Page 1 of 1

FAT direct loading

Posted: Wed Jun 24, 2009 11:07 pm
by extremecoder
I am trying to load stage2 from a FAT formatted floppy .. these are the specs for the volume:

Bytes Per Sector = 512 bytes
Root Entries = 224
Sector Per Cluster = 1
Sector Per FAT = 2
Sector Per Track = 18
Total Sectors = 2880

All I did was copied stage1 into sector 0 and copied stage2 as a file into the floppy.

Now, theoratically, the data sector should start at 19.

so I loaded cl, 0x00 and ch, 0x01 ... but this seems to be not loading stage2.bin from the floppy .. i tried with other sector numbers and track numbers, but Failed...

I checked by mounting this floppy (/dev/fd0) under linux and the volume contains the file stage2.bin ... but stage2 is not loading .. any idea ?

Re: FAT direct loading

Posted: Wed Jun 24, 2009 11:22 pm
by NickJohnson
You seem to be assuming that the stage2.bin file is the only (or first) file there, and is not at all fragmented. Even if this is somehow the case for you, Murphy's law will pretty much make it impossible to get other people to run it correctly. You either need to somehow hardcode the starting block of stage2.bin into the stage 1 on installation (and make sure there is no fragmentation, so no rewriting stage2.bin ever), or properly parse the FAT fileystsem at stage 1 (it's not too hard to code).

Re: FAT direct loading

Posted: Wed Jun 24, 2009 11:29 pm
by salil_bhagurkar
I think there's a small mistake there. You cannot load cl with 0 for a floppy, since the sectors start from 1. Besides, the starting sector of the first cylinder is 18 (starting from 0). So, to get to sector 19, you need ch = 1 and cl = 2. This should get you to the 19th sector IMHO.

Re: FAT direct loading

Posted: Thu Jun 25, 2009 1:21 am
by kop99
extremecoder, the good way to read stage2.bin file is that you implement reading of fat FS.

Re: FAT direct loading

Posted: Thu Jun 25, 2009 1:57 am
by extremecoder
off course i am reading the Fatgen.pdf from Microsoft ... I tried many combinations (numbers) for track and sector number ... I calculated the RootDirSector, First Data Sector ... etc

I am trying this in VMWare and in Virtual Floppy Image ... will this make a difference ?

Re: FAT direct loading

Posted: Thu Jun 25, 2009 3:33 am
by kop99
I've implemented the fat fs in VMWare and harddisk img.
And there was no difference. Maybe there'll be no problem with virtual floppy img.

Re: FAT direct loading

Posted: Thu Jun 25, 2009 3:46 am
by extremecoder
I want to know whether the process of creating FAT16 Floppy is correct ... this is what I am doing.

1) Create a Blank Floppy Image in VMWare
2) format it with command: fdformat /dev/fd0
3) then use the command mkdosfs to create the DOS File System
4) writing the Stage1 bin into sector 0.

is the above step correct ?

Re: FAT direct loading

Posted: Thu Jun 25, 2009 9:42 am
by Troy Martin
Uhh, floppies use FAT12, not FAT16.

Re: FAT direct loading

Posted: Thu Jun 25, 2009 11:12 am
by salil_bhagurkar
Have you checked if your root directory exists at sector 19 in your floppy image? If you have not done that, then do it, or post the image you made here. I will do that for you. If you see the root directory there, then you have a problem in the int 13h parameters you are setting. If not, then the computation '19' is wrong.

Edit: And yes, if you are thinking that the data of stage2.bin starts at sector 19, then thats not true. Its the root directory there. In that root directory, you find the directory entry of stage2.bin and then locate its cluster.

Re: FAT direct loading

Posted: Fri Jun 26, 2009 2:57 am
by egos
Sector Per FAT = 2
???

salil_bhagurkar is right:
0 - disk boot loader
1-9 - FAT1
10-18 - FAT2
19-32 - root directory
33-2879 - file data area

Re: FAT direct loading

Posted: Fri Jun 26, 2009 3:11 am
by VolTeK
you do not know how many questions you have answered for me :)
thanks you for posting that