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

wirehaze git hosting

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