Converting higher half bootloader to simple (not higher half

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.
Post Reply
User avatar
Bonfra
Member
Member
Posts: 270
Joined: Wed Feb 19, 2020 1:08 pm
Libera.chat IRC: Bonfra
Location: Italy

Converting higher half bootloader to simple (not higher half

Post 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?
Regards, Bonfra.
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: Converting higher half bootloader to simple (not higher

Post 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.
User avatar
Bonfra
Member
Member
Posts: 270
Joined: Wed Feb 19, 2020 1:08 pm
Libera.chat IRC: Bonfra
Location: Italy

Re: Converting higher half bootloader to simple (not higher

Post 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?
Regards, Bonfra.
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: Converting higher half bootloader to simple (not higher

Post 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.
FranchuFranchu
Posts: 8
Joined: Fri Jan 31, 2020 7:28 pm

Re: Converting higher half bootloader to simple (not higher

Post 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.
Post Reply