Page 1 of 1
Question about second stage of bootloader.
Posted: Sun Mar 17, 2013 11:24 pm
by dash
Hi,
I am a new learning OS development,and got confused with one problem. Here is the detail:
step 1.wrote a boot program(stage1) and copy it to the first sector of a floppy disk using debug command(-w 100 0 0 1).
step 2.tried to use "copy stage2.sys A:\stage2.sys" to copy my stage2 program to the disk
but at the second step,my OS just complained that the file system of the floppy disk could not be recognized.I really get confused with this. My OS is windows 7.Seems like the behavior of copy of the bootloader(stage1) has crashed the FAT fs of the floppy ,but how could this happen?
Thanks in advance!
Re: Question about second stage of bootloader.
Posted: Sun Mar 17, 2013 11:47 pm
by Brendan
Hi,
dash wrote:Seems like the behavior of copy of the bootloader(stage1) has crashed the FAT fs of the floppy ,but how could this happen?
The first sector of the floppy disk (that you overwrote) is also the first sector of the FAT file system and contains
important information needed to understand the FAT file system.
Cheers,
Brendan
Re: Question about second stage of bootloader.
Posted: Mon Mar 18, 2013 3:33 pm
by Mikemk
It would seem you overwrote the BIOS parameter block...
Re: Question about second stage of bootloader.
Posted: Mon Mar 18, 2013 7:25 pm
by dash
I see~~~.yes,I forgot to put the BPB into my boot loader.but still there's a little strange.
the first time I put the BPB like this,which still caused the same problem:
-------------------------
Code: Select all
bpbOEM: DB "My OS " ;8 bytes
bpbBytesPerSector: DW 512
bpbSectorsPerCluster: DB 1
bpbReservedSectors: DW 1
bpbNumberOfFATs: DB 2
bpbRootEntries: DW 224
bpbTotalSectors: DW 2880
bpbMedia:DB 0xF0
bpbSectorsPerFAT: DW 9
bpbSectorsPerTrack: DW 18
bpbHeadsPerCylinder: DW 2
bpbHiddenSectors: DD 0
bpbTotalSectorsBig: DD 0
bsDriveNumber: DB 0
bsUnused: DB 0
bsExtBootSignature: DB 0x29
bsSerialNumber: DD 0xa0a1a2a3
bsVolumeLabel: DB "MOS FLOPPY "
bsFileSystem: DB "FAT12 "
--------------------------
and after I replaced
with
,the problme was fixed.(start is label of the first jmp instruction)
Is there any differences?
Re: Question about second stage of bootloader.
Posted: Tue Mar 19, 2013 12:35 am
by Combuster
dash wrote:and after I replaced
with
,the problme was fixed.(start is label of the first jmp instruction)
Is there any differences?
The first option isn't guaranteed to put the BPB at the right place (jmp + OEM must be 11 bytes), while the latter simply puts the BPB where it should regardless of what opcode the assembler put in for the jump.
Re: Question about second stage of bootloader.
Posted: Tue Mar 19, 2013 1:32 am
by dash
I understand.
Thank you all very much
Re: Question about second stage of bootloader.
Posted: Tue Mar 19, 2013 1:25 pm
by Mikemk
Also, some versions of windows require that the oem label be either blank or "MSWIN4.0" (It's 4, not 2, right?)