fatLX - low level FAT file system driver
LX is the
Roman numeral (which as a number system is pretty much only used for Super Bowl) for 60
and fat32 + fat16 + fat12 adds up to 60.
For simplicity, the code assumes an unpartitioned USB flash drive with the Volume Boot Record in the first
physical sector and sector size 512 bytes. The code is PM32 and uses the HLL
fasmx macros.
The DRIVE_INFO
struct currently 3k in size, contains variables and data used in the process.
The high level file sytem routines such as
read, write, delete, rename, etc. will first setup drive_info and call
get_drive_info which will load the boot sector and setup some variables. The other routines will access the
DRIVE_INFO
struct.
Code: |
|
proc get_drive_info, drive_info
; load boot sector and setup some variables
proc get_first_directory_entry, drive_info, cluster_number
; load 1st sector of directory in 512 byte buffer in drive_info,
; if cluster_number is 0 use root directory of fat12 or fat16
; return pointer to first directory entry
proc get_next_directory_entry, drive_info
; return pointer to next directory entry, buffering directory as necessary
proc mark_directory, drive_info
; mark directory buffer modified when directory entry changed
proc flush_directory, drive_info
; write directory sector to drive
proc get_fat_entry, drive_info, fat
; load calculated fat sector (3 if fat12) to fat buffer in drive_info
; return cluster number of fat entry
proc put_fat_entry, drive_info, fat, cluster_number
; update fat entry with cluster number
; mark fat buffer as modified
proc flush_fat, drive_info
; write fat sector to drive
|
|
I've started work on the code. Comments, suggestions and participation are welcome.
The code will be released as
Public Domain.