FAT: Where can I find info?

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
Berry

FAT: Where can I find info?

Post by Berry »

Hello! I'm writing my bootloader. Currently it only checks to see if >386 is present. I'm about to add pmode, and then I'm going to write the (which I think is) most difficult part: the FAT. Sounds scary to me! I can't find any good information on FAT, only things as the layout... But NOT how I can calculate where the program is... Any site/information for me?

/Berry
DruG5t0r3

RE:FAT: Where can I find info?

Post by DruG5t0r3 »

This was asked before and will continue to be

a nice little example I use is http://alexfru.chat.ru/epm.html
get bootload.zip ...I think thats the name.
TheUbu

RE:FAT: Where can I find info?

Post by TheUbu »

Berry,

There should be quite a few good resources returned if you query google for fat12. But to make your life easier you can for now just to get a feel for things put your kernel onto fixed sectors of your floppy and go from there. Also have you thought about binary format that you will be using for your kernel.. There are many out there personal I prefer ELF32 and use it for just about every os projected I've started. Along with your binary format will also come decoding it so be prepared to do all that in your boot loader.


-Christopher
Berry

RE:FAT: Where can I find info?

Post by Berry »

[quote]Along with your binary format will also come decoding it so be prepared to do all that in your boot loader.[/quote]

ehhh? I thought that I just could load the kernel to memory and jmp to that adress to execute it? So it stood in the few tutorials and posts I read...
DruG5t0r3

RE:FAT: Where can I find info?

Post by DruG5t0r3 »

meaning that the code you load from the kernel is already configured to have an offset. So you need to load the code in consideration of that.

example : code from boot sector loads at 0x7c00 so every jmps offsets from it...etc etc
ASHLEY4

RE:FAT: Where can I find info?

Post by ASHLEY4 »

In your boot loader (stage1 thats loaded at 0x7c00 by bios) you can  load your 2stage/kernel by one of two ways.

1) loaded a number of sector's from the disk(This has to be at a set place on disk and needs a program to put it on the floppy).

2)impement fat12, and give it,(eg: kernel.exe) a file name to look for and load(this can be put on the disk from, eg: windows,just  like a normal program.)

ASHLEY4.
Berry

RE:FAT: Where can I find info?

Post by Berry »

And I like to go way 2! :) But I cant find any good info... What's the use of the 2 FAT's and what's the use of the root part? I get confused :S
ASHLEY4

RE:FAT: Where can I find info?

Post by ASHLEY4 »

You serch the root dir for the name of kernel name ,This must be 11 digits long,eg:
"kernel  exe" and the "." is removd.
You starts at from the begin of the root dir,if not found add 20h and so on to the end of the root dir,then you print "Error can not find file" But if you find file name you save the current offset.

ASHLEY4.
Berry

RE:FAT: Where can I find info?

Post by Berry »

ok that clears up a lot :) But 20h is the start of the root dir, not 200h? and you say save the offset, is the offset saved by the file? Or do I have to calculate this? And whatfor are the 2 FATs then?
Moose

RE:FAT: Where can I find info?

Post by Moose »

Two fats are used for backup.
One is the primary fat, the other is a backup of the primary fat if it screws up.

The offset is the record inside the fat that says where on the disk the file is. You need to know this
JAAman

RE:FAT: Where can I find info?

Post by JAAman »

the root dir is where all files are located

each file takes 32 bytes(0x20 hex) the first 11 are the filename(8chars) then the extention(3chars)

search the dir for the filename (easily done with CMPSB) then locate the starting cluster# (in the 32byte dir entry)

use this cluster as offset into the FAT table so multiply by bytes/per fat entry(1 1/2 for FAT12, 2 for FAT16, 4 for FAT32) then use this to find where in the FAT table to find the entry

also multiply this by the sectors/cluster and add the ending sector of the root dir to it to find the starting sector -- read (sectors/cluster) number of sectors

check the FAT entry if it is FFF (for FAT12) then that is the last cluster in the file, else the FAT entry is the next cluster number

on FAT12&16 the second(backup) FAT was almost ignored,it was updated exactly the same time and therefore would be automatically corrupted anytime the FAT was but FAT32 changed the way it was updated and so it became usefull for backup purposes
Post Reply