Loader Stages
Loader Stages
hi. i started work on my loader and I have now a second stage which halts in pmode i do purposely because i can not have my second stage read floppy disk. it does nothing, but that is not my question. my question is why do people load their stage 2 from disk rather than dd'ing both stage 1 and stage 2 to the front of disk right behind each other and then load the kernel from disk? what is the benefit of loading the stage 2 from disk too?
Re: Loader Stages
are you asking about; why dont we place a secoundstage bootloader after the bootloader ( sector 2 ,3 ... ) ?
or what do you mean ?
KMT DK
or what do you mean ?
KMT DK
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
Re: Loader Stages
no, I understand that. what I mean is why read the stage 2 from disk rather than write it to the disk to begin with? what benefit is it to read it off disk using stage 1 v. just hopping to it because it already exists on disk behind stage 1? so i do:
dd if=stage1 of=/dev/fd0 bs=512 count=1
dd if=stage2 of=/dev/fd0 bs=512 seek=1
i don't have to read stage 2 from disk, i jmp to it.
dd if=stage1 of=/dev/fd0 bs=512 count=1
dd if=stage2 of=/dev/fd0 bs=512 seek=1
i don't have to read stage 2 from disk, i jmp to it.
- Combuster
- Member

- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Loader Stages
The reason is to maintain the file system. Stage 2 is not required constant in size and if it grows it can start overwriting the FAT tables. It also makes life much easier with tools that do not allow you to set the number of reserved sectors. (and there are quite a few of those)
Having a file system allows you to tell the size of the second stage, and to be very dynamic about what programs/drivers you include. GRUB floppies are very handy because all you need to do is overwrite the kernel file instead of rewriting the whole disk.
In any case you *will* need to read stage 2 from disk and jump to it because the BIOS doesn't do that for you, independent of where you put it...
Having a file system allows you to tell the size of the second stage, and to be very dynamic about what programs/drivers you include. GRUB floppies are very handy because all you need to do is overwrite the kernel file instead of rewriting the whole disk.
In any case you *will* need to read stage 2 from disk and jump to it because the BIOS doesn't do that for you, independent of where you put it...
Re: Loader Stages
that makes a lot of sense. i thought that if i keep my stage2 the same it is ok to write it to disk behind stage 1 but i see why it is benefits me to do it the other way. thanks you

