Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
IDT doesn't work when part of the .data section gets loaded above 0xa0000. I am using GRUB. I have set up my own GDT. Source code here.
Changing line 6 of kernel.ld from 0x80000 to anything above 0x9c160 will cause the CPU to jump to 0xe05b on "int $3" instead of the correct interrupt handler. I tried linking the kernel way higher (at 4M and 100M) and it doesn't work as well.
OUTPUT_ARCH(i386)
ENTRY(_start)
SECTIONS
{
. = 0x80000; // Changing to anything above 0x9c160 will cause part of the .data section to go above 0xa0000.
.text : { *(.multiboot) *(.text) }
.data ALIGN(4096) : { *(.data .rodata*) }
.bss ALIGN(4096) : { *(.bss) }
}
I imagine 0xe05b is a GRUB interrupt handler. I want to know if that is an issue with my linker script, or if I am missing something with the GRUB setup. Also, I would like to know where I can learn more about linking the kernel/linkers in general.
f000:e05b is indicative your kernel triple faulted and returned back to real mode. You should be using . = 0x100000; in your linker script as the multiboot spec doesn't actually say it will support loading anywhere else except at 0x100000 .
I had a chance to look at the code. It will fault on your interrupts because the IDT descriptors have been built incorrectly in make_interrupt_gate. You have:
MichaelPetch wrote:I had a chance to look at the code. It will fault on your interrupts because the IDT descriptors have been built incorrectly in make_interrupt_gate.
Indeed, that was the case. Thank you very much for this and the previous reply.