[SOLVED] Pass arguments (bootloader)

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.
Tinei
Posts: 7
Joined: Sat Jan 02, 2016 11:31 am
Location: France

Re: Pass arguments (bootloader)

Post by Tinei »

Yes it works, thank you. I applied that for my bootloader and it works now :)
But why to load the kernel at 0x7E00 ?
User avatar
iocoder
Member
Member
Posts: 208
Joined: Sun Oct 18, 2009 5:47 pm
Libera.chat IRC: iocoder
Location: Alexandria, Egypt | Ottawa, Canada
Contact:

Re: [SOLVED] Pass arguments (bootloader)

Post by iocoder »

Tinei wrote:Yes it works, thank you. I applied that for my bootloader and it works now :)
But why to load the kernel at 0x7E00 ?
Because you have linked the kernel and the bootloader together as one single program.

In my point of view, you should put your kernel in a separate place so that the design can be clear. However, there is no harm in loading stage2 of the bootloader to 0x7E00, since you link stage1 and stage2 together in your makefile.

Also try to pass parameters by stack, and see why it doesn't work. It should work well. In C, don't pop the stack, but either add two integer parameters to your _start, so the signature can be something like this:

Code: Select all

_start(int low_memory, int high_memory);
You have also the option to pass parameters by registers...

BTW, if you want to load your kernel/stage2/whatever program you link with stage1 to another memory location than 0x7E00, you can divide your program into to sections (for example .text_stage0 and .text_whatevaa) and tell your linker that .text_stage0 will be at 0x7C00 and .text_whatevaa will be at wherevaaa. It's all about configuring the linker/toolchain correctly to achieve whatevaaa you like.

Good luck :)
Post Reply