Rev 72 | Rev 78 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 72 | Rev 75 | ||
---|---|---|---|
Line 4... | Line 4... | ||
4 | iglobal |
4 | iglobal |
5 | ; in this table names must be in lowercase |
5 | ; in this table names must be in lowercase |
6 | rootdirs: |
6 | rootdirs: |
7 | db 2,'rd' |
7 | db 2,'rd' |
8 | dd fs_OnRamdisk |
8 | dd fs_OnRamdisk |
- | 9 | dd fs_NextRamdisk |
|
9 | db 7,'ramdisk' |
10 | db 7,'ramdisk' |
10 | dd fs_OnRamdisk |
11 | dd fs_OnRamdisk |
- | 12 | dd fs_NextRamdisk |
|
11 | db 2,'fd' |
13 | db 2,'fd' |
12 | dd fs_OnFloppy |
14 | dd fs_OnFloppy |
- | 15 | dd fs_NextFloppy |
|
13 | db 10,'floppydisk' |
16 | db 10,'floppydisk' |
14 | dd fs_OnFloppy |
17 | dd fs_OnFloppy |
- | 18 | dd fs_NextFloppy |
|
15 | db 3,'hd0' |
19 | db 3,'hd0' |
16 | dd fs_OnHd0 |
20 | dd fs_OnHd0 |
- | 21 | dd fs_NextHd0 |
|
17 | db 3,'hd1' |
22 | db 3,'hd1' |
18 | dd fs_OnHd1 |
23 | dd fs_OnHd1 |
- | 24 | dd fs_NextHd1 |
|
19 | db 3,'hd2' |
25 | db 3,'hd2' |
20 | dd fs_OnHd2 |
26 | dd fs_OnHd2 |
- | 27 | dd fs_NextHd2 |
|
21 | db 3,'hd3' |
28 | db 3,'hd3' |
22 | dd fs_OnHd3 |
29 | dd fs_OnHd3 |
- | 30 | dd fs_NextHd3 |
|
23 | db 0 |
31 | db 0 |
- | 32 | ||
- | 33 | virtual_root_query: |
|
- | 34 | dd fs_HasRamdisk |
|
- | 35 | du 'rd',0 |
|
- | 36 | dd fs_HasFloppy |
|
- | 37 | du 'fd',0 |
|
- | 38 | dd fs_HasHd0 |
|
- | 39 | du 'hd0',0 |
|
- | 40 | dd fs_HasHd1 |
|
- | 41 | du 'hd1',0 |
|
- | 42 | dd fs_HasHd2 |
|
- | 43 | du 'hd2',0 |
|
- | 44 | dd fs_HasHd3 |
|
- | 45 | du 'hd3',0 |
|
- | 46 | dd 0 |
|
24 | endg |
47 | endg |
Line 25... | Line 48... | ||
25 | 48 | ||
26 | file_system_lfn: |
49 | file_system_lfn: |
27 | ; in: eax->fileinfo block |
50 | ; in: eax->fileinfo block |
28 | ; operation codes: |
51 | ; operation codes: |
29 | ; 0 : read file |
52 | ; 0 : read file |
30 | ; 1 : rewrite file - not implemented yet |
53 | ; 1 : read folder |
31 | ; 2 : delete file - not implemented yet |
54 | ; 2 : rewrite file - not implemented yet |
32 | ; 3 : write/append to file - not implemented yet |
55 | ; 3 : write/append to file - not implemented yet |
33 | ; 4 : create directory - not implemented yet |
56 | ; 4 : start application - not implemented yet |
34 | ; 5 : rename file/directory - not implemented yet |
57 | ; 5 : delete file - not implemented yet |
35 | ; 6 : get file attributes structure - not implemented yet |
58 | ; 6 : create directory - not implemented yet |
36 | ; 7 : start application - not implemented yet |
59 | ; 7 : rename file/directory - not implemented yet |
Line -... | Line 60... | ||
- | 60 | ; 8 : get file attributes structure - not implemented yet |
|
37 | ; 8 : find file with mask - not implemented yet |
61 | |
38 | 62 | add eax, std_application_base_address |
|
39 | ; parse file name |
63 | ; parse file name |
40 | xchg ebx, eax |
64 | xchg ebx, eax |
41 | lea esi, [ebx+20] |
65 | lea esi, [ebx+20] |
Line 46... | Line 70... | ||
46 | mov dword [esp+36], 5 ; file not found |
70 | mov dword [esp+36], 5 ; file not found |
47 | ret |
71 | ret |
48 | @@: |
72 | @@: |
49 | cmp byte [esi], 0 |
73 | cmp byte [esi], 0 |
50 | jz .rootdir |
74 | jz .rootdir |
51 | mov edi, rootdirs-4 |
75 | mov edi, rootdirs-8 |
52 | xor ecx, ecx |
76 | xor ecx, ecx |
53 | push esi |
77 | push esi |
54 | .scan1: |
78 | .scan1: |
55 | pop esi |
79 | pop esi |
56 | add edi, ecx |
80 | add edi, ecx |
57 | scasd |
81 | scasd |
- | 82 | scasd |
|
58 | mov cl, byte [edi] |
83 | mov cl, byte [edi] |
59 | jecxz .notfound |
84 | jecxz .notfound |
60 | inc edi |
85 | inc edi |
61 | push esi |
86 | push esi |
62 | @@: |
87 | @@: |
63 | lodsb |
88 | lodsb |
64 | or al, 20h |
89 | or al, 20h |
65 | scasb |
90 | scasb |
66 | loopz @b |
91 | loopz @b |
67 | jnz .scan1 |
92 | jnz .scan1 |
68 | pop eax |
- | |
69 | lodsb |
93 | lodsb |
70 | cmp al, '/' |
94 | cmp al, '/' |
71 | jz .found1 |
95 | jz .found1 |
72 | test al, al |
96 | test al, al |
73 | jnz .scan1 |
97 | jnz .scan1 |
- | 98 | pop eax |
|
74 | ; directory /xxx |
99 | ; directory /xxx |
75 | .maindir: |
100 | .maindir: |
- | 101 | cmp dword [ebx], 1 |
|
- | 102 | jnz .access_denied |
|
- | 103 | xor eax, eax |
|
- | 104 | mov ebp, [ebx+12] |
|
- | 105 | mov edx, [ebx+16] |
|
- | 106 | add edx, std_application_base_address |
|
- | 107 | mov ebx, [ebx+4] |
|
- | 108 | mov esi, [edi+4] |
|
- | 109 | ; ebx=first block, ebp=number of blocks, edx=return area, esi='Next' handler |
|
- | 110 | mov edi, edx |
|
- | 111 | mov ecx, 32/4 |
|
- | 112 | rep stosd |
|
- | 113 | mov byte [edx], 1 ; version |
|
- | 114 | .maindir_loop: |
|
- | 115 | call esi |
|
- | 116 | jc .maindir_done |
|
- | 117 | inc dword [edx+8] |
|
- | 118 | dec ebx |
|
- | 119 | jns .maindir_loop |
|
- | 120 | dec ebp |
|
- | 121 | js .maindir_loop |
|
- | 122 | inc dword [edx+4] |
|
- | 123 | mov dword [edi], 0x10 ; attributes: folder |
|
- | 124 | mov dword [edi+4], 1 ; name type: UNICODE |
|
- | 125 | push eax |
|
- | 126 | xor eax, eax |
|
- | 127 | add edi, 8 |
|
- | 128 | mov ecx, 40/4-2 |
|
- | 129 | rep stosd |
|
- | 130 | pop eax |
|
- | 131 | push eax edx |
|
- | 132 | ; convert number in eax to decimal UNICODE string |
|
- | 133 | push edi |
|
- | 134 | push -'0' |
|
- | 135 | mov cl, 10 |
|
- | 136 | @@: |
|
- | 137 | xor edx, edx |
|
- | 138 | div ecx |
|
- | 139 | push edx |
|
- | 140 | test eax, eax |
|
- | 141 | jnz @b |
|
- | 142 | @@: |
|
- | 143 | pop eax |
|
- | 144 | add al, '0' |
|
- | 145 | stosw |
|
- | 146 | jnz @b |
|
- | 147 | mov byte [edi-1], 0 |
|
- | 148 | pop edi |
|
- | 149 | add edi, 520 |
|
- | 150 | pop edx eax |
|
- | 151 | jmp .maindir_loop |
|
- | 152 | .maindir_done: |
|
- | 153 | mov ebx, [edx+8] |
|
- | 154 | xor eax, eax |
|
- | 155 | dec ebp |
|
- | 156 | js @f |
|
- | 157 | mov al, ERROR_END_OF_FILE |
|
- | 158 | @@: |
|
- | 159 | mov [esp+36], eax |
|
- | 160 | mov [esp+24], ebx |
|
- | 161 | ret |
|
76 | ; directory / |
162 | ; directory / |
77 | .rootdir: |
163 | .rootdir: |
- | 164 | cmp dword [ebx], 1 ; read folder? |
|
- | 165 | jz .readroot |
|
- | 166 | .access_denied: |
|
78 | mov dword [esp+36], 10 ; access denied |
167 | mov dword [esp+36], 10 ; access denied |
79 | ret |
168 | ret |
Line -... | Line 169... | ||
- | 169 | ||
- | 170 | .readroot: |
|
- | 171 | ; virtual root folder - special handler |
|
- | 172 | mov esi, virtual_root_query |
|
- | 173 | mov ebp, [ebx+12] |
|
- | 174 | mov edx, [ebx+16] |
|
- | 175 | add edx, std_application_base_address |
|
- | 176 | mov ebx, [ebx+4] |
|
- | 177 | xor eax, eax |
|
- | 178 | ; eax=0, ebx=first block, ebp=number of blocks, edx=return area |
|
- | 179 | mov edi, edx |
|
- | 180 | mov ecx, 32/4 |
|
- | 181 | rep stosd |
|
- | 182 | mov byte [edx], 1 ; version |
|
- | 183 | .readroot_loop: |
|
- | 184 | cmp dword [esi], eax |
|
- | 185 | jz .readroot_done |
|
- | 186 | call dword [esi] |
|
- | 187 | add esi, 4 |
|
- | 188 | test eax, eax |
|
- | 189 | jnz @f |
|
- | 190 | .readroot_next: |
|
- | 191 | or ecx, -1 |
|
- | 192 | xchg esi, edi |
|
- | 193 | repnz scasw |
|
- | 194 | xchg esi, edi |
|
- | 195 | jmp .readroot_loop |
|
- | 196 | @@: |
|
- | 197 | xor eax, eax |
|
- | 198 | inc dword [edx+8] |
|
- | 199 | dec ebx |
|
- | 200 | jns .readroot_next |
|
- | 201 | dec ebp |
|
- | 202 | js .readroot_next |
|
- | 203 | inc dword [edx+4] |
|
- | 204 | mov dword [edi], 0x10 ; attributes: folder |
|
- | 205 | mov dword [edi+4], 1 ; name type: UNICODE |
|
- | 206 | add edi, 8 |
|
- | 207 | mov ecx, 40/4-2 |
|
- | 208 | rep stosd |
|
- | 209 | push edi |
|
- | 210 | @@: |
|
- | 211 | lodsw |
|
- | 212 | stosw |
|
- | 213 | test eax, eax |
|
- | 214 | jnz @b |
|
- | 215 | pop edi |
|
- | 216 | add edi, 520 |
|
- | 217 | jmp .readroot_loop |
|
- | 218 | .readroot_done: |
|
- | 219 | mov ebx, [edx+8] |
|
- | 220 | xor eax, eax |
|
- | 221 | dec ebp |
|
- | 222 | js @f |
|
- | 223 | mov al, ERROR_END_OF_FILE |
|
- | 224 | @@: |
|
- | 225 | mov [esp+36], eax |
|
- | 226 | mov [esp+24], ebx |
|
- | 227 | ret |
|
80 | 228 | ||
- | 229 | .found1: |
|
81 | .found1: |
230 | pop eax |
82 | cmp byte [esi], 0 |
231 | cmp byte [esi], 0 |
83 | jz .maindir |
- | |
84 | mov ebp, dword [edi] ; handler for this device |
232 | jz .maindir |
85 | ; read partition number |
233 | ; read partition number |
86 | xor ecx, ecx |
234 | xor ecx, ecx |
87 | xor eax, eax |
235 | xor eax, eax |
88 | @@: |
236 | @@: |
Line 102... | Line 250... | ||
102 | jz .notfound |
250 | jz .notfound |
103 | test al, al |
251 | test al, al |
104 | jnz @f |
252 | jnz @f |
105 | dec esi |
253 | dec esi |
106 | @@: |
254 | @@: |
107 | ; now ebp contains handler address, ecx - partition number, esi points to ASCIIZ string - rest of name |
255 | ; now [edi] contains handler address, ecx - partition number, |
- | 256 | ; esi points to ASCIIZ string - rest of name |
|
108 | jmp ebp |
257 | jmp dword [edi] |
Line 109... | Line 258... | ||
109 | 258 | ||
- | 259 | ; handlers for devices |
|
110 | ; handlers for devices |
260 | ; in: ecx = 0 => query virtual directory /xxx |
111 | ; in: ecx = partition number |
261 | ; in: ecx = partition number |
112 | ; esi -> relative (for device) name |
262 | ; esi -> relative (for device) name |
113 | ; ebx -> fileinfo |
263 | ; ebx -> fileinfo |
Line 114... | Line 264... | ||
114 | ; out: [esp+36]=image of eax, [esp+24]=image of ebx |
264 | ; out: [esp+36]=image of eax, [esp+24]=image of ebx |
115 | 265 | ||
116 | fs_OnRamdisk: |
266 | fs_OnRamdisk: |
117 | cmp ecx, 1 |
267 | cmp ecx, 1 |
118 | jnz file_system_lfn.notfound |
268 | jnz file_system_lfn.notfound |
119 | movzx eax, byte [ebx] |
269 | mov eax, [ebx] |
120 | test eax, eax |
270 | cmp eax, 1 |
121 | jnz .not_impl |
271 | ja .not_impl |
122 | mov ecx, [ebx+12] |
272 | mov ecx, [ebx+12] |
123 | mov edx, [ebx+16] |
273 | mov edx, [ebx+16] |
124 | add edx, std_application_base_address |
274 | add edx, std_application_base_address |
Line 131... | Line 281... | ||
131 | mov dword [esp+36], 2 ; not implemented |
281 | mov dword [esp+36], 2 ; not implemented |
132 | ret |
282 | ret |
Line 133... | Line 283... | ||
133 | 283 | ||
134 | fs_RamdiskServices: |
284 | fs_RamdiskServices: |
- | 285 | dd fs_RamdiskRead |
|
Line 135... | Line 286... | ||
135 | dd fs_RamdiskRead |
286 | dd fs_RamdiskReadFolder |
136 | 287 | ||
137 | fs_OnFloppy: |
288 | fs_OnFloppy: |
138 | cmp ecx, 2 |
289 | cmp ecx, 2 |
139 | ja file_system_lfn.notfound |
290 | ja file_system_lfn.notfound |
140 | movzx eax, byte [ebx] |
291 | mov eax, [ebx] |
141 | test eax, eax |
292 | cmp eax, 1 |
142 | jnz fs_OnRamdisk.not_impl |
293 | ja fs_OnRamdisk.not_impl |
143 | call reserve_flp |
294 | call reserve_flp |
144 | mov [flp_number], cl |
295 | mov [flp_number], cl |
145 | mov ecx, [ebx+12] |
296 | mov ecx, [ebx+12] |
Line 152... | Line 303... | ||
152 | mov [esp+24], ebx |
303 | mov [esp+24], ebx |
153 | ret |
304 | ret |
Line 154... | Line 305... | ||
154 | 305 | ||
155 | fs_FloppyServices: |
306 | fs_FloppyServices: |
- | 307 | dd fs_FloppyRead |
|
Line 156... | Line 308... | ||
156 | dd fs_FloppyRead |
308 | dd fs_FloppyReadFolder |
157 | 309 | ||
158 | fs_OnHd0: |
310 | fs_OnHd0: |
159 | call reserve_hd1 |
311 | call reserve_hd1 |
Line 179... | Line 331... | ||
179 | mov [hdid], 0x10 |
331 | mov [hdid], 0x10 |
180 | push 4 |
332 | push 4 |
181 | fs_OnHd: |
333 | fs_OnHd: |
182 | pop eax |
334 | pop eax |
183 | mov [hdpos], eax |
335 | mov [hdpos], eax |
- | 336 | cmp ecx, 0x100 |
|
- | 337 | jae .nf |
|
184 | cmp ecx, [0x40001+eax] |
338 | cmp cl, [0x40001+eax] |
185 | jbe @f |
339 | jbe @f |
- | 340 | .nf: |
|
186 | and [hd1_status], 0 |
341 | and [hd1_status], 0 |
187 | mov dword [esp+36], 5 ; not found |
342 | mov dword [esp+36], 5 ; not found |
188 | ret |
343 | ret |
189 | @@: |
344 | @@: |
190 | mov [fat32part], ecx |
345 | mov [fat32part], ecx |
Line 192... | Line 347... | ||
192 | call choice_necessity_partition_1 |
347 | call choice_necessity_partition_1 |
193 | pop esi ebx |
348 | pop esi ebx |
194 | mov ecx, [ebx+12] |
349 | mov ecx, [ebx+12] |
195 | mov edx, [ebx+16] |
350 | mov edx, [ebx+16] |
196 | add edx, std_application_base_address |
351 | add edx, std_application_base_address |
197 | movzx eax, byte [ebx] |
352 | mov eax, [ebx] |
- | 353 | cmp eax, 1 |
|
- | 354 | ja .not_impl |
|
198 | add ebx, 4 |
355 | add ebx, 4 |
199 | call dword [fs_HdServices + eax*4] |
356 | call dword [fs_HdServices + eax*4] |
200 | and [hd1_status], 0 |
357 | and [hd1_status], 0 |
201 | mov [esp+36], eax |
358 | mov [esp+36], eax |
202 | mov [esp+24], ebx |
359 | mov [esp+24], ebx |
203 | ret |
360 | ret |
- | 361 | .not_impl: |
|
- | 362 | and [hd1_status], 0 |
|
- | 363 | mov dword [esp+36], 2 ; not implemented |
|
- | 364 | ret |
|
Line 204... | Line 365... | ||
204 | 365 | ||
205 | fs_HdServices: |
366 | fs_HdServices: |
- | 367 | dd fs_HdRead |
|
- | 368 | dd fs_HdReadFolder |
|
- | 369 | ||
- | 370 | fs_HasRamdisk: |
|
- | 371 | mov al, 1 ; we always have ramdisk |
|
- | 372 | ret |
|
- | 373 | ||
- | 374 | fs_HasFloppy: |
|
- | 375 | cmp byte [0x40000], 0 |
|
- | 376 | setnz al |
|
- | 377 | ret |
|
- | 378 | ||
- | 379 | fs_HasHd0: |
|
- | 380 | mov al, [0x40001] |
|
- | 381 | and al, 11000000b |
|
- | 382 | cmp al, 01000000b |
|
- | 383 | setz al |
|
- | 384 | ret |
|
- | 385 | fs_HasHd1: |
|
- | 386 | mov al, [0x40001] |
|
- | 387 | and al, 00110000b |
|
- | 388 | cmp al, 00010000b |
|
- | 389 | setz al |
|
- | 390 | ret |
|
- | 391 | fs_HasHd2: |
|
- | 392 | mov al, [0x40001] |
|
- | 393 | and al, 00001100b |
|
- | 394 | cmp al, 00000100b |
|
- | 395 | setz al |
|
- | 396 | ret |
|
- | 397 | fs_HasHd3: |
|
- | 398 | mov al, [0x40001] |
|
- | 399 | and al, 00000011b |
|
- | 400 | cmp al, 00000001b |
|
- | 401 | setz al |
|
- | 402 | ret |
|
- | 403 | ||
- | 404 | ; fs_NextXXX functions: |
|
- | 405 | ; in: eax = partition number, from which start to scan |
|
- | 406 | ; out: CF=1 => no more partitions |
|
- | 407 | ; CF=0 => eax=next partition number |
|
- | 408 | ||
- | 409 | fs_NextRamdisk: |
|
- | 410 | ; we always have /rd/1 |
|
- | 411 | test eax, eax |
|
- | 412 | stc |
|
- | 413 | jnz @f |
|
- | 414 | mov al, 1 |
|
- | 415 | clc |
|
- | 416 | @@: |
|
- | 417 | ret |
|
- | 418 | ||
- | 419 | fs_NextFloppy: |
|
- | 420 | ; we have /fd/1 iff (([0x40000] and 0xF0) != 0) and /fd/2 iff (([0x40000] and 0x0F) != 0) |
|
- | 421 | test byte [0x40000], 0xF0 |
|
- | 422 | jz .no1 |
|
- | 423 | test eax, eax |
|
- | 424 | jnz .no1 |
|
- | 425 | inc eax |
|
- | 426 | ret ; CF cleared |
|
- | 427 | .no1: |
|
- | 428 | test byte [0x40000], 0x0F |
|
- | 429 | jz .no2 |
|
- | 430 | cmp al, 2 |
|
- | 431 | jae .no2 |
|
- | 432 | mov al, 2 |
|
- | 433 | clc |
|
- | 434 | ret |
|
- | 435 | .no2: |
|
- | 436 | stc |
|
- | 437 | ret |
|
- | 438 | ||
- | 439 | ; on hdx, we have partitions from 1 to [0x40002+x] |
|
- | 440 | fs_NextHd0: |
|
- | 441 | push 0 |
|
- | 442 | jmp fs_NextHd |
|
- | 443 | fs_NextHd1: |
|
- | 444 | push 1 |
|
- | 445 | jmp fs_NextHd |
|
- | 446 | fs_NextHd2: |
|
- | 447 | push 2 |
|
- | 448 | jmp fs_NextHd |
|
- | 449 | fs_NextHd3: |
|
- | 450 | push 3 |
|
- | 451 | fs_NextHd: |
|
- | 452 | pop ecx |
|
- | 453 | movzx ecx, byte [0x40002+ecx] |
|
- | 454 | cmp eax, ecx |
|
- | 455 | jae fs_NextFloppy.no2 |
|
- | 456 | inc eax |
|
- | 457 | clc |