I am following James Molloy's Kernel tutorial, which is in turn based on Brandon Friesen's Kernel tutorial. Looking at old posts in this forum, it seems these are popular tutorials.
Unlike James, I opted to use QEMU (with GDB) instead of Bochs. Apart from the makefile (where I redirected the kernel elf to QEMU instead of Bochs) my code is essentially identical to his.
However, I cannot get the GDT part of the code/tutorial to work. Specifically, the gdt_flush assembly:
Code: Select all
global gdt_flush
gdt_flush:
mov eax, [esp+4]
lgdt [eax]
mov ax, 0x10
mov ds, ax ; Causes a triple fault
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
jmp 0x08:.flush
.flush:
ret
Code: Select all
move ds, ax
I've googled around and some of the answers I have seen mention something about this instruction not being allowed in protected mode. What does that mean? Is it the cause of the fault? If it is, what can I do to address it? I suspect it is due to my use of QEMU (and GDB) rather than Bochs as otherwise the tutorial would have mentioned (and addressed) it.
Edit:
Link to my code