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

wirehaze git hosting

057132764221886491ef65042a551c04d5fd799f
[BOS.git] / kernel / vfs / vfs.asm
1 ;----------------------------------------------------------;
2 ; BOS kernel Christoffer Bubach, 2012-2015. ;
3 ;----------------------------------------------------------;
4 ; ;
5 ; VFS handling all devices and filesystems. ;
6 ; ;
7 ;----------------------------------------------------------;
8
9
10 ;---------------------------------------------;
11 ; VFS main structure ;
12 ;---------------------------------------------;
13 struc VFS
14 {
15 .number: times 255 db 0 ; 00=FD, 0x10=HD, 0x60=CD, 0x80=VD, 90=RD, B0=ND
16 .storage:
17 times 255 * sizeof.VFS_storage db 0 ; storage driver structure
18 .filesystem:
19 times 255 * sizeof.VFS_filesystem db 0 ; filesystem driver structure
20 }
21
22 virtual at 0 ; could use "at esi" instead
23 VFS VFS
24 sizeof.VFS = $-$$
25 end virtual
26
27 ;---------------------------------------------;
28 ; VFS storage driver structure ;
29 ;---------------------------------------------;
30 struc VFS_storage
31 {
32 .data_pointer dd 0 ; internal driver data
33 .init dd 0 ; pointer to init
34 .deinit dd 0 ; remove driver
35 .read dd 0 ; read device
36 .write dd 0 ; write device
37 .ioctl dd 0 ; handle device specific extras
38 }
39
40 virtual at 0
41 VFS_storage VFS_storage
42 sizeof.VFS_storage = $-$$
43 end virtual
44
45 ;---------------------------------------------;
46 ; VFS filesystem structure ;
47 ;---------------------------------------------;
48 struc VFS_filesystem
49 {
50 .data_pointer dd 0 ; internal driver data
51 .init dd 0 ; pointer to init
52 .deinit dd 0 ; remove driver
53 .format dd 0 ; format drive
54 .mount dd 0 ; mount drive
55 .unmount dd 0 ; unmount drive
56 .find dd 0 ; find file
57 .findnext dd 0 ; get next match
58 .open dd 0 ; open file, get handle
59 .read dd 0 ; read file from handle
60 .write dd 0 ; write file from handle
61 .seek dd 0 ; seek from handle
62 .remove dd 0 ; remove file/dir
63 .create dd 0 ; create file/dir
64 .ioctl dd 0 ; extra calls if exists
65 }
66
67 virtual at 0
68 VFS_filesystem VFS_filesystem
69 sizeof.VFS_filesystem = $-$$
70 end virtual
71
72 ;---------------------------------------------;
73 ; VFS structure pointer ;
74 ;---------------------------------------------;
75 VFS_structure dd 0
76
77
78 ;--------------------------------------------------------------;
79 ; init_vfs - detect connected drives ;
80 ;--------------------------------------------------------------;
81 ; ;
82 ; out: cf = set if failed ;
83 ; ;
84 ;--------------------------------------------------------------;
85 init_vfs:
86 push eax
87 push ebx
88
89 mov ebx, sizeof.VFS ; allocate structure size
90 call allocate_mem
91 cmp eax, 0
92 jne .ok
93 stc ; if error, set carry
94 mov ebx, 0
95
96 .ok:
97 mov dword [VFS_structure], ebx
98
99 pop ebx
100 pop eax
101 ret
102
103 ;--------------------------------------------------------------;
104 ; add_media - add media driver ;
105 ;--------------------------------------------------------------;
106 ; ;
107 ; in: reg = pointer to VFS drive info ;
108 ; ;
109 ; out: reg = pointer to struct(s) if FAT12 found ;
110 ; ;
111 ;--------------------------------------------------------------;
112 add_media:
113 push eax
114 ;...
115 pop eax
116 ret
117
118 ;--------------------------------------------------------------;
119 ; add_fs - add filesystem driver ;
120 ;--------------------------------------------------------------;
121 ; ;
122 ; in: reg = pointer to VFS drive info ;
123 ; ;
124 ; out: reg = pointer to struct(s) if FAT12 found ;
125 ; ;
126 ;--------------------------------------------------------------;
127 add_fs:
128 push eax
129 ;...
130 pop eax
131 ret