Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Kernel/Kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ void PrintKernelInt(int num) {
}

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.

char *vidptr = (char*)0xb8000;
int offset = (line * 80 + col) * 2;
for (int k = 0; str[k] != '\0'; k++) {
Expand Down
2 changes: 1 addition & 1 deletion Kernel/Syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ uint64_t SyscallHandler(uint64_t syscall_num, uint64_t arg1, uint64_t arg2, uint

void SyscallInit(void) {
// Install syscall interrupt (0x80)
IdtSetGate(0x80, (uint64_t)SyscallEntry, SYSCALL_INTERRUPT_VECTOR, IDT_INTERRUPT_GATE_KERNEL);
IdtSetGate(0x80, (uint64_t)SyscallEntry, SYSCALL_SEGMENT_SELECTOR, IDT_INTERRUPT_GATE_KERNEL);
}
4 changes: 3 additions & 1 deletion Kernel/Syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
#define SYS_WRITE 2
#define SYS_READ 3
#define SYS_GETPID 4
#define SYSCALL_INTERRUPT_VECTOR 0x08
#define SYSCALL_INTERRUPT_VECTOR 0x80
#define IDT_INTERRUPT_GATE_KERNEL 0x8E
#define SYSCALL_SEGMENT_SELECTOR 0x08
#define MAX_SYSCALL_BUFFER_SIZE 4096
// System call handler
void SyscallInit(void);
uint64_t SyscallHandler(uint64_t syscall_num, uint64_t arg1, uint64_t arg2, uint64_t arg3);
Expand Down