Page 1 of 1

How to load variable size stage2 bootloader ?

Posted: Tue Jan 01, 2013 11:50 am
by dnyaneshgate
Hello All,

I just stated to write bootloader from scratch and I am completely beginner in writing bootloader.
I have implemented a stage1 bootloader which loads stage2 in memory.
But I am stuck at a point where, if my stage2 bootloader varies in size, then I have to change no of sectors to read in stage1.

My question is, How can I determine no of sectors to read to load complete stage2 in memory programmatically?
I am using an unformated floppy image for booting and bochs for emulating.

Is I have to use FAT/EXT formated disk image?
How does grub loads stage2 from unformated floppy image?

Here is my stage1.asm.

Any help will be appreciated.
Thank You.

Re: How to load variable size stage2 bootloader ?

Posted: Tue Jan 01, 2013 2:30 pm
by egos
dnyaneshgate wrote:My question is, How can I determine no of sectors to read to load complete stage2 in memory programmatically?
I am using an unformated floppy image for booting and bochs for emulating.
If you will use formatted image you can use file size field. It's more right way.
How does grub loads stage2 from unformated floppy image?
GRUB holds all required info in boot sector and in first sector of stage2.

Re: How to load variable size stage2 bootloader ?

Posted: Thu Jan 03, 2013 4:21 pm
by Yoda
dnyaneshgate wrote:My question is, How can I determine no of sectors to read to load complete stage2 in memory programmatically?
I am using an unformated floppy image for booting and bochs for emulating.
In my Boot Tools I described how you can build in one click the unformatted Bochs bootable image, where the bootloader reads exactly the necessary number of sectors. See the "direct.bin" description.