Page 1 of 1

Where to put stage 2?

Posted: Fri Jul 21, 2017 9:25 am
by randell23
Hello. I've just finished developing the ISO9660 stage 1 bootloader. But i don't know where to put stage 2.
Stage 1 locates at 0x0000:0x7c00 - 0x0000:0x8400.
So, where is the optimal place to put the stage 2 bootloader?

Re: Where to put stage 2?

Posted: Fri Jul 21, 2017 10:35 am
by AJ
Hi,

Short answer: wherever you like.

If it's a normal sized stage 2, why not place in in RAM immediately after stage 1? You have all that space up to the start of the BDA. If your stage 2 is more like a kernel, you will want somewhere above 1MiB.

The wiki article [wiki]Memory Map (x86)[/wiki] tells you of a few areas that are guaranteed free. You are also generally safe in the area from 1MiB - 14MiB if the RAM exists and you don't intend to place your kernel there. It's also worth generating a system memory map early on.

Cheers,
Adam

Re: Where to put stage 2?

Posted: Fri Jul 21, 2017 10:56 am
by randell23
AJ wrote:Hi,

Short answer: wherever you like.

If it's a normal sized stage 2, why not place in in RAM immediately after stage 1? You have all that space up to the start of the BDA. If your stage 2 is more like a kernel, you will want somewhere above 1MiB.

The wiki article [wiki]Memory Map (x86)[/wiki] tells you of a few areas that are guaranteed free. You are also generally safe in the area from 1MiB - 14MiB if the RAM exists and you don't intend to place your kernel there. It's also worth generating a system memory map early on.

Cheers,
Adam
OK. Thanks for the answer.