Bootloader issues #2

Open
opened 2024-09-18 22:41:16 -07:00 by gbowne1 · 0 comments
Owner

Some considerations for improving the current boot.asm

  • enabling the A20 line explicitly. This should allow better access to memory above 1MB.

  • obtaining a memory map using BIOS interrupt 0x15, function 0xE820 before switching to protected mode.
    This can be useful for the kernel to know about available memory.

  • We have a stack in protected mode. However, I think we should also consider setting up a small stack in real mode as well for some safety.

  • Error handling BIOS calls like checking after disk read operations (int 0x13). If the carry flag is set after the interrupt, it indicates an error

  • Consider using a smaller buffer size for reading sectors. Might create a potential stack overflow risk due to large sector count (64).

  • The kernel stack size of 16 KB might be sufficient for a simple kernel, but for more complex kernels,
    you might need to increase it to avoid stack overflows. The kernel stack is defined in the .bss section.

  • Might try using defined constants

  • In the GDT, the GDT limits are set to 0xFFFF, which may not be sufficient for larger kernels.
    The base addresses for the code and data segments are set to 0x0000, which may cause issues.

  • The ES, FS, and GS segment registers are set to DATA_SEG, but their usage is not clear.

  • The kmain function is called without checking if it exists or is properly defined.

  • The cli and hlt instructions are used without ensuring interrupts are properly set up.

  • The transition to 32-bit mode is not explicitly verified.

  • Multiboot compliance?

  • you might want to add a null descriptor at the end of the GDT for consistency in gdt_end: dq 0x0000000000000000

  • In the kernel part, add some buffer overflow protection, as in, check if ebx exceeds the screen dimensions before writing.

  • Consider using a loop counter instead of jumping to the start of the string repeatedly.

Some considerations for improving the current boot.asm - [ ] enabling the A20 line explicitly. This should allow better access to memory above 1MB. - [ ] obtaining a memory map using BIOS interrupt 0x15, function 0xE820 before switching to protected mode. This can be useful for the kernel to know about available memory. - [ ] We have a stack in protected mode. However, I think we should also consider setting up a small stack in real mode as well for some safety. - [ ] Error handling BIOS calls like checking after disk read operations (int 0x13). If the carry flag is set after the interrupt, it indicates an error - [ ] Consider using a smaller buffer size for reading sectors. Might create a potential stack overflow risk due to large sector count (64). - [ ] The kernel stack size of 16 KB might be sufficient for a simple kernel, but for more complex kernels, you might need to increase it to avoid stack overflows. The kernel stack is defined in the .bss section. - [ ] Might try using defined constants - [ ] In the GDT, the GDT limits are set to 0xFFFF, which may not be sufficient for larger kernels. The base addresses for the code and data segments are set to 0x0000, which may cause issues. - [ ] The ES, FS, and GS segment registers are set to DATA_SEG, but their usage is not clear. - [ ] The kmain function is called without checking if it exists or is properly defined. - [ ] The cli and hlt instructions are used without ensuring interrupts are properly set up. - [ ] The transition to 32-bit mode is not explicitly verified. - [ ] Multiboot compliance? - [ ] you might want to add a null descriptor at the end of the GDT for consistency in gdt_end: dq 0x0000000000000000 - [ ] In the kernel part, add some buffer overflow protection, as in, check if ebx exceeds the screen dimensions before writing. - [ ] Consider using a loop counter instead of jumping to the start of the string repeatedly.
gbowne1 added this to the Bootloader milestone 2024-09-18 22:41:16 -07:00
gbowne1 added this to the ClassicOS project 2024-09-18 22:41:16 -07:00
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: gbowne1/ClassicOS#2
No description provided.