1 ;----------------------------------------------------------;
2 ; BOS kernel Christoffer Bubach, 2012-2015. ;
3 ;----------------------------------------------------------;
5 ; VFS handling all devices and filesystems. ;
7 ;----------------------------------------------------------;
10 ;---------------------------------------------;
11 ; VFS main structure ;
12 ;---------------------------------------------;
15 .number: times 255 db 0 ; 00=FD, 0x10=HD, 0x60=CD, 0x80=VD, 90=RD, B0=ND
17 times 255 * sizeof
.VFS_storage
db 0 ; storage driver structure
19 times 255 * sizeof
.VFS_filesystem
db 0 ; filesystem driver structure
20 .mounted db 0 ; 1/0 switch if mounted
21 .current_path: times 255 db 0 ; drive opened path (increase max path size?)
24 virtual at 0 ; could use "at esi" instead
29 ;---------------------------------------------;
30 ; VFS storage driver structure ;
31 ;---------------------------------------------;
34 .data_pointer dd 0 ; internal driver data
35 .init dd 0 ; pointer to init
36 .deinit dd 0 ; remove driver
37 .read dd 0 ; read device
38 .write dd 0 ; write device
39 .ioctl dd 0 ; handle device specific extras
43 VFS_storage VFS_storage
44 sizeof
.VFS_storage
= $-$$
47 ;---------------------------------------------;
48 ; VFS filesystem structure ;
49 ;---------------------------------------------;
52 .data_pointer dd 0 ; internal driver data
53 .FSname db 0,0,0,0,0 ; 5 char filesystem name
54 .init dd 0 ; pointer to init
55 .deinit dd 0 ; remove driver
56 .format dd 0 ; format drive
57 .mount dd 0 ; mount drive
58 .unmount dd 0 ; unmount drive
59 .find dd 0 ; find file
60 .findnext dd 0 ; get next match
61 .open dd 0 ; open file, get handle
62 .close dd 0 ; close file from handle
63 .attrib dd 0 ; get/set attrib. and time
64 .read dd 0 ; read file from handle
65 .write dd 0 ; write file from handle
66 .seek dd 0 ; seek from handle
67 .rename dd 0 ; rename file
68 .remove dd 0 ; remove file/dir
69 .create dd 0 ; create file/dir
70 .ioctl dd 0 ; extra calls if exists
74 VFS_filesystem VFS_filesystem
75 sizeof
.VFS_filesystem
= $-$$
78 ;---------------------------------------------;
79 ; VFS structure pointer ;
80 ;---------------------------------------------;
84 ;--------------------------------------------------------------;
85 ; init_vfs - detect connected drives ;
86 ;--------------------------------------------------------------;
88 ; out: cf = set if failed ;
90 ;--------------------------------------------------------------;
95 mov ebx, sizeof
.VFS
; allocate structure size
99 stc ; if error, set carry
103 mov dword [VFS_structure
], ebx
109 ;--------------------------------------------------------------;
110 ; add_media - add media driver ;
111 ;--------------------------------------------------------------;
113 ; in: reg = pointer to VFS drive info ;
115 ; out: reg = pointer to struct(s) if FAT12 found ;
117 ;--------------------------------------------------------------;
124 ;--------------------------------------------------------------;
125 ; add_fs - add filesystem driver ;
126 ;--------------------------------------------------------------;
128 ; in: reg = pointer to VFS drive info ;
130 ; out: reg = pointer to struct(s) if FAT12 found ;
132 ;--------------------------------------------------------------;
139 ;--------------------------------------------------------------;
140 ; open_file - open file, return handle ;
141 ;--------------------------------------------------------------;
143 ; in: reg = ASCIIZ file name and such ;
145 ; out: reg = dword file handle ;
147 ;--------------------------------------------------------------;
150 ; file handles need to be dword, where the high
151 ; word contains drive number, and the low word
152 ; is the drive/FS specific handle. meaning no internal
153 ; table in VFS, created dynamically with FS info.
154 ; limits FS to a max of 65535 opened files. most use fewer
155 ; as default. FAT12 driver has 32.
156 ; FS reports error if handle is invalid.