2010-10-01 11:21:55 +02:00
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
;; ;;
|
2012-03-15 13:41:29 +01:00
|
|
|
|
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
|
2010-10-01 11:21:55 +02:00
|
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
|
;; ;;
|
|
|
|
|
;; ;;
|
|
|
|
|
;; System service for filesystem call ;;
|
|
|
|
|
;; (C) 2004 Ville Turjanmaa, License: GPL ;;
|
|
|
|
|
;; 29.04.2006 Elimination of hangup after the ;;
|
|
|
|
|
;; expiration hd_wait_timeout (for LBA) - Mario79 ;;
|
|
|
|
|
;; 15.01.2005 get file size/attr/date, ;;
|
|
|
|
|
;; file_append (only for hd) - ATV ;;
|
|
|
|
|
;; 23.11.2004 test if hd/partition is set - ATV ;;
|
|
|
|
|
;; 18.11.2004 get_disk_info and more error codes - ATV ;;
|
|
|
|
|
;; 08.11.2004 expand_pathz and rename (only for hd) - ATV ;;
|
|
|
|
|
;; 20.10.2004 Makedir/Removedir (only for hd) - ATV ;;
|
|
|
|
|
;; ;;
|
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
|
|
$Revision$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
iglobal
|
2013-05-11 14:38:27 +02:00
|
|
|
|
|
|
|
|
|
if lang eq sp
|
|
|
|
|
include 'fs/fs-sp.inc'
|
|
|
|
|
else
|
2012-03-08 09:33:38 +01:00
|
|
|
|
dir0:
|
|
|
|
|
db 'HARDDISK '
|
2010-10-01 11:21:55 +02:00
|
|
|
|
db 'RAMDISK '
|
|
|
|
|
db 'FLOPPYDISK '
|
|
|
|
|
db 0
|
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
dir1:
|
|
|
|
|
db 'FIRST '
|
2010-10-01 11:21:55 +02:00
|
|
|
|
db 'SECOND '
|
|
|
|
|
db 'THIRD '
|
|
|
|
|
db 'FOURTH '
|
|
|
|
|
db 0
|
2013-05-11 14:38:27 +02:00
|
|
|
|
end if
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
not_select_IDE db 0
|
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
hd_address_table:
|
|
|
|
|
dd 0x1f0,0x00,0x1f0,0x10
|
2010-10-01 11:21:55 +02:00
|
|
|
|
dd 0x170,0x00,0x170,0x10
|
|
|
|
|
endg
|
|
|
|
|
|
|
|
|
|
file_system:
|
|
|
|
|
|
|
|
|
|
; IN:
|
|
|
|
|
;
|
|
|
|
|
; eax = 0 ; read file /RamDisk/First 6
|
|
|
|
|
; eax = 8 ; lba read
|
|
|
|
|
; eax = 15 ; get_disk_info
|
|
|
|
|
;
|
|
|
|
|
; OUT:
|
|
|
|
|
;
|
|
|
|
|
; eax = 0 : read ok
|
|
|
|
|
; eax = 1 : no hd base and/or partition defined
|
|
|
|
|
; eax = 2 : function is unsupported for this FS
|
|
|
|
|
; eax = 3 : unknown FS
|
|
|
|
|
; eax = 4 : partition not defined at hd
|
|
|
|
|
; eax = 5 : file not found
|
|
|
|
|
; eax = 6 : end of file
|
|
|
|
|
; eax = 7 : memory pointer not in application area
|
|
|
|
|
; eax = 8 : disk full
|
|
|
|
|
; eax = 9 : fat table corrupted
|
|
|
|
|
; eax = 10 : access denied
|
|
|
|
|
; eax = 11 : disk error
|
|
|
|
|
;
|
|
|
|
|
; ebx = size
|
|
|
|
|
|
|
|
|
|
; \begin{diamond}[18.03.2006]
|
|
|
|
|
; for subfunction 16 (start application) error codes must be negative
|
|
|
|
|
; because positive values are valid PIDs
|
|
|
|
|
; so possible return values are:
|
|
|
|
|
; eax > 0 : process created, eax=PID
|
|
|
|
|
|
|
|
|
|
; -0x10 <= eax < 0 : -eax is filesystem error code:
|
|
|
|
|
; eax = -1 = 0xFFFFFFFF : no hd base and/or partition defined
|
|
|
|
|
; eax = -3 = 0xFFFFFFFD : unknown FS
|
|
|
|
|
; eax = -5 = 0xFFFFFFFB : file not found
|
|
|
|
|
; eax = -6 = 0xFFFFFFFA : unexpected end of file (probably not executable file)
|
|
|
|
|
; eax = -9 = 0xFFFFFFF7 : fat table corrupted
|
|
|
|
|
; eax = -10 = 0xFFFFFFF6 : access denied
|
|
|
|
|
|
|
|
|
|
; -0x20 <= eax < -0x10: eax is process creation error code:
|
|
|
|
|
; eax = -0x20 = 0xFFFFFFE0 : too many processes
|
|
|
|
|
; eax = -0x1F = 0xFFFFFFE1 : not Menuet/Kolibri executable
|
|
|
|
|
; eax = -0x1E = 0xFFFFFFE2 : no memory
|
|
|
|
|
|
|
|
|
|
; ebx is not changed
|
|
|
|
|
|
|
|
|
|
; \end{diamond}[18.03.2006]
|
|
|
|
|
|
|
|
|
|
; Extract parameters
|
|
|
|
|
; add eax, std_application_base_address ; abs start of info block
|
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp dword [eax+0], 15; GET_DISK_INFO
|
|
|
|
|
je fs_info
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp dword [CURRENT_TASK], 1; no memory checks for kernel requests
|
|
|
|
|
jz no_checks_for_kernel
|
|
|
|
|
mov edx, eax
|
|
|
|
|
cmp dword [eax+0], 1
|
|
|
|
|
jnz .usual_check
|
|
|
|
|
mov ebx, [eax+12]
|
2010-10-01 11:21:55 +02:00
|
|
|
|
; add ebx,std_application_base_address
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov ecx, [eax+8]
|
|
|
|
|
call check_region
|
|
|
|
|
test eax, eax
|
|
|
|
|
jnz area_in_app_mem
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
.error_output:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov esi, buffer_failed
|
|
|
|
|
call sys_msg_board_str
|
2010-10-01 11:21:55 +02:00
|
|
|
|
; mov eax,7
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov dword [esp+36], 7
|
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
iglobal
|
|
|
|
|
buffer_failed db 'K : Buffer check failed',13,10,0
|
|
|
|
|
endg
|
|
|
|
|
.usual_check:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp dword [eax+0], 0
|
|
|
|
|
mov ecx, 512
|
|
|
|
|
jnz .small_size
|
|
|
|
|
mov ecx, [eax+8]
|
|
|
|
|
shl ecx, 9
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.small_size:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov ebx, [eax+12]
|
2010-10-01 11:21:55 +02:00
|
|
|
|
; add ebx,std_application_base_address
|
2012-03-08 09:33:38 +01:00
|
|
|
|
call check_region
|
|
|
|
|
test eax, eax
|
|
|
|
|
jz .error_output
|
2010-10-01 11:21:55 +02:00
|
|
|
|
area_in_app_mem:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, edx
|
2010-10-01 11:21:55 +02:00
|
|
|
|
no_checks_for_kernel:
|
|
|
|
|
|
|
|
|
|
fs_read:
|
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov ebx, [eax+20] ; program wants root directory ?
|
|
|
|
|
test bl, bl
|
|
|
|
|
je fs_getroot
|
|
|
|
|
test bh, bh
|
|
|
|
|
jne fs_noroot
|
2010-10-01 11:21:55 +02:00
|
|
|
|
fs_getroot:
|
|
|
|
|
; \begin{diamond}[18.03.2006]
|
|
|
|
|
; root - only read is allowed
|
|
|
|
|
; other operations return "access denied", eax=10
|
|
|
|
|
; (execute operation returns eax=-10)
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp dword [eax], 0
|
|
|
|
|
jz .read_root
|
|
|
|
|
mov dword [esp+36], 10
|
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.read_root:
|
|
|
|
|
; \end{diamond}[18.03.2006]
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov esi, dir0
|
|
|
|
|
mov edi, [eax+12]
|
2010-10-01 11:21:55 +02:00
|
|
|
|
; add edi,std_application_base_address
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov ecx, 11
|
|
|
|
|
push ecx
|
2010-10-01 11:21:55 +02:00
|
|
|
|
; cld ; already is
|
2012-03-08 09:33:38 +01:00
|
|
|
|
rep movsb
|
|
|
|
|
mov al, 0x10
|
|
|
|
|
stosb
|
|
|
|
|
add edi, 32-11-1
|
|
|
|
|
pop ecx
|
|
|
|
|
rep movsb
|
|
|
|
|
stosb
|
|
|
|
|
and dword [esp+36], 0; ok read
|
|
|
|
|
mov dword [esp+24], 32*2; size of root
|
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
fs_info: ;start of code - Mihasik
|
2012-03-08 09:33:38 +01:00
|
|
|
|
push eax
|
|
|
|
|
cmp [eax+21], byte 'r'
|
|
|
|
|
je fs_info_r
|
|
|
|
|
cmp [eax+21], byte 'R'
|
|
|
|
|
je fs_info_r
|
|
|
|
|
mov eax, 3 ;if unknown disk
|
|
|
|
|
xor ebx, ebx
|
|
|
|
|
xor ecx, ecx
|
|
|
|
|
xor edx, edx
|
|
|
|
|
jmp fs_info1
|
2010-10-01 11:21:55 +02:00
|
|
|
|
fs_info_r:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
call ramdisk_free_space;if ramdisk
|
|
|
|
|
mov ecx, edi ;free space in ecx
|
|
|
|
|
shr ecx, 9 ;free clusters
|
|
|
|
|
mov ebx, 2847 ;total clusters
|
|
|
|
|
mov edx, 512 ;cluster size
|
|
|
|
|
xor eax, eax ;always 0
|
2010-10-01 11:21:55 +02:00
|
|
|
|
fs_info1:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
pop edi
|
|
|
|
|
mov [esp+36], eax
|
|
|
|
|
mov [esp+24], ebx ; total clusters on disk
|
|
|
|
|
mov [esp+32], ecx ; free clusters on disk
|
|
|
|
|
mov [edi], edx ; cluster size in bytes
|
|
|
|
|
ret ;end of code - Mihasik
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
fs_noroot:
|
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
push dword [eax+0] ; read/write/delete/.../makedir/rename/lba/run
|
|
|
|
|
push dword [eax+4] ; 512 block number to read
|
|
|
|
|
push dword [eax+8] ; bytes to write/append or 512 blocks to read
|
|
|
|
|
mov ebx, [eax+12]
|
2010-10-01 11:21:55 +02:00
|
|
|
|
; add ebx,std_application_base_address
|
2012-03-08 09:33:38 +01:00
|
|
|
|
push ebx ; abs start of return/save area
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
lea esi, [eax+20] ; abs start of dir + filename
|
|
|
|
|
mov edi, [eax+16]
|
2010-10-01 11:21:55 +02:00
|
|
|
|
; add edi,std_application_base_address ; abs start of work area
|
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
call expand_pathz
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
push edi ; dir start
|
|
|
|
|
push ebx ; name of file start
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, [edi+1]
|
|
|
|
|
cmp eax, 'RD '
|
|
|
|
|
je fs_yesramdisk
|
|
|
|
|
cmp eax, 'RAMD'
|
|
|
|
|
jne fs_noramdisk
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
fs_yesramdisk:
|
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp byte [edi+1+11], 0
|
|
|
|
|
je fs_give_dir1
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, [edi+1+12]
|
|
|
|
|
cmp eax, '1 '
|
|
|
|
|
je fs_yesramdisk_first
|
|
|
|
|
cmp eax, 'FIRS'
|
|
|
|
|
jne fs_noramdisk
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
fs_yesramdisk_first:
|
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp dword [esp+20], 8; LBA read ramdisk
|
|
|
|
|
jne fs_no_LBA_read_ramdisk
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, [esp+16] ; LBA block to read
|
|
|
|
|
mov ecx, [esp+8] ; abs pointer to return area
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
call LBA_read_ramdisk
|
|
|
|
|
jmp file_system_return
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs_no_LBA_read_ramdisk:
|
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp dword [esp+20], 0; READ
|
|
|
|
|
jne fs_noramdisk_read
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, [esp+4] ; fname
|
|
|
|
|
add eax, 2*12+1
|
|
|
|
|
mov ebx, [esp+16] ; block start
|
|
|
|
|
inc ebx
|
|
|
|
|
mov ecx, [esp+12] ; block count
|
|
|
|
|
mov edx, [esp+8] ; return
|
|
|
|
|
mov esi, [esp+0]
|
|
|
|
|
sub esi, eax
|
|
|
|
|
add esi, 12+1 ; file name length
|
|
|
|
|
call fileread
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
jmp file_system_return
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs_noramdisk_read:
|
|
|
|
|
fs_noramdisk:
|
|
|
|
|
|
|
|
|
|
;********************************************************************
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, [edi+1]
|
|
|
|
|
cmp eax, 'FD '
|
|
|
|
|
je fs_yesflpdisk
|
|
|
|
|
cmp eax, 'FLOP'
|
|
|
|
|
jne fs_noflpdisk
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
fs_yesflpdisk:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
call reserve_flp
|
|
|
|
|
|
|
|
|
|
cmp byte [edi+1+11], 0
|
|
|
|
|
je fs_give_dir1
|
|
|
|
|
|
|
|
|
|
mov eax, [edi+1+12]
|
|
|
|
|
cmp eax, '1 '
|
|
|
|
|
je fs_yesflpdisk_first
|
|
|
|
|
cmp eax, 'FIRS'
|
|
|
|
|
je fs_yesflpdisk_first
|
|
|
|
|
cmp eax, '2 '
|
|
|
|
|
je fs_yesflpdisk_second
|
|
|
|
|
cmp eax, 'SECO'
|
|
|
|
|
jne fs_noflpdisk
|
|
|
|
|
jmp fs_yesflpdisk_second
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
fs_yesflpdisk_first:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [flp_number], 1
|
|
|
|
|
jmp fs_yesflpdisk_start
|
2010-10-01 11:21:55 +02:00
|
|
|
|
fs_yesflpdisk_second:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [flp_number], 2
|
2010-10-01 11:21:55 +02:00
|
|
|
|
fs_yesflpdisk_start:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp dword [esp+20], 0; READ
|
|
|
|
|
jne fs_noflpdisk_read
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, [esp+4] ; fname
|
|
|
|
|
add eax, 2*12+1
|
|
|
|
|
mov ebx, [esp+16] ; block start
|
|
|
|
|
inc ebx
|
|
|
|
|
mov ecx, [esp+12] ; block count
|
|
|
|
|
mov edx, [esp+8] ; return
|
|
|
|
|
mov esi, [esp+0]
|
|
|
|
|
sub esi, eax
|
|
|
|
|
add esi, 12+1 ; file name length
|
|
|
|
|
call floppy_fileread
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
jmp file_system_return
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs_noflpdisk_read:
|
|
|
|
|
fs_noflpdisk:
|
|
|
|
|
;*****************************************************************
|
|
|
|
|
|
|
|
|
|
old_path_harddisk:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, [edi+1]
|
|
|
|
|
cmp eax, 'HD '
|
|
|
|
|
je fs_yesharddisk
|
|
|
|
|
cmp eax, 'HARD'
|
|
|
|
|
jne fs_noharddisk
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
fs_yesharddisk:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp dword [esp+20], 8; LBA read
|
|
|
|
|
jne fs_no_LBA_read
|
|
|
|
|
mov eax, [esp+16] ; LBA block to read
|
|
|
|
|
lea ebx, [edi+1+12] ; pointer to FIRST/SECOND/THIRD/FOURTH
|
|
|
|
|
mov ecx, [esp+8] ; abs pointer to return area
|
|
|
|
|
call LBA_read
|
|
|
|
|
jmp file_system_return
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
fs_no_LBA_read:
|
|
|
|
|
|
|
|
|
|
hd_err_return:
|
|
|
|
|
|
|
|
|
|
fs_noharddisk:
|
|
|
|
|
; \begin{diamond}[18.03.2006]
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, 5 ; file not found
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; а может быть, возвращать другой код ошибки?
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov ebx, [esp+24+24]; do not change ebx in application
|
2010-10-01 11:21:55 +02:00
|
|
|
|
; \end{diamond}[18.03.2006]
|
|
|
|
|
|
|
|
|
|
file_system_return:
|
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
add esp, 24
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [esp+36], eax
|
|
|
|
|
mov [esp+24], ebx
|
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fs_give_dir1:
|
|
|
|
|
|
|
|
|
|
; \begin{diamond}[18.03.2006]
|
|
|
|
|
; /RD,/FD,/HD - only read is allowed
|
|
|
|
|
; other operations return "access denied", eax=10
|
|
|
|
|
; (execute operation returns eax=-10)
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp dword [esp+20], 0
|
|
|
|
|
jz .read
|
|
|
|
|
add esp, 20
|
|
|
|
|
pop ecx
|
|
|
|
|
mov dword [esp+36], 10
|
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
.read:
|
|
|
|
|
; \end{diamond}[18.03.2006]
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov al, 0x10
|
|
|
|
|
mov ebx, 1
|
|
|
|
|
mov edi, [esp+8]
|
|
|
|
|
mov esi, dir1
|
2010-10-01 11:21:55 +02:00
|
|
|
|
fs_d1_new:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov ecx, 11
|
2010-10-01 11:21:55 +02:00
|
|
|
|
; cld
|
2012-03-08 09:33:38 +01:00
|
|
|
|
rep movsb
|
|
|
|
|
stosb
|
|
|
|
|
add edi, 32-11-1
|
|
|
|
|
dec ebx
|
|
|
|
|
jne fs_d1_new
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
add esp, 24
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
and dword [esp+36], 0; ok read
|
|
|
|
|
mov dword [esp+24], 32*1; dir/data size
|
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LBA_read_ramdisk:
|
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [lba_read_enabled], 1
|
|
|
|
|
je lbarrl1
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
xor ebx, ebx
|
|
|
|
|
mov eax, 2
|
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
lbarrl1:
|
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp eax, 18*2*80
|
|
|
|
|
jb lbarrl2
|
|
|
|
|
xor ebx, ebx
|
|
|
|
|
mov eax, 3
|
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
lbarrl2:
|
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
pushad
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
call restorefatchain
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov edi, ecx
|
|
|
|
|
mov esi, eax
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
shl esi, 9
|
|
|
|
|
add esi, RAMDISK
|
|
|
|
|
mov ecx, 512/4
|
2010-10-01 11:21:55 +02:00
|
|
|
|
; cld
|
2012-03-08 09:33:38 +01:00
|
|
|
|
rep movsd
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
popad
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
xor ebx, ebx
|
|
|
|
|
xor eax, eax
|
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
LBA_read:
|
|
|
|
|
|
|
|
|
|
; IN:
|
|
|
|
|
;
|
|
|
|
|
; eax = LBA block to read
|
|
|
|
|
; ebx = pointer to FIRST/SECOND/THIRD/FOURTH
|
|
|
|
|
; ecx = abs pointer to return area
|
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp [lba_read_enabled], 1
|
|
|
|
|
je lbarl1
|
|
|
|
|
mov eax, 2
|
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
lbarl1:
|
|
|
|
|
|
2013-09-14 20:55:13 +02:00
|
|
|
|
pushad
|
|
|
|
|
mov ecx, ide_mutex
|
|
|
|
|
call mutex_lock
|
|
|
|
|
popad
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
push eax
|
|
|
|
|
push ecx
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov edi, hd_address_table
|
|
|
|
|
mov esi, dir1
|
|
|
|
|
mov eax, [ebx]
|
|
|
|
|
mov edx, '1 '
|
|
|
|
|
mov ecx, 4
|
2010-10-01 11:21:55 +02:00
|
|
|
|
blar0:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp eax, [esi]
|
|
|
|
|
je blar2
|
|
|
|
|
cmp eax, edx
|
|
|
|
|
je blar2
|
|
|
|
|
inc edx
|
|
|
|
|
add edi, 8
|
|
|
|
|
add esi, 11
|
|
|
|
|
dec ecx
|
|
|
|
|
jnz blar0
|
|
|
|
|
|
|
|
|
|
mov eax, 1
|
|
|
|
|
mov ebx, 1
|
|
|
|
|
jmp LBA_read_ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
blar2:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov eax, [edi+0]
|
|
|
|
|
mov ebx, [edi+4]
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [hdbase], eax
|
|
|
|
|
mov [hdid], ebx
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
call wait_for_hd_idle
|
|
|
|
|
cmp [hd_error], 0
|
|
|
|
|
jne hd_lba_error
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
; eax = hd port
|
|
|
|
|
; ebx = set for primary (0x00) or slave (0x10)
|
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cli
|
|
|
|
|
|
|
|
|
|
mov edx, eax
|
|
|
|
|
inc edx
|
|
|
|
|
xor eax, eax
|
|
|
|
|
out dx, al
|
|
|
|
|
inc edx
|
|
|
|
|
inc eax
|
|
|
|
|
out dx, al
|
|
|
|
|
inc edx
|
|
|
|
|
mov eax, [esp+4]
|
|
|
|
|
out dx, al
|
|
|
|
|
shr eax, 8
|
|
|
|
|
inc edx
|
|
|
|
|
out dx, al
|
|
|
|
|
shr eax, 8
|
|
|
|
|
inc edx
|
|
|
|
|
out dx, al
|
|
|
|
|
shr eax, 8
|
|
|
|
|
inc edx
|
|
|
|
|
and al, 1+2+4+8
|
|
|
|
|
add al, bl
|
|
|
|
|
add al, 128+64+32
|
|
|
|
|
out dx, al
|
|
|
|
|
|
|
|
|
|
inc edx
|
|
|
|
|
mov al, 20h
|
|
|
|
|
out dx, al
|
|
|
|
|
|
|
|
|
|
sti
|
|
|
|
|
|
|
|
|
|
call wait_for_sector_buffer
|
|
|
|
|
cmp [hd_error], 0
|
|
|
|
|
jne hd_lba_error
|
|
|
|
|
|
|
|
|
|
cli
|
|
|
|
|
|
|
|
|
|
mov edi, [esp+0]
|
|
|
|
|
mov ecx, 256
|
|
|
|
|
sub edx, 7
|
|
|
|
|
cld
|
|
|
|
|
rep insw
|
|
|
|
|
|
|
|
|
|
sti
|
|
|
|
|
|
|
|
|
|
xor eax, eax
|
|
|
|
|
xor ebx, ebx
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
LBA_read_ret:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [hd_error], 0
|
|
|
|
|
mov [hd1_status], 0
|
|
|
|
|
add esp, 2*4
|
2013-09-14 20:55:13 +02:00
|
|
|
|
pushad
|
|
|
|
|
mov ecx, ide_mutex
|
|
|
|
|
call mutex_unlock
|
|
|
|
|
popad
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expand_pathz:
|
|
|
|
|
; IN:
|
|
|
|
|
; esi = asciiz path & file
|
|
|
|
|
; edi = buffer for path & file name
|
|
|
|
|
; OUT:
|
|
|
|
|
; edi = directory & file : / 11 + / 11 + / 11 - zero terminated
|
|
|
|
|
; ebx = /file name - zero terminated
|
|
|
|
|
; esi = pointer after source
|
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
push eax
|
|
|
|
|
push ecx
|
|
|
|
|
push edi;[esp+0]
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
pathz_start:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov byte [edi], '/'
|
|
|
|
|
inc edi
|
|
|
|
|
mov al, 32
|
|
|
|
|
mov ecx, 11
|
|
|
|
|
cld
|
|
|
|
|
rep stosb ; clear filename area
|
|
|
|
|
sub edi, 11
|
|
|
|
|
mov ebx, edi ; start of dir/file name
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
pathz_new_char:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov al, [esi]
|
|
|
|
|
inc esi
|
|
|
|
|
cmp al, 0
|
|
|
|
|
je pathz_end
|
|
|
|
|
|
|
|
|
|
cmp al, '/'
|
|
|
|
|
jne pathz_not_path
|
|
|
|
|
cmp edi, ebx ; skip first '/'
|
|
|
|
|
jz pathz_new_char
|
|
|
|
|
lea edi, [ebx+11] ; start of next directory
|
|
|
|
|
jmp pathz_start
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
pathz_not_path:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp al, '.'
|
|
|
|
|
jne pathz_not_ext
|
|
|
|
|
lea edi, [ebx+8] ; start of extension
|
|
|
|
|
jmp pathz_new_char
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
pathz_not_ext:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp al, 'a'
|
|
|
|
|
jb pathz_not_low
|
|
|
|
|
cmp al, 'z'
|
|
|
|
|
ja pathz_not_low
|
|
|
|
|
sub al, 0x20 ; char to uppercase
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
pathz_not_low:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov [edi], al
|
|
|
|
|
inc edi
|
|
|
|
|
mov eax, [esp+0] ; start_of_dest_path
|
|
|
|
|
add eax, 512 ; keep maximum path under 512 bytes
|
|
|
|
|
cmp edi, eax
|
|
|
|
|
jb pathz_new_char
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
pathz_end:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
cmp ebx, edi ; if path end with '/'
|
|
|
|
|
jnz pathz_put_zero ; go back 1 level
|
|
|
|
|
sub ebx, 12
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
pathz_put_zero:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov byte [ebx+11], 0
|
|
|
|
|
dec ebx ; include '/' char into file name
|
|
|
|
|
pop edi
|
|
|
|
|
pop ecx
|
|
|
|
|
pop eax
|
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
;*******************************************
|
|
|
|
|
;* string to number
|
|
|
|
|
;* input eax - 4 byte string
|
|
|
|
|
;* output eax - number
|
|
|
|
|
;*******************************************
|
|
|
|
|
StringToNumber:
|
2013-05-28 21:09:31 +02:00
|
|
|
|
; ПЕРЕВОД СТРОКОВОГО ЧИСЛА В ЧИСЛОВОЙ ВИД
|
|
|
|
|
; Вход:
|
|
|
|
|
; EDI - адрес строки с числом. Конец числа отмечен кодом 0Dh
|
|
|
|
|
; Выход:
|
|
|
|
|
; CF - индикатор ошибок:
|
|
|
|
|
; 0 - ошибок нет;
|
|
|
|
|
; 1 - ошибка
|
|
|
|
|
; Если CF=0, то AX - число.
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
push bx
|
|
|
|
|
push cx
|
|
|
|
|
push dx
|
|
|
|
|
push edi
|
|
|
|
|
mov [partition_string], eax
|
|
|
|
|
mov edi, partition_string
|
|
|
|
|
xor cx, cx
|
2010-10-01 11:21:55 +02:00
|
|
|
|
i1:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov al, [edi]
|
|
|
|
|
cmp al, 32;13
|
|
|
|
|
je i_exit
|
2010-10-01 11:21:55 +02:00
|
|
|
|
; cmp al,'0'
|
|
|
|
|
; jb err
|
|
|
|
|
; cmp al,'9'
|
|
|
|
|
; ja err
|
2012-03-08 09:33:38 +01:00
|
|
|
|
sub al, 48
|
|
|
|
|
shl cx, 1
|
|
|
|
|
jc error
|
|
|
|
|
mov bx, cx
|
|
|
|
|
shl cx, 1
|
|
|
|
|
jc error
|
|
|
|
|
shl cx, 1
|
|
|
|
|
jc error
|
|
|
|
|
add cx, bx
|
|
|
|
|
jc error
|
|
|
|
|
cbw
|
|
|
|
|
add cx, ax
|
|
|
|
|
jc error
|
2010-10-01 11:21:55 +02:00
|
|
|
|
i3:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
inc edi
|
|
|
|
|
jmp i1
|
2010-10-01 11:21:55 +02:00
|
|
|
|
i_exit:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
mov ax, cx
|
|
|
|
|
clc
|
2010-10-01 11:21:55 +02:00
|
|
|
|
i4:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
movzx eax, ax
|
|
|
|
|
pop edi
|
|
|
|
|
pop dx
|
|
|
|
|
pop cx
|
|
|
|
|
pop bx
|
|
|
|
|
ret
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
|
|
|
|
error:
|
2012-03-08 09:33:38 +01:00
|
|
|
|
stc
|
|
|
|
|
jmp i4
|
2010-10-01 11:21:55 +02:00
|
|
|
|
|
2012-03-08 09:33:38 +01:00
|
|
|
|
partition_string:
|
|
|
|
|
dd 0
|
2010-10-01 11:21:55 +02:00
|
|
|
|
db 32
|