flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > OS Construction > fatLX - low level FAT file system driver

Author
Thread Post new topic Reply to topic
Mike Gonta



Joined: 26 Dec 2010
Posts: 123
fatLX - low level FAT file system driver
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_infodrive_info
; load boot sector and setup some variables
proc get_first_directory_entrydrive_infocluster_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_entrydrive_info
; return pointer to next directory entry, buffering directory as necessary
proc mark_directorydrive_info
; mark directory buffer modified when directory entry changed
proc flush_directorydrive_info
; write directory sector to drive

proc get_fat_entrydrive_infofat
; load calculated fat sector (3 if fat12) to fat buffer in drive_info
; return cluster number of fat entry
proc put_fat_entrydrive_infofatcluster_number
; update fat entry with cluster number
; mark fat buffer as modified
proc flush_fatdrive_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.

_________________
Mike Gonta
look and see - many look but few see

http://mikegonta.com
Post 18 Mar 2012, 19:48
View user's profile Send private message Reply with quote
Mike Gonta



Joined: 26 Dec 2010
Posts: 123
DRIVE_INFO

Code:
use32
struct DRIVE_INFO
  vbr db 11 dup ?
    vbr.bytes_per_sector dw ?
    vbr.sectors_per_cluster db ?
    vbr.reserved_sector_count dw ?
    vbr.number_of_fats db ?
    vbr.root_directory_entries dw ?
    vbr.sector_count dw ?
      db ?
    vbr.sectors_per_fat dw ?
      dd ?
    hidden_sectors dd ?
    sector_count dd ?
    sectors_per_fat dd ?
      dd ?
    root_directory_cluster_number dd ?
    information_sector_number dw ?
      db 17 dup ?
    volume_id dd ?
    volume_label db 11 dup ?
    file_system db 8 dup ?
      db 2 dup ?
    drive_number dd ?
    start_of_fat dd ?
    start_of_root_directory dd ?
    start_of_data dd ?
      dd ?
      dd 100 dup ?
  information_sector dd 122 dup ?
    free_clusters dd ?
    last_cluster dd ?
      dd 4 dup ?
  fat_buffer dd 512*3/4 dup ?
  directory_buffer dd 512/4 dup ?
ends

proc file_routineargs
locals
  drive_info DRIVE_INFO
endl
  mov [drive_info.drive_number], [drive_number]
  call get_drive_infoaddr drive_info
  ret
endp



_________________
Mike Gonta
look and see - many look but few see

http://mikegonta.com
Post 18 Mar 2012, 20:22
View user's profile Send private message Reply with quote
GhostXoPCorp



Joined: 13 Dec 2008
Posts: 199
Location: 01F0:0100
Really like it, to be honest the system you have here is similar to the one i have. Either a good idea or everyone does this as well. Better idea to put it into macro form. Keep up the good work Smile

_________________
Oh that divide overflow. Just jumps out of the bushes every time to scare the day lights out of me.
Post 20 Mar 2012, 02:18
View user's profile Send private message Reply with quote
Mike Gonta



Joined: 26 Dec 2010
Posts: 123

GhostXoPCorp wrote:
Better idea to put it into macro form.


fasmx (operating system independent HLL macros) is the macro form.

_________________
Mike Gonta
look and see - many look but few see

http://mikegonta.com
Post 20 Mar 2012, 09:17
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1593
Location: web
Cool, i have had the the same idea, but with something like 'macro basic'
Post 20 Mar 2012, 20:25
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >

Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2013, Tomasz Grysztar.