Tried running in bochs emulator, and it seems to be a bit more strict than qemu, so it caught some issues.
Here are issues that I spotted after trying bochs:
1) Data segment registers aren't set in boot.asm
This causes a crash when trying to read kernel code to 0x100000, since default segments don't allow using addresses larger than 0xFFFF. Fixed it by moving step2 code under load32 instead and using DATA_SEG instead of 0x00:
2) PIC interrupt remapping in kernel.asm missing ICW3 command
ICW1, ICW2, and ICW4 are currently sent, but ICW3 is skipped, which bochs doesn't like.
Fixed it just by copying code in the PIC page on OSDev (https://wiki.osdev.org/8259_PIC):
; Remap the master PIC
mov al, 00010001b ; ICW1: Start init sequence
out 0x20, al
mov al, 0x20 ; ICW2: Start at interrupt 0x20
out 0x21, al
mov al, 4 ; ICW3: Slave PIC IRQ line
out 0x21, al
mov al, 00000001b ; ICW4: Enable 8086 mode
out 0x21, al
3) tss struct is missing some fields
The ss1 and ssp fields aren't included in tss.h. These fields aren't used directly, but they affect the size of the struct, which is referenced in the GDT limit field. The error happens since bochs expects that size field to be at least 104 bytes.
Tried running in bochs emulator, and it seems to be a bit more strict than qemu, so it caught some issues. Here are issues that I spotted after trying bochs:
1) Data segment registers aren't set in
boot.asm
This causes a crash when trying to read kernel code to 0x100000, since default segments don't allow using addresses larger than 0xFFFF. Fixed it by moving
step2
code underload32
instead and usingDATA_SEG
instead of0x00
:2) PIC interrupt remapping in
kernel.asm
missing ICW3 commandICW1, ICW2, and ICW4 are currently sent, but ICW3 is skipped, which bochs doesn't like. Fixed it just by copying code in the PIC page on OSDev (https://wiki.osdev.org/8259_PIC):
3)
tss
struct is missing some fieldsThe
ss1
andssp
fields aren't included intss.h
. These fields aren't used directly, but they affect the size of the struct, which is referenced in the GDT limit field. The error happens since bochs expects that size field to be at least 104 bytes.Fixed by adding the 2 missing fields: