FAT direct loading

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
extremecoder
Member
Member
Posts: 59
Joined: Tue May 23, 2006 11:00 pm

FAT direct loading

Post 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 ?
User avatar
NickJohnson
Member
Member
Posts: 1249
Joined: Tue Mar 24, 2009 8:11 pm
Location: Sunnyvale, California

Re: FAT direct loading

Post 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).
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

Re: FAT direct loading

Post 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.
User avatar
kop99
Member
Member
Posts: 120
Joined: Fri May 15, 2009 2:58 am

Re: FAT direct loading

Post by kop99 »

extremecoder, the good way to read stage2.bin file is that you implement reading of fat FS.
extremecoder
Member
Member
Posts: 59
Joined: Tue May 23, 2006 11:00 pm

Re: FAT direct loading

Post 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 ?
User avatar
kop99
Member
Member
Posts: 120
Joined: Fri May 15, 2009 2:58 am

Re: FAT direct loading

Post 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.
extremecoder
Member
Member
Posts: 59
Joined: Tue May 23, 2006 11:00 pm

Re: FAT direct loading

Post 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 ?
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: FAT direct loading

Post by Troy Martin »

Uhh, floppies use FAT12, not FAT16.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

Re: FAT direct loading

Post 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.
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: FAT direct loading

Post 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
If you have seen bad English in my words, tell me what's wrong, please.
User avatar
VolTeK
Member
Member
Posts: 815
Joined: Sat Nov 15, 2008 2:37 pm
Location: The Fire Nation

Re: FAT direct loading

Post by VolTeK »

you do not know how many questions you have answered for me :)
thanks you for posting that
Post Reply