Page 2 of 2

Re: Pass arguments (bootloader)

Posted: Sun Jan 03, 2016 2:28 am
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 ?

Re: [SOLVED] Pass arguments (bootloader)

Posted: Sun Jan 03, 2016 3:48 am
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 :)