How to load variable size stage2 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.
Post Reply
dnyaneshgate
Posts: 5
Joined: Fri Sep 23, 2011 3:15 pm

How to load variable size stage2 bootloader ?

Post 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.
Attachments
stage1.asm
(1.63 KiB) Downloaded 38 times
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: How to load variable size stage2 bootloader ?

Post 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.
If you have seen bad English in my words, tell me what's wrong, please.
User avatar
Yoda
Member
Member
Posts: 255
Joined: Tue Mar 09, 2010 8:57 am
Location: Moscow, Russia

Re: How to load variable size stage2 bootloader ?

Post 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.
Yet Other Developer of Architecture.
OS Boot Tools.
Russian national OSDev forum.
Post Reply