1 ;----------------------------------------------------------;
2 ; BOS kernel Christoffer Bubach, 2012-2015. ;
3 ;----------------------------------------------------------;
5 ; VFS handling all devices and filesystems. ;
7 ;----------------------------------------------------------;
10 ; file handles need to be dword, where the high
11 ; word contains drive number, and the low word
12 ; is the drive/FS specific handle. limits FS to
13 ; a max of 65535 opened files. should be alright. ;)
16 ;---------------------------------------------;
17 ; VFS main structure ;
18 ;---------------------------------------------;
21 .number: times 255 db 0 ; 00=FD, 0x10=HD, 0x60=CD, 0x80=VD, 90=RD, B0=ND
23 times 255 * sizeof
.VFS_storage
db 0 ; storage driver structure
25 times 255 * sizeof
.VFS_filesystem
db 0 ; filesystem driver structure
26 .mounted db 0 ; 1/0 switch if mounted
27 .current_path: times 255 db 0 ; drive opened path (increase max path size?)
30 virtual at 0 ; could use "at esi" instead
35 ;---------------------------------------------;
36 ; VFS storage driver structure ;
37 ;---------------------------------------------;
40 .data_pointer dd 0 ; internal driver data
41 .init dd 0 ; pointer to init
42 .deinit dd 0 ; remove driver
43 .read dd 0 ; read device
44 .write dd 0 ; write device
45 .ioctl dd 0 ; handle device specific extras
49 VFS_storage VFS_storage
50 sizeof
.VFS_storage
= $-$$
53 ;---------------------------------------------;
54 ; VFS filesystem structure ;
55 ;---------------------------------------------;
58 .data_pointer dd 0 ; internal driver data
59 .init dd 0 ; pointer to init
60 .deinit dd 0 ; remove driver
61 .format dd 0 ; format drive
62 .mount dd 0 ; mount drive
63 .unmount dd 0 ; unmount drive
64 .find dd 0 ; find file
65 .findnext dd 0 ; get next match
66 .open dd 0 ; open file, get handle
67 .read dd 0 ; read file from handle
68 .write dd 0 ; write file from handle
69 .seek dd 0 ; seek from handle
70 .remove dd 0 ; remove file/dir
71 .create dd 0 ; create file/dir
72 .ioctl dd 0 ; extra calls if exists
76 VFS_filesystem VFS_filesystem
77 sizeof
.VFS_filesystem
= $-$$
80 ;---------------------------------------------;
81 ; VFS structure pointer ;
82 ;---------------------------------------------;
86 ;--------------------------------------------------------------;
87 ; init_vfs - detect connected drives ;
88 ;--------------------------------------------------------------;
90 ; out: cf = set if failed ;
92 ;--------------------------------------------------------------;
97 mov ebx, sizeof
.VFS
; allocate structure size
101 stc ; if error, set carry
105 mov dword [VFS_structure
], ebx
111 ;--------------------------------------------------------------;
112 ; add_media - add media driver ;
113 ;--------------------------------------------------------------;
115 ; in: reg = pointer to VFS drive info ;
117 ; out: reg = pointer to struct(s) if FAT12 found ;
119 ;--------------------------------------------------------------;
126 ;--------------------------------------------------------------;
127 ; add_fs - add filesystem driver ;
128 ;--------------------------------------------------------------;
130 ; in: reg = pointer to VFS drive info ;
132 ; out: reg = pointer to struct(s) if FAT12 found ;
134 ;--------------------------------------------------------------;