Rev 321 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1 | ha | 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2 | ;; ;; |
||
3 | ;; System service for filesystem call ;; |
||
4 | ;; (C) 2004 Ville Turjanmaa, License: GPL ;; |
||
74 | mario79 | 5 | ;; 29.04.2006 Elimination of hangup after the ;; |
6 | ;; expiration hd_wait_timeout (for LBA) - Mario79 ;; |
||
1 | ha | 7 | ;; 15.01.2005 get file size/attr/date, file_append (only for hd) - ATV ;; |
8 | ;; 23.11.2004 test if hd/partition is set - ATV ;; |
||
9 | ;; 18.11.2004 get_disk_info and more error codes - ATV ;; |
||
10 | ;; 08.11.2004 expand_pathz and rename (only for hd) - ATV ;; |
||
11 | ;; 20.10.2004 Makedir/Removedir (only for hd) - ATV ;; |
||
12 | ;; ;; |
||
13 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
||
14 | |||
15 | iglobal |
||
16 | dir0: db 'HARDDISK ' |
||
17 | db 'RAMDISK ' |
||
18 | db 'FLOPPYDISK ' |
||
19 | db 0 |
||
20 | |||
21 | dir1: db 'FIRST ' |
||
22 | db 'SECOND ' |
||
23 | db 'THIRD ' |
||
24 | db 'FOURTH ' |
||
25 | db 0 |
||
26 | |||
27 | not_select_IDE db 0 |
||
28 | |||
29 | hd_address_table: dd 0x1f0,0x00,0x1f0,0x10 |
||
30 | dd 0x170,0x00,0x170,0x10 |
||
31 | endg |
||
32 | |||
74 | mario79 | 33 | file_system: |
34 | |||
1 | ha | 35 | ; IN: |
36 | ; |
||
133 | diamond | 37 | ; eax = 0 ; read file /RamDisk/First 6 |
1 | ha | 38 | ; eax = 1 ; write file /RamDisk/First 33 /HardDisk/First 56 |
39 | ; eax = 8 ; lba read |
||
40 | ; eax = 15 ; get_disk_info |
||
41 | ; |
||
42 | ; OUT: |
||
43 | ; |
||
44 | ; eax = 0 : read ok |
||
61 | halyavin | 45 | ; eax = 1 : no hd base and/or partition defined |
71 | diamond | 46 | ; eax = 2 : function is unsupported for this FS |
1 | ha | 47 | ; eax = 3 : unknown FS |
48 | ; eax = 4 : partition not defined at hd |
||
49 | ; eax = 5 : file not found |
||
50 | ; eax = 6 : end of file |
||
51 | ; eax = 7 : memory pointer not in application area |
||
52 | ; eax = 8 : disk full |
||
53 | ; eax = 9 : fat table corrupted |
||
54 | ; eax = 10 : access denied |
||
83 | diamond | 55 | ; eax = 11 : disk error |
1 | ha | 56 | ; |
57 | ; ebx = size |
||
58 | |||
61 | halyavin | 59 | ; \begin{diamond}[18.03.2006] |
60 | ; for subfunction 16 (start application) error codes must be negative |
||
64 | mario79 | 61 | ; because positive values are valid PIDs |
61 | halyavin | 62 | ; so possible return values are: |
63 | ; eax > 0 : process created, eax=PID |
||
64 | |||
65 | ; -0x10 <= eax < 0 : -eax is filesystem error code: |
||
66 | ; eax = -1 = 0xFFFFFFFF : no hd base and/or partition defined |
||
67 | ; eax = -3 = 0xFFFFFFFD : unknown FS |
||
68 | ; eax = -5 = 0xFFFFFFFB : file not found |
||
69 | ; eax = -6 = 0xFFFFFFFA : unexpected end of file (probably not executable file) |
||
70 | ; eax = -9 = 0xFFFFFFF7 : fat table corrupted |
||
71 | ; eax = -10 = 0xFFFFFFF6 : access denied |
||
72 | |||
73 | ; -0x20 <= eax < -0x10: eax is process creation error code: |
||
74 | ; eax = -0x20 = 0xFFFFFFE0 : too many processes |
||
75 | ; eax = -0x1F = 0xFFFFFFE1 : not Menuet/Kolibri executable |
||
76 | ; eax = -0x1E = 0xFFFFFFE2 : no memory |
||
77 | |||
78 | ; ebx is not changed |
||
79 | |||
80 | ; \end{diamond}[18.03.2006] |
||
81 | |||
1 | ha | 82 | ; Extract parameters |
64 | mario79 | 83 | add eax, std_application_base_address ; abs start of info block |
1 | ha | 84 | |
85 | cmp dword [eax+0],15 ; GET_DISK_INFO |
||
86 | je fs_info |
||
87 | |||
379 | serge | 88 | cmp dword [CURRENT_TASK],1 ; no memory checks for kernel requests |
1 | ha | 89 | jz no_checks_for_kernel |
90 | mov edx,eax |
||
91 | cmp dword [eax+0],1 |
||
92 | jnz .usual_check |
||
93 | mov ebx,[eax+12] |
||
94 | add ebx,std_application_base_address |
||
95 | mov ecx,[eax+8] |
||
96 | call check_region |
||
97 | test eax,eax |
||
98 | jnz area_in_app_mem |
||
379 | serge | 99 | |
1 | ha | 100 | .error_output: |
101 | mov esi,buffer_failed |
||
102 | call sys_msg_board_str |
||
61 | halyavin | 103 | ; mov eax,7 |
1 | ha | 104 | mov dword [esp+36],7 |
105 | ret |
||
106 | iglobal |
||
61 | halyavin | 107 | buffer_failed db 'K : Buffer check failed',13,10,0 |
379 | serge | 108 | endg |
1 | ha | 109 | .usual_check: |
110 | cmp dword [eax+0],0 |
||
111 | mov ecx,512 |
||
112 | jnz .small_size |
||
113 | mov ecx,[eax+8] |
||
114 | shl ecx,9 |
||
115 | .small_size: |
||
116 | mov ebx,[eax+12] |
||
117 | add ebx,std_application_base_address |
||
118 | call check_region |
||
119 | test eax,eax |
||
120 | jz .error_output |
||
121 | area_in_app_mem: |
||
122 | mov eax,edx |
||
123 | no_checks_for_kernel: |
||
124 | |||
125 | fs_read: |
||
126 | |||
127 | mov ebx,[eax+20] ; program wants root directory ? |
||
128 | test bl,bl |
||
129 | je fs_getroot |
||
130 | test bh,bh |
||
131 | jne fs_noroot |
||
132 | fs_getroot: |
||
61 | halyavin | 133 | ; \begin{diamond}[18.03.2006] |
134 | ; root - only read is allowed |
||
135 | ; other operations return "access denied", eax=10 |
||
136 | ; (execute operation returns eax=-10) |
||
64 | mario79 | 137 | cmp dword [eax], 0 |
138 | jz .read_root |
||
147 | diamond | 139 | mov dword [esp+36], 10 |
64 | mario79 | 140 | ret |
61 | halyavin | 141 | .read_root: |
142 | ; \end{diamond}[18.03.2006] |
||
1 | ha | 143 | mov esi,dir0 |
144 | mov edi,[eax+12] |
||
61 | halyavin | 145 | add edi,std_application_base_address |
1 | ha | 146 | mov ecx,11 |
61 | halyavin | 147 | push ecx |
64 | mario79 | 148 | ; cld ; already is |
1 | ha | 149 | rep movsb |
61 | halyavin | 150 | mov al,0x10 |
1 | ha | 151 | stosb |
152 | add edi,32-11-1 |
||
61 | halyavin | 153 | pop ecx |
1 | ha | 154 | rep movsb |
155 | stosb |
||
61 | halyavin | 156 | and dword [esp+36],0 ; ok read |
1 | ha | 157 | mov dword [esp+24],32*2 ; size of root |
158 | ret |
||
159 | |||
160 | fs_info: ;start of code - Mihasik |
||
61 | halyavin | 161 | push eax |
1 | ha | 162 | cmp [eax+21],byte 'h' |
163 | je fs_info_h |
||
164 | cmp [eax+21],byte 'H' |
||
165 | je fs_info_h |
||
166 | cmp [eax+21],byte 'r' |
||
167 | je fs_info_r |
||
168 | cmp [eax+21],byte 'R' |
||
169 | je fs_info_r |
||
170 | mov eax,3 ;if unknown disk |
||
171 | xor ebx,ebx |
||
172 | xor ecx,ecx |
||
173 | xor edx,edx |
||
174 | jmp fs_info1 |
||
175 | fs_info_r: |
||
176 | call ramdisk_free_space ;if ramdisk |
||
177 | mov ecx,edi ;free space in ecx |
||
178 | shr ecx,9 ;free clusters |
||
179 | mov ebx,2847 ;total clusters |
||
180 | mov edx,512 ;cluster size |
||
181 | xor eax,eax ;always 0 |
||
182 | jmp fs_info1 |
||
183 | fs_info_h: ;if harddisk |
||
184 | call get_hd_info |
||
185 | fs_info1: |
||
186 | pop edi |
||
187 | mov [esp+36],eax |
||
188 | mov [esp+24],ebx ; total clusters on disk |
||
189 | mov [esp+32],ecx ; free clusters on disk |
||
190 | mov [edi],edx ; cluster size in bytes |
||
191 | ret ;end of code - Mihasik |
||
192 | |||
193 | fs_noroot: |
||
194 | |||
61 | halyavin | 195 | push dword [eax+0] ; read/write/delete/.../makedir/rename/lba/run |
196 | push dword [eax+4] ; 512 block number to read |
||
197 | push dword [eax+8] ; bytes to write/append or 512 blocks to read |
||
1 | ha | 198 | mov ebx,[eax+12] |
61 | halyavin | 199 | add ebx,std_application_base_address |
1 | ha | 200 | push ebx ; abs start of return/save area |
201 | |||
202 | lea esi,[eax+20] ; abs start of dir + filename |
||
61 | halyavin | 203 | mov edi,[eax+16] |
64 | mario79 | 204 | add edi,std_application_base_address ; abs start of work area |
1 | ha | 205 | |
206 | call expand_pathz |
||
207 | |||
208 | push edi ; dir start |
||
209 | push ebx ; name of file start |
||
210 | |||
211 | mov eax,[edi+1] |
||
212 | cmp eax,'RD ' |
||
213 | je fs_yesramdisk |
||
61 | halyavin | 214 | cmp eax,'RAMD' |
1 | ha | 215 | jne fs_noramdisk |
216 | |||
217 | fs_yesramdisk: |
||
218 | |||
219 | cmp byte [edi+1+11],0 |
||
220 | je fs_give_dir1 |
||
221 | |||
222 | mov eax,[edi+1+12] |
||
223 | cmp eax,'1 ' |
||
224 | je fs_yesramdisk_first |
||
61 | halyavin | 225 | cmp eax,'FIRS' |
1 | ha | 226 | jne fs_noramdisk |
227 | |||
228 | fs_yesramdisk_first: |
||
229 | |||
230 | cmp dword [esp+20],8 ; LBA read ramdisk |
||
231 | jne fs_no_LBA_read_ramdisk |
||
232 | |||
233 | mov eax,[esp+16] ; LBA block to read |
||
234 | mov ecx,[esp+8] ; abs pointer to return area |
||
235 | |||
236 | call LBA_read_ramdisk |
||
237 | jmp file_system_return |
||
238 | |||
239 | |||
240 | fs_no_LBA_read_ramdisk: |
||
241 | |||
242 | cmp dword [esp+20],0 ; READ |
||
243 | jne fs_noramdisk_read |
||
244 | |||
245 | mov eax,[esp+4] ; fname |
||
246 | add eax,2*12+1 |
||
247 | mov ebx,[esp+16] ; block start |
||
248 | inc ebx |
||
249 | mov ecx,[esp+12] ; block count |
||
250 | mov edx,[esp+8] ; return |
||
251 | mov esi,[esp+0] |
||
252 | sub esi,eax |
||
253 | add esi,12+1 ; file name length |
||
254 | call fileread |
||
255 | |||
256 | jmp file_system_return |
||
257 | |||
258 | |||
259 | fs_noramdisk_read: |
||
260 | |||
261 | cmp dword [esp+20],1 ; WRITE |
||
262 | jne fs_noramdisk_write |
||
263 | |||
264 | mov eax,[esp+4] ; fname |
||
265 | add eax,2*12+1 |
||
266 | mov ebx,[esp+8] ; buffer |
||
267 | mov ecx,[esp+12] ; count to write |
||
268 | mov edx,0 ; create new |
||
269 | call filesave |
||
270 | |||
271 | ; eax=0 ok - eax=1 not enough free space |
||
272 | |||
273 | jmp file_system_return |
||
274 | |||
275 | fs_noramdisk_write: |
||
276 | fs_noramdisk: |
||
379 | serge | 277 | |
1 | ha | 278 | ;******************************************************************** |
279 | mov eax,[edi+1] |
||
280 | cmp eax,'FD ' |
||
281 | je fs_yesflpdisk |
||
61 | halyavin | 282 | cmp eax,'FLOP' |
1 | ha | 283 | jne fs_noflpdisk |
284 | |||
285 | fs_yesflpdisk: |
||
286 | call reserve_flp |
||
287 | |||
288 | cmp byte [edi+1+11],0 |
||
289 | je fs_give_dir1 |
||
290 | |||
291 | mov eax,[edi+1+12] |
||
379 | serge | 292 | cmp eax,'1 ' |
1 | ha | 293 | je fs_yesflpdisk_first |
61 | halyavin | 294 | cmp eax,'FIRS' |
1 | ha | 295 | je fs_yesflpdisk_first |
296 | cmp eax,'2 ' |
||
297 | je fs_yesflpdisk_second |
||
61 | halyavin | 298 | cmp eax,'SECO' |
1 | ha | 299 | jne fs_noflpdisk |
300 | jmp fs_yesflpdisk_second |
||
301 | |||
302 | fs_yesflpdisk_first: |
||
303 | mov [flp_number],1 |
||
304 | jmp fs_yesflpdisk_start |
||
305 | fs_yesflpdisk_second: |
||
306 | mov [flp_number],2 |
||
307 | fs_yesflpdisk_start: |
||
308 | cmp dword [esp+20],0 ; READ |
||
309 | jne fs_noflpdisk_read |
||
310 | |||
311 | mov eax,[esp+4] ; fname |
||
312 | add eax,2*12+1 |
||
313 | mov ebx,[esp+16] ; block start |
||
314 | inc ebx |
||
315 | mov ecx,[esp+12] ; block count |
||
316 | mov edx,[esp+8] ; return |
||
317 | mov esi,[esp+0] |
||
318 | sub esi,eax |
||
319 | add esi,12+1 ; file name length |
||
320 | call floppy_fileread |
||
321 | |||
322 | jmp file_system_return |
||
323 | |||
324 | |||
325 | fs_noflpdisk_read: |
||
326 | |||
327 | cmp dword [esp+20],1 ; WRITE |
||
328 | jne fs_noflpdisk_write |
||
329 | |||
330 | mov eax,[esp+4] ; fname |
||
331 | add eax,2*12+1 |
||
332 | mov ebx,[esp+8] ; buffer |
||
333 | mov ecx,[esp+12] ; count to write |
||
334 | mov edx,0 ; create new |
||
335 | call floppy_filesave |
||
336 | |||
337 | ; eax=0 ok - eax=1 not enough free space |
||
338 | |||
339 | jmp file_system_return |
||
340 | |||
341 | fs_noflpdisk_write: |
||
342 | |||
343 | fs_noflpdisk: |
||
344 | ;***************************************************************** |
||
379 | serge | 345 | |
1 | ha | 346 | mov eax,[edi+1] |
347 | cmp eax,'HD0 ' |
||
348 | je fs_yesharddisk_IDE0 |
||
349 | cmp eax,'HD1 ' |
||
350 | je fs_yesharddisk_IDE1 |
||
351 | cmp eax,'HD2 ' |
||
352 | je fs_yesharddisk_IDE2 |
||
353 | cmp eax,'HD3 ' |
||
354 | je fs_yesharddisk_IDE3 |
||
355 | jmp old_path_harddisk |
||
356 | fs_yesharddisk_IDE0: |
||
357 | call reserve_hd1 |
||
358 | mov [hdbase],0x1f0 |
||
359 | mov [hdid],0x0 |
||
360 | mov [hdpos],1 |
||
361 | jmp fs_yesharddisk_partition |
||
362 | fs_yesharddisk_IDE1: |
||
363 | call reserve_hd1 |
||
364 | mov [hdbase],0x1f0 |
||
365 | mov [hdid],0x10 |
||
366 | mov [hdpos],2 |
||
367 | jmp fs_yesharddisk_partition |
||
368 | fs_yesharddisk_IDE2: |
||
369 | call reserve_hd1 |
||
370 | mov [hdbase],0x170 |
||
371 | mov [hdid],0x0 |
||
372 | mov [hdpos],3 |
||
373 | jmp fs_yesharddisk_partition |
||
374 | fs_yesharddisk_IDE3: |
||
375 | call reserve_hd1 |
||
376 | mov [hdbase],0x170 |
||
377 | mov [hdid],0x10 |
||
378 | mov [hdpos],4 |
||
379 | fs_yesharddisk_partition: |
||
321 | diamond | 380 | call reserve_hd_channel |
379 | serge | 381 | ; call choice_necessity_partition |
382 | ; jmp fs_yesharddisk_all |
||
1 | ha | 383 | jmp fs_for_new_semantic |
384 | |||
385 | choice_necessity_partition: |
||
386 | mov eax,[edi+1+12] |
||
387 | call StringToNumber |
||
388 | mov [fat32part],eax |
||
389 | choice_necessity_partition_1: |
||
390 | mov ecx,[hdpos] |
||
391 | xor eax,eax |
||
61 | halyavin | 392 | mov [0xfe10], eax ; entries in hd cache |
1 | ha | 393 | mov edx,0x40002 |
394 | search_partition_array: |
||
395 | mov bl,[edx] |
||
396 | movzx ebx,bl |
||
397 | add eax,ebx |
||
398 | inc edx |
||
399 | loop search_partition_array |
||
400 | sub eax,ebx |
||
401 | add eax,[fat32part] |
||
402 | dec eax |
||
403 | xor edx,edx |
||
404 | imul eax,100 |
||
405 | add eax,0x4000a |
||
406 | mov [transfer_adress],eax |
||
407 | call partition_data_transfer_1 |
||
408 | ret |
||
409 | |||
410 | old_path_harddisk: |
||
411 | mov eax,[edi+1] |
||
412 | cmp eax,'HD ' |
||
413 | je fs_yesharddisk |
||
61 | halyavin | 414 | cmp eax,'HARD' |
1 | ha | 415 | jne fs_noharddisk |
416 | |||
417 | fs_yesharddisk: |
||
418 | cmp dword [esp+20],8 ; LBA read |
||
419 | jne fs_no_LBA_read |
||
420 | mov eax,[esp+16] ; LBA block to read |
||
421 | lea ebx,[edi+1+12] ; pointer to FIRST/SECOND/THIRD/FOURTH |
||
422 | mov ecx,[esp+8] ; abs pointer to return area |
||
423 | call LBA_read |
||
424 | jmp file_system_return |
||
425 | |||
426 | fs_no_LBA_read: |
||
427 | |||
428 | cmp byte [edi+1+11],0 ; directory read |
||
429 | je fs_give_dir1 |
||
63 | halyavin | 430 | call reserve_hd1 |
1 | ha | 431 | fs_for_new_semantic: |
379 | serge | 432 | call choice_necessity_partition |
1 | ha | 433 | |
434 | fs_yesharddisk_all: |
||
435 | mov eax,1 |
||
147 | diamond | 436 | mov ebx, [esp+24+24] |
1 | ha | 437 | cmp [hdpos],0 ; is hd base set? |
63 | halyavin | 438 | jz hd_err_return |
1 | ha | 439 | cmp [fat32part],0 ; is partition set? |
63 | halyavin | 440 | jnz @f |
441 | hd_err_return: |
||
321 | diamond | 442 | call free_hd_channel |
63 | halyavin | 443 | and [hd1_status], 0 |
444 | jmp file_system_return |
||
445 | @@: |
||
1 | ha | 446 | |
447 | cmp dword [esp+20],0 ; READ |
||
448 | jne fs_noharddisk_read |
||
449 | |||
450 | mov eax,[esp+0] ; /fname |
||
451 | lea edi,[eax+12] |
||
452 | mov byte [eax],0 ; path to asciiz |
||
453 | inc eax ; filename start |
||
454 | |||
455 | mov ebx,[esp+12] ; count to read |
||
456 | mov ecx,[esp+8] ; buffer |
||
457 | mov edx,[esp+4] |
||
458 | add edx,12*2 ; dir start |
||
459 | sub edi,edx ; path length |
||
460 | mov esi,[esp+16] ; blocks to read |
||
461 | |||
462 | call file_read |
||
463 | |||
464 | mov edi,[esp+0] |
||
465 | mov byte [edi],'/' |
||
466 | |||
321 | diamond | 467 | call free_hd_channel |
468 | and [hd1_status], 0 |
||
1 | ha | 469 | jmp file_system_return |
470 | |||
471 | fs_noharddisk_read: |
||
472 | |||
473 | |||
474 | cmp dword [esp+20],1 ; WRITE |
||
475 | jne fs_noharddisk_write |
||
476 | |||
477 | mov eax,[esp+0] ; /fname |
||
478 | mov byte [eax],0 ; path to asciiz |
||
479 | inc eax ; filename start |
||
480 | |||
481 | mov ebx,[esp+12] ; count to write |
||
482 | mov ecx,[esp+8] ; buffer |
||
483 | mov edx,[esp+4] |
||
484 | add edx,12*2 ; path start |
||
485 | |||
486 | call file_write |
||
487 | |||
488 | mov edi,[esp+0] |
||
489 | mov byte [edi],'/' |
||
490 | |||
491 | ; eax=0 ok - eax=1 not enough free space |
||
492 | |||
321 | diamond | 493 | call free_hd_channel |
494 | and [hd1_status], 0 |
||
1 | ha | 495 | jmp file_system_return |
496 | |||
497 | |||
498 | fs_noharddisk_write: |
||
499 | |||
500 | |||
321 | diamond | 501 | call free_hd_channel |
502 | and [hd1_status], 0 |
||
1 | ha | 503 | |
504 | fs_noharddisk: |
||
61 | halyavin | 505 | ; \begin{diamond}[18.03.2006] |
64 | mario79 | 506 | mov eax, 5 ; file not found |
61 | halyavin | 507 | ; à ìîæåò áûòü, âîçâðàùàòü äðóãîé êîä îøèáêè? |
147 | diamond | 508 | mov ebx, [esp+24+24] ; do not change ebx in application |
61 | halyavin | 509 | ; \end{diamond}[18.03.2006] |
1 | ha | 510 | |
511 | file_system_return: |
||
512 | |||
513 | add esp,24 |
||
514 | |||
515 | mov [esp+36],eax |
||
516 | mov [esp+24],ebx |
||
517 | ret |
||
518 | |||
519 | |||
520 | fs_give_dir1: |
||
521 | |||
61 | halyavin | 522 | ; \begin{diamond}[18.03.2006] |
523 | ; /RD,/FD,/HD - only read is allowed |
||
524 | ; other operations return "access denied", eax=10 |
||
525 | ; (execute operation returns eax=-10) |
||
64 | mario79 | 526 | cmp dword [esp+20], 0 |
527 | jz .read |
||
528 | add esp, 20 |
||
529 | pop ecx |
||
147 | diamond | 530 | mov dword [esp+36], 10 |
64 | mario79 | 531 | ret |
61 | halyavin | 532 | .read: |
533 | ; \end{diamond}[18.03.2006] |
||
534 | mov al,0x10 |
||
1 | ha | 535 | mov ebx,1 |
536 | mov edi,[esp+8] |
||
537 | mov esi,dir1 |
||
538 | fs_d1_new: |
||
539 | mov ecx,11 |
||
61 | halyavin | 540 | ; cld |
1 | ha | 541 | rep movsb |
542 | stosb |
||
543 | add edi,32-11-1 |
||
544 | dec ebx |
||
545 | jne fs_d1_new |
||
546 | |||
547 | add esp,24 |
||
548 | |||
61 | halyavin | 549 | and dword [esp+36],0 ; ok read |
1 | ha | 550 | mov dword [esp+24],32*1 ; dir/data size |
551 | ret |
||
552 | |||
553 | |||
554 | |||
555 | LBA_read_ramdisk: |
||
556 | |||
557 | cmp [lba_read_enabled],1 |
||
558 | je lbarrl1 |
||
559 | |||
560 | xor ebx,ebx |
||
561 | mov eax,2 |
||
562 | ret |
||
563 | |||
564 | lbarrl1: |
||
565 | |||
566 | cmp eax,18*2*80 |
||
567 | jb lbarrl2 |
||
568 | xor ebx,ebx |
||
569 | mov eax,3 |
||
570 | ret |
||
571 | |||
572 | lbarrl2: |
||
573 | |||
574 | pushad |
||
575 | |||
576 | call restorefatchain |
||
577 | |||
578 | mov edi,ecx |
||
579 | mov esi,eax |
||
580 | |||
581 | shl esi,9 |
||
582 | add esi,0x100000 |
||
583 | mov ecx,512/4 |
||
61 | halyavin | 584 | ; cld |
1 | ha | 585 | rep movsd |
586 | |||
587 | popad |
||
588 | |||
589 | xor ebx,ebx |
||
590 | xor eax,eax |
||
591 | ret |
||
592 | |||
593 | LBA_read: |
||
594 | |||
595 | ; IN: |
||
596 | ; |
||
597 | ; eax = LBA block to read |
||
598 | ; ebx = pointer to FIRST/SECOND/THIRD/FOURTH |
||
599 | ; ecx = abs pointer to return area |
||
600 | |||
601 | cmp [lba_read_enabled],1 |
||
602 | je lbarl1 |
||
603 | mov eax,2 |
||
604 | ret |
||
605 | |||
606 | lbarl1: |
||
607 | |||
63 | halyavin | 608 | call reserve_hd1 |
1 | ha | 609 | |
610 | push eax |
||
611 | push ecx |
||
612 | |||
613 | mov edi,hd_address_table |
||
614 | mov esi,dir1 |
||
615 | mov eax,[ebx] |
||
616 | mov edx,'1 ' |
||
617 | mov ecx,4 |
||
618 | blar0: |
||
619 | cmp eax,[esi] |
||
620 | je blar2 |
||
621 | cmp eax,edx |
||
622 | je blar2 |
||
623 | inc edx |
||
624 | add edi,8 |
||
625 | add esi,11 |
||
626 | dec ecx |
||
627 | jnz blar0 |
||
628 | |||
629 | mov eax,1 |
||
630 | mov ebx,1 |
||
631 | jmp LBA_read_ret |
||
632 | |||
633 | blar2: |
||
634 | mov eax,[edi+0] |
||
635 | mov ebx,[edi+4] |
||
636 | |||
64 | mario79 | 637 | mov [hdbase],eax |
638 | mov [hdid],ebx |
||
639 | |||
1 | ha | 640 | call wait_for_hd_idle |
74 | mario79 | 641 | cmp [hd_error],0 |
642 | jne hd_lba_error |
||
1 | ha | 643 | |
644 | ; eax = hd port |
||
645 | ; ebx = set for primary (0x00) or slave (0x10) |
||
646 | |||
647 | cli |
||
648 | |||
649 | mov edx,eax |
||
650 | inc edx |
||
651 | xor eax,eax |
||
652 | out dx,al |
||
653 | inc edx |
||
654 | inc eax |
||
655 | out dx,al |
||
656 | inc edx |
||
657 | mov eax,[esp+4] |
||
658 | out dx,al |
||
659 | shr eax,8 |
||
660 | inc edx |
||
661 | out dx,al |
||
662 | shr eax,8 |
||
663 | inc edx |
||
664 | out dx,al |
||
665 | shr eax,8 |
||
666 | inc edx |
||
667 | and al,1+2+4+8 |
||
668 | add al,bl |
||
669 | add al,128+64+32 |
||
670 | out dx,al |
||
671 | |||
672 | inc edx |
||
673 | mov al,20h |
||
674 | out dx,al |
||
675 | |||
676 | sti |
||
677 | |||
678 | call wait_for_sector_buffer |
||
74 | mario79 | 679 | cmp [hd_error],0 |
680 | jne hd_lba_error |
||
1 | ha | 681 | |
682 | cli |
||
683 | |||
684 | mov edi,[esp+0] |
||
685 | mov ecx,256 |
||
686 | sub edx,7 |
||
687 | cld |
||
688 | rep insw |
||
689 | |||
690 | sti |
||
691 | |||
692 | xor eax,eax |
||
693 | xor ebx,ebx |
||
694 | |||
695 | LBA_read_ret: |
||
74 | mario79 | 696 | mov [hd_error],0 |
1 | ha | 697 | mov [hd1_status],0 |
698 | add esp,2*4 |
||
699 | |||
700 | ret |
||
701 | |||
702 | |||
703 | expand_pathz: |
||
704 | ; IN: |
||
705 | ; esi = asciiz path & file |
||
706 | ; edi = buffer for path & file name |
||
707 | ; OUT: |
||
708 | ; edi = directory & file : / 11 + / 11 + / 11 - zero terminated |
||
709 | ; ebx = /file name - zero terminated |
||
710 | ; esi = pointer after source |
||
711 | |||
712 | push eax |
||
713 | push ecx |
||
714 | push edi ;[esp+0] |
||
715 | |||
716 | pathz_start: |
||
717 | mov byte [edi],'/' |
||
718 | inc edi |
||
719 | mov al,32 |
||
720 | mov ecx,11 |
||
721 | cld |
||
722 | rep stosb ; clear filename area |
||
723 | sub edi,11 |
||
724 | mov ebx,edi ; start of dir/file name |
||
725 | |||
726 | pathz_new_char: |
||
727 | mov al,[esi] |
||
728 | inc esi |
||
729 | cmp al,0 |
||
730 | je pathz_end |
||
731 | |||
732 | cmp al,'/' |
||
733 | jne pathz_not_path |
||
734 | cmp edi,ebx ; skip first '/' |
||
735 | jz pathz_new_char |
||
736 | lea edi,[ebx+11] ; start of next directory |
||
737 | jmp pathz_start |
||
738 | |||
739 | pathz_not_path: |
||
740 | cmp al,'.' |
||
741 | jne pathz_not_ext |
||
742 | lea edi,[ebx+8] ; start of extension |
||
743 | jmp pathz_new_char |
||
744 | |||
745 | pathz_not_ext: |
||
746 | cmp al,'a' |
||
747 | jb pathz_not_low |
||
748 | cmp al,'z' |
||
749 | ja pathz_not_low |
||
750 | sub al,0x20 ; char to uppercase |
||
751 | |||
752 | pathz_not_low: |
||
753 | mov [edi],al |
||
754 | inc edi |
||
755 | mov eax,[esp+0] ; start_of_dest_path |
||
756 | add eax,512 ; keep maximum path under 512 bytes |
||
757 | cmp edi,eax |
||
758 | jb pathz_new_char |
||
759 | |||
760 | pathz_end: |
||
761 | cmp ebx,edi ; if path end with '/' |
||
762 | jnz pathz_put_zero ; go back 1 level |
||
763 | sub ebx,12 |
||
764 | |||
765 | pathz_put_zero: |
||
766 | mov byte [ebx+11],0 |
||
767 | dec ebx ; include '/' char into file name |
||
768 | pop edi |
||
769 | pop ecx |
||
770 | pop eax |
||
771 | ret |
||
772 | |||
773 | ;******************************************* |
||
774 | ;* string to number |
||
775 | ;* input eax - 4 byte string |
||
776 | ;* output eax - number |
||
777 | ;******************************************* |
||
778 | StringToNumber: |
||
779 | ; ÏÅÐÅÂÎÄ ÑÒÐÎÊÎÂÎÃÎ ×ÈÑËÀ  ×ÈÑËÎÂÎÉ ÂÈÄ |
||
780 | ; Âõîä: |
||
781 | ; EDI - àäðåñ ñòðîêè ñ ÷èñëîì. Êîíåö ÷èñëà îòìå÷åí êîäîì 0Dh |
||
782 | ; Âûõîä: |
||
783 | ; CF - èíäèêàòîð îøèáîê: |
||
784 | ; 0 - îøèáîê íåò; |
||
785 | ; 1 - îøèáêà |
||
786 | ; Åñëè CF=0, òî AX - ÷èñëî. |
||
787 | |||
788 | push bx |
||
789 | push cx |
||
790 | push dx |
||
791 | push edi |
||
792 | mov [partition_string],eax |
||
793 | mov edi,partition_string |
||
794 | xor cx,cx |
||
379 | serge | 795 | i1: |
1 | ha | 796 | mov al,[edi] |
797 | cmp al,32 ;13 |
||
798 | je i_exit |
||
799 | ; cmp al,'0' |
||
800 | ; jb err |
||
801 | ; cmp al,'9' |
||
802 | ; ja err |
||
803 | sub al,48 |
||
804 | shl cx,1 |
||
805 | jc err |
||
806 | mov bx,cx |
||
807 | shl cx,1 |
||
808 | jc err |
||
809 | shl cx,1 |
||
810 | jc err |
||
811 | add cx,bx |
||
812 | jc err |
||
813 | cbw |
||
814 | add cx,ax |
||
815 | jc err |
||
816 | i3: |
||
817 | inc edi |
||
818 | jmp i1 |
||
819 | i_exit: |
||
820 | mov ax,cx |
||
821 | clc |
||
822 | i4: |
||
823 | movzx eax,ax |
||
824 | pop edi |
||
825 | pop dx |
||
826 | pop cx |
||
827 | pop bx |
||
828 | ret |
||
829 | |||
830 | err: |
||
831 | stc |
||
832 | jmp i4 |
||
833 | |||
834 | partition_string: dd 0 |
||
835 | db 32>=>>=> |