]> wirehaze git hosting - BOS.git/blobdiff - kernel/fat12/fat12.asm

wirehaze git hosting

More VFS/FAT12 structure work
[BOS.git] / kernel / fat12 / fat12.asm
index 416fe43d42b1cbb66d7f0dc78c68ee55235318da..832df8fedb57910cb3d94c1f4f35b546f0b6f7a0 100644 (file)
@@ -6,27 +6,55 @@
 ;                                                          ;
 ;----------------------------------------------------------;
 
 ;                                                          ;
 ;----------------------------------------------------------;
 
+    ;---------------------------------------------;
+    ;   FAT12 calltable and structure pointer     ;
+    ;---------------------------------------------;
+    FAT12:
+        .data_pointer         dd  0                   ; internal driver data
+        .FSname               db  'FAT12'             ; 5 char filesystem name
+        .init                 dd  init_fat12          ; pointer to init
+        .deinit               dd  0                   ; remove driver
+        .format               dd  0                   ; format drive
+        .mount                dd  0                   ; mount drive
+        .unmount              dd  0                   ; unmount drive
+        .find                 dd  0                   ; find file
+        .findnext             dd  0                   ; get next match
+        .open                 dd  0                   ; open file, get handle
+        .close                dd  0                   ; close file from handle
+        .attrib               dd  0                   ; get/set attrib. and time
+        .read                 dd  0                   ; read file from handle
+        .write                dd  0                   ; write file from handle
+        .seek                 dd  0                   ; seek from handle
+        .rename               dd  0                   ; rename file
+        .remove               dd  0                   ; remove file/dir
+        .create               dd  0                   ; create file/dir
+        .ioctl                dd  0                   ; extra calls if exists
+
     ;---------------------------------------------;
     ;   FAT12 main info structure                 ;
     ;---------------------------------------------;
     ;---------------------------------------------;
     ;   FAT12 main info structure                 ;
     ;---------------------------------------------;
-    struc fat12
+    struc fat12_data
     {
     {
-        .disk_number                     db  0       ; which VFS disk number
-        .root_dir                        dw  0       ; position of rootdir
-        .fat_1                           dd  0       ; position of fat1
-        .fat_2                           dd  0       ; position of fat2
-        .data_area                       dw  0       ; position of dataarea
-        .disk_size                       dd  0       ; total storage size
-        .free_space                      dd  0       ; free space available
-        .boot                            bootsector  
+        .disk_number                     db  0        ; which VFS disk number
+        .root_dir                        dw  0        ; position of rootdir
+        .disk_size                       dd  0        ; total storage size
+        .free_space                      dd  0        ; free space available
+        .fat_1                           dd  0        ; position of fat1
+        .fat_2                           dd  0        ; position of fat2
+        .data_area                       dw  0        ; position of dataarea
+        .boot: times sizeof.bootsector   db  0        ; copy of FAT12 bootsector
         .dir_entries:
         .dir_entries:
-            times 16 * sizeof.dir_entry  db 0        ; 512b dir entry buffer
-        .fat_buffer:      times 512      db 0        ; 512b FAT cluster info buffer
+            times 16 * sizeof.dir_entry  db  0        ; 512b dir entry buffer
+        .fat_buffer:      times 512      db  0        ; 512b FAT cluster info buffer
+        .foundfile:
+            times 1 * sizeof.search      db  0        ; "DTA" like structure
+        .filehandles:                                 ; "System File Table"
+            times 32 * sizeof.filehandle db  0        ; for now, max opened files is 32
     }
 
     virtual at 0                                      ; could use "at esi" instead
     }
 
     virtual at 0                                      ; could use "at esi" instead
-        fat12 fat12
-        sizeof.fat12 = $-$$     
+        fat12_data fat12_data
+        sizeof.fat12_data = $-$$     
     end virtual
 
     ;---------------------------------------------;
     end virtual
 
     ;---------------------------------------------;
         sizeof.lfn_entry = $-$$
     end virtual
 
         sizeof.lfn_entry = $-$$
     end virtual
 
+    ;---------------------------------------------;
+    ;   FAT12 file search/DTA structure           ;
+    ;---------------------------------------------;
+    struc search
+    {
+        .searchname:
+            times 255      db  0                      ; file search pattern.
+        .attribute         db  0                      ; search attribute.
+        .direntry          dw  0                      ; directory entry number, 0 based
+        .dircluster        dw  0                      ; starting cluster of dir, 0 root
+        .foundattrib       db  0                      ; attribute of matching file
+        .foundtime         dw  0                      ; file time
+        .founddate         dw  0                      ; file date
+        .foundsize         dw  0                      ; file size
+    }
+
+    virtual at 0
+        search search
+        sizeof.search = $-$$
+    end virtual
+
+    ;---------------------------------------------;
+    ;   FAT12 file-handle structure               ;
+    ;---------------------------------------------;
+    struc filehandle
+    {
+        .handles           db  0                      ; reference count or or zero for unused
+        .mode              db  0                      ; open mode. 0=read, 1=write, 2=r/w.
+        .lfn_entry         dw  0                      ; file LFN directory entry position
+        .direntry          dw  0                      ; file directory entry position
+        .cluster           dw  0                      ; file first cluster
+        .attribute         db  0                      ; file attributes
+        .filetime          dw  0                      ; last modified time
+        .filedate          dw  0                      ; last modified date
+        .filesize          dd  0                      ; filesize
+        .position          dd  0                      ; R/W position in file
+        .clusterpos        dw  0                      ; cluster number of last cluster read
+        .shortname:
+            times 11       db  0                      ; short name
+        .fullname:
+            times 255      db  0                      ; the full LFN
+    }
+
+    virtual at 0
+        filehandle filehandle
+        sizeof.filehandle = $-$$
+    end virtual
+
     ;------------------------------------------;
     ;   FAT cluster constants used             ;
     ;------------------------------------------;
     ;------------------------------------------;
     ;   FAT cluster constants used             ;
     ;------------------------------------------;
     attribute_lfn       = 0x0F                         ; attrb. byte value for LFN dir entry
 
 
     attribute_lfn       = 0x0F                         ; attrb. byte value for LFN dir entry
 
 
-
-
-
-fd0 fat12            ; define fd0 data..  tmp example.
-
-; TODO, alloc memory for struct and keep pointer only.
-; ---------------
-;drive dd 0
-;mov edi, drive+fat12into.boot
-
 ;--------------------------------------------------------------;
 ;   init_fat12  -  detect if drive fs is fat12 and init        ;
 ;--------------------------------------------------------------;
 ;--------------------------------------------------------------;
 ;   init_fat12  -  detect if drive fs is fat12 and init        ;
 ;--------------------------------------------------------------;