Page 1 of 1

Converting higher half bootloader to simple (not higher half

Posted: Sat Oct 24, 2020 4:41 pm
by Bonfra
I've wanted to write my own bootloader so I started researching and found this repository which I think is very good for studying as it seems very complete (at least the bootloader part that is what I'm interested in). After some tweaks here and there I've managed to adapt and rewrite it to my own needs but this specific bootloader was designed to run a higher half kernel, instead I just want a simple kernel wich runs at 0x100000. This file contains all the memory layout that the bootloader uses to load the kernel, I tried to play with these values but I failed. I think that I've to adjust only the Mem.Kernel.* but at this point I'm not really sure. What do you think about it?

Re: Converting higher half bootloader to simple (not higher

Posted: Sat Oct 24, 2020 5:13 pm
by Octocontrabass
Bonfra wrote:I've wanted to write my own bootloader
I think copying someone else's code isn't really writing your own bootloader.
Bonfra wrote:this specific bootloader was designed to run a higher half kernel
No it wasn't.
Bonfra wrote:I think that I've to adjust only the Mem.Kernel.* but at this point I'm not really sure. What do you think about it?
I think you would have to modify the code that sets up the page tables, since it makes some assumptions about the memory layout that aren't valid if the kernel is loaded at a different address.

Re: Converting higher half bootloader to simple (not higher

Posted: Sat Oct 24, 2020 5:26 pm
by Bonfra
Octocontrabass wrote:I think copying someone else's code isn't really writing your own bootloader.
Guess is not, now I'm just learning how bootloader works to then write my own and this one seemed to be good.
Octocontrabass wrote:I think you would have to modify the code that sets up the page tables, since it makes some assumptions about the memory layout that aren't valid if the kernel is loaded at a different address.
Really dumb question, I'm a beginner, how should i modify it? Or at least wich part? Also which address do I have to modify with what in mem.inc?

Re: Converting higher half bootloader to simple (not higher

Posted: Sat Oct 24, 2020 5:56 pm
by Octocontrabass
If you want to learn how to write a bootloader, you should probably start with something simpler so you can practice x86 assembly.

If you don't want to learn how to write a bootloader, use GRUB.

Re: Converting higher half bootloader to simple (not higher

Posted: Sat Oct 24, 2020 7:13 pm
by FranchuFranchu
I've read the code of the repo and it seems that the kernel's code is at 0x00301000 (not exactly higher-half). Also, mem.inc isn't the only thing you would want to change. You also want to change the linker script of MonkOS (kernel/kernel.ld) so that it relocates all symbols to 0x100000 instead of 0x00301000.