DRF
User
 Platinum Osdever
| Posts: 123 |   | Karma: 1
|
Re: Fat - 2004/10/28 16:31
Well you don't 'need' FAT. There are quite a few different file systems around or you could design and implement your own. So FAT isn't the only way to make an OS. Also my early testing kernels used direct sector addressing without FAT (tho that meant no easy read/write as eveything had to be compiled and put in certain locations by hand staticly mapped).
The FAT12 system is the most commonly used on floppy disks, it is fairly easy to implement though I haven't done any filesystem work in a while.
The bootloader must contain some basic information first (to be read by other computers) the basic information needed is: Disk Name, Reserved sectors (where the bootloader is) Root directory entrys and FAT table locations. (With this table you can read and write data to and from a floppy disk, so you could hide the kernel and bootloader within the hidden sectors and have the rest of the disk available for use like any other disk).
| Code: |
...
jmp main ; Jump to the start of the boot loader code
OEM_ID db "DFOS " ; 8 char sys ID
BytesPerSector dw 512 ; Sector size in bytes
SectorsPerCluster db 1 ; Sector per cluster
ReservedSectors dw 4 ; Reserved sectors (This I think for this should become 2 for the boot strap, was 1)
TotalFATs db 2 ; Number of fats
MaxRootEntries dw 224 ; Root directory entries
TotalSectorsSmall dw 2880 ; Total Sectors
MediaDescriptor db 0F0h ; Format ID (FAT12 ID number)
SectorsPerFAT dw 9 ; Sectors per FAT
SectorsPerTrack dw 18 ; Sectors per track
NumHeads dw 2 ; Number of heads (2 as double sided floppy)
HiddenSectors dd 0 ; Special hidden sectors
TotalSectorsLarge dd 0 ; More sectors
DriveNumber db 0 ; Drive Number (Primary Floppy is normally 0)
Flags db 0 ; Reserved
Signature db 41 ; Boot signature
VolumeID dd 435101793 ; Volume serial number
VolumeLabel db "NO NAME " ; Volume label (11 bytes)
SystemID db "FAT12 " ; File system (8 bytes)
main:
...
|
The above is an example. If you have space in your bootloader cutting and pasting that into the very start of the bootloader code (after [org 0x7c00]) will allow FAT12 access but by 3rd party FAT12 drivers. (DOS/Linux etc).
I've summarised in my own style (which may not be to readable to some) on my site, www.dftech.cwc.net/osdev/ in the tutorials and doc's section. But the bootloader changes are the easiest thing to do first and te most fundamental. (Just realised I copyed that from a version of my bootloader that used multiple sectors to avoid the 512byte limit, so the number of hidden sectors is probably different from yours, and just 1)
Hope that helpped if not look up my notes on the subject and feel free to ask any questions.
Daniel
|