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

wirehaze git hosting

new indentation style
[BOS.git] / kernel / vfs / vfs.asm
index ab2f0facc35e1f91f131447278be0a42b30a5cd4..83cd12777cf41230fe4ac869b9ebaf7dbcf8a5bb 100644 (file)
@@ -6,6 +6,7 @@
 ;                                                          ;
 ;----------------------------------------------------------;
 
+
     ;---------------------------------------------;
     ;   VFS main structure                        ;
     ;---------------------------------------------;
@@ -16,6 +17,8 @@
             times 255 * sizeof.VFS_storage     db 0   ; storage driver structure
         .filesystem:          
             times 255 * sizeof.VFS_filesystem  db 0   ; filesystem driver structure
+        .mounted                               db 0   ; 1/0 switch if mounted
+        .current_path:          times 255      db 0   ; drive opened path (increase max path size?)
     }
 
     virtual at 0                                      ; could use "at esi" instead
@@ -47,6 +50,7 @@
     struc VFS_filesystem
     {
         .data_pointer         dd  0                   ; internal driver data
+        .FSname               db  0,0,0,0,0           ; 5 char filesystem name
         .init                 dd  0                   ; pointer to init
         .deinit               dd  0                   ; remove driver
         .format               dd  0                   ; format 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
         sizeof.VFS_filesystem = $-$$
     end virtual
 
+    ;---------------------------------------------;
+    ;   VFS structure pointer                     ;
+    ;---------------------------------------------;
+    VFS_structure             dd 0
 
-VFS_structure VFS
 
 ;--------------------------------------------------------------;
 ;   init_vfs  -  detect connected drives                       ;
 ;--------------------------------------------------------------;
 ;                                                              ;
+;       out:                    cf = set if failed             ;
+;                                                              ;
+;--------------------------------------------------------------;
+init_vfs:
+        push   eax
+        push   ebx
+
+        mov    ebx, sizeof.VFS                        ; allocate structure size
+        call   allocate_mem
+        cmp    eax, 0
+        jne    .ok
+        stc                                           ; if error, set carry
+        mov    ebx, 0
+
+    .ok:
+        mov    dword [VFS_structure], ebx
+
+        pop    ebx
+        pop    eax
+        ret
+
+;--------------------------------------------------------------;
+;   add_media  -  add media driver                             ;
+;--------------------------------------------------------------;
+;                                                              ;
 ;       in:  reg = pointer to VFS drive info                   ;
 ;                                                              ;
 ;       out: reg = pointer to struct(s) if FAT12 found         ;
 ;                                                              ;
 ;--------------------------------------------------------------;
-init_vfs:
+add_media:
+        push   eax
+        ;...
+        pop    eax
+        ret
+
+;--------------------------------------------------------------;
+;   add_fs  -  add filesystem driver                           ;
+;--------------------------------------------------------------;
+;                                                              ;
+;       in:  reg = pointer to VFS drive info                   ;
+;                                                              ;
+;       out: reg = pointer to struct(s) if FAT12 found         ;
+;                                                              ;
+;--------------------------------------------------------------;
+add_fs:
+        push   eax
+        ;...
+        pop    eax
+        ret
+
+;--------------------------------------------------------------;
+;   open_file  -  open file, return handle                     ;
+;--------------------------------------------------------------;
+;                                                              ;
+;       in:  reg = ASCIIZ file name and such                   ;
+;                                                              ;
+;       out: reg = dword file handle                           ;
+;                                                              ;
+;--------------------------------------------------------------;
+open_file:
         push   eax
-        ; a bit more code here 
+        ; file handles need to be dword, where the high
+        ; word contains drive number, and the low word
+        ; is the drive/FS specific handle.  meaning no internal
+        ; table in VFS, created dynamically with FS info.
+        ; limits FS to a max of 65535 opened files. most use fewer
+        ; as default. FAT12 driver has 32.
+        ; FS reports error if handle is invalid.
         pop    eax
         ret
\ No newline at end of file