File system: read folders with long names and in new standard

System functions: many small corrections

git-svn-id: svn://kolibrios.org@75 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Evgeny Grechnikov (Diamond) 2006-05-05 12:40:02 +00:00
parent 9d76fed06e
commit 17da7e7f7a
10 changed files with 1399 additions and 610 deletions

View File

@ -42,6 +42,7 @@ MAX_Track equ 79
MAX_Head equ 1 MAX_Head equ 1
MAX_Sector equ 18 MAX_Sector equ 18
uglobal
; Счетчик тиков таймера ; Счетчик тиков таймера
TickCounter dd ? TickCounter dd ?
; Код завершения операции с контроллером НГМД ; Код завершения операции с контроллером НГМД
@ -69,6 +70,7 @@ FDC_N DB ?
ReadRepCounter DB ? ReadRepCounter DB ?
; Счетчик повторения операции рекалибровки ; Счетчик повторения операции рекалибровки
RecalRepCounter DB ? RecalRepCounter DB ?
endg
; Область памяти для хранения прочитанного сектора ; Область памяти для хранения прочитанного сектора
;FDD_DataBuffer: times 512 db 0 ;DB 512 DUP (?) ;FDD_DataBuffer: times 512 db 0 ;DB 512 DUP (?)
fdd_motor_status db 0 fdd_motor_status db 0
@ -111,13 +113,13 @@ Init_FDC_DMA:
;*********************************** ;***********************************
FDCDataOutput: FDCDataOutput:
; pusha ; pusha
push ax cx dx push eax ecx edx
mov AH,AL ;запомнить байт в AH mov AH,AL ;запомнить байт в AH
; Сбросить переменную состояния контроллера ; Сбросить переменную состояния контроллера
mov [FDC_Status],FDC_Normal mov [FDC_Status],FDC_Normal
; Проверить готовность контроллера к приему данных ; Проверить готовность контроллера к приему данных
mov DX,3F4h ;(порт состояния FDC) mov DX,3F4h ;(порт состояния FDC)
xor CX,CX ;установить счетчик тайм-аута mov ecx, 0x10000 ;óñòàíîâèòü ñ÷åò÷èê òàéì-àóòà
@@TestRS: @@TestRS:
in AL,DX ;прочитать регистр RS in AL,DX ;прочитать регистр RS
and AL,0C0h ;выделить разряды 6 и 7 and AL,0C0h ;выделить разряды 6 и 7
@ -134,7 +136,7 @@ FDCDataOutput:
out DX,AL out DX,AL
@@End_5: @@End_5:
; popa ; popa
pop dx cx ax pop edx ecx eax
ret ret
;****************************************** ;******************************************

View File

@ -553,7 +553,7 @@ uni2ansi_str:
add al, 0x70 add al, 0x70
jmp .doit jmp .doit
.rus2: .rus2:
; 0x440-0x450 -> 0xE0-0xEF ; 0x440-0x44F -> 0xE0-0xEF
add al, 0xA0 add al, 0xA0
.ascii: .ascii:
.doit: .doit:
@ -563,6 +563,43 @@ uni2ansi_str:
mov byte [edi], 0 mov byte [edi], 0
ret ret
ansi2uni_char:
; convert ANSI character in al to UNICODE character in ax, using cp866 encoding
mov ah, 0
; 0x00-0x7F - trivial map
cmp al, 0x80
jb .ret
; 0x80-0xAF -> 0x410-0x43F
cmp al, 0xB0
jae @f
add ax, 0x410-0x80
.ret:
ret
@@:
; 0xE0-0xEF -> 0x440-0x44F
cmp al, 0xE0
jb .unk
cmp al, 0xF0
jae @f
add ax, 0x440-0xE0
ret
; 0xF0 -> 0x401
; 0xF1 -> 0x451
@@:
cmp al, 'ð'
jz .yo1
cmp al, 'ñ'
jz .yo2
.unk:
mov al, '_' ; ah=0
ret
.yo1:
mov ax, 0x401
ret
.yo2:
mov ax, 0x451
ret
char_toupper: char_toupper:
; convert character to uppercase, using cp866 encoding ; convert character to uppercase, using cp866 encoding
; in: al=symbol ; in: al=symbol
@ -607,6 +644,8 @@ fat_get_name:
push ecx push ecx
mov ecx, 8 mov ecx, 8
push edi ebp ecx push edi ebp ecx
cmp byte [ebp-4], 0
jnz .unicode_short
@@: @@:
mov al, [edi] mov al, [edi]
inc edi inc edi
@ -641,6 +680,49 @@ fat_get_name:
and byte [ebp], 0 ; CF=0 and byte [ebp], 0 ; CF=0
pop ebp edi ecx pop ebp edi ecx
ret ret
.unicode_short:
@@:
mov al, [edi]
inc edi
call ansi2uni_char
mov [ebp], ax
inc ebp
inc ebp
loop @b
pop ecx
@@:
cmp word [ebp-2], ' '
jnz @f
dec ebp
dec ebp
loop @b
@@:
mov word [ebp], '.'
inc ebp
inc ebp
mov ecx, 3
push ecx
@@:
mov al, [edi]
inc edi
call ansi2uni_char
mov [ebp], ax
inc ebp
inc ebp
loop @b
pop ecx
@@:
cmp word [ebp-2], ' '
jnz @f
dec ebp
dec ebp
loop @b
dec ebp
dec ebp
@@:
and word [ebp], 0 ; CF=0
pop ebp edi ecx
ret
.longname: .longname:
; LFN ; LFN
mov al, byte [edi] mov al, byte [edi]
@ -681,12 +763,15 @@ fat_get_name:
ret ret
@@: @@:
; if this is first entry: ; if this is first entry:
cmp byte [ebp-4], 0
jnz .ret
; buffer at ebp contains UNICODE name, convert it to ANSI ; buffer at ebp contains UNICODE name, convert it to ANSI
push esi edi push esi edi
mov esi, ebp mov esi, ebp
mov edi, ebp mov edi, ebp
call uni2ansi_str call uni2ansi_str
pop edi esi pop edi esi
.ret:
clc clc
ret ret
@ -725,6 +810,76 @@ fat_compare_name:
pop esi ebp pop esi ebp
ret ret
fat_time_to_bdfe:
; in: eax=FAT time
; out: eax=BDFE time
push ecx edx
mov ecx, eax
mov edx, eax
shr eax, 11
shl eax, 16 ; hours
and edx, 0x1F
add edx, edx
mov al, dl ; seconds
shr ecx, 5
and ecx, 0x3F
mov ah, cl ; minutes
pop edx ecx
ret
fat_date_to_bdfe:
push ecx edx
mov ecx, eax
mov edx, eax
shr eax, 9
add ax, 1980
shl eax, 16 ; year
and edx, 0x1F
mov al, dl ; day
shr ecx, 5
and ecx, 0xF
mov ah, cl ; month
pop edx ecx
ret
fat_entry_to_bdfe:
; convert FAT entry at edi to BDFE (block of data of folder entry) at esi, advance esi
; destroys eax
movzx eax, byte [edi+11]
mov [esi], eax ; attributes
mov eax, [ebp-4]
mov [esi+4], eax ; ASCII/UNICODE name
movzx eax, word [edi+14]
call fat_time_to_bdfe
mov [esi+8], eax ; creation time
movzx eax, word [edi+16]
call fat_date_to_bdfe
mov [esi+12], eax ; creation date
and dword [esi+16], 0 ; last access time is not supported on FAT
movzx eax, word [edi+18]
call fat_date_to_bdfe
mov [esi+20], eax ; last access date
movzx eax, word [edi+22]
call fat_time_to_bdfe
mov [esi+24], eax ; last write time
movzx eax, word [edi+24]
call fat_date_to_bdfe
mov [esi+28], eax ; last write date
mov eax, [edi+28]
mov [esi+32], eax ; file size (low dword)
xor eax, eax
mov [esi+36], eax ; file size (high dword)
push ecx edi
lea edi, [esi+40]
mov esi, ebp
mov ecx, 259/2
rep movsd
movsw
stosw
mov esi, edi
pop edi ecx
ret
rd_find_lfn: rd_find_lfn:
; in: esi->name ; in: esi->name
; out: CF=1 - file not found ; out: CF=1 - file not found
@ -732,6 +887,7 @@ rd_find_lfn:
push esi ebp edi push esi ebp edi
sub esp, 262*2 ; allocate space for LFN sub esp, 262*2 ; allocate space for LFN
mov ebp, esp ; ebp points to buffer mov ebp, esp ; ebp points to buffer
push 0 ; for fat_get_name: read ASCII name
mov edi, 0x100000+512*19 ; to root dir mov edi, 0x100000+512*19 ; to root dir
.l1: .l1:
call fat_get_name call fat_get_name
@ -743,7 +899,7 @@ rd_find_lfn:
cmp edi, 0x100000+512*33 cmp edi, 0x100000+512*33
jb .l1 jb .l1
.notfound: .notfound:
add esp, 262*2 add esp, 262*2+4
pop edi ebp esi pop edi ebp esi
stc stc
ret ret
@ -757,7 +913,7 @@ rd_find_lfn:
; folders are not supported ; folders are not supported
cmp byte [esi], 0 cmp byte [esi], 0
jnz .notfound jnz .notfound
add esp, 262*2+4 ; CF=0 add esp, 262*2+4+4 ; CF=0
pop ebp esi pop ebp esi
ret ret
@ -851,4 +1007,71 @@ fs_RamdiskRead:
xor eax, eax xor eax, eax
ret ret
;----------------------------------------------------------------
;
; fs_RamdiskReadFolder - LFN variant for reading sys floppy folder
;
; esi points to filename; only root is folder on ramdisk
; ebx pointer to 32-bit number = first wanted block
; ecx number of blocks to read, 0+
; edx mem location to return data
;
; ret ebx = size or 0xffffffff file not found
; eax = 0 ok read or other = errormsg
;
;--------------------------------------------------------------
fs_RamdiskReadFolder:
mov ebx, [ebx]
cmp byte [esi], 0
jz @f
; ramdisk doesn't support folders
mov eax, ERROR_ACCESS_DENIED
or ebx, -1
ret
@@:
push esi edi ecx
; init header
push ecx
mov edi, edx
mov ecx, 32/4
xor eax, eax
rep stosd
mov byte [edx], 1 ; version
pop ecx
push ebp
sub esp, 262*2 ; allocate space for LFN
mov ebp, esp
push 1 ; for fat_get_name: read UNICODE name
; read root
mov esi, edi ; esi points to block of data of folder entry (BDFE)
mov edi, 0x100000+512*19
.l1:
call fat_get_name
jc .l2
cmp byte [edi+11], 0xF
jnz @f
add edi, 0x20
@@:
inc dword [edx+8] ; new file found
dec ebx
jns .l2
dec ecx
js .l2
inc dword [edx+4] ; new file block copied
call fat_entry_to_bdfe
.l2:
add edi, 0x20
cmp edi, 0x100000+512*33
jb .l1
add esp, 262*2+4
pop ebp
mov ebx, [edx+8]
xor eax, eax
dec ecx
js @f
mov al, ERROR_END_OF_FILE
@@:
pop ecx edi esi
ret
; \end{diamond} ; \end{diamond}

View File

@ -1,5 +1,4 @@
cmp eax,6 ; SAVE FLOPPY IMAGE (HD version only) sysfn_saveramdisk: ; 18.6 = SAVE FLOPPY IMAGE (HD version only)
jnz nosaveimage
cmp ebx,1 cmp ebx,1
jnz img_save_hd_1 jnz img_save_hd_1
mov edx,bootpath ; path = '/KOLIBRI ' mov edx,bootpath ; path = '/KOLIBRI '
@ -21,6 +20,5 @@
mov ebx,1440*1024 ; size 1440 Kb mov ebx,1440*1024 ; size 1440 Kb
mov ecx,0x100000 ; address of image mov ecx,0x100000 ; address of image
call file_write call file_write
mov [esp+36],eax
ret ret
nosaveimage:

View File

@ -465,10 +465,13 @@ irqhandler:
add esi,irq00read ; 1 add esi,irq00read ; 1
shl edi,12 ; 1 shl edi,12 ; 1
add edi,0x2E0000 add edi,0x2E0000
mov ecx,16
mov [check_idle_semaphore],5 mov [check_idle_semaphore],5
irqnewread: irqnewread:
dec ecx
js irqover
mov dx,[esi] ; 2+ mov dx,[esi] ; 2+

View File

@ -86,7 +86,7 @@ iglobal
dd sys_background ; 15-bgr dd sys_background ; 15-bgr
dd sys_cachetodiskette ; 16-FlushFloppyCache dd sys_cachetodiskette ; 16-FlushFloppyCache
dd sys_getbutton ; 17-GetButton dd sys_getbutton ; 17-GetButton
dd syscall_system ; 18-Shutdown,KillApp,WindowActivate dd sys_system ; 18-System Services
dd syscall_startapp ; 19-StartApp dd syscall_startapp ; 19-StartApp
dd sys_midi ; 20-ResetMidi and OutputMidi dd sys_midi ; 20-ResetMidi and OutputMidi
dd sys_setup ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,. dd sys_setup ; 21-SetMidiBase,SetKeymap,SetShiftKeymap,.
@ -98,11 +98,14 @@ iglobal
dd sys_wss ; 27-SetWssMainVol and SetWssCdVol dd sys_wss ; 27-SetWssMainVol and SetWssCdVol
dd sys_sb16II ; 28-SetSb16 dd sys_sb16II ; 28-SetSb16
dd sys_date ; 29-GetDate dd sys_date ; 29-GetDate
dd syscall_readhd ; 30-ReadHd ; dd syscall_readhd ; 30-ReadHd - obsolete <diamond>
dd syscall_starthdapp ; 31-StartHdApp dd undefined_syscall ; 30-reserved
; dd syscall_starthdapp ; 31-StartHdApp - obsolete <diamond>
dd undefined_syscall ; 31-reserved
dd syscall_delramdiskfile ; 32-DelRamdiskFile dd syscall_delramdiskfile ; 32-DelRamdiskFile
dd syscall_writeramdiskfile; 33-WriteRamdiskFile dd syscall_writeramdiskfile; 33-WriteRamdiskFile
dd read_floppy_file ; 34-ReadFloppyDrive ; dd read_floppy_file ; 34-ReadFloppyDrive - obsolete <diamond>
dd undefined_syscall ; 34-reserved
dd syscall_getpixel ; 35-GetPixel dd syscall_getpixel ; 35-GetPixel
dd syscall_readstring ; 36-ReadString (not yet ready) dd syscall_readstring ; 36-ReadString (not yet ready)
dd readmousepos ; 37-GetMousePosition_ScreenRelative,. dd readmousepos ; 37-GetMousePosition_ScreenRelative,.
@ -125,7 +128,8 @@ iglobal
dd user_events ; 54-User events dd user_events ; 54-User events
dd sound_interface ; 55-Sound interface dd sound_interface ; 55-Sound interface
dd write_to_hd ; 56-Write a file to hd dd write_to_hd ; 56-Write a file to hd
dd delete_from_hd ; 57-Delete a file from hd ; dd delete_from_hd ; 57-Delete a file from hd - obsolete <diamond>
dd undefined_syscall ; 57-reserved
dd file_system ; 58-Common file system interface dd file_system ; 58-Common file system interface
dd sys_trace ; 59-System call trace dd sys_trace ; 59-System call trace
dd new_sys_ipc ; 60-Inter Process Communication dd new_sys_ipc ; 60-Inter Process Communication

View File

@ -1091,6 +1091,7 @@ fd_find_lfn:
pusha pusha
sub esp, 262*2 ; reserve place for LFN sub esp, 262*2 ; reserve place for LFN
mov ebp, esp mov ebp, esp
push 0 ; for fat_get_name: read ASCII name
call read_flp_fat call read_flp_fat
cmp [FDC_Status], 0 cmp [FDC_Status], 0
jnz .error jnz .error
@ -1121,13 +1122,13 @@ fd_find_lfn:
js @f js @f
jnz .20_1 jnz .20_1
.error: .error:
add esp, 262*2 add esp, 262*2+4
popa popa
stc stc
ret ret
@@: @@:
; read next sector from FAT ; read next sector from FAT
mov eax, [(eax-31)*2+0x282000] mov eax, [(eax-31-1)*2+0x282000]
and eax, 0xFFF and eax, 0xFFF
cmp eax, 0xFF8 cmp eax, 0xFF8
jae .error jae .error
@ -1158,7 +1159,7 @@ fd_find_lfn:
mov dh, 0 mov dh, 0
jmp .main_loop jmp .main_loop
.done: .done:
add esp, 262*2+4 add esp, 262*2+4+4
push edi push edi
popad popad
ret ret
@ -1178,7 +1179,7 @@ fd_find_lfn:
; ;
;-------------------------------------------------------------- ;--------------------------------------------------------------
fs_FloppyRead: fs_FloppyRead:
mov [save_flag], 0 call read_flp_fat
cmp byte [esi], 0 cmp byte [esi], 0
jnz @f jnz @f
or ebx, -1 or ebx, -1
@ -1261,4 +1262,139 @@ fs_FloppyRead:
mov eax, 5 ; may be other error code? mov eax, 5 ; may be other error code?
pop edx ecx ebx ebx edi pop edx ecx ebx ebx edi
ret ret
;----------------------------------------------------------------
;
; fs_FloppyReadFolder - LFN variant for reading floppy folders
;
; esi points to filename
; ebx pointer to 32-bit number = first wanted block, 0+
; ecx number of blocks to read, 0+
; edx mem location to return data
;
; ret ebx = size or 0xffffffff folder not found
; eax = 0 ok read or other = errormsg
;
;--------------------------------------------------------------
fs_FloppyReadFolder:
call read_flp_fat
mov ebx, [ebx]
push edi
cmp byte [esi], 0
jz .root
call fd_find_lfn
jnc .found
pop edi
or ebx, -1
mov eax, ERROR_FILE_NOT_FOUND
ret
.found:
test byte [edi+11], 0x10 ; do not allow read files
jnz .found_dir
pop edi
or ebx, -1
mov eax, ERROR_ACCESS_DENIED
ret
.found_dir:
movzx eax, word [edi+26]
add eax, 31
push 0
jmp .doit
.root:
mov eax, 19
push 14
.doit:
push ecx ebp
sub esp, 262*2 ; reserve space for LFN
mov ebp, esp
push 1 ; for fat_get_name: read UNICODE names
; init header
push eax ecx
mov edi, edx
mov ecx, 32/4
xor eax, eax
rep stosd
pop ecx eax
mov byte [edx], 1 ; version
mov esi, edi ; esi points to BDFE
.main_loop:
pusha
call read_chs_sector
popa
cmp [FDC_Status], 0
jnz .error
mov edi, 0xD000
push eax
.l1:
call fat_get_name
jc .l2
cmp byte [edi+11], 0xF
jnz .do_bdfe
add edi, 0x20
cmp edi, 0xD200
jb .do_bdfe
pop eax
inc eax
dec byte [esp+262*2+12]
jz .done
jns @f
; read next sector from FAT
mov eax, [(eax-31-1)*2+0x282000]
and eax, 0xFFF
cmp eax, 0xFF8
jae .done
add eax, 31
mov byte [esp+262*2+12], 0
@@:
pusha
call read_chs_sector
popa
cmp [FDC_Status], 0
jnz .error
mov edi, 0xD000
push eax
.do_bdfe:
inc dword [edx+8] ; new file found
dec ebx
jns .l2
dec ecx
js .l2
inc dword [edx+4] ; new file block copied
call fat_entry_to_bdfe
.l2:
add edi, 0x20
cmp edi, 0xD200
jb .l1
pop eax
inc eax
dec byte [esp+262*2+12]
jz .done
jns @f
; read next sector from FAT
mov eax, [(eax-31-1)*2+0x282000]
and eax, 0xFFF
cmp eax, 0xFF8
jae .done
add eax, 31
mov byte [esp+262*2+12], 0
@@:
jmp .main_loop
.error:
add esp, 262*2+4
pop ebp ecx edi edi
or ebx, -1
mov eax, ERROR_FILE_NOT_FOUND
ret
.done:
add esp, 262*2+4
pop ebp
mov ebx, [edx+8]
xor eax, eax
dec ecx
js @f
mov al, ERROR_END_OF_FILE
@@:
pop ecx edi edi
ret
; \end{diamond} ; \end{diamond}

View File

@ -7,9 +7,10 @@
;; Copyright 2002 Paolo Minazzi, paolo.minazzi@inwind.it ;; ;; Copyright 2002 Paolo Minazzi, paolo.minazzi@inwind.it ;;
;; ;; ;; ;;
;; See file COPYING for details ;; ;; See file COPYING for details ;;
;; 04.05.2006 LFN read folder - diamond ;;
;; 29.04.2006 Elimination of hangup after the ;; ;; 29.04.2006 Elimination of hangup after the ;;
;; expiration hd_wait_timeout - Mario79 ;; ;; expiration hd_wait_timeout - Mario79 ;;
;; 23.04.2006 LFN read - diamond ;; ;; 23.04.2006 LFN read file - diamond ;;
;; 28.01.2006 find all Fat16/32 partition in all input point ;; ;; 28.01.2006 find all Fat16/32 partition in all input point ;;
;; to MBR, see file part_set.inc - Mario79 ;; ;; to MBR, see file part_set.inc - Mario79 ;;
;; 15.01.2005 get file size/attr/date, file_append - ATV ;; ;; 15.01.2005 get file size/attr/date, file_append - ATV ;;
@ -2936,6 +2937,7 @@ hd_find_lfn:
pusha pusha
sub esp, 262*2 ; allocate space for LFN sub esp, 262*2 ; allocate space for LFN
mov ebp, esp mov ebp, esp
push 0 ; for fat_get_name: read ASCII name
mov eax, [ROOT_CLUSTER] ; start from root mov eax, [ROOT_CLUSTER] ; start from root
.mainloop: .mainloop:
.new_cluster: .new_cluster:
@ -2990,7 +2992,7 @@ hd_find_lfn:
cmp eax, [fatRESERVED] cmp eax, [fatRESERVED]
jb .new_cluster jb .new_cluster
.notfound: .notfound:
add esp, 262*2 add esp, 262*2+4
popa popa
stc stc
ret ret
@ -3036,7 +3038,7 @@ hd_find_lfn:
mov ax, [edi+26] mov ax, [edi+26]
jmp .mainloop jmp .mainloop
.done: .done:
add esp, 262*2+4 ; CF=0 add esp, 262*2+4+4 ; CF=0
push edi push edi
popad popad
ret ret
@ -3197,4 +3199,172 @@ fs_HdRead:
.eof: .eof:
pop ebx edx ecx ebx pop ebx edx ecx ebx
jmp .reteof jmp .reteof
;----------------------------------------------------------------
;
; fs_HdReadFolder - LFN variant for reading hard disk folder
;
; esi points to filename
; ebx pointer to 32-bit number = first wanted block, 0+
; ecx number of blocks to read, 0+
; edx mem location to return data
;
; ret ebx = size or 0xffffffff folder not found
; eax = 0 ok read or other = errormsg
;
;--------------------------------------------------------------
fs_HdReadFolder:
mov ebx, [ebx]
mov eax, [ROOT_CLUSTER]
push edi
cmp byte [esi], 0
jz .doit
call hd_find_lfn
jnc .found
pop edi
or ebx, -1
mov eax, ERROR_FILE_NOT_FOUND
ret
.found:
test byte [edi+11], 0x10 ; do not allow read files
jnz .found_dir
pop edi
or ebx, -1
mov eax, ERROR_ACCESS_DENIED
ret
.found_dir:
mov eax, [edi+20-2]
mov ax, [edi+26] ; eax=cluster
.doit:
push esi ecx
push ebp
sub esp, 262*2 ; reserve space for LFN
mov ebp, esp
push 1 ; for fat_get_name: read UNICODE name
; init header
push eax ecx
mov edi, edx
mov ecx, 32/4
xor eax, eax
rep stosd
pop ecx eax
mov byte [edx], 1 ; version
mov esi, edi ; esi points to BDFE
.new_cluster:
mov [cluster_tmp], eax
test eax, eax
jnz @f
cmp [fat_type], 32
jz .notfound
mov eax, [ROOT_START]
push [ROOT_SECTORS]
push ebx
jmp .new_sector
@@:
dec eax
dec eax
imul eax, [SECTORS_PER_CLUSTER]
push [SECTORS_PER_CLUSTER]
add eax, [DATA_START]
push ebx
.new_sector:
mov ebx, buffer
mov edi, ebx
call hd_read
cmp [hd_error], 0
jnz .notfound2
add ebx, 512
push eax
.l1:
call fat_get_name
jc .l2
cmp byte [edi+11], 0xF
jnz .do_bdfe
add edi, 0x20
cmp edi, ebx
jb .do_bdfe
pop eax
inc eax
dec dword [esp+4]
jnz @f
mov eax, [cluster_tmp]
test eax, eax
jz .done
call get_FAT
cmp [hd_error], 0
jnz .notfound2
cmp eax, 2
jb .done
cmp eax, [fatRESERVED]
jae .done
push eax
mov eax, [SECTORS_PER_CLUSTER]
mov [esp+8], eax
pop eax
mov [cluster_tmp], eax
dec eax
dec eax
imul eax, [SECTORS_PER_CLUSTER]
add eax, [DATA_START]
@@:
mov ebx, buffer
mov edi, ebx
call hd_read
cmp [hd_error], 0
jnz .notfound2
add ebx, 512
push eax
.do_bdfe:
inc dword [edx+8] ; new file found
dec dword [esp+4]
jns .l2
dec ecx
js .l2
inc dword [edx+4] ; new file block copied
call fat_entry_to_bdfe
.l2:
add edi, 0x20
cmp edi, ebx
jb .l1
pop eax
inc eax
dec dword [esp+4]
jnz .new_sector
mov eax, [cluster_tmp]
test eax, eax
jz .done
call get_FAT
cmp [hd_error], 0
jnz .notfound2
cmp eax, 2
jb .done
cmp eax, [fatRESERVED]
jae .done
push eax
mov eax, [SECTORS_PER_CLUSTER]
mov [esp+8], eax
pop eax
pop ebx
add esp, 4
jmp .new_cluster
.notfound2:
add esp, 8
.notfound:
add esp, 262*2+4
pop ebp ecx esi edi
mov eax, ERROR_FILE_NOT_FOUND
or ebx, -1
ret
.done:
add esp, 262*2+4+8
pop ebp
mov ebx, [edx+8]
xor eax, eax
dec ecx
js @f
mov al, ERROR_END_OF_FILE
@@:
pop ecx esi edi
ret
; \end{diamond} ; \end{diamond}

View File

@ -6,36 +6,60 @@ iglobal
rootdirs: rootdirs:
db 2,'rd' db 2,'rd'
dd fs_OnRamdisk dd fs_OnRamdisk
dd fs_NextRamdisk
db 7,'ramdisk' db 7,'ramdisk'
dd fs_OnRamdisk dd fs_OnRamdisk
dd fs_NextRamdisk
db 2,'fd' db 2,'fd'
dd fs_OnFloppy dd fs_OnFloppy
dd fs_NextFloppy
db 10,'floppydisk' db 10,'floppydisk'
dd fs_OnFloppy dd fs_OnFloppy
dd fs_NextFloppy
db 3,'hd0' db 3,'hd0'
dd fs_OnHd0 dd fs_OnHd0
dd fs_NextHd0
db 3,'hd1' db 3,'hd1'
dd fs_OnHd1 dd fs_OnHd1
dd fs_NextHd1
db 3,'hd2' db 3,'hd2'
dd fs_OnHd2 dd fs_OnHd2
dd fs_NextHd2
db 3,'hd3' db 3,'hd3'
dd fs_OnHd3 dd fs_OnHd3
dd fs_NextHd3
db 0 db 0
virtual_root_query:
dd fs_HasRamdisk
du 'rd',0
dd fs_HasFloppy
du 'fd',0
dd fs_HasHd0
du 'hd0',0
dd fs_HasHd1
du 'hd1',0
dd fs_HasHd2
du 'hd2',0
dd fs_HasHd3
du 'hd3',0
dd 0
endg endg
file_system_lfn: file_system_lfn:
; in: eax->fileinfo block ; in: eax->fileinfo block
; operation codes: ; operation codes:
; 0 : read file ; 0 : read file
; 1 : rewrite file - not implemented yet ; 1 : read folder
; 2 : delete file - not implemented yet ; 2 : rewrite file - not implemented yet
; 3 : write/append to file - not implemented yet ; 3 : write/append to file - not implemented yet
; 4 : create directory - not implemented yet ; 4 : start application - not implemented yet
; 5 : rename file/directory - not implemented yet ; 5 : delete file - not implemented yet
; 6 : get file attributes structure - not implemented yet ; 6 : create directory - not implemented yet
; 7 : start application - not implemented yet ; 7 : rename file/directory - not implemented yet
; 8 : find file with mask - not implemented yet ; 8 : get file attributes structure - not implemented yet
add eax, std_application_base_address
; parse file name ; parse file name
xchg ebx, eax xchg ebx, eax
lea esi, [ebx+20] lea esi, [ebx+20]
@ -48,13 +72,14 @@ file_system_lfn:
@@: @@:
cmp byte [esi], 0 cmp byte [esi], 0
jz .rootdir jz .rootdir
mov edi, rootdirs-4 mov edi, rootdirs-8
xor ecx, ecx xor ecx, ecx
push esi push esi
.scan1: .scan1:
pop esi pop esi
add edi, ecx add edi, ecx
scasd scasd
scasd
mov cl, byte [edi] mov cl, byte [edi]
jecxz .notfound jecxz .notfound
inc edi inc edi
@ -65,23 +90,146 @@ file_system_lfn:
scasb scasb
loopz @b loopz @b
jnz .scan1 jnz .scan1
pop eax
lodsb lodsb
cmp al, '/' cmp al, '/'
jz .found1 jz .found1
test al, al test al, al
jnz .scan1 jnz .scan1
pop eax
; directory /xxx ; directory /xxx
.maindir: .maindir:
cmp dword [ebx], 1
jnz .access_denied
xor eax, eax
mov ebp, [ebx+12]
mov edx, [ebx+16]
add edx, std_application_base_address
mov ebx, [ebx+4]
mov esi, [edi+4]
; ebx=first block, ebp=number of blocks, edx=return area, esi='Next' handler
mov edi, edx
mov ecx, 32/4
rep stosd
mov byte [edx], 1 ; version
.maindir_loop:
call esi
jc .maindir_done
inc dword [edx+8]
dec ebx
jns .maindir_loop
dec ebp
js .maindir_loop
inc dword [edx+4]
mov dword [edi], 0x10 ; attributes: folder
mov dword [edi+4], 1 ; name type: UNICODE
push eax
xor eax, eax
add edi, 8
mov ecx, 40/4-2
rep stosd
pop eax
push eax edx
; convert number in eax to decimal UNICODE string
push edi
push -'0'
mov cl, 10
@@:
xor edx, edx
div ecx
push edx
test eax, eax
jnz @b
@@:
pop eax
add al, '0'
stosw
jnz @b
mov byte [edi-1], 0
pop edi
add edi, 520
pop edx eax
jmp .maindir_loop
.maindir_done:
mov ebx, [edx+8]
xor eax, eax
dec ebp
js @f
mov al, ERROR_END_OF_FILE
@@:
mov [esp+36], eax
mov [esp+24], ebx
ret
; directory / ; directory /
.rootdir: .rootdir:
cmp dword [ebx], 1 ; read folder?
jz .readroot
.access_denied:
mov dword [esp+36], 10 ; access denied mov dword [esp+36], 10 ; access denied
ret ret
.readroot:
; virtual root folder - special handler
mov esi, virtual_root_query
mov ebp, [ebx+12]
mov edx, [ebx+16]
add edx, std_application_base_address
mov ebx, [ebx+4]
xor eax, eax
; eax=0, ebx=first block, ebp=number of blocks, edx=return area
mov edi, edx
mov ecx, 32/4
rep stosd
mov byte [edx], 1 ; version
.readroot_loop:
cmp dword [esi], eax
jz .readroot_done
call dword [esi]
add esi, 4
test eax, eax
jnz @f
.readroot_next:
or ecx, -1
xchg esi, edi
repnz scasw
xchg esi, edi
jmp .readroot_loop
@@:
xor eax, eax
inc dword [edx+8]
dec ebx
jns .readroot_next
dec ebp
js .readroot_next
inc dword [edx+4]
mov dword [edi], 0x10 ; attributes: folder
mov dword [edi+4], 1 ; name type: UNICODE
add edi, 8
mov ecx, 40/4-2
rep stosd
push edi
@@:
lodsw
stosw
test eax, eax
jnz @b
pop edi
add edi, 520
jmp .readroot_loop
.readroot_done:
mov ebx, [edx+8]
xor eax, eax
dec ebp
js @f
mov al, ERROR_END_OF_FILE
@@:
mov [esp+36], eax
mov [esp+24], ebx
ret
.found1: .found1:
pop eax
cmp byte [esi], 0 cmp byte [esi], 0
jz .maindir jz .maindir
mov ebp, dword [edi] ; handler for this device
; read partition number ; read partition number
xor ecx, ecx xor ecx, ecx
xor eax, eax xor eax, eax
@ -104,10 +252,12 @@ file_system_lfn:
jnz @f jnz @f
dec esi dec esi
@@: @@:
; now ebp contains handler address, ecx - partition number, esi points to ASCIIZ string - rest of name ; now [edi] contains handler address, ecx - partition number,
jmp ebp ; esi points to ASCIIZ string - rest of name
jmp dword [edi]
; handlers for devices ; handlers for devices
; in: ecx = 0 => query virtual directory /xxx
; in: ecx = partition number ; in: ecx = partition number
; esi -> relative (for device) name ; esi -> relative (for device) name
; ebx -> fileinfo ; ebx -> fileinfo
@ -116,9 +266,9 @@ file_system_lfn:
fs_OnRamdisk: fs_OnRamdisk:
cmp ecx, 1 cmp ecx, 1
jnz file_system_lfn.notfound jnz file_system_lfn.notfound
movzx eax, byte [ebx] mov eax, [ebx]
test eax, eax cmp eax, 1
jnz .not_impl ja .not_impl
mov ecx, [ebx+12] mov ecx, [ebx+12]
mov edx, [ebx+16] mov edx, [ebx+16]
add edx, std_application_base_address add edx, std_application_base_address
@ -133,13 +283,14 @@ fs_OnRamdisk:
fs_RamdiskServices: fs_RamdiskServices:
dd fs_RamdiskRead dd fs_RamdiskRead
dd fs_RamdiskReadFolder
fs_OnFloppy: fs_OnFloppy:
cmp ecx, 2 cmp ecx, 2
ja file_system_lfn.notfound ja file_system_lfn.notfound
movzx eax, byte [ebx] mov eax, [ebx]
test eax, eax cmp eax, 1
jnz fs_OnRamdisk.not_impl ja fs_OnRamdisk.not_impl
call reserve_flp call reserve_flp
mov [flp_number], cl mov [flp_number], cl
mov ecx, [ebx+12] mov ecx, [ebx+12]
@ -154,6 +305,7 @@ fs_OnFloppy:
fs_FloppyServices: fs_FloppyServices:
dd fs_FloppyRead dd fs_FloppyRead
dd fs_FloppyReadFolder
fs_OnHd0: fs_OnHd0:
call reserve_hd1 call reserve_hd1
@ -181,8 +333,11 @@ fs_OnHd3:
fs_OnHd: fs_OnHd:
pop eax pop eax
mov [hdpos], eax mov [hdpos], eax
cmp ecx, [0x40001+eax] cmp ecx, 0x100
jae .nf
cmp cl, [0x40001+eax]
jbe @f jbe @f
.nf:
and [hd1_status], 0 and [hd1_status], 0
mov dword [esp+36], 5 ; not found mov dword [esp+36], 5 ; not found
ret ret
@ -194,13 +349,110 @@ fs_OnHd:
mov ecx, [ebx+12] mov ecx, [ebx+12]
mov edx, [ebx+16] mov edx, [ebx+16]
add edx, std_application_base_address add edx, std_application_base_address
movzx eax, byte [ebx] mov eax, [ebx]
cmp eax, 1
ja .not_impl
add ebx, 4 add ebx, 4
call dword [fs_HdServices + eax*4] call dword [fs_HdServices + eax*4]
and [hd1_status], 0 and [hd1_status], 0
mov [esp+36], eax mov [esp+36], eax
mov [esp+24], ebx mov [esp+24], ebx
ret ret
.not_impl:
and [hd1_status], 0
mov dword [esp+36], 2 ; not implemented
ret
fs_HdServices: fs_HdServices:
dd fs_HdRead dd fs_HdRead
dd fs_HdReadFolder
fs_HasRamdisk:
mov al, 1 ; we always have ramdisk
ret
fs_HasFloppy:
cmp byte [0x40000], 0
setnz al
ret
fs_HasHd0:
mov al, [0x40001]
and al, 11000000b
cmp al, 01000000b
setz al
ret
fs_HasHd1:
mov al, [0x40001]
and al, 00110000b
cmp al, 00010000b
setz al
ret
fs_HasHd2:
mov al, [0x40001]
and al, 00001100b
cmp al, 00000100b
setz al
ret
fs_HasHd3:
mov al, [0x40001]
and al, 00000011b
cmp al, 00000001b
setz al
ret
; fs_NextXXX functions:
; in: eax = partition number, from which start to scan
; out: CF=1 => no more partitions
; CF=0 => eax=next partition number
fs_NextRamdisk:
; we always have /rd/1
test eax, eax
stc
jnz @f
mov al, 1
clc
@@:
ret
fs_NextFloppy:
; we have /fd/1 iff (([0x40000] and 0xF0) != 0) and /fd/2 iff (([0x40000] and 0x0F) != 0)
test byte [0x40000], 0xF0
jz .no1
test eax, eax
jnz .no1
inc eax
ret ; CF cleared
.no1:
test byte [0x40000], 0x0F
jz .no2
cmp al, 2
jae .no2
mov al, 2
clc
ret
.no2:
stc
ret
; on hdx, we have partitions from 1 to [0x40002+x]
fs_NextHd0:
push 0
jmp fs_NextHd
fs_NextHd1:
push 1
jmp fs_NextHd
fs_NextHd2:
push 2
jmp fs_NextHd
fs_NextHd3:
push 3
fs_NextHd:
pop ecx
movzx ecx, byte [0x40002+ecx]
cmp eax, ecx
jae fs_NextFloppy.no2
inc eax
clc
ret

View File

@ -1417,8 +1417,8 @@ display_number:
ret ret
cont_displ: cont_displ:
cmp eax,60*0x10000 ; length <= 60 ? cmp eax,61*0x10000 ; length <= 60 ?
jbe cont_displ2 jb cont_displ2
ret ret
cont_displ2: cont_displ2:
@ -1435,7 +1435,7 @@ display_number:
cmp ah,0 ; DECIMAL cmp ah,0 ; DECIMAL
jne no_display_desnum jne no_display_desnum
shr eax,16 shr eax,16
and eax,0x2f and eax,0x3f
push eax push eax
;mov edi,[0x3010] ;mov edi,[0x3010]
;mov edi,[edi+0x10] ;mov edi,[edi+0x10]
@ -1461,7 +1461,7 @@ display_number:
cmp ah,0x01 ; HEXADECIMAL cmp ah,0x01 ; HEXADECIMAL
jne no_display_hexnum jne no_display_hexnum
shr eax,16 shr eax,16
and eax,0x2f and eax,0x3f
push eax push eax
;mov edi,[0x3010] ;mov edi,[0x3010]
;mov edi,[edi+0x10] ;mov edi,[edi+0x10]
@ -1488,7 +1488,7 @@ display_number:
cmp ah,0x02 ; BINARY cmp ah,0x02 ; BINARY
jne no_display_binnum jne no_display_binnum
shr eax,16 shr eax,16
and eax,0x2f and eax,0x3f
push eax push eax
;mov edi,[0x3010] ;mov edi,[0x3010]
;mov edi,[edi+0x10] ;mov edi,[edi+0x10]
@ -1637,6 +1637,10 @@ midi_base dw 0
nsyse2: nsyse2:
cmp eax,3 ; CD cmp eax,3 ; CD
jnz nsyse3 jnz nsyse3
test ebx,ebx
jz nosesl
cmp ebx, 4
ja nosesl
mov [cd_base],bl mov [cd_base],bl
cmp ebx,1 cmp ebx,1
jnz noprma jnz noprma
@ -1694,6 +1698,10 @@ wss_temp dd 0
cmp eax,7 ; HD BASE cmp eax,7 ; HD BASE
jne nsyse7 jne nsyse7
test ebx,ebx
jz nosethd
cmp ebx,4
ja nosethd
mov [hd_base],bl mov [hd_base],bl
cmp ebx,1 cmp ebx,1
jnz noprmahd jnz noprmahd
@ -1727,6 +1735,7 @@ wss_temp dd 0
call reserve_hd1 call reserve_hd1
call clear_hd_cache call clear_hd_cache
mov [hd1_status],0 ; free mov [hd1_status],0 ; free
nosethd:
ret ret
hd_base db 0 hd_base db 0
@ -1748,6 +1757,8 @@ hd_base db 0
cmp eax,10 ; SOUND DMA CHANNEL cmp eax,10 ; SOUND DMA CHANNEL
jne no_set_sound_dma jne no_set_sound_dma
cmp ebx,3
ja sys_setup_err
mov [sound_dma],ebx mov [sound_dma],ebx
ret ret
no_set_sound_dma: no_set_sound_dma:
@ -1770,6 +1781,7 @@ hd_base db 0
include 'vmodeint.inc' include 'vmodeint.inc'
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
sys_setup_err:
mov [esp+36],dword -1 mov [esp+36],dword -1
ret ret
@ -2062,34 +2074,61 @@ sys_end:
call delay_hs call delay_hs
jmp waitterm jmp waitterm
sys_system: iglobal
sys_system_table:
dd sysfn_shutdown ; 1 = system shutdown
dd sysfn_terminate ; 2 = terminate thread
dd sysfn_activate ; 3 = activate window
dd sysfn_getidletime ; 4 = get idle time
dd sysfn_getcpuclock ; 5 = get cpu clock
dd sysfn_saveramdisk ; 6 = save ramdisk
dd sysfn_getactive ; 7 = get active window
dd sysfn_sound_flag ; 8 = get/set sound_flag
dd sysfn_shutdown_param ; 9 = shutdown with parameter
dd sysfn_minimize ; 10 = minimize window
dd sysfn_getdiskinfo ; 11 = get disk subsystem info
dd sysfn_lastkey ; 12 = get last pressed key
dd sysfn_getversion ; 13 = get kernel version
dd sysfn_waitretrace ; 14 = wait retrace
dd sysfn_centermouse ; 15 = center mouse cursor
dd sysfn_getfreemem ; 16 = get free memory size
dd sysfn_getallmem ; 17 = get total memory size
sysfn_num = ($ - sys_system_table)/4
endg
cmp eax,1 ; BOOT sys_system:
jnz nosystemboot dec eax
cmp eax, sysfn_num
jae @f
jmp dword [sys_system_table + eax*4]
@@:
ret
sysfn_shutdown: ; 18.1 = BOOT
mov [0x2f0000+0x9030],byte 0 mov [0x2f0000+0x9030],byte 0
for_shutdown_parameter: for_shutdown_parameter:
mov eax,[0x3004] mov eax,[0x3004]
add eax,2 add eax,2
mov [shutdown_processes],eax mov [shutdown_processes],eax
mov [0xFF00],al mov [0xFF00],al
xor eax, eax and dword [esp+36], 0
ret ret
uglobal uglobal
shutdown_processes: dd 0x0 shutdown_processes: dd 0x0
endg endg
nosystemboot:
cmp eax,2 ; TERMINATE sysfn_terminate: ; 18.2 = TERMINATE
jnz noprocessterminate
cmp ebx,2 cmp ebx,2
jb noprocessterminate jb noprocessterminate
mov edx,[0x3004] mov edx,[0x3004]
cmp ebx,edx cmp ebx,edx
jg noprocessterminate ja noprocessterminate
mov eax,[0x3004] mov eax,[0x3004]
shl ebx,5 shl ebx,5
mov edx,[ebx+0x3000+4] mov edx,[ebx+0x3000+4]
add ebx,0x3000+0xa add ebx,0x3000+0xa
cmp byte [ebx], 9
jz noprocessterminate
;call MEM_Heap_Lock ;guarantee that process isn't working with heap ;call MEM_Heap_Lock ;guarantee that process isn't working with heap
mov [ebx],byte 3 ; clear possible i40's mov [ebx],byte 3 ; clear possible i40's
@ -2099,11 +2138,10 @@ sys_system:
jne noatsc jne noatsc
mov [application_table_status],0 mov [application_table_status],0
noatsc: noatsc:
ret
noprocessterminate: noprocessterminate:
ret
cmp eax,3 ; ACTIVATE WINDOW sysfn_activate: ; 18.3 = ACTIVATE WINDOW
jnz nowindowactivate
cmp ebx,2 cmp ebx,2
jb nowindowactivate jb nowindowactivate
cmp ebx,[0x3004] cmp ebx,[0x3004]
@ -2115,80 +2153,73 @@ sys_system:
;mov esi, [ebx] ; esi = window stack value ;mov esi, [ebx] ; esi = window stack value
;and esi, 0xffff ; word ;and esi, 0xffff ; word
movzx esi, word [0xC000 + ebx*2] movzx esi, word [0xC000 + ebx*2]
mov edx, [0x3004] ; edx = number of processes cmp esi, [0x3004] ; number of processes
cmp esi, edx
jz nowindowactivate ; continue if window_stack_value != number_of_processes jz nowindowactivate ; continue if window_stack_value != number_of_processes
; i.e. if window is not already active ; i.e. if window is not already active
;* start code - get active process (1) - Mario79 ;* start code - get active process (1) - Mario79
cli ; cli
mov [window_minimize],2 mov [window_minimize],2
; mov [active_process],edi ; mov [active_process],edi
sti ; sti
;* end code - get active process (1) - Mario79 ;* end code - get active process (1) - Mario79
mov [0xff01],edi ; activate mov [0xff01],edi ; activate
xor eax, eax nowindowactivate:
ret ret
nowindowactivate: sysfn_getidletime: ; 18.4 = GET IDLETIME
cmp eax,4 ; GET IDLETIME
jnz nogetidletime
mov eax,[idleusesec] mov eax,[idleusesec]
mov [esp+36], eax
ret ret
nogetidletime:
cmp eax,5 ; GET TSC/SEC sysfn_getcpuclock: ; 18.5 = GET TSC/SEC
jnz nogettscsec
mov eax,[0xf600] mov eax,[0xf600]
mov [esp+36], eax
ret ret
nogettscsec:
; SAVE ramdisk to /hd/1/menuet.img ; SAVE ramdisk to /hd/1/menuet.img
;!!!!!!!!!!!!!!!!!!!!!!!! ;!!!!!!!!!!!!!!!!!!!!!!!!
include 'blkdev/rdsave.inc' include 'blkdev/rdsave.inc'
;!!!!!!!!!!!!!!!!!!!!!!!! ;!!!!!!!!!!!!!!!!!!!!!!!!
cmp eax,7
jnz nogetactiveprocess sysfn_getactive: ; 18.7 = get active window
mov eax,[active_process] mov eax,[active_process]
mov [esp+36],eax
ret ret
nogetactiveprocess:
cmp eax,8 sysfn_sound_flag: ; 18.8 = get/set sound_flag
jnz nosoundflag
cmp ebx,1 cmp ebx,1
jne nogetsoundflag jne nogetsoundflag
movzx eax,byte [sound_flag] ; get sound_flag movzx eax,byte [sound_flag] ; get sound_flag
mov [esp+36],eax
ret ret
nogetsoundflag: nogetsoundflag:
cmp ebx,2 cmp ebx,2
jnz nosoundflag jnz nosoundflag
inc byte [sound_flag] ; set sound_flag xor byte [sound_flag], 1
and byte [sound_flag],1 ; nosoundflag:
ret ret
nosoundflag:
cmp eax,9 ; system shutdown with param sysfn_shutdown_param: ; 18.9 = system shutdown with param
jnz noshutdownsystem
cmp ebx,1 cmp ebx,1
jl exit_for_anyone jl exit_for_anyone
cmp ebx,4 cmp ebx,4
jg exit_for_anyone jg exit_for_anyone
mov [0x2f0000+0x9030],bl mov [0x2f0000+0x9030],bl
jmp for_shutdown_parameter jmp for_shutdown_parameter
noshutdownsystem:
cmp eax,10 ; minimize window sysfn_minimize: ; 18.10 = minimize window
jnz nominimizewindow
mov [window_minimize],1 mov [window_minimize],1
exit_for_anyone: exit_for_anyone:
ret ret
nominimizewindow:
cmp eax,11 ; get disk info table sysfn_getdiskinfo: ; 18.11 = get disk info table
jnz nogetdiskinfo
cmp ebx,1 cmp ebx,1
jnz full_table jnz full_table
small_table: small_table:
call for_all_tables call for_all_tables
mov cx,10 mov ecx,10
cld cld
rep movsb rep movsb
ret ret
@ -2197,28 +2228,24 @@ nominimizewindow:
mov edi,[edi+10h] mov edi,[edi+10h]
add edi,ecx add edi,ecx
mov esi,0x40000 mov esi,0x40000
xor ecx,ecx
ret ret
full_table: full_table:
cmp ebx,2 cmp ebx,2
jnz exit_for_anyone jnz exit_for_anyone
call for_all_tables call for_all_tables
mov cx,16384 mov ecx,16384
cld cld
rep movsd rep movsd
ret ret
nogetdiskinfo:
cmp eax,12 ; get all key pressed with ALT sysfn_lastkey: ; 18.12 = get all key pressed with ALT
jnz nogetkey
mov eax,[last_key_press] mov eax,[last_key_press]
mov al,[keyboard_mode_sys] mov al,[keyboard_mode_sys]
mov [esp+36],eax mov [esp+36],eax
mov [last_key_press],0 mov [last_key_press],0
.finish:
ret ret
nogetkey:
cmp eax,13 ; get kernel ID and version sysfn_getversion: ; 18.13 = get kernel ID and version
jnz nogetkernel_id
mov edi,[3010h] mov edi,[3010h]
mov edi,[edi+10h] mov edi,[edi+10h]
add edi,ebx add edi,ebx
@ -2227,9 +2254,8 @@ nogetkey:
cld cld
rep movsb rep movsb
ret ret
nogetkernel_id:
cmp eax,14 ; sys wait retrace sysfn_waitretrace: ; 18.14 = sys wait retrace
jnz nosys_wait_retrace
;wait retrace functions ;wait retrace functions
sys_wait_retrace: sys_wait_retrace:
mov edx,0x3da mov edx,0x3da
@ -2239,29 +2265,26 @@ nogetkernel_id:
jz WaitRetrace_loop jz WaitRetrace_loop
mov [esp+36],dword 0 mov [esp+36],dword 0
ret ret
nosys_wait_retrace:
cmp eax,15 ; mouse centered sysfn_centermouse: ; 18.15 = mouse centered
jnz no_mouse_centered
call mouse_centered call mouse_centered
mov [esp+36],dword 0 mov [esp+36],dword 0
ret ret
no_mouse_centered:
cmp eax,16 sysfn_getfreemem:
jnz no_get_free_space
mov eax,[MEM_FreeSpace] mov eax,[MEM_FreeSpace]
shl eax,2 shl eax,2
mov [esp+36],eax
ret ret
no_get_free_space:
cmp eax,17 sysfn_getallmem:
jnz no_get_all_space
mov eax,[0xFE8C] mov eax,[0xFE8C]
shr eax,10 shr eax,10
; mov eax,[MEM_AllSpace] ; mov eax,[MEM_AllSpace]
; shl eax,2 ; shl eax,2
mov [esp+36],eax
ret ret
no_get_all_space:
ret
uglobal uglobal
;// mike.dld, 2006-29-01 [ ;// mike.dld, 2006-29-01 [
screen_workarea RECT screen_workarea RECT
@ -2694,10 +2717,18 @@ align 4
sys_date: sys_date:
cli cli
mov al,6 ; day of week
out 0x70,al @@: mov al, 10
in al,0x71 out 0x70, al
mov ch,al in al, 0x71
test al, al
jns @f
mov esi, 1
call delay_ms
jmp @b
@@:
mov ch,0
mov al,7 ; date mov al,7 ; date
out 0x70,al out 0x70,al
in al,0x71 in al,0x71
@ -3503,50 +3534,51 @@ memmove: ; memory move in bytes
ret ret
align 4 ; <diamond> Sysfunction 34, read_floppy_file, is obsolete. Use 58 or 70 function instead.
;align 4
read_floppy_file:
; as input
; ;
; eax pointer to file ;read_floppy_file:
; ebx file lenght
; ecx start 512 byte block number
; edx number of blocks to read
; esi pointer to return/work area (atleast 20 000 bytes)
; ;
;; as input
;;
;; eax pointer to file
;; ebx file lenght
;; ecx start 512 byte block number
;; edx number of blocks to read
;; esi pointer to return/work area (atleast 20 000 bytes)
;;
;;
;; on return
;;
;; eax = 0 command succesful
;; 1 no fd base and/or partition defined
;; 2 yet unsupported FS
;; 3 unknown FS
;; 4 partition not defined at hd
;; 5 file not found
;; ebx = size of file
; ;
; on return ; mov edi,[0x3010]
; add edi,0x10
; add esi,[edi]
; add eax,[edi]
; ;
; eax = 0 command succesful ; pushad
; 1 no fd base and/or partition defined ; mov edi,esi
; 2 yet unsupported FS ; add edi,1024
; 3 unknown FS ; mov esi,0x100000+19*512
; 4 partition not defined at hd ; sub ecx,1
; 5 file not found ; shl ecx,9
; ebx = size of file ; add esi,ecx
; shl edx,9
mov edi,[0x3010] ; mov ecx,edx
add edi,0x10 ; cld
add esi,[edi] ; rep movsb
add eax,[edi] ; popad
;
pushad ; mov [esp+36],eax
mov edi,esi ; mov [esp+24],ebx
add edi,1024 ; ret
mov esi,0x100000+19*512
sub ecx,1
shl ecx,9
add esi,ecx
shl edx,9
mov ecx,edx
cld
rep movsb
popad
mov [esp+36],eax
mov [esp+24],ebx
ret
@ -3558,14 +3590,13 @@ sys_programirq:
add edi,0x10 add edi,0x10
add eax,[edi] add eax,[edi]
mov edx,ebx cmp ebx,16
shl edx,2 jae .not_owner
add edx,irq_owner
mov edx,[edx]
mov edi,[0x3010] mov edi,[0x3010]
mov edi,[edi+0x4] mov edi,[edi+0x4]
cmp edx,edi cmp edi,[irq_owner+ebx*4]
je spril1 je spril1
.not_owner:
mov [esp+36],dword 1 mov [esp+36],dword 1
ret ret
spril1: spril1:
@ -3584,7 +3615,8 @@ sys_programirq:
align 4 align 4
get_irq_data: get_irq_data:
cmp eax,16
jae .not_owner
mov edx,eax ; check for correct owner mov edx,eax ; check for correct owner
shl edx,2 shl edx,2
add edx,irq_owner add edx,irq_owner
@ -3593,9 +3625,8 @@ get_irq_data:
mov edi,[edi+0x4] mov edi,[edi+0x4]
cmp edx,edi cmp edx,edi
je gidril1 je gidril1
mov [esp+36],eax .not_owner:
mov [esp+32],dword 2 mov [esp+32],dword 2 ; ecx=2
mov [esp+24],ebx
ret ret
gidril1: gidril1:
@ -3618,7 +3649,7 @@ get_irq_data:
mov ecx,4000 / 4 mov ecx,4000 / 4
cld cld
rep movsd rep movsd
xor ecx,ecx ; xor ecx,ecx ; as result of 'rep' ecx=0
gid1: gid1:
mov [esp+36],eax mov [esp+36],eax
mov [esp+32],ecx mov [esp+32],ecx
@ -3678,18 +3709,20 @@ r_f_port_area:
pushad pushad
cmp ebx,ecx ; beginning > end ? cmp ebx,ecx ; beginning > end ?
jg rpal1 ja rpal1
cmp ecx,65536
jae rpal1
mov esi,[0x2d0000] mov esi,[0x2d0000]
cmp esi,0 ; no reserved areas ? test esi,esi ; no reserved areas ?
je rpal2 je rpal2
cmp esi,255 ; max reserved cmp esi,255 ; max reserved
jge rpal1 jae rpal1
rpal3: rpal3:
mov edi,esi mov edi,esi
shl edi,4 shl edi,4
add edi,0x2d0000 add edi,0x2d0000
cmp ebx,[edi+8] cmp ebx,[edi+8]
jg rpal4 ja rpal4
cmp ecx,[edi+4] cmp ecx,[edi+4]
jae rpal1 jae rpal1
; jb rpal4 ; jb rpal4
@ -3721,7 +3754,7 @@ r_f_port_area:
pushad pushad
mov ebp,0 ; enable - eax = port xor ebp,ebp ; enable - eax = port
call set_io_access_rights call set_io_access_rights
popad popad
@ -3757,7 +3790,7 @@ free_port_area:
pushad pushad
mov esi,[0x2d0000] ; no reserved areas ? mov esi,[0x2d0000] ; no reserved areas ?
cmp esi,0 test esi,esi
je frpal2 je frpal2
mov edx,[0x3010] mov edx,[0x3010]
mov edx,[edx+4] mov edx,[edx+4]
@ -3825,43 +3858,35 @@ free_port_area:
reserve_free_irq: reserve_free_irq:
cmp eax,0 mov ecx, 1
cmp ebx, 16
jae fril1
test eax,eax
jz reserve_irq jz reserve_irq
mov edi,ebx lea edi,[irq_owner+ebx*4]
shl edi,2
add edi,irq_owner
mov edx,[edi] mov edx,[edi]
mov eax,[0x3010] mov eax,[0x3010]
mov eax,[eax+0x4] cmp edx,[eax+0x4]
mov ecx,1
cmp edx,eax
jne fril1 jne fril1
mov [edi],dword 0 dec ecx
mov ecx,0 mov [edi],ecx
fril1: fril1:
mov [esp+36],ecx ; return in eax mov [esp+36],ecx ; return in eax
ret ret
reserve_irq: reserve_irq:
mov edi,ebx lea edi,[irq_owner+ebx*4]
shl edi,2 cmp dword [edi], 0
add edi,irq_owner jnz ril1
mov edx,[edi]
mov ecx,1
cmp edx,0
jne ril1
mov edx,[0x3010] mov edx,[0x3010]
mov edx,[edx+0x4] mov edx,[edx+0x4]
mov [edi],edx mov [edi],edx
mov ecx,0 dec ecx
ril1: ril1:
mov [esp+36],ecx ; return in eax mov [esp+36],ecx ; return in eax
ret ret
@ -3904,7 +3929,13 @@ drawbackground:
call [draw_pointer] call [draw_pointer]
ret ret
align 4
syscall_putimage: ; PutImage
mov edx,ecx
mov ecx,ebx
lea ebx, [eax+std_application_base_address]
sys_putimage: sys_putimage:
test ecx,0x80008000 test ecx,0x80008000
@ -3916,29 +3947,21 @@ sys_putimage:
.exit: .exit:
ret ret
@@: @@:
mov eax, vga_putimage
cmp [0xfe0c], word 0x12
jz .doit
mov eax, vesa12_putimage
cmp [0xfe0c], word 0100000000000000b
jae @f
cmp [0xfe0c], word 0x13
jnz .doit
@@:
mov eax, vesa20_putimage
.doit:
; inc [mouse_pause] ; inc [mouse_pause]
cmp [0xfe0c],word 0x12 call eax
jne spiv20
call vga_putimage
; dec [mouse_pause] ; dec [mouse_pause]
call [draw_pointer] jmp [draw_pointer]
ret
spiv20:
cmp [0xfe0c],word 0100000000000000b
jge piv20
cmp [0xfe0c],word 0x13
je piv20
call vesa12_putimage
; dec [mouse_pause]
call [draw_pointer]
ret
piv20:
call vesa20_putimage
; dec [mouse_pause]
call [draw_pointer]
ret
; eax x beginning ; eax x beginning
; ebx y beginning ; ebx y beginning
@ -4458,7 +4481,7 @@ sys_ipc:
mov eax,edi mov eax,edi
add eax,ecx add eax,ecx
cmp eax,ebx cmp eax,ebx
jge ipc_err3 ; not enough room ? jg ipc_err3 ; not enough room ?
push ecx push ecx
@ -4598,20 +4621,6 @@ syscall_openramdiskfile: ; OpenRamdiskFile
align 4 align 4
syscall_putimage: ; PutImage
mov edi,[0x3010]
add edi,0x10
add eax,[edi]
mov edx,ecx
mov ecx,ebx
mov ebx,eax
call sys_putimage
mov [esp+36],eax
ret
align 4
syscall_drawrect: ; DrawRect syscall_drawrect: ; DrawRect
mov edi,ecx mov edi,ecx
@ -4642,14 +4651,6 @@ syscall_getscreensize: ; GetScreenSize
align 4 align 4
syscall_system: ; System
call sys_system
mov [esp+36],eax
ret
align 4
syscall_startapp: ; StartApp syscall_startapp: ; StartApp
mov edi,[0x3010] mov edi,[0x3010]
add edi,0x10 add edi,0x10
@ -4673,32 +4674,33 @@ syscall_cdaudio: ; CD
mov [esp+36],eax mov [esp+36],eax
ret ret
align 4 ; <diamond> ReadHd and StartHdApp functions are obsolete. Use 58 or 70 functions instead.
;align 4
;
;syscall_readhd: ; ReadHd
;
; mov edi,[0x3010]
; add edi,0x10
; add esi,[edi]
; add eax,[edi]
; call read_hd_file
; mov [esp+36],eax
; mov [esp+24],ebx
; ret
syscall_readhd: ; ReadHd ;align 4
;
mov edi,[0x3010] ;syscall_starthdapp: ; StartHdApp
add edi,0x10 ;
add esi,[edi] ; mov edi,[0x3010]
add eax,[edi] ; add edi,0x10
call read_hd_file ; add eax,[edi]
mov [esp+36],eax ; add ecx,[edi]
mov [esp+24],ebx ; xor ebp,ebp
ret ; xor edx,edx ; compatibility - flags=0
; call start_application_hd
align 4 ; mov [esp+36],eax
; ret
syscall_starthdapp: ; StartHdApp
mov edi,[0x3010]
add edi,0x10
add eax,[edi]
add ecx,[edi]
xor ebp,ebp
xor edx,edx ; compatibility - flags=0
call start_application_hd
mov [esp+36],eax
ret
align 4 align 4
@ -4769,12 +4771,16 @@ syscall_drawline: ; DrawLine
align 4 align 4
syscall_getirqowner: ; GetIrqOwner syscall_getirqowner: ; GetIrqOwner
cmp eax,16
jae .err
shl eax,2 shl eax,2
add eax,irq_owner add eax,irq_owner
mov eax,[eax] mov eax,[eax]
mov [esp+36],eax mov [esp+36],eax
ret ret
.err:
or dword [esp+36], -1
ret
align 4 align 4
@ -4860,17 +4866,18 @@ write_to_hd: ; Write a file to hd
call file_write call file_write
ret ret
align 4 ; <diamond> Sysfunction 57, delete_from_hd, is obsolete. Use 58 or 70 functions instead.
;align 4
delete_from_hd: ; Delete a file from hd ;
;delete_from_hd: ; Delete a file from hd
mov edi,[0x3010] ;
add edi,0x10 ; mov edi,[0x3010]
add eax,[edi] ; add edi,0x10
add ecx,[edi] ; add eax,[edi]
call file_delete ; add ecx,[edi]
ret ; call file_delete
; ret
;
align 4 align 4

View File

@ -131,8 +131,6 @@ vesa20_putimage:
ja @f ja @f
add esp, putimg.stack_data add esp, putimg.stack_data
popad popad
xor eax, eax
inc eax
ret ret
@@: @@:
cmp ebx, [putimg.image_sx] cmp ebx, [putimg.image_sx]
@ -149,8 +147,6 @@ vesa20_putimage:
ja @f ja @f
add esp, putimg.stack_data add esp, putimg.stack_data
popad popad
xor eax, eax
inc eax
ret ret
@@: @@:
cmp ebx, [putimg.image_sy] cmp ebx, [putimg.image_sy]
@ -248,7 +244,6 @@ vesa20_putimage:
.finish: .finish:
add esp, putimg.stack_data add esp, putimg.stack_data
popad popad
xor eax, eax
;sti ; !!!!!!!!!!!!!!!!!!!!! ;sti ; !!!!!!!!!!!!!!!!!!!!!
ret ret
@ -286,7 +281,6 @@ put_image_end_32:
.finish: .finish:
add esp, putimg.stack_data add esp, putimg.stack_data
popad popad
xor eax, eax
ret ret