How to load a higher-half kernel from a custom bootloader
Posted: Thu Oct 06, 2022 12:12 am
I've been working with FASM on a bootloader/kernel/not really sure based off of Xv6 code with some modifications, since I want to have total control over my software stack (that is - avoiding GRUB or any other bootloader). As of right now, I've got a bootsector that enables A20, protected mode, and so on, before loading some arbitrary length binary and jumping to it. Currently, it loads the arbitrary binary to 0x00010000, but I'd like to load it to somewhere in the higher half - preferably 0xC0010000 or 0x80010000, but neither of them work.
I don't know enough about the i386's memory addressing to know where my problem is - I'd imagine it's to do with physical vs. virtual addressing, but I don't know how I'd be able to fix that. I've checked sources like Xv6 to see how it's done, but I can't see anything that's done significantly differently (I don't use ELF files but I don't think that's the problem). I've also checked the page on higher-half kernels, but I still can't figure out what I'm doing (or not doing) wrong.
I've published my code at https://github.com/stepcity/crux, with comments in both files about where I've been trying to modify the addresses, but any changes I make prevent it from loading the binary.
Does anyone have any advice? If so, thanks!
I don't know enough about the i386's memory addressing to know where my problem is - I'd imagine it's to do with physical vs. virtual addressing, but I don't know how I'd be able to fix that. I've checked sources like Xv6 to see how it's done, but I can't see anything that's done significantly differently (I don't use ELF files but I don't think that's the problem). I've also checked the page on higher-half kernels, but I still can't figure out what I'm doing (or not doing) wrong.
I've published my code at https://github.com/stepcity/crux, with comments in both files about where I've been trying to modify the addresses, but any changes I make prevent it from loading the binary.
Does anyone have any advice? If so, thanks!