-
Notifications
You must be signed in to change notification settings - Fork 972
x86_64 interrupt handling #499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The ELF entry address should be at offset 0x18. If it is not, then that must be adjusted to where it is. The entry address is the interrupt handler |
|
Thanks for that hint, i'm currently trying to figure out why my dissasmbly doesn't match what i see in the debugger. |
|
Offset is now correct, the interrupt handler is called correctly, but there is still some page fault in the kernel and the page fault handler itself faults, leading to a triple fault. I'll look into this later. |
|
Now i know, why the kernel relocation led to a page fault, after writing to 0x81000. |
|
That's good work. The relocation was being done because ELF had placed the text section ahead of where it should be, use You should send an email to [email protected] asking for a chat invite from the address you want to use, we do discussion of internals there. |
|
Oh thanks, i'll do that immediately. I think the current kernel is too big to fit into low memory, which provides us at most 512KiB continuous Memory, and only after overriding the BIOS IVT and BDA and our Boot Sector 0x000000 - 0x0004FF (reserved) used by BIOS, do not override until the bios is no more needed kernel needs 517KiB, 394KiB after stripping this is in total (assuming 1KiB stack and 1KiB Memory Map) 408 KiB, after striping the kernel (i don't know if it boots without debug information, and where all the sections land) and i don't believe the kernel is about to shrink, so we need to think about restructuring the boot process. enabling the A20-Line earlier should leave us with enough memory to keep going (14MiB) |
|
I agree, I wish in both 32-bit and 64-bit versions that we loaded at 1 MB. We could feasibly get into unreal mode and do a bios read of 256 KB at a time, then copy it using unreal mode to higher memory. This would be easier than switching back and forth between protected mode, I believe. OSDev has an example that fits in a bootloader: http://wiki.osdev.org/Unreal_Mode |
|
Awesome stuff, @Roxxik! |
|
I haven't considered the memory addressing in real mode. without protected mode we can't get above 1MiB. I'd ditch this branch and reopen another one, first refactoring i386 to use Unreal Mode, to have a already working example and afterwards going to x86_64 and implementing the same thing |
|
Found a linker script/linker command combo that will make the 64-bit elf look the same as the 32-bit elf, will try that |
|
No need to relocate anymore |
|
the kernel is still pretty big for low memory.... i'd like to load the kernel immediately to higher memory |
|
Understood, but it will allow me to fix other problems with x86_64 while you work on the unreal mode loader |
|
I am compiling a 480KB kernel.bin, just small enough to fit in 0x00007E00 to 0x0007FFFF range it is loaded in |
|
I'd close this one after #500 is merged, because it contains the same changes as this branch |
|
I think this can be closed after merging #500 |
I don't know why there was kernel relocation code. on i386 there is none. And the relocation code as it was did quite some garbage. That's why i removed it.
It moved the memory from kernel_file + 0xB000 to kernel_file, so overwrote the kernel, and afterwards cleared 0xB000 Bytes from the end of the - now overwritten - kernel. And this memory is taken from 0x80000+ where there could be some parts from EBDA, which could have led to the Page Fault. Tried to move the kernel to some higher address(1MB+) and it worked, but i don't know if this memory is used elsewhere, and i don't see the purpose in moving the kernel. If this is needed for something and someone knows where to place the kernel, i'd be happy to put the code back.
Where does this MagicValue(tm) 0x18 come from? in
It works on i386 but on x86_64 it points in the midst of zeroed memory
Interrupts are working now, the page fault experienced before was due to writing to protected lower memory (my theory, see above) and the kernel exception handler wasn't yet set up, which led to a triple fault.
tl;dr: We have interrupts, but I don't know where the kernel interrupt handler lives, so we can't do much with those interrupts.