Skip to content

Conversation

assembler-0
Copy link
Owner

@assembler-0 assembler-0 commented Jul 8, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved boundary checks to prevent display issues when printing at specific screen lines.
  • New Features

    • Added new constants for segment selector and maximum syscall buffer size.
  • Refactor

    • Updated system call interrupt vector and segment selector values for improved compatibility.

@coderabbitai
Copy link

coderabbitai bot commented Jul 8, 2025

Walkthrough

The changes introduce a boundary check in the kernel's printing function to prevent line overflow, update the syscall interrupt vector and segment selector usage, and add new constants for syscall configuration, including a buffer size limit. No function signatures or exported interfaces were altered.

Changes

File(s) Change Summary
Kernel/Kernel.c Added boundary check in PrintKernelAt to ensure CurrentLine does not exceed 24.
Kernel/Syscall.c Changed third argument in IdtSetGate from interrupt vector to segment selector in SyscallInit.
Kernel/Syscall.h Changed syscall interrupt vector to 0x80; added segment selector and buffer size constants.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Kernel
    participant Syscall
    participant IDT

    User->>Kernel: Trigger syscall (int 0x80)
    Kernel->>IDT: Use SYSCALL_SEGMENT_SELECTOR (0x08) for gate setup
    Kernel->>Syscall: Handle syscall with buffer size limit (4096 bytes)
    Syscall-->>User: Return result
Loading

Possibly related PRs

  • Development #2: Introduces the IdtSetGate function and implements syscall initialization, directly related to the changes in syscall vector and segment selector usage.

Poem

A hop and a skip, the kernel’s in line,
No more overflow, things work just fine.
Syscalls now leap with a segment selector,
0x80’s the vector—couldn’t be better!
With buffers defined and boundaries tight,
The rabbit declares: “All systems are right!”
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2952332 and c65033b.

📒 Files selected for processing (3)
  • Kernel/Kernel.c (1 hunks)
  • Kernel/Syscall.c (1 hunks)
  • Kernel/Syscall.h (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: assembler-0
PR: assembler-0/VoidFrame#2
File: Kernel/Syscall.c:44-44
Timestamp: 2025-07-08T00:36:50.290Z
Learning: In IdtSetGate function calls, the parameters are: (interrupt_vector, handler_address, selector, flags). The interrupt vector (like 0x80) is the first argument, and the selector (like 0x08 for kernel code segment) is the third argument.
Kernel/Syscall.c (1)
Learnt from: assembler-0
PR: assembler-0/VoidFrame#2
File: Kernel/Syscall.c:44-44
Timestamp: 2025-07-08T00:36:50.290Z
Learning: In IdtSetGate function calls, the parameters are: (interrupt_vector, handler_address, selector, flags). The interrupt vector (like 0x80) is the first argument, and the selector (like 0x08 for kernel code segment) is the third argument.
Kernel/Syscall.h (1)
Learnt from: assembler-0
PR: assembler-0/VoidFrame#2
File: Kernel/Syscall.c:44-44
Timestamp: 2025-07-08T00:36:50.290Z
Learning: In IdtSetGate function calls, the parameters are: (interrupt_vector, handler_address, selector, flags). The interrupt vector (like 0x80) is the first argument, and the selector (like 0x08 for kernel code segment) is the third argument.
🧬 Code Graph Analysis (1)
Kernel/Syscall.c (1)
Kernel/Idt.h (1)
  • IdtSetGate (25-25)
🔇 Additional comments (3)
Kernel/Syscall.c (1)

47-47: LGTM! Correct parameter usage in IdtSetGate.

The change from SYSCALL_INTERRUPT_VECTOR to SYSCALL_SEGMENT_SELECTOR properly uses the segment selector (0x08) as the third parameter, while maintaining the interrupt vector (0x80) as the first parameter. This aligns with the correct IdtSetGate parameter order.

Kernel/Syscall.h (2)

11-11: LGTM! Standard syscall interrupt vector.

Changing from 0x08 to 0x80 aligns with the standard Linux syscall interrupt vector, which is the conventional choice for system calls in x86 systems.


13-14: LGTM! Well-defined syscall constants.

The addition of SYSCALL_SEGMENT_SELECTOR (0x08) and MAX_SYSCALL_BUFFER_SIZE (4096) provides:

  • Clear separation between interrupt vector and segment selector concepts
  • Reasonable buffer size limit for syscall operations
  • Better code maintainability through named constants

}

void PrintKernelAt(const char *str, int line, int col) {
if (CurrentLine >= 25) CurrentLine = 24;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix logical inconsistency in boundary check.

The boundary check modifies the global CurrentLine variable, but the PrintKernelAt function uses the line parameter for positioning (line 104). This creates an inconsistency where the function doesn't use CurrentLine for its core functionality but still modifies it.

Consider either:

  1. Removing the boundary check if it's not needed for this function's operation
  2. Applying the boundary check to the line parameter instead
  3. Clarifying the intended behavior of this global state modification
-    if (CurrentLine >= 25) CurrentLine = 24;
+    // Remove if CurrentLine isn't used for positioning in this function
+    // OR apply boundary check to the line parameter:
+    // if (line >= 25) line = 24;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (CurrentLine >= 25) CurrentLine = 24;
// Remove if CurrentLine isn't used for positioning in this function
// OR apply boundary check to the line parameter:
// if (line >= 25) line = 24;
🤖 Prompt for AI Agents
In Kernel/Kernel.c at line 102, the boundary check currently modifies the global
variable CurrentLine, but the function PrintKernelAt uses the local parameter
line for positioning, causing inconsistency. To fix this, apply the boundary
check to the line parameter instead of CurrentLine, ensuring the function's
logic aligns with its parameter usage and avoids unintended side effects on the
global state.

@assembler-0 assembler-0 merged commit b9d12eb into main Jul 8, 2025
1 check passed
This was referenced Jul 8, 2025
@coderabbitai coderabbitai bot mentioned this pull request Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant