2017-10-18 22:19:53 +02:00
|
|
|
format ELF
|
|
|
|
|
2018-05-04 20:18:09 +02:00
|
|
|
__DEBUG__ = 1
|
2017-11-02 21:41:11 +01:00
|
|
|
__DEBUG_LEVEL__ = 1
|
2017-10-18 22:19:53 +02:00
|
|
|
|
2018-04-23 12:09:46 +02:00
|
|
|
include 'macros.inc'
|
2017-10-18 22:19:53 +02:00
|
|
|
include 'proc32.inc'
|
|
|
|
include 'struct.inc'
|
|
|
|
include 'const.inc'
|
|
|
|
include 'system.inc'
|
|
|
|
include 'debug-fdo.inc'
|
2018-05-04 20:18:09 +02:00
|
|
|
include 'blkdev/disk.inc'
|
|
|
|
include 'blkdev/disk_cache.inc'
|
|
|
|
include 'fs/fs_lfn.inc'
|
|
|
|
include 'crc.inc'
|
2017-10-18 22:19:53 +02:00
|
|
|
|
2017-11-02 21:41:11 +01:00
|
|
|
struct FS_FUNCTIONS
|
|
|
|
Free dd ?
|
|
|
|
Size dd ?
|
|
|
|
ReadFile dd ?
|
|
|
|
ReadFolder dd ?
|
|
|
|
CreateFile dd ?
|
|
|
|
WriteFile dd ?
|
|
|
|
SetFileEnd dd ?
|
|
|
|
GetFileInfo dd ?
|
|
|
|
SetFileInfo dd ?
|
|
|
|
Run dd ?
|
|
|
|
Delete dd ?
|
|
|
|
CreateFolder dd ?
|
|
|
|
ends
|
|
|
|
|
2017-10-18 22:19:53 +02:00
|
|
|
purge section,mov,add,sub
|
|
|
|
section '.text' executable align 16
|
|
|
|
|
2018-04-24 18:51:48 +02:00
|
|
|
|
|
|
|
;uint32_t kos_time_to_epoch(uint8_t *time);
|
|
|
|
public kos_time_to_epoch
|
|
|
|
kos_time_to_epoch:
|
|
|
|
push ebx esi edi ebp
|
|
|
|
|
|
|
|
mov esi, [esp + 0x14]
|
|
|
|
call fsCalculateTime
|
|
|
|
add eax, 978307200 ; epoch to 2001.01.01
|
|
|
|
|
|
|
|
pop ebp edi esi ebx
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
;void *kos_fuse_init(int fd);
|
2017-10-18 22:19:53 +02:00
|
|
|
public kos_fuse_init
|
|
|
|
kos_fuse_init:
|
|
|
|
push ebx esi edi ebp
|
|
|
|
|
2018-05-06 21:58:05 +02:00
|
|
|
mov [pg_data.pages_free], (128*1024*1024)/0x1000
|
|
|
|
|
2017-10-18 22:19:53 +02:00
|
|
|
mov eax, [esp + 0x14]
|
|
|
|
mov [fd], eax
|
|
|
|
|
2018-05-04 20:18:09 +02:00
|
|
|
mov [file_disk.Size], 65536
|
|
|
|
stdcall disk_add, disk_functions, disk_name, file_disk, DISK_NO_INSERT_NOTIFICATION
|
|
|
|
mov [disk], eax
|
|
|
|
stdcall disk_media_changed, [disk], 1
|
|
|
|
|
|
|
|
mov eax, [disk]
|
|
|
|
cmp [eax + DISK.NumPartitions], 0
|
|
|
|
jnz .done
|
2017-10-18 22:19:53 +02:00
|
|
|
mov eax, SYS_WRITE
|
|
|
|
mov ebx, STDOUT
|
2018-05-04 20:18:09 +02:00
|
|
|
mov ecx, msg_no_partition
|
|
|
|
mov edx, msg_no_partition.size
|
2017-10-18 22:19:53 +02:00
|
|
|
int 0x80
|
2018-04-23 13:42:32 +02:00
|
|
|
xor eax, eax
|
2018-05-04 20:18:09 +02:00
|
|
|
.done:
|
2017-10-18 22:19:53 +02:00
|
|
|
mov [fs_struct], eax
|
|
|
|
|
|
|
|
pop ebp edi esi ebx
|
|
|
|
ret
|
|
|
|
|
2018-04-24 18:51:48 +02:00
|
|
|
|
2018-04-25 12:27:05 +02:00
|
|
|
;char *kos_fuse_readdir(const char *path, off_t offset)
|
2017-10-18 22:19:53 +02:00
|
|
|
public kos_fuse_readdir
|
|
|
|
kos_fuse_readdir:
|
2018-05-06 21:58:05 +02:00
|
|
|
;DEBUGF 1, '#kos_fuse_readdir\n'
|
2017-10-18 22:19:53 +02:00
|
|
|
push ebx esi edi ebp
|
|
|
|
|
|
|
|
mov edx, sf70_params
|
|
|
|
mov dword[edx + 0x00], 1
|
|
|
|
mov eax, [esp + 0x18] ; offset
|
|
|
|
mov [edx + 0x04], eax
|
2018-05-06 21:58:05 +02:00
|
|
|
mov dword[edx + 0x08], 1 ; cp866
|
2017-10-18 22:19:53 +02:00
|
|
|
mov dword[edx + 0x0c], 100
|
|
|
|
mov dword[edx + 0x10], sf70_buffer
|
|
|
|
mov eax, [esp + 0x14] ; path
|
2018-05-06 21:58:05 +02:00
|
|
|
mov byte[edx + 0x14], 0
|
|
|
|
mov [edx + 0x15], eax
|
2017-10-18 22:19:53 +02:00
|
|
|
|
|
|
|
mov ebx, sf70_params
|
2018-05-06 21:58:05 +02:00
|
|
|
pushad ; file_system_lfn writes here
|
|
|
|
call file_system_lfn
|
|
|
|
popad
|
2017-10-18 22:19:53 +02:00
|
|
|
pop ebp edi esi ebx
|
|
|
|
mov eax, sf70_buffer
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2017-11-16 02:16:20 +01:00
|
|
|
;void *kos_fuse_getattr(const char *path)
|
2017-11-02 21:41:11 +01:00
|
|
|
public kos_fuse_getattr
|
|
|
|
kos_fuse_getattr:
|
2018-05-06 21:58:05 +02:00
|
|
|
;DEBUGF 1, '#kos_fuse_getattr\n'
|
2017-11-02 21:41:11 +01:00
|
|
|
push ebx esi edi ebp
|
|
|
|
|
|
|
|
mov edx, sf70_params
|
|
|
|
mov dword[edx + 0x00], 5
|
|
|
|
mov dword[edx + 0x04], 0
|
|
|
|
mov dword[edx + 0x08], 0
|
|
|
|
mov dword[edx + 0x0c], 0
|
|
|
|
mov dword[edx + 0x10], sf70_buffer
|
|
|
|
mov eax, [esp + 0x14] ; path
|
2018-05-06 21:58:05 +02:00
|
|
|
mov byte[edx + 0x14], 0
|
|
|
|
mov [edx + 0x15], eax
|
2017-11-02 21:41:11 +01:00
|
|
|
|
|
|
|
mov ebx, sf70_params
|
2018-05-06 21:58:05 +02:00
|
|
|
pushad ; file_system_lfn writes here
|
|
|
|
call file_system_lfn
|
|
|
|
popad
|
2017-11-02 21:41:11 +01:00
|
|
|
pop ebp edi esi ebx
|
|
|
|
mov eax, sf70_buffer
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2017-11-16 02:16:20 +01:00
|
|
|
;long *kos_fuse_read(const char *path, char *buf, size_t size, off_t offset)
|
|
|
|
public kos_fuse_read
|
|
|
|
kos_fuse_read:
|
|
|
|
push ebx esi edi ebp
|
|
|
|
|
|
|
|
mov edx, sf70_params
|
|
|
|
mov dword[edx + 0x00], 0
|
2018-05-07 17:31:42 +02:00
|
|
|
mov eax, [esp + 0x20] ; offset lo
|
2017-11-16 02:16:20 +01:00
|
|
|
mov dword[edx + 0x04], eax
|
2018-05-07 17:31:42 +02:00
|
|
|
mov dword[edx + 0x08], 0 ; offset hi
|
|
|
|
mov eax, [esp + 0x1c] ; size
|
2017-11-16 02:16:20 +01:00
|
|
|
mov dword[edx + 0x0c], eax
|
2018-05-07 17:31:42 +02:00
|
|
|
mov eax, [esp + 0x18] ; buf
|
2017-11-16 02:16:20 +01:00
|
|
|
mov dword[edx + 0x10], eax
|
|
|
|
mov eax, [esp + 0x14] ; path
|
2018-05-07 17:31:42 +02:00
|
|
|
mov byte[edx + 0x14], 0
|
|
|
|
mov [edx + 0x15], eax
|
2017-11-16 02:16:20 +01:00
|
|
|
|
|
|
|
mov ebx, sf70_params
|
2018-05-07 17:31:42 +02:00
|
|
|
pushad ; file_system_lfn writes here
|
|
|
|
call file_system_lfn
|
|
|
|
popad
|
2017-11-16 02:16:20 +01:00
|
|
|
|
|
|
|
pop ebp edi esi ebx
|
|
|
|
mov eax, 0
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
2018-05-04 20:18:09 +02:00
|
|
|
proc disk_read stdcall, userdata, buffer, startsector:qword, numsectors
|
2017-10-18 22:19:53 +02:00
|
|
|
pushad
|
2018-05-04 20:18:09 +02:00
|
|
|
mov eax, dword[startsector + 0] ; sector lo
|
|
|
|
mov edx, dword[startsector + 4] ; sector hi
|
2017-10-18 22:19:53 +02:00
|
|
|
imul ecx, eax, 512
|
|
|
|
mov eax, SYS_LSEEK
|
|
|
|
mov ebx, [fd]
|
|
|
|
mov edx, SEEK_SET
|
|
|
|
int 0x80
|
2018-05-06 21:58:05 +02:00
|
|
|
;DEBUGF 1, "lseek: %x\n", eax
|
2017-10-18 22:19:53 +02:00
|
|
|
popad
|
|
|
|
|
|
|
|
pushad
|
|
|
|
mov eax, SYS_READ
|
|
|
|
mov ebx, [fd]
|
2018-05-04 20:18:09 +02:00
|
|
|
mov ecx, [buffer]
|
|
|
|
mov edx, [numsectors]
|
|
|
|
mov edx, [edx]
|
|
|
|
imul edx, 512
|
2017-10-18 22:19:53 +02:00
|
|
|
int 0x80
|
2018-05-06 21:58:05 +02:00
|
|
|
;DEBUGF 1, "read: %d\n", eax
|
2017-10-18 22:19:53 +02:00
|
|
|
popad
|
|
|
|
|
2018-05-04 20:18:09 +02:00
|
|
|
movi eax, DISK_STATUS_OK
|
2017-10-18 22:19:53 +02:00
|
|
|
ret
|
2018-05-04 20:18:09 +02:00
|
|
|
endp
|
2017-10-18 22:19:53 +02:00
|
|
|
|
|
|
|
|
2018-05-04 20:18:09 +02:00
|
|
|
proc disk_write stdcall, userdata, buffer, startsector:qword, numsectors
|
|
|
|
ud2
|
2017-10-18 22:19:53 +02:00
|
|
|
pushad
|
|
|
|
imul ecx, eax, 512
|
|
|
|
add ecx, 2048*512
|
|
|
|
mov eax, SYS_LSEEK
|
|
|
|
mov ebx, [fd]
|
|
|
|
mov edx, SEEK_SET
|
|
|
|
int 0x80
|
|
|
|
;DEBUGF 1, "lseek: %x\n", eax
|
|
|
|
popad
|
|
|
|
|
|
|
|
pushad
|
2018-05-04 20:18:09 +02:00
|
|
|
mov eax, SYS_WRITE
|
2017-10-18 22:19:53 +02:00
|
|
|
mov ecx, ebx
|
|
|
|
mov ebx, [fd]
|
2018-05-04 20:18:09 +02:00
|
|
|
mov edx, 512
|
2017-10-18 22:19:53 +02:00
|
|
|
int 0x80
|
2018-05-04 20:18:09 +02:00
|
|
|
;DEBUGF 1, "write: %d\n", eax
|
2017-10-18 22:19:53 +02:00
|
|
|
popad
|
|
|
|
|
2018-05-04 20:18:09 +02:00
|
|
|
movi eax, DISK_STATUS_OK
|
2017-10-18 22:19:53 +02:00
|
|
|
ret
|
2018-05-04 20:18:09 +02:00
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
|
|
; int querymedia(void* userdata, DISKMEDIAINFO* info);
|
|
|
|
proc disk_querymedia stdcall, hd_data, mediainfo
|
|
|
|
mov ecx, [mediainfo]
|
|
|
|
mov [ecx + DISKMEDIAINFO.Flags], 0
|
|
|
|
mov [ecx + DISKMEDIAINFO.SectorSize], 512
|
|
|
|
mov eax, [hd_data]
|
|
|
|
mov eax, dword[eax + FILE_DISK.Size + 0]
|
|
|
|
mov dword [ecx + DISKMEDIAINFO.Capacity], eax
|
|
|
|
mov dword [ecx + DISKMEDIAINFO.Capacity + 4], 0
|
|
|
|
|
|
|
|
movi eax, DISK_STATUS_OK
|
2017-10-18 22:19:53 +02:00
|
|
|
ret
|
2018-05-04 20:18:09 +02:00
|
|
|
endp
|
2017-10-18 22:19:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
malloc:
|
|
|
|
push [alloc_pos]
|
|
|
|
add [alloc_pos], eax
|
|
|
|
pop eax
|
|
|
|
ret
|
|
|
|
|
2018-05-04 20:18:09 +02:00
|
|
|
proc kernel_alloc _size
|
|
|
|
mov eax, [_size]
|
|
|
|
call malloc
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
|
|
|
|
|
|
|
proc alloc_kernel_space _size
|
|
|
|
mov eax, [_size]
|
|
|
|
call malloc
|
|
|
|
ret
|
|
|
|
endp
|
|
|
|
|
2018-05-06 21:58:05 +02:00
|
|
|
proc alloc_pages _cnt
|
|
|
|
mov eax, [_cnt]
|
2018-05-04 20:18:09 +02:00
|
|
|
shl eax, 12
|
|
|
|
call malloc
|
2017-10-18 22:19:53 +02:00
|
|
|
ret
|
2018-05-04 20:18:09 +02:00
|
|
|
endp
|
2017-10-18 22:19:53 +02:00
|
|
|
|
|
|
|
|
2018-05-04 20:18:09 +02:00
|
|
|
|
|
|
|
|
|
|
|
free:
|
|
|
|
ret
|
|
|
|
|
2018-05-06 21:58:05 +02:00
|
|
|
proc kernel_free blah
|
2017-10-18 22:19:53 +02:00
|
|
|
ret
|
2018-05-06 21:58:05 +02:00
|
|
|
endp
|
2017-10-18 22:19:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
mutex_init:
|
|
|
|
mutex_lock:
|
|
|
|
mutex_unlock:
|
|
|
|
ret
|
|
|
|
|
|
|
|
put_board:
|
|
|
|
pushad
|
|
|
|
mov eax, SYS_WRITE
|
|
|
|
mov ebx, STDOUT
|
|
|
|
push ecx
|
|
|
|
mov ecx, esp
|
|
|
|
mov edx, 1
|
|
|
|
int 0x80
|
|
|
|
pop ecx
|
|
|
|
popad
|
|
|
|
ret
|
|
|
|
|
2018-05-04 20:18:09 +02:00
|
|
|
align 16 ;very often call this subrutine
|
|
|
|
memmove: ; memory move in bytes
|
|
|
|
; eax = from
|
|
|
|
; ebx = to
|
|
|
|
; ecx = no of bytes
|
|
|
|
test ecx, ecx
|
|
|
|
jle .ret
|
|
|
|
|
|
|
|
push esi edi ecx
|
|
|
|
|
|
|
|
mov edi, ebx
|
|
|
|
mov esi, eax
|
|
|
|
|
|
|
|
test ecx, not 11b
|
|
|
|
jz @f
|
|
|
|
|
|
|
|
push ecx
|
|
|
|
shr ecx, 2
|
|
|
|
rep movsd
|
|
|
|
pop ecx
|
|
|
|
and ecx, 11b
|
|
|
|
jz .finish
|
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
|
|
|
@@:
|
|
|
|
rep movsb
|
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
|
|
|
.finish:
|
|
|
|
pop ecx edi esi
|
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
|
|
|
.ret:
|
|
|
|
ret
|
2017-10-18 22:19:53 +02:00
|
|
|
|
2018-05-04 20:18:09 +02:00
|
|
|
|
|
|
|
sys_msg_board_str:
|
|
|
|
protect_from_terminate:
|
|
|
|
unprotect_from_terminate:
|
|
|
|
change_task:
|
|
|
|
ReadCDWRetr:
|
|
|
|
WaitUnitReady:
|
|
|
|
prevent_medium_removal:
|
|
|
|
Read_TOC:
|
|
|
|
commit_pages:
|
|
|
|
release_pages:
|
|
|
|
ret
|
|
|
|
|
|
|
|
proc fs_execute
|
|
|
|
; edx = flags
|
|
|
|
; ecx -> cmdline
|
|
|
|
; ebx -> absolute file path
|
|
|
|
; eax = string length
|
|
|
|
ret
|
|
|
|
endp
|
2017-10-18 22:19:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
section '.data' writeable align 16
|
|
|
|
include_debug_strings
|
2018-05-04 20:18:09 +02:00
|
|
|
disk_functions:
|
|
|
|
dd disk_functions_end - disk_functions
|
|
|
|
dd 0
|
|
|
|
dd 0
|
|
|
|
dd disk_querymedia
|
|
|
|
dd disk_read
|
|
|
|
dd disk_write
|
|
|
|
dd 0
|
|
|
|
dd 0
|
|
|
|
disk_functions_end:
|
|
|
|
|
|
|
|
struct FILE_DISK
|
|
|
|
Size dd ?
|
|
|
|
ends
|
|
|
|
|
|
|
|
file_disk FILE_DISK
|
2017-10-18 22:19:53 +02:00
|
|
|
|
|
|
|
alloc_pos dd alloc_base
|
|
|
|
sf70_params rd 6
|
2018-05-04 20:18:09 +02:00
|
|
|
msg_no_partition db 'no partition detected',0x0a
|
|
|
|
msg_no_partition.size = $ - msg_no_partition
|
2018-05-06 21:58:05 +02:00
|
|
|
disk_name db 'hd0',0
|
2018-05-04 20:18:09 +02:00
|
|
|
current_slot dd ?
|
|
|
|
pg_data PG_DATA
|
|
|
|
ide_channel1_mutex MUTEX
|
|
|
|
ide_channel2_mutex MUTEX
|
|
|
|
ide_channel3_mutex MUTEX
|
|
|
|
ide_channel4_mutex MUTEX
|
|
|
|
ide_channel5_mutex MUTEX
|
|
|
|
ide_channel6_mutex MUTEX
|
|
|
|
ide_channel7_mutex MUTEX
|
|
|
|
ide_channel8_mutex MUTEX
|
2017-10-18 22:19:53 +02:00
|
|
|
IncludeIGlobals
|
|
|
|
|
|
|
|
|
|
|
|
section '.bss' writeable align 16
|
2018-05-06 21:58:05 +02:00
|
|
|
fd rd 1
|
|
|
|
disk dd ?
|
|
|
|
alloc_base rb 32*1024*1024
|
|
|
|
fs_struct rd 1
|
|
|
|
sf70_buffer rb 16*1024*1024
|
|
|
|
IncludeUGlobals
|
2018-05-04 20:18:09 +02:00
|
|
|
DiskNumber db ?
|
|
|
|
ChannelNumber db ?
|
|
|
|
DevErrorCode dd ?
|
|
|
|
CDSectorAddress dd ?
|
|
|
|
CDDataBuf_pointer dd ?
|
|
|
|
DRIVE_DATA: rb 0x4000
|
|
|
|
cdpos dd ?
|
|
|
|
cd_appl_data rd 1
|