use __CDECL16 macros and clean up a few proc calls
This commit is contained in:
@@ -25,14 +25,9 @@ ALIGN 4, db 0x90
|
|||||||
InitFATDriver:
|
InitFATDriver:
|
||||||
__CDECL16_PROC_ENTRY
|
__CDECL16_PROC_ENTRY
|
||||||
.func:
|
.func:
|
||||||
mov ax, FAT32_State_t_size
|
|
||||||
push ax ; length of fat32_state structure
|
__CDECL16_CALL_ARGS fat32_state, 0x0000, FAT32_State_t_size
|
||||||
xor ax, ax
|
__CDECL16_CALL kmemset, 3
|
||||||
push ax ; init fat32_state with zero
|
|
||||||
mov ax, fat32_state
|
|
||||||
push ax ; address of structure
|
|
||||||
call kmemset
|
|
||||||
add sp, 0x6
|
|
||||||
|
|
||||||
.calc_active_part:
|
.calc_active_part:
|
||||||
mov ax, word [partition_offset]
|
mov ax, word [partition_offset]
|
||||||
@@ -111,13 +106,12 @@ SearchFATDIR:
|
|||||||
|
|
||||||
mov bx, fat32_state
|
mov bx, fat32_state
|
||||||
.load_first_dir:
|
.load_first_dir:
|
||||||
mov eax, dword [bx + FAT32_State_t.curr_dir_cluster_32]
|
|
||||||
push dword eax ; cluster
|
; uint8_t ReadFATCluster(uint16_t seg, uint16_t offset, uint32_t cluster)
|
||||||
mov ax, dir_buffer
|
push dword [bx + FAT32_State_t.curr_dir_cluster_32] ; cluster
|
||||||
push ax ; offset
|
push dir_buffer ; offset
|
||||||
xor ax, ax
|
push 0x0000 ; segment
|
||||||
push ax ; segment
|
call ReadFATCluster
|
||||||
call ReadFATCluster ; uint8_t ReadFATCluster(uint16_t seg, uint16_t offset, uint32_t cluster)
|
|
||||||
add sp, 0x8
|
add sp, 0x8
|
||||||
|
|
||||||
mov si, dir_buffer
|
mov si, dir_buffer
|
||||||
@@ -127,9 +121,9 @@ SearchFATDIR:
|
|||||||
; if eax >= 0x0FFFFFF8 then there are no more clusters (end of chain)
|
; if eax >= 0x0FFFFFF8 then there are no more clusters (end of chain)
|
||||||
; if eax == 0x0FFFFFF7 then this is a cluster that is marked as bad
|
; if eax == 0x0FFFFFF7 then this is a cluster that is marked as bad
|
||||||
|
|
||||||
mov eax, dword [bx + FAT32_State_t.curr_dir_cluster_32]
|
; uint32_t NextCluster(uint32_t active_cluster);
|
||||||
push dword eax
|
push dword [bx + FAT32_State_t.curr_dir_cluster_32]
|
||||||
call NextCluster ; uint32_t NextCluster(uint32_t active_cluster);
|
call NextCluster
|
||||||
add sp, 0x4
|
add sp, 0x4
|
||||||
|
|
||||||
cmp eax, 0x0fff_fff7
|
cmp eax, 0x0fff_fff7
|
||||||
@@ -139,16 +133,14 @@ SearchFATDIR:
|
|||||||
|
|
||||||
.load_next_dir_next_OK:
|
.load_next_dir_next_OK:
|
||||||
; load 512 bytes of directory entries from data sector
|
; load 512 bytes of directory entries from data sector
|
||||||
mov eax, [bx + FAT32_State_t.curr_dir_cluster_32]
|
|
||||||
push dword eax ; cluster
|
|
||||||
|
|
||||||
mov ax, dir_buffer
|
; uint8_t ReadFATCluster(uint16_t seg, uint16_t offset, uint32_t cluster)
|
||||||
push ax ; offset
|
push dword [bx + FAT32_State_t.curr_dir_cluster_32] ; cluster
|
||||||
|
push dir_buffer ; offset
|
||||||
xor ax, ax
|
push 0x0000 ; segment
|
||||||
push ax ; segment
|
call ReadFATCluster
|
||||||
call ReadFATCluster ; uint8_t ReadFATCluster(uint16_t seg, uint16_t offset, uint32_t cluster)
|
|
||||||
add sp, 0x8
|
add sp, 0x8
|
||||||
|
|
||||||
.empty_dir_entry:
|
.empty_dir_entry:
|
||||||
; check for 0x0 in first byte, if true then there are no more files
|
; check for 0x0 in first byte, if true then there are no more files
|
||||||
; if true we did not find the file, we should error here
|
; if true we did not find the file, we should error here
|
||||||
@@ -219,16 +211,10 @@ NextCluster:
|
|||||||
__CDECL16_CALL_ARGS NextFATCluster_info
|
__CDECL16_CALL_ARGS NextFATCluster_info
|
||||||
__CDECL16_CALL PrintString, 1
|
__CDECL16_CALL PrintString, 1
|
||||||
|
|
||||||
mov ax, FAT32_NextClusterData_t_size
|
__CDECL16_CALL_ARGS fat32_nc_data, 0x0000, FAT32_NextClusterData_t_size
|
||||||
push ax ; length
|
__CDECL16_CALL kmemset, 3
|
||||||
xor ax, ax
|
|
||||||
push ax ; init with zero
|
|
||||||
mov ax, fat32_nc_data
|
|
||||||
push ax ; address of structure
|
|
||||||
call kmemset
|
|
||||||
add sp, 0x6
|
|
||||||
|
|
||||||
mov edx, dword [bp + 4]
|
mov edx, dword [bp + 4] ; active_cluster
|
||||||
mov si, fat32_nc_data ; instead of push/pop and moving the data back
|
mov si, fat32_nc_data ; instead of push/pop and moving the data back
|
||||||
mov di, fat32_bpb ; load si & di then use xchg
|
mov di, fat32_bpb ; load si & di then use xchg
|
||||||
mov bx, fat32_state
|
mov bx, fat32_state
|
||||||
@@ -275,10 +261,11 @@ NextCluster:
|
|||||||
; uint32_t lba,
|
; uint32_t lba,
|
||||||
; uint16_t count, uint16_t drive_num)
|
; uint16_t count, uint16_t drive_num)
|
||||||
.read_cluster:
|
.read_cluster:
|
||||||
; next_cluster = fat_buffer[entry_offset]
|
; next_cluster = fat_buffer[entry_offset]
|
||||||
mov ebx, dword [si + FAT32_NextClusterData_t.entry_offset]
|
mov ebx, dword [si + FAT32_NextClusterData_t.entry_offset]
|
||||||
mov si, fat_buffer
|
mov si, fat_buffer
|
||||||
mov eax, dword [bx+si+0]
|
mov eax, dword [bx+si+0]
|
||||||
|
; BUG: ???
|
||||||
.endp:
|
.endp:
|
||||||
__CDECL16_PROC_EXIT
|
__CDECL16_PROC_EXIT
|
||||||
ret
|
ret
|
||||||
|
|||||||
Reference in New Issue
Block a user