Function 70.1 now supports ANSI+UNICODE. Flag CF in function 49 corrected.

git-svn-id: svn://kolibrios.org@78 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Evgeny Grechnikov (Diamond) 2006-05-12 12:47:52 +00:00
parent 0b65f18e93
commit 60290f1452
6 changed files with 141 additions and 87 deletions

View File

@ -30,14 +30,11 @@ calculatefatchain:
shl eax,4
and eax,0x0fffffff ;2 ok
shr ax,4 ;1 ok
mov dword [edi],eax
add edi,4
mov dword [edi],ebx
add edi,4
mov dword [edi],ecx
add edi,4
mov dword [edi],edx
add edi,4
mov dword [edi],eax
mov dword [edi+4],ebx
mov dword [edi+8],ecx
mov dword [edi+12],edx
add edi,16
add esi,12
cmp edi,0x280000+2856*2 ;2849 clusters
@ -63,10 +60,9 @@ restorefatchain: ; restore fat chain
shr ebx,4
shrd eax,ebx,8
shr ebx,8
mov dword [edi],eax
add edi,4
mov word [edi],bx
add edi,2
mov dword [edi],eax
mov word [edi+4],bx
add edi,6
add esi,8
cmp edi,0x100000+512+4278 ;4274 bytes - all used FAT
@ -100,8 +96,8 @@ ramdisk_free_space:
repne scasw
jnz rdfs2 ;if last cluster not 0
inc ebx
jcxz rdfs2 ;if last cluster=0
jmp rdfs1 ;if not last
test ecx, ecx
jnz rdfs1
rdfs2:
shl ebx,9 ;free clusters*512
mov edi,ebx
@ -438,15 +434,11 @@ mov [edi+22],ax ; time
jbe flnsa
sub eax,512
mov [esp+12],eax
mov eax,[esp+16]
add eax,512
mov [esp+16],eax
add dword [esp+16], 512
jmp frnewds
flnsa:
dec edi
dec edi
mov [edi],word 4095 ; mark end of file - last cluster
mov [edi-2],word 4095 ; mark end of file - last cluster
frnoreadds:
@ -644,7 +636,7 @@ fat_get_name:
push ecx
mov ecx, 8
push edi ebp ecx
cmp byte [ebp-4], 0
test byte [ebp-4], 1
jnz .unicode_short
@@:
mov al, [edi]
@ -763,7 +755,7 @@ fat_get_name:
ret
@@:
; if this is first entry:
cmp byte [ebp-4], 0
test byte [ebp-4], 1
jnz .ret
; buffer at ebp contains UNICODE name, convert it to ANSI
push esi edi
@ -872,50 +864,57 @@ fat_entry_to_bdfe:
push ecx edi
lea edi, [esi+40]
mov esi, ebp
mov ecx, 259/2
test byte [esi-4], 1
jz .ansi
mov ecx, 260/2
rep movsd
movsw
stosw
mov [edi-2], ax
@@:
mov esi, edi
pop edi ecx
ret
.ansi:
mov ecx, 264/4
rep movsd
mov [edi-1], al
jmp @b
rd_find_lfn:
; in: esi->name
; out: CF=1 - file not found
; else CF=0 and edi->direntry
push esi ebp edi
sub esp, 262*2 ; allocate space for LFN
mov ebp, esp ; ebp points to buffer
push 0 ; for fat_get_name: read ASCII name
mov edi, 0x100000+512*19 ; to root dir
push esi ebp edi
sub esp, 262*2 ; allocate space for LFN
mov ebp, esp ; ebp points to buffer
push 0 ; for fat_get_name: read ASCII name
mov edi, 0x100000+512*19 ; to root dir
.l1:
call fat_get_name
jc .l2
call fat_compare_name
jz .found
call fat_get_name
jc .l2
call fat_compare_name
jz .found
.l2:
add edi, 0x20
cmp edi, 0x100000+512*33
jb .l1
add edi, 0x20
cmp edi, 0x100000+512*33
jb .l1
.notfound:
add esp, 262*2+4
pop edi ebp esi
stc
ret
add esp, 262*2+4
pop edi ebp esi
stc
ret
.found:
; found
; if this is LFN entry, advance to true entry
cmp byte [edi+11], 0xF
jnz @f
add edi, 0x20
cmp byte [edi+11], 0xF
jnz @f
add edi, 0x20
@@:
; folders are not supported
cmp byte [esi], 0
jnz .notfound
add esp, 262*2+4+4 ; CF=0
pop ebp esi
ret
cmp byte [esi], 0
jnz .notfound
add esp, 262*2+4+4 ; CF=0
pop ebp esi
ret
;----------------------------------------------------------------
;
@ -1013,7 +1012,9 @@ fs_RamdiskRead:
; 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
; ebx pointer to structure 32-bit number = first wanted block
; & flags (bitfields)
; flags: bit 0: 0=ANSI names, 1=UNICODE names
; ecx number of blocks to read, 0+
; edx mem location to return data
;
@ -1022,7 +1023,6 @@ fs_RamdiskRead:
;
;--------------------------------------------------------------
fs_RamdiskReadFolder:
mov ebx, [ebx]
cmp byte [esi], 0
jz @f
; ramdisk doesn't support folders
@ -1042,7 +1042,8 @@ fs_RamdiskReadFolder:
push ebp
sub esp, 262*2 ; allocate space for LFN
mov ebp, esp
push 1 ; for fat_get_name: read UNICODE name
push dword [ebx+4] ; for fat_get_name: read ANSI/UNICODE name
mov ebx, [ebx]
; read root
mov esi, edi ; esi points to block of data of folder entry (BDFE)
mov edi, 0x100000+512*19
@ -1075,4 +1076,4 @@ fs_RamdiskReadFolder:
pop ecx edi esi
ret
; \end{diamond}
; \end{diamond}

View File

@ -2235,6 +2235,27 @@ dword-
* <20>®«ì§®¢ â¥«ì ¬®¦¥â ¨§¬¥­ïâì ᪨­ áâ â¨ç¥áª¨, ᮧ¤ ¢ ᢮©
default.skn, ¨«¨ ¤¨­ ¬¨ç¥áª¨ á ¯®¬®éìî ¯à¨«®¦¥­¨ï desktop.
======================================================================
============ ”ã­ªæ¨ï 49 - Advanced Power Management (APM). ===========
======================================================================
<EFBFBD> à ¬¥âàë:
* eax = 49 - ­®¬¥à ä㭪樨
* dx = ­®¬¥à ä㭪樨 APM ( ­ «®£ ax ¢ ᯥæ¨ä¨ª æ¨¨)
* bx, cx = ¯ à ¬¥âàë ä㭪樨 APM
‚®§¢à é ¥¬®¥ §­ ç¥­¨¥:
* 16-¡¨â­ë¥ ॣ¨áâàë ax, bx, cx, dx, si, di ¨ ä« £ CF
ãáâ ­®¢«¥­ë ¢ ᮮ⢥âá⢨¨ ᮠᯥæ¨ä¨ª æ¨¥© APM
* áâ à訥 ¯®«®¢¨­ë 32-¡¨â­ëå ॣ¨áâ஢ eax, ebx, ecx,
edx, esi, edi à §àãè îâáï
‡ ¬¥ç ­¨ï:
* ‘¯¥æ¨ä¨ª æ¨ï APM 1.2 ®¯¨á뢠¥âáï ¢ ¤®ªã¬¥­â¥
"Advanced Power Management (APM) BIOS Specification"
(Revision 1.2), ¤®áâ㯭®¬ ­ 
http://www.microsoft.com/whdc/archive/amp_12.mspx;
ªà®¬¥ ⮣®, ®­  ¢ª«î祭  ¢ ¨§¢¥áâ­ë© Interrupt List by Ralf Brown
(http://www.pobox.com/~ralf/files.html,
ftp://ftp.cs.cmu.edu/afs/cs/user/ralf/pub/).
======================================================================
================= ”ã­ªæ¨ï 50 - ãáâ ­®¢ª  ä®à¬ë ®ª­ . =================
======================================================================
@ -4077,7 +4098,11 @@ Architecture Software Developer's Manual, Volume 3, Appendix B);
”®à¬ â ¨­ä®à¬ æ¨®­­®© áâàãªâãàë:
* +0: dword: 1 = ­®¬¥à ¯®¤ä㭪樨
* +4: dword: ¨­¤¥ªá ­ ç «ì­®£® ¡«®ª  (áç¨â ï á 0)
* +8: dword: 0 (§ à¥§¥à¢¨à®¢ ­®)
* +8: dword: ¯®«¥ ä« £®¢:
* ¡¨â 0 (¬ áª  1): ¢ ª ª®¬ ä®à¬ â¥ ¢®§¢à é âì ¨¬¥­ ,
0=ANSI, 1=UNICODE
* ¯à®ç¨¥ ¡¨âë § à¥§¥à¢¨à®¢ ­ë ¨ ¤®«¦­ë ¡ëâì ãáâ ­®¢«¥­ë ¢ 0
¤«ï ¡ã¤ã饩 ᮢ¬¥á⨬®áâ¨
* +12 = +0xC: dword: ᪮«ìª® ¡«®ª®¢ ç¨â âì
* +16 = +0x10: dword: 㪠§ â¥«ì ­  ¡ãä¥à, ªã¤  ¡ã¤ãâ § ¯¨á ­ë
¤ ­­ë¥, à §¬¥à ¡ãä¥à  ¤®«¦¥­ ¡ëâì ­¥ ¬¥­ìè¥ 32 + [+12]*560 ¡ ©â
@ -4114,7 +4139,8 @@ Architecture Software Developer's Manual, Volume 3, Appendix B);
íâ® ¬®¦¥â ¡ëâì ¯®«¥§­® ¤«ï  ¢â®¬ â¨ç¥áª®£® ᮧ¤ ­¨ï
backup- à娢®¢, ¨¡® ¯à¨ § ¯¨á¨ ¡¨â ®¡ëç­® ãáâ ­ ¢«¨¢ ¥âáï
(­¥ ¢ Kolibri, ¯à ¢¤ )
* +4: byte: ⨯ ¤ ­­ëå ¨¬¥­¨: (¤«ï ⥪ã饩 ॠ«¨§ æ¨¨ ¢á¥£¤  1)
* +4: byte: ⨯ ¤ ­­ëå ¨¬¥­¨:
(ᮢ¯ ¤ ¥â á ¡¨â®¬ 0 ä« £®¢ ¨­ä®à¬ æ¨®­­®© áâàãªâãàë)
* 0 = ASCII = 1-¡ ©â­®¥ ¯à¥¤áâ ¢«¥­¨¥ ª ¦¤®£® ᨬ¢®« 
* 1 = UNICODE = 2-¡ ©â­®¥ ¯à¥¤áâ ¢«¥­¨¥ ª ¦¤®£® ᨬ¢®« 
* +5: 3*byte: § à¥§¥à¢¨à®¢ ­® (­ã«¨)
@ -4142,11 +4168,12 @@ Architecture Software Developer's Manual, Volume 3, Appendix B);
* +2: word: £®¤
* ­ ¯à¨¬¥à, 25.11.1979 § ¯¨á뢠¥âáï ª ª (¢ hex) 19 0B BB 07
‡ ¬¥ç ­¨ï:
* ’¥ªãé ï ॠ«¨§ æ¨ï ¢®§¢à é ¥â ¨¬¥­  ⮫쪮 ¢ ä®à¬ â¥ UNICODE.
* …᫨ ¢ <20>Š ¯à¨áãâáâ¢ã¥â ¨¬ï ¢ ASCII, â® ¤«¨­  <20>Š á®áâ ¢«ï¥â
304 ¡ ©â , ¥á«¨ ¢ UNICODE - 560 ¡ ©â. ‡­ ç¥­¨¥ ¤«¨­ë ¢ëà ¢­¥­®
­  楫®¥ ªà â­®¥ 16 ¡ ©â
(¤«ï ã᪮७¨ï ®¡à ¡®âª¨ ¢ ªíè-¯ ¬ï⨠CPU).
* <20>¥à¢ë© ᨬ¢®« ¯®á«¥ ¨¬¥­¨ ­ã«¥¢®© (ASCIIZ-áâப ). „ «ì­¥©è¨¥
¤ ­­ë¥ ᮤ¥à¦ â ¬ãá®à.
* …᫨ ä ©«ë ¢ ¯ ¯ª¥ ª®­ç¨«¨áì à ­ìè¥, 祬 ¡ë«® ¯à®ç¨â ­®
§ ¯à®è¥­­®¥ ª®«¨ç¥á⢮, â® äã­ªæ¨ï ¯à®ç¨â ¥â, ᪮«ìª® ᬮ¦¥â,
¯®á«¥ 祣® ¢¥à­ñâ eax=6 (EOF).

View File

@ -55,7 +55,6 @@ floppy_free_space:
rdfs1_1:
mov ebx,[eax]
and ebx,4095
cmp ebx,0
jne rdfs2_1
add edi,512
rdfs2_1:
@ -1268,7 +1267,9 @@ fs_FloppyRead:
; fs_FloppyReadFolder - LFN variant for reading floppy folders
;
; esi points to filename
; ebx pointer to 32-bit number = first wanted block, 0+
; ebx pointer to structure: 32-bit number = first wanted block, 0+
; & flags (bitfields)
; flags: bit 0: 0=ANSI names, 1=UNICODE names
; ecx number of blocks to read, 0+
; edx mem location to return data
;
@ -1278,7 +1279,6 @@ fs_FloppyRead:
;--------------------------------------------------------------
fs_FloppyReadFolder:
call read_flp_fat
mov ebx, [ebx]
push edi
cmp byte [esi], 0
jz .root
@ -1307,7 +1307,8 @@ fs_FloppyReadFolder:
push ecx ebp
sub esp, 262*2 ; reserve space for LFN
mov ebp, esp
push 1 ; for fat_get_name: read UNICODE names
push dword [ebx+4] ; for fat_get_name: read ANSI/UNICODE names
mov ebx, [ebx]
; init header
push eax ecx
mov edi, edx
@ -1397,4 +1398,4 @@ fs_FloppyReadFolder:
pop ecx edi edi
ret
; \end{diamond}
; \end{diamond}

View File

@ -3202,7 +3202,9 @@ fs_HdRead:
; fs_HdReadFolder - LFN variant for reading hard disk folder
;
; esi points to filename
; ebx pointer to 32-bit number = first wanted block, 0+
; ebx pointer to structure 32-bit number = first wanted block, 0+
; & flags (bitfields)
; flags: bit 0: 0=ANSI names, 1=UNICODE names
; ecx number of blocks to read, 0+
; edx mem location to return data
;
@ -3211,7 +3213,6 @@ fs_HdRead:
;
;--------------------------------------------------------------
fs_HdReadFolder:
mov ebx, [ebx]
mov eax, [ROOT_CLUSTER]
push edi
cmp byte [esi], 0
@ -3237,7 +3238,8 @@ fs_HdReadFolder:
push ebp
sub esp, 262*2 ; reserve space for LFN
mov ebp, esp
push 1 ; for fat_get_name: read UNICODE name
push dword [ebx+4] ; for fat_get_name: read ANSI/UNICODE name
mov ebx, [ebx]
; init header
push eax ecx
mov edi, edx

View File

@ -32,17 +32,17 @@ rootdirs:
virtual_root_query:
dd fs_HasRamdisk
du 'rd',0
db 'rd',0
dd fs_HasFloppy
du 'fd',0
db 'fd',0
dd fs_HasHd0
du 'hd0',0
db 'hd0',0
dd fs_HasHd1
du 'hd1',0
db 'hd1',0
dd fs_HasHd2
du 'hd2',0
db 'hd2',0
dd fs_HasHd3
du 'hd3',0
db 'hd3',0
dd 0
endg
@ -104,9 +104,10 @@ file_system_lfn:
mov ebp, [ebx+12]
mov edx, [ebx+16]
add edx, std_application_base_address
mov ebx, [ebx+4]
push dword [ebx+4] ; first block
mov ebx, [ebx+8] ; flags
mov esi, [edi+4]
; ebx=first block, ebp=number of blocks, edx=return area, esi='Next' handler
; ebx=flags, [esp]=first block, ebp=number of blocks, edx=return area, esi='Next' handler
mov edi, edx
mov ecx, 32/4
rep stosd
@ -115,7 +116,7 @@ file_system_lfn:
call esi
jc .maindir_done
inc dword [edx+8]
dec ebx
dec dword [esp]
jns .maindir_loop
dec ebp
js .maindir_loop
@ -142,15 +143,27 @@ file_system_lfn:
@@:
pop eax
add al, '0'
stosw
stosb
test bl, 1 ; UNICODE name?
jz .ansi2
mov byte [edi], 0
inc edi
.ansi2:
test al, al
jnz @b
mov byte [edi-1], 0
pop edi
; UNICODE name length is 520 bytes, ANSI - 264
add edi, 520
test bl, 1
jnz @f
sub edi, 520-264
@@:
pop edx eax
jmp .maindir_loop
.maindir_done:
mov ebx, [edx+8]
pop eax
mov ebx, [edx+4]
xor eax, eax
dec ebp
js @f
@ -173,9 +186,10 @@ file_system_lfn:
mov ebp, [ebx+12]
mov edx, [ebx+16]
add edx, std_application_base_address
mov ebx, [ebx+4]
push dword [ebx+4] ; first block
mov ebx, [ebx+8] ; flags
xor eax, eax
; eax=0, ebx=first block, ebp=number of blocks, edx=return area
; eax=0, [esp]=first block, ebx=flags, ebp=number of blocks, edx=return area
mov edi, edx
mov ecx, 32/4
rep stosd
@ -190,13 +204,13 @@ file_system_lfn:
.readroot_next:
or ecx, -1
xchg esi, edi
repnz scasw
repnz scasb
xchg esi, edi
jmp .readroot_loop
@@:
xor eax, eax
inc dword [edx+8]
dec ebx
dec dword [esp]
jns .readroot_next
dec ebp
js .readroot_next
@ -208,15 +222,24 @@ file_system_lfn:
rep stosd
push edi
@@:
lodsw
stosw
lodsb
stosb
test bl, 1
jz .ansi
mov byte [edi], 0
inc edi
.ansi:
test eax, eax
jnz @b
pop edi
add edi, 520
test bl, 1
jnz .readroot_loop
sub edi, 520-264
jmp .readroot_loop
.readroot_done:
mov ebx, [edx+8]
pop eax
mov ebx, [edx+4]
xor eax, eax
dec ebp
js @f

View File

@ -4888,7 +4888,7 @@ align 4
sys_apm:
cmp word [apm_vf], 0 ; Check APM BIOS enable
jne @f
or [esp + 40], byte 1 ; error
or [esp + 56], byte 1 ; error
mov [esp + 36], dword 8 ; 32-bit protected-mode interface not supported
ret
@ -4897,13 +4897,13 @@ sys_apm:
cmp al, 3
ja @f
and [esp + 40], byte 0xfe ; emulate func 0..3 as func 0
and [esp + 56], byte 0xfe ; emulate func 0..3 as func 0
mov eax, [apm_vf]
mov [esp + 36], eax
shr eax, 16
mov [esp + 32], eax
ret
@@: call pword [apm_entry] ; call APM BIOS
mov [esp + 8 ], edi
mov [esp + 12], esi
@ -4912,8 +4912,8 @@ sys_apm:
mov [esp + 32], ecx
mov [esp + 36], eax
setc al
and [esp + 40], byte 0xfe
or [esp + 40], al
and [esp + 56], byte 0xfe
or [esp + 56], al
ret
; -----------------------------------------