Synced net branch with trunk

git-svn-id: svn://kolibrios.org@2382 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
hidnplayr
2012-02-22 16:06:05 +00:00
parent 58fe32f210
commit e6242dd229
80 changed files with 29882 additions and 24945 deletions

View File

@@ -31,19 +31,19 @@ ReadCDWRetr:
; ebx = destination ; ebx = destination
;----------------------------------------------------------- ;-----------------------------------------------------------
pushad pushad
mov eax,[CDSectorAddress] mov eax, [CDSectorAddress]
mov ebx,[CDDataBuf_pointer] mov ebx, [CDDataBuf_pointer]
call cd_calculate_cache call cd_calculate_cache
xor edi,edi xor edi, edi
add esi,8 add esi, 8
inc edi inc edi
.hdreadcache: .hdreadcache:
; cmp dword [esi+4],0 ; empty ; cmp dword [esi+4],0 ; empty
; je .nohdcache ; je .nohdcache
cmp [esi],eax ; correct sector cmp [esi], eax ; correct sector
je .yeshdcache je .yeshdcache
.nohdcache: .nohdcache:
add esi,8 add esi, 8
inc edi inc edi
dec ecx dec ecx
jnz .hdreadcache jnz .hdreadcache
@@ -52,30 +52,30 @@ ReadCDWRetr:
push edi push edi
push eax push eax
call cd_calculate_cache_2 call cd_calculate_cache_2
shl edi,11 shl edi, 11
add edi,eax add edi, eax
mov [CDDataBuf_pointer],edi mov [CDDataBuf_pointer], edi
pop eax pop eax
pop edi pop edi
call ReadCDWRetr_1 call ReadCDWRetr_1
cmp [DevErrorCode],0 cmp [DevErrorCode], 0
jne .exit jne .exit
mov [CDDataBuf_pointer],ebx mov [CDDataBuf_pointer], ebx
call cd_calculate_cache_1 call cd_calculate_cache_1
lea esi,[edi*8+esi] lea esi, [edi*8+esi]
mov [esi],eax ; sector number mov [esi], eax ; sector number
; mov dword [esi+4],1 ; hd read - mark as same as in hd ; mov dword [esi+4],1 ; hd read - mark as same as in hd
.yeshdcache: .yeshdcache:
mov esi,edi mov esi, edi
shl esi,11 ;9 shl esi, 11;9
push eax push eax
call cd_calculate_cache_2 call cd_calculate_cache_2
add esi,eax add esi, eax
pop eax pop eax
mov edi,ebx ;[CDDataBuf_pointer] mov edi, ebx;[CDDataBuf_pointer]
mov ecx,512 ;/4 mov ecx, 512;/4
cld cld
rep movsd ; move data rep movsd ; move data
.exit: .exit:
@@ -87,7 +87,7 @@ ReadCDWRetr_1:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov ECX,MaxRetr mov ECX, MaxRetr
@@NextRetr: @@NextRetr:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
;************************************************* ;*************************************************
@@ -111,18 +111,18 @@ ReadCDWRetr_1:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Read CD ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Read CD
mov [PacketCommand],byte 0x28 ;0xBE mov [PacketCommand], byte 0x28;0xBE
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov AX,word [CDSectorAddress+2] mov AX, word [CDSectorAddress+2]
xchg AL,AH xchg AL, AH
mov word [PacketCommand+2],AX mov word [PacketCommand+2], AX
mov AX,word [CDSectorAddress] mov AX, word [CDSectorAddress]
xchg AL,AH xchg AL, AH
mov word [PacketCommand+4],AX mov word [PacketCommand+4], AX
; mov eax,[CDSectorAddress] ; mov eax,[CDSectorAddress]
; mov [PacketCommand+2],eax ; mov [PacketCommand+2],eax
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [PacketCommand+8],byte 1 mov [PacketCommand+8], byte 1
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; mov [PacketCommand+9],byte 0xF8 ; mov [PacketCommand+9],byte 0xF8
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@ -131,16 +131,16 @@ ReadCDWRetr_1:
; ret ; ret
; cmp [DevErrorCode],0 ; cmp [DevErrorCode],0
test eax,eax test eax, eax
jz @@End_4 jz @@End_4
or ecx,ecx ;{SPraid.simba} (for cd load) or ecx, ecx ;{SPraid.simba} (for cd load)
jz @@End_4 jz @@End_4
dec ecx dec ecx
cmp [timer_ticks_enable],0 cmp [timer_ticks_enable], 0
jne @f jne @f
mov eax,NoTickWaitTime mov eax, NoTickWaitTime
.wait: .wait:
dec eax dec eax
; test eax,eax ; test eax,eax
@@ -156,7 +156,7 @@ ReadCDWRetr_1:
; ja @@Wait ; ja @@Wait
loop @@NextRetr loop @@NextRetr
@@End_4: @@End_4:
mov dword [DevErrorCode],eax mov dword [DevErrorCode], eax
popad popad
ret ret
@@ -170,13 +170,15 @@ ReadCDWRetr_1:
MaxCDWaitTime equ 1000 ;200 ;10 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> MaxCDWaitTime equ 1000 ;200 ;10 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
uglobal uglobal
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
PacketCommand: rb 12 ;DB 12 DUP (?) PacketCommand:
rb 12 ;DB 12 DUP (?)
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
;CDDataBuf DB 4096 DUP (0) ;CDDataBuf DB 4096 DUP (0)
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
;CDBlockSize DW ? ;CDBlockSize DW ?
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CDSectorAddress: DD ? CDSectorAddress:
DD ?
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TickCounter_1 DD 0 TickCounter_1 DD 0
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@ -197,31 +199,31 @@ endg
; return eax DevErrorCode ; return eax DevErrorCode
;**************************************************** ;****************************************************
SendPacketDatCommand: SendPacketDatCommand:
xor eax,eax xor eax, eax
; mov byte [DevErrorCode],al ; mov byte [DevErrorCode],al
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CHS ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CHS
mov byte [ATAAddressMode],al mov byte [ATAAddressMode], al
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ATA-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ATA-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov byte [ATAFeatures],al mov byte [ATAFeatures], al
mov byte [ATASectorCount],al mov byte [ATASectorCount], al
mov byte [ATASectorNumber],al mov byte [ATASectorNumber], al
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [ATAHead],al mov [ATAHead], al
; mov AX,[CDBlockSize] ; mov AX,[CDBlockSize]
mov [ATACylinder],CDBlockSize mov [ATACylinder], CDBlockSize
mov [ATACommand],0A0h mov [ATACommand], 0A0h
call SendCommandToHDD_1 call SendCommandToHDD_1
test eax,eax test eax, eax
; cmp [DevErrorCode],0 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; cmp [DevErrorCode],0 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
jnz @@End_8 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> jnz @@End_8 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov DX,[ATABasePortAddr] mov DX, [ATABasePortAddr]
add DX,7 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1<EFBFBD>7h add DX, 7 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1<EFBFBD>7h
mov ecx,NoTickWaitTime mov ecx, NoTickWaitTime
@@WaitDevice0: @@WaitDevice0:
cmp [timer_ticks_enable],0 cmp [timer_ticks_enable], 0
jne @f jne @f
dec ecx dec ecx
; test ecx,ecx ; test ecx,ecx
@@ -230,41 +232,41 @@ SendPacketDatCommand:
@@: @@:
call change_task call change_task
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov EAX,[timer_ticks] mov EAX, [timer_ticks]
sub EAX,[TickCounter_1] sub EAX, [TickCounter_1]
cmp EAX,BSYWaitTime cmp EAX, BSYWaitTime
ja @@Err1_1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ja @@Err1_1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
.test: .test:
in AL,DX in AL, DX
test AL,80h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BSY test AL, 80h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BSY
jnz @@WaitDevice0 jnz @@WaitDevice0
test AL,1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ERR test AL, 1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ERR
jnz @@Err6 jnz @@Err6
test AL,08h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DRQ test AL, 08h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DRQ
jz @@WaitDevice0 jz @@WaitDevice0
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cli cli
mov DX,[ATABasePortAddr] mov DX, [ATABasePortAddr]
mov AX,[PacketCommand] mov AX, [PacketCommand]
out DX,AX out DX, AX
mov AX,[PacketCommand+2] mov AX, [PacketCommand+2]
out DX,AX out DX, AX
mov AX,[PacketCommand+4] mov AX, [PacketCommand+4]
out DX,AX out DX, AX
mov AX,[PacketCommand+6] mov AX, [PacketCommand+6]
out DX,AX out DX, AX
mov AX,[PacketCommand+8] mov AX, [PacketCommand+8]
out DX,AX out DX, AX
mov AX,[PacketCommand+10] mov AX, [PacketCommand+10]
out DX,AX out DX, AX
sti sti
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov DX,[ATABasePortAddr] mov DX, [ATABasePortAddr]
add DX,7 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1<EFBFBD>7h add DX, 7 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1<EFBFBD>7h
mov ecx,NoTickWaitTime mov ecx, NoTickWaitTime
@@WaitDevice1: @@WaitDevice1:
cmp [timer_ticks_enable],0 cmp [timer_ticks_enable], 0
jne @f jne @f
dec ecx dec ecx
; test ecx,ecx ; test ecx,ecx
@@ -273,28 +275,28 @@ SendPacketDatCommand:
@@: @@:
call change_task call change_task
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov EAX,[timer_ticks] mov EAX, [timer_ticks]
sub EAX,[TickCounter_1] sub EAX, [TickCounter_1]
cmp EAX,MaxCDWaitTime cmp EAX, MaxCDWaitTime
ja @@Err1_1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ja @@Err1_1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
.test_1: .test_1:
in AL,DX in AL, DX
test AL,80h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BSY test AL, 80h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BSY
jnz @@WaitDevice1 jnz @@WaitDevice1
test AL,1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ERR test AL, 1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ERR
jnz @@Err6_temp jnz @@Err6_temp
test AL,08h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DRQ test AL, 08h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DRQ
jz @@WaitDevice1 jz @@WaitDevice1
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov EDI,[CDDataBuf_pointer] ;0x7000 ;CDDataBuf mov EDI, [CDDataBuf_pointer];0x7000 ;CDDataBuf
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov DX,[ATABasePortAddr] ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1x0h mov DX, [ATABasePortAddr];<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1x0h
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
xor ecx,ecx xor ecx, ecx
mov CX,CDBlockSize mov CX, CDBlockSize
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> 16-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> 16-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
shr CX,1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> 2 shr CX, 1;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> 2
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cli cli
cld cld
@@ -302,23 +304,23 @@ SendPacketDatCommand:
sti sti
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@End_8: @@End_8:
xor eax,eax xor eax, eax
ret ret
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@Err1_1: @@Err1_1:
xor eax,eax xor eax, eax
inc eax inc eax
ret ret
; mov [DevErrorCode],1 ; mov [DevErrorCode],1
; ret ; ret
@@Err6_temp: @@Err6_temp:
mov eax,7 mov eax, 7
ret ret
; mov [DevErrorCode],7 ; mov [DevErrorCode],7
; ret ; ret
@@Err6: @@Err6:
mov eax,6 mov eax, 6
ret ret
; mov [DevErrorCode],6 ; mov [DevErrorCode],6
;@@End_8: ;@@End_8:
@@ -337,89 +339,89 @@ SendPacketDatCommand:
;*********************************************** ;***********************************************
SendPacketNoDatCommand: SendPacketNoDatCommand:
pushad pushad
xor eax,eax xor eax, eax
; mov byte [DevErrorCode],al ; mov byte [DevErrorCode],al
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CHS ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CHS
mov byte [ATAAddressMode],al mov byte [ATAAddressMode], al
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ATA-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ATA-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov byte [ATAFeatures],al mov byte [ATAFeatures], al
mov byte [ATASectorCount],al mov byte [ATASectorCount], al
mov byte [ATASectorNumber],al mov byte [ATASectorNumber], al
mov word [ATACylinder],ax mov word [ATACylinder], ax
mov byte [ATAHead],al mov byte [ATAHead], al
mov [ATACommand],0A0h mov [ATACommand], 0A0h
call SendCommandToHDD_1 call SendCommandToHDD_1
; cmp [DevErrorCode],0 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; cmp [DevErrorCode],0 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
test eax,eax test eax, eax
jnz @@End_9 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> jnz @@End_9 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov DX,[ATABasePortAddr] mov DX, [ATABasePortAddr]
add DX,7 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1<EFBFBD>7h add DX, 7 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1<EFBFBD>7h
@@WaitDevice0_1: @@WaitDevice0_1:
call change_task call change_task
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov EAX,[timer_ticks] mov EAX, [timer_ticks]
sub EAX,[TickCounter_1] sub EAX, [TickCounter_1]
cmp EAX,BSYWaitTime cmp EAX, BSYWaitTime
ja @@Err1_3 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ja @@Err1_3 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
in AL,DX in AL, DX
test AL,80h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BSY test AL, 80h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BSY
jnz @@WaitDevice0_1 jnz @@WaitDevice0_1
test AL,1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ERR test AL, 1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ERR
jnz @@Err6_1 jnz @@Err6_1
test AL,08h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DRQ test AL, 08h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DRQ
jz @@WaitDevice0_1 jz @@WaitDevice0_1
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; cli ; cli
mov DX,[ATABasePortAddr] mov DX, [ATABasePortAddr]
mov AX,word [PacketCommand] mov AX, word [PacketCommand]
out DX,AX out DX, AX
mov AX,word [PacketCommand+2] mov AX, word [PacketCommand+2]
out DX,AX out DX, AX
mov AX,word [PacketCommand+4] mov AX, word [PacketCommand+4]
out DX,AX out DX, AX
mov AX,word [PacketCommand+6] mov AX, word [PacketCommand+6]
out DX,AX out DX, AX
mov AX,word [PacketCommand+8] mov AX, word [PacketCommand+8]
out DX,AX out DX, AX
mov AX,word [PacketCommand+10] mov AX, word [PacketCommand+10]
out DX,AX out DX, AX
; sti ; sti
cmp [ignore_CD_eject_wait],1 cmp [ignore_CD_eject_wait], 1
je @@clear_DEC je @@clear_DEC
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov DX,[ATABasePortAddr] mov DX, [ATABasePortAddr]
add DX,7 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1<EFBFBD>7h add DX, 7 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1<EFBFBD>7h
@@WaitDevice1_1: @@WaitDevice1_1:
call change_task call change_task
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov EAX,[timer_ticks] mov EAX, [timer_ticks]
sub EAX,[TickCounter_1] sub EAX, [TickCounter_1]
cmp EAX,MaxCDWaitTime cmp EAX, MaxCDWaitTime
ja @@Err1_3 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ja @@Err1_3 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
in AL,DX in AL, DX
test AL,80h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BSY test AL, 80h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BSY
jnz @@WaitDevice1_1 jnz @@WaitDevice1_1
test AL,1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ERR test AL, 1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ERR
jnz @@Err6_1 jnz @@Err6_1
test AL,40h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DRDY test AL, 40h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DRDY
jz @@WaitDevice1_1 jz @@WaitDevice1_1
@@clear_DEC: @@clear_DEC:
and [DevErrorCode],0 and [DevErrorCode], 0
popad popad
ret ret
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@Err1_3: @@Err1_3:
xor eax,eax xor eax, eax
inc eax inc eax
jmp @@End_9 jmp @@End_9
@@Err6_1: @@Err6_1:
mov eax,6 mov eax, 6
@@End_9: @@End_9:
mov [DevErrorCode],eax mov [DevErrorCode], eax
popad popad
ret ret
@@ -446,37 +448,37 @@ SendCommandToHDD_1:
; pushad ; pushad
; mov [DevErrorCode],0 not need ; mov [DevErrorCode],0 not need
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cmp [ATAAddressMode],1 cmp [ATAAddressMode], 1
ja @@Err2_4 ja @@Err2_4
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov BX,[ChannelNumber] mov BX, [ChannelNumber]
cmp BX,1 cmp BX, 1
jb @@Err3_4 jb @@Err3_4
cmp BX,2 cmp BX, 2
ja @@Err3_4 ja @@Err3_4
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
dec BX dec BX
shl BX,1 shl BX, 1
movzx ebx,bx movzx ebx, bx
mov AX,[ebx+StandardATABases] mov AX, [ebx+StandardATABases]
mov [ATABasePortAddr],AX mov [ATABasePortAddr], AX
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HDD <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HDD <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov DX,[ATABasePortAddr] mov DX, [ATABasePortAddr]
add DX,6 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> add DX, 6 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov AL,[DiskNumber] mov AL, [DiskNumber]
cmp AL,1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> cmp AL, 1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ja @@Err4_4 ja @@Err4_4
shl AL,4 shl AL, 4
or AL,10100000b or AL, 10100000b
out DX,AL out DX, AL
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
inc DX inc DX
mov eax,[timer_ticks] mov eax, [timer_ticks]
mov [TickCounter_1],eax mov [TickCounter_1], eax
mov ecx,NoTickWaitTime mov ecx, NoTickWaitTime
@@WaitHDReady_2: @@WaitHDReady_2:
cmp [timer_ticks_enable],0 cmp [timer_ticks_enable], 0
jne @f jne @f
dec ecx dec ecx
; test ecx,ecx ; test ecx,ecx
@@ -485,79 +487,79 @@ SendCommandToHDD_1:
@@: @@:
call change_task call change_task
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov eax,[timer_ticks] mov eax, [timer_ticks]
sub eax,[TickCounter_1] sub eax, [TickCounter_1]
cmp eax,BSYWaitTime ;300 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 3 <EFBFBD><EFBFBD><EFBFBD>. cmp eax, BSYWaitTime;300 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 3 <EFBFBD><EFBFBD><EFBFBD>.
ja @@Err1_4 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ja @@Err1_4 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
.test: .test:
in AL,DX in AL, DX
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BSY ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BSY
test AL,80h test AL, 80h
jnz @@WaitHDReady_2 jnz @@WaitHDReady_2
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DRQ ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DRQ
test AL,08h test AL, 08h
jnz @@WaitHDReady_2 jnz @@WaitHDReady_2
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cli cli
mov DX,[ATABasePortAddr] mov DX, [ATABasePortAddr]
inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
mov AL,[ATAFeatures] mov AL, [ATAFeatures]
out DX,AL out DX, AL
inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov AL,[ATASectorCount] mov AL, [ATASectorCount]
out DX,AL out DX, AL
inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov AL,[ATASectorNumber] mov AL, [ATASectorNumber]
out DX,AL out DX, AL
inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>) inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
mov AX,[ATACylinder] mov AX, [ATACylinder]
out DX,AL out DX, AL
inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>) inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
mov AL,AH mov AL, AH
out DX,AL out DX, AL
inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov AL,[DiskNumber] mov AL, [DiskNumber]
shl AL,4 shl AL, 4
cmp [ATAHead],0Fh ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> cmp [ATAHead], 0Fh;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ja @@Err5_4 ja @@Err5_4
or AL,[ATAHead] or AL, [ATAHead]
or AL,10100000b or AL, 10100000b
mov AH,[ATAAddressMode] mov AH, [ATAAddressMode]
shl AH,6 shl AH, 6
or AL,AH or AL, AH
out DX,AL out DX, AL
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov AL,[ATACommand] mov AL, [ATACommand]
inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
out DX,AL out DX, AL
sti sti
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; mov [DevErrorCode],0 ; mov [DevErrorCode],0
@@End_10: @@End_10:
xor eax,eax xor eax, eax
ret ret
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@Err1_4: @@Err1_4:
xor eax,eax xor eax, eax
inc eax inc eax
; mov [DevErrorCode],1 ; mov [DevErrorCode],1
ret ret
@@Err2_4: @@Err2_4:
mov eax,2 mov eax, 2
; mov [DevErrorCode],2 ; mov [DevErrorCode],2
ret ret
@@Err3_4: @@Err3_4:
mov eax,3 mov eax, 3
; mov [DevErrorCode],3 ; mov [DevErrorCode],3
ret ret
@@Err4_4: @@Err4_4:
mov eax,4 mov eax, 4
; mov [DevErrorCode],4 ; mov [DevErrorCode],4
ret ret
@@Err5_4: @@Err5_4:
mov eax,5 mov eax, 5
; mov [DevErrorCode],5 ; mov [DevErrorCode],5
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ret ret
@@ -574,20 +576,20 @@ SendCommandToHDD_1:
WaitUnitReady: WaitUnitReady:
pusha pusha
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov EAX,[timer_ticks] mov EAX, [timer_ticks]
mov [WURStartTime],EAX mov [WURStartTime], EAX
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call clear_packet_buffer call clear_packet_buffer
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> TEST UNIT READY ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> TEST UNIT READY
mov [PacketCommand],word 00h mov [PacketCommand], word 00h
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov ecx,NoTickWaitTime mov ecx, NoTickWaitTime
@@SendCommand: @@SendCommand:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call SendPacketNoDatCommand call SendPacketNoDatCommand
cmp [timer_ticks_enable],0 cmp [timer_ticks_enable], 0
jne @f jne @f
cmp [DevErrorCode],0 cmp [DevErrorCode], 0
je @@End_11 je @@End_11
dec ecx dec ecx
; cmp ecx,0 ; cmp ecx,0
@@ -596,16 +598,16 @@ WaitUnitReady:
@@: @@:
call change_task call change_task
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cmp [DevErrorCode],0 cmp [DevErrorCode], 0
je @@End_11 je @@End_11
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov EAX,[timer_ticks] mov EAX, [timer_ticks]
sub EAX,[WURStartTime] sub EAX, [WURStartTime]
cmp EAX,MaxCDWaitTime cmp EAX, MaxCDWaitTime
jb @@SendCommand jb @@SendCommand
.Error: .Error:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [DevErrorCode],1 mov [DevErrorCode], 1
@@End_11: @@End_11:
popa popa
ret ret
@@ -622,15 +624,15 @@ prevent_medium_removal:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call clear_packet_buffer call clear_packet_buffer
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [PacketCommand],byte 0x1E mov [PacketCommand], byte 0x1E
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [PacketCommand+4],byte 11b mov [PacketCommand+4], byte 11b
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call SendPacketNoDatCommand call SendPacketNoDatCommand
mov eax,ATAPI_IDE0_lock mov eax, ATAPI_IDE0_lock
add eax,[cdpos] add eax, [cdpos]
dec eax dec eax
mov [eax],byte 1 mov [eax], byte 1
popa popa
ret ret
@@ -646,15 +648,15 @@ allow_medium_removal:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call clear_packet_buffer call clear_packet_buffer
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [PacketCommand],byte 0x1E mov [PacketCommand], byte 0x1E
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [PacketCommand+4],byte 00b mov [PacketCommand+4], byte 00b
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call SendPacketNoDatCommand call SendPacketNoDatCommand
mov eax,ATAPI_IDE0_lock mov eax, ATAPI_IDE0_lock
add eax,[cdpos] add eax, [cdpos]
dec eax dec eax
mov [eax],byte 0 mov [eax], byte 0
popa popa
ret ret
@@ -671,9 +673,9 @@ LoadMedium:
call clear_packet_buffer call clear_packet_buffer
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> START/STOP UNIT ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> START/STOP UNIT
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [PacketCommand],word 1Bh mov [PacketCommand], word 1Bh
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [PacketCommand+4],word 00000011b mov [PacketCommand+4], word 00000011b
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call SendPacketNoDatCommand call SendPacketNoDatCommand
popa popa
@@ -692,9 +694,9 @@ EjectMedium:
call clear_packet_buffer call clear_packet_buffer
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> START/STOP UNIT ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> START/STOP UNIT
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [PacketCommand],word 1Bh mov [PacketCommand], word 1Bh
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [PacketCommand+4],word 00000010b mov [PacketCommand+4], word 00000010b
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call SendPacketNoDatCommand call SendPacketNoDatCommand
popa popa
@@ -711,53 +713,53 @@ EjectMedium:
align 4 align 4
check_ATAPI_device_event: check_ATAPI_device_event:
pusha pusha
mov eax,[timer_ticks] mov eax, [timer_ticks]
sub eax,[timer_ATAPI_check] sub eax, [timer_ATAPI_check]
cmp eax,100 cmp eax, 100
jb .end_1 jb .end_1
mov al,[DRIVE_DATA+1] mov al, [DRIVE_DATA+1]
and al,11b and al, 11b
cmp al,10b cmp al, 10b
jz .ide3 jz .ide3
.ide2_1: .ide2_1:
mov al,[DRIVE_DATA+1] mov al, [DRIVE_DATA+1]
and al,1100b and al, 1100b
cmp al,1000b cmp al, 1000b
jz .ide2 jz .ide2
.ide1_1: .ide1_1:
mov al,[DRIVE_DATA+1] mov al, [DRIVE_DATA+1]
and al,110000b and al, 110000b
cmp al,100000b cmp al, 100000b
jz .ide1 jz .ide1
.ide0_1: .ide0_1:
mov al,[DRIVE_DATA+1] mov al, [DRIVE_DATA+1]
and al,11000000b and al, 11000000b
cmp al,10000000b cmp al, 10000000b
jz .ide0 jz .ide0
.end: .end:
sti sti
mov eax,[timer_ticks] mov eax, [timer_ticks]
mov [timer_ATAPI_check],eax mov [timer_ATAPI_check], eax
.end_1: .end_1:
popa popa
ret ret
.ide3: .ide3:
cli cli
cmp [ATAPI_IDE3_lock],1 cmp [ATAPI_IDE3_lock], 1
jne .ide2_1 jne .ide2_1
cmp [IDE_Channel_2],0 cmp [IDE_Channel_2], 0
jne .ide1_1 jne .ide1_1
cmp [cd_status],0 cmp [cd_status], 0
jne .end jne .end
mov [IDE_Channel_2],1 mov [IDE_Channel_2], 1
call reserve_ok2 call reserve_ok2
mov [ChannelNumber],2 mov [ChannelNumber], 2
mov [DiskNumber],1 mov [DiskNumber], 1
mov [cdpos],4 mov [cdpos], 4
call GetEvent_StatusNotification call GetEvent_StatusNotification
cmp [CDDataBuf+4],byte 1 cmp [CDDataBuf+4], byte 1
je .eject_ide3 je .eject_ide3
call syscall_cdaudio.free call syscall_cdaudio.free
jmp .ide2_1 jmp .ide2_1
@@ -768,19 +770,19 @@ check_ATAPI_device_event:
.ide2: .ide2:
cli cli
cmp [ATAPI_IDE2_lock],1 cmp [ATAPI_IDE2_lock], 1
jne .ide1_1 jne .ide1_1
cmp [IDE_Channel_2],0 cmp [IDE_Channel_2], 0
jne .ide1_1 jne .ide1_1
cmp [cd_status],0 cmp [cd_status], 0
jne .end jne .end
mov [IDE_Channel_2],1 mov [IDE_Channel_2], 1
call reserve_ok2 call reserve_ok2
mov [ChannelNumber],2 mov [ChannelNumber], 2
mov [DiskNumber],0 mov [DiskNumber], 0
mov [cdpos],3 mov [cdpos], 3
call GetEvent_StatusNotification call GetEvent_StatusNotification
cmp [CDDataBuf+4],byte 1 cmp [CDDataBuf+4], byte 1
je .eject_ide2 je .eject_ide2
call syscall_cdaudio.free call syscall_cdaudio.free
jmp .ide1_1 jmp .ide1_1
@@ -791,19 +793,19 @@ check_ATAPI_device_event:
.ide1: .ide1:
cli cli
cmp [ATAPI_IDE1_lock],1 cmp [ATAPI_IDE1_lock], 1
jne .ide0_1 jne .ide0_1
cmp [IDE_Channel_1],0 cmp [IDE_Channel_1], 0
jne .end jne .end
cmp [cd_status],0 cmp [cd_status], 0
jne .end jne .end
mov [IDE_Channel_1],1 mov [IDE_Channel_1], 1
call reserve_ok2 call reserve_ok2
mov [ChannelNumber],1 mov [ChannelNumber], 1
mov [DiskNumber],1 mov [DiskNumber], 1
mov [cdpos],2 mov [cdpos], 2
call GetEvent_StatusNotification call GetEvent_StatusNotification
cmp [CDDataBuf+4],byte 1 cmp [CDDataBuf+4], byte 1
je .eject_ide1 je .eject_ide1
call syscall_cdaudio.free call syscall_cdaudio.free
jmp .ide0_1 jmp .ide0_1
@@ -814,19 +816,19 @@ check_ATAPI_device_event:
.ide0: .ide0:
cli cli
cmp [ATAPI_IDE0_lock],1 cmp [ATAPI_IDE0_lock], 1
jne .end jne .end
cmp [IDE_Channel_1],0 cmp [IDE_Channel_1], 0
jne .end jne .end
cmp [cd_status],0 cmp [cd_status], 0
jne .end jne .end
mov [IDE_Channel_1],1 mov [IDE_Channel_1], 1
call reserve_ok2 call reserve_ok2
mov [ChannelNumber],1 mov [ChannelNumber], 1
mov [DiskNumber],0 mov [DiskNumber], 0
mov [cdpos],1 mov [cdpos], 1
call GetEvent_StatusNotification call GetEvent_StatusNotification
cmp [CDDataBuf+4],byte 1 cmp [CDDataBuf+4], byte 1
je .eject_ide0 je .eject_ide0
call syscall_cdaudio.free call syscall_cdaudio.free
jmp .end jmp .end
@@ -838,9 +840,9 @@ check_ATAPI_device_event:
.eject: .eject:
call clear_CD_cache call clear_CD_cache
call allow_medium_removal call allow_medium_removal
mov [ignore_CD_eject_wait],1 mov [ignore_CD_eject_wait], 1
call EjectMedium call EjectMedium
mov [ignore_CD_eject_wait],0 mov [ignore_CD_eject_wait], 0
ret ret
iglobal iglobal
timer_ATAPI_check dd 0 timer_ATAPI_check dd 0
@@ -860,17 +862,17 @@ endg
;************************************************* ;*************************************************
GetEvent_StatusNotification: GetEvent_StatusNotification:
pusha pusha
mov [CDDataBuf_pointer],CDDataBuf mov [CDDataBuf_pointer], CDDataBuf
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call clear_packet_buffer call clear_packet_buffer
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [PacketCommand],byte 4Ah mov [PacketCommand], byte 4Ah
mov [PacketCommand+1],byte 00000001b mov [PacketCommand+1], byte 00000001b
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [PacketCommand+4],byte 00010000b mov [PacketCommand+4], byte 00010000b
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [PacketCommand+7],byte 8h mov [PacketCommand+7], byte 8h
mov [PacketCommand+8],byte 0h mov [PacketCommand+8], byte 0h
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call SendPacketDatCommand call SendPacketDatCommand
popa popa
@@ -885,17 +887,17 @@ GetEvent_StatusNotification:
;************************************************* ;*************************************************
Read_TOC: Read_TOC:
pusha pusha
mov [CDDataBuf_pointer],CDDataBuf mov [CDDataBuf_pointer], CDDataBuf
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call clear_packet_buffer call clear_packet_buffer
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [PacketCommand],byte 0x43 mov [PacketCommand], byte 0x43
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [PacketCommand+2],byte 1 mov [PacketCommand+2], byte 1
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [PacketCommand+7],byte 0xFF mov [PacketCommand+7], byte 0xFF
mov [PacketCommand+8],byte 0h mov [PacketCommand+8], byte 0h
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call SendPacketDatCommand call SendPacketDatCommand
popa popa
@@ -923,7 +925,7 @@ Read_TOC:
clear_packet_buffer: clear_packet_buffer:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
and [PacketCommand],dword 0 and [PacketCommand], dword 0
and [PacketCommand+4],dword 0 and [PacketCommand+4], dword 0
and [PacketCommand+8],dword 0 and [PacketCommand+8], dword 0
ret ret

View File

@@ -10,9 +10,9 @@ $Revision$
sys_cd_audio: sys_cd_audio:
cmp word [cdbase],word 0 cmp word [cdbase], word 0
jnz @f jnz @f
mov eax,1 mov eax, 1
ret ret
@@: @@:
@@ -20,28 +20,28 @@ sys_cd_audio:
; eax=2 get tracklist size of ecx to [ebx] ; eax=2 get tracklist size of ecx to [ebx]
; eax=3 stop/pause playing ; eax=3 stop/pause playing
cmp eax,1 cmp eax, 1
jnz nocdp jnz nocdp
call sys_cdplay call sys_cdplay
ret ret
nocdp: nocdp:
cmp eax,2 cmp eax, 2
jnz nocdtl jnz nocdtl
mov edi,[TASK_BASE] mov edi, [TASK_BASE]
add edi,TASKDATA.mem_start add edi, TASKDATA.mem_start
add ebx,[edi] add ebx, [edi]
call sys_cdtracklist call sys_cdtracklist
ret ret
nocdtl: nocdtl:
cmp eax,3 cmp eax, 3
jnz nocdpause jnz nocdpause
call sys_cdpause call sys_cdpause
ret ret
nocdpause: nocdpause:
mov eax,0xffffff01 mov eax, 0xffffff01
ret ret
@@ -50,96 +50,96 @@ sys_cd_atapi_command:
pushad pushad
mov dx,word [cdbase] mov dx, word [cdbase]
add dx,6 add dx, 6
mov ax,word [cdid] mov ax, word [cdid]
out dx,al out dx, al
mov esi,10 mov esi, 10
call delay_ms call delay_ms
mov dx,word [cdbase] mov dx, word [cdbase]
add dx,7 add dx, 7
in al,dx in al, dx
and al,0x80 and al, 0x80
cmp al,0 cmp al, 0
jnz res jnz res
jmp cdl6 jmp cdl6
res: res:
mov dx,word [cdbase] mov dx, word [cdbase]
add dx,7 add dx, 7
mov al,0x8 mov al, 0x8
out dx,al out dx, al
mov dx,word [cdbase] mov dx, word [cdbase]
add dx,0x206 add dx, 0x206
mov al,0xe mov al, 0xe
out dx,al out dx, al
mov esi,1 mov esi, 1
call delay_ms call delay_ms
mov dx,word [cdbase] mov dx, word [cdbase]
add dx,0x206 add dx, 0x206
mov al,0x8 mov al, 0x8
out dx,al out dx, al
mov esi,30 mov esi, 30
call delay_ms call delay_ms
xor cx,cx xor cx, cx
cdl5: cdl5:
inc cx inc cx
cmp cx,10 cmp cx, 10
jz cdl6 jz cdl6
mov dx,word [cdbase] mov dx, word [cdbase]
add dx,7 add dx, 7
in al,dx in al, dx
and al,0x88 and al, 0x88
cmp al,0x00 cmp al, 0x00
jz cdl5 jz cdl5
mov esi,100 mov esi, 100
call delay_ms call delay_ms
jmp cdl5 jmp cdl5
cdl6: cdl6:
mov dx,word [cdbase] mov dx, word [cdbase]
add dx,4 add dx, 4
mov al,0 mov al, 0
out dx,al out dx, al
mov dx,word [cdbase] mov dx, word [cdbase]
add dx,5 add dx, 5
mov al,0 mov al, 0
out dx,al out dx, al
mov dx,word [cdbase] mov dx, word [cdbase]
add dx,7 add dx, 7
mov al,0xec mov al, 0xec
out dx,al out dx, al
mov esi,5 mov esi, 5
call delay_ms call delay_ms
mov dx,word [cdbase] mov dx, word [cdbase]
add dx,1 add dx, 1
mov al,0 mov al, 0
out dx,al out dx, al
add dx,1 add dx, 1
mov al,0 mov al, 0
out dx,al out dx, al
add dx,1 add dx, 1
mov al,0 mov al, 0
out dx,al out dx, al
add dx,1 add dx, 1
mov al,0 mov al, 0
out dx,al out dx, al
add dx,1 add dx, 1
mov al,128 mov al, 128
out dx,al out dx, al
add dx,2 add dx, 2
mov al,0xa0 mov al, 0xa0
out dx,al out dx, al
xor cx,cx xor cx, cx
mov dx,word [cdbase] mov dx, word [cdbase]
add dx,7 add dx, 7
cdl1: cdl1:
inc cx inc cx
cmp cx,100 cmp cx, 100
jz cdl2 jz cdl2
in al,dx in al, dx
and ax,0x88 and ax, 0x88
cmp al,0x8 cmp al, 0x8
jz cdl2 jz cdl2
mov esi,2 mov esi, 2
call delay_ms call delay_ms
jmp cdl1 jmp cdl1
cdl2: cdl2:
@@ -150,37 +150,37 @@ sys_cd_atapi_command:
sys_cdplay: sys_cdplay:
mov ax,5 mov ax, 5
push ax push ax
push ebx push ebx
cdplay: cdplay:
call sys_cd_atapi_command call sys_cd_atapi_command
cli cli
mov dx,word [cdbase] mov dx, word [cdbase]
mov ax,0x0047 mov ax, 0x0047
out dx,ax out dx, ax
mov al,1 mov al, 1
mov ah,[esp+0] ; min xx mov ah, [esp+0]; min xx
out dx,ax out dx, ax
mov ax,[esp+1] ; fr sec mov ax, [esp+1]; fr sec
out dx,ax out dx, ax
mov ax,256+99 mov ax, 256+99
out dx,ax out dx, ax
mov ax,0x0001 mov ax, 0x0001
out dx,ax out dx, ax
mov ax,0x0000 mov ax, 0x0000
out dx,ax out dx, ax
mov esi,10 mov esi, 10
call delay_ms call delay_ms
sti sti
add dx,7 add dx, 7
in al,dx in al, dx
test al,1 test al, 1
jz cdplayok jz cdplayok
mov ax,[esp+4] mov ax, [esp+4]
dec ax dec ax
mov [esp+4],ax mov [esp+4], ax
cmp ax,0 cmp ax, 0
jz cdplayfail jz cdplayfail
jmp cdplay jmp cdplay
cdplayfail: cdplayfail:
@@ -196,46 +196,46 @@ sys_cdtracklist:
push ebx push ebx
tcdplay: tcdplay:
call sys_cd_atapi_command call sys_cd_atapi_command
mov dx,word [cdbase] mov dx, word [cdbase]
mov ax,0x43+2*256 mov ax, 0x43+2*256
out dx,ax out dx, ax
mov ax,0x0 mov ax, 0x0
out dx,ax out dx, ax
mov ax,0x0 mov ax, 0x0
out dx,ax out dx, ax
mov ax,0x0 mov ax, 0x0
out dx,ax out dx, ax
mov ax,200 mov ax, 200
out dx,ax out dx, ax
mov ax,0x0 mov ax, 0x0
out dx,ax out dx, ax
in al,dx in al, dx
mov cx,1000 mov cx, 1000
mov dx,word [cdbase] mov dx, word [cdbase]
add dx,7 add dx, 7
cld cld
cdtrnwewait: cdtrnwewait:
mov esi,10 mov esi, 10
call delay_ms call delay_ms
in al,dx in al, dx
and al,128 and al, 128
cmp al,0 cmp al, 0
jz cdtrl1 jz cdtrl1
loop cdtrnwewait loop cdtrnwewait
cdtrl1: cdtrl1:
; read the result ; read the result
mov ecx,[esp+0] mov ecx, [esp+0]
mov dx,word [cdbase] mov dx, word [cdbase]
cdtrread: cdtrread:
add dx,7 add dx, 7
in al,dx in al, dx
and al,8 and al, 8
cmp al,8 cmp al, 8
jnz cdtrdone jnz cdtrdone
sub dx,7 sub dx, 7
in ax,dx in ax, dx
mov [ecx],ax mov [ecx], ax
add ecx,2 add ecx, 2
jmp cdtrread jmp cdtrread
cdtrdone: cdtrdone:
pop ecx pop ecx
@@ -247,24 +247,24 @@ sys_cdpause:
call sys_cd_atapi_command call sys_cd_atapi_command
mov dx,word [cdbase] mov dx, word [cdbase]
mov ax,0x004B mov ax, 0x004B
out dx,ax out dx, ax
mov ax,0 mov ax, 0
out dx,ax out dx, ax
mov ax,0 mov ax, 0
out dx,ax out dx, ax
mov ax,0 mov ax, 0
out dx,ax out dx, ax
mov ax,0 mov ax, 0
out dx,ax out dx, ax
mov ax,0 mov ax, 0
out dx,ax out dx, ax
mov esi,10 mov esi, 10
call delay_ms call delay_ms
add dx,7 add dx, 7
in al,dx in al, dx
xor eax, eax xor eax, eax
ret ret

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,592 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2011. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 2381 $
; This function is intended to replace the old 'hd_read' function when
; [hdd_appl_data] = 0, so its input/output parameters are the same, except
; that it can't use the global variables 'hd_error' and 'hdd_appl_data'.
; in: eax = sector, ebx = buffer, ebp = pointer to PARTITION structure
; eax is relative to partition start
; out: eax = error code; 0 = ok
fs_read32_sys:
; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure,
; this request should be processed by hd_read.
cmp [ebp+PARTITION.Disk], 'old'
jnz @f
mov [hdd_appl_data], 0
call hd_read
mov [hdd_appl_data], 1 ; restore to default state
ret
@@:
; In the normal case, save ecx, set ecx to SysCache and let the common part
; do its work.
push ecx
mov ecx, [ebp+PARTITION.Disk]
add ecx, DISK.SysCache
jmp fs_read32_common
; This function is intended to replace the old 'hd_read' function when
; [hdd_appl_data] = 1, so its input/output parameters are the same, except
; that it can't use the global variables 'hd_error' and 'hdd_appl_data'.
; in: eax = sector, ebx = buffer, ebp = pointer to PARTITION structure
; eax is relative to partition start
; out: eax = error code; 0 = ok
fs_read32_app:
; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure,
; this request should be processed by hd_read.
cmp [ebp+PARTITION.Disk], 'old'
jnz @f
mov [hdd_appl_data], 1
jmp hd_read
@@:
; In the normal case, save ecx, set ecx to AppCache and let the common part
; do its work.
push ecx
mov ecx, [ebp+PARTITION.Disk]
add ecx, DISK.AppCache
; This label is the common part of fs_read32_sys and fs_read32_app.
fs_read32_common:
; 1. Check that the required sector is inside the partition. If no, return
; DISK_STATUS_END_OF_MEDIA.
cmp dword [ebp+PARTITION.Length+4], 0
jnz @f
cmp dword [ebp+PARTITION.Length], eax
ja @f
mov eax, DISK_STATUS_END_OF_MEDIA
pop ecx
ret
@@:
; 2. Get the absolute sector on the disk.
push edx
xor edx, edx
add eax, dword [ebp+PARTITION.FirstSector]
adc edx, dword [ebp+PARTITION.FirstSector+4]
; 3. If there is no cache for this disk, just pass the request to the driver.
cmp [ecx+DISKCACHE.pointer], 0
jnz .scancache
push 1
push esp ; numsectors
push edx ; startsector
push eax ; startsector
push ebx ; buffer
mov al, DISKFUNC.read
call disk_call_driver
pop ecx
pop edx
pop ecx
ret
.scancache:
; 4. Scan the cache.
push esi edi ecx ; scan cache
push edx eax
virtual at esp
.sector_lo dd ?
.sector_hi dd ?
.cache dd ?
end virtual
; The following code is inherited from hd_read. The differences are:
; all code is protected by the cache lock; instead of static calls
; to hd_read_dma/hd_read_pio/bd_read the dynamic call to DISKFUNC.read is used;
; sector is 64-bit, not 32-bit.
call mutex_lock
mov eax, [.sector_lo]
mov edx, [.sector_hi]
mov esi, [ecx+DISKCACHE.pointer]
mov ecx, [ecx+DISKCACHE.sad_size]
add esi, 12
mov edi, 1
.hdreadcache:
cmp dword [esi+8], 0 ; empty
je .nohdcache
cmp [esi], eax ; correct sector
jne .nohdcache
cmp [esi+4], edx ; correct sector
je .yeshdcache
.nohdcache:
add esi, 12
inc edi
dec ecx
jnz .hdreadcache
mov esi, [.cache]
call find_empty_slot64 ; ret in edi
test eax, eax
jnz .read_done
push 1
push esp
push edx
push [.sector_lo+12]
mov ecx, [.cache]
mov eax, edi
shl eax, 9
add eax, [ecx+DISKCACHE.data]
push eax
mov esi, [ebp+PARTITION.Disk]
mov al, DISKFUNC.read
call disk_call_driver
pop ecx
dec ecx
jnz .read_done
mov ecx, [.cache]
lea eax, [edi*3]
mov esi, [ecx+DISKCACHE.pointer]
lea esi, [eax*4+esi]
mov eax, [.sector_lo]
mov edx, [.sector_hi]
mov [esi], eax ; sector number
mov [esi+4], edx ; sector number
mov dword [esi+8], 1; hd read - mark as same as in hd
.yeshdcache:
mov esi, edi
mov ecx, [.cache]
shl esi, 9
add esi, [ecx+DISKCACHE.data]
mov edi, ebx
mov ecx, 512/4
rep movsd ; move data
xor eax, eax ; successful read
.read_done:
mov ecx, [.cache]
push eax
call mutex_unlock
pop eax
add esp, 12
pop edi esi edx ecx
ret
; This function is intended to replace the old 'hd_write' function when
; [hdd_appl_data] = 0, so its input/output parameters are the same, except
; that it can't use the global variables 'hd_error' and 'hdd_appl_data'.
; in: eax = sector, ebx = buffer, ebp = pointer to PARTITION structure
; eax is relative to partition start
; out: eax = error code; 0 = ok
fs_write32_sys:
; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure,
; this request should be processed by hd_write.
cmp [ebp+PARTITION.Disk], 'old'
jnz @f
mov [hdd_appl_data], 0
call hd_write
mov [hdd_appl_data], 1 ; restore to default state
ret
@@:
; In the normal case, save ecx, set ecx to SysCache and let the common part
; do its work.
push ecx
mov ecx, [ebp+PARTITION.Disk]
add ecx, DISK.SysCache
jmp fs_write32_common
; This function is intended to replace the old 'hd_write' function when
; [hdd_appl_data] = 1, so its input/output parameters are the same, except
; that it can't use the global variables 'hd_error' and 'hdd_appl_data'.
; in: eax = sector, ebx = buffer, ebp = pointer to PARTITION structure
; eax is relative to partition start
; out: eax = error code; 0 = ok
fs_write32_app:
; Compatibility hack: if PARTITION.Disk is 'old', there is no DISK structure,
; this request should be processed by hd_write.
cmp [ebp+PARTITION.Disk], 'old'
jnz @f
mov [hdd_appl_data], 1
jmp hd_write
@@:
; In the normal case, save ecx, set ecx to AppCache and let the common part
; do its work.
push ecx
mov ecx, [ebp+PARTITION.Disk]
add ecx, DISK.AppCache
; This label is the common part of fs_read32_sys and fs_read32_app.
fs_write32_common:
; 1. Check that the required sector is inside the partition. If no, return
; DISK_STATUS_END_OF_MEDIA.
cmp dword [ebp+PARTITION.Length+4], 0
jnz @f
cmp dword [ebp+PARTITION.Length], eax
ja @f
mov eax, DISK_STATUS_END_OF_MEDIA
pop ecx
ret
@@:
push edx
; 2. Get the absolute sector on the disk.
xor edx, edx
add eax, dword [ebp+PARTITION.FirstSector]
adc edx, dword [ebp+PARTITION.FirstSector+4]
; 3. If there is no cache for this disk, just pass request to the driver.
cmp [ecx+DISKCACHE.pointer], 0
jnz .scancache
push 1
push esp ; numsectors
push edx ; startsector
push eax ; startsector
push ebx ; buffer
mov al, DISKFUNC.write
call disk_call_driver
pop ecx
pop edx
pop ecx
ret
.scancache:
; 4. Scan the cache.
push esi edi ecx ; scan cache
push edx eax
virtual at esp
.sector_lo dd ?
.sector_hi dd ?
.cache dd ?
end virtual
; The following code is inherited from hd_write. The differences are:
; all code is protected by the cache lock;
; sector is 64-bit, not 32-bit.
call mutex_lock
; check if the cache already has the sector and overwrite it
mov eax, [.sector_lo]
mov edx, [.sector_hi]
mov esi, [ecx+DISKCACHE.pointer]
mov ecx, [ecx+DISKCACHE.sad_size]
add esi, 12
mov edi, 1
.hdwritecache:
cmp dword [esi+8], 0 ; if cache slot is empty
je .not_in_cache_write
cmp [esi], eax ; if the slot has the sector
jne .not_in_cache_write
cmp [esi+4], edx ; if the slot has the sector
je .yes_in_cache_write
.not_in_cache_write:
add esi, 12
inc edi
dec ecx
jnz .hdwritecache
; sector not found in cache
; write the block to a new location
mov esi, [.cache]
call find_empty_slot64 ; ret in edi
test eax, eax
jne .hd_write_access_denied
mov ecx, [.cache]
lea eax, [edi*3]
mov esi, [ecx+DISKCACHE.pointer]
lea esi, [eax*4+esi]
mov eax, [.sector_lo]
mov edx, [.sector_hi]
mov [esi], eax ; sector number
mov [esi+4], edx ; sector number
.yes_in_cache_write:
mov dword [esi+4], 2 ; write - differs from hd
shl edi, 9
mov ecx, [.cache]
add edi, [ecx+DISKCACHE.data]
mov esi, ebx
mov ecx, 512/4
rep movsd ; move data
xor eax, eax ; success
.hd_write_access_denied:
mov ecx, [.cache]
push eax
call mutex_unlock
pop eax
add esp, 12
pop edi esi edx ecx
ret
; This internal function is called from fs_read32_* and fs_write32_*. It is the
; analogue of find_empty_slot for 64-bit sectors.
find_empty_slot64:
;-----------------------------------------------------------
; find empty or read slot, flush cache if next 12.5% is used by write
; output : edi = cache slot
;-----------------------------------------------------------
.search_again:
mov ecx, [esi+DISKCACHE.sad_size]
mov edi, [esi+DISKCACHE.search_start]
shr ecx, 3
.search_for_empty:
inc edi
cmp edi, [esi+DISKCACHE.sad_size]
jbe .inside_cache
mov edi, 1
.inside_cache:
lea eax, [edi*3]
shl eax, 2
add eax, [esi+DISKCACHE.pointer]
cmp dword [eax+8], 2
jb .found_slot ; it's empty or read
dec ecx
jnz .search_for_empty
call write_cache64 ; no empty slots found, write all
test eax, eax
jne .found_slot_access_denied
jmp .search_again ; and start again
.found_slot:
mov [esi+DISKCACHE.search_start], edi
xor eax, eax ; success
.found_slot_access_denied:
ret
; This function is intended to replace the old 'write_cache' function.
proc write_cache64 uses ecx edx esi edi
locals
cache_chain_started dd ?
cache_chain_size dd ?
cache_chain_pos dd ?
cache_chain_ptr dd ?
endl
; If there is no cache for this disk, nothing to do.
cmp [esi+DISKCACHE.pointer], 0
jz .flush
;-----------------------------------------------------------
; write all changed sectors to disk
;-----------------------------------------------------------
; write difference ( 2 ) from cache to DISK
mov ecx, [esi+DISKCACHE.sad_size]
mov esi, [esi+DISKCACHE.pointer]
add esi, 12
mov edi, 1
.write_cache_more:
cmp dword [esi+8], 2 ; if cache slot is not different
jne .write_chain
mov dword [esi+8], 1 ; same as in hd
mov eax, [esi]
mov edx, [esi+4] ; edx:eax = sector to write
; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>
cmp ecx, 1
jz .nonext
cmp dword [esi+12+8], 2
jnz .nonext
push eax edx
add eax, 1
adc edx, 0
cmp eax, [esi+12]
jnz @f
cmp edx, [esi+12+4]
@@:
pop edx eax
jnz .nonext
cmp [cache_chain_started], 1
jz @f
mov [cache_chain_started], 1
mov [cache_chain_size], 0
mov [cache_chain_pos], edi
mov [cache_chain_ptr], esi
@@:
inc [cache_chain_size]
cmp [cache_chain_size], 16
jnz .continue
jmp .write_chain
.nonext:
call .flush_cache_chain
test eax, eax
jnz .nothing
mov [cache_chain_size], 1
mov [cache_chain_ptr], esi
call .write_cache_sector
test eax, eax
jnz .nothing
jmp .continue
.write_chain:
call .flush_cache_chain
test eax, eax
jnz .nothing
.continue:
add esi, 12
inc edi
dec ecx
jnz .write_cache_more
call .flush_cache_chain
test eax, eax
jnz .nothing
.flush:
mov esi, [ebp]
mov esi, [esi+PARTITION.Disk]
mov al, DISKFUNC.flush
call disk_call_driver
.nothing:
ret
.flush_cache_chain:
xor eax, eax
cmp [cache_chain_started], eax
jz @f
call .write_cache_chain
mov [cache_chain_started], 0
@@:
retn
.write_cache_sector:
mov [cache_chain_size], 1
mov [cache_chain_pos], edi
.write_cache_chain:
pusha
mov edi, [cache_chain_pos]
mov ecx, [ebp-12]
shl edi, 9
add edi, [ecx+DISKCACHE.data]
mov ecx, [cache_chain_size]
push ecx
push esp ; numsectors
mov eax, [cache_chain_ptr]
pushd [eax+4]
pushd [eax] ; startsector
push edi ; buffer
mov esi, [ebp]
mov esi, [esi+PARTITION.Disk]
mov al, DISKFUNC.write
call disk_call_driver
pop ecx
mov [esp+28], eax
popa
retn
endp
; This internal function is called from disk_add to initialize the caching for
; a new DISK.
; The algorithm is inherited from getcache.inc: take 1/32 part of the available
; physical memory, round down to 8 pages, limit by 128K from below and by 1M
; from above. Reserve 1/8 part of the cache for system data and 7/8 for app
; data.
; After the size is calculated, but before the cache is allocated, the device
; driver can adjust the size. In particular, setting size to zero disables
; caching: there is no sense in a cache for a ramdisk. In fact, such action
; is most useful example of a non-trivial adjustment.
; esi = pointer to DISK structure
disk_init_cache:
; 1. Calculate the suggested cache size.
; 1a. Get the size of free physical memory in pages.
mov eax, [pg_data.pages_free]
; 1b. Use the value to calculate the size.
shl eax, 12 - 5 ; 1/32 of it in bytes
and eax, -8*4096 ; round down to the multiple of 8 pages
; 1c. Force lower and upper limits.
cmp eax, 1024*1024
jb @f
mov eax, 1024*1024
@@:
cmp eax, 128*1024
ja @f
mov eax, 128*1024
@@:
; 1d. Give a chance to the driver to adjust the size.
push eax
mov al, DISKFUNC.adjust_cache_size
call disk_call_driver
; Cache size calculated.
mov [esi+DISK.cache_size], eax
test eax, eax
jz .nocache
; 2. Allocate memory for the cache.
; 2a. Call the allocator.
stdcall kernel_alloc, eax
test eax, eax
jnz @f
; 2b. If it failed, say a message and return with eax = 0.
dbgstr 'no memory for disk cache'
jmp .nothing
@@:
; 3. Fill two DISKCACHE structures.
mov [esi+DISK.SysCache.pointer], eax
lea ecx, [esi+DISK.SysCache.mutex]
call mutex_init
lea ecx, [esi+DISK.AppCache.mutex]
call mutex_init
; The following code is inherited from getcache.inc.
mov edx, [esi+DISK.SysCache.pointer]
and [esi+DISK.SysCache.search_start], 0
and [esi+DISK.AppCache.search_start], 0
mov eax, [esi+DISK.cache_size]
shr eax, 3
mov [esi+DISK.SysCache.data_size], eax
add edx, eax
imul eax, 7
mov [esi+DISK.AppCache.data_size], eax
mov [esi+DISK.AppCache.pointer], edx
mov eax, [esi+DISK.SysCache.data_size]
push ebx
call calculate_for_hd
pop ebx
add eax, [esi+DISK.SysCache.pointer]
mov [esi+DISK.SysCache.data], eax
mov [esi+DISK.SysCache.sad_size], ecx
push edi
mov edi, [esi+DISK.SysCache.pointer]
lea ecx, [ecx*3]
xor eax, eax
rep stosd
pop edi
mov eax, [esi+DISK.AppCache.data_size]
push ebx
call calculate_for_hd
pop ebx
add eax, [esi+DISK.AppCache.pointer]
mov [esi+DISK.AppCache.data], eax
mov [esi+DISK.AppCache.sad_size], ecx
push edi
mov edi, [esi+DISK.AppCache.pointer]
lea ecx, [ecx*3]
xor eax, eax
rep stosd
pop edi
; 4. Return with nonzero al.
mov al, 1
; 5. Return.
.nothing:
ret
; No caching is required for this driver. Zero cache pointers and return with
; nonzero al.
.nocache:
mov [esi+DISK.SysCache.pointer], eax
mov [esi+DISK.AppCache.pointer], eax
mov al, 1
ret
; This internal function is called from disk_media_dereference to free the
; allocated cache, if there is one.
; esi = pointer to DISK structure
disk_free_cache:
; The algorithm is straightforward.
mov eax, [esi+DISK.SysCache.pointer]
test eax, eax
jz .nothing
stdcall kernel_free, eax
.nothing:
ret

View File

@@ -19,53 +19,53 @@ uglobal
endg endg
fdc_init: ;start with clean tracks. fdc_init: ;start with clean tracks.
mov edi,OS_BASE+0xD201 mov edi, OS_BASE+0xD201
mov al,0 mov al, 0
mov ecx,160 mov ecx, 160
rep stosb rep stosb
ret ret
fdc_irq: fdc_irq:
call [fdc_irq_func] call [fdc_irq_func]
fdc_null: fdc_null:
ret ret
save_image: save_image:
call reserve_flp call reserve_flp
call restorefatchain call restorefatchain
pusha pusha
call check_label call check_label
cmp [FDC_Status],0 cmp [FDC_Status], 0
jne unnecessary_save_image jne unnecessary_save_image
mov [FDD_Track],0 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov [FDD_Track], 0; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDD_Head],0 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov [FDD_Head], 0; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDD_Sector],1 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov [FDD_Sector], 1; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov esi,RAMDISK mov esi, RAMDISK
call SeekTrack call SeekTrack
save_image_1: save_image_1:
push esi push esi
call take_data_from_application_1 call take_data_from_application_1
pop esi pop esi
add esi,512 add esi, 512
call WriteSectWithRetr call WriteSectWithRetr
; call WriteSector ; call WriteSector
cmp [FDC_Status],0 cmp [FDC_Status], 0
jne unnecessary_save_image jne unnecessary_save_image
inc [FDD_Sector] inc [FDD_Sector]
cmp [FDD_Sector],19 cmp [FDD_Sector], 19
jne save_image_1 jne save_image_1
mov [FDD_Sector],1 mov [FDD_Sector], 1
inc [FDD_Head] inc [FDD_Head]
cmp [FDD_Head],2 cmp [FDD_Head], 2
jne save_image_1 jne save_image_1
mov [FDD_Head],0 mov [FDD_Head], 0
inc [FDD_Track] inc [FDD_Track]
call SeekTrack call SeekTrack
cmp [FDD_Track],80 cmp [FDD_Track], 80
jne save_image_1 jne save_image_1
unnecessary_save_image: unnecessary_save_image:
mov [fdc_irq_func],fdc_null mov [fdc_irq_func], fdc_null
popa popa
mov [flp_status],0 mov [flp_status], 0
ret ret

View File

@@ -19,9 +19,9 @@ $Revision$
; mov edi,[edi+TASKDATA.mem_start] ; mov edi,[edi+TASKDATA.mem_start]
; add edi,ecx ; add edi,ecx
give_back_application_data_1: give_back_application_data_1:
mov esi,FDD_BUFF ;FDD_DataBuffer ;0x40000 mov esi, FDD_BUFF;FDD_DataBuffer ;0x40000
xor ecx,ecx xor ecx, ecx
mov cx,128 mov cx, 128
cld cld
rep movsd rep movsd
ret ret
@@ -31,9 +31,9 @@ give_back_application_data_1:
; mov esi,[esi+TASKDATA.mem_start] ; mov esi,[esi+TASKDATA.mem_start]
; add esi,ecx ; add esi,ecx
take_data_from_application_1: take_data_from_application_1:
mov edi,FDD_BUFF ;FDD_DataBuffer ;0x40000 mov edi, FDD_BUFF;FDD_DataBuffer ;0x40000
xor ecx,ecx xor ecx, ecx
mov cx,128 mov cx, 128
cld cld
rep movsd rep movsd
ret ret
@@ -91,28 +91,28 @@ timer_fdd_motor dd 0
;************************************* ;*************************************
Init_FDC_DMA: Init_FDC_DMA:
pushad pushad
mov al,0 mov al, 0
out 0x0c,al ; reset the flip-flop to a known state. out 0x0c, al; reset the flip-flop to a known state.
mov al,6 ; mask channel 2 so we can reprogram it. mov al, 6 ; mask channel 2 so we can reprogram it.
out 0x0a,al out 0x0a, al
mov al,[dmamode] ; 0x46 -> Read from floppy - 0x4A Write to floppy mov al, [dmamode]; 0x46 -> Read from floppy - 0x4A Write to floppy
out 0x0b,al out 0x0b, al
mov al,0 mov al, 0
out 0x0c,al ; reset the flip-flop to a known state. out 0x0c, al; reset the flip-flop to a known state.
mov eax,0xD000 mov eax, 0xD000
out 0x04,al ; set the channel 2 starting address to 0 out 0x04, al; set the channel 2 starting address to 0
shr eax,8 shr eax, 8
out 0x04,al out 0x04, al
shr eax,8 shr eax, 8
out 0x81,al out 0x81, al
mov al,0 mov al, 0
out 0x0c, al ; reset flip-flop out 0x0c, al; reset flip-flop
mov al, 0xff ;set count (actual size -1) mov al, 0xff;set count (actual size -1)
out 0x5, al out 0x5, al
mov al,0x1 ;[dmasize] ;(0x1ff = 511 / 0x23ff =9215) mov al, 0x1;[dmasize] ;(0x1ff = 511 / 0x23ff =9215)
out 0x5,al out 0x5, al
mov al,2 mov al, 2
out 0xa,al out 0xa, al
popad popad
ret ret
@@ -124,26 +124,26 @@ Init_FDC_DMA:
FDCDataOutput: FDCDataOutput:
; pusha ; pusha
push eax ecx edx push eax ecx edx
mov AH,AL ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> AH mov AH, AL ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> AH
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDC_Status],FDC_Normal mov [FDC_Status], FDC_Normal
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov DX,3F4h ;(<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FDC) mov DX, 3F4h ;(<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FDC)
mov ecx, 0x10000 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov ecx, 0x10000 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@TestRS: @@TestRS:
in AL,DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> RS in AL, DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> RS
and AL,0C0h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 6 <EFBFBD> 7 and AL, 0C0h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 6 <EFBFBD> 7
cmp AL,80h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 6 <EFBFBD> 7 cmp AL, 80h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 6 <EFBFBD> 7
je @@OutByteToFDC je @@OutByteToFDC
loop @@TestRS loop @@TestRS
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDC_Status],FDC_TimeOut mov [FDC_Status], FDC_TimeOut
jmp @@End_5 jmp @@End_5
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@OutByteToFDC: @@OutByteToFDC:
inc DX inc DX
mov AL,AH mov AL, AH
out DX,AL out DX, AL
@@End_5: @@End_5:
; popa ; popa
pop edx ecx eax pop edx ecx eax
@@ -159,24 +159,25 @@ FDCDataInput:
push ECX push ECX
push DX push DX
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDC_Status],FDC_Normal mov [FDC_Status], FDC_Normal
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov DX,3F4h ;(<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FDC) mov DX, 3F4h ;(<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FDC)
xor CX,CX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD> xor CX, CX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@TestRS_1: @@TestRS_1:
in AL,DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> RS in AL, DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> RS
and AL,0C0h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 6 <EFBFBD> 7 and AL, 0C0h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 6 <EFBFBD> 7
cmp AL,0C0h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 6 <EFBFBD> 7 cmp AL, 0C0h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 6 <EFBFBD> 7
je @@GetByteFromFDC je @@GetByteFromFDC
loop @@TestRS_1 loop @@TestRS_1
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDC_Status],FDC_TimeOut mov [FDC_Status], FDC_TimeOut
jmp @@End_6 jmp @@End_6
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@GetByteFromFDC: @@GetByteFromFDC:
inc DX inc DX
in AL,DX in AL, DX
@@End_6: pop DX @@End_6:
pop DX
pop ECX pop ECX
ret ret
@@ -185,7 +186,7 @@ FDCDataInput:
;********************************************* ;*********************************************
FDCInterrupt: FDCInterrupt:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDD_IntFlag],1 mov [FDD_IntFlag], 1
ret ret
@@ -194,7 +195,7 @@ FDCInterrupt:
;* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> * ;* <EFBFBD><EFBFBD><EFBFBD><EFBFBD> *
;****************************************** ;******************************************
SetUserInterrupts: SetUserInterrupts:
mov [fdc_irq_func],FDCInterrupt mov [fdc_irq_func], FDCInterrupt
ret ret
;******************************************* ;*******************************************
@@ -203,26 +204,27 @@ SetUserInterrupts:
WaitFDCInterrupt: WaitFDCInterrupt:
pusha pusha
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDC_Status],FDC_Normal mov [FDC_Status], FDC_Normal
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDD_IntFlag],0 mov [FDD_IntFlag], 0
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov eax,[timer_ticks] mov eax, [timer_ticks]
mov [TickCounter],eax mov [TickCounter], eax
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@TestRS_2: @@TestRS_2:
cmp [FDD_IntFlag],0 cmp [FDD_IntFlag], 0
jnz @@End_7 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> jnz @@End_7 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call change_task call change_task
mov eax,[timer_ticks] mov eax, [timer_ticks]
sub eax,[TickCounter] sub eax, [TickCounter]
cmp eax,50 ;25 ;5 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 5 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> cmp eax, 50 ;25 ;5 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 5 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
jb @@TestRS_2 jb @@TestRS_2
; jl @@TestRS_2 ; jl @@TestRS_2
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDC_Status],FDC_TimeOut mov [FDC_Status], FDC_TimeOut
; mov [flp_status],0 ; mov [flp_status],0
@@End_7: popa @@End_7:
popa
ret ret
;********************************* ;*********************************
@@ -232,40 +234,40 @@ FDDMotorON:
pusha pusha
; cmp [fdd_motor_status],1 ; cmp [fdd_motor_status],1
; je fdd_motor_on ; je fdd_motor_on
mov al,[flp_number] mov al, [flp_number]
cmp [fdd_motor_status],al cmp [fdd_motor_status], al
je fdd_motor_on je fdd_motor_on
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov DX,3F2h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov DX, 3F2h;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov AL,0 mov AL, 0
out DX,AL out DX, AL
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cmp [flp_number],1 cmp [flp_number], 1
jne FDDMotorON_B jne FDDMotorON_B
; call FDDMotorOFF_B ; call FDDMotorOFF_B
mov AL,1Ch ; Floppy A mov AL, 1Ch ; Floppy A
jmp FDDMotorON_1 jmp FDDMotorON_1
FDDMotorON_B: FDDMotorON_B:
; call FDDMotorOFF_A ; call FDDMotorOFF_A
mov AL,2Dh ; Floppy B mov AL, 2Dh ; Floppy B
FDDMotorON_1: FDDMotorON_1:
out DX,AL out DX, AL
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov eax,[timer_ticks] mov eax, [timer_ticks]
mov [TickCounter],eax mov [TickCounter], eax
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0,5 <EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0,5 <EFBFBD>
@@dT: @@dT:
call change_task call change_task
mov eax,[timer_ticks] mov eax, [timer_ticks]
sub eax,[TickCounter] sub eax, [TickCounter]
cmp eax,50 ;10 cmp eax, 50 ;10
jb @@dT jb @@dT
cmp [flp_number],1 cmp [flp_number], 1
jne fdd_motor_on_B jne fdd_motor_on_B
mov [fdd_motor_status],1 mov [fdd_motor_status], 1
jmp fdd_motor_on jmp fdd_motor_on
fdd_motor_on_B: fdd_motor_on_B:
mov [fdd_motor_status],2 mov [fdd_motor_status], 2
fdd_motor_on: fdd_motor_on:
call save_timer_fdd_motor call save_timer_fdd_motor
popa popa
@@ -275,8 +277,8 @@ fdd_motor_on:
;* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> * ;* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *
;***************************************** ;*****************************************
save_timer_fdd_motor: save_timer_fdd_motor:
mov eax,[timer_ticks] mov eax, [timer_ticks]
mov [timer_fdd_motor],eax mov [timer_fdd_motor], eax
ret ret
;***************************************** ;*****************************************
@@ -284,16 +286,16 @@ save_timer_fdd_motor:
;***************************************** ;*****************************************
align 4 align 4
check_fdd_motor_status: check_fdd_motor_status:
cmp [fdd_motor_status],0 cmp [fdd_motor_status], 0
je end_check_fdd_motor_status_1 je end_check_fdd_motor_status_1
mov eax,[timer_ticks] mov eax, [timer_ticks]
sub eax,[timer_fdd_motor] sub eax, [timer_fdd_motor]
cmp eax,500 cmp eax, 500
jb end_check_fdd_motor_status jb end_check_fdd_motor_status
call FDDMotorOFF call FDDMotorOFF
mov [fdd_motor_status],0 mov [fdd_motor_status], 0
end_check_fdd_motor_status_1: end_check_fdd_motor_status_1:
mov [flp_status],0 mov [flp_status], 0
end_check_fdd_motor_status: end_check_fdd_motor_status:
ret ret
@@ -303,7 +305,7 @@ end_check_fdd_motor_status:
FDDMotorOFF: FDDMotorOFF:
push AX push AX
push DX push DX
cmp [flp_number],1 cmp [flp_number], 1
jne FDDMotorOFF_1 jne FDDMotorOFF_1
call FDDMotorOFF_A call FDDMotorOFF_A
jmp FDDMotorOFF_2 jmp FDDMotorOFF_2
@@ -313,20 +315,20 @@ FDDMotorOFF_2:
pop DX pop DX
pop AX pop AX
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [root_read],0 mov [root_read], 0
mov [flp_fat],0 mov [flp_fat], 0
ret ret
FDDMotorOFF_A: FDDMotorOFF_A:
mov DX,3F2h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov DX, 3F2h;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov AL,0Ch ; Floppy A mov AL, 0Ch ; Floppy A
out DX,AL out DX, AL
ret ret
FDDMotorOFF_B: FDDMotorOFF_B:
mov DX,3F2h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov DX, 3F2h;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov AL,5h ; Floppy B mov AL, 5h ; Floppy B
out DX,AL out DX, AL
ret ret
;******************************* ;*******************************
@@ -336,9 +338,9 @@ RecalibrateFDD:
pusha pusha
call save_timer_fdd_motor call save_timer_fdd_motor
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
mov AL,07h mov AL, 07h
call FDCDataOutput call FDCDataOutput
mov AL,00h mov AL, 00h
call FDCDataOutput call FDCDataOutput
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call WaitFDCInterrupt call WaitFDCInterrupt
@@ -361,45 +363,45 @@ SeekTrack:
pusha pusha
call save_timer_fdd_motor call save_timer_fdd_motor
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
mov AL,0Fh mov AL, 0Fh
call FDCDataOutput call FDCDataOutput
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov AL,[FDD_Head] mov AL, [FDD_Head]
shl AL,2 shl AL, 2
call FDCDataOutput call FDCDataOutput
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov AL,[FDD_Track] mov AL, [FDD_Track]
call FDCDataOutput call FDCDataOutput
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call WaitFDCInterrupt call WaitFDCInterrupt
cmp [FDC_Status],FDC_Normal cmp [FDC_Status], FDC_Normal
jne @@Exit jne @@Exit
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov AL,08h mov AL, 08h
call FDCDataOutput call FDCDataOutput
call FDCDataInput call FDCDataInput
mov [FDC_ST0],AL mov [FDC_ST0], AL
call FDCDataInput call FDCDataInput
mov [FDC_C],AL mov [FDC_C], AL
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
test [FDC_ST0],100000b test [FDC_ST0], 100000b
je @@Err je @@Err
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
mov AL,[FDC_C] mov AL, [FDC_C]
cmp AL,[FDD_Track] cmp AL, [FDD_Track]
jne @@Err jne @@Err
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
mov AL,[FDC_ST0] mov AL, [FDC_ST0]
and AL,100b and AL, 100b
shr AL,2 shr AL, 2
cmp AL,[FDD_Head] cmp AL, [FDD_Head]
jne @@Err jne @@Err
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDC_Status],FDC_Normal mov [FDC_Status], FDC_Normal
jmp @@Exit jmp @@Exit
@@Err: ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> @@Err: ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDC_Status],FDC_TrackNotFound mov [FDC_Status], FDC_TrackNotFound
; mov [flp_status],0 ; mov [flp_status],0
@@Exit: @@Exit:
call save_timer_fdd_motor call save_timer_fdd_motor
@@ -420,43 +422,44 @@ ReadSector:
pushad pushad
call save_timer_fdd_motor call save_timer_fdd_motor
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 500 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 500 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<EFBFBD>
mov AX,0 mov AX, 0
mov DX,03F7h mov DX, 03F7h
out DX,AL out DX, AL
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [dmamode],0x46 mov [dmamode], 0x46
call Init_FDC_DMA call Init_FDC_DMA
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
mov AL,0E6h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov AL, 0E6h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call FDCDataOutput call FDCDataOutput
mov AL,[FDD_Head] mov AL, [FDD_Head]
shl AL,2 shl AL, 2
call FDCDataOutput call FDCDataOutput
mov AL,[FDD_Track] mov AL, [FDD_Track]
call FDCDataOutput call FDCDataOutput
mov AL,[FDD_Head] mov AL, [FDD_Head]
call FDCDataOutput call FDCDataOutput
mov AL,[FDD_Sector] mov AL, [FDD_Sector]
call FDCDataOutput call FDCDataOutput
mov AL,2 ;<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (512 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>) mov AL, 2 ;<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (512 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
call FDCDataOutput call FDCDataOutput
mov AL,18 ;+1; 3Fh ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov AL, 18 ;+1; 3Fh ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call FDCDataOutput call FDCDataOutput
mov AL,1Bh ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> GPL mov AL, 1Bh ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> GPL
call FDCDataOutput call FDCDataOutput
mov AL,0FFh ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DTL mov AL, 0FFh;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DTL
call FDCDataOutput call FDCDataOutput
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call WaitFDCInterrupt call WaitFDCInterrupt
cmp [FDC_Status],FDC_Normal cmp [FDC_Status], FDC_Normal
jne @@Exit_1 jne @@Exit_1
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call GetStatusInfo call GetStatusInfo
test [FDC_ST0],11011000b test [FDC_ST0], 11011000b
jnz @@Err_1 jnz @@Err_1
mov [FDC_Status],FDC_Normal mov [FDC_Status], FDC_Normal
jmp @@Exit_1 jmp @@Exit_1
@@Err_1: mov [FDC_Status],FDC_SectorNotFound @@Err_1:
mov [FDC_Status], FDC_SectorNotFound
; mov [flp_status],0 ; mov [flp_status],0
@@Exit_1: @@Exit_1:
call save_timer_fdd_motor call save_timer_fdd_motor
@@ -476,32 +479,32 @@ ReadSector:
ReadSectWithRetr: ReadSectWithRetr:
pusha pusha
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [RecalRepCounter],0 mov [RecalRepCounter], 0
@@TryAgain: @@TryAgain:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [ReadRepCounter],0 mov [ReadRepCounter], 0
@@ReadSector_1: @@ReadSector_1:
call ReadSector call ReadSector
cmp [FDC_Status],0 cmp [FDC_Status], 0
je @@Exit_2 je @@Exit_2
cmp [FDC_Status],1 cmp [FDC_Status], 1
je @@Err_3 je @@Err_3
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
inc [ReadRepCounter] inc [ReadRepCounter]
cmp [ReadRepCounter],3 cmp [ReadRepCounter], 3
jb @@ReadSector_1 jb @@ReadSector_1
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call RecalibrateFDD call RecalibrateFDD
call SeekTrack call SeekTrack
inc [RecalRepCounter] inc [RecalRepCounter]
cmp [RecalRepCounter],3 cmp [RecalRepCounter], 3
jb @@TryAgain jb @@TryAgain
; mov [flp_status],0 ; mov [flp_status],0
@@Exit_2: @@Exit_2:
popa popa
ret ret
@@Err_3: @@Err_3:
mov [flp_status],0 mov [flp_status], 0
popa popa
ret ret
@@ -519,43 +522,44 @@ WriteSector:
pushad pushad
call save_timer_fdd_motor call save_timer_fdd_motor
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 500 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 500 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<EFBFBD>
mov AX,0 mov AX, 0
mov DX,03F7h mov DX, 03F7h
out DX,AL out DX, AL
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [dmamode],0x4A mov [dmamode], 0x4A
call Init_FDC_DMA call Init_FDC_DMA
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
mov AL,0xC5 ;0x45 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov AL, 0xC5 ;0x45 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call FDCDataOutput call FDCDataOutput
mov AL,[FDD_Head] mov AL, [FDD_Head]
shl AL,2 shl AL, 2
call FDCDataOutput call FDCDataOutput
mov AL,[FDD_Track] mov AL, [FDD_Track]
call FDCDataOutput call FDCDataOutput
mov AL,[FDD_Head] mov AL, [FDD_Head]
call FDCDataOutput call FDCDataOutput
mov AL,[FDD_Sector] mov AL, [FDD_Sector]
call FDCDataOutput call FDCDataOutput
mov AL,2 ;<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (512 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>) mov AL, 2 ;<EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (512 <EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
call FDCDataOutput call FDCDataOutput
mov AL,18; 3Fh ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov AL, 18; 3Fh ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call FDCDataOutput call FDCDataOutput
mov AL,1Bh ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> GPL mov AL, 1Bh ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> GPL
call FDCDataOutput call FDCDataOutput
mov AL,0FFh ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DTL mov AL, 0FFh;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DTL
call FDCDataOutput call FDCDataOutput
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call WaitFDCInterrupt call WaitFDCInterrupt
cmp [FDC_Status],FDC_Normal cmp [FDC_Status], FDC_Normal
jne @@Exit_3 jne @@Exit_3
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call GetStatusInfo call GetStatusInfo
test [FDC_ST0],11000000b ;11011000b test [FDC_ST0], 11000000b ;11011000b
jnz @@Err_2 jnz @@Err_2
mov [FDC_Status],FDC_Normal mov [FDC_Status], FDC_Normal
jmp @@Exit_3 jmp @@Exit_3
@@Err_2: mov [FDC_Status],FDC_SectorNotFound @@Err_2:
mov [FDC_Status], FDC_SectorNotFound
@@Exit_3: @@Exit_3:
call save_timer_fdd_motor call save_timer_fdd_motor
popad popad
@@ -574,31 +578,31 @@ WriteSector:
WriteSectWithRetr: WriteSectWithRetr:
pusha pusha
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [RecalRepCounter],0 mov [RecalRepCounter], 0
@@TryAgain_1: @@TryAgain_1:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [ReadRepCounter],0 mov [ReadRepCounter], 0
@@WriteSector_1: @@WriteSector_1:
call WriteSector call WriteSector
cmp [FDC_Status],0 cmp [FDC_Status], 0
je @@Exit_4 je @@Exit_4
cmp [FDC_Status],1 cmp [FDC_Status], 1
je @@Err_4 je @@Err_4
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
inc [ReadRepCounter] inc [ReadRepCounter]
cmp [ReadRepCounter],3 cmp [ReadRepCounter], 3
jb @@WriteSector_1 jb @@WriteSector_1
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call RecalibrateFDD call RecalibrateFDD
call SeekTrack call SeekTrack
inc [RecalRepCounter] inc [RecalRepCounter]
cmp [RecalRepCounter],3 cmp [RecalRepCounter], 3
jb @@TryAgain_1 jb @@TryAgain_1
@@Exit_4: @@Exit_4:
popa popa
ret ret
@@Err_4: @@Err_4:
mov [flp_status],0 mov [flp_status], 0
popa popa
ret ret
@@ -608,19 +612,19 @@ WriteSectWithRetr:
GetStatusInfo: GetStatusInfo:
push AX push AX
call FDCDataInput call FDCDataInput
mov [FDC_ST0],AL mov [FDC_ST0], AL
call FDCDataInput call FDCDataInput
mov [FDC_ST1],AL mov [FDC_ST1], AL
call FDCDataInput call FDCDataInput
mov [FDC_ST2],AL mov [FDC_ST2], AL
call FDCDataInput call FDCDataInput
mov [FDC_C],AL mov [FDC_C], AL
call FDCDataInput call FDCDataInput
mov [FDC_H],AL mov [FDC_H], AL
call FDCDataInput call FDCDataInput
mov [FDC_R],AL mov [FDC_R], AL
call FDCDataInput call FDCDataInput
mov [FDC_N],AL mov [FDC_N], AL
pop AX pop AX
ret ret

View File

@@ -24,27 +24,27 @@ hd_read:
; mov ecx,cache_max ; entries in cache ; mov ecx,cache_max ; entries in cache
; mov esi,HD_CACHE+8 ; mov esi,HD_CACHE+8
call calculate_cache call calculate_cache
add esi,8 add esi, 8
mov edi,1 mov edi, 1
hdreadcache: hdreadcache:
cmp dword [esi+4],0 ; empty cmp dword [esi+4], 0; empty
je nohdcache je nohdcache
cmp [esi],eax ; correct sector cmp [esi], eax ; correct sector
je yeshdcache je yeshdcache
nohdcache: nohdcache:
add esi,8 add esi, 8
inc edi inc edi
dec ecx dec ecx
jnz hdreadcache jnz hdreadcache
call find_empty_slot ; ret in edi call find_empty_slot ; ret in edi
cmp [hd_error],0 cmp [hd_error], 0
jne return_01 jne return_01
; Read through BIOS? ; Read through BIOS?
cmp [hdpos], 0x80 cmp [hdpos], 0x80
@@ -73,24 +73,24 @@ hd_read:
; lea esi,[edi*8+HD_CACHE] ; lea esi,[edi*8+HD_CACHE]
; push eax ; push eax
call calculate_cache_1 call calculate_cache_1
lea esi,[edi*8+esi] lea esi, [edi*8+esi]
; pop eax ; pop eax
mov [esi],eax ; sector number mov [esi], eax ; sector number
mov dword [esi+4],1 ; hd read - mark as same as in hd mov dword [esi+4], 1; hd read - mark as same as in hd
yeshdcache: yeshdcache:
mov esi,edi mov esi, edi
shl esi,9 shl esi, 9
; add esi,HD_CACHE+65536 ; add esi,HD_CACHE+65536
push eax push eax
call calculate_cache_2 call calculate_cache_2
add esi,eax add esi, eax
pop eax pop eax
mov edi,ebx mov edi, ebx
mov ecx,512/4 mov ecx, 512/4
cld cld
rep movsd ; move data rep movsd ; move data
return_01: return_01:
@@ -102,53 +102,53 @@ hd_read_pio:
push eax edx push eax edx
call wait_for_hd_idle call wait_for_hd_idle
cmp [hd_error],0 cmp [hd_error], 0
jne hd_read_error jne hd_read_error
cli cli
xor eax,eax xor eax, eax
mov edx,[hdbase] mov edx, [hdbase]
inc edx inc edx
out dx,al ; ATAFeatures <EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" out dx, al; ATAFeatures <EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
inc edx inc edx
inc eax inc eax
out dx,al ; ATASectorCount <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> out dx, al; ATASectorCount <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>
inc edx inc edx
mov eax,[esp+4] mov eax, [esp+4]
out dx,al ; ATASectorNumber <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> out dx, al; ATASectorNumber <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
shr eax,8 shr eax, 8
inc edx inc edx
out dx,al ; ATACylinder <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>) out dx, al; ATACylinder <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
shr eax,8 shr eax, 8
inc edx inc edx
out dx,al ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>) out dx, al; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
shr eax,8 shr eax, 8
inc edx inc edx
and al,1+2+4+8 and al, 1+2+4+8
add al,byte [hdid] add al, byte [hdid]
add al,128+64+32 add al, 128+64+32
out dx,al ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> out dx, al; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>
inc edx inc edx
mov al,20h mov al, 20h
out dx,al ; ATACommand <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> out dx, al; ATACommand <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
sti sti
call wait_for_sector_buffer call wait_for_sector_buffer
cmp [hd_error],0 cmp [hd_error], 0
jne hd_read_error jne hd_read_error
cli cli
push edi push edi
shl edi,9 shl edi, 9
; add edi,HD_CACHE+65536 ; add edi,HD_CACHE+65536
push eax push eax
call calculate_cache_2 call calculate_cache_2
add edi,eax add edi, eax
pop eax pop eax
mov ecx,256 mov ecx, 256
mov edx,[hdbase] mov edx, [hdbase]
cld cld
rep insw rep insw
pop edi pop edi
@@ -186,21 +186,21 @@ hd_write:
; mov ecx,cache_max ; mov ecx,cache_max
; mov esi,HD_CACHE+8 ; mov esi,HD_CACHE+8
call calculate_cache call calculate_cache
add esi,8 add esi, 8
mov edi,1 mov edi, 1
hdwritecache: hdwritecache:
cmp dword [esi+4],0 ; if cache slot is empty cmp dword [esi+4], 0; if cache slot is empty
je not_in_cache_write je not_in_cache_write
cmp [esi],eax ; if the slot has the sector cmp [esi], eax ; if the slot has the sector
je yes_in_cache_write je yes_in_cache_write
not_in_cache_write: not_in_cache_write:
add esi,8 add esi, 8
inc edi inc edi
dec ecx dec ecx
jnz hdwritecache jnz hdwritecache
@@ -209,30 +209,30 @@ hd_write:
; write the block to a new location ; write the block to a new location
call find_empty_slot ; ret in edi call find_empty_slot ; ret in edi
cmp [hd_error],0 cmp [hd_error], 0
jne hd_write_access_denied jne hd_write_access_denied
; lea esi,[edi*8+HD_CACHE] ; lea esi,[edi*8+HD_CACHE]
; push eax ; push eax
call calculate_cache_1 call calculate_cache_1
lea esi,[edi*8+esi] lea esi, [edi*8+esi]
; pop eax ; pop eax
mov [esi],eax ; sector number mov [esi], eax ; sector number
yes_in_cache_write: yes_in_cache_write:
mov dword [esi+4],2 ; write - differs from hd mov dword [esi+4], 2; write - differs from hd
shl edi,9 shl edi, 9
; add edi,HD_CACHE+65536 ; add edi,HD_CACHE+65536
push eax push eax
call calculate_cache_2 call calculate_cache_2
add edi,eax add edi, eax
pop eax pop eax
mov esi,ebx mov esi, ebx
mov ecx,512/4 mov ecx, 512/4
cld cld
rep movsd ; move data rep movsd ; move data
hd_write_access_denied: hd_write_access_denied:
@@ -241,60 +241,60 @@ hd_write:
align 4 align 4
cache_write_pio: cache_write_pio:
cmp dword[esi],0x10000000 cmp dword[esi], 0x10000000
jae .bad jae .bad
; call disable_ide_int ; call disable_ide_int
call wait_for_hd_idle call wait_for_hd_idle
cmp [hd_error],0 cmp [hd_error], 0
jne hd_write_error jne hd_write_error
cli cli
xor eax,eax xor eax, eax
mov edx,[hdbase] mov edx, [hdbase]
inc edx inc edx
out dx,al out dx, al
inc edx inc edx
inc eax inc eax
out dx,al out dx, al
inc edx inc edx
mov eax,[esi] ; eax = sector to write mov eax, [esi] ; eax = sector to write
out dx,al out dx, al
shr eax,8 shr eax, 8
inc edx inc edx
out dx,al out dx, al
shr eax,8 shr eax, 8
inc edx inc edx
out dx,al out dx, al
shr eax,8 shr eax, 8
inc edx inc edx
and al,1+2+4+8 and al, 1+2+4+8
add al,byte [hdid] add al, byte [hdid]
add al,128+64+32 add al, 128+64+32
out dx,al out dx, al
inc edx inc edx
mov al,30h mov al, 30h
out dx,al out dx, al
sti sti
call wait_for_sector_buffer call wait_for_sector_buffer
cmp [hd_error],0 cmp [hd_error], 0
jne hd_write_error jne hd_write_error
push ecx esi push ecx esi
cli cli
mov esi,edi mov esi, edi
shl esi,9 shl esi, 9
; add esi,HD_CACHE+65536 ; esi = from memory position ; add esi,HD_CACHE+65536 ; esi = from memory position
push eax push eax
call calculate_cache_2 call calculate_cache_2
add esi,eax add esi, eax
pop eax pop eax
mov ecx,256 mov ecx, 256
mov edx,[hdbase] mov edx, [hdbase]
cld cld
rep outsw rep outsw
sti sti
@@ -310,9 +310,9 @@ cache_write_pio:
save_hd_wait_timeout: save_hd_wait_timeout:
push eax push eax
mov eax,[timer_ticks] mov eax, [timer_ticks]
add eax,300 ; 3 sec timeout add eax, 300 ; 3 sec timeout
mov [hd_wait_timeout],eax mov [hd_wait_timeout], eax
pop eax pop eax
ret ret
@@ -320,11 +320,11 @@ align 4
check_hd_wait_timeout: check_hd_wait_timeout:
push eax push eax
mov eax,[hd_wait_timeout] mov eax, [hd_wait_timeout]
cmp [timer_ticks], eax cmp [timer_ticks], eax
jg hd_timeout_error jg hd_timeout_error
pop eax pop eax
mov [hd_error],0 mov [hd_error], 0
ret ret
;iglobal ;iglobal
@@ -342,7 +342,7 @@ hd_timeout_error:
; call sys_msg_board_str ; call sys_msg_board_str
DEBUGF 1,"K : FS - HD timeout\n" DEBUGF 1,"K : FS - HD timeout\n"
mov [hd_error],1 mov [hd_error], 1
pop eax pop eax
ret ret
@@ -390,17 +390,17 @@ wait_for_hd_idle:
call save_hd_wait_timeout call save_hd_wait_timeout
mov edx,[hdbase] mov edx, [hdbase]
add edx,0x7 add edx, 0x7
wfhil1: wfhil1:
call check_hd_wait_timeout call check_hd_wait_timeout
cmp [hd_error],0 cmp [hd_error], 0
jne @f jne @f
in al,dx in al, dx
test al,128 test al, 128
jnz wfhil1 jnz wfhil1
@@: @@:
@@ -414,30 +414,30 @@ wait_for_sector_buffer:
push eax edx push eax edx
mov edx,[hdbase] mov edx, [hdbase]
add edx,0x7 add edx, 0x7
call save_hd_wait_timeout call save_hd_wait_timeout
hdwait_sbuf: ; wait for sector buffer to be ready hdwait_sbuf: ; wait for sector buffer to be ready
call check_hd_wait_timeout call check_hd_wait_timeout
cmp [hd_error],0 cmp [hd_error], 0
jne @f jne @f
in al,dx in al, dx
test al,8 test al, 8
jz hdwait_sbuf jz hdwait_sbuf
mov [hd_error],0 mov [hd_error], 0
cmp [hd_setup],1 ; do not mark error for setup request cmp [hd_setup], 1 ; do not mark error for setup request
je buf_wait_ok je buf_wait_ok
test al,1 ; previous command ended up with an error test al, 1 ; previous command ended up with an error
jz buf_wait_ok jz buf_wait_ok
@@: @@:
mov [hd_error],1 mov [hd_error], 1
buf_wait_ok: buf_wait_ok:
@@ -578,8 +578,8 @@ align 4
hd_read_dma: hd_read_dma:
push eax push eax
push edx push edx
mov edx,[dma_hdpos] mov edx, [dma_hdpos]
cmp edx,[hdpos] cmp edx, [hdpos]
jne .notread jne .notread
mov edx, [dma_cur_sector] mov edx, [dma_cur_sector]
cmp eax, edx cmp eax, edx
@@ -597,7 +597,7 @@ hd_read_dma:
; add edi, HD_CACHE+0x10000 ; add edi, HD_CACHE+0x10000
push eax push eax
call calculate_cache_2 call calculate_cache_2
add edi,eax add edi, eax
pop eax pop eax
mov ecx, 512/4 mov ecx, 512/4
@@ -683,8 +683,8 @@ hd_read_dma:
@@: @@:
cmp [hd_error], 0 cmp [hd_error], 0
jnz hd_read_error jnz hd_read_error
mov eax,[hdpos] mov eax, [hdpos]
mov [dma_hdpos],eax mov [dma_hdpos], eax
pop edx pop edx
pop eax pop eax
mov [dma_cur_sector], eax mov [dma_cur_sector], eax
@@ -692,28 +692,28 @@ hd_read_dma:
align 4 align 4
write_cache_sector: write_cache_sector:
mov [cache_chain_size],1 mov [cache_chain_size], 1
mov [cache_chain_pos],edi mov [cache_chain_pos], edi
write_cache_chain: write_cache_chain:
cmp [hdpos], 0x80 cmp [hdpos], 0x80
jae bd_write_cache_chain jae bd_write_cache_chain
mov eax,[cache_chain_ptr] mov eax, [cache_chain_ptr]
cmp dword[eax],0x10000000 cmp dword[eax], 0x10000000
jae .bad jae .bad
push esi push esi
mov eax, IDE_descriptor_table mov eax, IDE_descriptor_table
mov edx,eax mov edx, eax
pusha pusha
mov esi,[cache_chain_pos] mov esi, [cache_chain_pos]
shl esi, 9 shl esi, 9
call calculate_cache_2 call calculate_cache_2
add esi,eax add esi, eax
mov edi, (OS_BASE+IDE_DMA) mov edi, (OS_BASE+IDE_DMA)
mov dword [edx], IDE_DMA mov dword [edx], IDE_DMA
movzx ecx, [cache_chain_size] movzx ecx, [cache_chain_size]
shl ecx, 9 shl ecx, 9
mov word [edx+4], cx mov word [edx+4], cx
shr ecx,2 shr ecx, 2
cld cld
rep movsd rep movsd
popa popa
@@ -830,7 +830,7 @@ bd_read:
; add edi, HD_CACHE+0x10000 ; add edi, HD_CACHE+0x10000
push eax push eax
call calculate_cache_2 call calculate_cache_2
add edi,eax add edi, eax
pop eax pop eax
mov ecx, 512/4 mov ecx, 512/4

File diff suppressed because it is too large Load Diff

View File

@@ -18,33 +18,33 @@ calculatefatchain:
pushad pushad
mov esi,RAMDISK+512 mov esi, RAMDISK+512
mov edi,RAMDISK_FAT mov edi, RAMDISK_FAT
fcnew: fcnew:
mov eax,dword [esi] mov eax, dword [esi]
mov ebx,dword [esi+4] mov ebx, dword [esi+4]
mov ecx,dword [esi+8] mov ecx, dword [esi+8]
mov edx,ecx mov edx, ecx
shr edx,4 ;8 ok shr edx, 4;8 ok
shr dx,4 ;7 ok shr dx, 4;7 ok
xor ch,ch xor ch, ch
shld ecx,ebx,20 ;6 ok shld ecx, ebx, 20;6 ok
shr cx,4 ;5 ok shr cx, 4;5 ok
shld ebx,eax,12 shld ebx, eax, 12
and ebx,0x0fffffff ;4 ok and ebx, 0x0fffffff;4 ok
shr bx,4 ;3 ok shr bx, 4;3 ok
shl eax,4 shl eax, 4
and eax,0x0fffffff ;2 ok and eax, 0x0fffffff;2 ok
shr ax,4 ;1 ok shr ax, 4;1 ok
mov dword [edi],eax mov dword [edi], eax
mov dword [edi+4],ebx mov dword [edi+4], ebx
mov dword [edi+8],ecx mov dword [edi+8], ecx
mov dword [edi+12],edx mov dword [edi+12], edx
add edi,16 add edi, 16
add esi,12 add esi, 12
cmp edi,RAMDISK_FAT+2856*2 ;2849 clusters cmp edi, RAMDISK_FAT+2856*2;2849 clusters
jnz fcnew jnz fcnew
popad popad
@@ -55,29 +55,29 @@ restorefatchain: ; restore fat chain
pushad pushad
mov esi,RAMDISK_FAT mov esi, RAMDISK_FAT
mov edi,RAMDISK+512 mov edi, RAMDISK+512
fcnew2: fcnew2:
mov eax,dword [esi] mov eax, dword [esi]
mov ebx,dword [esi+4] mov ebx, dword [esi+4]
shl ax,4 shl ax, 4
shl eax,4 shl eax, 4
shl bx,4 shl bx, 4
shr ebx,4 shr ebx, 4
shrd eax,ebx,8 shrd eax, ebx, 8
shr ebx,8 shr ebx, 8
mov dword [edi],eax mov dword [edi], eax
mov word [edi+4],bx mov word [edi+4], bx
add edi,6 add edi, 6
add esi,8 add esi, 8
cmp edi,RAMDISK+512+4278 ;4274 bytes - all used FAT cmp edi, RAMDISK+512+4278;4274 bytes - all used FAT
jb fcnew2 jb fcnew2
mov esi,RAMDISK+512 ; duplicate fat chain mov esi, RAMDISK+512 ; duplicate fat chain
mov edi,RAMDISK+512+0x1200 mov edi, RAMDISK+512+0x1200
mov ecx,1069 ;4274/4 mov ecx, 1069;4274/4
cld cld
rep movsd rep movsd
@@ -94,10 +94,10 @@ ramdisk_free_space:
push eax ebx ecx push eax ebx ecx
mov edi,RAMDISK_FAT ;start of FAT mov edi, RAMDISK_FAT;start of FAT
xor ax,ax ;Free cluster=0x0000 in FAT xor ax, ax;Free cluster=0x0000 in FAT
xor ebx,ebx ;counter xor ebx, ebx;counter
mov ecx,2849 ;2849 clusters mov ecx, 2849;2849 clusters
cld cld
rdfs1: rdfs1:
repne scasw repne scasw
@@ -106,8 +106,8 @@ ramdisk_free_space:
test ecx, ecx test ecx, ecx
jnz rdfs1 jnz rdfs1
rdfs2: rdfs2:
shl ebx,9 ;free clusters*512 shl ebx, 9;free clusters*512
mov edi,ebx mov edi, ebx
pop ecx ebx eax pop ecx ebx eax
ret ret
@@ -122,38 +122,38 @@ expand_filename:
push esi edi ebx push esi edi ebx
mov edi,esp ; check for '.' in the name mov edi, esp ; check for '.' in the name
add edi,12+8 add edi, 12+8
mov esi,eax mov esi, eax
mov eax,edi mov eax, edi
mov [eax+0],dword ' ' mov [eax+0], dword ' '
mov [eax+4],dword ' ' mov [eax+4], dword ' '
mov [eax+8],dword ' ' mov [eax+8], dword ' '
flr1: flr1:
cmp [esi],byte '.' cmp [esi], byte '.'
jne flr2 jne flr2
mov edi,eax mov edi, eax
add edi,7 add edi, 7
jmp flr3 jmp flr3
flr2: flr2:
mov bl,[esi] mov bl, [esi]
mov [edi],bl mov [edi], bl
flr3: flr3:
inc esi inc esi
inc edi inc edi
mov ebx,eax mov ebx, eax
add ebx,11 add ebx, 11
cmp edi,ebx cmp edi, ebx
jbe flr1 jbe flr1
pop ebx edi esi pop ebx edi esi
@@ -174,59 +174,59 @@ fileread:
; eax = 0 ok read or other = errormsg ; eax = 0 ok read or other = errormsg
; ;
;-------------------------------------------------------------- ;--------------------------------------------------------------
test ebx,ebx ;if ebx=0 - set to 1 test ebx, ebx;if ebx=0 - set to 1
jnz frfl5 jnz frfl5
inc ebx inc ebx
frfl5: frfl5:
test ecx,ecx ;if ecx=0 - set to 1 test ecx, ecx;if ecx=0 - set to 1
jnz frfl6 jnz frfl6
inc ecx inc ecx
frfl6: frfl6:
test esi,esi ; return ramdisk root test esi, esi ; return ramdisk root
jnz fr_noroot ;if not root jnz fr_noroot ;if not root
cmp ebx,14 ;14 clusters=root dir cmp ebx, 14 ;14 clusters=root dir
ja oorr ja oorr
cmp ecx,14 cmp ecx, 14
ja oorr ja oorr
jmp fr_do jmp fr_do
oorr: oorr:
mov eax,5 ;out of root range (fnf) mov eax, 5 ;out of root range (fnf)
xor ebx,ebx xor ebx, ebx
dec ebx ;0xffffffff dec ebx ;0xffffffff
ret ret
fr_do: ;reading rootdir fr_do: ;reading rootdir
mov edi,edx mov edi, edx
dec ebx dec ebx
push edx push edx
mov edx,ecx mov edx, ecx
add edx,ebx add edx, ebx
cmp edx,15 ;ebx+ecx=14+1 cmp edx, 15 ;ebx+ecx=14+1
pushf pushf
jbe fr_do1 jbe fr_do1
sub edx,14 sub edx, 14
sub ecx,edx sub ecx, edx
fr_do1: fr_do1:
shl ebx,9 shl ebx, 9
mov esi,RAMDISK+512*19 mov esi, RAMDISK+512*19
add esi,ebx add esi, ebx
shl ecx,7 shl ecx, 7
cld cld
rep movsd rep movsd
popf popf
pop edx pop edx
jae fr_do2 jae fr_do2
xor eax,eax ; ok read xor eax, eax; ok read
xor ebx,ebx xor ebx, ebx
ret ret
fr_do2: ;if last cluster fr_do2: ;if last cluster
mov eax,6 ;end of file mov eax, 6;end of file
xor ebx,ebx xor ebx, ebx
ret ret
fr_noroot: fr_noroot:
sub esp,32 sub esp, 32
call expand_filename call expand_filename
dec ebx dec ebx
@@ -236,66 +236,66 @@ fileread:
push eax ebx ecx edx esi edi push eax ebx ecx edx esi edi
call rd_findfile call rd_findfile
je fifound je fifound
add esp,32+28 ;if file not found add esp, 32+28 ;if file not found
ret ret
fifound: fifound:
mov ebx,[edi-11+28] ;file size mov ebx, [edi-11+28] ;file size
mov [esp+20],ebx mov [esp+20], ebx
mov [esp+24],ebx mov [esp+24], ebx
add edi,0xf add edi, 0xf
movzx eax,word [edi] movzx eax, word [edi]
mov edi,eax ;edi=cluster mov edi, eax ;edi=cluster
frnew: frnew:
add eax,31 ;bootsector+2*fat+filenames add eax, 31 ;bootsector+2*fat+filenames
shl eax,9 ;*512 shl eax, 9 ;*512
add eax,RAMDISK ;image base add eax, RAMDISK ;image base
mov ebx,[esp+8] mov ebx, [esp+8]
mov ecx,512 ;[esp+4] mov ecx, 512 ;[esp+4]
cmp [esp+16],dword 0 ; wanted cluster ? cmp [esp+16], dword 0 ; wanted cluster ?
jne frfl7 jne frfl7
call memmove call memmove
add [esp+8],dword 512 add [esp+8], dword 512
dec dword [esp+12] ; last wanted cluster ? dec dword [esp+12] ; last wanted cluster ?
je frnoread je frnoread
jmp frfl8 jmp frfl8
frfl7: frfl7:
dec dword [esp+16] dec dword [esp+16]
frfl8: frfl8:
movzx eax,word [edi*2+RAMDISK_FAT] ; find next cluster from FAT movzx eax, word [edi*2+RAMDISK_FAT] ; find next cluster from FAT
mov edi,eax mov edi, eax
cmp edi,4095 ;eof - cluster cmp edi, 4095 ;eof - cluster
jz frnoread2 jz frnoread2
cmp [esp+24],dword 512 ;eof - size cmp [esp+24], dword 512 ;eof - size
jb frnoread jb frnoread
sub [esp+24],dword 512 sub [esp+24], dword 512
jmp frnew jmp frnew
frnoread2: frnoread2:
cmp [esp+16],dword 0 ; eof without read ? cmp [esp+16], dword 0 ; eof without read ?
je frnoread je frnoread
pop edi esi edx ecx pop edi esi edx ecx
add esp,4 add esp, 4
pop ebx ; ebx <- eax : size of file pop ebx ; ebx <- eax : size of file
add esp,36 add esp, 36
mov eax,6 ; end of file mov eax, 6 ; end of file
ret ret
frnoread: frnoread:
pop edi esi edx ecx pop edi esi edx ecx
add esp,4 add esp, 4
pop ebx ; ebx <- eax : size of file pop ebx ; ebx <- eax : size of file
add esp,36 add esp, 36
xor eax,eax ;read ok xor eax, eax;read ok
ret ret
@@ -304,19 +304,19 @@ fileread:
;by Mihasik ;by Mihasik
;IN: eax - pointer to filename OUT: filestring+11 in edi or notZero in flags and fnf in eax,ebx ;IN: eax - pointer to filename OUT: filestring+11 in edi or notZero in flags and fnf in eax,ebx
mov edi,RAMDISK+512*18+512 ;Point at directory mov edi, RAMDISK+512*18+512;Point at directory
cld cld
rd_newsearch: rd_newsearch:
mov esi,eax mov esi, eax
mov ecx,11 mov ecx, 11
rep cmpsb rep cmpsb
je rd_ff je rd_ff
add cl,21 add cl, 21
add edi,ecx add edi, ecx
cmp edi,RAMDISK+512*33 cmp edi, RAMDISK+512*33
jb rd_newsearch jb rd_newsearch
mov eax,5 ;if file not found - eax=5 mov eax, 5 ;if file not found - eax=5
xor ebx,ebx xor ebx, ebx
dec ebx ;ebx=0xffffffff and zf=0 dec ebx ;ebx=0xffffffff and zf=0
rd_ff: rd_ff:
ret ret
@@ -1169,7 +1169,8 @@ fat_next_short_name:
add edi, 6 add edi, 6
cmp word [edi], ' ' cmp word [edi], ' '
jnz .insert_tilde jnz .insert_tilde
@@: dec edi @@:
dec edi
cmp byte [edi], ' ' cmp byte [edi], ' '
jz @b jz @b
inc edi inc edi

View File

@@ -0,0 +1,119 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) 2010 KolibriOS team. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;; ;;
;; PCIe.INC ;;
;; ;;
;; Extended PCI express services ;;
;; ;;
;; art_zh <artem@jerdev.co.uk> ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 1463 $
;***************************************************************************
; Function
; pci_ext_config:
;
; Description
; PCIe extended (memory-mapped) config space detection
;
; WARNINGs:
; 1) Very Experimental!
; 2) direct HT-detection (no ACPI or BIOS service used)
; 3) Only AMD/HT processors currently supported
;
;***************************************************************************
PCIe_CONFIG_SPACE equ 0xF0000000 ; to be moved to const.inc
mmio_pcie_cfg_addr dd 0x0 ; intel pcie space may be defined here
mmio_pcie_cfg_lim dd 0x0 ; upper pcie space address
align 4
pci_ext_config:
mov ebx, [mmio_pcie_cfg_addr]
or ebx, ebx
jz @f
or ebx, 0x7FFFFFFF ; required by PCI-SIG standards
jnz .pcie_failed
add ebx, 0x0FFFFC
cmp ebx, [mmio_pcie_cfg_lim]; is the space limit correct?
ja .pcie_failed
jmp .pcie_cfg_mapped
@@:
mov ebx, [cpu_vendor]
cmp ebx, dword [AMD_str]
jne .pcie_failed
mov bx, 0xC184 ; dev = 24, fn = 01, reg = 84h
.check_HT_mmio:
mov cx, bx
mov ax, 0x0002 ; bus = 0, 1dword to read
call pci_read_reg
mov bx, cx
sub bl, 4
and al, 0x80 ; check the NP bit
jz .no_pcie_cfg
shl eax, 8 ; bus:[27..20], dev:[19:15]
or eax, 0x00007FFC ; fun:[14..12], reg:[11:2]
mov [mmio_pcie_cfg_lim], eax
mov cl, bl
mov ax, 0x0002 ; bus = 0, 1dword to read
call pci_read_reg
mov bx, cx
test al, 0x03 ; MMIO Base RW enabled?
jz .no_pcie_cfg
test al, 0x0C ; MMIO Base locked?
jnz .no_pcie_cfg
xor al, al
shl eax, 8
test eax, 0x000F0000 ; MMIO Base must be bus0-aligned
jnz .no_pcie_cfg
mov [mmio_pcie_cfg_addr], eax
add eax, 0x000FFFFC
sub eax, [mmio_pcie_cfg_lim]; MMIO must cover at least one bus
ja .no_pcie_cfg
; -- it looks like a true PCIe config space;
mov eax, [mmio_pcie_cfg_addr] ; physical address
or eax, (PG_SHARED + PG_LARGE + PG_USER)
mov ebx, PCIe_CONFIG_SPACE ; linear address
mov ecx, ebx
shr ebx, 20
add ebx, sys_pgdir ; PgDir entry @
@@:
mov dword[ebx], eax ; map 4 buses
invlpg [ecx]
cmp bl, 4
jz .pcie_cfg_mapped ; fix it later
add bl, 4 ; next PgDir entry
add eax, 0x400000 ; eax += 4M
add ecx, 0x400000
jmp @b
.pcie_cfg_mapped:
; -- glad to have the extended PCIe config field found
; mov esi, boot_pcie_ok
; call boot_log
ret ; <<<<<<<<<<< OK >>>>>>>>>>>
.no_pcie_cfg:
xor eax, eax
mov [mmio_pcie_cfg_addr], eax
mov [mmio_pcie_cfg_lim], eax
add bl, 12
cmp bl, 0xC0 ; MMIO regs lay below this offset
jb .check_HT_mmio
.pcie_failed:
; mov esi, boot_pcie_fail
; call boot_log
ret ; <<<<<<<<< FAILURE >>>>>>>>>

View File

@@ -22,30 +22,30 @@ init_pci_16:
pushad pushad
xor ax,ax xor ax, ax
mov es,ax mov es, ax
mov byte [es:0x9020],1 ;default mechanism:1 mov byte [es:0x9020], 1;default mechanism:1
mov ax,0xb101 mov ax, 0xb101
int 0x1a int 0x1a
or ah,ah or ah, ah
jnz pci16skip jnz pci16skip
mov [es:0x9021],cl ;last PCI bus in system mov [es:0x9021], cl;last PCI bus in system
mov [es:0x9022],bx mov [es:0x9022], bx
mov [es:0x9024],edi mov [es:0x9024], edi
; we have a PCI BIOS, so check which configuration mechanism(s) ; we have a PCI BIOS, so check which configuration mechanism(s)
; it supports ; it supports
; AL = PCI hardware characteristics (bit0 => mechanism1, bit1 => mechanism2) ; AL = PCI hardware characteristics (bit0 => mechanism1, bit1 => mechanism2)
test al,1 test al, 1
jnz pci16skip jnz pci16skip
test al,2 test al, 2
jz pci16skip jz pci16skip
mov byte [es:0x9020],2 ; if (al&3)==2 => mechanism 2 mov byte [es:0x9020], 2; if (al&3)==2 => mechanism 2
pci16skip: pci16skip:
mov ax,0x1000 mov ax, 0x1000
mov es,ax mov es, ax
popad popad

View File

@@ -32,63 +32,91 @@ $Revision$
;*************************************************************************** ;***************************************************************************
;mmio_pci_addr equ 0x400 ; set actual PCI address here to activate user-MMIO ;mmio_pci_addr equ 0x400 ; set actual PCI address here to activate user-MMIO
iglobal
align 4
f62call:
dd pci_fn_0
dd pci_fn_1
dd pci_fn_2
dd pci_service_not_supported ;3
dd pci_read_reg ;4 byte
dd pci_read_reg ;5 word
dd pci_read_reg ;6 dword
dd pci_service_not_supported ;7
dd pci_write_reg ;8 byte
dd pci_write_reg ;9 word
dd pci_write_reg ;10 dword
if defined mmio_pci_addr
dd pci_mmio_init ;11
dd pci_mmio_map ;12
dd pci_mmio_unmap ;13
end if
endg
align 4 align 4
pci_api: pci_api:
cmp [pci_access_enabled],1 ;cross
jne no_pci_access_for_applications mov eax, ebx
mov ebx, ecx
mov ecx, edx
or al,al cmp [pci_access_enabled], 1
jnz pci_fn_1 jne pci_service_not_supported
; PCI function 0: get pci version (AH.AL)
movzx eax,word [BOOT_VAR+0x9022] movzx edx, al
if defined mmio_pci_addr
cmp al, 13
ja pci_service_not_supported
else
cmp al, 10
ja pci_service_not_supported
end if
call dword [f62call+edx*4]
mov dword [esp+32], eax
ret
align 4
pci_api_drv:
cmp [pci_access_enabled], 1
jne .fail
cmp eax, 2
ja .fail
jmp dword [f62call+eax*4]
.fail:
or eax, -1
ret
;; ============================================
pci_fn_0:
; PCI function 0: get pci version (AH.AL)
movzx eax, word [BOOT_VAR+0x9022]
ret ret
pci_fn_1: pci_fn_1:
cmp al,1 ; PCI function 1: get last bus in AL
jnz pci_fn_2 mov al, [BOOT_VAR+0x9021]
; PCI function 1: get last bus in AL
mov al,[BOOT_VAR+0x9021]
ret ret
pci_fn_2: pci_fn_2:
cmp al,2 ; PCI function 2: get pci access mechanism
jne pci_fn_3 mov al, [BOOT_VAR+0x9020]
; PCI function 2: get pci access mechanism
mov al,[BOOT_VAR+0x9020]
ret ret
pci_fn_3:
cmp al,4
jz pci_read_reg ;byte
cmp al,5
jz pci_read_reg ;word
cmp al,6
jz pci_read_reg ;dword
cmp al,8
jz pci_write_reg ;byte
cmp al,9
jz pci_write_reg ;word
cmp al,10
jz pci_write_reg ;dword
if defined mmio_pci_addr
cmp al,11 ; user-level MMIO functions
jz pci_mmio_init
cmp al,12
jz pci_mmio_map
cmp al,13
jz pci_mmio_unmap
end if
no_pci_access_for_applications:
or eax,-1
pci_service_not_supported:
or eax, -1
mov dword [esp+32], eax
ret ret
;*************************************************************************** ;***************************************************************************
@@ -107,10 +135,10 @@ end if
align 4 align 4
pci_make_config_cmd: pci_make_config_cmd:
shl eax,8 ; move bus to bits 16-23 shl eax, 8 ; move bus to bits 16-23
mov ax,bx ; combine all mov ax, bx ; combine all
and eax,0xffffff and eax, 0xffffff
or eax,0x80000000 or eax, 0x80000000
ret ret
;*************************************************************************** ;***************************************************************************
@@ -127,118 +155,118 @@ pci_make_config_cmd:
align 4 align 4
pci_read_reg: pci_read_reg:
cmp byte [BOOT_VAR+0x9020],2 ;what mechanism will we use? cmp byte [BOOT_VAR+0x9020], 2;what mechanism will we use?
je pci_read_reg_2 je pci_read_reg_2
; mechanism 1 ; mechanism 1
push esi ; save register size into ESI push esi ; save register size into ESI
mov esi,eax mov esi, eax
and esi,3 and esi, 3
call pci_make_config_cmd call pci_make_config_cmd
mov ebx,eax mov ebx, eax
; get current state ; get current state
mov dx,0xcf8 mov dx, 0xcf8
in eax, dx in eax, dx
push eax push eax
; set up addressing to config data ; set up addressing to config data
mov eax,ebx mov eax, ebx
and al,0xfc ; make address dword-aligned and al, 0xfc; make address dword-aligned
out dx,eax out dx, eax
; get requested DWORD of config data ; get requested DWORD of config data
mov dl,0xfc mov dl, 0xfc
and bl,3 and bl, 3
or dl,bl ; add to port address first 2 bits of register address or dl, bl ; add to port address first 2 bits of register address
or esi,esi or esi, esi
jz pci_read_byte1 jz pci_read_byte1
cmp esi,1 cmp esi, 1
jz pci_read_word1 jz pci_read_word1
cmp esi,2 cmp esi, 2
jz pci_read_dword1 jz pci_read_dword1
jmp pci_fin_read1 jmp pci_fin_read1
pci_read_byte1: pci_read_byte1:
in al,dx in al, dx
jmp pci_fin_read1 jmp pci_fin_read1
pci_read_word1: pci_read_word1:
in ax,dx in ax, dx
jmp pci_fin_read1 jmp pci_fin_read1
pci_read_dword1: pci_read_dword1:
in eax,dx in eax, dx
jmp pci_fin_read1 jmp pci_fin_read1
pci_fin_read1: pci_fin_read1:
; restore configuration control ; restore configuration control
xchg eax,[esp] xchg eax, [esp]
mov dx,0xcf8 mov dx, 0xcf8
out dx,eax out dx, eax
pop eax pop eax
pop esi pop esi
ret ret
pci_read_reg_2: pci_read_reg_2:
test bh,128 ;mech#2 only supports 16 devices per bus test bh, 128 ;mech#2 only supports 16 devices per bus
jnz pci_read_reg_err jnz pci_read_reg_err
push esi ; save register size into ESI push esi; save register size into ESI
mov esi,eax mov esi, eax
and esi,3 and esi, 3
push eax push eax
;store current state of config space ;store current state of config space
mov dx,0xcf8 mov dx, 0xcf8
in al,dx in al, dx
mov ah,al mov ah, al
mov dl,0xfa mov dl, 0xfa
in al,dx in al, dx
xchg eax,[esp] xchg eax, [esp]
; out 0xcfa,bus ; out 0xcfa,bus
mov al,ah mov al, ah
out dx,al out dx, al
; out 0xcf8,0x80 ; out 0xcf8,0x80
mov dl,0xf8 mov dl, 0xf8
mov al,0x80 mov al, 0x80
out dx,al out dx, al
; compute addr ; compute addr
shr bh,3 ; func is ignored in mechanism 2 shr bh, 3; func is ignored in mechanism 2
or bh,0xc0 or bh, 0xc0
mov dx,bx mov dx, bx
or esi,esi or esi, esi
jz pci_read_byte2 jz pci_read_byte2
cmp esi,1 cmp esi, 1
jz pci_read_word2 jz pci_read_word2
cmp esi,2 cmp esi, 2
jz pci_read_dword2 jz pci_read_dword2
jmp pci_fin_read2 jmp pci_fin_read2
pci_read_byte2: pci_read_byte2:
in al,dx in al, dx
jmp pci_fin_read2 jmp pci_fin_read2
pci_read_word2: pci_read_word2:
in ax,dx in ax, dx
jmp pci_fin_read2 jmp pci_fin_read2
pci_read_dword2: pci_read_dword2:
in eax,dx in eax, dx
; jmp pci_fin_read2 ; jmp pci_fin_read2
pci_fin_read2: pci_fin_read2:
; restore configuration space ; restore configuration space
xchg eax,[esp] xchg eax, [esp]
mov dx,0xcfa mov dx, 0xcfa
out dx,al out dx, al
mov dl,0xf8 mov dl, 0xf8
mov al,ah mov al, ah
out dx,al out dx, al
pop eax pop eax
pop esi pop esi
ret ret
pci_read_reg_err: pci_read_reg_err:
xor eax,eax xor eax, eax
dec eax dec eax
ret ret
@@ -258,122 +286,122 @@ pci_read_reg_err:
align 4 align 4
pci_write_reg: pci_write_reg:
cmp byte [BOOT_VAR+0x9020],2 ;what mechanism will we use? cmp byte [BOOT_VAR+0x9020], 2;what mechanism will we use?
je pci_write_reg_2 je pci_write_reg_2
; mechanism 1 ; mechanism 1
push esi ; save register size into ESI push esi ; save register size into ESI
mov esi,eax mov esi, eax
and esi,3 and esi, 3
call pci_make_config_cmd call pci_make_config_cmd
mov ebx,eax mov ebx, eax
; get current state into ecx ; get current state into ecx
mov dx,0xcf8 mov dx, 0xcf8
in eax, dx in eax, dx
push eax push eax
; set up addressing to config data ; set up addressing to config data
mov eax,ebx mov eax, ebx
and al,0xfc ; make address dword-aligned and al, 0xfc; make address dword-aligned
out dx,eax out dx, eax
; write DWORD of config data ; write DWORD of config data
mov dl,0xfc mov dl, 0xfc
and bl,3 and bl, 3
or dl,bl or dl, bl
mov eax,ecx mov eax, ecx
or esi,esi or esi, esi
jz pci_write_byte1 jz pci_write_byte1
cmp esi,1 cmp esi, 1
jz pci_write_word1 jz pci_write_word1
cmp esi,2 cmp esi, 2
jz pci_write_dword1 jz pci_write_dword1
jmp pci_fin_write1 jmp pci_fin_write1
pci_write_byte1: pci_write_byte1:
out dx,al out dx, al
jmp pci_fin_write1 jmp pci_fin_write1
pci_write_word1: pci_write_word1:
out dx,ax out dx, ax
jmp pci_fin_write1 jmp pci_fin_write1
pci_write_dword1: pci_write_dword1:
out dx,eax out dx, eax
jmp pci_fin_write1 jmp pci_fin_write1
pci_fin_write1: pci_fin_write1:
; restore configuration control ; restore configuration control
pop eax pop eax
mov dl,0xf8 mov dl, 0xf8
out dx,eax out dx, eax
xor eax,eax xor eax, eax
pop esi pop esi
ret ret
pci_write_reg_2: pci_write_reg_2:
test bh,128 ;mech#2 only supports 16 devices per bus test bh, 128 ;mech#2 only supports 16 devices per bus
jnz pci_write_reg_err jnz pci_write_reg_err
push esi ; save register size into ESI push esi; save register size into ESI
mov esi,eax mov esi, eax
and esi,3 and esi, 3
push eax push eax
;store current state of config space ;store current state of config space
mov dx,0xcf8 mov dx, 0xcf8
in al,dx in al, dx
mov ah,al mov ah, al
mov dl,0xfa mov dl, 0xfa
in al,dx in al, dx
xchg eax,[esp] xchg eax, [esp]
; out 0xcfa,bus ; out 0xcfa,bus
mov al,ah mov al, ah
out dx,al out dx, al
; out 0xcf8,0x80 ; out 0xcf8,0x80
mov dl,0xf8 mov dl, 0xf8
mov al,0x80 mov al, 0x80
out dx,al out dx, al
; compute addr ; compute addr
shr bh,3 ; func is ignored in mechanism 2 shr bh, 3; func is ignored in mechanism 2
or bh,0xc0 or bh, 0xc0
mov dx,bx mov dx, bx
; write register ; write register
mov eax,ecx mov eax, ecx
or esi,esi or esi, esi
jz pci_write_byte2 jz pci_write_byte2
cmp esi,1 cmp esi, 1
jz pci_write_word2 jz pci_write_word2
cmp esi,2 cmp esi, 2
jz pci_write_dword2 jz pci_write_dword2
jmp pci_fin_write2 jmp pci_fin_write2
pci_write_byte2: pci_write_byte2:
out dx,al out dx, al
jmp pci_fin_write2 jmp pci_fin_write2
pci_write_word2: pci_write_word2:
out dx,ax out dx, ax
jmp pci_fin_write2 jmp pci_fin_write2
pci_write_dword2: pci_write_dword2:
out dx,eax out dx, eax
jmp pci_fin_write2 jmp pci_fin_write2
pci_fin_write2: pci_fin_write2:
; restore configuration space ; restore configuration space
pop eax pop eax
mov dx,0xcfa mov dx, 0xcfa
out dx,al out dx, al
mov dl,0xf8 mov dl, 0xf8
mov al,ah mov al, ah
out dx,al out dx, al
xor eax,eax xor eax, eax
pop esi pop esi
ret ret
pci_write_reg_err: pci_write_reg_err:
xor eax,eax xor eax, eax
dec eax dec eax
ret ret
@@ -393,15 +421,15 @@ if defined mmio_pci_addr ; must be set above
pci_mmio_init: pci_mmio_init:
cmp bx, mmio_pci_addr cmp bx, mmio_pci_addr
jz @f jz @f
mov eax,-2 mov eax, -2
ret ret
@@: @@:
call init_heap ; (if not initialized yet) call init_heap ; (if not initialized yet)
or eax,eax or eax, eax
jz @f jz @f
ret ret
@@: @@:
mov eax,-3 mov eax, -3
ret ret
@@ -431,44 +459,45 @@ pci_mmio_init:
;*************************************************************************** ;***************************************************************************
pci_mmio_map: pci_mmio_map:
and edx,0x0ffff and edx, 0x0ffff
cmp ah,6 cmp ah, 6
jc .bar_0_5 jc .bar_0_5
jz .bar_rom jz .bar_rom
mov eax,-2 mov eax, -2
ret ret
.bar_rom: .bar_rom:
mov ah, 8 ; bar6 = Expansion ROM base address mov ah, 8 ; bar6 = Expansion ROM base address
.bar_0_5: .bar_0_5:
push ecx push ecx
add ebx, 4095 add ebx, 4095
and ebx,-4096 and ebx, -4096
push ebx push ebx
mov bl, ah ; bl = BAR# (0..5), however bl=8 for BAR6 mov bl, ah ; bl = BAR# (0..5), however bl=8 for BAR6
shl bl, 1 shl bl, 1
shl bl, 1 shl bl, 1
add bl, 0x10 ; now bl = BAR offset in PCI config. space add bl, 0x10; now bl = BAR offset in PCI config. space
mov ax, mmio_pci_addr mov ax, mmio_pci_addr
mov bh, al ; bh = dddddfff mov bh, al ; bh = dddddfff
mov al, 2 ; al : DW to read mov al, 2 ; al : DW to read
call pci_read_reg call pci_read_reg
or eax, eax or eax, eax
jnz @f jnz @f
mov eax,-3 ; empty I/O space mov eax, -3 ; empty I/O space
jmp mmio_ret_fail jmp mmio_ret_fail
@@: @@:
test eax, 1 test eax, 1
jz @f jz @f
mov eax,-4 ; damned ports (not MMIO space) mov eax, -4 ; damned ports (not MMIO space)
jmp mmio_ret_fail jmp mmio_ret_fail
@@: @@:
pop ecx ; ecx = block size, bytes (expanded to whole page) pop ecx ; ecx = block size, bytes (expanded to whole page)
mov ebx, ecx ; user_alloc destroys eax, ecx, edx, but saves ebx mov ebx, ecx; user_alloc destroys eax, ecx, edx, but saves ebx
and eax, 0xFFFFFFF0
push eax ; store MMIO physical address + keep 2DWords in the stack push eax ; store MMIO physical address + keep 2DWords in the stack
stdcall user_alloc, ecx stdcall user_alloc, ecx
or eax, eax or eax, eax
jnz mmio_map_over jnz mmio_map_over
mov eax,-5 ; problem with page allocation mov eax, -5 ; problem with page allocation
mmio_ret_fail: mmio_ret_fail:
pop ecx pop ecx
@@ -476,13 +505,13 @@ mmio_ret_fail:
ret ret
mmio_map_over: mmio_map_over:
mov ecx, ebx ; ecx = size (bytes, expanded to whole page) mov ecx, ebx; ecx = size (bytes, expanded to whole page)
shr ecx, 12 ; ecx = number of pages shr ecx, 12 ; ecx = number of pages
mov ebx, eax ; ebx = linear address mov ebx, eax; ebx = linear address
pop eax ; eax = MMIO start pop eax ; eax = MMIO start
pop edx ; edx = MMIO shift (pages) pop edx ; edx = MMIO shift (pages)
shl edx, 12 ; edx = MMIO shift (bytes) shl edx, 12 ; edx = MMIO shift (bytes)
add eax, edx ; eax = uMMIO physical address add eax, edx; eax = uMMIO physical address
or eax, PG_SHARED or eax, PG_SHARED
or eax, PG_UW or eax, PG_UW
or eax, PG_NOCACHE or eax, PG_NOCACHE
@@ -516,7 +545,8 @@ end if
uglobal uglobal
align 4 align 4
; VendID (2), DevID (2), Revision = 0 (1), Class Code (3), FNum (1), Bus (1) ; VendID (2), DevID (2), Revision = 0 (1), Class Code (3), FNum (1), Bus (1)
pci_emu_dat: times 30*10 db 0 pci_emu_dat:
times 30*10 db 0
endg endg
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
align 4 align 4
@@ -540,9 +570,9 @@ sys_pcibios:
cmp ebp, 1 ; PCI_FUNCTION_ID cmp ebp, 1 ; PCI_FUNCTION_ID
jnz .not_PCI_BIOS_PRESENT jnz .not_PCI_BIOS_PRESENT
mov edx, 'PCI ' mov edx, 'PCI '
mov al, [OS_BASE+0x2F0000 + 0x9020] mov al, [BOOT_VAR + 0x9020]
mov bx, [OS_BASE+0x2F0000 + 0x9022] mov bx, [BOOT_VAR + 0x9022]
mov cl, [OS_BASE+0x2F0000 + 0x9021] mov cl, [BOOT_VAR + 0x9021]
xor ah, ah xor ah, ah
jmp .return_abcd jmp .return_abcd
@@ -550,7 +580,8 @@ sys_pcibios:
cmp ebp, 2 ; FIND_PCI_DEVICE cmp ebp, 2 ; FIND_PCI_DEVICE
jne .not_FIND_PCI_DEVICE jne .not_FIND_PCI_DEVICE
mov ebx, pci_emu_dat mov ebx, pci_emu_dat
..nxt: cmp [ebx], dx ..nxt:
cmp [ebx], dx
jne ..no jne ..no
cmp [ebx + 2], cx cmp [ebx + 2], cx
jne ..no jne ..no
@@ -559,7 +590,8 @@ sys_pcibios:
mov bx, [ebx + 4] mov bx, [ebx + 4]
xor ah, ah xor ah, ah
jmp .return_ab jmp .return_ab
..no: cmp word[ebx], 0 ..no:
cmp word[ebx], 0
je ..dev_not_found je ..dev_not_found
add ebx, 10 add ebx, 10
jmp ..nxt jmp ..nxt
@@ -572,12 +604,14 @@ sys_pcibios:
jne .not_FIND_PCI_CLASS_CODE jne .not_FIND_PCI_CLASS_CODE
mov esi, pci_emu_dat mov esi, pci_emu_dat
shl ecx, 8 shl ecx, 8
..nxt2: cmp [esi], ecx ..nxt2:
cmp [esi], ecx
jne ..no2 jne ..no2
mov bx, [esi] mov bx, [esi]
xor ah, ah xor ah, ah
jmp .return_ab jmp .return_ab
..no2: cmp dword[esi], 0 ..no2:
cmp dword[esi], 0
je ..dev_not_found je ..dev_not_found
add esi, 10 add esi, 10
jmp ..nxt2 jmp ..nxt2
@@ -612,7 +646,8 @@ sys_pcibios:
.not_WRITE_CONFIG: .not_WRITE_CONFIG:
.unsupported_func: .unsupported_func:
mov ah, 0x81 ; FUNC_NOT_SUPPORTED mov ah, 0x81 ; FUNC_NOT_SUPPORTED
.return:mov dword[esp + 4 ], edi .return:
mov dword[esp + 4 ], edi
mov dword[esp + 8], esi mov dword[esp + 8], esi
.return_abcd: .return_abcd:
mov dword[esp + 24], edx mov dword[esp + 24], edx

View File

@@ -143,44 +143,41 @@ SSE_FZ equ 0x8000
SSE_INIT equ (SSE_IM+SSE_DM+SSE_ZM+SSE_OM+SSE_UM+SSE_PM) SSE_INIT equ (SSE_IM+SSE_DM+SSE_ZM+SSE_OM+SSE_UM+SSE_PM)
IRQ_PIC equ 0
IRQ_APIC equ 1
struc TSS struct TSS
{ _back rw 2
._back rw 2 _esp0 rd 1
._esp0 rd 1 _ss0 rw 2
._ss0 rw 2 _esp1 rd 1
._esp1 rd 1 _ss1 rw 2
._ss1 rw 2 _esp2 rd 1
._esp2 rd 1 _ss2 rw 2
._ss2 rw 2 _cr3 rd 1
._cr3 rd 1 _eip rd 1
._eip rd 1 _eflags rd 1
._eflags rd 1 _eax rd 1
._eax rd 1 _ecx rd 1
._ecx rd 1 _edx rd 1
._edx rd 1 _ebx rd 1
._ebx rd 1 _esp rd 1
._esp rd 1 _ebp rd 1
._ebp rd 1 _esi rd 1
._esi rd 1 _edi rd 1
._edi rd 1 _es rw 2
._es rw 2 _cs rw 2
._cs rw 2 _ss rw 2
._ss rw 2 _ds rw 2
._ds rw 2 _fs rw 2
._fs rw 2 _gs rw 2
._gs rw 2 _ldt rw 2
._ldt rw 2 _trap rw 1
._trap rw 1 _io rw 1
._io rw 1
rb 24 rb 24
._io_map_0 rb 4096 _io_map_0 rb 4096
._io_map_1 rb 4096 _io_map_1 rb 4096
} ends
virtual at 0
TSS TSS
end virtual
TSS_SIZE equ (128+8192) TSS_SIZE equ (128+8192)
@@ -247,19 +244,20 @@ ScreenBPP equ (OS_BASE+0x000FBF1)
;unused ? only one reference ;unused ? only one reference
MOUSE_BUFF_COUNT equ (OS_BASE+0x000FCFF) MOUSE_BUFF_COUNT equ (OS_BASE+0x000FCFF)
LFBAddress equ (OS_BASE+0x000FE80)
MEM_AMOUNT equ (OS_BASE+0x000FE8C)
Screen_Max_X equ (OS_BASE+0x000FE00) Screen_Max_X equ (OS_BASE+0x000FE00)
Screen_Max_Y equ (OS_BASE+0x000FE04) Screen_Max_Y equ (OS_BASE+0x000FE04)
BytesPerScanLine equ (OS_BASE+0x000FE08) BytesPerScanLine equ (OS_BASE+0x000FE08)
SCR_MODE equ (OS_BASE+0x000FE0C) SCR_MODE equ (OS_BASE+0x000FE0C)
LFBAddress equ (OS_BASE+0x000FE80)
BTN_ADDR equ (OS_BASE+0x000FE88) BTN_ADDR equ (OS_BASE+0x000FE88)
MEM_AMOUNT equ (OS_BASE+0x000FE8C)
SYS_SHUTDOWN equ (OS_BASE+0x000FF00) SYS_SHUTDOWN equ (OS_BASE+0x000FF00)
TASK_ACTIVATE equ (OS_BASE+0x000FF01) TASK_ACTIVATE equ (OS_BASE+0x000FF01)
REDRAW_BACKGROUND equ (OS_BASE+0x000FFF0) REDRAW_BACKGROUND equ (OS_BASE+0x000FFF0)
BACKGROUND_CHANGED equ (OS_BASE+0x000FFF1)
BANK_RW equ (OS_BASE+0x000FFF2) BANK_RW equ (OS_BASE+0x000FFF2)
MOUSE_BACKGROUND equ (OS_BASE+0x000FFF4) MOUSE_BACKGROUND equ (OS_BASE+0x000FFF4)
DONT_DRAW_MOUSE equ (OS_BASE+0x000FFF5) DONT_DRAW_MOUSE equ (OS_BASE+0x000FFF5)
@@ -285,32 +283,34 @@ RAMDISK equ (OS_BASE+0x0100000)
RAMDISK_FAT equ (OS_BASE+0x0280000) RAMDISK_FAT equ (OS_BASE+0x0280000)
FLOPPY_FAT equ (OS_BASE+0x0282000) FLOPPY_FAT equ (OS_BASE+0x0282000)
CLEAN_ZONE equ 0x284000
IDE_DMA equ 0x284000 IDE_DMA equ 0x284000
BgrAuxTable equ (OS_BASE+0x0298000) BgrAuxTable equ (OS_BASE+0x0298000)
; unused? ; unused?
SB16Buffer equ (OS_BASE+0x2A0000) SB16Buffer equ (OS_BASE+0x02A0000)
SB16_Status equ (OS_BASE+0x02B0000) SB16_Status equ (OS_BASE+0x02B0000)
BUTTON_INFO equ (OS_BASE+0x02C0000) BUTTON_INFO equ (OS_BASE+0x02C0000)
RESERVED_PORTS equ (OS_BASE+0x02D0000) RESERVED_PORTS equ (OS_BASE+0x02D0000)
IRQ_SAVE equ (OS_BASE+0x02E0000) BOOT_VAR equ (OS_BASE+0x02E0000)
BOOT_VAR equ (OS_BASE+0x02f0000)
stack_data_start equ (OS_BASE+0x0300000) stack_data_start equ (OS_BASE+0x02F0000)
eth_data_start equ (OS_BASE+0x0300000) eth_data_start equ (OS_BASE+0x02F0000)
stack_data equ (OS_BASE+0x0304000) stack_data equ (OS_BASE+0x02F4000)
stack_data_end equ (OS_BASE+0x031ffff) stack_data_end equ (OS_BASE+0x030ffff)
resendQ equ (OS_BASE+0x0320000) resendQ equ (OS_BASE+0x0310000)
VMODE_BASE equ (OS_BASE+0x0328000)
skin_data equ (OS_BASE+0x0330000)
draw_data equ (OS_BASE+0x0338000);
BgrDrawMode equ (OS_BASE+0x033BFF4) skin_data equ (OS_BASE+0x0318000)
BgrDataWidth equ (OS_BASE+0x033BFF8) draw_data equ (OS_BASE+0x0320000)
BgrDataHeight equ (OS_BASE+0x033BFFC)
sys_pgmap equ (OS_BASE+0x033C000) BgrDrawMode equ (OS_BASE+0x0323FF4)
BgrDataWidth equ (OS_BASE+0x0323FF8)
BgrDataHeight equ (OS_BASE+0x0323FFC)
sys_pgmap equ (OS_BASE+0x0324000)
UPPER_KERNEL_PAGES equ (OS_BASE+0x0400000)
virtual at (OS_BASE+0x05FFF80) virtual at (OS_BASE+0x05FFF80)
tss TSS tss TSS
@@ -587,20 +587,6 @@ virtual at 0
display_t display_t display_t display_t
end virtual end virtual
struc HEAP_DATA
{
.mutex rd 1
.refcount rd 1
.heap_base rd 1
.heap_top rd 1
.app_mem rd 1
}
HEAP_DATA_SIZE equ 20
virtual at 0
HEAP_DATA HEAP_DATA
end virtual
struc BOOT_DATA struc BOOT_DATA
{ .bpp dd ? { .bpp dd ?
.scanline dd ? .scanline dd ?
@@ -639,7 +625,7 @@ virtual at 0
end virtual end virtual
struc MEM_STATE struc MEM_STATE
{ .mutex rd 1 { .mutex MUTEX
.smallmap rd 1 .smallmap rd 1
.treemap rd 1 .treemap rd 1
.topsize rd 1 .topsize rd 1
@@ -658,7 +644,7 @@ struc PG_DATA
.kernel_pages dd ? .kernel_pages dd ?
.kernel_tables dd ? .kernel_tables dd ?
.sys_page_dir dd ? .sys_page_dir dd ?
.pg_mutex dd ? .mutex MUTEX
} }
;struc LIB ;struc LIB
@@ -765,3 +751,27 @@ end virtual
virtual at 0 virtual at 0
CSYM COFF_SYM CSYM COFF_SYM
end virtual end virtual
struc LHEAD
{
.next dd ? ;next object in list
.prev dd ? ;prev object in list
.sizeof:
}
virtual at 0
LHEAD LHEAD
end virtual
struc IRQH
{
.list LHEAD
.handler dd ? ;handler roututine
.data dd ? ;user-specific data
.sizeof:
}
virtual at 0
IRQH IRQH
end virtual

View File

@@ -0,0 +1,417 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
iglobal
IRQ_COUNT dd 24
endg
uglobal
irq_mode rd 1
IOAPIC_base rd 1
LAPIC_BASE rd 1
endg
APIC_ID equ 0x20
APIC_TPR equ 0x80
APIC_EOI equ 0xb0
APIC_LDR equ 0xd0
APIC_DFR equ 0xe0
APIC_SVR equ 0xf0
APIC_ISR equ 0x100
APIC_ESR equ 0x280
APIC_ICRL equ 0x300
APIC_ICRH equ 0x310
APIC_LVT_LINT0 equ 0x350
APIC_LVT_LINT1 equ 0x360
APIC_LVT_err equ 0x370
; APIC timer
APIC_LVT_timer equ 0x320
APIC_timer_div equ 0x3e0
APIC_timer_init equ 0x380
APIC_timer_cur equ 0x390
; IOAPIC
IOAPIC_ID equ 0x0
IOAPIC_VER equ 0x1
IOAPIC_ARB equ 0x2
IOAPIC_REDTBL equ 0x10
align 4
APIC_init:
mov [irq_mode], IRQ_PIC
cmp [acpi_ioapic_base], 0
jz .no_apic
cmp [acpi_lapic_base], 0
jz .no_apic
stdcall load_file, dev_data_path
test eax, eax
jz .no_apic
mov [acpi_dev_data], eax
mov [acpi_dev_size], ebx
call IRQ_mask_all
; IOAPIC init
stdcall map_io_mem, [acpi_ioapic_base], 0x20, PG_SW
mov [IOAPIC_base], eax
mov eax, IOAPIC_VER
call IOAPIC_read
shr eax, 16
inc al
movzx eax, al
cmp al, IRQ_RESERVED
jbe @f
mov al, IRQ_RESERVED
@@:
mov [IRQ_COUNT], eax
; Reroute IOAPIC & mask all interrupts
xor ecx, ecx
mov eax, IOAPIC_REDTBL
@@:
mov ebx, eax
call IOAPIC_read
mov ah, 0x09; Delivery Mode: Lowest Priority, Destination Mode: Logical
mov al, cl
add al, 0x20; vector
or eax, 0x10000; Mask Interrupt
cmp ecx, 16
jb .set
or eax, 0xa000;<<< level-triggered active-low for IRQ16+
.set:
xchg eax, ebx
call IOAPIC_write
inc eax
mov ebx, eax
call IOAPIC_read
or eax, 0xff000000; Destination Field
xchg eax, ebx
call IOAPIC_write
inc eax
inc ecx
cmp ecx, [IRQ_COUNT]
jb @b
call LAPIC_init
mov [irq_mode], IRQ_APIC
mov al, 0x70
out 0x22, al
mov al, 1
out 0x23, al
call pci_irq_fixup
.no_apic:
ret
;===========================================================
align 4
LAPIC_init:
; Check MSR support
;....
; Get LAPIC base address
; mov ecx, 0x1b
; rdmsr ; it may be replaced to
; and ax, 0xf000 ; mov eax, 0xfee00000
stdcall map_io_mem, [acpi_lapic_base], 0x1000, PG_SW
mov [LAPIC_BASE], eax
mov esi, eax
; Program Destination Format Register for Flat mode.
mov eax, [esi + APIC_DFR]
or eax, 0xf0000000
mov [esi + APIC_DFR], eax
; Program Logical Destination Register.
mov eax, [esi + APIC_LDR]
;and eax, 0xff000000
and eax, 0x00ffffff
or eax, 0x01000000;!!!!!!!!!!!!
mov [esi + APIC_LDR], eax
; Task Priority Register initialization.
mov eax, [esi + APIC_TPR]
and eax, 0xffffff00
mov [esi + APIC_TPR], eax
; Flush the queue
mov edx, 0
.nxt2:
mov ecx, 32
mov eax, [esi + APIC_ISR + edx]
.nxt:
shr eax, 1
jnc @f
mov dword [esi + APIC_EOI], 0; EOI
@@:
loop .nxt
add edx, 0x10
cmp edx, 0x170
jbe .nxt2
; Spurious-Interrupt Vector Register initialization.
mov eax, [esi + APIC_SVR]
or eax, 0x1ff
and eax, 0xfffffdff
mov [esi + APIC_SVR], eax
; Initialize LVT LINT0 register. (INTR)
mov eax, 0x00700
; mov eax, 0x10700
mov [esi + APIC_LVT_LINT0], eax
; Initialize LVT LINT1 register. (NMI)
mov eax, 0x00400
mov [esi + APIC_LVT_LINT1], eax
; Initialize LVT Error register.
mov eax, [esi + APIC_LVT_err]
or eax, 0x10000; bit 16
mov [esi + APIC_LVT_err], eax
; LAPIC timer
; pre init
mov dword[esi + APIC_timer_div], 1011b; 1
mov dword[esi + APIC_timer_init], 0xffffffff; max val
push esi
mov esi, 640 ; wait 0.64 sec
call delay_ms
pop esi
mov eax, [esi + APIC_timer_cur]; read current tick couner
xor eax, 0xffffffff ; eax = 0xffffffff - eax
shr eax, 6 ; eax /= 64; APIC ticks per 0.01 sec
; Start (every 0.01 sec)
mov dword[esi + APIC_LVT_timer], 0x30020; periodic int 0x20
mov dword[esi + APIC_timer_init], eax
ret
;===========================================================
; IOAPIC implementation
align 4
IOAPIC_read:
; in : EAX - IOAPIC register
; out: EAX - readed value
push esi
mov esi, [IOAPIC_base]
mov [esi], eax
mov eax, [esi + 0x10]
pop esi
ret
align 4
IOAPIC_write:
; in : EAX - IOAPIC register
; EBX - value
; out: none
push esi
mov esi, [IOAPIC_base]
mov [esi], eax
mov [esi + 0x10], ebx
pop esi
ret
;===========================================================
; Remap all IRQ to 0x20+ Vectors
; IRQ0 to vector 0x20, IRQ1 to vector 0x21....
align 4
PIC_init:
cli
mov al, 0x11 ; icw4, edge triggered
out 0x20, al
out 0xA0, al
mov al, 0x20 ; generate 0x20 +
out 0x21, al
mov al, 0x28 ; generate 0x28 +
out 0xA1, al
mov al, 0x04 ; slave at irq2
out 0x21, al
mov al, 0x02 ; at irq9
out 0xA1, al
mov al, 0x01 ; 8086 mode
out 0x21, al
out 0xA1, al
call IRQ_mask_all
; mov dword[irq_type_to_set], IRQ_TYPE_PIC
ret
; -----------------------------------------
; TIMER SET TO 1/100 S
align 4
PIT_init:
mov al, 0x34 ; set to 100Hz
out 0x43, al
mov al, 0x9b ; lsb 1193180 / 1193
out 0x40, al
mov al, 0x2e ; msb
out 0x40, al
ret
; -----------------------------------------
align 4
unmask_timer:
cmp [irq_mode], IRQ_APIC
je @f
stdcall enable_irq, 0
ret
@@:
; use PIT
; in some systems PIT no connected to IOAPIC
; mov eax, 0x14
; call IOAPIC_read
; mov ah, 0x09 ; Delivery Mode: Lowest Priority, Destination Mode: Logical
; mov al, 0x20
; or eax, 0x10000 ; Mask Interrupt
; mov ebx, eax
; mov eax, 0x14
; call IOAPIC_write
; stdcall enable_irq, 2
; ret
; use LAPIC timer
mov esi, [LAPIC_BASE]
mov eax, [esi + APIC_LVT_timer]
and eax, 0xfffeffff
mov [esi + APIC_LVT_timer], eax
ret
; -----------------------------------------
; Disable all IRQ
align 4
IRQ_mask_all:
cmp [irq_mode], IRQ_APIC
je .APIC
mov al, 0xFF
out 0x21, al
out 0xA1, al
mov ecx, 0x1000
ret
.APIC:
mov ecx, [IRQ_COUNT]
mov eax, 0x10
@@:
mov ebx, eax
call IOAPIC_read
or eax, 0x10000; bit 16
xchg eax, ebx
call IOAPIC_write
inc eax
inc eax
loop @b
ret
; -----------------------------------------
; End Of Interrupt
; cl - IRQ number
align 4
irq_eoi: ; __fastcall
cmp [irq_mode], IRQ_APIC
je .APIC
cmp cl, 8
mov al, 0x20
jb @f
out 0xa0, al
@@:
out 0x20, al
ret
.APIC:
mov eax, [LAPIC_BASE]
mov dword [eax + APIC_EOI], 0; EOI
ret
; -----------------------------------------
; from dll.inc
align 4
proc enable_irq stdcall, irq_line:dword
mov ebx, [irq_line]
cmp [irq_mode], IRQ_APIC
je .APIC
mov edx, 0x21
cmp ebx, 8
jb @F
mov edx, 0xA1
sub ebx, 8
@@:
in al, dx
btr eax, ebx
out dx, al
ret
.APIC:
shl ebx, 1
add ebx, 0x10
mov eax, ebx
call IOAPIC_read
and eax, 0xfffeffff; bit 16
xchg eax, ebx
call IOAPIC_write
ret
endp
align 4
pci_irq_fixup:
push ebp
mov esi, [acpi_dev_data]
mov ebx, [acpi_dev_size]
lea edi, [esi+ebx]
.iterate:
cmp esi, edi
jae .done
mov eax, [esi]
cmp eax, -1
je .done
movzx ebx, al
movzx ebp, ah
stdcall pci_read32, ebp, ebx, 0
cmp eax, [esi+4]
jne .skip
mov eax, [esi+8]
stdcall pci_write8, ebp, ebx, 0x3C, eax
.skip:
add esi, 16
jmp .iterate
.done:
.fail:
pop ebp
ret

View File

@@ -13,7 +13,8 @@
$Revision$ $Revision$
iglobal iglobal
conf_path_sect: db 'path',0 conf_path_sect:
db 'path',0
conf_fname db '/sys/sys.conf',0 conf_fname db '/sys/sys.conf',0
endg endg
@@ -27,30 +28,30 @@ proc set_kernel_conf
;[gui] ;[gui]
;mouse_speed ;mouse_speed
lea eax,[par] lea eax, [par]
push eax push eax
invoke ini.get_str,conf_fname, ugui, ugui_mouse_speed,\ invoke ini.get_str, conf_fname, ugui, ugui_mouse_speed, \
eax,30, ugui_mouse_speed_def eax,30, ugui_mouse_speed_def
pop eax pop eax
stdcall strtoint,eax stdcall strtoint, eax
mov [mouse_speed_factor], ax mov [mouse_speed_factor], ax
;mouse_delay ;mouse_delay
lea eax,[par] lea eax, [par]
push eax push eax
invoke ini.get_str,conf_fname, ugui, ugui_mouse_delay,\ invoke ini.get_str, conf_fname, ugui, ugui_mouse_delay, \
eax,30, ugui_mouse_delay_def eax,30, ugui_mouse_delay_def
pop eax pop eax
stdcall strtoint,eax stdcall strtoint, eax
mov [mouse_delay], eax mov [mouse_delay], eax
;midibase ;midibase
lea eax,[par] lea eax, [par]
push eax push eax
invoke ini.get_str,conf_fname, udev, udev_midibase, eax,30, udev_midibase_def invoke ini.get_str, conf_fname, udev, udev_midibase, eax, 30, udev_midibase_def
pop eax pop eax
stdcall strtoint,eax stdcall strtoint, eax
cmp eax, 0x100 cmp eax, 0x100
jb @f jb @f
@@ -75,83 +76,28 @@ udev db 'dev',0
udev_midibase db 'midibase',0 udev_midibase db 'midibase',0
udev_midibase_def db '0x320',0 udev_midibase_def db '0x320',0
endg endg
;set up netvork configuration
proc set_network_conf
locals
par db 30 dup(?)
endl
pushad
;[net]
;active
lea eax,[par]
invoke ini.get_int,conf_fname, unet, unet_active, 0
or eax,eax
jz .do_not_set_net
mov eax, [stack_config]
and eax, 0xFFFFFF80
add eax, 3
mov [stack_config], eax
call ash_eth_enable
;addr
lea eax,[par]
push eax
invoke ini.get_str,conf_fname, unet, unet_addr, eax,30, unet_def
pop eax
stdcall do_inet_adr,eax
mov [stack_ip], eax
;mask
lea eax,[par]
push eax
invoke ini.get_str,conf_fname, unet, unet_mask, eax,30, unet_def
pop eax
stdcall do_inet_adr,eax
mov [subnet_mask], eax
;gate
lea eax,[par]
push eax
invoke ini.get_str,conf_fname, unet, unet_gate, eax,30, unet_def
pop eax
stdcall do_inet_adr,eax
mov [gateway_ip], eax
.do_not_set_net:
popad
ret
endp
iglobal
unet db 'net',0
unet_active db 'active',0
unet_addr db 'addr',0
unet_mask db 'mask',0
unet_gate db 'gate',0
unet_def db 0
endg
; convert string to DWord ; convert string to DWord
proc strtoint stdcall,strs proc strtoint stdcall,strs
pushad pushad
mov eax,[strs] mov eax, [strs]
inc eax inc eax
mov bl,[eax] mov bl, [eax]
cmp bl,'x' cmp bl, 'x'
je .hex je .hex
cmp bl,'X' cmp bl, 'X'
je .hex je .hex
jmp .dec jmp .dec
.hex: .hex:
inc eax inc eax
stdcall strtoint_hex,eax stdcall strtoint_hex, eax
jmp .exit jmp .exit
.dec: .dec:
dec eax dec eax
stdcall strtoint_dec,eax stdcall strtoint_dec, eax
.exit: .exit:
mov [esp+28],eax mov [esp+28], eax
popad popad
ret ret
endp endp
@@ -159,52 +105,52 @@ endp
; convert string to DWord for decimal value ; convert string to DWord for decimal value
proc strtoint_dec stdcall,strs proc strtoint_dec stdcall,strs
pushad pushad
xor edx,edx xor edx, edx
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov esi,[strs] mov esi, [strs]
@@: @@:
lodsb lodsb
or al,al or al, al
jnz @b jnz @b
mov ebx,esi mov ebx, esi
mov esi,[strs] mov esi, [strs]
dec ebx dec ebx
sub ebx,esi sub ebx, esi
mov ecx,1 mov ecx, 1
@@: @@:
dec ebx dec ebx
or ebx,ebx or ebx, ebx
jz @f jz @f
imul ecx,ecx,10 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD> imul ecx, ecx, 10; <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
jmp @b jmp @b
@@: @@:
xchg ebx,ecx xchg ebx, ecx
xor ecx,ecx xor ecx, ecx
@@: @@:
xor eax,eax xor eax, eax
lodsb lodsb
cmp al,0 cmp al, 0
je .eend je .eend
sub al,30h sub al, 30h
imul ebx imul ebx
add ecx,eax add ecx, eax
push ecx push ecx
xchg eax,ebx xchg eax, ebx
mov ecx,10 mov ecx, 10
div ecx div ecx
xchg eax,ebx xchg eax, ebx
pop ecx pop ecx
jmp @b jmp @b
.eend: .eend:
mov [esp+28],ecx mov [esp+28], ecx
popad popad
ret ret
endp endp
@@ -212,86 +158,53 @@ endp
;convert string to DWord for hex value ;convert string to DWord for hex value
proc strtoint_hex stdcall,strs proc strtoint_hex stdcall,strs
pushad pushad
xor edx,edx xor edx, edx
mov esi,[strs] mov esi, [strs]
mov ebx,1 mov ebx, 1
add esi,1 add esi, 1
@@: @@:
lodsb lodsb
or al,al or al, al
jz @f jz @f
shl ebx,4 shl ebx, 4
jmp @b jmp @b
@@: @@:
xor ecx,ecx xor ecx, ecx
mov esi,[strs] mov esi, [strs]
@@: @@:
xor eax,eax xor eax, eax
lodsb lodsb
cmp al,0 cmp al, 0
je .eend je .eend
cmp al,'a' cmp al, 'a'
jae .bm jae .bm
cmp al,'A' cmp al, 'A'
jae .bb jae .bb
jmp .cc jmp .cc
.bm: ; 57h .bm: ; 57h
sub al,57h sub al, 57h
jmp .do jmp .do
.bb: ; 37h .bb: ; 37h
sub al,37h sub al, 37h
jmp .do jmp .do
.cc: ; 30h .cc: ; 30h
sub al,30h sub al, 30h
.do: .do:
imul ebx imul ebx
add ecx,eax add ecx, eax
shr ebx,4 shr ebx, 4
jmp @b jmp @b
.eend: .eend:
mov [esp+28],ecx mov [esp+28], ecx
popad
ret
endp
; convert string to DWord for IP addres
proc do_inet_adr stdcall,strs
pushad
mov esi,[strs]
mov ebx,0
.next:
push esi
@@:
lodsb
or al,al
jz @f
cmp al,'.'
jz @f
jmp @b
@@:
mov cl, al
mov [esi-1],byte 0
;pop eax
call strtoint_dec
rol eax,24
ror ebx,8
add ebx,eax
or cl,cl
jz @f
jmp .next
@@:
mov [esp+28],ebx
popad popad
ret ret
endp endp

View File

@@ -13,7 +13,8 @@ sys_debug_services:
cmp ebx, 9 cmp ebx, 9
ja @f ja @f
jmp dword [sys_debug_services_table+ebx*4] jmp dword [sys_debug_services_table+ebx*4]
@@: ret @@:
ret
iglobal iglobal
align 4 align 4
sys_debug_services_table: sys_debug_services_table:
@@ -76,7 +77,7 @@ debug_terminate:
shr ecx, 5 shr ecx, 5
; push 2 ; push 2
; pop ebx ; pop ebx
mov edx,esi mov edx, esi
jmp sysfn_terminate jmp sysfn_terminate
debug_suspend: debug_suspend:
@@ -93,7 +94,8 @@ debug_suspend:
cmp cl, 5 cmp cl, 5
jnz .ret jnz .ret
mov cl, 2 mov cl, 2
.2: mov [CURRENT_TASK+eax+TASKDATA.state], cl .2:
mov [CURRENT_TASK+eax+TASKDATA.state], cl
.ret: .ret:
sti sti
ret ret
@@ -108,9 +110,12 @@ do_resume:
cmp cl, 2 cmp cl, 2
jnz .ret jnz .ret
mov cl, 5 mov cl, 5
.2: mov [CURRENT_TASK+eax+TASKDATA.state], cl .2:
.ret: ret mov [CURRENT_TASK+eax+TASKDATA.state], cl
.1: dec ecx .ret:
ret
.1:
dec ecx
jmp .2 jmp .2
debug_resume: debug_resume:
@@ -122,7 +127,8 @@ debug_resume:
shl eax, 5 shl eax, 5
jz .ret jz .ret
call do_resume call do_resume
.ret: sti .ret:
sti
ret ret
debug_getcontext: debug_getcontext:
@@ -238,10 +244,10 @@ debug_set_drx:
ja .errret ja .errret
mov ecx, dr7 mov ecx, dr7
;fix me ;fix me
xchg ecx,edx xchg ecx, edx
shr edx, cl shr edx, cl
shr edx, cl shr edx, cl
xchg ecx,edx xchg ecx, edx
test ecx, 2 ; bit 1+2*index = G0..G3, global break enable test ecx, 2 ; bit 1+2*index = G0..G3, global break enable
jnz .errret2 jnz .errret2
@@ -283,7 +289,7 @@ debug_set_drx:
cmp cl, 2 cmp cl, 2
jz .errret jz .errret
mov ebx,esi mov ebx, esi
test bl, dl test bl, dl
jnz .errret jnz .errret
@@ -323,7 +329,7 @@ debug_read_process_memory:
call get_debuggee_slot call get_debuggee_slot
jc .err jc .err
shr eax, 5 shr eax, 5
; mov ebx, esi mov ecx, edi
call read_process_memory call read_process_memory
sti sti
mov dword [esp+32], eax mov dword [esp+32], eax
@@ -349,7 +355,7 @@ debug_write_process_memory:
call get_debuggee_slot call get_debuggee_slot
jc debug_read_process_memory.err jc debug_read_process_memory.err
shr eax, 5 shr eax, 5
; mov ebx, esi mov ecx, edi
call write_process_memory call write_process_memory
sti sti
mov [esp+32], eax mov [esp+32], eax
@@ -368,23 +374,23 @@ debugger_notify:
.1: .1:
mov eax, ebp mov eax, ebp
shl eax, 8 shl eax, 8
mov edx, [SLOT_BASE+eax+APPDATA.dbg_event_mem] mov esi, [SLOT_BASE+eax+APPDATA.dbg_event_mem]
test edx, edx test esi, esi
jz .ret jz .ret
; read buffer header ; read buffer header
push ecx push ecx
push eax push eax
push eax push eax
mov eax, ebp mov eax, ebp
mov ebx, esp mov ecx, esp
mov ecx, 8 mov edx, 8
call read_process_memory call read_process_memory
cmp eax, ecx cmp eax, edx
jz @f jz @f
add esp, 12 add esp, 12
jmp .ret jmp .ret
@@: @@:
cmp dword [ebx], 0 cmp dword [ecx], 0
jg @f jg @f
.2: .2:
pop ecx pop ecx
@@ -400,26 +406,26 @@ debugger_notify:
cli cli
jmp .1 jmp .1
@@: @@:
mov ecx, [ebx+8] mov edx, [ecx+8]
add ecx, [ebx+4] add edx, [ecx+4]
cmp ecx, [ebx] cmp edx, [ecx]
ja .2 ja .2
; advance buffer position ; advance buffer position
push ecx push edx
mov ecx, 4 mov edx, 4
sub ebx, ecx sub ecx, edx
mov eax, ebp mov eax, ebp
add edx, ecx add esi, edx
call write_process_memory call write_process_memory
pop eax pop eax
; write message ; write message
mov eax, ebp mov eax, ebp
add edx, ecx add esi, edx
add edx, [ebx+8] add esi, [ecx+8]
add ebx, 20 add ecx, 20
pop ecx pop edx
pop ecx pop edx
pop ecx pop edx
call write_process_memory call write_process_memory
; new debug event ; new debug event
mov eax, ebp mov eax, ebp

View File

@@ -9,195 +9,19 @@ $Revision$
DRV_COMPAT equ 5 ;minimal required drivers version DRV_COMPAT equ 5 ;minimal required drivers version
DRV_CURRENT equ 5 ;current drivers model version DRV_CURRENT equ 6 ;current drivers model version
DRV_VERSION equ (DRV_COMPAT shl 16) or DRV_CURRENT DRV_VERSION equ (DRV_COMPAT shl 16) or DRV_CURRENT
PID_KERNEL equ 1 ;os_idle thread PID_KERNEL equ 1 ;os_idle thread
align 4
proc attach_int_handler stdcall, irq:dword, handler:dword, access_rights:dword
push ebx
mov ebx, [irq] ;irq num
test ebx, ebx
jz .err
cmp ebx, 15 ; hidnplayr says: we only have 16 IRQ's
ja .err
mov eax, [handler]
test eax, eax
jz .err
cmp [irq_owner + 4 * ebx], 0
je @f
mov ecx, [irq_rights + 4 * ebx] ; Rights : 0 - full access, 1 - read only, 2 - forbidden
test ecx, ecx
jnz .err
@@:
mov [irq_tab+ebx*4], eax
mov eax, [access_rights]
mov [irq_rights + 4 * ebx], eax
mov [irq_owner + 4 * ebx], PID_KERNEL ; all handlers belong to a kernel
stdcall enable_irq, [irq]
pop ebx
mov eax, 1
ret
.err:
pop ebx
xor eax, eax
ret
endp
uglobal
irq_rights rd 16
endg
proc get_int_handler stdcall, irq:dword
mov eax, [irq]
cmp [irq_rights + 4 * eax], dword 1
ja .err
mov eax, [irq_tab + 4 * eax]
ret
.err:
xor eax, eax
ret
endp
align 4
proc detach_int_handler
ret
endp
align 4
proc enable_irq stdcall, irq_line:dword
mov ebx, [irq_line]
mov edx, 0x21
cmp ebx, 8
jb @F
mov edx, 0xA1
sub ebx,8
@@:
in al,dx
btr eax, ebx
out dx, al
ret
endp
align 16
;; proc irq_serv
irq_serv:
.irq_1:
push 1
jmp .main
align 4
.irq_2:
push 2
jmp .main
align 4
.irq_3:
push 3
jmp .main
align 4
.irq_4:
push 4
jmp .main
align 4
.irq_5:
push 5
jmp .main
; align 4
; .irq_6:
; push 6
; jmp .main
align 4
.irq_7:
push 7
jmp .main
align 4
.irq_8:
push 8
jmp .main
align 4
.irq_9:
push 9
jmp .main
align 4
.irq_10:
push 10
jmp .main
align 4
.irq_11:
push 11
jmp .main
align 4
.irq_12:
push 12
jmp .main
; align 4
; .irq_13:
; push 13
; jmp .main
; align 4
; .irq_14:
; push 14
; jmp .main
; align 4
; .irq_15:
; push 15
; jmp .main
align 16
.main:
save_ring3_context
mov eax, [esp + 32]
mov bx, app_data ;os_data
mov ds, bx
mov es, bx
cmp [v86_irqhooks+eax*8], 0
jnz v86_irq
mov ebx, [irq_tab+eax*4]
test ebx, ebx
jz .exit
call ebx
mov [check_idle_semaphore],5
.exit:
cmp dword [esp + 32], 8
mov al, 0x20
jb @f
out 0xa0, al
@@:
out 0x20, al
restore_ring3_context
add esp, 4
iret
align 4 align 4
proc get_notify stdcall, p_ev:dword proc get_notify stdcall, p_ev:dword
.wait: .wait:
mov ebx,[current_slot] mov ebx, [current_slot]
test dword [ebx+APPDATA.event_mask],EVENT_NOTIFY test dword [ebx+APPDATA.event_mask], EVENT_NOTIFY
jz @f jz @f
and dword [ebx+APPDATA.event_mask], not EVENT_NOTIFY and dword [ebx+APPDATA.event_mask], not EVENT_NOTIFY
mov edi, [p_ev] mov edi, [p_ev]
@@ -212,7 +36,7 @@ endp
align 4 align 4
proc pci_read32 stdcall, bus:dword, devfn:dword, reg:dword proc pci_read32 stdcall, bus:dword, devfn:dword, reg:dword
push ebx edx push ebx
xor eax, eax xor eax, eax
xor ebx, ebx xor ebx, ebx
mov ah, byte [bus] mov ah, byte [bus]
@@ -220,13 +44,13 @@ proc pci_read32 stdcall, bus:dword, devfn:dword, reg:dword
mov bh, byte [devfn] mov bh, byte [devfn]
mov bl, byte [reg] mov bl, byte [reg]
call pci_read_reg call pci_read_reg
pop edx ebx pop ebx
ret ret
endp endp
align 4 align 4
proc pci_read16 stdcall, bus:dword, devfn:dword, reg:dword proc pci_read16 stdcall, bus:dword, devfn:dword, reg:dword
push ebx edx push ebx
xor eax, eax xor eax, eax
xor ebx, ebx xor ebx, ebx
mov ah, byte [bus] mov ah, byte [bus]
@@ -234,13 +58,13 @@ proc pci_read16 stdcall, bus:dword, devfn:dword, reg:dword
mov bh, byte [devfn] mov bh, byte [devfn]
mov bl, byte [reg] mov bl, byte [reg]
call pci_read_reg call pci_read_reg
pop edx ebx pop ebx
ret ret
endp endp
align 4 align 4
proc pci_read8 stdcall, bus:dword, devfn:dword, reg:dword proc pci_read8 stdcall, bus:dword, devfn:dword, reg:dword
push ebx edx push ebx
xor eax, eax xor eax, eax
xor ebx, ebx xor ebx, ebx
mov ah, byte [bus] mov ah, byte [bus]
@@ -248,13 +72,13 @@ proc pci_read8 stdcall, bus:dword, devfn:dword, reg:dword
mov bh, byte [devfn] mov bh, byte [devfn]
mov bl, byte [reg] mov bl, byte [reg]
call pci_read_reg call pci_read_reg
pop edx ebx pop ebx
ret ret
endp endp
align 4 align 4
proc pci_write8 stdcall, bus:dword, devfn:dword, reg:dword, val:dword proc pci_write8 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
push ebx edx push ebx
xor eax, eax xor eax, eax
xor ebx, ebx xor ebx, ebx
mov ah, byte [bus] mov ah, byte [bus]
@@ -263,13 +87,13 @@ proc pci_write8 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
mov bl, byte [reg] mov bl, byte [reg]
mov ecx, [val] mov ecx, [val]
call pci_write_reg call pci_write_reg
pop edx ebx pop ebx
ret ret
endp endp
align 4 align 4
proc pci_write16 stdcall, bus:dword, devfn:dword, reg:dword, val:dword proc pci_write16 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
push ebx edx push ebx
xor eax, eax xor eax, eax
xor ebx, ebx xor ebx, ebx
mov ah, byte [bus] mov ah, byte [bus]
@@ -278,13 +102,13 @@ proc pci_write16 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
mov bl, byte [reg] mov bl, byte [reg]
mov ecx, [val] mov ecx, [val]
call pci_write_reg call pci_write_reg
pop edx ebx pop ebx
ret ret
endp endp
align 4 align 4
proc pci_write32 stdcall, bus:dword, devfn:dword, reg:dword, val:dword proc pci_write32 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
push ebx edx push ebx
xor eax, eax xor eax, eax
xor ebx, ebx xor ebx, ebx
mov ah, byte [bus] mov ah, byte [bus]
@@ -293,7 +117,7 @@ proc pci_write32 stdcall, bus:dword, devfn:dword, reg:dword, val:dword
mov bl, byte [reg] mov bl, byte [reg]
mov ecx, [val] mov ecx, [val]
call pci_write_reg call pci_write_reg
pop edx ebx pop ebx
ret ret
endp endp
@@ -453,7 +277,7 @@ proc get_proc stdcall, exp:dword, sz_name:dword
test eax, eax test eax, eax
jz .ok jz .ok
add edx,8 add edx, 8
jmp .next jmp .next
.ok: .ok:
mov eax, [edx+4] mov eax, [edx+4]
@@ -466,7 +290,7 @@ proc get_coff_sym stdcall, pSym:dword,count:dword, sz_sym:dword
@@: @@:
stdcall strncmp, [pSym], [sz_sym], 8 stdcall strncmp, [pSym], [sz_sym], 8
test eax,eax test eax, eax
jz .ok jz .ok
add [pSym], 18 add [pSym], 18
dec [count] dec [count]
@@ -481,7 +305,7 @@ endp
align 4 align 4
proc get_curr_task proc get_curr_task
mov eax,[CURRENT_TASK] mov eax, [CURRENT_TASK]
shl eax, 8 shl eax, 8
ret ret
endp endp
@@ -544,10 +368,8 @@ proc read_file stdcall,file_name:dword, buffer:dword, off:dword,\
mov [name], ebx mov [name], ebx
pushad pushad
push eax lea ebx, [cmd]
lea eax, [cmd]
call file_system_lfn call file_system_lfn
pop eax
popad popad
ret ret
endp endp
@@ -597,6 +419,8 @@ proc load_file stdcall, file_name:dword
stdcall kernel_alloc, [file_size] stdcall kernel_alloc, [file_size]
mov [file], eax mov [file], eax
test eax, eax
jz .fail
stdcall read_file, [file_name], eax, dword 0, [file_size] stdcall read_file, [file_name], eax, dword 0, [file_size]
cmp ebx, [file_size] cmp ebx, [file_size]
@@ -667,7 +491,7 @@ proc get_proc_ex stdcall, proc_name:dword, imports:dword
test eax, eax test eax, eax
jz .ok jz .ok
add edx,8 add edx, 8
jmp .next jmp .next
.next_table: .next_table:
add [imports], 4 add [imports], 4
@@ -701,7 +525,7 @@ proc fix_coff_symbols stdcall uses ebx esi, sec:dword, symbols:dword,\
add edi, [strings] add edi, [strings]
@@: @@:
push edi push edi
stdcall get_proc_ex, edi,[imports] stdcall get_proc_ex, edi, [imports]
pop edi pop edi
xor ebx, ebx xor ebx, ebx
@@ -715,7 +539,7 @@ proc fix_coff_symbols stdcall uses ebx esi, sec:dword, symbols:dword,\
mov esi, msg_CR mov esi, msg_CR
call sys_msg_board_str call sys_msg_board_str
mov [retval],0 mov [retval], 0
@@: @@:
mov edi, [symbols] mov edi, [symbols]
mov [edi+CSYM.Value], eax mov [edi+CSYM.Value], eax
@@ -762,8 +586,8 @@ proc fix_coff_relocs stdcall uses ebx esi, coff:dword, sym:dword, \
jz .next jz .next
.reloc_loop: .reloc_loop:
mov ebx, [edi+CRELOC.SymIndex] mov ebx, [edi+CRELOC.SymIndex]
add ebx,ebx add ebx, ebx
lea ebx,[ebx+ebx*8] lea ebx, [ebx+ebx*8]
add ebx, [sym] add ebx, [sym]
mov edx, [ebx+CSYM.Value] mov edx, [ebx+CSYM.Value]
@@ -797,6 +621,7 @@ proc fix_coff_relocs stdcall uses ebx esi, coff:dword, sym:dword, \
ret ret
endp endp
align 4
proc rebase_coff stdcall uses ebx esi, coff:dword, sym:dword, \ proc rebase_coff stdcall uses ebx esi, coff:dword, sym:dword, \
delta:dword delta:dword
locals locals
@@ -929,8 +754,8 @@ proc load_driver stdcall, driver_name:dword
add ebx, edx add ebx, edx
mov [sym], ebx mov [sym], ebx
mov ecx, [edx+CFH.nSymbols] mov ecx, [edx+CFH.nSymbols]
add ecx,ecx add ecx, ecx
lea ecx,[ecx+ecx*8] ;ecx*=18 = nSymbols*CSYM_SIZE lea ecx, [ecx+ecx*8];ecx*=18 = nSymbols*CSYM_SIZE
add ecx, [sym] add ecx, [sym]
mov [strings], ecx mov [strings], ecx
@@ -939,7 +764,7 @@ proc load_driver stdcall, driver_name:dword
mov dword [ebx+4], 0 mov dword [ebx+4], 0
lea eax, [edx+20] lea eax, [edx+20]
stdcall fix_coff_symbols, eax, [sym], [edx+CFH.nSymbols],\ stdcall fix_coff_symbols, eax, [sym], [edx+CFH.nSymbols], \
[strings], ebx [strings], ebx
test eax, eax test eax, eax
jz .link_fail jz .link_fail
@@ -947,7 +772,7 @@ proc load_driver stdcall, driver_name:dword
mov ebx, [coff] mov ebx, [coff]
stdcall fix_coff_relocs, ebx, [sym], 0 stdcall fix_coff_relocs, ebx, [sym], 0
stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szVersion stdcall get_coff_sym, [sym], [ebx+CFH.nSymbols], szVersion
test eax, eax test eax, eax
jz .link_fail jz .link_fail
@@ -960,7 +785,7 @@ proc load_driver stdcall, driver_name:dword
ja .ver_fail ja .ver_fail
mov ebx, [coff] mov ebx, [coff]
stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szSTART stdcall get_coff_sym, [sym], [ebx+CFH.nSymbols], szSTART
mov [start], eax mov [start], eax
stdcall kernel_free, [coff] stdcall kernel_free, [coff]
@@ -1010,7 +835,7 @@ proc load_driver stdcall, driver_name:dword
mov esi, msg_CR mov esi, msg_CR
call sys_msg_board_str call sys_msg_board_str
.cleanup: .cleanup:
stdcall kernel_free,[img_base] stdcall kernel_free, [img_base]
.fail: .fail:
stdcall kernel_free, [coff] stdcall kernel_free, [coff]
.exit: .exit:
@@ -1105,8 +930,8 @@ proc load_library stdcall, file_name:dword
test eax, eax test eax, eax
jnz .continue_scan jnz .continue_scan
.test_prev_dll: .test_prev_dll:
mov eax, dword [fileinfo+24] ; last modified time mov eax, dword [fileinfo+24]; last modified time
mov edx, dword [fileinfo+28] ; last modified date mov edx, dword [fileinfo+28]; last modified date
cmp dword [esi+DLLDESCR.timestamp], eax cmp dword [esi+DLLDESCR.timestamp], eax
jnz .continue_scan jnz .continue_scan
cmp dword [esi+DLLDESCR.timestamp+4], edx cmp dword [esi+DLLDESCR.timestamp+4], edx
@@ -1145,7 +970,7 @@ proc load_library stdcall, file_name:dword
mov eax, dword [fileinfo+28] mov eax, dword [fileinfo+28]
mov dword [esi+DLLDESCR.timestamp+4], eax mov dword [esi+DLLDESCR.timestamp+4], eax
; initialize DLLDESCR struct ; initialize DLLDESCR struct
and dword [esi+DLLDESCR.refcount], 0 ; no HDLLs yet; later it will be incremented and dword [esi+DLLDESCR.refcount], 0; no HDLLs yet; later it will be incremented
mov [esi+DLLDESCR.fd], dll_list mov [esi+DLLDESCR.fd], dll_list
mov eax, [dll_list.bk] mov eax, [dll_list.bk]
mov [dll_list.bk], esi mov [dll_list.bk], esi
@@ -1296,18 +1121,18 @@ proc load_library stdcall, file_name:dword
add ecx, ecx add ecx, ecx
add ecx, [esi+DLLDESCR.symbols_ptr] add ecx, [esi+DLLDESCR.symbols_ptr]
stdcall fix_coff_symbols, edx, [esi+DLLDESCR.symbols_ptr], eax,\ stdcall fix_coff_symbols, edx, [esi+DLLDESCR.symbols_ptr], eax, \
ecx, 0 ecx, 0
; test eax, eax ; test eax, eax
; jnz @F ; jnz @F
; ;
;@@: ;@@:
stdcall get_coff_sym,[esi+DLLDESCR.symbols_ptr],[ebx+CFH.nSymbols],szEXPORTS stdcall get_coff_sym, [esi+DLLDESCR.symbols_ptr], [ebx+CFH.nSymbols], szEXPORTS
test eax, eax test eax, eax
jnz @F jnz @F
stdcall get_coff_sym,[esi+DLLDESCR.symbols_ptr],[ebx+CFH.nSymbols],sz_EXPORTS stdcall get_coff_sym, [esi+DLLDESCR.symbols_ptr], [ebx+CFH.nSymbols], sz_EXPORTS
@@: @@:
mov [esi+DLLDESCR.exports], eax mov [esi+DLLDESCR.exports], eax
@@ -1581,7 +1406,7 @@ create_kernel_object:
test eax, eax test eax, eax
jz .fail jz .fail
mov ecx,[current_slot] mov ecx, [current_slot]
add ecx, APP_OBJ_OFFSET add ecx, APP_OBJ_OFFSET
pushfd pushfd
@@ -1620,70 +1445,3 @@ destroy_kernel_object:
call free ;release object memory call free ;release object memory
ret ret
if 0
irq:
.irq0:
pusfd
pushad
push IRQ_0
jmp .master
.irq_1:
pusfd
pushad
push IRQ_1
jmp .master
.master:
mov ax, app_data
mov ds, eax
mov es, eax
mov ebx, [esp+4] ;IRQ_xx
mov eax, [irq_handlers+ebx+4]
call intr_handler
mov ecx, [esp+4]
cmp [irq_actids+ecx*4], 0
je @F
in al, 0x21
bts eax, ecx
out 0x21, al
mov al, 0x20
out 0x20, al
jmp .restart
.slave:
mov ax, app_data
mov ds, eax
mov es, eax
mov ebx, [esp+4] ;IRQ_xx
mov eax, [irq_handlers+ebx+4]
call intr_handler
mov ecx, [esp+4]
sub ecx, 8
cmp [irq_actids+ecx*4], 0
je @F
in al, 0xA1
bts eax, ecx
out 0xA1, al
mov al, 0x20
out 0xA0, al
out 0x20, al
.restart:
mov ebx, [next_slot]
test ebx, ebx
jz @F
mov [next_task],0
mov esi, [prev_slot]
call do_change_task
add esp, 4
iretd
end if

View File

@@ -28,7 +28,8 @@ macro export dllname,[label,string]
local name local name
dd (name-OS_BASE) dd (name-OS_BASE)
common common
ordinal: count = 0 ordinal:
count = 0
forward forward
dw count dw count
count = count+1 count = count+1

View File

@@ -16,12 +16,16 @@ iglobal
szGetService db 'GetService',0 szGetService db 'GetService',0
szServiceHandler db 'ServiceHandler',0 szServiceHandler db 'ServiceHandler',0
szAttachIntHandler db 'AttachIntHandler',0 szAttachIntHandler db 'AttachIntHandler',0
szGetIntHandler db 'GetIntHandler', 0 ; szGetIntHandler db 'GetIntHandler', 0
szFpuSave db 'FpuSave',0 szFpuSave db 'FpuSave',0
szFpuRestore db 'FpuRestore',0 szFpuRestore db 'FpuRestore',0
szReservePortArea db 'ReservePortArea',0 szReservePortArea db 'ReservePortArea',0
szBoot_Log db 'Boot_Log',0 szBoot_Log db 'Boot_Log',0
szMutexInit db 'MutexInit',0
szMutexLock db 'MutexLock',0
szMutexUnlock db 'MutexUnlock',0
szPciApi db 'PciApi', 0 szPciApi db 'PciApi', 0
szPciRead32 db 'PciRead32', 0 szPciRead32 db 'PciRead32', 0
szPciRead16 db 'PciRead16', 0 szPciRead16 db 'PciRead16', 0
@@ -71,6 +75,9 @@ iglobal
szSleep db 'Sleep',0 szSleep db 'Sleep',0
szGetTimerTicks db 'GetTimerTicks',0 szGetTimerTicks db 'GetTimerTicks',0
szGetDisplay db 'GetDisplay',0
szSetScreen db 'SetScreen',0
szStrncat db 'strncat',0 szStrncat db 'strncat',0
szStrncpy db 'strncpy',0 szStrncpy db 'strncpy',0
szstrncmp db 'strncmp',0 szstrncmp db 'strncmp',0
@@ -78,6 +85,13 @@ iglobal
szStrchr db 'strchr',0 szStrchr db 'strchr',0
szStrrchr db 'strrchr',0 szStrrchr db 'strrchr',0
szDiskAdd db 'DiskAdd',0
szDiskDel db 'DiskDel',0
szDiskMediaChanged db 'DiskMediaChanged',0
szTimerHS db 'TimerHS',0
szCancelTimerHS db 'CancelTimerHS',0
szNetRegDev db 'NetRegDev',0 szNetRegDev db 'NetRegDev',0
szNetUnRegDev db 'NetUnRegDev',0 szNetUnRegDev db 'NetUnRegDev',0
szNetPtrToNum db 'NetPtrToNum',0 szNetPtrToNum db 'NetPtrToNum',0
@@ -91,13 +105,17 @@ kernel_export:
dd szGetService , get_service dd szGetService , get_service
dd szServiceHandler , srv_handler dd szServiceHandler , srv_handler
dd szAttachIntHandler, attach_int_handler dd szAttachIntHandler, attach_int_handler
dd szGetIntHandler , get_int_handler ; dd szGetIntHandler , get_int_handler
dd szFpuSave , fpu_save dd szFpuSave , fpu_save
dd szFpuRestore , fpu_restore dd szFpuRestore , fpu_restore
dd szReservePortArea , r_f_port_area dd szReservePortArea , r_f_port_area
dd szBoot_Log , boot_log dd szBoot_Log , boot_log
dd szPciApi , pci_api dd szMutexInit , mutex_init ;gcc fastcall
dd szMutexLock , mutex_lock ;gcc fastcall
dd szMutexUnlock , mutex_unlock ;gcc fastcall
dd szPciApi , pci_api_drv
dd szPciRead32 , pci_read32 dd szPciRead32 , pci_read32
dd szPciRead16 , pci_read16 dd szPciRead16 , pci_read16
dd szPciRead8 , pci_read8 dd szPciRead8 , pci_read8
@@ -145,6 +163,9 @@ kernel_export:
dd szSleep , delay_ms dd szSleep , delay_ms
dd szGetTimerTicks , get_timer_ticks dd szGetTimerTicks , get_timer_ticks
dd szGetDisplay , get_display
dd szSetScreen , set_screen
dd szStrncat , strncat dd szStrncat , strncat
dd szStrncpy , strncpy dd szStrncpy , strncpy
dd szstrncmp , strncmp dd szstrncmp , strncmp
@@ -152,6 +173,13 @@ kernel_export:
dd szStrchr , strchr dd szStrchr , strchr
dd szStrrchr , strrchr dd szStrrchr , strrchr
dd szDiskAdd , disk_add
dd szDiskDel , disk_del
dd szDiskMediaChanged, disk_media_changed
dd szTimerHS , timer_hs
dd szCancelTimerHS , cancel_timer_hs
dd szNetRegDev , NET_add_device dd szNetRegDev , NET_add_device
dd szNetUnRegDev , NET_remove_device dd szNetUnRegDev , NET_remove_device
dd szNetPtrToNum , NET_ptr_to_num dd szNetPtrToNum , NET_ptr_to_num

View File

@@ -116,14 +116,14 @@ proc load_k_library stdcall, file_name:dword
add ebx, edx add ebx, edx
mov [sym], ebx mov [sym], ebx
mov ecx, [edx+CFH.nSymbols] mov ecx, [edx+CFH.nSymbols]
add ecx,ecx add ecx, ecx
lea ecx,[ecx+ecx*8] ;ecx*=18 = nSymbols*CSYM_SIZE lea ecx, [ecx+ecx*8];ecx*=18 = nSymbols*CSYM_SIZE
add ecx, [sym] add ecx, [sym]
mov [strings], ecx mov [strings], ecx
lea eax, [edx+20] lea eax, [edx+20]
stdcall fix_coff_symbols, eax, [sym], [edx+CFH.nSymbols],\ stdcall fix_coff_symbols, eax, [sym], [edx+CFH.nSymbols], \
[strings], dword 0 [strings], dword 0
test eax, eax test eax, eax
jnz @F jnz @F
@@ -143,7 +143,7 @@ proc load_k_library stdcall, file_name:dword
stdcall fix_coff_relocs, [coff], edx, [sym] stdcall fix_coff_relocs, [coff], edx, [sym]
mov ebx, [coff] mov ebx, [coff]
stdcall get_coff_sym,[sym],[ebx+CFH.nSymbols],szEXPORTS stdcall get_coff_sym, [sym], [ebx+CFH.nSymbols], szEXPORTS
mov [exports], eax mov [exports], eax
stdcall kernel_free, [coff] stdcall kernel_free, [coff]
@@ -157,92 +157,103 @@ endp
proc dll.Load, import_table:dword proc dll.Load, import_table:dword
mov esi,[import_table] mov esi, [import_table]
.next_lib: mov edx,[esi] .next_lib:
or edx,edx mov edx, [esi]
or edx, edx
jz .exit jz .exit
push esi push esi
mov edi,s_libname mov edi, s_libname
mov al, '/' mov al, '/'
stosb stosb
mov esi,sysdir_path mov esi, sysdir_path
@@: lodsb @@:
lodsb
stosb stosb
or al,al or al, al
jnz @b jnz @b
dec edi dec edi
mov [edi], dword '/lib' mov [edi], dword '/lib'
mov [edi+4],byte '/' mov [edi+4], byte '/'
add edi,5 add edi, 5
pop esi pop esi
push esi push esi
mov esi,[esi+4] mov esi, [esi+4]
@@: lodsb @@:
lodsb
stosb stosb
or al,al or al, al
jnz @b jnz @b
pushad pushad
stdcall load_k_library,s_libname stdcall load_k_library, s_libname
mov [esp+28],eax mov [esp+28], eax
popad popad
or eax,eax or eax, eax
jz .fail jz .fail
stdcall dll.Link,eax,edx stdcall dll.Link, eax, edx
stdcall dll.Init,[eax+4] stdcall dll.Init, [eax+4]
pop esi pop esi
add esi,8 add esi, 8
jmp .next_lib jmp .next_lib
.exit: xor eax,eax .exit:
xor eax, eax
ret ret
.fail: add esp,4 .fail:
xor eax,eax add esp, 4
xor eax, eax
inc eax inc eax
ret ret
endp endp
proc dll.Link, exp:dword,imp:dword proc dll.Link, exp:dword,imp:dword
push eax push eax
mov esi,[imp] mov esi, [imp]
test esi,esi test esi, esi
jz .done jz .done
.next: lodsd .next:
test eax,eax lodsd
test eax, eax
jz .done jz .done
stdcall dll.GetProcAddress,[exp],eax stdcall dll.GetProcAddress, [exp], eax
or eax,eax or eax, eax
jz @f jz @f
mov [esi-4],eax mov [esi-4], eax
jmp .next jmp .next
@@: mov dword[esp],0 @@:
.done: pop eax mov dword[esp], 0
.done:
pop eax
ret ret
endp endp
proc dll.Init, dllentry:dword proc dll.Init, dllentry:dword
pushad pushad
mov eax,mem.Alloc mov eax, mem.Alloc
mov ebx,mem.Free mov ebx, mem.Free
mov ecx,mem.ReAlloc mov ecx, mem.ReAlloc
mov edx,dll.Load mov edx, dll.Load
stdcall [dllentry] stdcall [dllentry]
popad popad
ret ret
endp endp
proc dll.GetProcAddress, exp:dword,sz_name:dword proc dll.GetProcAddress, exp:dword,sz_name:dword
mov edx,[exp] mov edx, [exp]
.next: test edx,edx .next:
test edx, edx
jz .end jz .end
stdcall strncmp,[edx],[sz_name], dword -1 stdcall strncmp, [edx], [sz_name], dword -1
test eax,eax test eax, eax
jz .ok jz .ok
add edx,8 add edx, 8
jmp .next jmp .next
.ok: mov eax,[edx+4] .ok:
.end: ret mov eax, [edx+4]
.end:
ret
endp endp
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
@@ -267,32 +278,34 @@ endp
proc mem.ReAlloc mptr,size;/////////////////////////////////////////////////// proc mem.ReAlloc mptr,size;///////////////////////////////////////////////////
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
push ebx ecx esi edi eax push ebx ecx esi edi eax
mov eax,[mptr] mov eax, [mptr]
mov ebx,[size] mov ebx, [size]
or eax,eax or eax, eax
jz @f jz @f
lea ecx,[ebx+4+4095] lea ecx, [ebx+4+4095]
and ecx,not 4095 and ecx, not 4095
add ecx,-4 add ecx, -4
cmp ecx,[eax-4] cmp ecx, [eax-4]
je .exit je .exit
@@: mov eax,ebx @@:
mov eax, ebx
call mem.Alloc call mem.Alloc
xchg eax,[esp] xchg eax, [esp]
or eax,eax or eax, eax
jz .exit jz .exit
mov esi,eax mov esi, eax
xchg eax,[esp] xchg eax, [esp]
mov edi,eax mov edi, eax
mov ecx,[esi-4] mov ecx, [esi-4]
cmp ecx,[edi-4] cmp ecx, [edi-4]
jbe @f jbe @f
mov ecx,[edi-4] mov ecx, [edi-4]
@@: add ecx,3 @@:
shr ecx,2 add ecx, 3
shr ecx, 2
cld cld
rep movsd rep movsd
xchg eax,[esp] xchg eax, [esp]
call mem.Free call mem.Free
.exit: .exit:
pop eax edi esi ecx ebx pop eax edi esi ecx ebx

View File

@@ -145,7 +145,7 @@ align 4
except_7: ;#NM exception handler except_7: ;#NM exception handler
save_ring3_context save_ring3_context
clts clts
mov ax, app_data ; mov ax, app_data;
mov ds, ax mov ds, ax
mov es, ax mov es, ax

View File

@@ -9,17 +9,17 @@ $Revision$
struc MEM_BLOCK struc MEM_BLOCK
{ .next_block dd ? {
.list LHEAD
.next_block dd ? ;+8
.prev_block dd ? ;+4 .prev_block dd ? ;+4
.list_fd dd ? ;+8
.list_bk dd ? ;+12
.base dd ? ;+16 .base dd ? ;+16
.size dd ? ;+20 .size dd ? ;+20
.flags dd ? ;+24 .flags dd ? ;+24
.handle dd ? ;+28 .handle dd ? ;+28
.sizeof:
} }
MEM_LIST_OFFSET equ 8
FREE_BLOCK equ 4 FREE_BLOCK equ 4
USED_BLOCK equ 8 USED_BLOCK equ 8
DONT_FREE_BLOCK equ 10h DONT_FREE_BLOCK equ 10h
@@ -28,12 +28,11 @@ virtual at 0
MEM_BLOCK MEM_BLOCK MEM_BLOCK MEM_BLOCK
end virtual end virtual
MEM_BLOCK_SIZE equ 8*4
block_next equ MEM_BLOCK.next_block block_next equ MEM_BLOCK.next_block
block_prev equ MEM_BLOCK.prev_block block_prev equ MEM_BLOCK.prev_block
list_fd equ MEM_BLOCK.list_fd list_fd equ MEM_BLOCK.list.next
list_bk equ MEM_BLOCK.list_bk list_bk equ MEM_BLOCK.list.prev
block_base equ MEM_BLOCK.base block_base equ MEM_BLOCK.base
block_size equ MEM_BLOCK.size block_size equ MEM_BLOCK.size
block_flags equ MEM_BLOCK.flags block_flags equ MEM_BLOCK.flags
@@ -47,113 +46,159 @@ macro calc_index op
@@: @@:
} }
macro remove_from_list op align 4
{ mov edx, [op+list_fd] md:
mov ecx, [op+list_bk] .add_to_used:
test edx, edx mov eax, [esi+block_base]
jz @f mov ebx, [esi+block_base]
mov [edx+list_bk], ecx shr ebx, 6
@@: add eax, ebx
test ecx, ecx shr ebx, 6
jz @f add eax, ebx
mov [ecx+list_fd], edx shr eax, 12
@@: and eax, 63
mov [op+list_fd],0 inc [mem_hash_cnt+eax*4]
mov [op+list_bk],0
}
macro remove_from_free op lea ecx, [mem_used_list+eax*8]
{ list_add esi, ecx
remove_from_list op mov [esi+block_flags], USED_BLOCK
mov eax, [esi+block_size]
sub [heap_free], eax
ret
align 4
.find_used:
mov ecx, eax
mov ebx, eax
shr ebx, 6
add ecx, ebx
shr ebx, 6
add ecx, ebx
shr ecx, 12
and ecx, 63
mov eax, [op+block_size] lea ebx, [mem_used_list+ecx*8]
calc_index eax mov esi, ebx
cmp [mem_block_list+eax*4], op .next:
jne @f mov esi, [esi+list_fd]
mov [mem_block_list+eax*4], edx cmp esi, ebx
@@: je .fail
cmp [mem_block_list+eax*4], 0
jne @f
btr [mem_block_mask], eax
@@:
}
macro remove_from_used op cmp eax, [esi+block_base]
{ jne .next
mov edx, [op+list_fd]
mov ecx, [op+list_bk] ret
mov [edx+list_bk], ecx .fail:
mov [ecx+list_fd], edx xor esi, esi
mov [op+list_fd], 0 ret
mov [op+list_bk], 0
} align 4
.del_from_used:
call .find_used
test esi, esi
jz .done
cmp [esi+block_flags], USED_BLOCK
jne .fatal
dec [mem_hash_cnt+ecx*4]
list_del esi
.done:
ret
.fatal: ;FIXME panic here
xor esi, esi
ret
;Initial heap state
;
;+heap_size terminator USED_BLOCK
;+4096*MEM_BLOCK.sizeof free space FREE_BLOCK
;HEAP_BASE heap_descriptors USED_BLOCK
;
align 4 align 4
proc init_kernel_heap proc init_kernel_heap
mov ecx, 64 mov ecx, 64
mov edi, mem_block_list mov edi, mem_block_list
xor eax, eax @@:
cld mov eax, edi
rep stosd stosd
stosd
loop @B
mov ecx, 512/4 mov ecx, 64
mov edi, mem_block_map mov edi, mem_used_list
not eax @@:
rep stosd mov eax, edi
stosd
mov [mem_block_start], mem_block_map stosd
mov [mem_block_end], mem_block_map+512 loop @B
mov [mem_block_arr], HEAP_BASE
mov eax, mem_used.fd-MEM_LIST_OFFSET
mov [mem_used.fd], eax
mov [mem_used.bk], eax
stdcall alloc_pages, dword 32 stdcall alloc_pages, dword 32
mov ecx, 32 mov ecx, 32
mov edx, eax mov edx, eax
mov edi, HEAP_BASE mov edi, HEAP_BASE
.l1: .l1:
stdcall map_page,edi,edx,PG_SW stdcall map_page, edi, edx, PG_SW
add edi, 0x1000 add edi, 0x1000
add edx, 0x1000 add edx, 0x1000
dec ecx dec ecx
jnz .l1 jnz .l1
mov edi, HEAP_BASE mov edi, HEAP_BASE ;descriptors
mov ebx, HEAP_BASE+MEM_BLOCK_SIZE mov ebx, HEAP_BASE+MEM_BLOCK.sizeof ;free space
mov ecx, HEAP_BASE+MEM_BLOCK.sizeof*2 ;terminator
xor eax, eax xor eax, eax
mov [edi+block_next], ebx mov [edi+block_next], ebx
mov [edi+block_prev], eax mov [edi+block_prev], eax
mov [edi+list_fd], eax mov [edi+list_fd], eax
mov [edi+list_bk], eax mov [edi+list_bk], eax
mov [edi+block_base], HEAP_BASE mov [edi+block_base], HEAP_BASE
mov [edi+block_size], 4096*MEM_BLOCK_SIZE mov [edi+block_size], 4096*MEM_BLOCK.sizeof
mov [edi+block_flags], USED_BLOCK mov [edi+block_flags], USED_BLOCK
mov [ebx+block_next], eax mov [ecx+block_next], eax
mov [ebx+block_prev], eax mov [ecx+block_prev], ebx
mov [ebx+list_fd], eax mov [edi+list_fd], eax
mov [ebx+list_bk], eax mov [edi+list_bk], eax
mov [ebx+block_base], HEAP_BASE+4096*MEM_BLOCK_SIZE mov [edi+block_base], eax
mov [edi+block_size], eax
mov [edi+block_flags], USED_BLOCK
mov [ebx+block_next], ecx
mov [ebx+block_prev], edi
mov [ebx+block_base], HEAP_BASE+4096*MEM_BLOCK.sizeof
mov ecx, [pg_data.kernel_pages] mov ecx, [pg_data.kernel_pages]
shl ecx, 12 shl ecx, 12
sub ecx, HEAP_BASE-OS_BASE+4096*MEM_BLOCK_SIZE sub ecx, HEAP_BASE-OS_BASE+4096*MEM_BLOCK.sizeof
mov [heap_size], ecx mov [heap_size], ecx
mov [heap_free], ecx mov [heap_free], ecx
mov [ebx+block_size], ecx mov [ebx+block_size], ecx
mov [ebx+block_flags], FREE_BLOCK mov [ebx+block_flags], FREE_BLOCK
mov [mem_block_mask], eax mov [mem_block_mask], eax
mov [mem_block_mask+4],0x80000000 mov [mem_block_mask+4], 0x80000000
mov [mem_block_list+63*4], ebx mov ecx, mem_block_list+63*8
mov byte [mem_block_map], 0xFC list_add ebx, ecx
and [heap_mutex], 0
mov [heap_blocks], 4095 mov ecx, 4096-3-1
mov [free_blocks], 4094 mov eax, HEAP_BASE+MEM_BLOCK.sizeof*4
mov [next_memblock], HEAP_BASE+MEM_BLOCK.sizeof*3
@@:
mov [eax-MEM_BLOCK.sizeof], eax
add eax, MEM_BLOCK.sizeof
loop @B
mov [eax-MEM_BLOCK.sizeof], dword 0
mov ecx, heap_mutex
call mutex_init
mov [heap_blocks], 4094
mov [free_blocks], 4093
ret ret
endp endp
@@ -190,11 +235,18 @@ get_small_block:
bsf edi, edx bsf edi, edx
jz .high_mask jz .high_mask
add ebx, edi add ebx, edi
mov edi, [mem_block_list+ebx*4] lea ecx, [mem_block_list+ebx*8]
.check_size: mov edi, ecx
.next:
mov edi, [edi+list_fd]
cmp edi, ecx
je .err
cmp eax, [edi+block_size] cmp eax, [edi+block_size]
ja .next ja .next
ret ret
.err:
xor edi, edi
ret
.high_mask: .high_mask:
add esi, 4 add esi, 4
@@ -203,65 +255,23 @@ get_small_block:
add ebx, 32 add ebx, 32
mov edx, [esi] mov edx, [esi]
jmp .find jmp .find
.next:
mov edi, [edi+list_fd]
test edi, edi
jnz .check_size
.err:
xor edi, edi
ret
align 4
alloc_mem_block:
mov ebx, [mem_block_start]
mov ecx, [mem_block_end]
.l1:
bsf eax,[ebx];
jnz found
add ebx,4
cmp ebx, ecx
jb .l1
xor eax,eax
ret
found:
btr [ebx], eax
mov [mem_block_start],ebx
sub ebx, mem_block_map
lea eax,[eax+ebx*8]
shl eax, 5
add eax, [mem_block_arr]
dec [free_blocks]
ret
align 4 align 4
free_mem_block: free_mem_block:
mov dword [eax], 0 mov ebx, [next_memblock]
mov dword [eax+4], 0 mov [eax], ebx
mov dword [eax+8], 0 mov [next_memblock], eax
mov dword [eax+12], 0 xor ebx, ebx
mov dword [eax+16], 0
; mov dword [eax+20], 0
mov dword [eax+24], 0
mov dword [eax+28], 0
sub eax, [mem_block_arr] mov dword [eax+4], ebx
shr eax, 5 mov dword [eax+8], ebx
mov dword [eax+12], ebx
mov ebx, mem_block_map mov dword [eax+16], ebx
bts [ebx], eax ; mov dword [eax+20], 0 ;don't clear block size
mov dword [eax+24], ebx
mov dword [eax+28], ebx
inc [free_blocks] inc [free_blocks]
shr eax, 3
and eax, not 3
add eax, ebx
cmp [mem_block_start], eax
ja @f
ret
@@:
mov [mem_block_start], eax
ret
.err:
xor eax, eax
ret ret
align 4 align 4
@@ -277,18 +287,20 @@ proc alloc_kernel_space stdcall, size:dword
and eax, not 4095 and eax, not 4095
mov [size], eax mov [size], eax
mov ebx, heap_mutex
call wait_mutex ;ebx
cmp eax, [heap_free] cmp eax, [heap_free]
ja .error ja .error
mov ecx, heap_mutex
call mutex_lock
mov eax, [size]
call get_small_block ; eax call get_small_block ; eax
test edi, edi test edi, edi
jz .error jz .error_unlock
cmp [edi+block_flags], FREE_BLOCK cmp [edi+block_flags], FREE_BLOCK
jne .error jne .error_unlock
mov [block_ind], ebx ;index of allocated block mov [block_ind], ebx ;index of allocated block
@@ -296,11 +308,13 @@ proc alloc_kernel_space stdcall, size:dword
cmp eax, [size] cmp eax, [size]
je .m_eq_size je .m_eq_size
call alloc_mem_block mov esi, [next_memblock] ;new memory block
and eax, eax test esi, esi
jz .error jz .error_unlock
mov esi, eax ;esi - splitted block dec [free_blocks]
mov eax, [esi]
mov [next_memblock], eax
mov [esi+block_next], edi mov [esi+block_next], edi
mov eax, [edi+block_prev] mov eax, [edi+block_prev]
@@ -308,10 +322,8 @@ proc alloc_kernel_space stdcall, size:dword
mov [edi+block_prev], esi mov [edi+block_prev], esi
mov [esi+list_fd], 0 mov [esi+list_fd], 0
mov [esi+list_bk], 0 mov [esi+list_bk], 0
and eax, eax
jz @f
mov [eax+block_next], esi mov [eax+block_next], esi
@@:
mov ebx, [edi+block_base] mov ebx, [edi+block_base]
mov [esi+block_base], ebx mov [esi+block_base], ebx
mov edx, [size] mov edx, [size]
@@ -320,75 +332,48 @@ proc alloc_kernel_space stdcall, size:dword
sub [edi+block_size], edx sub [edi+block_size], edx
mov eax, [edi+block_size] mov eax, [edi+block_size]
shr eax, 12 calc_index eax
sub eax, 1
cmp eax, 63
jna @f
mov eax, 63
@@:
cmp eax, [block_ind] cmp eax, [block_ind]
je .m_eq_ind je .add_used
remove_from_list edi list_del edi
mov ecx, [block_ind] mov ecx, [block_ind]
mov [mem_block_list+ecx*4], edx lea edx, [mem_block_list+ecx*8]
cmp edx, [edx]
test edx, edx
jnz @f jnz @f
btr [mem_block_mask], ecx btr [mem_block_mask], ecx
@@: @@:
mov edx, [mem_block_list+eax*4]
mov [edi+list_fd], edx
test edx, edx
jz @f
mov [edx+list_bk], edi
@@:
mov [mem_block_list+eax*4], edi
bts [mem_block_mask], eax bts [mem_block_mask], eax
.m_eq_ind: lea edx, [mem_block_list+eax*8] ;edx= list head
mov ecx, mem_used.fd-MEM_LIST_OFFSET list_add edi, edx
mov edx, [ecx+list_fd] .add_used:
mov [esi+list_fd], edx
mov [esi+list_bk], ecx
mov [ecx+list_fd], esi
mov [edx+list_bk], esi
mov [esi+block_flags], USED_BLOCK call md.add_to_used
mov ecx, heap_mutex
call mutex_unlock
mov eax, [esi+block_base] mov eax, [esi+block_base]
mov ebx, [size]
sub [heap_free], ebx
and [heap_mutex], 0
pop edi pop edi
pop esi pop esi
pop ebx pop ebx
ret ret
.m_eq_size: .m_eq_size:
remove_from_list edi list_del edi
mov [mem_block_list+ebx*4], edx lea edx, [mem_block_list+ebx*8]
and edx, edx cmp edx, [edx]
jnz @f jnz @f
btr [mem_block_mask], ebx btr [mem_block_mask], ebx
@@: @@:
mov ecx, mem_used.fd-MEM_LIST_OFFSET mov esi, edi
mov edx, [ecx+list_fd] jmp .add_used
mov [edi+list_fd], edx
mov [edi+list_bk], ecx
mov [ecx+list_fd], edi
mov [edx+list_bk], edi
mov [edi+block_flags], USED_BLOCK .error_unlock:
mov eax, [edi+block_base] mov ecx, heap_mutex
mov ebx, [size] call mutex_unlock
sub [heap_free], ebx
and [heap_mutex], 0
pop edi
pop esi
pop ebx
ret
.error: .error:
xor eax, eax xor eax, eax
mov [heap_mutex], eax
pop edi pop edi
pop esi pop esi
pop ebx pop ebx
@@ -397,66 +382,49 @@ endp
align 4 align 4
proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword
push ebx
push esi mov ecx, heap_mutex
push edi call mutex_lock
mov ebx, heap_mutex
call wait_mutex ;ebx
mov eax, [base] mov eax, [base]
mov esi, [mem_used.fd]
@@:
cmp esi, mem_used.fd-MEM_LIST_OFFSET
je .fail
cmp [esi+block_base], eax call md.del_from_used
je .found test esi, esi
mov esi, [esi+list_fd] jz .fail
jmp @b
.found:
cmp [esi+block_flags], USED_BLOCK
jne .fail
mov eax, [esi+block_size] mov eax, [esi+block_size]
add [heap_free], eax add [heap_free], eax
mov edi, [esi+block_next] mov edi, [esi+block_next]
test edi, edi
jz .prev
cmp [edi+block_flags], FREE_BLOCK cmp [edi+block_flags], FREE_BLOCK
jne .prev jne .prev
remove_from_free edi list_del edi
mov edx, [edi+block_next] mov edx, [edi+block_next]
mov [esi+block_next], edx mov [esi+block_next], edx
test edx, edx
jz @f
mov [edx+block_prev], esi mov [edx+block_prev], esi
@@:
mov ecx, [edi+block_size] mov ecx, [edi+block_size]
add [esi+block_size], ecx add [esi+block_size], ecx
calc_index ecx
lea edx, [mem_block_list+ecx*8]
cmp edx, [edx]
jne @F
btr [mem_block_mask], ecx
@@:
mov eax, edi mov eax, edi
call free_mem_block call free_mem_block
.prev: .prev:
mov edi, [esi+block_prev] mov edi, [esi+block_prev]
test edi, edi
jz .insert
cmp [edi+block_flags], FREE_BLOCK cmp [edi+block_flags], FREE_BLOCK
jne .insert jne .insert
remove_from_used esi
mov edx, [esi+block_next] mov edx, [esi+block_next]
mov [edi+block_next], edx mov [edi+block_next], edx
test edx, edx
jz @f
mov [edx+block_prev], edi mov [edx+block_prev], edi
@@:
mov eax, esi mov eax, esi
call free_mem_block call free_mem_block
@@ -465,67 +433,40 @@ proc free_kernel_space stdcall uses ebx ecx edx esi edi, base:dword
add eax, ecx add eax, ecx
mov [edi+block_size], eax mov [edi+block_size], eax
calc_index eax calc_index eax ;new index
calc_index ecx calc_index ecx ;old index
cmp eax, ecx cmp eax, ecx
je .m_eq je .m_eq
push ecx push ecx
remove_from_list edi list_del edi
pop ecx pop ecx
cmp [mem_block_list+ecx*4], edi lea edx, [mem_block_list+ecx*8]
jne @f cmp edx, [edx]
mov [mem_block_list+ecx*4], edx jne .add_block
@@:
cmp [mem_block_list+ecx*4], 0
jne @f
btr [mem_block_mask], ecx btr [mem_block_mask], ecx
@@: .add_block:
mov esi, [mem_block_list+eax*4]
mov [mem_block_list+eax*4], edi
mov [edi+list_fd], esi
test esi, esi
jz @f
mov [esi+list_bk], edi
@@:
bts [mem_block_mask], eax bts [mem_block_mask], eax
lea edx, [mem_block_list+eax*8]
list_add edi, edx
.m_eq: .m_eq:
mov ecx, heap_mutex
call mutex_unlock
xor eax, eax xor eax, eax
mov [heap_mutex], eax not eax
dec eax
pop edi
pop esi
pop ebx
ret ret
.insert: .insert:
remove_from_used esi mov [esi+block_flags], FREE_BLOCK
mov eax, [esi+block_size] mov eax, [esi+block_size]
calc_index eax calc_index eax
mov edi, esi
jmp .add_block
mov edi, [mem_block_list+eax*4]
mov [mem_block_list+eax*4], esi
mov [esi+list_fd], edi
test edi, edi
jz @f
mov [edi+list_bk], esi
@@:
bts [mem_block_mask], eax
mov [esi+block_flags],FREE_BLOCK
xor eax, eax
mov [heap_mutex], eax
dec eax
pop edi
pop esi
pop ebx
ret
.fail: .fail:
mov ecx, heap_mutex
call mutex_unlock
xor eax, eax xor eax, eax
mov [heap_mutex], eax
pop edi
pop esi
pop ebx
ret ret
endp endp
@@ -571,7 +512,7 @@ proc kernel_alloc stdcall, size:dword
mov edi, eax mov edi, eax
mov edx, [lin_addr] mov edx, [lin_addr]
@@: @@:
stdcall map_page,edx,edi,dword PG_SW stdcall map_page, edx, edi, dword PG_SW
add edx, 0x1000 add edx, 0x1000
add edi, 0x1000 add edi, 0x1000
dec ecx dec ecx
@@ -587,7 +528,7 @@ proc kernel_alloc stdcall, size:dword
test eax, eax test eax, eax
jz .err jz .err
stdcall map_page,edx,eax,dword PG_SW stdcall map_page, edx, eax, dword PG_SW
add edx, 0x1000 add edx, 0x1000
dec ecx dec ecx
jnz @B jnz @B
@@ -605,37 +546,31 @@ endp
align 4 align 4
proc kernel_free stdcall, base:dword proc kernel_free stdcall, base:dword
push ebx esi push ebx esi
mov ebx, heap_mutex mov ecx, heap_mutex
call wait_mutex ;ebx call mutex_lock
mov eax, [base] mov eax, [base]
mov esi, [mem_used.fd] call md.find_used
@@:
cmp esi, mem_used.fd-MEM_LIST_OFFSET
je .fail
cmp [esi+block_base], eax mov ecx, heap_mutex
je .found
mov esi, [esi+list_fd]
jmp @b
.found:
cmp [esi+block_flags], USED_BLOCK cmp [esi+block_flags], USED_BLOCK
jne .fail jne .fail
and [heap_mutex], 0 call mutex_unlock
push ecx mov eax, [esi+block_base]
mov ecx, [esi+block_size]; mov ecx, [esi+block_size]
shr ecx, 12 shr ecx, 12
call release_pages ;eax, ecx call release_pages ;eax, ecx
pop ecx
stdcall free_kernel_space, [base] stdcall free_kernel_space, [base]
pop esi ebx pop esi ebx
ret ret
.fail: .fail:
and [heap_mutex], 0 call mutex_unlock
xor eax, eax
pop esi ebx pop esi ebx
ret ret
endp endp
@@ -654,11 +589,11 @@ HEAP_TOP equ 0x5FC00000
align 4 align 4
proc init_heap proc init_heap
mov ebx,[current_slot] mov ebx, [current_slot]
mov eax, [ebx+APPDATA.heap_top] mov eax, [ebx+APPDATA.heap_top]
test eax, eax test eax, eax
jz @F jz @F
sub eax,[ebx+APPDATA.heap_base] sub eax, [ebx+APPDATA.heap_base]
sub eax, 4096 sub eax, 4096
ret ret
@@: @@:
@@ -1226,8 +1161,8 @@ proc alloc_service
.find: .find:
btr [srv_map], eax btr [srv_map], eax
popf popf
shl eax,0x02 shl eax, 0x02
lea eax,[srv_tab+eax+eax*8] ;srv_tab+eax*36 lea eax, [srv_tab+eax+eax*8] ;srv_tab+eax*36
ret ret
endp endp
@@ -1325,7 +1260,7 @@ align 4
cmp esi, shmem_list cmp esi, shmem_list
je .not_found je .not_found
lea edx, [esi+SMEM.name] ; link , base, size lea edx, [esi+SMEM.name]; link , base, size
stdcall strncmp, edx, ebx, 32 stdcall strncmp, edx, ebx, 32
test eax, eax test eax, eax
je .found je .found
@@ -1521,13 +1456,14 @@ proc shmem_close stdcall, name:dword
test edi, edi test edi, edi
jz .next jz .next
lea eax, [edi+SMEM.name] lea edi, [edi+SMEM.name]
stdcall strncmp, [name], edi, 32 stdcall strncmp, [name], edi, 32
test eax, eax test eax, eax
jne .next jne .next
stdcall user_free, [esi+SMAP.base] stdcall user_free, [esi+SMAP.base]
mov eax, esi
call [esi+APPOBJ.destroy] call [esi+APPOBJ.destroy]
@@: @@:
popfd popfd

View File

@@ -0,0 +1,229 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
IRQ_RESERVED equ 24
IRQ_POOL_SIZE equ 48
uglobal
align 16
irqh_tab rd LHEAD.sizeof * IRQ_RESERVED / 4
irqh_pool rd IRQH.sizeof * IRQ_POOL_SIZE /4
next_irqh rd 1
irq_active_set rd 1
irq_failed rd IRQ_RESERVED
endg
align 4
init_irqs:
mov ecx, IRQ_RESERVED
mov edi, irqh_tab
@@:
mov eax, edi
stosd
stosd
loop @B
mov ecx, IRQ_POOL_SIZE-1
mov eax, irqh_pool+IRQH.sizeof
mov [next_irqh], irqh_pool
@@:
mov [eax-IRQH.sizeof], eax
add eax, IRQH.sizeof
loop @B
mov [eax-IRQH.sizeof], dword 0
ret
align 4
proc attach_int_handler stdcall, irq:dword, handler:dword, user_data:dword
locals
.irqh dd ?
endl
and [.irqh], 0
push ebx
mov ebx, [irq] ;irq num
test ebx, ebx
jz .err
cmp ebx, IRQ_RESERVED
jae .err
mov edx, [handler]
test edx, edx
jz .err
pushfd
cli
;allocate handler
mov ecx, [next_irqh]
test ecx, ecx
jz .fail
mov eax, [ecx]
mov [next_irqh], eax
mov [.irqh], ecx
mov [irq_failed+ebx*4], 0;clear counter
mov eax, [user_data]
mov [ecx+IRQH.handler], edx
mov [ecx+IRQH.data], eax
lea edx, [irqh_tab+ebx*8]
list_add_tail ecx, edx ;clobber eax
stdcall enable_irq, ebx
.fail:
popfd
.err:
pop ebx
mov eax, [.irqh]
ret
endp
if 0
align 4
proc get_int_handler stdcall, irq:dword
mov eax, [irq]
cmp eax, 15
ja .fail
mov eax, [irq_tab + 4 * eax]
ret
.fail:
xor eax, eax
ret
endp
end if
align 4
proc detach_int_handler
ret
endp
macro irq_serv_h [num] {
forward
align 4
.irq_#num :
push num
jmp .main
}
align 16
irq_serv:
; .irq_1:
; push 1
; jmp .main
; etc...
irq_serv_h 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 15
irq_serv_h 16, 17, 18, 19, 20, 21, 22, 23
purge irq_serv_h
align 16
.main:
save_ring3_context
mov ebp, [esp + 32]
mov bx, app_data;os_data
mov ds, bx
mov es, bx
cmp [v86_irqhooks+ebp*8], 0
jnz v86_irq
cmp bp, 6
jnz @f
push ebp
call [fdc_irq_func]
pop ebp
@@:
cmp bp, 14
jnz @f
push ebp
call [irq14_func]
pop ebp
@@:
cmp bp, 15
jnz @f
push ebp
call [irq15_func]
pop ebp
@@:
bts [irq_active_set], ebp
lea esi, [irqh_tab+ebp*8] ; esi= list head
mov ebx, esi
.next:
mov ebx, [ebx+IRQH.list.next]; ebx= irqh pointer
cmp ebx, esi
je .done
push ebx ; FIX THIS
push edi
push esi
push [ebx+IRQH.data]
call [ebx+IRQH.handler]
add esp, 4
pop esi
pop edi
pop ebx
test eax, eax
jz .next
btr [irq_active_set], ebp
jmp .next
.done:
btr [irq_active_set], ebp
jnc .exit
inc [irq_failed+ebp*4]
.exit:
mov [check_idle_semaphore], 5
mov ecx, ebp
call irq_eoi
restore_ring3_context
add esp, 4
iret
align 4
irqD:
push eax
push ecx
xor eax, eax
out 0xf0, al
mov cl, 13
call irq_eoi
pop ecx
pop eax
iret

View File

@@ -20,7 +20,7 @@ $Revision$
; esi= nb ; esi= nb
; ebx= idx ; ebx= idx
; ;
align 16 align 4
malloc: malloc:
push esi push esi
@@ -31,8 +31,8 @@ malloc:
and esi, -8 and esi, -8
add esi, 8 add esi, 8
mov ebx, mst.mutex mov ecx, mst.mutex
call wait_mutex ;ebx call mutex_lock
cmp esi, 256 cmp esi, 256
jae .large jae .large
@@ -92,9 +92,13 @@ malloc:
pop edi pop edi
pop ebp pop ebp
.done: .done:
mov esi, eax
mov ecx, mst.mutex
call mutex_unlock
mov eax, esi
pop esi pop esi
mov [mst.mutex], 0
ret ret
.split: .split:
lea ebx, [edx+8] ;ebx=mem lea ebx, [edx+8] ;ebx=mem
@@ -133,16 +137,16 @@ malloc:
mov [edx+12], eax ; F->bk = r; mov [edx+12], eax ; F->bk = r;
mov [eax+8], edx ; r->fd = F; mov [eax+8], edx ; r->fd = F;
mov [eax+12], ecx ; r->bk = B; mov [eax+12], ecx ; r->bk = B;
mov eax, ebx mov eax, ebx
pop esi jmp .done
mov [mst.mutex], 0
ret
.small: .small:
; if (ms.treemap != 0 && (mem = malloc_small(nb)) != 0) ; if (ms.treemap != 0 && (mem = malloc_small(nb)) != 0)
;;;;;;;;;;; start a change <lrz> ;;;;;;;;;;; start a change <lrz>
mov eax,[mst.treemap] mov eax, [mst.treemap]
test eax,eax test eax, eax
;;;;;;;;;;; end the change <lrz> ;;;;;;;;;;; end the change <lrz>
; cmp [mst.treemap], 0 ; cmp [mst.treemap], 0
jz .from_top jz .from_top
@@ -150,9 +154,8 @@ malloc:
call malloc_small call malloc_small
test eax, eax test eax, eax
jz .from_top jz .from_top
pop esi jmp .done
and [mst.mutex], 0
ret
.large: .large:
; if (ms.treemap != 0 && (mem = malloc_large(nb)) != 0) ; if (ms.treemap != 0 && (mem = malloc_large(nb)) != 0)
@@ -189,19 +192,19 @@ malloc:
mov [edx+4], eax mov [edx+4], eax
mov [ecx+4], esi mov [ecx+4], esi
lea eax, [ecx+8] lea eax, [ecx+8]
pop esi jmp .done
and [mst.mutex], 0
ret
.fail: .fail:
xor eax, eax xor eax, eax
pop esi jmp .done
and [mst.mutex], 0
ret
; param ; param
; eax= mem ; eax= mem
align 4
free: free:
test eax, eax
jz .exit
push edi push edi
mov edi, eax mov edi, eax
add edi, -8 add edi, -8
@@ -211,8 +214,8 @@ free:
test byte [edi+4], 2 test byte [edi+4], 2
je .fail je .fail
mov ebx, mst.mutex mov ecx, mst.mutex
call wait_mutex ;ebx call mutex_lock
; psize = p->head & (~3); ; psize = p->head & (~3);
@@ -289,11 +292,16 @@ free:
mov [mst.top], edi mov [mst.top], edi
mov [edi+4], eax mov [edi+4], eax
.fail2: .fail2:
and [mst.mutex], 0 mov esi, eax
mov ecx, mst.mutex
call mutex_unlock
mov eax, esi
pop esi pop esi
.fail: .fail:
pop edi pop edi
.exit:
ret ret
@@: @@:
; nsize = next->head & ~INUSE_BITS; ; nsize = next->head & ~INUSE_BITS;
@@ -410,13 +418,15 @@ insert_chunk:
mov [esi+8], edx ;P->fd = F mov [esi+8], edx ;P->fd = F
mov [esi+12], eax ;P->bk = B mov [esi+12], eax ;P->bk = B
pop esi pop esi
and [mst.mutex], 0 mov ecx, mst.mutex
call mutex_unlock
ret ret
.large: .large:
mov ebx, eax mov ebx, eax
call insert_large_chunk call insert_large_chunk
pop esi pop esi
and [mst.mutex], 0 mov ecx, mst.mutex
call mutex_unlock
ret ret
@@ -636,7 +646,7 @@ malloc_small:
push edi push edi
bsf eax,[mst.treemap] bsf eax, [mst.treemap]
mov ecx, [mst.treebins+eax*4] mov ecx, [mst.treebins+eax*4]
; rsize = (t->head & ~INUSE_BITS) - nb; ; rsize = (t->head & ~INUSE_BITS) - nb;
@@ -1025,5 +1035,8 @@ init_malloc:
cmp eax, mst.smallbins+512 cmp eax, mst.smallbins+512
jb @B jb @B
mov ecx, mst.mutex
call mutex_init
ret ret

View File

@@ -22,14 +22,14 @@ proc alloc_page
mov ebx, [page_start] mov ebx, [page_start]
mov ecx, [page_end] mov ecx, [page_end]
.l1: .l1:
bsf eax,[ebx]; bsf eax, [ebx];
jnz .found jnz .found
add ebx,4 add ebx, 4
cmp ebx, ecx cmp ebx, ecx
jb .l1 jb .l1
pop ebx pop ebx
popfd popfd
xor eax,eax xor eax, eax
ret ret
.found: .found:
;//- ;//-
@@ -37,7 +37,7 @@ proc alloc_page
jz .out_of_memory jz .out_of_memory
;//- ;//-
btr [ebx], eax btr [ebx], eax
mov [page_start],ebx mov [page_start], ebx
sub ebx, sys_pgmap sub ebx, sys_pgmap
lea eax, [eax+ebx*8] lea eax, [eax+ebx*8]
shl eax, 12 shl eax, 12
@@ -84,7 +84,7 @@ proc alloc_pages stdcall, count:dword
dec edx dec edx
jz .ok jz .ok
inc ecx inc ecx
cmp ecx,ebx cmp ecx, ebx
jb .match jb .match
.out_of_memory: .out_of_memory:
.fail: .fail:
@@ -171,9 +171,14 @@ proc map_io_mem stdcall, base:dword, size:dword, flags:dword
push ebx push ebx
push edi push edi
mov eax, [size] mov eax, [size]
add eax, [base]
add eax, 4095 add eax, 4095
and eax, -4096 and eax, -4096
mov ecx, [base]
and ecx, -4096
sub eax, ecx
mov [size], eax mov [size], eax
stdcall alloc_kernel_space, eax stdcall alloc_kernel_space, eax
test eax, eax test eax, eax
jz .fail jz .fail
@@ -181,7 +186,7 @@ proc map_io_mem stdcall, base:dword, size:dword, flags:dword
mov edi, 0x1000 mov edi, 0x1000
mov ebx, eax mov ebx, eax
mov ecx,[size] mov ecx, [size]
mov edx, [base] mov edx, [base]
shr eax, 12 shr eax, 12
shr ecx, 12 shr ecx, 12
@@ -189,9 +194,7 @@ proc map_io_mem stdcall, base:dword, size:dword, flags:dword
or edx, [flags] or edx, [flags]
@@: @@:
mov [page_tabs+eax*4], edx mov [page_tabs+eax*4], edx
; push eax
invlpg [ebx] invlpg [ebx]
; pop eax
inc eax inc eax
add ebx, edi add ebx, edi
add edx, edi add edx, edi
@@ -214,30 +217,32 @@ endp
align 4 align 4
commit_pages: commit_pages:
push edi
test ecx, ecx test ecx, ecx
jz .fail jz .fail
mov edi, ebx push edi
mov ebx, pg_data.pg_mutex push eax
call wait_mutex ;ebx push ecx
mov ecx, pg_data.mutex
call mutex_lock
pop ecx
pop eax
mov edx, 0x1000 mov edi, ebx
mov ebx, edi shr edi, 12
shr ebx, 12 lea edi, [page_tabs+edi*4]
@@: @@:
mov [page_tabs+ebx*4], eax stosd
; push eax invlpg [ebx]
invlpg [edi] add eax, 0x1000
; pop eax add ebx, 0x1000
add edi, edx loop @B
add eax, edx
inc ebx
dec ecx
jnz @B
mov [pg_data.pg_mutex],ecx
.fail:
pop edi pop edi
mov ecx, pg_data.mutex
call mutex_unlock
.fail:
ret ret
@@ -248,15 +253,21 @@ commit_pages:
align 4 align 4
release_pages: release_pages:
pushad push ebp
mov ebx, pg_data.pg_mutex push esi
call wait_mutex ;ebx push edi
push ebx
mov esi, eax mov esi, eax
mov edi, eax mov edi, eax
shr esi, 10 shr esi, 12
add esi, page_tabs lea esi, [page_tabs+esi*4]
push ecx
mov ecx, pg_data.mutex
call mutex_lock
pop ecx
mov ebp, [pg_data.pages_free] mov ebp, [pg_data.pages_free]
mov ebx, [page_start] mov ebx, [page_start]
@@ -264,9 +275,7 @@ release_pages:
@@: @@:
xor eax, eax xor eax, eax
xchg eax, [esi] xchg eax, [esi]
push eax
invlpg [edi] invlpg [edi]
pop eax
test eax, 1 test eax, 1
jz .next jz .next
@@ -285,11 +294,16 @@ release_pages:
.next: .next:
add edi, 0x1000 add edi, 0x1000
add esi, 4 add esi, 4
dec ecx loop @B
jnz @B
mov [pg_data.pages_free], ebp mov [pg_data.pages_free], ebp
and [pg_data.pg_mutex],0 mov ecx, pg_data.mutex
popad call mutex_unlock
pop ebx
pop edi
pop esi
pop ebp
ret ret
; param ; param
@@ -343,7 +357,7 @@ proc init_LFB
cmp dword [LFBAddress], -1 cmp dword [LFBAddress], -1
jne @f jne @f
mov [BOOT_VAR+0x901c],byte 2 mov [BOOT_VAR+0x901c], byte 2
stdcall alloc_pages, (0x280000 / 4096) stdcall alloc_pages, (0x280000 / 4096)
push eax push eax
@@ -357,9 +371,9 @@ proc init_LFB
mov [LFBAddress], dword LFB_BASE mov [LFBAddress], dword LFB_BASE
ret ret
@@: @@:
test [SCR_MODE],word 0100000000000000b test [SCR_MODE], word 0100000000000000b
jnz @f jnz @f
mov [BOOT_VAR+0x901c],byte 2 mov [BOOT_VAR+0x901c], byte 2
ret ret
@@: @@:
call init_mtrr call init_mtrr
@@ -423,16 +437,16 @@ endp
align 4 align 4
proc new_mem_resize stdcall, new_size:dword proc new_mem_resize stdcall, new_size:dword
mov ebx, pg_data.pg_mutex mov ecx, pg_data.mutex
call wait_mutex ;ebx call mutex_lock
mov edi, [new_size] mov edi, [new_size]
add edi,4095 add edi, 4095
and edi,not 4095 and edi, not 4095
mov [new_size], edi mov [new_size], edi
mov edx,[current_slot] mov edx, [current_slot]
cmp [edx+APPDATA.heap_base],0 cmp [edx+APPDATA.heap_base], 0
jne .exit jne .exit
mov esi, [edx+APPDATA.mem_size] mov esi, [edx+APPDATA.mem_size]
@@ -456,7 +470,8 @@ proc new_mem_resize stdcall, new_size:dword
pop eax pop eax
call free_page call free_page
.next: add edi, 1 .next:
add edi, 1
cmp edi, esi cmp edi, esi
jb @B jb @B
@@ -464,8 +479,10 @@ proc new_mem_resize stdcall, new_size:dword
mov ebx, [new_size] mov ebx, [new_size]
call update_mem_size call update_mem_size
mov ecx, pg_data.mutex
call mutex_unlock
xor eax, eax xor eax, eax
dec [pg_data.pg_mutex]
ret ret
.expand: .expand:
@@ -517,7 +534,7 @@ proc new_mem_resize stdcall, new_size:dword
call alloc_page call alloc_page
test eax, eax test eax, eax
jz .exit jz .exit
stdcall map_page,esi,eax,dword PG_UW stdcall map_page, esi, eax, dword PG_UW
push edi push edi
mov edi, esi mov edi, esi
@@ -539,9 +556,11 @@ proc new_mem_resize stdcall, new_size:dword
pop edi pop edi
pop esi pop esi
.exit: .exit:
mov ecx, pg_data.mutex
call mutex_unlock
xor eax, eax xor eax, eax
inc eax inc eax
dec [pg_data.pg_mutex]
ret ret
endp endp
@@ -550,26 +569,26 @@ update_mem_size:
; ebx = new memory size ; ebx = new memory size
; destroys eax,ecx,edx ; destroys eax,ecx,edx
mov [APPDATA.mem_size+edx],ebx mov [APPDATA.mem_size+edx], ebx
;search threads and update ;search threads and update
;application memory size infomation ;application memory size infomation
mov ecx,[APPDATA.dir_table+edx] mov ecx, [APPDATA.dir_table+edx]
mov eax,2 mov eax, 2
.search_threads: .search_threads:
;eax = current slot ;eax = current slot
;ebx = new memory size ;ebx = new memory size
;ecx = page directory ;ecx = page directory
cmp eax,[TASK_COUNT] cmp eax, [TASK_COUNT]
jg .search_threads_end jg .search_threads_end
mov edx,eax mov edx, eax
shl edx,5 shl edx, 5
cmp word [CURRENT_TASK+edx+TASKDATA.state],9 ;if slot empty? cmp word [CURRENT_TASK+edx+TASKDATA.state], 9 ;if slot empty?
jz .search_threads_next jz .search_threads_next
shl edx,3 shl edx, 3
cmp [SLOT_BASE+edx+APPDATA.dir_table],ecx ;if it is our thread? cmp [SLOT_BASE+edx+APPDATA.dir_table], ecx ;if it is our thread?
jnz .search_threads_next jnz .search_threads_next
mov [SLOT_BASE+edx+APPDATA.mem_size],ebx ;update memory size mov [SLOT_BASE+edx+APPDATA.mem_size], ebx ;update memory size
.search_threads_next: .search_threads_next:
inc eax inc eax
jmp .search_threads jmp .search_threads
@@ -655,7 +674,7 @@ end if
test eax, eax test eax, eax
jz .fail jz .fail
stdcall map_page,[.err_addr],eax,PG_UW stdcall map_page, [.err_addr], eax, PG_UW
mov edi, [.err_addr] mov edi, [.err_addr]
and edi, 0xFFFFF000 and edi, 0xFFFFF000
@@ -664,7 +683,7 @@ end if
;cld ;caller is duty for this ;cld ;caller is duty for this
rep stosd rep stosd
.exit: ;iret with repeat fault instruction .exit: ;iret with repeat fault instruction
add esp,12 ;clear in stack: locals(.err_addr) + #PF + ret_to_caller add esp, 12;clear in stack: locals(.err_addr) + #PF + ret_to_caller
restore_ring3_context restore_ring3_context
iretd iretd
@@ -693,7 +712,7 @@ end if
call alloc_page call alloc_page
test eax, eax test eax, eax
jz .fail jz .fail
stdcall map_page,ebx,eax,PG_UW stdcall map_page, ebx, eax, PG_UW
mov edi, ebx mov edi, ebx
mov ecx, 1024 mov ecx, 1024
sub ebx, [esi+HDLL.base] sub ebx, [esi+HDLL.base]
@@ -707,7 +726,7 @@ end if
test eax, PG_MAP test eax, PG_MAP
jz .fail ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> jz .fail ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
test eax,12 ;U/S (+below) test eax, 12 ;U/S (+below)
jnz .fail ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> jnz .fail ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
;test eax, 8 ;test eax, 8
@@ -730,7 +749,7 @@ end if
jz .fail jz .fail
push eax push eax
stdcall map_page,[.err_addr],eax,dword PG_SW stdcall map_page, [.err_addr], eax, dword PG_SW
pop eax pop eax
mov edi, [.err_addr] mov edi, [.err_addr]
and edi, -4096 and edi, -4096
@@ -762,7 +781,7 @@ proc map_mem stdcall, lin_addr:dword,slot:dword,\
mov eax, [SLOT_BASE+eax+APPDATA.dir_table] mov eax, [SLOT_BASE+eax+APPDATA.dir_table]
and eax, 0xFFFFF000 and eax, 0xFFFFF000
stdcall map_page,[ipc_pdir],eax,PG_UW stdcall map_page, [ipc_pdir], eax, PG_UW
mov ebx, [ofs] mov ebx, [ofs]
shr ebx, 22 shr ebx, 22
mov esi, [ipc_pdir] mov esi, [ipc_pdir]
@@ -770,7 +789,7 @@ proc map_mem stdcall, lin_addr:dword,slot:dword,\
mov eax, [esi+ebx*4] mov eax, [esi+ebx*4]
and eax, 0xFFFFF000 and eax, 0xFFFFF000
jz .exit jz .exit
stdcall map_page,edi,eax,PG_UW stdcall map_page, edi, eax, PG_UW
; inc ebx ; inc ebx
; add edi, 0x1000 ; add edi, 0x1000
; mov eax, [esi+ebx*4] ; mov eax, [esi+ebx*4]
@@ -779,7 +798,8 @@ proc map_mem stdcall, lin_addr:dword,slot:dword,\
; and eax, 0xFFFFF000 ; and eax, 0xFFFFF000
; stdcall map_page, edi, eax ; stdcall map_page, edi, eax
@@: mov edi, [lin_addr] @@:
mov edi, [lin_addr]
and edi, 0xFFFFF000 and edi, 0xFFFFF000
mov ecx, [buf_size] mov ecx, [buf_size]
add ecx, 4095 add ecx, 4095
@@ -792,7 +812,7 @@ proc map_mem stdcall, lin_addr:dword,slot:dword,\
mov esi, [ipc_ptab] mov esi, [ipc_ptab]
.map: .map:
stdcall safe_map_page,[slot],[req_access],[ofs] stdcall safe_map_page, [slot], [req_access], [ofs]
jnc .exit jnc .exit
add dword [ebp-4], 4096 add dword [ebp-4], 4096
add [ofs], 4096 add [ofs], 4096
@@ -807,7 +827,7 @@ proc map_mem stdcall, lin_addr:dword,slot:dword,\
mov eax, [eax+ebx*4] mov eax, [eax+ebx*4]
and eax, 0xFFFFF000 and eax, 0xFFFFF000
jz .exit jz .exit
stdcall map_page,esi,eax,PG_UW stdcall map_page, esi, eax, PG_UW
xor edx, edx xor edx, edx
jmp .map jmp .map
@@ -828,7 +848,7 @@ proc map_memEx stdcall, lin_addr:dword,slot:dword,\
mov eax, [SLOT_BASE+eax+APPDATA.dir_table] mov eax, [SLOT_BASE+eax+APPDATA.dir_table]
and eax, 0xFFFFF000 and eax, 0xFFFFF000
stdcall map_page,[proc_mem_pdir],eax,PG_UW stdcall map_page, [proc_mem_pdir], eax, PG_UW
mov ebx, [ofs] mov ebx, [ofs]
shr ebx, 22 shr ebx, 22
mov esi, [proc_mem_pdir] mov esi, [proc_mem_pdir]
@@ -837,9 +857,10 @@ proc map_memEx stdcall, lin_addr:dword,slot:dword,\
and eax, 0xFFFFF000 and eax, 0xFFFFF000
test eax, eax test eax, eax
jz .exit jz .exit
stdcall map_page,edi,eax,PG_UW stdcall map_page, edi, eax, PG_UW
@@: mov edi, [lin_addr] @@:
mov edi, [lin_addr]
and edi, 0xFFFFF000 and edi, 0xFFFFF000
mov ecx, [buf_size] mov ecx, [buf_size]
add ecx, 4095 add ecx, 4095
@@ -852,7 +873,7 @@ proc map_memEx stdcall, lin_addr:dword,slot:dword,\
mov esi, [proc_mem_tab] mov esi, [proc_mem_tab]
.map: .map:
stdcall safe_map_page,[slot],[req_access],[ofs] stdcall safe_map_page, [slot], [req_access], [ofs]
jnc .exit jnc .exit
add dword [ebp-4], 0x1000 add dword [ebp-4], 0x1000
add edi, 0x1000 add edi, 0x1000
@@ -960,17 +981,18 @@ sys_IPC:
dec ebx dec ebx
jnz @f jnz @f
mov eax,[current_slot] mov eax, [current_slot]
pushf pushf
cli cli
mov [eax+APPDATA.ipc_start],ecx ;set fields in extended information area mov [eax+APPDATA.ipc_start], ecx ;set fields in extended information area
mov [eax+APPDATA.ipc_size],edx mov [eax+APPDATA.ipc_size], edx
add edx, ecx add edx, ecx
add edx, 4095 add edx, 4095
and edx, not 4095 and edx, not 4095
.touch: mov eax, [ecx] .touch:
mov eax, [ecx]
add ecx, 0x1000 add ecx, 0x1000
cmp ecx, edx cmp ecx, edx
jb .touch jb .touch
@@ -989,7 +1011,7 @@ sys_IPC:
mov [esp+32], eax mov [esp+32], eax
ret ret
@@: @@:
or eax,-1 or eax, -1
mov [esp+32], eax mov [esp+32], eax
ret ret
@@ -1029,13 +1051,13 @@ proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword
mov eax, [PID] mov eax, [PID]
call pid_to_slot call pid_to_slot
test eax,eax test eax, eax
jz .no_pid jz .no_pid
mov [dst_slot], eax mov [dst_slot], eax
shl eax,8 shl eax, 8
mov edi,[eax+SLOT_BASE+0xa0] ;is ipc area defined? mov edi, [eax+SLOT_BASE+0xa0] ;is ipc area defined?
test edi,edi test edi, edi
jz .no_ipc_area jz .no_ipc_area
mov ebx, edi mov ebx, edi
@@ -1046,16 +1068,16 @@ proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword
mov [buf_size], esi mov [buf_size], esi
mov ecx, [ipc_tmp] mov ecx, [ipc_tmp]
cmp esi, 0x40000-0x1000 ; size of [ipc_tmp] minus one page cmp esi, 0x40000-0x1000; size of [ipc_tmp] minus one page
jbe @f jbe @f
push esi edi push esi edi
add esi,0x1000 add esi, 0x1000
stdcall alloc_kernel_space,esi stdcall alloc_kernel_space, esi
mov ecx, eax mov ecx, eax
pop edi esi pop edi esi
@@: @@:
mov [used_buf], ecx mov [used_buf], ecx
stdcall map_mem, ecx, [dst_slot],\ stdcall map_mem, ecx, [dst_slot], \
edi, esi, PG_SW edi, esi, PG_SW
mov edi, [dst_offset] mov edi, [dst_offset]
@@ -1070,7 +1092,7 @@ proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword
ja .buffer_overflow ;esi<0 - not enough memory in buffer ja .buffer_overflow ;esi<0 - not enough memory in buffer
mov dword [edi+4], ebx mov dword [edi+4], ebx
mov eax,[TASK_BASE] mov eax, [TASK_BASE]
mov eax, [eax+0x04] ;eax - our PID mov eax, [eax+0x04] ;eax - our PID
add edi, edx add edi, edx
mov [edi], eax mov [edi], eax
@@ -1106,11 +1128,11 @@ proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword
mov eax, [dst_slot] mov eax, [dst_slot]
shl eax, 8 shl eax, 8
or [eax+SLOT_BASE+0xA8],dword 0x40 or [eax+SLOT_BASE+0xA8], dword 0x40
cmp dword [check_idle_semaphore],20 cmp dword [check_idle_semaphore], 20
jge .ipc_no_cis jge .ipc_no_cis
mov dword [check_idle_semaphore],5 mov dword [check_idle_semaphore], 5
.ipc_no_cis: .ipc_no_cis:
push 0 push 0
jmp .ret jmp .ret
@@ -1132,7 +1154,7 @@ proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword
mov eax, [used_buf] mov eax, [used_buf]
cmp eax, [ipc_tmp] cmp eax, [ipc_tmp]
jz @f jz @f
stdcall free_kernel_space,eax stdcall free_kernel_space, eax
@@: @@:
pop eax pop eax
popf popf
@@ -1169,7 +1191,7 @@ sysfn_meminfo:
align 4 align 4
f68: f68:
cmp ebx,4 cmp ebx, 4
jbe sys_sheduler jbe sys_sheduler
cmp ebx, 11 cmp ebx, 11
@@ -1194,7 +1216,7 @@ f68:
.14: .14:
cmp ecx, OS_BASE cmp ecx, OS_BASE
jae .fail jae .fail
mov edi,ecx mov edi, ecx
call get_event_ex call get_event_ex
mov [esp+32], eax mov [esp+32], eax
ret ret
@@ -1271,13 +1293,13 @@ f68:
mov [esp+20], edx ; reg_ebx+8 mov [esp+20], edx ; reg_ebx+8
ret ret
.25: .25:
cmp ecx,32 cmp ecx, 32
jae .fail jae .fail
mov eax, [current_slot] mov eax, [current_slot]
btr [eax+APPDATA.except_mask],ecx btr [eax+APPDATA.except_mask], ecx
setc byte[esp+32] setc byte[esp+32]
jecxz @f jecxz @f
bts [eax+APPDATA.except_mask],ecx bts [eax+APPDATA.except_mask], ecx
@@: @@:
ret ret
@@ -1331,7 +1353,7 @@ endp
align 4 align 4
proc init_mtrr proc init_mtrr
cmp [BOOT_VAR+0x901c],byte 2 cmp [BOOT_VAR+0x901c], byte 2
je .exit je .exit
bt [cpu_caps], CAPS_MTRR bt [cpu_caps], CAPS_MTRR
@@ -1382,11 +1404,11 @@ proc init_mtrr
; enable MTRRs ; enable MTRRs
pop eax pop eax
or ah, 8 or ah, 8
and al, 0xF0 ; default memtype = UC and al, 0xF0; default memtype = UC
mov ecx, 0x2FF mov ecx, 0x2FF
wrmsr wrmsr
.skip_init: .skip_init:
stdcall set_mtrr, [LFBAddress],[LFBSize],MEM_WC stdcall set_mtrr, [LFBAddress], [LFBSize], MEM_WC
wbinvd ;again invalidate wbinvd ;again invalidate
@@ -1407,7 +1429,7 @@ proc set_mtrr stdcall, base:dword,size:dword,mem_type:dword
test ah, 8 test ah, 8
jz .found jz .found
rdmsr rdmsr
mov al, 0 ; clear memory type field mov al, 0; clear memory type field
cmp eax, [base] cmp eax, [base]
jz .ret jz .ret
add ecx, 3 add ecx, 3
@@ -1448,7 +1470,7 @@ proc stall stdcall, delay:dword
mov ecx, edx ;high mov ecx, edx ;high
rdtsc rdtsc
add ebx, eax add ebx, eax
adc ecx,edx adc ecx, edx
@@: @@:
rdtsc rdtsc
sub eax, ebx sub eax, ebx

View File

@@ -122,7 +122,7 @@ L2:
L12: L12:
lea ebx, [eax-8] lea ebx, [eax-8]
xor edi, edi xor edi, edi
shr ebx,1 shr ebx, 1
jmp L13 jmp L13
L14: L14:
movzx eax, WORD PTR [ecx+8+edi*2] movzx eax, WORD PTR [ecx+8+edi*2]
@@ -283,20 +283,33 @@ __exports:
alloc_page, 'AllocPage', \ ; gcc ABI alloc_page, 'AllocPage', \ ; gcc ABI
alloc_pages, 'AllocPages', \ ; stdcall alloc_pages, 'AllocPages', \ ; stdcall
commit_pages, 'CommitPages', \ ; eax, ebx, ecx commit_pages, 'CommitPages', \ ; eax, ebx, ecx
\
create_event, 'CreateEvent', \ ; ecx, esi
destroy_event, 'DestroyEvent', \ ;
raise_event, 'RaiseEvent', \ ; eax, ebx, edx, esi
wait_event, 'WaitEvent', \ ; eax, ebx
get_event_ex, 'GetEvent', \ ; edi
\
create_kernel_object, 'CreateObject', \ create_kernel_object, 'CreateObject', \
create_ring_buffer, 'CreateRingBuffer', \ ; stdcall create_ring_buffer, 'CreateRingBuffer', \ ; stdcall
destroy_kernel_object, 'DestroyObject', \ destroy_kernel_object, 'DestroyObject', \
free_kernel_space, 'FreeKernelSpace', \ ; stdcall free_kernel_space, 'FreeKernelSpace', \ ; stdcall
free_page, 'FreePage', \ ; eax
kernel_alloc, 'KernelAlloc', \ ; stdcall kernel_alloc, 'KernelAlloc', \ ; stdcall
kernel_free, 'KernelFree', \ ; stdcall kernel_free, 'KernelFree', \ ; stdcall
malloc, 'Kmalloc', \ malloc, 'Kmalloc', \
free, 'Kfree', \ free, 'Kfree', \
map_io_mem, 'MapIoMem', \ ; stdcall map_io_mem, 'MapIoMem', \ ; stdcall
get_pg_addr, 'GetPgAddr', \ ; eax get_pg_addr, 'GetPgAddr', \ ; eax
\
mutex_init, 'MutexInit', \ ; gcc fastcall
mutex_lock, 'MutexLock', \ ; gcc fastcall
mutex_unlock, 'MutexUnlock', \ ; gcc fastcall
\ \
get_display, 'GetDisplay', \ get_display, 'GetDisplay', \
set_screen, 'SetScreen', \ set_screen, 'SetScreen', \
pci_api, 'PciApi', \ window._.get_rect, 'GetWindowRect', \ ; gcc fastcall
pci_api_drv, 'PciApi', \
pci_read8, 'PciRead8', \ ; stdcall pci_read8, 'PciRead8', \ ; stdcall
pci_read16, 'PciRead16', \ ; stdcall pci_read16, 'PciRead16', \ ; stdcall
pci_read32, 'PciRead32', \ ; stdcall pci_read32, 'PciRead32', \ ; stdcall
@@ -304,6 +317,7 @@ __exports:
pci_write16, 'PciWrite16', \ ; stdcall pci_write16, 'PciWrite16', \ ; stdcall
pci_write32, 'PciWrite32', \ ; stdcall pci_write32, 'PciWrite32', \ ; stdcall
\ \
get_pid, 'GetPid', \
get_service, 'GetService', \ ; get_service, 'GetService', \ ;
reg_service, 'RegService', \ ; stdcall reg_service, 'RegService', \ ; stdcall
attach_int_handler, 'AttachIntHandler', \ ; stdcall attach_int_handler, 'AttachIntHandler', \ ; stdcall
@@ -311,8 +325,12 @@ __exports:
user_free, 'UserFree', \ ; stdcall user_free, 'UserFree', \ ; stdcall
unmap_pages, 'UnmapPages', \ ; eax, ecx unmap_pages, 'UnmapPages', \ ; eax, ecx
sys_msg_board_str, 'SysMsgBoardStr', \ sys_msg_board_str, 'SysMsgBoardStr', \
get_timer_ticks, 'GetTimerTicks', \
get_stack_base, 'GetStackBase', \
delay_hs, 'Delay', \ ; ebx delay_hs, 'Delay', \ ; ebx
set_mouse_data, 'SetMouseData' set_mouse_data, 'SetMouseData', \ ;
set_keyboard_data, 'SetKeyboardData', \ ; gcc fastcall
timer_hs, 'TimerHs' ; stdcall

View File

@@ -21,14 +21,14 @@ irq0:
inc [timer_ticks] inc [timer_ticks]
mov eax, [timer_ticks] mov eax, [timer_ticks]
call playNote ; <<<--- Speaker driver call playNote ; <<<--- Speaker driver
sub eax,[next_usage_update] sub eax, [next_usage_update]
cmp eax,100 cmp eax, 100
jb .nocounter jb .nocounter
add [next_usage_update],100 add [next_usage_update], 100
call updatecputimes call updatecputimes
.nocounter: .nocounter:
mov al,0x20 ; send End Of Interrupt signal xor ecx, ecx ; send End Of Interrupt signal
out 0x20,al call irq_eoi
btr dword[DONT_SWITCH], 0 btr dword[DONT_SWITCH], 0
jc .return jc .return
call find_next_task call find_next_task
@@ -60,7 +60,8 @@ if 0
end if end if
call find_next_task call find_next_task
jz .return ; the same task -> skip switch jz .return ; the same task -> skip switch
@@: mov byte[DONT_SWITCH], 1 @@:
mov byte[DONT_SWITCH], 1
call do_change_task call do_change_task
.return: .return:
popad popad
@@ -88,16 +89,16 @@ update_counters:
ret ret
align 4 align 4
updatecputimes: updatecputimes:
xor eax,eax xor eax, eax
xchg eax,[idleuse] xchg eax, [idleuse]
mov [idleusesec],eax mov [idleusesec], eax
mov ecx, [TASK_COUNT] mov ecx, [TASK_COUNT]
mov edi, TASK_DATA mov edi, TASK_DATA
.newupdate: .newupdate:
xor eax,eax xor eax, eax
xchg eax,[edi+TASKDATA.counter_sum] xchg eax, [edi+TASKDATA.counter_sum]
mov [edi+TASKDATA.cpu_usage],eax mov [edi+TASKDATA.cpu_usage], eax
add edi,0x20 add edi, 0x20
loop .newupdate loop .newupdate
ret ret
@@ -117,12 +118,13 @@ find_next_task:
call update_counters ; edi := [TASK_BASE] call update_counters ; edi := [TASK_BASE]
Mov esi, ebx, [current_slot] Mov esi, ebx, [current_slot]
.loop: .loop:
cmp bh,[TASK_COUNT] cmp bh, [TASK_COUNT]
jb @f jb @f
xor bh, bh xor bh, bh
mov edi,CURRENT_TASK mov edi, CURRENT_TASK
@@: inc bh ; ebx += APPDATA.size @@:
add edi,0x20 ; edi += TASKDATA.size inc bh ; ebx += APPDATA.size
add edi, 0x20; edi += TASKDATA.size
mov al, [edi+TASKDATA.state] mov al, [edi+TASKDATA.state]
test al, al test al, al
jz .found ; state == 0 jz .found ; state == 0
@@ -131,22 +133,23 @@ find_next_task:
; state == 5 ; state == 5
pushad ; more freedom for [APPDATA.wait_test] pushad ; more freedom for [APPDATA.wait_test]
call [ebx+APPDATA.wait_test] call [ebx+APPDATA.wait_test]
mov [esp+28],eax mov [esp+28], eax
popad popad
or eax,eax or eax, eax
jnz @f jnz @f
; testing for timeout ; testing for timeout
mov ecx, [timer_ticks] mov ecx, [timer_ticks]
sub ecx, [ebx+APPDATA.wait_begin] sub ecx, [ebx+APPDATA.wait_begin]
cmp ecx, [ebx+APPDATA.wait_timeout] cmp ecx, [ebx+APPDATA.wait_timeout]
jb .loop jb .loop
@@: mov [ebx+APPDATA.wait_param], eax ; retval for wait @@:
mov [ebx+APPDATA.wait_param], eax ; retval for wait
mov [edi+TASKDATA.state], 0 mov [edi+TASKDATA.state], 0
.found: .found:
mov [CURRENT_TASK],bh mov [CURRENT_TASK], bh
mov [TASK_BASE],edi mov [TASK_BASE], edi
rdtsc ;call _rdtsc rdtsc ;call _rdtsc
mov [edi+TASKDATA.counter_add],eax ; for next using update_counters mov [edi+TASKDATA.counter_add], eax; for next using update_counters
cmp ebx, esi ;esi - previous slot-base cmp ebx, esi ;esi - previous slot-base
ret ret
;TODO: <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> do_change_task <EFBFBD><EFBFBD> V86... ;TODO: <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> do_change_task <EFBFBD><EFBFBD> V86...
@@ -160,8 +163,8 @@ do_change_task:
; [CURRENT_TASK] and [TASK_BASE] must be changed before (e.g. in find_next_task) ; [CURRENT_TASK] and [TASK_BASE] must be changed before (e.g. in find_next_task)
; [current_slot] is the outcoming (old), and set here to a new value (ebx) ; [current_slot] is the outcoming (old), and set here to a new value (ebx)
;scratched: eax,ecx,esi ;scratched: eax,ecx,esi
mov esi,ebx mov esi, ebx
xchg esi,[current_slot] xchg esi, [current_slot]
; set new stack after saving old ; set new stack after saving old
mov [esi+APPDATA.saved_esp], esp mov [esi+APPDATA.saved_esp], esp
mov esp, [ebx+APPDATA.saved_esp] mov esp, [ebx+APPDATA.saved_esp]
@@ -183,10 +186,10 @@ do_change_task:
cmp edx, [esi+APPDATA.tls_base] cmp edx, [esi+APPDATA.tls_base]
je @f je @f
mov [tls_data_l+2],dx mov [tls_data_l+2], dx
shr edx,16 shr edx, 16
mov [tls_data_l+4],dl mov [tls_data_l+4], dl
mov [tls_data_l+7],dh mov [tls_data_l+7], dh
mov dx, app_tls mov dx, app_tls
mov fs, dx mov fs, dx
@@ -207,17 +210,103 @@ do_change_task:
jz @f jz @f
xor eax, eax xor eax, eax
mov dr6, eax mov dr6, eax
lea esi,[ebx+ecx+APPDATA.dbg_regs-APPDATA.dir_table] ;offset>0x7F lea esi, [ebx+ecx+APPDATA.dbg_regs-APPDATA.dir_table];offset>0x7F
cld cld
macro lodsReg [reg] { macro lodsReg [reg] {
lodsd lodsd
mov reg,eax mov reg, eax
} lodsReg dr0, dr1, dr2, dr3, dr7 } lodsReg dr0, dr1, dr2, dr3, dr7
purge lodsReg purge lodsReg
@@: ret @@:
ret
;end. ;end.
struct MUTEX_WAITER
list LHEAD
task dd ?
ends
;void __fastcall mutex_init(struct mutex *lock)
align 4
mutex_init:
mov [ecx+MUTEX.lhead.next], ecx
mov [ecx+MUTEX.lhead.prev], ecx
mov [ecx+MUTEX.count], 1
ret
;void __fastcall mutex_lock(struct mutex *lock)
align 4
mutex_lock:
dec [ecx+MUTEX.count]
jns .done
pushfd
cli
sub esp, sizeof.MUTEX_WAITER
list_add_tail esp, ecx ;esp= new waiter, ecx= list head
mov edx, [TASK_BASE]
mov [esp+MUTEX_WAITER.task], edx
.forever:
mov eax, -1
xchg eax, [ecx+MUTEX.count]
dec eax
jz @F
mov [edx+TASKDATA.state], 1
call change_task
jmp .forever
@@:
mov edx, [esp+MUTEX_WAITER.list.next]
mov eax, [esp+MUTEX_WAITER.list.prev]
mov [eax+MUTEX_WAITER.list.next], edx
mov [edx+MUTEX_WAITER.list.prev], eax
cmp [ecx+MUTEX.lhead.next], ecx
jne @F
mov [ecx+MUTEX.count], 0
@@:
add esp, sizeof.MUTEX_WAITER
popfd
.done:
ret
;void __fastcall mutex_unlock(struct mutex *lock)
align 4
mutex_unlock:
pushfd
cli
mov eax, [ecx+MUTEX.lhead.next]
cmp eax, ecx
mov [ecx+MUTEX.count], 1
je @F
mov eax, [eax+MUTEX_WAITER.task]
mov [eax+TASKDATA.state], 0
@@:
popfd
ret
purge MUTEX_WAITER
if 0 if 0
struc TIMER struc TIMER
{ {
.next dd ? .next dd ?
@@ -266,7 +355,7 @@ pick_task:
; ecx= front if 1 or back if 0 ; ecx= front if 1 or back if 0
align 4 align 4
shed: shed:
cmp [eax+.tics_left], 0 ;signed compare cmp [eax+.tics_left], 0;signed compare
mov ebx, [eax+.priority] mov ebx, [eax+.priority]
setg ecx setg ecx
jg @F jg @F
@@ -283,8 +372,8 @@ shed:
; eax= task ; eax= task
align 4 align 4
enqueue: enqueue:
call shed ;eax call shed;eax
cmp [rdy_head+ebx*4],0 cmp [rdy_head+ebx*4], 0
jnz @F jnz @F
mov [rdy_head+ebx*4], eax mov [rdy_head+ebx*4], eax
@@ -305,7 +394,7 @@ enqueue:
mov [rdy_tail+ebx*4], eax mov [rdy_tail+ebx*4], eax
mov [eax+.next_ready], 0 mov [eax+.next_ready], 0
.pick: .pick:
call pick_proc ;select next task call pick_proc;select next task
ret ret
end if end if

View File

@@ -27,32 +27,32 @@ macro WaitSimpleMutex name
local start_wait,ok local start_wait,ok
start_wait=$ start_wait=$
cli cli
cmp [name],dword 0 cmp [name], dword 0
jz ok jz ok
sti sti
call change_task call change_task
jmp start_wait jmp start_wait
ok=$ ok=$
push eax push eax
mov eax,dword [TASK_BASE+second_base_address] mov eax, dword [TASK_BASE+second_base_address]
mov eax,[eax+TASKDATA.pid] mov eax, [eax+TASKDATA.pid]
mov [name],eax mov [name], eax
pop eax pop eax
sti sti
} }
macro ReleaseSimpleMutex name macro ReleaseSimpleMutex name
{ {
mov [name],dword 0 mov [name], dword 0
} }
macro TryWaitSimpleMutex name ;result in eax and in flags macro TryWaitSimpleMutex name ;result in eax and in flags
{ {
local ok,try_end local ok,try_end
cmp [name],dword 0 cmp [name], dword 0
jz ok jz ok
xor eax,eax xor eax, eax
jmp try_end jmp try_end
ok=$ ok=$
xor eax,eax xor eax, eax
inc eax inc eax
try_end=$ try_end=$
} }
@@ -68,20 +68,20 @@ macro WaitSimpleCriticalSection name
{ {
local start_wait,first_wait,inc_counter,end_wait local start_wait,first_wait,inc_counter,end_wait
push eax push eax
mov eax,[TASK_BASE+second_base_address] mov eax, [TASK_BASE+second_base_address]
mov eax,[eax+TASKDATA.pid] mov eax, [eax+TASKDATA.pid]
start_wait=$ start_wait=$
cli cli
cmp [name],dword 0 cmp [name], dword 0
jz first_wait jz first_wait
cmp [name],eax cmp [name], eax
jz inc_counter jz inc_counter
sti sti
call change_task call change_task
jmp start_wait jmp start_wait
first_wait=$ first_wait=$
mov [name],eax mov [name], eax
mov [name+4],dword 1 mov [name+4], dword 1
jmp end_wait jmp end_wait
inc_counter=$ inc_counter=$
inc dword [name+4] inc dword [name+4]
@@ -94,22 +94,22 @@ macro ReleaseSimpleCriticalSection name
local release_end local release_end
dec dword [name+4] dec dword [name+4]
jnz release_end jnz release_end
mov [name],dword 0 mov [name], dword 0
release_end=$ release_end=$
} }
macro TryWaitSimpleCriticalSection name ;result in eax and in flags macro TryWaitSimpleCriticalSection name ;result in eax and in flags
{ {
local ok,try_end local ok,try_end
mov eax,[CURRENT_TASK+second_base_address] mov eax, [CURRENT_TASK+second_base_address]
mov eax,[eax+TASKDATA.pid] mov eax, [eax+TASKDATA.pid]
cmp [name],eax cmp [name], eax
jz ok jz ok
cmp [name],0 cmp [name], 0
jz ok jz ok
xor eax,eax xor eax, eax
jmp try_end jmp try_end
ok=$ ok=$
xor eax,eax xor eax, eax
inc eax inc eax
try_end=$ try_end=$
} }

View File

@@ -20,7 +20,8 @@ build_interrupt_table:
mov esi, sys_int mov esi, sys_int
mov ecx, 0x40 mov ecx, 0x40
mov eax, (10001110b shl 24) + os_code mov eax, (10001110b shl 24) + os_code
@@: movsw ;low word of code-entry @@:
movsw ;low word of code-entry
stosd ;interrupt gate type : os_code selector stosd ;interrupt gate type : os_code selector
movsw ;high word of code-entry movsw ;high word of code-entry
loop @b loop @b
@@ -39,17 +40,22 @@ iglobal
times 12 dd unknown_interrupt ;int_20..int_31 times 12 dd unknown_interrupt ;int_20..int_31
;interrupt handlers addresses (for interrupt gate construction) ;interrupt handlers addresses (for interrupt gate construction)
; 0x20 .. 0x2F - IRQ handlers
dd irq0, irq_serv.irq_1, irq_serv.irq_2 dd irq0, irq_serv.irq_1, irq_serv.irq_2
if USE_COM_IRQ
dd irq_serv.irq_3, irq_serv.irq_4 dd irq_serv.irq_3, irq_serv.irq_4
else dd irq_serv.irq_5, irq_serv.irq_6, irq_serv.irq_7
dd p_irq3, p_irq4 ;??? <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
end if
dd irq_serv.irq_5, p_irq6, irq_serv.irq_7
dd irq_serv.irq_8, irq_serv.irq_9, irq_serv.irq_10 dd irq_serv.irq_8, irq_serv.irq_9, irq_serv.irq_10
dd irq_serv.irq_11, irq_serv.irq_12, irqD,p_irq14,p_irq15 dd irq_serv.irq_11, irq_serv.irq_12, irqD, irq_serv.irq_14, irq_serv.irq_15
times 16 dd unknown_interrupt ;int_0x30..int_0x3F dd irq_serv.irq_16
dd irq_serv.irq_17
dd irq_serv.irq_18
dd irq_serv.irq_19
dd irq_serv.irq_20
dd irq_serv.irq_21
dd irq_serv.irq_22
dd irq_serv.irq_23
times 32 - IRQ_RESERVED dd unknown_interrupt
;int_0x40 gate trap (for directly copied) ;int_0x40 gate trap (for directly copied)
dw i40 and 0xFFFF, os_code, 11101111b shl 8, i40 shr 16 dw i40 and 0xFFFF, os_code, 11101111b shl 8, i40 shr 16
@@ -103,7 +109,7 @@ endg
page_fault_exc: ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>... page_fault_exc: ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...
pop [ss:pf_err_code]; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> #PF pop [ss:pf_err_code]; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> #PF
save_ring3_context save_ring3_context
mov bl,14 mov bl, 14
exc_c: ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 7-<EFBFBD><EFBFBD> - #NM) exc_c: ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 7-<EFBFBD><EFBFBD> - #NM)
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> 3-<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> + pushad (<EFBFBD>.<EFBFBD>., <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> 3-<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> + pushad (<EFBFBD>.<EFBFBD>., <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
@@ -122,23 +128,26 @@ exc_c: ;
reg_esi equ esp+0x04 reg_esi equ esp+0x04
reg_edi equ esp+0x00 reg_edi equ esp+0x00
Mov ds,ax,app_data ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov ax, app_data ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov es,ax ; <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov ds, ax ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov es, ax ;<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cld ; <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DF <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> cld ; <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DF <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
movzx ebx,bl movzx ebx, bl
; redirect to V86 manager? (EFLAGS & 0x20000) != 0? ; redirect to V86 manager? (EFLAGS & 0x20000) != 0?
test byte[reg_eflags+2],2 test byte[reg_eflags+2], 2
jnz v86_exc_c jnz v86_exc_c
cmp bl,14 ; #PF cmp bl, 14 ; #PF
jne @f jne @f
call page_fault_handler ; SEE: core/memory.inc call page_fault_handler ; SEE: core/memory.inc
@@: mov esi, [current_slot] @@:
mov esi, [current_slot]
btr [esi+APPDATA.except_mask], ebx btr [esi+APPDATA.except_mask], ebx
jnc @f jnc @f
mov eax,[esi+APPDATA.exc_handler] mov eax, [esi+APPDATA.exc_handler]
test eax, eax test eax, eax
jnz IRetToUserHook jnz IRetToUserHook
@@: cli @@:
cli
mov eax, [esi+APPDATA.debugger_slot] mov eax, [esi+APPDATA.debugger_slot]
test eax, eax test eax, eax
jnz .debug jnz .debug
@@ -151,18 +160,20 @@ exc_c: ;
.debug: .debug:
; we are debugged process, notify debugger and suspend ourself ; we are debugged process, notify debugger and suspend ourself
; eax=debugger PID ; eax=debugger PID
mov ecx,1 ; debug_message code=other_exception mov ecx, 1 ; debug_message code=other_exception
cmp bl,1 ; #DB cmp bl, 1 ; #DB
jne .notify ; notify debugger and suspend ourself jne .notify ; notify debugger and suspend ourself
mov ebx, dr6 ; debug_message data=DR6_image mov ebx, dr6 ; debug_message data=DR6_image
xor edx, edx xor edx, edx
mov dr6, edx mov dr6, edx
mov edx, dr7 mov edx, dr7
mov cl, not 8 mov cl, not 8
.l1: shl dl,2 .l1:
shl dl, 2
jc @f jc @f
and bl, cl and bl, cl
@@: sar cl,1 @@:
sar cl, 1
jc .l1 jc .l1
mov cl, 3 ; debug_message code=debug_exception mov cl, 3 ; debug_message code=debug_exception
.notify: .notify:
@@ -172,7 +183,7 @@ exc_c: ;
push ecx ; debug_message code ((here: ecx==1/3)) push ecx ; debug_message code ((here: ecx==1/3))
mov cl, 12 ; debug_message size mov cl, 12 ; debug_message size
call debugger_notify ;; only ONE using, inline ??? SEE: core/debug.inc call debugger_notify ;; only ONE using, inline ??? SEE: core/debug.inc
add esp,12 add esp, 12
mov edx, [TASK_BASE] mov edx, [TASK_BASE]
mov byte [edx+TASKDATA.state], 1 ; suspended mov byte [edx+TASKDATA.state], 1 ; suspended
call change_task ; SEE: core/shed.inc call change_task ; SEE: core/shed.inc
@@ -186,19 +197,31 @@ IRetToUserHook:
stosd stosd
mov [edi], ebx mov [edi], ebx
restore_ring3_context restore_ring3_context
; simply return control to interrupted process
unknown_interrupt: unknown_interrupt:
iretd iretd
;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= ;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
; bl - error vector
show_error_parameters: show_error_parameters:
mov edx,[TASK_BASE] ;not scratched below cmp bl, 0x06
jnz .no_ud
push ebx
mov ebx, ud_user_message
mov ebp, notifyapp
call fs_execute_from_sysdir_param
pop ebx
.no_ud:
mov edx, [TASK_BASE];not scratched below
DEBUGF 1, "K : Process - forced terminate PID: %x\n", [edx+TASKDATA.pid] DEBUGF 1, "K : Process - forced terminate PID: %x\n", [edx+TASKDATA.pid]
cmp bl, 0x08 cmp bl, 0x08
jb .l0 jb .l0
cmp bl, 0x0e cmp bl, 0x0e
jbe .l1 jbe .l1
.l0: mov bl, 0x09 .l0:
.l1: mov eax,[msg_fault_sel+ebx*4 - 0x08*4] mov bl, 0x09
.l1:
mov eax, [msg_fault_sel+ebx*4 - 0x08*4]
DEBUGF 1, "K : %s\n", eax DEBUGF 1, "K : %s\n", eax
mov eax, [reg_cs3+4] mov eax, [reg_cs3+4]
mov edi, msg_sel_app mov edi, msg_sel_app
@@ -207,7 +230,8 @@ show_error_parameters:
je @f je @f
mov edi, msg_sel_ker mov edi, msg_sel_ker
mov ebx, [reg_esp0+4] mov ebx, [reg_esp0+4]
@@: DEBUGF 1, "K : EAX : %x EBX : %x ECX : %x\n", [reg_eax+4], [reg_ebx+4], [reg_ecx+4] @@:
DEBUGF 1, "K : EAX : %x EBX : %x ECX : %x\n", [reg_eax+4], [reg_ebx+4], [reg_ecx+4]
DEBUGF 1, "K : EDX : %x ESI : %x EDI : %x\n", [reg_edx+4], [reg_esi+4], [reg_edi+4] DEBUGF 1, "K : EDX : %x ESI : %x EDI : %x\n", [reg_edx+4], [reg_esi+4], [reg_edi+4]
DEBUGF 1, "K : EBP : %x EIP : %x ESP : %x\n", [reg_ebp+4], [reg_eip+4], ebx DEBUGF 1, "K : EBP : %x EIP : %x ESP : %x\n", [reg_ebp+4], [reg_eip+4], ebx
DEBUGF 1, "K : Flags : %x CS : %x (%s)\n", [reg_eflags+4], eax, edi DEBUGF 1, "K : Flags : %x CS : %x (%s)\n", [reg_eflags+4], eax, edi
@@ -228,181 +252,35 @@ show_error_parameters:
restore reg_esi restore reg_esi
restore reg_edi restore reg_edi
; irq1 -> hid/keyboard.inc
macro irqh [num] {
p_irq#num :
mov edi, num
jmp irqhandler
}
p_irq6:
save_ring3_context
mov ax, app_data ;os_data
mov ds, ax
mov es, ax
mov edi, 6
cmp [v86_irqhooks+edi*8], 0
jnz v86_irq2
call fdc_irq
call ready_for_next_irq
restore_ring3_context
iret
p_irq14:
save_ring3_context
mov ax, app_data ;os_data
mov ds, ax
mov es, ax
mov edi, 14
cmp [v86_irqhooks+edi*8], 0
jnz v86_irq2
; mov byte [BOOT_VAR + 0x48E], 0xFF
call [irq14_func]
call ready_for_next_irq_1
restore_ring3_context
iret
p_irq15:
save_ring3_context
mov ax, app_data ;os_data
mov ds, ax
mov es, ax
mov edi, 15
cmp [v86_irqhooks+edi*8], 0
jnz v86_irq2
; mov byte [BOOT_VAR + 0x48E], 0xFF
call [irq15_func]
call ready_for_next_irq_1
restore_ring3_context
iret
ready_for_next_irq:
mov eax,5
mov [check_idle_semaphore],eax
; mov al, 0x20
add eax,(0x20-0x5)
out 0x20, al
ret
;destroy eax
ready_for_next_irq_1:
mov eax,5
mov [check_idle_semaphore],eax
; mov al, 0x20
add eax,(0x20-0x5)
out 0xa0,al
out 0x20, al
ret
irqD:
push eax
xor eax,eax
out 0xf0,al
mov al,0x20
out 0xa0,al
out 0x20,al
pop eax
iret
irqh 2,3,4,5,7,8,9,10,11
irqhandler:
mov esi,edi ; 1
shl esi,6 ; 1
add esi,irq00read ; 1
shl edi,12 ; 1
add edi,IRQ_SAVE
mov ecx,16
irqnewread:
dec ecx
js irqover
movzx edx, word [esi] ; 2+
test edx, edx ; 1
jz irqover
mov ebx, [edi] ; address of begin of buffer in edi ; + 0x0 dword - data size
mov eax, 4000 ; + 0x4 dword - data begin offset
cmp ebx, eax
je irqfull
add ebx, [edi + 0x4] ; add data size to data begin offset
cmp ebx, eax ; if end of buffer, begin cycle again
jb @f
xor ebx, ebx
@@:
add ebx, edi
movzx eax, byte[esi + 3] ; get type of data being received 1 - byte, 2 - word
dec eax
jz irqbyte
dec eax
jnz noirqword
in ax,dx
cmp ebx, 3999 ; check for address odd in the end of buffer
jne .odd
mov [ebx + 0x10], ax
jmp .add_size
.odd:
mov [ebx + 0x10], al ; I could make mistake here :)
mov [edi + 0x10], ah
.add_size:
add dword [edi], 2
jmp nextport
irqbyte:
in al,dx
mov [ebx + 0x10],al
inc dword [edi]
nextport:
add esi,4
jmp irqnewread
noirqword:
irqfull:
irqover:
ret
align 4
set_application_table_status: set_application_table_status:
push eax push eax
mov eax,[CURRENT_TASK] mov eax, [CURRENT_TASK]
shl eax, 5 shl eax, 5
add eax,CURRENT_TASK+TASKDATA.pid add eax, CURRENT_TASK+TASKDATA.pid
mov eax,[eax] mov eax, [eax]
mov [application_table_status],eax mov [application_table_status], eax
pop eax pop eax
ret ret
align 4
clear_application_table_status: clear_application_table_status:
push eax push eax
mov eax,[CURRENT_TASK] mov eax, [CURRENT_TASK]
shl eax, 5 shl eax, 5
add eax,CURRENT_TASK+TASKDATA.pid add eax, CURRENT_TASK+TASKDATA.pid
mov eax,[eax] mov eax, [eax]
cmp eax,[application_table_status] cmp eax, [application_table_status]
jne apptsl1 jne apptsl1
xor eax,eax xor eax, eax
mov [application_table_status],eax mov [application_table_status], eax
apptsl1: apptsl1:
pop eax pop eax
@@ -416,6 +294,7 @@ clear_application_table_status:
; * eax = 0 - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; * eax = 0 - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; * eax = 1 - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; * eax = 1 - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
align 4
sys_resize_app_memory: sys_resize_app_memory:
; ebx = 1 - resize ; ebx = 1 - resize
; ecx = new amount of memory ; ecx = new amount of memory
@@ -437,6 +316,7 @@ endg
; param ; param
; esi= slot ; esi= slot
align 4
terminate: ; terminate application terminate: ; terminate application
.slot equ esp ;locals .slot equ esp ;locals
@@ -455,7 +335,7 @@ terminate: ; terminate application
;call sys_msg_board_str ;call sys_msg_board_str
@@: @@:
cli cli
cmp [application_table_status],0 cmp [application_table_status], 0
je term9 je term9
sti sti
call change_task call change_task
@@ -482,7 +362,7 @@ term9:
.nov86: .nov86:
mov esi, [.slot] mov esi, [.slot]
shl esi,8 shl esi, 8
add esi, SLOT_BASE+APP_OBJ_OFFSET add esi, SLOT_BASE+APP_OBJ_OFFSET
@@: @@:
mov eax, [esi+APPOBJ.fd] mov eax, [esi+APPOBJ.fd]
@@ -504,10 +384,10 @@ term9:
stdcall destroy_app_space, [SLOT_BASE+eax+APPDATA.dir_table], [SLOT_BASE+eax+APPDATA.dlls_list_ptr] stdcall destroy_app_space, [SLOT_BASE+eax+APPDATA.dir_table], [SLOT_BASE+eax+APPDATA.dlls_list_ptr]
mov esi, [.slot] mov esi, [.slot]
cmp [fpu_owner],esi ; if user fpu last -> fpu user = 1 cmp [fpu_owner], esi ; if user fpu last -> fpu user = 1
jne @F jne @F
mov [fpu_owner],1 mov [fpu_owner], 1
mov eax, [256+SLOT_BASE+APPDATA.fpu_state] mov eax, [256+SLOT_BASE+APPDATA.fpu_state]
clts clts
bt [cpu_caps], CAPS_SSE bt [cpu_caps], CAPS_SSE
@@ -519,8 +399,8 @@ term9:
frstor [eax] frstor [eax]
@@: @@:
mov [KEY_COUNT],byte 0 ; empty keyboard buffer mov [KEY_COUNT], byte 0 ; empty keyboard buffer
mov [BTN_COUNT],byte 0 ; empty button buffer mov [BTN_COUNT], byte 0 ; empty button buffer
; remove defined hotkeys ; remove defined hotkeys
@@ -557,25 +437,25 @@ term9:
cmp eax, hotkey_buffer+120*8 cmp eax, hotkey_buffer+120*8
jb .loop2 jb .loop2
mov ecx,esi ; remove buttons mov ecx, esi ; remove buttons
bnewba2: bnewba2:
mov edi,[BTN_ADDR] mov edi, [BTN_ADDR]
mov eax,edi mov eax, edi
cld cld
movzx ebx,word [edi] movzx ebx, word [edi]
inc bx inc bx
bnewba: bnewba:
dec bx dec bx
jz bnmba jz bnmba
add eax,0x10 add eax, 0x10
cmp cx,[eax] cmp cx, [eax]
jnz bnewba jnz bnewba
pusha pusha
mov ecx,ebx mov ecx, ebx
inc ecx inc ecx
shl ecx,4 shl ecx, 4
mov ebx,eax mov ebx, eax
add eax,0x10 add eax, 0x10
call memmove call memmove
dec dword [edi] dec dword [edi]
popa popa
@@ -584,28 +464,28 @@ term9:
pusha ; save window coordinates for window restoring pusha ; save window coordinates for window restoring
cld cld
shl esi,5 shl esi, 5
add esi,window_data add esi, window_data
mov eax,[esi+WDATA.box.left] mov eax, [esi+WDATA.box.left]
mov [draw_limits.left],eax mov [draw_limits.left], eax
add eax,[esi+WDATA.box.width] add eax, [esi+WDATA.box.width]
mov [draw_limits.right],eax mov [draw_limits.right], eax
mov eax,[esi+WDATA.box.top] mov eax, [esi+WDATA.box.top]
mov [draw_limits.top],eax mov [draw_limits.top], eax
add eax,[esi+WDATA.box.height] add eax, [esi+WDATA.box.height]
mov [draw_limits.bottom],eax mov [draw_limits.bottom], eax
xor eax, eax xor eax, eax
mov [esi+WDATA.box.left],eax mov [esi+WDATA.box.left], eax
mov [esi+WDATA.box.width],eax mov [esi+WDATA.box.width], eax
mov [esi+WDATA.box.top],eax mov [esi+WDATA.box.top], eax
mov [esi+WDATA.box.height],eax mov [esi+WDATA.box.height], eax
mov [esi+WDATA.cl_workarea],eax mov [esi+WDATA.cl_workarea], eax
mov [esi+WDATA.cl_titlebar],eax mov [esi+WDATA.cl_titlebar], eax
mov [esi+WDATA.cl_frames],eax mov [esi+WDATA.cl_frames], eax
mov dword [esi+WDATA.reserved],eax ; clear all flags: wstate, redraw, wdrawn mov dword [esi+WDATA.reserved], eax; clear all flags: wstate, redraw, wdrawn
lea edi, [esi-window_data+draw_data] lea edi, [esi-window_data+draw_data]
mov ecx,32/4 mov ecx, 32/4
rep stosd rep stosd
popa popa
@@ -618,7 +498,7 @@ term9:
jz .nodebug jz .nodebug
push 8 push 8
pop ecx pop ecx
push dword [CURRENT_TASK+edi+TASKDATA.pid] ; PID push dword [CURRENT_TASK+edi+TASKDATA.pid]; PID
push 2 push 2
call debugger_notify call debugger_notify
pop ecx pop ecx
@@ -629,17 +509,17 @@ term9:
mov ebx, [.slot] mov ebx, [.slot]
shl ebx, 8 shl ebx, 8
push ebx push ebx
mov ebx,[SLOT_BASE+ebx+APPDATA.pl0_stack] mov ebx, [SLOT_BASE+ebx+APPDATA.pl0_stack]
stdcall kernel_free, ebx stdcall kernel_free, ebx
pop ebx pop ebx
mov ebx,[SLOT_BASE+ebx+APPDATA.cur_dir] mov ebx, [SLOT_BASE+ebx+APPDATA.cur_dir]
stdcall kernel_free, ebx stdcall kernel_free, ebx
mov edi, [.slot] mov edi, [.slot]
shl edi,8 shl edi, 8
add edi,SLOT_BASE add edi, SLOT_BASE
mov eax, [edi+APPDATA.io_map] mov eax, [edi+APPDATA.io_map]
cmp eax, [SLOT_BASE+256+APPDATA.io_map] cmp eax, [SLOT_BASE+256+APPDATA.io_map]
@@ -655,7 +535,7 @@ term9:
stosd stosd
stosd stosd
stosd stosd
mov ecx,244/4 mov ecx, 244/4
xor eax, eax xor eax, eax
rep stosd rep stosd
@@ -708,45 +588,26 @@ term9:
and [bgrlock], 0 and [bgrlock], 0
@@: @@:
pusha ; remove all irq reservations
mov eax,esi
shl eax, 5
mov eax,[eax+CURRENT_TASK+TASKDATA.pid]
mov edi,irq_owner
xor ebx, ebx
xor edx, edx
newirqfree:
cmp [edi + 4 * ebx], eax
jne nofreeirq
mov [edi + 4 * ebx], edx ; remove irq reservation
mov [irq_tab + 4 * ebx], edx ; remove irq handler
mov [irq_rights + 4 * ebx], edx ; set access rights to full access
nofreeirq:
inc ebx
cmp ebx, 16
jb newirqfree
popa
pusha ; remove all port reservations pusha ; remove all port reservations
mov edx,esi mov edx, esi
shl edx, 5 shl edx, 5
add edx,CURRENT_TASK add edx, CURRENT_TASK
mov edx,[edx+TASKDATA.pid] mov edx, [edx+TASKDATA.pid]
rmpr0: rmpr0:
mov esi,[RESERVED_PORTS] mov esi, [RESERVED_PORTS]
test esi,esi test esi, esi
jz rmpr9 jz rmpr9
rmpr3: rmpr3:
mov edi,esi mov edi, esi
shl edi,4 shl edi, 4
add edi,RESERVED_PORTS add edi, RESERVED_PORTS
cmp edx,[edi] cmp edx, [edi]
je rmpr4 je rmpr4
dec esi dec esi
@@ -756,12 +617,12 @@ term9:
rmpr4: rmpr4:
mov ecx,256 mov ecx, 256
sub ecx,esi sub ecx, esi
shl ecx,4 shl ecx, 4
mov esi,edi mov esi, edi
add esi,16 add esi, 16
cld cld
rep movsb rep movsb
@@ -772,9 +633,9 @@ term9:
rmpr9: rmpr9:
popa popa
mov edi,esi ; do not run this process slot mov edi, esi ; do not run this process slot
shl edi, 5 shl edi, 5
mov [edi+CURRENT_TASK + TASKDATA.state],byte 9 mov [edi+CURRENT_TASK + TASKDATA.state], byte 9
; debugger test - terminate all debuggees ; debugger test - terminate all debuggees
mov eax, 2 mov eax, 2
mov ecx, SLOT_BASE+2*0x100+APPDATA.debugger_slot mov ecx, SLOT_BASE+2*0x100+APPDATA.debugger_slot
@@ -806,29 +667,30 @@ term9:
xor esi, esi xor esi, esi
call redrawscreen call redrawscreen
mov [MOUSE_BACKGROUND],byte 0 ; no mouse background mov [MOUSE_BACKGROUND], byte 0; no mouse background
mov [DONT_DRAW_MOUSE],byte 0 ; draw mouse mov [DONT_DRAW_MOUSE], byte 0; draw mouse
and [application_table_status],0 and [application_table_status], 0
;mov esi,process_terminated ;mov esi,process_terminated
;call sys_msg_board_str ;call sys_msg_board_str
mov eax, [.slot]
call SOCKET_process_end
add esp, 4 add esp, 4
ret ret
restore .slot restore .slot
iglobal iglobal
if lang eq ru
boot_sched_1 db '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> GDT TSS 㪠<><E3AAA0><EFBFBD>',0
boot_sched_2 db '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IDT ⠡<><E2A0A1><EFBFBD><EFBFBD>',0
else
boot_sched_1 db 'Building gdt tss pointer',0 boot_sched_1 db 'Building gdt tss pointer',0
boot_sched_2 db 'Building IDT table',0 boot_sched_2 db 'Building IDT table',0
end if
endg endg
build_scheduler: build_scheduler:
mov esi,boot_sched_1 mov esi, boot_sched_1
call boot_log call boot_log
; call build_process_gdt_tss_pointer ; call build_process_gdt_tss_pointer

View File

@@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2010. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -17,6 +17,7 @@ cross_order:
mov edx, esi mov edx, esi
mov esi, edi mov esi, edi
movzx edi, byte[esp+28 + 4] movzx edi, byte[esp+28 + 4]
sub edi, 53
call dword [servetable+edi*4] call dword [servetable+edi*4]
ret ret
@@ -101,78 +102,17 @@ iglobal
align 4 align 4
servetable: servetable:
dd 0 dd 0
dd 0 dd 0
dd 0 dd 0
dd 0 dd 0
dd 0 dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd 0
dd sound_interface ; 55-Sound interface
dd 0
dd 0
dd file_system ; 58-Common file system interface dd file_system ; 58-Common file system interface
dd 0 dd 0
dd sys_IPC ; 60-Inter Process Communication dd 0
dd sys_gs ; 61-Direct graphics access dd 0
dd sys_pci ; 62-PCI functions dd 0 ; 62-PCI functions
dd sys_msg_board ; 63-System message board dd sys_msg_board ; 63-System message board
dd 0
dd syscall_putimage_palette; 65-PutImagePalette
dd sys_process_def ; 66-Process definitions - keyboard
dd sys_window_move ; 67-Window move or resize
dd 0
dd 0
dd file_system_lfn ; 70-Common file system interface, version 2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; NEW SYSTEM FUNCTIONS TABLE ;; ;; NEW SYSTEM FUNCTIONS TABLE ;;
@@ -180,7 +120,7 @@ iglobal
align 4 align 4
servetable2: servetable2:
dd sys_drawwindow ; 0-DrawWindow dd syscall_draw_window ; 0-DrawWindow
dd syscall_setpixel ; 1-SetPixel dd syscall_setpixel ; 1-SetPixel
dd sys_getkey ; 2-GetKey dd sys_getkey ; 2-GetKey
dd sys_clock ; 3-GetTime dd sys_clock ; 3-GetTime
@@ -221,39 +161,39 @@ iglobal
dd syscall_drawline ; 38-DrawLine dd syscall_drawline ; 38-DrawLine
dd sys_getbackground ; 39-GetBackgroundSize,ReadBgrData,. dd sys_getbackground ; 39-GetBackgroundSize,ReadBgrData,.
dd set_app_param ; 40-WantEvents dd set_app_param ; 40-WantEvents
dd syscall_getirqowner ; 41-GetIrqOwner dd undefined_syscall ; 41- deprecated GetIrqOwner
dd get_irq_data ; 42-ReadIrqData dd undefined_syscall ; 42- deprecated ReadIrqData
dd sys_outport ; 43-SendDeviceData dd sys_outport ; 43-SendDeviceData
dd sys_programirq ; 44-ProgramIrqs dd undefined_syscall ; 44- deprecated ProgramIrqs
dd reserve_free_irq ; 45-ReserveIrq and FreeIrq dd undefined_syscall ; 45- deprecated ReserveIrq and FreeIrq
dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea dd syscall_reserveportarea ; 46-ReservePortArea and FreePortArea
dd display_number ; 47-WriteNum dd display_number ; 47-WriteNum
dd syscall_display_settings ; 48-SetRedrawType and SetButtonType dd syscall_display_settings ; 48-SetRedrawType and SetButtonType
dd sys_apm ; 49-Advanced Power Management (APM) dd sys_apm ; 49-Advanced Power Management (APM)
dd syscall_set_window_shape ; 50-Window shape & scale dd syscall_set_window_shape ; 50-Window shape & scale
dd syscall_threads ; 51-Threads dd syscall_threads ; 51-Threads
dd undefined_syscall ; 52-Stack driver status dd undefined_syscall ; 52 old network stack
dd undefined_syscall ; 53-Socket interface dd undefined_syscall ; 53 old network stack
dd undefined_syscall ; 54-reserved dd undefined_syscall ; 54-reserved
dd cross_order ; 55-Sound interface dd sound_interface ; 55-Sound interface
dd undefined_syscall ; 56-reserved dd undefined_syscall ; 56-reserved
dd sys_pcibios ; 57-PCI BIOS32 dd sys_pcibios ; 57-PCI BIOS32
dd cross_order ; 58-Common file system interface dd cross_order ; 58-Common file system interface
dd undefined_syscall ; 59-reserved dd undefined_syscall ; 59-reserved
dd cross_order ; 60-Inter Process Communication dd sys_IPC ; 60-Inter Process Communication
dd cross_order ; 61-Direct graphics access dd sys_gs ; 61-Direct graphics access
dd cross_order ; 62-PCI functions dd pci_api ;cross_order ; 62-PCI functions
dd cross_order ; 63-System message board dd cross_order ; 63-System message board
dd sys_resize_app_memory ; 64-Resize application memory usage dd sys_resize_app_memory ; 64-Resize application memory usage
dd cross_order ; 65-PutImagePalette dd sys_putimage_palette ; 65-PutImagePalette
dd cross_order ; 66-Process definitions - keyboard dd sys_process_def ; 66-Process definitions - keyboard
dd cross_order ; 67-Window move or resize dd syscall_move_window ; 67-Window move or resize
dd f68 ; 68-Some internal services dd f68 ; 68-Some internal services
dd sys_debug_services ; 69-Debug dd sys_debug_services ; 69-Debug
dd cross_order ; 70-Common file system interface, version 2 dd file_system_lfn ; 70-Common file system interface, version 2
dd syscall_windowsettings ; 71-Window settings dd syscall_window_settings ; 71-Window settings
dd sys_sendwindowmsg ; 72-Send window message dd sys_sendwindowmsg ; 72-Send window message
dd undefined_syscall ; 73-reserved for blitter dd blit_32 ; 73-blitter;
dd sys_network ; 74-Network stack dd sys_network ; 74-Network stack
dd sys_socket ; 75-Sockets dd sys_socket ; 75-Sockets
dd sys_protocols ; 76-Protocols dd sys_protocols ; 76-Protocols

View File

@@ -48,6 +48,7 @@ macro _clear_ op
fs_execute_from_sysdir: fs_execute_from_sysdir:
xor ebx, ebx xor ebx, ebx
fs_execute_from_sysdir_param:
xor edx, edx xor edx, edx
mov esi, sysdir_path mov esi, sysdir_path
@@ -126,7 +127,7 @@ proc fs_execute
@@: @@:
lea eax, [filename] lea eax, [filename]
stdcall load_file, eax stdcall load_file, eax
mov ecx, -ERROR_FILE_NOT_FOUND mov esi, -ERROR_FILE_NOT_FOUND
test eax, eax test eax, eax
jz .err_file jz .err_file
@@ -135,15 +136,12 @@ proc fs_execute
lea ebx, [hdr_cmdline] lea ebx, [hdr_cmdline]
call test_app_header call test_app_header
mov ecx, -0x1F mov esi, -0x1F
test eax, eax test eax, eax
jz .err_hdr jz .err_hdr
;mov esi, new_process_loading
;call sys_msg_board_str ; write message to message board
.wait_lock: .wait_lock:
cmp [application_table_status],0 cmp [application_table_status], 0
je .get_lock je .get_lock
call change_task call change_task
jmp .wait_lock jmp .wait_lock
@@ -158,7 +156,7 @@ proc fs_execute
call get_new_process_place call get_new_process_place
test eax, eax test eax, eax
mov ecx, -0x20 ; too many processes mov esi, -0x20 ; too many processes
jz .err jz .err
mov [slot], eax mov [slot], eax
@@ -177,7 +175,7 @@ proc fs_execute
jnz @F jnz @F
lea esi, [filename] lea esi, [filename]
@@: @@:
mov ecx, 8 ; 8 chars for name mov ecx, 8; 8 chars for name
mov edi, [slot_base] mov edi, [slot_base]
.copy_process_name_loop: .copy_process_name_loop:
lodsb lodsb
@@ -192,15 +190,15 @@ proc fs_execute
mov ebx, cr3 mov ebx, cr3
mov [save_cr3], ebx mov [save_cr3], ebx
stdcall create_app_space,[hdr_mem],[file_base],[file_size] stdcall create_app_space, [hdr_mem], [file_base], [file_size]
mov ecx, -30 ; no memory mov esi, -30; no memory
test eax, eax test eax, eax
jz .failed jz .failed
mov ebx,[slot_base] mov ebx, [slot_base]
mov [ebx+APPDATA.dir_table],eax mov [ebx+APPDATA.dir_table], eax
mov eax,[hdr_mem] mov eax, [hdr_mem]
mov [ebx+APPDATA.mem_size],eax mov [ebx+APPDATA.mem_size], eax
xor edx, edx xor edx, edx
cmp word [6], '02' cmp word [6], '02'
@@ -208,7 +206,7 @@ proc fs_execute
not edx not edx
@@: @@:
mov [ebx+APPDATA.tls_base],edx mov [ebx+APPDATA.tls_base], edx
if GREEDY_KERNEL if GREEDY_KERNEL
else else
@@ -231,25 +229,25 @@ end if
lea eax, [hdr_cmdline] lea eax, [hdr_cmdline]
lea ebx, [cmdline] lea ebx, [cmdline]
lea ecx, [filename] lea ecx, [filename]
stdcall set_app_params ,[slot],eax,ebx,ecx,[flags] stdcall set_app_params , [slot], eax, ebx, ecx, [flags]
mov eax, [save_cr3] mov eax, [save_cr3]
call set_cr3 call set_cr3
xor ebx, ebx xor ebx, ebx
mov [application_table_status],ebx ;unlock application_table_status mutex mov [application_table_status], ebx;unlock application_table_status mutex
mov eax,[process_number] ;set result mov eax, [process_number];set result
ret ret
.failed: .failed:
mov eax, [save_cr3] mov eax, [save_cr3]
call set_cr3 call set_cr3
.err: .err:
.err_hdr: .err_hdr:
stdcall kernel_free,[file_base] stdcall kernel_free, [file_base]
.err_file: .err_file:
xor eax, eax xor eax, eax
mov [application_table_status],eax mov [application_table_status], eax
mov eax, ecx mov eax, esi
ret ret
endp endp
@@ -264,20 +262,20 @@ test_app_header:
cmp dword [eax], 'MENU' cmp dword [eax], 'MENU'
jne .fail jne .fail
cmp word [eax+4],'ET' cmp word [eax+4], 'ET'
jne .fail jne .fail
cmp [eax+6], word '00' cmp [eax+6], word '00'
jne .check_01_header jne .check_01_header
mov ecx,[APP_HEADER_00.start] mov ecx, [APP_HEADER_00.start]
mov [ebx+0x08], ecx ;app_eip mov [ebx+0x08], ecx ;app_eip
mov edx,[APP_HEADER_00.mem_size] mov edx, [APP_HEADER_00.mem_size]
mov [ebx+0x10], edx ;app_mem mov [ebx+0x10], edx ;app_mem
shr edx,1 shr edx, 1
sub edx,0x10 sub edx, 0x10
mov [ebx+0x0C], edx ;app_esp mov [ebx+0x0C], edx ;app_esp
mov ecx,[APP_HEADER_00.i_param] mov ecx, [APP_HEADER_00.i_param]
mov [ebx], ecx ;app_cmdline mov [ebx], ecx ;app_cmdline
mov [ebx+4], dword 0 ;app_path mov [ebx+4], dword 0 ;app_path
mov edx, [APP_HEADER_00.i_end] mov edx, [APP_HEADER_00.i_end]
@@ -291,23 +289,23 @@ test_app_header:
cmp [eax+6], word '02' cmp [eax+6], word '02'
jne .fail jne .fail
@@: @@:
mov ecx,[APP_HEADER_01.start] mov ecx, [APP_HEADER_01.start]
mov [ebx+0x08], ecx ;app_eip mov [ebx+0x08], ecx ;app_eip
mov edx,[APP_HEADER_01.mem_size] mov edx, [APP_HEADER_01.mem_size]
; \begin{diamond}[20.08.2006] ; \begin{diamond}[20.08.2006]
; sanity check (functions 19,58 load app_i_end bytes and that must ; sanity check (functions 19,58 load app_i_end bytes and that must
; fit in allocated memory to prevent kernel faults) ; fit in allocated memory to prevent kernel faults)
cmp edx,[APP_HEADER_01.i_end] cmp edx, [APP_HEADER_01.i_end]
jb .fail jb .fail
; \end{diamond}[20.08.2006] ; \end{diamond}[20.08.2006]
mov [ebx+0x10], edx ;app_mem mov [ebx+0x10], edx ;app_mem
mov ecx,[APP_HEADER_01.stack_top] mov ecx, [APP_HEADER_01.stack_top]
mov [ebx+0x0C], ecx ;app_esp mov [ebx+0x0C], ecx ;app_esp
mov edx,[APP_HEADER_01.i_param] mov edx, [APP_HEADER_01.i_param]
mov [ebx], edx ;app_cmdline mov [ebx], edx ;app_cmdline
mov ecx,[APP_HEADER_01.i_icon] mov ecx, [APP_HEADER_01.i_icon]
mov [ebx+4], ecx ;app_path mov [ebx+4], ecx ;app_path
mov edx, [APP_HEADER_01.i_end] mov edx, [APP_HEADER_01.i_end]
mov [ebx+0x14], edx mov [ebx+0x14], edx
@@ -325,28 +323,28 @@ proc get_new_process_place
; 0 - failed. ; 0 - failed.
;This function find least empty slot. ;This function find least empty slot.
;It doesn't increase [TASK_COUNT]! ;It doesn't increase [TASK_COUNT]!
mov eax,CURRENT_TASK mov eax, CURRENT_TASK
mov ebx,[TASK_COUNT] mov ebx, [TASK_COUNT]
inc ebx inc ebx
shl ebx,5 shl ebx, 5
add ebx,eax ;ebx - address of process information for (last+1) slot add ebx, eax ;ebx - address of process information for (last+1) slot
.newprocessplace: .newprocessplace:
;eax = address of process information for current slot ;eax = address of process information for current slot
cmp eax,ebx cmp eax, ebx
jz .endnewprocessplace ;empty slot after high boundary jz .endnewprocessplace ;empty slot after high boundary
add eax,0x20 add eax, 0x20
cmp word [eax+0xa],9 ;check process state, 9 means that process slot is empty cmp word [eax+0xa], 9;check process state, 9 means that process slot is empty
jnz .newprocessplace jnz .newprocessplace
.endnewprocessplace: .endnewprocessplace:
mov ebx,eax mov ebx, eax
sub eax,CURRENT_TASK sub eax, CURRENT_TASK
shr eax,5 ;calculate slot index shr eax, 5 ;calculate slot index
cmp eax,256 cmp eax, 256
jge .failed ;it should be <256 jge .failed ;it should be <256
mov word [ebx+0xa],9 ;set process state to 9 (for slot after hight boundary) mov word [ebx+0xa], 9;set process state to 9 (for slot after hight boundary)
ret ret
.failed: .failed:
xor eax,eax xor eax, eax
ret ret
endp endp
@@ -359,8 +357,8 @@ proc create_app_space stdcall, app_size:dword,img_base:dword,img_size:dword
app_tabs dd ? app_tabs dd ?
endl endl
mov ebx, pg_data.pg_mutex mov ecx, pg_data.mutex
call wait_mutex ;ebx call mutex_lock
xor eax, eax xor eax, eax
mov [dir_addr], eax mov [dir_addr], eax
@@ -386,11 +384,11 @@ proc create_app_space stdcall, app_size:dword,img_base:dword,img_size:dword
shr ecx, 12 shr ecx, 12
mov [img_pages], ecx mov [img_pages], ecx
if GREEDY_KERNEL if GREEDY_KERNEL
lea eax, [ecx+ebx+2] ;only image size lea eax, [ecx+ebx+2];only image size
else else
lea eax, [eax+ebx+2] ;all requested memory lea eax, [eax+ebx+2];all requested memory
end if end if
cmp eax, [pg_data.pages_free] cmp eax, [pg_data.pages_free]
ja .fail ja .fail
@@ -398,7 +396,7 @@ proc create_app_space stdcall, app_size:dword,img_base:dword,img_size:dword
test eax, eax test eax, eax
jz .fail jz .fail
mov [dir_addr], eax mov [dir_addr], eax
stdcall map_page,[tmp_task_pdir],eax,dword PG_SW stdcall map_page, [tmp_task_pdir], eax, dword PG_SW
mov edi, [tmp_task_pdir] mov edi, [tmp_task_pdir]
mov ecx, (OS_BASE shr 20)/4 mov ecx, (OS_BASE shr 20)/4
@@ -449,7 +447,7 @@ proc create_app_space stdcall, app_size:dword,img_base:dword,img_size:dword
add edi, page_tabs add edi, page_tabs
.remap: .remap:
lodsd lodsd
or eax, ebx ; force user level r/w access or eax, ebx; force user level r/w access
stosd stosd
add edx, 0x1000 add edx, 0x1000
dec [app_pages] dec [app_pages]
@@ -470,20 +468,22 @@ else
test eax, eax test eax, eax
jz .fail jz .fail
stdcall map_page,edx,eax,dword PG_UW stdcall map_page, edx, eax, dword PG_UW
add edx, 0x1000 add edx, 0x1000
dec [app_pages] dec [app_pages]
jnz .alloc jnz .alloc
end if end if
.done: .done:
stdcall map_page,[tmp_task_pdir],dword 0,dword PG_UNMAP stdcall map_page, [tmp_task_pdir], dword 0, dword PG_UNMAP
dec [pg_data.pg_mutex] mov ecx, pg_data.mutex
call mutex_unlock
mov eax, [dir_addr] mov eax, [dir_addr]
ret ret
.fail: .fail:
dec [pg_data.pg_mutex] mov ecx, pg_data.mutex
call mutex_unlock
cmp [dir_addr], 0 cmp [dir_addr], 0
je @f je @f
stdcall destroy_app_space, [dir_addr], 0 stdcall destroy_app_space, [dir_addr], 0
@@ -525,42 +525,42 @@ endp
align 4 align 4
proc destroy_app_space stdcall, pg_dir:dword, dlls_list:dword proc destroy_app_space stdcall, pg_dir:dword, dlls_list:dword
xor edx,edx xor edx, edx
push edx push edx
mov eax,0x2 mov eax, 0x2
mov ebx, [pg_dir] mov ebx, [pg_dir]
.loop: .loop:
;eax = current slot of process ;eax = current slot of process
mov ecx,eax mov ecx, eax
shl ecx,5 shl ecx, 5
cmp byte [CURRENT_TASK+ecx+0xa],9 ;if process running? cmp byte [CURRENT_TASK+ecx+0xa], 9;if process running?
jz @f ;skip empty slots jz @f ;skip empty slots
shl ecx,3 shl ecx, 3
add ecx,SLOT_BASE add ecx, SLOT_BASE
cmp [ecx+APPDATA.dir_table],ebx ;compare page directory addresses cmp [ecx+APPDATA.dir_table], ebx;compare page directory addresses
jnz @f jnz @f
mov [ebp-4],ecx mov [ebp-4], ecx
inc edx ;thread found inc edx ;thread found
@@: @@:
inc eax inc eax
cmp eax,[TASK_COUNT] ;exit loop if we look through all processes cmp eax, [TASK_COUNT] ;exit loop if we look through all processes
jle .loop jle .loop
;edx = number of threads ;edx = number of threads
;our process is zombi so it isn't counted ;our process is zombi so it isn't counted
pop ecx pop ecx
cmp edx,1 cmp edx, 1
jg .ret jg .ret
;if there isn't threads then clear memory. ;if there isn't threads then clear memory.
mov esi, [dlls_list] mov esi, [dlls_list]
call destroy_all_hdlls call destroy_all_hdlls;ecx=APPDATA
mov ebx, pg_data.pg_mutex mov ecx, pg_data.mutex
call wait_mutex ;ebx call mutex_lock
mov eax, [pg_dir] mov eax, [pg_dir]
and eax, not 0xFFF and eax, not 0xFFF
stdcall map_page,[tmp_task_pdir],eax,PG_SW stdcall map_page, [tmp_task_pdir], eax, PG_SW
mov esi, [tmp_task_pdir] mov esi, [tmp_task_pdir]
mov edi, (OS_BASE shr 20)/4 mov edi, (OS_BASE shr 20)/4
.destroy: .destroy:
@@ -568,7 +568,7 @@ proc destroy_app_space stdcall, pg_dir:dword, dlls_list:dword
test eax, 1 test eax, 1
jz .next jz .next
and eax, not 0xFFF and eax, not 0xFFF
stdcall map_page,[tmp_task_ptab],eax,PG_SW stdcall map_page, [tmp_task_ptab], eax, PG_SW
stdcall destroy_page_table, [tmp_task_ptab] stdcall destroy_page_table, [tmp_task_ptab]
mov eax, [esi] mov eax, [esi]
call free_page call free_page
@@ -580,9 +580,10 @@ proc destroy_app_space stdcall, pg_dir:dword, dlls_list:dword
mov eax, [pg_dir] mov eax, [pg_dir]
call free_page call free_page
.exit: .exit:
stdcall map_page,[tmp_task_ptab],0,PG_UNMAP stdcall map_page, [tmp_task_ptab], 0, PG_UNMAP
stdcall map_page,[tmp_task_pdir],0,PG_UNMAP stdcall map_page, [tmp_task_pdir], 0, PG_UNMAP
dec [pg_data.pg_mutex] mov ecx, pg_data.mutex
call mutex_unlock
.ret: .ret:
ret ret
endp endp
@@ -601,30 +602,30 @@ pid_to_slot:
;Search process by PID. ;Search process by PID.
push ebx push ebx
push ecx push ecx
mov ebx,[TASK_COUNT] mov ebx, [TASK_COUNT]
shl ebx,5 shl ebx, 5
mov ecx,2*32 mov ecx, 2*32
.loop: .loop:
;ecx=offset of current process info entry ;ecx=offset of current process info entry
;ebx=maximum permitted offset ;ebx=maximum permitted offset
cmp byte [CURRENT_TASK+ecx+0xa],9 cmp byte [CURRENT_TASK+ecx+0xa], 9
jz .endloop ;skip empty slots jz .endloop ;skip empty slots
cmp [CURRENT_TASK+ecx+0x4],eax ;check PID cmp [CURRENT_TASK+ecx+0x4], eax;check PID
jz .pid_found jz .pid_found
.endloop: .endloop:
add ecx,32 add ecx, 32
cmp ecx,ebx cmp ecx, ebx
jle .loop jle .loop
pop ecx pop ecx
pop ebx pop ebx
xor eax,eax xor eax, eax
ret ret
.pid_found: .pid_found:
shr ecx,5 shr ecx, 5
mov eax,ecx ;convert offset to index of slot mov eax, ecx ;convert offset to index of slot
pop ecx pop ecx
pop ebx pop ebx
ret ret
@@ -636,7 +637,7 @@ check_region:
;result: ;result:
; eax = 1 region lays in app memory ; eax = 1 region lays in app memory
; eax = 0 region don't lays in app memory ; eax = 0 region don't lays in app memory
mov eax,[CURRENT_TASK] mov eax, [CURRENT_TASK]
; jmp check_process_region ; jmp check_process_region
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
;check_process_region: ;check_process_region:
@@ -648,17 +649,17 @@ check_region:
; eax = 1 region lays in app memory ; eax = 1 region lays in app memory
; eax = 0 region don't lays in app memory ; eax = 0 region don't lays in app memory
test edx,edx test edx, edx
jle .ok jle .ok
shl eax,5 shl eax, 5
cmp word [CURRENT_TASK+eax+0xa],0 cmp word [CURRENT_TASK+eax+0xa], 0
jnz .failed jnz .failed
shl eax,3 shl eax, 3
mov eax,[SLOT_BASE+eax+0xb8] mov eax, [SLOT_BASE+eax+0xb8]
test eax,eax test eax, eax
jz .failed jz .failed
mov eax,1 mov eax, 1
ret ret
@@ -701,7 +702,7 @@ check_region:
; pop ecx ; pop ecx
; pop ebx ; pop ebx
.ok: .ok:
mov eax,1 mov eax, 1
ret ret
; ;
;.failed1: ;.failed1:
@@ -709,7 +710,7 @@ check_region:
; pop ecx ; pop ecx
; pop ebx ; pop ebx
.failed: .failed:
xor eax,eax xor eax, eax
ret ret
align 4 align 4
@@ -754,7 +755,7 @@ proc read_process_memory
mov ebx, [offset] mov ebx, [offset]
push ecx push ecx
stdcall map_memEx, [proc_mem_map],\ stdcall map_memEx, [proc_mem_map], \
[slot], ebx, ecx, PG_MAP [slot], ebx, ecx, PG_MAP
pop ecx pop ecx
@@ -825,7 +826,7 @@ proc write_process_memory
mov ebx, [offset] mov ebx, [offset]
; add ebx, new_app_base ; add ebx, new_app_base
push ecx push ecx
stdcall map_memEx, [proc_mem_map],\ stdcall map_memEx, [proc_mem_map], \
[slot], ebx, ecx, PG_SW [slot], ebx, ecx, PG_SW
pop ecx pop ecx
@@ -864,10 +865,10 @@ proc new_sys_threads
app_mem dd ? ;0x10 app_mem dd ? ;0x10
endl endl
cmp ebx,1 cmp ebx, 1
jne .failed ;other subfunctions jne .failed ;other subfunctions
xor eax,eax xor eax, eax
mov [app_eip], ecx mov [app_eip], ecx
mov [app_cmdline], eax mov [app_cmdline], eax
mov [app_esp], edx mov [app_esp], edx
@@ -875,7 +876,7 @@ proc new_sys_threads
;mov esi,new_process_loading ;mov esi,new_process_loading
;call sys_msg_board_str ;call sys_msg_board_str
.wait_lock: .wait_lock:
cmp [application_table_status],0 cmp [application_table_status], 0
je .get_lock je .get_lock
call change_task call change_task
jmp .wait_lock jmp .wait_lock
@@ -894,36 +895,36 @@ proc new_sys_threads
mov [slot], eax mov [slot], eax
mov esi,[current_slot] mov esi, [current_slot]
mov ebx,esi ;ebx=esi - pointer to extended information about current thread mov ebx, esi ;ebx=esi - pointer to extended information about current thread
mov edi, eax mov edi, eax
shl edi,8 shl edi, 8
add edi,SLOT_BASE add edi, SLOT_BASE
mov edx,edi ;edx=edi - pointer to extended infomation about new thread mov edx, edi ;edx=edi - pointer to extended infomation about new thread
mov ecx,256/4 mov ecx, 256/4
xor eax, eax xor eax, eax
cld cld
rep stosd ;clean extended information about new thread rep stosd ;clean extended information about new thread
mov esi,ebx mov esi, ebx
mov edi,edx mov edi, edx
mov ecx,11 mov ecx, 11
rep movsb ;copy process name rep movsb ;copy process name
mov eax,[ebx+APPDATA.heap_base] mov eax, [ebx+APPDATA.heap_base]
mov [edx+APPDATA.heap_base], eax mov [edx+APPDATA.heap_base], eax
mov ecx,[ebx+APPDATA.heap_top] mov ecx, [ebx+APPDATA.heap_top]
mov [edx+APPDATA.heap_top], ecx mov [edx+APPDATA.heap_top], ecx
mov eax,[ebx+APPDATA.mem_size] mov eax, [ebx+APPDATA.mem_size]
mov [edx+APPDATA.mem_size], eax mov [edx+APPDATA.mem_size], eax
mov ecx,[ebx+APPDATA.dir_table] mov ecx, [ebx+APPDATA.dir_table]
mov [edx+APPDATA.dir_table],ecx ;copy page directory mov [edx+APPDATA.dir_table], ecx;copy page directory
mov eax,[ebx+APPDATA.dlls_list_ptr] mov eax, [ebx+APPDATA.dlls_list_ptr]
mov [edx+APPDATA.dlls_list_ptr],eax mov [edx+APPDATA.dlls_list_ptr], eax
mov eax, [ebx+APPDATA.tls_base] mov eax, [ebx+APPDATA.tls_base]
test eax, eax test eax, eax
@@ -933,46 +934,28 @@ proc new_sys_threads
stdcall user_alloc, 4096 stdcall user_alloc, 4096
pop edx pop edx
test eax, eax test eax, eax
jz .failed1 ;eax=0 jz .failed1;eax=0
@@: @@:
mov [edx+APPDATA.tls_base], eax mov [edx+APPDATA.tls_base], eax
lea eax, [app_cmdline] lea eax, [app_cmdline]
stdcall set_app_params ,[slot],eax,dword 0,\ stdcall set_app_params , [slot], eax, dword 0, \
dword 0,dword 0 dword 0,dword 0
;mov esi,new_process_running ;mov esi,new_process_running
;call sys_msg_board_str ;output information about succefull startup ;call sys_msg_board_str ;output information about succefull startup
xor eax,eax xor eax, eax
mov [application_table_status],eax ;unlock application_table_status mutex mov [application_table_status], eax ;unlock application_table_status mutex
mov eax,[process_number] ;set result mov eax, [process_number] ;set result
ret ret
.failed: .failed:
xor eax,eax xor eax, eax
.failed1: .failed1:
mov [application_table_status],eax mov [application_table_status], eax
dec eax ;-1 dec eax ;-1
ret ret
endp endp
; param
; ebx=mutex
align 4
wait_mutex:
;;Maxis use atomic bts for mutex 4.4.2009
push eax
push ebx
.do_wait:
bts dword [ebx],0
jnc .locked
call change_task
jmp .do_wait
.locked:
pop ebx
pop eax
ret
align 4 align 4
tls_app_entry: tls_app_entry:
@@ -981,10 +964,10 @@ tls_app_entry:
mov edx, [current_slot] mov edx, [current_slot]
mov [edx+APPDATA.tls_base], eax mov [edx+APPDATA.tls_base], eax
mov [tls_data_l+2],ax mov [tls_data_l+2], ax
shr eax,16 shr eax, 16
mov [tls_data_l+4],al mov [tls_data_l+4], al
mov [tls_data_l+7],ah mov [tls_data_l+7], ah
mov dx, app_tls mov dx, app_tls
mov fs, dx mov fs, dx
popad popad
@@ -1028,44 +1011,44 @@ proc set_app_params stdcall,slot:dword, params:dword,\
mov ecx, 512/4 mov ecx, 512/4
rep movsd rep movsd
cmp ebx,[TASK_COUNT] cmp ebx, [TASK_COUNT]
jle .noinc jle .noinc
inc dword [TASK_COUNT] ;update number of processes inc dword [TASK_COUNT] ;update number of processes
.noinc: .noinc:
shl ebx,8 shl ebx, 8
lea edx, [ebx+SLOT_BASE+APP_EV_OFFSET] lea edx, [ebx+SLOT_BASE+APP_EV_OFFSET]
mov [SLOT_BASE+APPDATA.fd_ev+ebx],edx mov [SLOT_BASE+APPDATA.fd_ev+ebx], edx
mov [SLOT_BASE+APPDATA.bk_ev+ebx],edx mov [SLOT_BASE+APPDATA.bk_ev+ebx], edx
add edx, APP_OBJ_OFFSET-APP_EV_OFFSET add edx, APP_OBJ_OFFSET-APP_EV_OFFSET
mov [SLOT_BASE+APPDATA.fd_obj+ebx],edx mov [SLOT_BASE+APPDATA.fd_obj+ebx], edx
mov [SLOT_BASE+APPDATA.bk_obj+ebx],edx mov [SLOT_BASE+APPDATA.bk_obj+ebx], edx
mov ecx, [def_cursor] mov ecx, [def_cursor]
mov [SLOT_BASE+APPDATA.cursor+ebx],ecx mov [SLOT_BASE+APPDATA.cursor+ebx], ecx
mov eax, [pl0_stack] mov eax, [pl0_stack]
mov [SLOT_BASE+APPDATA.pl0_stack+ebx],eax mov [SLOT_BASE+APPDATA.pl0_stack+ebx], eax
add eax, RING0_STACK_SIZE add eax, RING0_STACK_SIZE
mov [SLOT_BASE+APPDATA.saved_esp0+ebx], eax mov [SLOT_BASE+APPDATA.saved_esp0+ebx], eax
push ebx push ebx
stdcall kernel_alloc, 0x1000 stdcall kernel_alloc, 0x1000
pop ebx pop ebx
mov esi,[current_slot] mov esi, [current_slot]
mov esi,[esi+APPDATA.cur_dir] mov esi, [esi+APPDATA.cur_dir]
mov ecx,0x1000/4 mov ecx, 0x1000/4
mov edi,eax mov edi, eax
mov [ebx+SLOT_BASE+APPDATA.cur_dir],eax mov [ebx+SLOT_BASE+APPDATA.cur_dir], eax
rep movsd rep movsd
shr ebx,3 shr ebx, 3
mov eax, new_app_base mov eax, new_app_base
mov dword [CURRENT_TASK+ebx+0x10],eax mov dword [CURRENT_TASK+ebx+0x10], eax
.add_command_line: .add_command_line:
mov edx,[params] mov edx, [params]
mov edx,[edx] ;app_cmdline mov edx, [edx] ;app_cmdline
test edx,edx test edx, edx
jz @f ;application doesn't need parameters jz @f ;application doesn't need parameters
mov eax, edx mov eax, edx
@@ -1081,9 +1064,9 @@ proc set_app_params stdcall,slot:dword, params:dword,\
jz @f jz @f
stdcall strncpy, edx, eax, 256 stdcall strncpy, edx, eax, 256
@@: @@:
mov edx,[params] mov edx, [params]
mov edx, [edx+4] ;app_path mov edx, [edx+4];app_path
test edx,edx test edx, edx
jz @F ;application don't need path of file jz @F ;application don't need path of file
mov eax, edx mov eax, edx
add eax, 1024 add eax, 1024
@@ -1092,10 +1075,10 @@ proc set_app_params stdcall,slot:dword, params:dword,\
ja @f ja @f
stdcall strncpy, edx, [app_path], 1024 stdcall strncpy, edx, [app_path], 1024
@@: @@:
mov ebx,[slot] mov ebx, [slot]
mov eax,ebx mov eax, ebx
shl ebx,5 shl ebx, 5
lea ecx,[draw_data+ebx] ;ecx - pointer to draw data lea ecx, [draw_data+ebx];ecx - pointer to draw data
mov edx, irq0.return mov edx, irq0.return
cmp [ebx*8+SLOT_BASE+APPDATA.tls_base], -1 cmp [ebx*8+SLOT_BASE+APPDATA.tls_base], -1
@@ -1105,26 +1088,26 @@ proc set_app_params stdcall,slot:dword, params:dword,\
; set window state to 'normal' (non-minimized/maximized/rolled-up) state ; set window state to 'normal' (non-minimized/maximized/rolled-up) state
mov [ebx+window_data+WDATA.fl_wstate], WSTATE_NORMAL mov [ebx+window_data+WDATA.fl_wstate], WSTATE_NORMAL
mov [ebx+window_data+WDATA.fl_redraw], 1 mov [ebx+window_data+WDATA.fl_redraw], 1
add ebx,CURRENT_TASK ;ebx - pointer to information about process add ebx, CURRENT_TASK ;ebx - pointer to information about process
mov [ebx+TASKDATA.wnd_number],al;set window number on screen = process slot mov [ebx+TASKDATA.wnd_number], al;set window number on screen = process slot
mov [ebx+TASKDATA.event_mask],dword 1+2+4 ;set default event flags (see 40 function) mov [ebx+TASKDATA.event_mask], dword 1+2+4;set default event flags (see 40 function)
inc dword [process_number] inc dword [process_number]
mov eax,[process_number] mov eax, [process_number]
mov [ebx+4],eax ;set PID mov [ebx+4], eax ;set PID
;set draw data to full screen ;set draw data to full screen
xor eax,eax xor eax, eax
mov [ecx+0],dword eax mov [ecx+0], dword eax
mov [ecx+4],dword eax mov [ecx+4], dword eax
mov eax,[Screen_Max_X] mov eax, [Screen_Max_X]
mov [ecx+8],eax mov [ecx+8], eax
mov eax,[Screen_Max_Y] mov eax, [Screen_Max_Y]
mov [ecx+12],eax mov [ecx+12], eax
mov ebx, [pl0_stack] mov ebx, [pl0_stack]
mov esi,[params] mov esi, [params]
lea ecx, [ebx+REG_EIP] lea ecx, [ebx+REG_EIP]
xor eax, eax xor eax, eax
@@ -1132,19 +1115,19 @@ proc set_app_params stdcall,slot:dword, params:dword,\
mov [ebx+REG_EDI], eax mov [ebx+REG_EDI], eax
mov [ebx+REG_ESI], eax mov [ebx+REG_ESI], eax
mov [ebx+REG_EBP], eax mov [ebx+REG_EBP], eax
mov [ebx+REG_ESP], ecx ;ebx+REG_EIP mov [ebx+REG_ESP], ecx;ebx+REG_EIP
mov [ebx+REG_EBX], eax mov [ebx+REG_EBX], eax
mov [ebx+REG_EDX], eax mov [ebx+REG_EDX], eax
mov [ebx+REG_ECX], eax mov [ebx+REG_ECX], eax
mov [ebx+REG_EAX], eax mov [ebx+REG_EAX], eax
mov eax, [esi+0x08] ;app_eip mov eax, [esi+0x08] ;app_eip
mov [ebx+REG_EIP], eax ;app_entry mov [ebx+REG_EIP], eax;app_entry
mov [ebx+REG_CS], dword app_code mov [ebx+REG_CS], dword app_code
mov [ebx+REG_EFLAGS], dword EFL_IOPL1+EFL_IF mov [ebx+REG_EFLAGS], dword EFL_IOPL1+EFL_IF
mov eax, [esi+0x0C] ;app_esp mov eax, [esi+0x0C] ;app_esp
mov [ebx+REG_APP_ESP], eax ;app_stack mov [ebx+REG_APP_ESP], eax;app_stack
mov [ebx+REG_SS], dword app_data mov [ebx+REG_SS], dword app_data
lea ecx, [ebx+REG_RET] lea ecx, [ebx+REG_RET]
@@ -1152,13 +1135,13 @@ proc set_app_params stdcall,slot:dword, params:dword,\
shl ebx, 5 shl ebx, 5
mov [ebx*8+SLOT_BASE+APPDATA.saved_esp], ecx mov [ebx*8+SLOT_BASE+APPDATA.saved_esp], ecx
xor ecx, ecx ; process state - running xor ecx, ecx; process state - running
; set if debuggee ; set if debuggee
test byte [flags], 1 test byte [flags], 1
jz .no_debug jz .no_debug
inc ecx ; process state - suspended inc ecx ; process state - suspended
mov eax,[CURRENT_TASK] mov eax, [CURRENT_TASK]
mov [SLOT_BASE+ebx*8+APPDATA.debugger_slot],eax mov [SLOT_BASE+ebx*8+APPDATA.debugger_slot], eax
.no_debug: .no_debug:
mov [CURRENT_TASK+ebx+TASKDATA.state], cl mov [CURRENT_TASK+ebx+TASKDATA.state], cl
;mov esi,new_process_running ;mov esi,new_process_running
@@ -1166,4 +1149,13 @@ proc set_app_params stdcall,slot:dword, params:dword,\
ret ret
endp endp
align 4
get_stack_base:
mov eax, [current_slot]
mov eax, [eax+APPDATA.pl0_stack]
ret
include "debug.inc" include "debug.inc"

View File

@@ -0,0 +1,205 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2011. All rights reserved. ;;
;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 2381 $
; Simple implementation of timers. All timers are organized in a double-linked
; list, and the OS loop after every timer tick processes the list.
; This structure describes a timer for the kernel.
struct TIMER
Next dd ?
Prev dd ?
; These fields organize a double-linked list of all timers.
TimerFunc dd ?
; Function to be called when the timer is activated.
UserData dd ?
; The value that is passed as is to .TimerFunc.
Time dd ?
; Time at which the timer should be activated.
Interval dd ?
; Interval between activations of the timer, in 0.01s.
ends
iglobal
align 4
; The head of timer list.
timer_list:
dd timer_list
dd timer_list
endg
uglobal
; These two variables are used to synchronize access to the global list.
; Logically, they form an recursive mutex. Physically, the first variable holds
; the slot number of the current owner or 0, the second variable holds the
; recursion count.
; The mutex should be recursive to allow a timer function to add/delete other
; timers or itself.
timer_list_owner dd 0
timer_list_numlocks dd 0
; A timer function can delete any timer, including itself and the next timer in
; the chain. To handle such situation correctly, we keep the next timer in a
; global variable, so the removing operation can update it.
timer_next dd 0
endg
; This internal function acquires the lock for the global list.
lock_timer_list:
mov edx, [CURRENT_TASK]
@@:
xor eax, eax
lock cmpxchg [timer_list_owner], edx
jz @f
cmp eax, edx
jz @f
call change_task
jmp @b
@@:
inc [timer_list_numlocks]
ret
; This internal function releases the lock for the global list.
unlock_timer_list:
dec [timer_list_numlocks]
jnz .nothing
mov [timer_list_owner], 0
.nothing:
ret
; This function adds a timer.
; If deltaStart is nonzero, the timer is activated after deltaStart hundredths
; of seconds starting from the current time. If interval is nonzero, the timer
; is activated every deltaWork hundredths of seconds starting from the first
; activation. The activated timer calls timerFunc as stdcall function with one
; argument userData.
; Return value is NULL if something has failed or some value which is opaque
; for the caller. Later this value can be used for cancel_timer_hs.
proc timer_hs stdcall uses ebx, deltaStart:dword, interval:dword, \
timerFunc:dword, userData:dword
; 1. Allocate memory for the TIMER structure.
; 1a. Call the allocator.
push sizeof.TIMER
pop eax
call malloc
; 1b. If allocation failed, return (go to 5) with eax = 0.
test eax, eax
jz .nothing
; 2. Setup the TIMER structure.
xchg ebx, eax
; 2a. Copy values from the arguments.
mov ecx, [interval]
mov [ebx+TIMER.Interval], ecx
mov ecx, [timerFunc]
mov [ebx+TIMER.TimerFunc], ecx
mov ecx, [userData]
mov [ebx+TIMER.UserData], ecx
; 2b. Get time of the next activation.
mov ecx, [deltaStart]
test ecx, ecx
jnz @f
mov ecx, [interval]
@@:
add ecx, [timer_ticks]
mov [ebx+TIMER.Time], ecx
; 3. Insert the TIMER structure to the global list.
; 3a. Acquire the lock.
call lock_timer_list
; 3b. Insert an item at ebx to the tail of the timer_list.
mov eax, timer_list
mov ecx, [eax+TIMER.Prev]
mov [ebx+TIMER.Next], eax
mov [ebx+TIMER.Prev], ecx
mov [eax+TIMER.Prev], ebx
mov [ecx+TIMER.Next], ebx
; 3c. Release the lock.
call unlock_timer_list
; 4. Return with eax = pointer to TIMER structure.
xchg ebx, eax
.nothing:
; 5. Returning.
ret
endp
; This function removes a timer.
; The only argument is [esp+4] = the value which was returned from timer_hs.
cancel_timer_hs:
push ebx ; save used register to be stdcall
; 1. Remove the TIMER structure from the global list.
; 1a. Acquire the lock.
call lock_timer_list
mov ebx, [esp+4+4]
; 1b. Delete an item at ebx from the double-linked list.
mov eax, [ebx+TIMER.Next]
mov ecx, [ebx+TIMER.Prev]
mov [eax+TIMER.Prev], ecx
mov [ecx+TIMER.Next], eax
; 1c. If we are removing the next timer in currently processing chain,
; the next timer for this timer becomes new next timer.
cmp ebx, [timer_next]
jnz @f
mov [timer_next], eax
@@:
; 1d. Release the lock.
call unlock_timer_list
; 2. Free the TIMER structure.
xchg eax, ebx
call free
; 3. Return.
pop ebx ; restore used register to be stdcall
ret 4 ; purge one dword argument to be stdcall
; This function is regularly called from osloop. It processes the global list
; and activates the corresponding timers.
check_timers:
; 1. Acquire the lock.
call lock_timer_list
; 2. Loop over all registered timers, checking time.
; 2a. Get the first item.
mov eax, [timer_list+TIMER.Next]
mov [timer_next], eax
.loop:
; 2b. Check for end of list.
cmp eax, timer_list
jz .done
; 2c. Get and store the next timer.
mov edx, [eax+TIMER.Next]
mov [timer_next], edx
; 2d. Check time for timer activation.
; We can't just compare [timer_ticks] and [TIMER.Time], since overflows are
; possible: if the current time is 0FFFFFFFFh ticks and timer should be
; activated in 3 ticks, the simple comparison will produce incorrect result.
; So we calculate the difference [timer_ticks] - [TIMER.Time]; if it is
; non-negative, the time is over; if it is negative, then either the time is
; not over or we have not processed this timer for 2^31 ticks, what is very
; unlikely.
mov edx, [timer_ticks]
sub edx, [eax+TIMER.Time]
js .next
; The timer should be activated now.
; 2e. Store the timer data in the stack. This is required since 2f can delete
; the timer, invalidating the content.
push [eax+TIMER.UserData] ; parameter for TimerFunc
push [eax+TIMER.TimerFunc] ; to be restored in 2g
; 2f. Calculate time of next activation or delete the timer if it is one-shot.
mov ecx, [eax+TIMER.Interval]
add [eax+TIMER.Time], ecx
test ecx, ecx
jnz .nodelete
stdcall cancel_timer_hs, eax
.nodelete:
; 2g. Activate timer, using data from the stack.
pop eax
call eax
.next:
; 2h. Advance to the next timer and continue the loop.
mov eax, [timer_next]
jmp .loop
.done:
; 3. Release the lock.
call unlock_timer_list
; 4. Return.
ret

View File

@@ -91,10 +91,10 @@ v86_create:
; now V86 specific: initialize known addresses in first Mb ; now V86 specific: initialize known addresses in first Mb
pop eax pop eax
; first page - BIOS data (shared between all machines!) ; first page - BIOS data (shared between all machines!)
; physical address = 0x2f0000 ; physical address = 0
; linear address = BOOT_VAR = OS_BASE + 0x2f0000 ; linear address = OS_BASE
mov dword [eax], (BOOT_VAR - OS_BASE) or 111b mov dword [eax], 111b
mov dword [eax+800h], BOOT_VAR mov dword [eax+800h], OS_BASE
; page before 0xA0000 - Extended BIOS Data Area (shared between all machines!) ; page before 0xA0000 - Extended BIOS Data Area (shared between all machines!)
; physical address = 0x9C000 ; physical address = 0x9C000
; linear address = 0x8009C000 ; linear address = 0x8009C000
@@ -219,12 +219,12 @@ init_sys_v86:
mov [sys_v86_machine], eax mov [sys_v86_machine], eax
test eax, eax test eax, eax
jz .ret jz .ret
mov byte [BOOT_VAR + 0x500], 0xCD mov byte [OS_BASE + 0x500], 0xCD
mov byte [BOOT_VAR + 0x501], 0x13 mov byte [OS_BASE + 0x501], 0x13
mov byte [BOOT_VAR + 0x502], 0xF4 mov byte [OS_BASE + 0x502], 0xF4
mov byte [BOOT_VAR + 0x503], 0xCD mov byte [OS_BASE + 0x503], 0xCD
mov byte [BOOT_VAR + 0x504], 0x10 mov byte [OS_BASE + 0x504], 0x10
mov byte [BOOT_VAR + 0x505], 0xF4 mov byte [OS_BASE + 0x505], 0xF4
mov esi, eax mov esi, eax
mov ebx, [eax+V86_machine.pagedir] mov ebx, [eax+V86_machine.pagedir]
; one page for stack, two pages for results (0x2000 bytes = 16 sectors) ; one page for stack, two pages for results (0x2000 bytes = 16 sectors)
@@ -328,7 +328,7 @@ v86_start:
cmp edx, -1 cmp edx, -1
jz .noirqhook jz .noirqhook
uglobal uglobal
v86_irqhooks rd 16*2 v86_irqhooks rd IRQ_RESERVED * 2
endg endg
cmp [v86_irqhooks+edx*8], 0 cmp [v86_irqhooks+edx*8], 0
jz @f jz @f
@@ -367,11 +367,12 @@ endg
v86_exc_c: v86_exc_c:
; Did we all that we have wanted to do? ; Did we all that we have wanted to do?
cmp bl,1 cmp bl, 1
jne @f jne @f
xor eax, eax xor eax, eax
mov dr6, eax mov dr6, eax
@@: mov eax, [esp+v86_regs.size+10h+18h] @@:
mov eax, [esp+v86_regs.size+10h+18h]
cmp word [esp+v86_regs.eip], ax cmp word [esp+v86_regs.eip], ax
jnz @f jnz @f
shr eax, 16 shr eax, 16
@@ -805,7 +806,6 @@ end if
mov dword [SLOT_BASE+ecx+APPDATA.io_map], ebx mov dword [SLOT_BASE+ecx+APPDATA.io_map], ebx
mov dword [page_tabs + (tss._io_map_0 shr 10)], ebx mov dword [page_tabs + (tss._io_map_0 shr 10)], ebx
mov cr3, eax mov cr3, eax
; mov [irq_tab+5*4], 0
sti sti
popad popad
@@ -839,16 +839,17 @@ end if
; mov byte [BOOT_VAR + 48Eh], 0FFh ; mov byte [BOOT_VAR + 48Eh], 0FFh
; ret ; ret
align 4
v86_irq: v86_irq:
; push irq/pushad/jmp v86_irq ; push irq/pushad/jmp v86_irq
; eax = irq ; ebp = irq
lea esi, [esp+1Ch] lea esi, [esp+1Ch]
lea edi, [esi+4] lea edi, [esi+4]
mov ecx, 8 mov ecx, 8
std std
rep movsd rep movsd
cld cld
mov edi, eax mov edi, ebp
pop eax pop eax
v86_irq2: v86_irq2:
mov esi, [v86_irqhooks+edi*8] ; get VM handle mov esi, [v86_irqhooks+edi*8] ; get VM handle
@@ -898,12 +899,8 @@ v86_irq2:
pop ecx pop ecx
.cont: .cont:
loop .scan loop .scan
mov al, 20h mov ecx, edi
out 20h, al call irq_eoi
cmp edi, 8
jb @f
out 0A0h, al
@@:
popad popad
iretd iretd
.found: .found:

View File

@@ -12,7 +12,8 @@ flm db 0
preboot_lfb db 0 preboot_lfb db 0
preboot_bootlog db 0 preboot_bootlog db 0
boot_drive db 0 boot_drive db 0
bx_from_load: dw 'r1' ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>- <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> bx ; {SPraid}[13.03.2007] bx_from_load:
dw 'r1' ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>- <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> bx ; {SPraid}[13.03.2007]
; a,b,c,d - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, r - <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; a,b,c,d - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, r - <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; # <20><><EFBFBD><EFBFBD><EFBFBD>... <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20> <20><> <20><><EFBFBD><EFBFBD>. '1', <20> <20><> 1 ; # <20><><EFBFBD><EFBFBD><EFBFBD>... <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20> <20><> <20><><EFBFBD><EFBFBD>. '1', <20> <20><> 1
@@ -22,10 +23,12 @@ old_ints_h:
dd 0 dd 0
dw 0 dw 0
if ~ defined extended_primary_loader ; restart from memory is not supported in extended primary loader cfg
kernel_restart_bootblock: kernel_restart_bootblock:
db 1 ; version db 1 ; version
dw 1 ; floppy image is in memory dw 1 ; floppy image is in memory
dd 0 ; cannot save parameters dd 0 ; cannot save parameters
end if
; table for move to extended memory (int 15h, ah=87h) ; table for move to extended memory (int 15h, ah=87h)
align 8 align 8
@@ -53,3 +56,36 @@ fwmovedesc:
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0 db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
if defined extended_primary_loader
; look in PrimaryLoader.txt for the description
bootdevice dw 0 ; ax from primary loader
bootfs dw 0 ; bx from primary loader
bootcallback dd 0 ; ds:si from primary loader
; data for configuration file loading, look in PrimaryLoader.txt
config_file_struct:
dw 0, 4000h ; load to 4000:0000
dw 16 ; read no more than 16*4K = 64K
db 'config.ini',0
; data for configuration file parsing
macro config_variable string,parser
{
local len
len dw 0
db string
store word $ - len - 2 at len
dw parser
}
config_file_variables:
config_variable 'timeout', parse_timeout
config_variable 'resolution', parse_resolution
config_variable 'vbemode', parse_vbemode
; config_variable 'vrr', parse_vrr
config_variable 'biosdisks', parse_biosdisks
config_variable 'imgfrom', parse_imgfrom
dw 0
; data for image file loading, look in PrimaryLoader.txt
image_file_struct:
dw 0, 4000h ; load to 4000:0000
dw 16 ; read no more than 16*4K = 64K
db 'kolibri.img',0
end if

View File

@@ -47,20 +47,43 @@ keymap_alt:
db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' db 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
boot_memdetect db 'Determining amount of memory',0
if lang eq ru
boot_fonts db '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><E3A6A5>',0
boot_memdetect db '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E2A8A2><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',' ',' <20><>',0
boot_tss db '<27><><EFBFBD><E2A0AD><EFBFBD><EFBFBD> TSSs',0
boot_cpuid db '<27><EFBFBD><E2A5AD> CPUIDs',0
boot_devices db '<27><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><E0AEA9><EFBFBD>',0
boot_timer db '<27><><EFBFBD><E2A0AD><EFBFBD><EFBFBD><><E2A0A9><EFBFBD><EFBFBD>',0
boot_irqs db '<27><><EFBFBD><EFBFBD><E0A5A4><EFBFBD><EFBFBD><EFBFBD><EFBFBD> IRQ',0
boot_setmouse db '<27><><EFBFBD><E2A0AD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>',0
boot_windefs db '<27><><EFBFBD><E2A0AD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><><EFBFBD><E7A0AD>',0
boot_bgr db '<27><><EFBFBD><E2A0AD><EFBFBD><EFBFBD><>',0
boot_resirqports db '<27><><EFBFBD><EFBFBD>ࢨ஢<E0A2A8><E0AEA2><EFBFBD><EFBFBD> IRQ <20> <20><><EFBFBD>⮢',0
boot_setrports db '<27><><EFBFBD><E2A0AD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>ᮢ IRQ',0
boot_setostask db '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>',0
boot_allirqs db '<27><><EFBFBD><EFBFBD><EFBFBD><20><><EFBFBD><EFBFBD> IRQ',0
boot_tsc db '<27><EFBFBD><E2A5AD> TSC',0
boot_cpufreq db '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ',' ',' <20><><EFBFBD>',0
boot_pal_ega db '<27><><EFBFBD><E2A0AD><EFBFBD><EFBFBD> EGA/CGA 320x200 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',0
boot_pal_vga db '<27><><EFBFBD><E2A0AD><EFBFBD><EFBFBD> VGA 640x480 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',0
boot_failed db '<27><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><E0A2AE> <20><EFBFBD><E0A8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><><E3A4A0><EFBFBD><EFBFBD>',0
boot_mtrr db '<27><><EFBFBD><E2A0AD><EFBFBD><EFBFBD> MTRR',0
if preboot_blogesc
boot_tasking db '<27><><EFBFBD> <20><><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD>᪠, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ESC <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',0
end if
else
boot_fonts db 'Fonts loaded',0 boot_fonts db 'Fonts loaded',0
boot_memdetect db 'Determining amount of memory',0
boot_tss db 'Setting TSSs',0 boot_tss db 'Setting TSSs',0
boot_cpuid db 'Reading CPUIDs',0 boot_cpuid db 'Reading CPUIDs',0
boot_devices db 'Detecting devices',0 boot_devices db 'Detecting devices',0
boot_timer db 'Setting timer',0
boot_irqs db 'Reprogramming IRQs',0
boot_setmouse db 'Setting mouse',0 boot_setmouse db 'Setting mouse',0
boot_windefs db 'Setting window defaults',0 boot_windefs db 'Setting window defaults',0
boot_bgr db 'Calculating background',0 boot_bgr db 'Calculating background',0
boot_resirqports db 'Reserving IRQs & ports',0 boot_resirqports db 'Reserving IRQs & ports',0
boot_setrports db 'Setting addresses for IRQs',0
boot_setostask db 'Setting OS task',0 boot_setostask db 'Setting OS task',0
boot_allirqs db 'Unmasking all IRQs',0 boot_allirqs db 'Unmasking IRQs',0
boot_tsc db 'Reading TSC',0 boot_tsc db 'Reading TSC',0
boot_cpufreq db 'CPU frequency is ',' ',' MHz',0 boot_cpufreq db 'CPU frequency is ',' ',' MHz',0
boot_pal_ega db 'Setting EGA/CGA 320x200 palette',0 boot_pal_ega db 'Setting EGA/CGA 320x200 palette',0
@@ -70,6 +93,10 @@ keymap_alt:
if preboot_blogesc if preboot_blogesc
boot_tasking db 'All set - press ESC to start',0 boot_tasking db 'All set - press ESC to start',0
end if end if
end if
boot_APIC_found db 'APIC enabled', 0
boot_APIC_nfound db 'APIC not found', 0
;new_process_loading db 'K : New Process - loading',13,10,0 ;new_process_loading db 'K : New Process - loading',13,10,0
;new_process_running db 'K : New Process - done',13,10,0 ;new_process_running db 'K : New Process - done',13,10,0
@@ -101,6 +128,12 @@ szIMPORTS db 'IMPORTS',0
read_firstapp db '/sys/' read_firstapp db '/sys/'
firstapp db 'LAUNCHER',0 firstapp db 'LAUNCHER',0
notifyapp db '@notify',0
if lang eq ru
ud_user_message db '<27><EFBFBD><E8A8A1>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E0A6A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>',0
else
ud_user_message db 'Error: unsupported processor instruction',0
end if
char db '/sys/FONTS/CHAR.MT',0 char db '/sys/FONTS/CHAR.MT',0
char2 db '/sys/FONTS/CHAR2.MT',0 char2 db '/sys/FONTS/CHAR2.MT',0
@@ -108,9 +141,10 @@ char2 db '/sys/FONTS/CHAR2.MT',0
bootpath db '/KOLIBRI ' bootpath db '/KOLIBRI '
bootpath2 db 0 bootpath2 db 0
vmode db '/sys/drivers/VMODE.MDR',0 vmode db '/sys/drivers/VMODE.MDR',0
vrr_m db 'VRR_M',0 ;vrr_m db 'VRR_M',0
kernel_file db 'KERNEL MNT' kernel_file db 'KERNEL MNT'
dev_data_path db '/RD/1/DRIVERS/DEVICES.DAT',0
align 4 align 4
@@ -259,51 +293,23 @@ gdte:
align 16 align 16
cur_saved_data rb 4096 cur_saved_data rb 4096
fpu_data: rb 512 fpu_data:
rb 512
; device irq owners mem_block_list rd 64*2
irq_owner rd 16 ; process id mem_used_list rd 64*2
mem_hash_cnt rd 64
; on irq read ports heap_mutex MUTEX
irq00read rd 16
irq01read rd 16
irq02read rd 16
irq03read rd 16
irq04read rd 16
irq05read rd 16
irq06read rd 16
irq07read rd 16
irq08read rd 16
irq09read rd 16
irq10read rd 16
irq11read rd 16
irq12read rd 16
irq13read rd 16
irq14read rd 16
irq15read rd 16
irq_tab rd 16
mem_block_map rb 512
mem_block_list rd 64
large_block_list rd 31
mem_block_mask rd 2
large_block_mask rd 1
mem_used.fd rd 1
mem_used.bk rd 1
mem_block_arr rd 1
mem_block_start rd 1
mem_block_end rd 1
heap_mutex rd 1
heap_size rd 1 heap_size rd 1
heap_free rd 1 heap_free rd 1
heap_blocks rd 1 heap_blocks rd 1
free_blocks rd 1 free_blocks rd 1
mem_block_mask rd 2
next_memblock rd 1
mst MEM_STATE mst MEM_STATE
page_start rd 1 page_start rd 1
@@ -368,6 +374,7 @@ cdid rd 1
hdbase rd 1 ; for boot 0x1f0 hdbase rd 1 ; for boot 0x1f0
hdid rd 1 hdid rd 1
hdpos rd 1 ; for boot 0x1 hdpos rd 1 ; for boot 0x1
label known_part dword
fat32part rd 1 ; for boot 0x1 fat32part rd 1 ; for boot 0x1
cdpos rd 1 cdpos rd 1

View File

@@ -55,7 +55,7 @@ bdds:
inc ax inc ax
cmp word [si], 170h cmp word [si], 170h
jz @f jz @f
or ax,-1 or ax, -1
; mov ax, -1 ; mov ax, -1
@@: @@:
stosw stosw
@@ -64,7 +64,7 @@ bdds:
bddl: bddl:
mov al, dl mov al, dl
stosb stosb
xor ax,ax xor ax, ax
stosb stosb
dec ax dec ax
stosw stosw

View File

@@ -13,18 +13,25 @@ $Revision$
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FDD ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FDD
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Mario79 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Mario79
;*************************************************** ;***************************************************
xor eax,eax xor eax, eax
mov edi,DRIVE_DATA mov edi, DRIVE_DATA
mov ecx,16384 mov ecx, 16384
cld cld
rep stosd rep stosd
mov al,0x10 mov al, 0x10
out 0x70,al out 0x70, al
mov cx,0xff mov cx, 0xff
wait_cmos: wait_cmos:
dec cx dec cx
test cx,cx test cx, cx
jnz wait_cmos jnz wait_cmos
in al,0x71 in al, 0x71
mov [DRIVE_DATA],al mov [DRIVE_DATA], al
test al, al
jz @f
in al, 0x21
and al, 10111111b ; Enable IRQ6
out 0x21, al
@@:

View File

@@ -18,8 +18,8 @@ $Revision$
;* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HDD <EFBFBD> CD * ;* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HDD <EFBFBD> CD *
;**************************************************** ;****************************************************
FindHDD: FindHDD:
mov [ChannelNumber],1 mov [ChannelNumber], 1
mov [DiskNumber],0 mov [DiskNumber], 0
call FindHDD_3 call FindHDD_3
; mov ax,[Sector512+176] ; mov ax,[Sector512+176]
; mov [DRIVE_DATA+6],ax ; mov [DRIVE_DATA+6],ax
@@ -27,16 +27,16 @@ FindHDD:
; mov [DRIVE_DATA+8],ax ; mov [DRIVE_DATA+8],ax
; mov ax,[Sector512+128] ; mov ax,[Sector512+128]
; mov [DRIVE_DATA+8],ax ; mov [DRIVE_DATA+8],ax
mov [DiskNumber],1 mov [DiskNumber], 1
call FindHDD_3 call FindHDD_3
; mov al,[Sector512+176] ; mov al,[Sector512+176]
; mov [DRIVE_DATA+7],al ; mov [DRIVE_DATA+7],al
inc [ChannelNumber] inc [ChannelNumber]
mov [DiskNumber],0 mov [DiskNumber], 0
call FindHDD_3 call FindHDD_3
; mov al,[Sector512+176] ; mov al,[Sector512+176]
; mov [DRIVE_DATA+8],al ; mov [DRIVE_DATA+8],al
mov [DiskNumber],1 mov [DiskNumber], 1
call FindHDD_1 call FindHDD_1
; mov al,[Sector512+176] ; mov al,[Sector512+176]
; mov [DRIVE_DATA+9],al ; mov [DRIVE_DATA+9],al
@@ -45,20 +45,20 @@ FindHDD:
FindHDD_1: FindHDD_1:
call ReadHDD_ID call ReadHDD_ID
cmp [DevErrorCode],0 cmp [DevErrorCode], 0
jne FindHDD_2 jne FindHDD_2
cmp [Sector512+6],word 16 cmp [Sector512+6], word 16
ja FindHDD_2 ja FindHDD_2
cmp [Sector512+12],word 255 cmp [Sector512+12], word 255
ja FindHDD_2 ja FindHDD_2
inc byte [DRIVE_DATA+1] inc byte [DRIVE_DATA+1]
jmp FindHDD_2_2 jmp FindHDD_2_2
FindHDD_2: FindHDD_2:
call DeviceReset call DeviceReset
cmp [DevErrorCode],0 cmp [DevErrorCode], 0
jne FindHDD_2_2 jne FindHDD_2_2
call ReadCD_ID call ReadCD_ID
cmp [DevErrorCode],0 cmp [DevErrorCode], 0
jne FindHDD_2_2 jne FindHDD_2_2
inc byte [DRIVE_DATA+1] inc byte [DRIVE_DATA+1]
inc byte [DRIVE_DATA+1] inc byte [DRIVE_DATA+1]
@@ -67,7 +67,7 @@ FindHDD_1:
FindHDD_3: FindHDD_3:
call FindHDD_1 call FindHDD_1
shl byte [DRIVE_DATA+1],2 shl byte [DRIVE_DATA+1], 2
ret ret
@@ -86,45 +86,46 @@ endg
;************************************************* ;*************************************************
ReadHDD_ID: ReadHDD_ID:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CHS ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CHS
mov [ATAAddressMode],0 mov [ATAAddressMode], 0
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [ATAFeatures],0 mov [ATAFeatures], 0
mov [ATAHead],0 mov [ATAHead], 0
mov [ATACommand],0ECh mov [ATACommand], 0ECh
call SendCommandToHDD call SendCommandToHDD
cmp [DevErrorCode],0 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> cmp [DevErrorCode], 0;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
jne @@End ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> jne @@End ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov DX,[ATABasePortAddr] mov DX, [ATABasePortAddr]
add DX,7 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> add DX, 7 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov ecx,0xffff mov ecx, 0xffff
@@WaitCompleet: @@WaitCompleet:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
dec ecx dec ecx
; cmp ecx,0 ; cmp ecx,0
jz @@Error1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD> jz @@Error1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
in AL,DX in AL, DX
test AL,80h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BSY test AL, 80h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BSY
jnz @@WaitCompleet jnz @@WaitCompleet
test AL,1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ERR test AL, 1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ERR
jnz @@Error6 jnz @@Error6
test AL,08h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DRQ test AL, 08h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DRQ
jz @@WaitCompleet jz @@WaitCompleet
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; mov AX,DS ; mov AX,DS
; mov ES,AX ; mov ES,AX
mov EDI,Sector512 ;offset Sector512 mov EDI, Sector512 ;offset Sector512
mov DX,[ATABasePortAddr] ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov DX, [ATABasePortAddr];<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov CX,256 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov CX, 256 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
rep insw ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> rep insw ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ret ret
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@Error1: @@Error1:
mov [DevErrorCode],1 mov [DevErrorCode], 1
ret ret
@@Error6: @@Error6:
mov [DevErrorCode],6 mov [DevErrorCode], 6
@@End: ret @@End:
ret
iglobal iglobal
@@ -174,33 +175,33 @@ endg
;**************************************************** ;****************************************************
SendCommandToHDD: SendCommandToHDD:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cmp [ATAAddressMode],1 cmp [ATAAddressMode], 1
ja @@Err2 ja @@Err2
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov BX,[ChannelNumber] mov BX, [ChannelNumber]
cmp BX,1 cmp BX, 1
jb @@Err3 jb @@Err3
cmp BX,2 cmp BX, 2
ja @@Err3 ja @@Err3
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
dec BX dec BX
shl BX,1 shl BX, 1
movzx ebx,bx movzx ebx, bx
mov AX,[ebx+StandardATABases] mov AX, [ebx+StandardATABases]
mov [ATABasePortAddr],AX mov [ATABasePortAddr], AX
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HDD <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HDD <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov DX,[ATABasePortAddr] mov DX, [ATABasePortAddr]
add DX,6 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> add DX, 6 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov AL,[DiskNumber] mov AL, [DiskNumber]
cmp AL,1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> cmp AL, 1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ja @@Err4 ja @@Err4
shl AL,4 shl AL, 4
or AL,10100000b or AL, 10100000b
out DX,AL out DX, AL
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
inc DX inc DX
mov ecx,0xfff mov ecx, 0xfff
; mov eax,[timer_ticks] ; mov eax,[timer_ticks]
; mov [TickCounter_1],eax ; mov [TickCounter_1],eax
@@WaitHDReady: @@WaitHDReady:
@@ -213,60 +214,65 @@ SendCommandToHDD:
; cmp eax,300 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 300 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; cmp eax,300 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 300 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; ja @@Err1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; ja @@Err1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
in AL,DX in AL, DX
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BSY ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BSY
test AL,80h test AL, 80h
jnz @@WaitHDReady jnz @@WaitHDReady
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DRQ ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DRQ
test AL,08h test AL, 08h
jnz @@WaitHDReady jnz @@WaitHDReady
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cli cli
mov DX,[ATABasePortAddr] mov DX, [ATABasePortAddr]
inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
mov AL,[ATAFeatures] mov AL, [ATAFeatures]
out DX,AL out DX, AL
inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov AL,[ATASectorCount] mov AL, [ATASectorCount]
out DX,AL out DX, AL
inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov AL,[ATASectorNumber] mov AL, [ATASectorNumber]
out DX,AL out DX, AL
inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>) inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
mov AX,[ATACylinder] mov AX, [ATACylinder]
out DX,AL out DX, AL
inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>) inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
mov AL,AH mov AL, AH
out DX,AL out DX, AL
inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov AL,[DiskNumber] mov AL, [DiskNumber]
shl AL,4 shl AL, 4
cmp [ATAHead],0Fh ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> cmp [ATAHead], 0Fh;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ja @@Err5 ja @@Err5
or AL,[ATAHead] or AL, [ATAHead]
or AL,10100000b or AL, 10100000b
mov AH,[ATAAddressMode] mov AH, [ATAAddressMode]
shl AH,6 shl AH, 6
or AL,AH or AL, AH
out DX,AL out DX, AL
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov AL,[ATACommand] mov AL, [ATACommand]
inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
out DX,AL out DX, AL
sti sti
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [DevErrorCode],0 mov [DevErrorCode], 0
ret ret
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@Err1: mov [DevErrorCode],1 @@Err1:
mov [DevErrorCode], 1
ret ret
@@Err2: mov [DevErrorCode],2 @@Err2:
mov [DevErrorCode], 2
ret ret
@@Err3: mov [DevErrorCode],3 @@Err3:
mov [DevErrorCode], 3
ret ret
@@Err4: mov [DevErrorCode],4 @@Err4:
mov [DevErrorCode], 4
ret ret
@@Err5: mov [DevErrorCode],5 @@Err5:
mov [DevErrorCode], 5
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ret ret
@@ -281,48 +287,48 @@ SendCommandToHDD:
;************************************************* ;*************************************************
ReadCD_ID: ReadCD_ID:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CHS ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> CHS
mov [ATAAddressMode],0 mov [ATAAddressMode], 0
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [ATAFeatures],0 mov [ATAFeatures], 0
mov [ATASectorCount],0 mov [ATASectorCount], 0
mov [ATASectorNumber],0 mov [ATASectorNumber], 0
mov [ATACylinder],0 mov [ATACylinder], 0
mov [ATAHead],0 mov [ATAHead], 0
mov [ATACommand],0A1h mov [ATACommand], 0A1h
call SendCommandToHDD call SendCommandToHDD
cmp [DevErrorCode],0 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> cmp [DevErrorCode], 0;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
jne @@End_1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> jne @@End_1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HDD ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> HDD
mov DX,[ATABasePortAddr] mov DX, [ATABasePortAddr]
add DX,7 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1<EFBFBD>7h add DX, 7 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1<EFBFBD>7h
mov ecx,0xffff mov ecx, 0xffff
@@WaitCompleet_1: @@WaitCompleet_1:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
dec ecx dec ecx
; cmp ecx,0 ; cmp ecx,0
jz @@Error1_1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD> jz @@Error1_1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
in AL,DX in AL, DX
test AL,80h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BSY test AL, 80h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BSY
jnz @@WaitCompleet_1 jnz @@WaitCompleet_1
test AL,1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ERR test AL, 1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ERR
jnz @@Error6_1 jnz @@Error6_1
test AL,08h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DRQ test AL, 08h ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> DRQ
jz @@WaitCompleet_1 jz @@WaitCompleet_1
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; mov AX,DS ; mov AX,DS
; mov ES,AX ; mov ES,AX
mov EDI,Sector512 ;offset Sector512 mov EDI, Sector512 ;offset Sector512
mov DX,[ATABasePortAddr] ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1x0h mov DX, [ATABasePortAddr];<EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1x0h
mov CX,256 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov CX, 256;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
rep insw rep insw
ret ret
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@Error1_1: @@Error1_1:
mov [DevErrorCode],1 mov [DevErrorCode], 1
ret ret
@@Error6_1: @@Error6_1:
mov [DevErrorCode],6 mov [DevErrorCode], 6
@@End_1: @@End_1:
ret ret
@@ -335,49 +341,52 @@ ReadCD_ID:
;************************************************* ;*************************************************
DeviceReset: DeviceReset:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov BX,[ChannelNumber] mov BX, [ChannelNumber]
cmp BX,1 cmp BX, 1
jb @@Err3_2 jb @@Err3_2
cmp BX,2 cmp BX, 2
ja @@Err3_2 ja @@Err3_2
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
dec BX dec BX
shl BX,1 shl BX, 1
movzx ebx,bx movzx ebx, bx
mov DX,[ebx+StandardATABases] mov DX, [ebx+StandardATABases]
mov [ATABasePortAddr],DX mov [ATABasePortAddr], DX
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
add DX,6 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> add DX, 6 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov AL,[DiskNumber] mov AL, [DiskNumber]
cmp AL,1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> cmp AL, 1 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ja @@Err4_2 ja @@Err4_2
shl AL,4 shl AL, 4
or AL,10100000b or AL, 10100000b
out DX,AL out DX, AL
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"
mov AL,08h mov AL, 08h
inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> inc DX ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
out DX,AL out DX, AL
mov ecx,0x80000 mov ecx, 0x80000
@@WaitHDReady_1: @@WaitHDReady_1:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
dec ecx dec ecx
; cmp ecx,0 ; cmp ecx,0
je @@Err1_2 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD> je @@Err1_2 ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
in AL,DX in AL, DX
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BSY ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> BSY
test AL,80h test AL, 80h
jnz @@WaitHDReady_1 jnz @@WaitHDReady_1
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [DevErrorCode],0 mov [DevErrorCode], 0
ret ret
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@Err1_2: mov [DevErrorCode],1 @@Err1_2:
mov [DevErrorCode], 1
ret ret
@@Err3_2: mov [DevErrorCode],3 @@Err3_2:
mov [DevErrorCode], 3
ret ret
@@Err4_2: mov [DevErrorCode],4 @@Err4_2:
mov [DevErrorCode], 4
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ret ret

View File

@@ -9,133 +9,133 @@ $Revision$
pusha pusha
mov eax,[pg_data.pages_free] mov eax, [pg_data.pages_free]
; 1/32 ; 1/32
shr eax,5 shr eax, 5
; round off up to 8 pages ; round off up to 8 pages
shr eax,3 shr eax, 3
shl eax,3 shl eax, 3
; translate pages in butes *4096 ; translate pages in butes *4096
shl eax,12 shl eax, 12
; check a upper size of the cache, no more than 1 Mb on the physical device ; check a upper size of the cache, no more than 1 Mb on the physical device
cmp eax,1024*1024 cmp eax, 1024*1024
jbe @f jbe @f
mov eax,1024*1024 mov eax, 1024*1024
jmp .continue jmp .continue
@@: @@:
; check a lower size of the cache, not less than 128 Kb on the physical device ; check a lower size of the cache, not less than 128 Kb on the physical device
cmp eax,128*1024 cmp eax, 128*1024
jae @f jae @f
mov eax,128*1024 mov eax, 128*1024
@@: @@:
.continue: .continue:
mov [cache_ide0_size],eax mov [cache_ide0_size], eax
mov [cache_ide1_size],eax mov [cache_ide1_size], eax
mov [cache_ide2_size],eax mov [cache_ide2_size], eax
mov [cache_ide3_size],eax mov [cache_ide3_size], eax
xor eax,eax xor eax, eax
mov [hdd_appl_data],1 ;al mov [hdd_appl_data], 1;al
mov [cd_appl_data],1 mov [cd_appl_data], 1
mov ch,[DRIVE_DATA+1] mov ch, [DRIVE_DATA+1]
mov cl,ch mov cl, ch
and cl,11b and cl, 11b
je .ide2 je .ide2
mov esi,cache_ide3 mov esi, cache_ide3
call get_cache_ide call get_cache_ide
.ide2: .ide2:
mov cl,ch mov cl, ch
shr cl,2 shr cl, 2
and cl,11b and cl, 11b
je .ide1 je .ide1
mov esi,cache_ide2 mov esi, cache_ide2
call get_cache_ide call get_cache_ide
.ide1: .ide1:
mov cl,ch mov cl, ch
shr cl,4 shr cl, 4
and cl,11b and cl, 11b
je .ide0 je .ide0
mov esi,cache_ide1 mov esi, cache_ide1
call get_cache_ide call get_cache_ide
.ide0: .ide0:
mov cl,ch mov cl, ch
shr cl,6 shr cl, 6
and cl,11b and cl, 11b
je @f je @f
mov esi,cache_ide0 mov esi, cache_ide0
call get_cache_ide call get_cache_ide
@@: @@:
xor ecx,ecx xor ecx, ecx
cmp [NumBiosDisks],ecx cmp [NumBiosDisks], ecx
jz .endbd jz .endbd
mov esi,BiosDiskCaches mov esi, BiosDiskCaches
.loopbd: .loopbd:
push ecx push ecx
movsx ecx,byte [BiosDisksData+ecx*4+2] movsx ecx, byte [BiosDisksData+ecx*4+2]
inc ecx inc ecx
jz .getbd jz .getbd
add ecx,ecx add ecx, ecx
movzx eax,byte [DRIVE_DATA+1] movzx eax, byte [DRIVE_DATA+1]
shl eax,cl shl eax, cl
and ah,3 and ah, 3
cmp ah,1 cmp ah, 1
jz .contbd jz .contbd
pop ecx pop ecx
mov byte [BiosDisksData+ecx*4+2], -1 mov byte [BiosDisksData+ecx*4+2], -1
push ecx push ecx
.getbd: .getbd:
mov eax,[cache_ide0_size] mov eax, [cache_ide0_size]
mov [esi+cache_ide0_size-cache_ide0],eax mov [esi+cache_ide0_size-cache_ide0], eax
mov cl,1 mov cl, 1
call get_cache_ide call get_cache_ide
.contbd: .contbd:
pop ecx pop ecx
add esi,cache_ide1-cache_ide0 add esi, cache_ide1-cache_ide0
inc ecx inc ecx
cmp ecx,[NumBiosDisks] cmp ecx, [NumBiosDisks]
jb .loopbd jb .loopbd
.endbd: .endbd:
jmp end_get_cache jmp end_get_cache
get_cache_ide: get_cache_ide:
and [esi+cache_ide0_search_start-cache_ide0],0 and [esi+cache_ide0_search_start-cache_ide0], 0
and [esi+cache_ide0_appl_search_start-cache_ide0],0 and [esi+cache_ide0_appl_search_start-cache_ide0], 0
push ecx push ecx
stdcall kernel_alloc,[esi+cache_ide0_size-cache_ide0] stdcall kernel_alloc, [esi+cache_ide0_size-cache_ide0]
mov [esi+cache_ide0_pointer-cache_ide0],eax mov [esi+cache_ide0_pointer-cache_ide0], eax
pop ecx pop ecx
mov edx,eax mov edx, eax
mov eax,[esi+cache_ide0_size-cache_ide0] mov eax, [esi+cache_ide0_size-cache_ide0]
shr eax,3 shr eax, 3
mov [esi+cache_ide0_system_data_size-cache_ide0],eax mov [esi+cache_ide0_system_data_size-cache_ide0], eax
mov ebx,eax mov ebx, eax
imul eax,7 imul eax, 7
mov [esi+cache_ide0_appl_data_size-cache_ide0],eax mov [esi+cache_ide0_appl_data_size-cache_ide0], eax
add ebx,edx add ebx, edx
mov [esi+cache_ide0_data_pointer-cache_ide0],ebx mov [esi+cache_ide0_data_pointer-cache_ide0], ebx
cmp cl,10b cmp cl, 10b
je .cd je .cd
push ecx push ecx
mov eax,[esi+cache_ide0_system_data_size-cache_ide0] mov eax, [esi+cache_ide0_system_data_size-cache_ide0]
call calculate_for_hd call calculate_for_hd
add eax,[esi+cache_ide0_pointer-cache_ide0] add eax, [esi+cache_ide0_pointer-cache_ide0]
mov [esi+cache_ide0_system_data-cache_ide0],eax mov [esi+cache_ide0_system_data-cache_ide0], eax
mov [esi+cache_ide0_system_sad_size-cache_ide0],ecx mov [esi+cache_ide0_system_sad_size-cache_ide0], ecx
push edi push edi
mov edi,[esi+cache_ide0_pointer-cache_ide0] mov edi, [esi+cache_ide0_pointer-cache_ide0]
call clear_ide_cache call clear_ide_cache
pop edi pop edi
mov eax,[esi+cache_ide0_appl_data_size-cache_ide0] mov eax, [esi+cache_ide0_appl_data_size-cache_ide0]
call calculate_for_hd call calculate_for_hd
add eax,[esi+cache_ide0_data_pointer-cache_ide0] add eax, [esi+cache_ide0_data_pointer-cache_ide0]
mov [esi+cache_ide0_appl_data-cache_ide0],eax mov [esi+cache_ide0_appl_data-cache_ide0], eax
mov [esi+cache_ide0_appl_sad_size-cache_ide0],ecx mov [esi+cache_ide0_appl_sad_size-cache_ide0], ecx
push edi push edi
mov edi,[esi+cache_ide0_data_pointer-cache_ide0] mov edi, [esi+cache_ide0_data_pointer-cache_ide0]
call clear_ide_cache call clear_ide_cache
pop edi pop edi
@@ -143,25 +143,25 @@ get_cache_ide:
ret ret
.cd: .cd:
push ecx push ecx
mov eax,[esi+cache_ide0_system_data_size-cache_ide0] mov eax, [esi+cache_ide0_system_data_size-cache_ide0]
call calculate_for_cd call calculate_for_cd
add eax,[esi+cache_ide0_pointer-cache_ide0] add eax, [esi+cache_ide0_pointer-cache_ide0]
mov [esi+cache_ide0_system_data-cache_ide0],eax mov [esi+cache_ide0_system_data-cache_ide0], eax
mov [esi+cache_ide0_system_sad_size-cache_ide0],ecx mov [esi+cache_ide0_system_sad_size-cache_ide0], ecx
push edi push edi
mov edi,[esi+cache_ide0_pointer-cache_ide0] mov edi, [esi+cache_ide0_pointer-cache_ide0]
call clear_ide_cache call clear_ide_cache
pop edi pop edi
mov eax,[esi+cache_ide0_appl_data_size-cache_ide0] mov eax, [esi+cache_ide0_appl_data_size-cache_ide0]
call calculate_for_cd call calculate_for_cd
add eax,[esi+cache_ide0_data_pointer-cache_ide0] add eax, [esi+cache_ide0_data_pointer-cache_ide0]
mov [esi+cache_ide0_appl_data-cache_ide0],eax mov [esi+cache_ide0_appl_data-cache_ide0], eax
mov [esi+cache_ide0_appl_sad_size-cache_ide0],ecx mov [esi+cache_ide0_appl_sad_size-cache_ide0], ecx
push edi push edi
mov edi,[esi+cache_ide0_data_pointer-cache_ide0] mov edi, [esi+cache_ide0_data_pointer-cache_ide0]
call clear_ide_cache call clear_ide_cache
pop edi pop edi
@@ -170,36 +170,36 @@ get_cache_ide:
calculate_for_hd: calculate_for_hd:
push eax push eax
mov ebx,eax mov ebx, eax
shr eax,9 shr eax, 9
shl eax,3 shl eax, 3
sub ebx,eax sub ebx, eax
shr ebx,9 shr ebx, 9
mov ecx,ebx mov ecx, ebx
shl ebx,9 shl ebx, 9
pop eax pop eax
sub eax,ebx sub eax, ebx
dec ecx dec ecx
ret ret
calculate_for_cd: calculate_for_cd:
push eax push eax
mov ebx,eax mov ebx, eax
shr eax,11 shr eax, 11
shl eax,3 shl eax, 3
sub ebx,eax sub ebx, eax
shr ebx,11 shr ebx, 11
mov ecx,ebx mov ecx, ebx
shl ebx,11 shl ebx, 11
pop eax pop eax
sub eax,ebx sub eax, ebx
dec ecx dec ecx
ret ret
clear_ide_cache: clear_ide_cache:
push eax push eax
shl ecx,1 shl ecx, 1
xor eax,eax xor eax, eax
cld cld
rep stosd rep stosd
pop eax pop eax

View File

@@ -13,73 +13,93 @@ $Revision$
; <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Mario79 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Mario79
;**************************************************** ;****************************************************
mov [transfer_adress],DRIVE_DATA+0xa mov [transfer_adress], DRIVE_DATA+0xa
search_partitions_ide0: search_partitions_ide0:
test [DRIVE_DATA+1],byte 0x40 test [DRIVE_DATA+1], byte 0x40
jz search_partitions_ide1 jz search_partitions_ide1
mov [hdbase],0x1f0 mov [hdbase], 0x1f0
mov [hdid],0x0 mov [hdid], 0x0
mov [hdpos],1 mov [hdpos], 1
mov [fat32part],1 mov [known_part], 1
search_partitions_ide0_1: search_partitions_ide0_1:
call set_FAT32_variables call set_PARTITION_variables
cmp [problem_partition],0 test [problem_partition], 2
jne search_partitions_ide1 jnz search_partitions_ide1 ; not found part
test [problem_partition], 1
jnz @F ; not found known_part
;cmp [problem_partition],0
;jne search_partitions_ide1
inc byte [DRIVE_DATA+2] inc byte [DRIVE_DATA+2]
call partition_data_transfer call partition_data_transfer
add [transfer_adress],100 add [transfer_adress], 100
inc [fat32part] @@:
inc [known_part]
jmp search_partitions_ide0_1 jmp search_partitions_ide0_1
search_partitions_ide1: search_partitions_ide1:
test [DRIVE_DATA+1],byte 0x10 test [DRIVE_DATA+1], byte 0x10
jz search_partitions_ide2 jz search_partitions_ide2
mov [hdbase],0x1f0 mov [hdbase], 0x1f0
mov [hdid],0x10 mov [hdid], 0x10
mov [hdpos],2 mov [hdpos], 2
mov [fat32part],1 mov [known_part], 1
search_partitions_ide1_1: search_partitions_ide1_1:
call set_FAT32_variables call set_PARTITION_variables
cmp [problem_partition],0 test [problem_partition], 2
jne search_partitions_ide2 jnz search_partitions_ide2
test [problem_partition], 1
jnz @F
;cmp [problem_partition],0
;jne search_partitions_ide2
inc byte [DRIVE_DATA+3] inc byte [DRIVE_DATA+3]
call partition_data_transfer call partition_data_transfer
add [transfer_adress],100 add [transfer_adress], 100
inc [fat32part] @@:
inc [known_part]
jmp search_partitions_ide1_1 jmp search_partitions_ide1_1
search_partitions_ide2: search_partitions_ide2:
test [DRIVE_DATA+1],byte 0x4 test [DRIVE_DATA+1], byte 0x4
jz search_partitions_ide3 jz search_partitions_ide3
mov [hdbase],0x170 mov [hdbase], 0x170
mov [hdid],0x0 mov [hdid], 0x0
mov [hdpos],3 mov [hdpos], 3
mov [fat32part],1 mov [known_part], 1
search_partitions_ide2_1: search_partitions_ide2_1:
call set_FAT32_variables call set_PARTITION_variables
cmp [problem_partition],0 test [problem_partition], 2
jne search_partitions_ide3 jnz search_partitions_ide3
test [problem_partition], 1
jnz @F
;cmp [problem_partition],0
;jne search_partitions_ide3
inc byte [DRIVE_DATA+4] inc byte [DRIVE_DATA+4]
call partition_data_transfer call partition_data_transfer
add [transfer_adress],100 add [transfer_adress], 100
inc [fat32part] @@:
inc [known_part]
jmp search_partitions_ide2_1 jmp search_partitions_ide2_1
search_partitions_ide3: search_partitions_ide3:
test [DRIVE_DATA+1],byte 0x1 test [DRIVE_DATA+1], byte 0x1
jz end_search_partitions_ide jz end_search_partitions_ide
mov [hdbase],0x170 mov [hdbase], 0x170
mov [hdid],0x10 mov [hdid], 0x10
mov [hdpos],4 mov [hdpos], 4
mov [fat32part],1 mov [known_part], 1
search_partitions_ide3_1: search_partitions_ide3_1:
call set_FAT32_variables call set_PARTITION_variables
cmp [problem_partition],0 test [problem_partition], 2
jne end_search_partitions_ide jnz end_search_partitions_ide
test [problem_partition], 1
jnz @F
;cmp [problem_partition],0
;jne end_search_partitions_ide
inc byte [DRIVE_DATA+5] inc byte [DRIVE_DATA+5]
call partition_data_transfer call partition_data_transfer
add [transfer_adress],100 add [transfer_adress], 100
inc [fat32part] @@:
inc [known_part]
jmp search_partitions_ide3_1 jmp search_partitions_ide3_1
end_search_partitions_ide: end_search_partitions_ide:
@@ -91,16 +111,21 @@ start_search_partitions_bd:
push ecx push ecx
mov eax, [hdpos] mov eax, [hdpos]
and [BiosDiskPartitions+(eax-80h)*4], 0 and [BiosDiskPartitions+(eax-80h)*4], 0
mov [fat32part], 1 mov [known_part], 1
search_partitions_bd: search_partitions_bd:
call set_FAT32_variables call set_PARTITION_variables
cmp [problem_partition], 0 test [problem_partition], 2
jne end_search_partitions_bd jnz end_search_partitions_bd
test [problem_partition], 1
jnz @F
;cmp [problem_partition], 0
;jne end_search_partitions_bd
mov eax, [hdpos] mov eax, [hdpos]
inc [BiosDiskPartitions+(eax-80h)*4] inc [BiosDiskPartitions+(eax-80h)*4]
call partition_data_transfer call partition_data_transfer
add [transfer_adress], 100 add [transfer_adress], 100
inc [fat32part] @@:
inc [known_part]
jmp search_partitions_bd jmp search_partitions_bd
end_search_partitions_bd: end_search_partitions_bd:
pop ecx pop ecx
@@ -109,9 +134,9 @@ end_search_partitions_bd:
jmp end_search_partitions jmp end_search_partitions
partition_data_transfer: partition_data_transfer:
mov edi,[transfer_adress] mov edi, [transfer_adress]
mov esi,PARTITION_START mov esi, PARTITION_START ;start of file_system_data
mov ecx,(file_system_data_size+3)/4 mov ecx, (file_system_data_size+3)/4
rep movsd rep movsd
ret ret
uglobal uglobal
@@ -120,9 +145,9 @@ endg
partition_data_transfer_1: partition_data_transfer_1:
; cli ; cli
push edi push edi
mov edi,PARTITION_START mov edi, PARTITION_START
mov esi,[transfer_adress] mov esi, [transfer_adress]
mov ecx,(file_system_data_size+3)/4 mov ecx, (file_system_data_size+3)/4
rep movsd rep movsd
pop edi pop edi
; sti ; sti
@@ -130,24 +155,3 @@ partition_data_transfer_1:
end_search_partitions: end_search_partitions:
;PARTITION_START dd 0x3f
;PARTITION_END dd 0
;SECTORS_PER_FAT dd 0x1f3a
;NUMBER_OF_FATS dd 0x2
;SECTORS_PER_CLUSTER dd 0x8
;BYTES_PER_SECTOR dd 0x200 ; Note: if BPS <> 512 need lots of changes
;ROOT_CLUSTER dd 2 ; first rootdir cluster
;FAT_START dd 0 ; start of fat table
;ROOT_START dd 0 ; start of rootdir (only fat16)
;ROOT_SECTORS dd 0 ; count of rootdir sectors (only fat16)
;DATA_START dd 0 ; start of data area (=first cluster 2)
;LAST_CLUSTER dd 0 ; last availabe cluster
;ADR_FSINFO dd 0 ; used only by fat32
;
;fatRESERVED dd 0x0FFFFFF6
;fatBAD dd 0x0FFFFFF7
;fatEND dd 0x0FFFFFF8
;fatMASK dd 0x0FFFFFFF
;
;fat_type db 0 ; 0=none, 16=fat16, 32=fat32

View File

@@ -62,40 +62,38 @@ macro DEBUGS_N _sign,_num,[_str] {
jmp ..label jmp ..label
..str db _str,0 ..str db _str,0
..label: ..label:
; add esp,4*8+4 mov edx, ..str
esp equ esp+4*8+4
mov edx,..str
esp equ _esp
; sub esp,4*8+4
else else
mov edx,_str esp equ esp+4*8+4
mov edx, _str
esp equ _esp
end if end if
if ~_num eq if ~_num eq
if _num eqtype eax if _num eqtype eax
if _num in <eax,ebx,ecx,edx,edi,ebp,esp> if _num in <eax,ebx,ecx,edx,edi,ebp,esp>
mov esi,_num mov esi, _num
else if ~_num eq esi else if ~_num eq esi
movzx esi,_num movzx esi, _num
end if end if
else if _num eqtype 0 else if _num eqtype 0
mov esi,_num mov esi, _num
else else
local tp local tp
tp equ 0 tp equ 0
match [_arg],_num \{ match [_arg],_num \{
mov esi,dword[_arg] mov esi, dword[_arg]
tp equ 1 tp equ 1
\} \}
match =0 =dword[_arg],tp _num \{ match =0 =dword[_arg],tp _num \{
mov esi,dword[_arg] mov esi, dword[_arg]
tp equ 1 tp equ 1
\} \}
match =0 =word[_arg],tp _num \{ match =0 =word[_arg],tp _num \{
movzx esi,word[_arg] movzx esi, word[_arg]
tp equ 1 tp equ 1
\} \}
match =0 =byte[_arg],tp _num \{ match =0 =byte[_arg],tp _num \{
movzx esi,byte[_arg] movzx esi, byte[_arg]
tp equ 1 tp equ 1
\} \}
match =0,tp \{ match =0,tp \{
@@ -103,7 +101,7 @@ esp equ _esp
\} \}
end if end if
else else
mov esi,0x7FFFFFFF mov esi, 0x7FFFFFFF
end if end if
call fdo_debug_outstr call fdo_debug_outstr
popad popad
@@ -139,40 +137,40 @@ macro DEBUGD_N _sign,_num,_dec {
end if end if
if _dec eqtype eax if _dec eqtype eax
if _dec in <ebx,ecx,edx,esi,edi,ebp,esp> if _dec in <ebx,ecx,edx,esi,edi,ebp,esp>
mov eax,_dec mov eax, _dec
else if ~_dec eq eax else if ~_dec eq eax
if _sign = 1 if _sign = 1
movsx eax,_dec movsx eax, _dec
else else
movzx eax,_dec movzx eax, _dec
end if end if
end if end if
else if _dec eqtype 0 else if _dec eqtype 0
mov eax,_dec mov eax, _dec
else else
; add esp,4*8+4 ; add esp,4*8+4
esp equ esp+4*8+4 esp equ esp+4*8+4
if _num eq if _num eq
mov eax,dword _dec mov eax, dword _dec
else if _num = 1 else if _num = 1
if _sign = 1 if _sign = 1
movsx eax,byte _dec movsx eax, byte _dec
else else
movzx eax,byte _dec movzx eax, byte _dec
end if end if
else if _num = 2 else if _num = 2
if _sign = 1 if _sign = 1
movsx eax,word _dec movsx eax, word _dec
else else
movzx eax,word _dec movzx eax, word _dec
end if end if
else else
mov eax,dword _dec mov eax, dword _dec
end if end if
esp equ _esp esp equ _esp
; sub esp,4*8+4 ; sub esp,4*8+4
end if end if
mov cl,_sign mov cl, _sign
call fdo_debug_outdec call fdo_debug_outdec
popad popad
popf popf
@@ -199,38 +197,38 @@ macro DEBUGH_N _sign,_num,_hex {
if _hex eqtype eax if _hex eqtype eax
if _hex in <eax,ebx,ecx,edx,esi,edi,ebp,esp> if _hex in <eax,ebx,ecx,edx,esi,edi,ebp,esp>
if ~_hex eq eax if ~_hex eq eax
mov eax,_hex mov eax, _hex
end if end if
mov edx,8 mov edx, 8
else if _hex in <ax,bx,cx,dx,si,di,bp,sp> else if _hex in <ax,bx,cx,dx,si,di,bp,sp>
if ~_hex eq ax if ~_hex eq ax
movzx eax,_hex movzx eax, _hex
end if end if
if (_num eq) if (_num eq)
mov edx,4 mov edx, 4
end if end if
else if _hex in <al,ah,bl,bh,cl,ch,dl,dh> else if _hex in <al,ah,bl,bh,cl,ch,dl,dh>
if ~_hex eq al if ~_hex eq al
movzx eax,_hex movzx eax, _hex
end if end if
if (_num eq) if (_num eq)
mov edx,2 mov edx, 2
end if end if
end if end if
else if _hex eqtype 0 else if _hex eqtype 0
mov eax,_hex mov eax, _hex
else else
; add esp,4*8+4 ; add esp,4*8+4
esp equ esp+4*8+4 esp equ esp+4*8+4
mov eax,dword _hex mov eax, dword _hex
esp equ _esp esp equ _esp
; sub esp,4*8+4 ; sub esp,4*8+4
end if end if
if ~_num eq if ~_num eq
mov edx,_num mov edx, _num
else else
if ~_hex eqtype eax if ~_hex eqtype eax
mov edx,8 mov edx, 8
end if end if
end if end if
call fdo_debug_outhex call fdo_debug_outhex
@@ -243,9 +241,9 @@ esp equ _esp
debug_func fdo_debug_outchar debug_func fdo_debug_outchar
debug_beginf debug_beginf
pushad pushad
movzx ebx,al movzx ebx, al
mov eax,1 mov eax, 1
mov ecx,sys_msg_board mov ecx, sys_msg_board
call ecx ; sys_msg_board call ecx ; sys_msg_board
popad popad
ret ret
@@ -253,58 +251,65 @@ debug_endf
debug_func fdo_debug_outstr debug_func fdo_debug_outstr
debug_beginf debug_beginf
mov eax,1 mov eax, 1
.l1: dec esi .l1:
dec esi
js .l2 js .l2
movzx ebx,byte[edx] movzx ebx, byte[edx]
or bl,bl or bl, bl
jz .l2 jz .l2
mov ecx,sys_msg_board mov ecx, sys_msg_board
call ecx ; sys_msg_board call ecx ; sys_msg_board
inc edx inc edx
jmp .l1 jmp .l1
.l2: ret .l2:
ret
debug_endf debug_endf
debug_func fdo_debug_outdec debug_func fdo_debug_outdec
debug_beginf debug_beginf
or cl,cl or cl, cl
jz @f jz @f
or eax,eax or eax, eax
jns @f jns @f
neg eax neg eax
push eax push eax
mov al,'-' mov al, '-'
call fdo_debug_outchar call fdo_debug_outchar
pop eax pop eax
@@: push 10 @@:
push 10
pop ecx pop ecx
push -'0' push -'0'
.l1: xor edx,edx .l1:
xor edx, edx
div ecx div ecx
push edx push edx
test eax,eax test eax, eax
jnz .l1 jnz .l1
.l2: pop eax .l2:
add al,'0' pop eax
add al, '0'
jz .l3 jz .l3
call fdo_debug_outchar call fdo_debug_outchar
jmp .l2 jmp .l2
.l3: ret .l3:
ret
debug_endf debug_endf
debug_func fdo_debug_outhex debug_func fdo_debug_outhex
__fdo_hexdigits db '0123456789ABCDEF' __fdo_hexdigits db '0123456789ABCDEF'
debug_beginf debug_beginf
mov cl,dl mov cl, dl
neg cl neg cl
add cl,8 add cl, 8
shl cl,2 shl cl, 2
rol eax,cl rol eax, cl
.l1: rol eax,4 .l1:
rol eax, 4
push eax push eax
and eax,0x0000000F and eax, 0x0000000F
mov al,[__fdo_hexdigits+eax] mov al, [__fdo_hexdigits+eax]
call fdo_debug_outchar call fdo_debug_outchar
pop eax pop eax
dec edx dec edx

File diff suppressed because it is too large Load Diff

View File

@@ -27,7 +27,7 @@ flp_label rb 15 ; Label and ID of inserted floppy disk
reserve_flp: reserve_flp:
cli cli
cmp [flp_status],0 cmp [flp_status], 0
je reserve_flp_ok je reserve_flp_ok
sti sti
@@ -37,10 +37,10 @@ reserve_flp:
reserve_flp_ok: reserve_flp_ok:
push eax push eax
mov eax,[CURRENT_TASK] mov eax, [CURRENT_TASK]
shl eax,5 shl eax, 5
mov eax,[eax+CURRENT_TASK+TASKDATA.pid] mov eax, [eax+CURRENT_TASK+TASKDATA.pid]
mov [flp_status],eax mov [flp_status], eax
pop eax pop eax
sti sti
ret ret
@@ -63,154 +63,154 @@ floppy_fileread:
; 10 = access denied ; 10 = access denied
;-------------------------------------------------------------- ;--------------------------------------------------------------
mov [save_flag],0 mov [save_flag], 0
mov [path_pointer_flp],edi mov [path_pointer_flp], edi
test esi,esi ; return ramdisk root test esi, esi ; return ramdisk root
jnz fr_noroot_1 jnz fr_noroot_1
cmp ebx,224/16 cmp ebx, 224/16
jbe fr_do_1 jbe fr_do_1
mov eax,5 mov eax, 5
xor ebx,ebx xor ebx, ebx
mov [flp_status],ebx mov [flp_status], ebx
ret ret
fr_do_1: fr_do_1:
push ebx ecx edx push ebx ecx edx
call read_flp_root call read_flp_root
pop edx ecx ebx pop edx ecx ebx
cmp [FDC_Status],0 cmp [FDC_Status], 0
jne fdc_status_error_1 jne fdc_status_error_1
mov edi,edx mov edi, edx
dec ebx dec ebx
shl ebx,9 shl ebx, 9
mov esi,FLOPPY_BUFF mov esi, FLOPPY_BUFF
add esi,ebx add esi, ebx
shl ecx,9 shl ecx, 9
cld cld
rep movsb rep movsb
xor eax,eax xor eax, eax
xor ebx,ebx xor ebx, ebx
; mov eax,0 ; ok read ; mov eax,0 ; ok read
; mov ebx,0 ; mov ebx,0
mov [flp_status],eax mov [flp_status], eax
ret ret
fdc_status_error_1: fdc_status_error_1:
xor eax,eax xor eax, eax
mov [flp_status],eax mov [flp_status], eax
mov eax,10 mov eax, 10
or ebx,-1 or ebx, -1
ret ret
fr_noroot_1: fr_noroot_1:
sub esp,32 sub esp, 32
call expand_filename call expand_filename
frfloppy_1: frfloppy_1:
test ebx,ebx test ebx, ebx
jnz frfl5_1 jnz frfl5_1
mov ebx,1 mov ebx, 1
frfl5_1: frfl5_1:
test ecx,ecx test ecx, ecx
jnz frfl6_1 jnz frfl6_1
mov ecx,1 mov ecx, 1
frfl6_1: frfl6_1:
dec ebx dec ebx
push eax push eax
push eax ebx ecx edx esi edi push eax ebx ecx edx esi edi
call read_flp_fat call read_flp_fat
cmp [FDC_Status],0 cmp [FDC_Status], 0
jne fdc_status_error_3_1 jne fdc_status_error_3_1
mov [FDD_Track],0 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov [FDD_Track], 0; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDD_Head],1 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov [FDD_Head], 1; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDD_Sector],2 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov [FDD_Sector], 2; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call SeekTrack call SeekTrack
mov dh,14 mov dh, 14
l.20_1: l.20_1:
call ReadSectWithRetr call ReadSectWithRetr
cmp [FDC_Status],0 cmp [FDC_Status], 0
jne fdc_status_error_3_1 jne fdc_status_error_3_1
mov dl,16 mov dl, 16
mov edi,FDD_BUFF mov edi, FDD_BUFF
inc [FDD_Sector] inc [FDD_Sector]
l.21_1: l.21_1:
mov esi,eax ;Name of file we want mov esi, eax ;Name of file we want
mov ecx,11 mov ecx, 11
cld cld
rep cmpsb ;Found the file? rep cmpsb ;Found the file?
je fifound_1 ;Yes je fifound_1 ;Yes
add ecx,21 add ecx, 21
add edi, ecx ;Advance to next entry add edi, ecx ;Advance to next entry
dec dl dec dl
test dl,dl test dl, dl
jnz l.21_1 jnz l.21_1
dec dh dec dh
test dh,dh test dh, dh
jnz l.20_1 jnz l.20_1
fdc_status_error_3: fdc_status_error_3:
mov eax,5 ; file not found ? mov eax, 5 ; file not found ?
or ebx,-1 or ebx, -1
add esp,32+28 add esp, 32+28
mov [flp_status],0 mov [flp_status], 0
ret ret
fdc_status_error_3_2: fdc_status_error_3_2:
cmp [FDC_Status],0 cmp [FDC_Status], 0
je fdc_status_error_3 je fdc_status_error_3
fdc_status_error_3_1: fdc_status_error_3_1:
add esp,32+28 add esp, 32+28
jmp fdc_status_error_1 jmp fdc_status_error_1
fifound_1: fifound_1:
mov eax,[path_pointer_flp] mov eax, [path_pointer_flp]
cmp [eax+36],byte 0 cmp [eax+36], byte 0
je fifound_2 je fifound_2
add edi,0xf add edi, 0xf
mov eax,[edi] mov eax, [edi]
and eax,65535 and eax, 65535
mov ebx,[path_pointer_flp] mov ebx, [path_pointer_flp]
add ebx,36 add ebx, 36
call get_cluster_of_a_path_flp call get_cluster_of_a_path_flp
jc fdc_status_error_3_2 jc fdc_status_error_3_2
mov ebx,[ebx-11+28] ;file size mov ebx, [ebx-11+28] ;file size
mov [esp+20],ebx mov [esp+20], ebx
mov [esp+24],ebx mov [esp+24], ebx
jmp fifound_3 jmp fifound_3
fifound_2: fifound_2:
mov ebx,[edi-11+28] ;file size mov ebx, [edi-11+28] ;file size
mov [esp+20],ebx mov [esp+20], ebx
mov [esp+24],ebx mov [esp+24], ebx
add edi,0xf add edi, 0xf
mov eax,[edi] mov eax, [edi]
fifound_3: fifound_3:
and eax,65535 and eax, 65535
mov [n_sector],eax ;eax=cluster mov [n_sector], eax ;eax=cluster
frnew_1: frnew_1:
add eax,31 ;bootsector+2*fat+filenames add eax, 31 ;bootsector+2*fat+filenames
cmp [esp+16],dword 0 ; wanted cluster ? cmp [esp+16], dword 0; wanted cluster ?
jne frfl7_1 jne frfl7_1
call read_chs_sector call read_chs_sector
cmp [FDC_Status],0 cmp [FDC_Status], 0
jne fdc_status_error_5 jne fdc_status_error_5
mov edi,[esp+8] mov edi, [esp+8]
call give_back_application_data_1 call give_back_application_data_1
add [esp+8],dword 512 add [esp+8], dword 512
dec dword [esp+12] ; last wanted cluster ? dec dword [esp+12] ; last wanted cluster ?
cmp [esp+12],dword 0 cmp [esp+12], dword 0
je frnoread_1 je frnoread_1
jmp frfl8_1 jmp frfl8_1
frfl7_1: frfl7_1:
dec dword [esp+16] dec dword [esp+16]
frfl8_1: frfl8_1:
mov edi,[n_sector] mov edi, [n_sector]
shl edi,1 ;find next cluster from FAT shl edi, 1 ;find next cluster from FAT
add edi,FLOPPY_FAT add edi, FLOPPY_FAT
mov eax,[edi] mov eax, [edi]
and eax,4095 and eax, 4095
mov edi,eax mov edi, eax
mov [n_sector],edi mov [n_sector], edi
cmp edi,4095 ;eof - cluster cmp edi, 4095 ;eof - cluster
jz frnoread2_1 jz frnoread2_1
cmp [esp+24],dword 512 ;eof - size cmp [esp+24], dword 512;eof - size
jb frnoread_1 jb frnoread_1
sub [esp+24],dword 512 sub [esp+24], dword 512
jmp frnew_1 jmp frnew_1
read_chs_sector: read_chs_sector:
@@ -219,57 +219,57 @@ read_chs_sector:
ret ret
frnoread2_1: frnoread2_1:
cmp [esp+16],dword 0 ; eof without read ? cmp [esp+16], dword 0; eof without read ?
je frnoread_1 je frnoread_1
mov [fdc_irq_func],fdc_null mov [fdc_irq_func], fdc_null
pop edi esi edx ecx pop edi esi edx ecx
add esp,4 add esp, 4
pop ebx ; ebx <- eax : size of file pop ebx; ebx <- eax : size of file
add esp,36 add esp, 36
mov eax,6 ; end of file mov eax, 6; end of file
mov [flp_status],0 mov [flp_status], 0
ret ret
frnoread_1: frnoread_1:
pop edi esi edx ecx pop edi esi edx ecx
add esp,4 add esp, 4
pop ebx ; ebx <- eax : size of file pop ebx; ebx <- eax : size of file
add esp,36 add esp, 36
xor eax,eax xor eax, eax
mov [flp_status],eax mov [flp_status], eax
ret ret
fdc_status_error_5: fdc_status_error_5:
pop edi esi edx ecx pop edi esi edx ecx
add esp,4 add esp, 4
pop ebx ; ebx <- eax : size of file pop ebx; ebx <- eax : size of file
add esp,36 add esp, 36
jmp fdc_status_error_1 jmp fdc_status_error_1
read_flp_root: read_flp_root:
pusha pusha
call check_label call check_label
cmp [FDC_Status],0 cmp [FDC_Status], 0
jne unnecessary_root_read jne unnecessary_root_read
cmp [root_read],1 cmp [root_read], 1
je unnecessary_root_read je unnecessary_root_read
mov [FDD_Track],0 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov [FDD_Track], 0; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDD_Head],1 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov [FDD_Head], 1; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDD_Sector],2 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov [FDD_Sector], 2; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov edi,FLOPPY_BUFF mov edi, FLOPPY_BUFF
call SeekTrack call SeekTrack
read_flp_root_1: read_flp_root_1:
call ReadSectWithRetr call ReadSectWithRetr
cmp [FDC_Status],0 cmp [FDC_Status], 0
jne unnecessary_root_read jne unnecessary_root_read
push edi push edi
call give_back_application_data_1 call give_back_application_data_1
pop edi pop edi
add edi,512 add edi, 512
inc [FDD_Sector] inc [FDD_Sector]
cmp [FDD_Sector],16 cmp [FDD_Sector], 16
jne read_flp_root_1 jne read_flp_root_1
mov [root_read],1 mov [root_read], 1
unnecessary_root_read: unnecessary_root_read:
popa popa
ret ret
@@ -278,35 +278,35 @@ unnecessary_root_read:
read_flp_fat: read_flp_fat:
pusha pusha
call check_label call check_label
cmp [FDC_Status],0 cmp [FDC_Status], 0
jne unnecessary_flp_fat jne unnecessary_flp_fat
cmp [flp_fat],1 cmp [flp_fat], 1
je unnecessary_flp_fat je unnecessary_flp_fat
mov [FDD_Track],0 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov [FDD_Track], 0; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDD_Head],0 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov [FDD_Head], 0; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDD_Sector],2 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov [FDD_Sector], 2; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov edi,FLOPPY_BUFF mov edi, FLOPPY_BUFF
call SeekTrack call SeekTrack
read_flp_fat_1: read_flp_fat_1:
call ReadSectWithRetr call ReadSectWithRetr
cmp [FDC_Status],0 cmp [FDC_Status], 0
jne unnecessary_flp_fat jne unnecessary_flp_fat
push edi push edi
call give_back_application_data_1 call give_back_application_data_1
pop edi pop edi
add edi,512 add edi, 512
inc [FDD_Sector] inc [FDD_Sector]
cmp [FDD_Sector],19 cmp [FDD_Sector], 19
jne read_flp_fat_1 jne read_flp_fat_1
mov [FDD_Sector],1 mov [FDD_Sector], 1
mov [FDD_Head],1 mov [FDD_Head], 1
call ReadSectWithRetr call ReadSectWithRetr
cmp [FDC_Status],0 cmp [FDC_Status], 0
jne unnecessary_flp_fat jne unnecessary_flp_fat
call give_back_application_data_1 call give_back_application_data_1
call calculatefatchain_flp call calculatefatchain_flp
mov [root_read],0 mov [root_read], 0
mov [flp_fat],1 mov [flp_fat], 1
unnecessary_flp_fat: unnecessary_flp_fat:
popa popa
ret ret
@@ -314,36 +314,36 @@ unnecessary_flp_fat:
calculatefatchain_flp: calculatefatchain_flp:
pushad pushad
mov esi,FLOPPY_BUFF mov esi, FLOPPY_BUFF
mov edi,FLOPPY_FAT mov edi, FLOPPY_FAT
fcnew_1: fcnew_1:
mov eax,dword [esi] mov eax, dword [esi]
mov ebx,dword [esi+4] mov ebx, dword [esi+4]
mov ecx,dword [esi+8] mov ecx, dword [esi+8]
mov edx,ecx mov edx, ecx
shr edx,4 ;8 ok shr edx, 4;8 ok
shr dx,4 ;7 ok shr dx, 4;7 ok
xor ch,ch xor ch, ch
shld ecx,ebx,20 ;6 ok shld ecx, ebx, 20;6 ok
shr cx,4 ;5 ok shr cx, 4;5 ok
shld ebx,eax,12 shld ebx, eax, 12
and ebx,0x0fffffff ;4 ok and ebx, 0x0fffffff;4 ok
shr bx,4 ;3 ok shr bx, 4;3 ok
shl eax,4 shl eax, 4
and eax,0x0fffffff ;2 ok and eax, 0x0fffffff;2 ok
shr ax,4 ;1 ok shr ax, 4;1 ok
mov dword [edi],eax mov dword [edi], eax
add edi,4 add edi, 4
mov dword [edi],ebx mov dword [edi], ebx
add edi,4 add edi, 4
mov dword [edi],ecx mov dword [edi], ecx
add edi,4 add edi, 4
mov dword [edi],edx mov dword [edi], edx
add edi,4 add edi, 4
add esi,12 add esi, 12
cmp edi,FLOPPY_FAT+2856*2 ;2849 clusters cmp edi, FLOPPY_FAT+2856*2;2849 clusters
jnz fcnew_1 jnz fcnew_1
popad popad
@@ -351,32 +351,32 @@ calculatefatchain_flp:
check_label: check_label:
pushad pushad
mov [FDD_Track],0 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov [FDD_Track], 0; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDD_Head],0 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov [FDD_Head], 0; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDD_Sector],1 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov [FDD_Sector], 1; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call SetUserInterrupts call SetUserInterrupts
call FDDMotorON call FDDMotorON
call RecalibrateFDD call RecalibrateFDD
cmp [FDC_Status],0 cmp [FDC_Status], 0
jne fdc_status_error jne fdc_status_error
call SeekTrack call SeekTrack
cmp [FDC_Status],0 cmp [FDC_Status], 0
jne fdc_status_error jne fdc_status_error
call ReadSectWithRetr call ReadSectWithRetr
cmp [FDC_Status],0 cmp [FDC_Status], 0
jne fdc_status_error jne fdc_status_error
mov esi,flp_label mov esi, flp_label
mov edi,FDD_BUFF+39 mov edi, FDD_BUFF+39
mov ecx,15 mov ecx, 15
cld cld
rep cmpsb rep cmpsb
je same_label je same_label
mov [root_read],0 mov [root_read], 0
mov [flp_fat],0 mov [flp_fat], 0
same_label: same_label:
mov esi,FDD_BUFF+39 mov esi, FDD_BUFF+39
mov edi,flp_label mov edi, flp_label
mov ecx,15 mov ecx, 15
cld cld
rep movsb rep movsb
popad popad
@@ -388,64 +388,64 @@ fdc_status_error:
save_flp_root: save_flp_root:
pusha pusha
call check_label call check_label
cmp [FDC_Status],0 cmp [FDC_Status], 0
jne unnecessary_root_save jne unnecessary_root_save
cmp [root_read],0 cmp [root_read], 0
je unnecessary_root_save je unnecessary_root_save
mov [FDD_Track],0 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov [FDD_Track], 0; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDD_Head],1 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov [FDD_Head], 1; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDD_Sector],2 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov [FDD_Sector], 2; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov esi,FLOPPY_BUFF mov esi, FLOPPY_BUFF
call SeekTrack call SeekTrack
save_flp_root_1: save_flp_root_1:
push esi push esi
call take_data_from_application_1 call take_data_from_application_1
pop esi pop esi
add esi,512 add esi, 512
call WriteSectWithRetr call WriteSectWithRetr
cmp [FDC_Status],0 cmp [FDC_Status], 0
jne unnecessary_root_save jne unnecessary_root_save
inc [FDD_Sector] inc [FDD_Sector]
cmp [FDD_Sector],16 cmp [FDD_Sector], 16
jne save_flp_root_1 jne save_flp_root_1
unnecessary_root_save: unnecessary_root_save:
mov [fdc_irq_func],fdc_null mov [fdc_irq_func], fdc_null
popa popa
ret ret
save_flp_fat: save_flp_fat:
pusha pusha
call check_label call check_label
cmp [FDC_Status],0 cmp [FDC_Status], 0
jne unnecessary_flp_fat_save jne unnecessary_flp_fat_save
cmp [flp_fat],0 cmp [flp_fat], 0
je unnecessary_flp_fat_save je unnecessary_flp_fat_save
call restorefatchain_flp call restorefatchain_flp
mov [FDD_Track],0 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov [FDD_Track], 0; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDD_Head],0 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov [FDD_Head], 0; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [FDD_Sector],2 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov [FDD_Sector], 2; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov esi,FLOPPY_BUFF mov esi, FLOPPY_BUFF
call SeekTrack call SeekTrack
save_flp_fat_1: save_flp_fat_1:
push esi push esi
call take_data_from_application_1 call take_data_from_application_1
pop esi pop esi
add esi,512 add esi, 512
call WriteSectWithRetr call WriteSectWithRetr
cmp [FDC_Status],0 cmp [FDC_Status], 0
jne unnecessary_flp_fat_save jne unnecessary_flp_fat_save
inc [FDD_Sector] inc [FDD_Sector]
cmp [FDD_Sector],19 cmp [FDD_Sector], 19
jne save_flp_fat_1 jne save_flp_fat_1
mov [FDD_Sector],1 mov [FDD_Sector], 1
mov [FDD_Head],1 mov [FDD_Head], 1
call take_data_from_application_1 call take_data_from_application_1
call WriteSectWithRetr call WriteSectWithRetr
cmp [FDC_Status],0 cmp [FDC_Status], 0
jne unnecessary_flp_fat_save jne unnecessary_flp_fat_save
mov [root_read],0 mov [root_read], 0
unnecessary_flp_fat_save: unnecessary_flp_fat_save:
mov [fdc_irq_func],fdc_null mov [fdc_irq_func], fdc_null
popa popa
ret ret
@@ -453,30 +453,30 @@ unnecessary_flp_fat_save:
restorefatchain_flp: ; restore fat chain restorefatchain_flp: ; restore fat chain
pushad pushad
mov esi,FLOPPY_FAT mov esi, FLOPPY_FAT
mov edi,FLOPPY_BUFF mov edi, FLOPPY_BUFF
fcnew2_1: fcnew2_1:
mov eax,dword [esi] mov eax, dword [esi]
mov ebx,dword [esi+4] mov ebx, dword [esi+4]
shl ax,4 shl ax, 4
shl eax,4 shl eax, 4
shl bx,4 shl bx, 4
shr ebx,4 shr ebx, 4
shrd eax,ebx,8 shrd eax, ebx, 8
shr ebx,8 shr ebx, 8
mov dword [edi],eax mov dword [edi], eax
add edi,4 add edi, 4
mov word [edi],bx mov word [edi], bx
add edi,2 add edi, 2
add esi,8 add esi, 8
cmp edi,FLOPPY_BUFF+0x1200 ;4274 bytes - all used FAT cmp edi, FLOPPY_BUFF+0x1200;4274 bytes - all used FAT
jb fcnew2_1 jb fcnew2_1
mov esi,FLOPPY_BUFF ; duplicate fat chain mov esi, FLOPPY_BUFF ; duplicate fat chain
mov edi,FLOPPY_BUFF+0x1200 mov edi, FLOPPY_BUFF+0x1200
mov ecx,0x1200/4 mov ecx, 0x1200/4
cld cld
rep movsd rep movsd
@@ -490,24 +490,24 @@ save_chs_sector:
ret ret
calculate_chs: calculate_chs:
mov bl,[FDD_Track] mov bl, [FDD_Track]
mov [old_track],bl mov [old_track], bl
mov ebx,18 mov ebx, 18
xor edx,edx xor edx, edx
div ebx div ebx
inc edx inc edx
mov [FDD_Sector],dl mov [FDD_Sector], dl
xor edx,edx xor edx, edx
mov ebx,2 mov ebx, 2
div ebx div ebx
mov [FDD_Track],al mov [FDD_Track], al
mov [FDD_Head],0 mov [FDD_Head], 0
test edx,edx test edx, edx
jz no_head_2 jz no_head_2
inc [FDD_Head] inc [FDD_Head]
no_head_2: no_head_2:
mov dl,[old_track] mov dl, [old_track]
cmp dl,[FDD_Track] cmp dl, [FDD_Track]
je no_seek_track_1 je no_seek_track_1
call SeekTrack call SeekTrack
no_seek_track_1: no_seek_track_1:
@@ -526,31 +526,31 @@ get_cluster_of_a_path_flp:
;--------------------------------------------------------- ;---------------------------------------------------------
push edx push edx
mov edx,ebx mov edx, ebx
search_end_of_path_flp: search_end_of_path_flp:
cmp [save_flag],0 cmp [save_flag], 0
jne search_end_of_path_flp_1 jne search_end_of_path_flp_1
cmp byte [edx],0 cmp byte [edx], 0
je found_end_of_path_flp je found_end_of_path_flp
jmp search_end_of_path_flp_2 jmp search_end_of_path_flp_2
search_end_of_path_flp_1: search_end_of_path_flp_1:
cmp byte [edx+12],0 cmp byte [edx+12], 0
je found_end_of_path_flp je found_end_of_path_flp
search_end_of_path_flp_2: search_end_of_path_flp_2:
inc edx ; '/' inc edx; '/'
call analyze_directory_flp call analyze_directory_flp
jc directory_not_found_flp jc directory_not_found_flp
mov eax,[ebx+20-2] ; read the HIGH 16bit cluster field mov eax, [ebx+20-2] ; read the HIGH 16bit cluster field
mov ax,[ebx+26] ; read the LOW 16bit cluster field mov ax, [ebx+26] ; read the LOW 16bit cluster field
and eax,0xfff ;[fatMASK] and eax, 0xfff ;[fatMASK]
add edx,11 ; 8+3 (name+extension) add edx, 11 ; 8+3 (name+extension)
jmp search_end_of_path_flp jmp search_end_of_path_flp
found_end_of_path_flp: found_end_of_path_flp:
inc edx inc edx
mov [pointer_file_name_flp],edx mov [pointer_file_name_flp], edx
pop edx pop edx
clc ; no errors clc ; no errors
ret ret
@@ -570,7 +570,7 @@ analyze_directory_flp:
; ECX,EDX,EDI,EDI not changed ; ECX,EDX,EDI,EDI not changed
; IF CARRY=1 ; IF CARRY=1
;-------------------------------- ;--------------------------------
push ebx ;[esp+16] push ebx;[esp+16]
push ecx push ecx
push edx push edx
push esi push esi
@@ -578,43 +578,43 @@ analyze_directory_flp:
adr56_flp: adr56_flp:
mov [clust_tmp_flp],eax mov [clust_tmp_flp], eax
add eax,31 add eax, 31
pusha pusha
call read_chs_sector call read_chs_sector
popa popa
cmp [FDC_Status],0 cmp [FDC_Status], 0
jne not_found_file_analyze_flp jne not_found_file_analyze_flp
mov ecx,512/32 mov ecx, 512/32
mov ebx,FDD_BUFF mov ebx, FDD_BUFF
adr1_analyze_flp: adr1_analyze_flp:
mov esi,edx ;[esp+16] mov esi, edx;[esp+16]
mov edi,ebx mov edi, ebx
cld cld
push ecx push ecx
mov ecx,11 mov ecx, 11
rep cmpsb rep cmpsb
pop ecx pop ecx
je found_file_analyze_flp je found_file_analyze_flp
add ebx,32 add ebx, 32
loop adr1_analyze_flp loop adr1_analyze_flp
mov eax,[clust_tmp_flp] mov eax, [clust_tmp_flp]
shl eax,1 ;find next cluster from FAT shl eax, 1 ;find next cluster from FAT
add eax,FLOPPY_FAT add eax, FLOPPY_FAT
mov eax,[eax] mov eax, [eax]
and eax,4095 and eax, 4095
cmp eax,0x0ff8 cmp eax, 0x0ff8
jb adr56_flp jb adr56_flp
not_found_file_analyze_flp: not_found_file_analyze_flp:
pop edi pop edi
pop esi pop esi
pop edx pop edx
pop ecx pop ecx
add esp,4 add esp, 4
stc ;file not found stc ;file not found
ret ret
@@ -623,7 +623,7 @@ found_file_analyze_flp:
pop esi pop esi
pop edx pop edx
pop ecx pop ecx
add esp,4 add esp, 4
clc ;file found clc ;file found
ret ret

File diff suppressed because it is too large Load Diff

View File

@@ -21,12 +21,14 @@ $Revision$
iglobal iglobal
dir0: db 'HARDDISK ' dir0:
db 'HARDDISK '
db 'RAMDISK ' db 'RAMDISK '
db 'FLOPPYDISK ' db 'FLOPPYDISK '
db 0 db 0
dir1: db 'FIRST ' dir1:
db 'FIRST '
db 'SECOND ' db 'SECOND '
db 'THIRD ' db 'THIRD '
db 'FOURTH ' db 'FOURTH '
@@ -34,7 +36,8 @@ dir1: db 'FIRST '
not_select_IDE db 0 not_select_IDE db 0
hd_address_table: dd 0x1f0,0x00,0x1f0,0x10 hd_address_table:
dd 0x1f0,0x00,0x1f0,0x10
dd 0x170,0x00,0x170,0x10 dd 0x170,0x00,0x170,0x10
endg endg
@@ -89,52 +92,52 @@ file_system:
; Extract parameters ; Extract parameters
; add eax, std_application_base_address ; abs start of info block ; add eax, std_application_base_address ; abs start of info block
cmp dword [eax+0],15 ; GET_DISK_INFO cmp dword [eax+0], 15; GET_DISK_INFO
je fs_info je fs_info
cmp dword [CURRENT_TASK],1 ; no memory checks for kernel requests cmp dword [CURRENT_TASK], 1; no memory checks for kernel requests
jz no_checks_for_kernel jz no_checks_for_kernel
mov edx,eax mov edx, eax
cmp dword [eax+0],1 cmp dword [eax+0], 1
jnz .usual_check jnz .usual_check
mov ebx,[eax+12] mov ebx, [eax+12]
; add ebx,std_application_base_address ; add ebx,std_application_base_address
mov ecx,[eax+8] mov ecx, [eax+8]
call check_region call check_region
test eax,eax test eax, eax
jnz area_in_app_mem jnz area_in_app_mem
.error_output: .error_output:
mov esi,buffer_failed mov esi, buffer_failed
call sys_msg_board_str call sys_msg_board_str
; mov eax,7 ; mov eax,7
mov dword [esp+36],7 mov dword [esp+36], 7
ret ret
iglobal iglobal
buffer_failed db 'K : Buffer check failed',13,10,0 buffer_failed db 'K : Buffer check failed',13,10,0
endg endg
.usual_check: .usual_check:
cmp dword [eax+0],0 cmp dword [eax+0], 0
mov ecx,512 mov ecx, 512
jnz .small_size jnz .small_size
mov ecx,[eax+8] mov ecx, [eax+8]
shl ecx,9 shl ecx, 9
.small_size: .small_size:
mov ebx,[eax+12] mov ebx, [eax+12]
; add ebx,std_application_base_address ; add ebx,std_application_base_address
call check_region call check_region
test eax,eax test eax, eax
jz .error_output jz .error_output
area_in_app_mem: area_in_app_mem:
mov eax,edx mov eax, edx
no_checks_for_kernel: no_checks_for_kernel:
fs_read: fs_read:
mov ebx,[eax+20] ; program wants root directory ? mov ebx, [eax+20] ; program wants root directory ?
test bl,bl test bl, bl
je fs_getroot je fs_getroot
test bh,bh test bh, bh
jne fs_noroot jne fs_noroot
fs_getroot: fs_getroot:
; \begin{diamond}[18.03.2006] ; \begin{diamond}[18.03.2006]
@@ -147,54 +150,54 @@ endg
ret ret
.read_root: .read_root:
; \end{diamond}[18.03.2006] ; \end{diamond}[18.03.2006]
mov esi,dir0 mov esi, dir0
mov edi,[eax+12] mov edi, [eax+12]
; add edi,std_application_base_address ; add edi,std_application_base_address
mov ecx,11 mov ecx, 11
push ecx push ecx
; cld ; already is ; cld ; already is
rep movsb rep movsb
mov al,0x10 mov al, 0x10
stosb stosb
add edi,32-11-1 add edi, 32-11-1
pop ecx pop ecx
rep movsb rep movsb
stosb stosb
and dword [esp+36],0 ; ok read and dword [esp+36], 0; ok read
mov dword [esp+24],32*2 ; size of root mov dword [esp+24], 32*2; size of root
ret ret
fs_info: ;start of code - Mihasik fs_info: ;start of code - Mihasik
push eax push eax
cmp [eax+21],byte 'h' cmp [eax+21], byte 'h'
je fs_info_h je fs_info_h
cmp [eax+21],byte 'H' cmp [eax+21], byte 'H'
je fs_info_h je fs_info_h
cmp [eax+21],byte 'r' cmp [eax+21], byte 'r'
je fs_info_r je fs_info_r
cmp [eax+21],byte 'R' cmp [eax+21], byte 'R'
je fs_info_r je fs_info_r
mov eax,3 ;if unknown disk mov eax, 3 ;if unknown disk
xor ebx,ebx xor ebx, ebx
xor ecx,ecx xor ecx, ecx
xor edx,edx xor edx, edx
jmp fs_info1 jmp fs_info1
fs_info_r: fs_info_r:
call ramdisk_free_space ;if ramdisk call ramdisk_free_space;if ramdisk
mov ecx,edi ;free space in ecx mov ecx, edi ;free space in ecx
shr ecx,9 ;free clusters shr ecx, 9 ;free clusters
mov ebx,2847 ;total clusters mov ebx, 2847 ;total clusters
mov edx,512 ;cluster size mov edx, 512 ;cluster size
xor eax,eax ;always 0 xor eax, eax ;always 0
jmp fs_info1 jmp fs_info1
fs_info_h: ;if harddisk fs_info_h: ;if harddisk
call get_hd_info call get_hd_info
fs_info1: fs_info1:
pop edi pop edi
mov [esp+36],eax mov [esp+36], eax
mov [esp+24],ebx ; total clusters on disk mov [esp+24], ebx ; total clusters on disk
mov [esp+32],ecx ; free clusters on disk mov [esp+32], ecx ; free clusters on disk
mov [edi],edx ; cluster size in bytes mov [edi], edx ; cluster size in bytes
ret ;end of code - Mihasik ret ;end of code - Mihasik
fs_noroot: fs_noroot:
@@ -202,12 +205,12 @@ endg
push dword [eax+0] ; read/write/delete/.../makedir/rename/lba/run push dword [eax+0] ; read/write/delete/.../makedir/rename/lba/run
push dword [eax+4] ; 512 block number to read push dword [eax+4] ; 512 block number to read
push dword [eax+8] ; bytes to write/append or 512 blocks to read push dword [eax+8] ; bytes to write/append or 512 blocks to read
mov ebx,[eax+12] mov ebx, [eax+12]
; add ebx,std_application_base_address ; add ebx,std_application_base_address
push ebx ; abs start of return/save area push ebx ; abs start of return/save area
lea esi,[eax+20] ; abs start of dir + filename lea esi, [eax+20] ; abs start of dir + filename
mov edi,[eax+16] mov edi, [eax+16]
; add edi,std_application_base_address ; abs start of work area ; add edi,std_application_base_address ; abs start of work area
call expand_pathz call expand_pathz
@@ -215,30 +218,30 @@ endg
push edi ; dir start push edi ; dir start
push ebx ; name of file start push ebx ; name of file start
mov eax,[edi+1] mov eax, [edi+1]
cmp eax,'RD ' cmp eax, 'RD '
je fs_yesramdisk je fs_yesramdisk
cmp eax,'RAMD' cmp eax, 'RAMD'
jne fs_noramdisk jne fs_noramdisk
fs_yesramdisk: fs_yesramdisk:
cmp byte [edi+1+11],0 cmp byte [edi+1+11], 0
je fs_give_dir1 je fs_give_dir1
mov eax,[edi+1+12] mov eax, [edi+1+12]
cmp eax,'1 ' cmp eax, '1 '
je fs_yesramdisk_first je fs_yesramdisk_first
cmp eax,'FIRS' cmp eax, 'FIRS'
jne fs_noramdisk jne fs_noramdisk
fs_yesramdisk_first: fs_yesramdisk_first:
cmp dword [esp+20],8 ; LBA read ramdisk cmp dword [esp+20], 8; LBA read ramdisk
jne fs_no_LBA_read_ramdisk jne fs_no_LBA_read_ramdisk
mov eax,[esp+16] ; LBA block to read mov eax, [esp+16] ; LBA block to read
mov ecx,[esp+8] ; abs pointer to return area mov ecx, [esp+8] ; abs pointer to return area
call LBA_read_ramdisk call LBA_read_ramdisk
jmp file_system_return jmp file_system_return
@@ -246,18 +249,18 @@ endg
fs_no_LBA_read_ramdisk: fs_no_LBA_read_ramdisk:
cmp dword [esp+20],0 ; READ cmp dword [esp+20], 0; READ
jne fs_noramdisk_read jne fs_noramdisk_read
mov eax,[esp+4] ; fname mov eax, [esp+4] ; fname
add eax,2*12+1 add eax, 2*12+1
mov ebx,[esp+16] ; block start mov ebx, [esp+16] ; block start
inc ebx inc ebx
mov ecx,[esp+12] ; block count mov ecx, [esp+12] ; block count
mov edx,[esp+8] ; return mov edx, [esp+8] ; return
mov esi,[esp+0] mov esi, [esp+0]
sub esi,eax sub esi, eax
add esi,12+1 ; file name length add esi, 12+1 ; file name length
call fileread call fileread
jmp file_system_return jmp file_system_return
@@ -267,47 +270,47 @@ endg
fs_noramdisk: fs_noramdisk:
;******************************************************************** ;********************************************************************
mov eax,[edi+1] mov eax, [edi+1]
cmp eax,'FD ' cmp eax, 'FD '
je fs_yesflpdisk je fs_yesflpdisk
cmp eax,'FLOP' cmp eax, 'FLOP'
jne fs_noflpdisk jne fs_noflpdisk
fs_yesflpdisk: fs_yesflpdisk:
call reserve_flp call reserve_flp
cmp byte [edi+1+11],0 cmp byte [edi+1+11], 0
je fs_give_dir1 je fs_give_dir1
mov eax,[edi+1+12] mov eax, [edi+1+12]
cmp eax,'1 ' cmp eax, '1 '
je fs_yesflpdisk_first je fs_yesflpdisk_first
cmp eax,'FIRS' cmp eax, 'FIRS'
je fs_yesflpdisk_first je fs_yesflpdisk_first
cmp eax,'2 ' cmp eax, '2 '
je fs_yesflpdisk_second je fs_yesflpdisk_second
cmp eax,'SECO' cmp eax, 'SECO'
jne fs_noflpdisk jne fs_noflpdisk
jmp fs_yesflpdisk_second jmp fs_yesflpdisk_second
fs_yesflpdisk_first: fs_yesflpdisk_first:
mov [flp_number],1 mov [flp_number], 1
jmp fs_yesflpdisk_start jmp fs_yesflpdisk_start
fs_yesflpdisk_second: fs_yesflpdisk_second:
mov [flp_number],2 mov [flp_number], 2
fs_yesflpdisk_start: fs_yesflpdisk_start:
cmp dword [esp+20],0 ; READ cmp dword [esp+20], 0; READ
jne fs_noflpdisk_read jne fs_noflpdisk_read
mov eax,[esp+4] ; fname mov eax, [esp+4] ; fname
add eax,2*12+1 add eax, 2*12+1
mov ebx,[esp+16] ; block start mov ebx, [esp+16] ; block start
inc ebx inc ebx
mov ecx,[esp+12] ; block count mov ecx, [esp+12] ; block count
mov edx,[esp+8] ; return mov edx, [esp+8] ; return
mov esi,[esp+0] mov esi, [esp+0]
sub esi,eax sub esi, eax
add esi,12+1 ; file name length add esi, 12+1 ; file name length
call floppy_fileread call floppy_fileread
jmp file_system_return jmp file_system_return
@@ -317,39 +320,39 @@ endg
fs_noflpdisk: fs_noflpdisk:
;***************************************************************** ;*****************************************************************
mov eax,[edi+1] mov eax, [edi+1]
cmp eax,'HD0 ' cmp eax, 'HD0 '
je fs_yesharddisk_IDE0 je fs_yesharddisk_IDE0
cmp eax,'HD1 ' cmp eax, 'HD1 '
je fs_yesharddisk_IDE1 je fs_yesharddisk_IDE1
cmp eax,'HD2 ' cmp eax, 'HD2 '
je fs_yesharddisk_IDE2 je fs_yesharddisk_IDE2
cmp eax,'HD3 ' cmp eax, 'HD3 '
je fs_yesharddisk_IDE3 je fs_yesharddisk_IDE3
jmp old_path_harddisk jmp old_path_harddisk
fs_yesharddisk_IDE0: fs_yesharddisk_IDE0:
call reserve_hd1 call reserve_hd1
mov [hdbase],0x1f0 mov [hdbase], 0x1f0
mov [hdid],0x0 mov [hdid], 0x0
mov [hdpos],1 mov [hdpos], 1
jmp fs_yesharddisk_partition jmp fs_yesharddisk_partition
fs_yesharddisk_IDE1: fs_yesharddisk_IDE1:
call reserve_hd1 call reserve_hd1
mov [hdbase],0x1f0 mov [hdbase], 0x1f0
mov [hdid],0x10 mov [hdid], 0x10
mov [hdpos],2 mov [hdpos], 2
jmp fs_yesharddisk_partition jmp fs_yesharddisk_partition
fs_yesharddisk_IDE2: fs_yesharddisk_IDE2:
call reserve_hd1 call reserve_hd1
mov [hdbase],0x170 mov [hdbase], 0x170
mov [hdid],0x0 mov [hdid], 0x0
mov [hdpos],3 mov [hdpos], 3
jmp fs_yesharddisk_partition jmp fs_yesharddisk_partition
fs_yesharddisk_IDE3: fs_yesharddisk_IDE3:
call reserve_hd1 call reserve_hd1
mov [hdbase],0x170 mov [hdbase], 0x170
mov [hdid],0x10 mov [hdid], 0x10
mov [hdpos],4 mov [hdpos], 4
fs_yesharddisk_partition: fs_yesharddisk_partition:
call reserve_hd_channel call reserve_hd_channel
; call choice_necessity_partition ; call choice_necessity_partition
@@ -357,76 +360,76 @@ fs_yesharddisk_partition:
jmp fs_for_new_semantic jmp fs_for_new_semantic
choice_necessity_partition: choice_necessity_partition:
mov eax,[edi+1+12] mov eax, [edi+1+12]
call StringToNumber call StringToNumber
mov [fat32part],eax mov [fat32part], eax
choice_necessity_partition_1: choice_necessity_partition_1:
mov ecx,[hdpos] mov ecx, [hdpos]
xor eax,eax xor eax, eax
mov [hd_entries], eax ; entries in hd cache mov [hd_entries], eax; entries in hd cache
mov edx,DRIVE_DATA+2 mov edx, DRIVE_DATA+2
cmp ecx,0x80 cmp ecx, 0x80
jb search_partition_array jb search_partition_array
mov ecx,4 mov ecx, 4
search_partition_array: search_partition_array:
mov bl,[edx] mov bl, [edx]
movzx ebx,bl movzx ebx, bl
add eax,ebx add eax, ebx
inc edx inc edx
loop search_partition_array loop search_partition_array
mov ecx,[hdpos] mov ecx, [hdpos]
mov edx,BiosDiskPartitions mov edx, BiosDiskPartitions
sub ecx,0x80 sub ecx, 0x80
jb .s jb .s
je .f je .f
@@: @@:
mov ebx,[edx] mov ebx, [edx]
add edx,4 add edx, 4
add eax,ebx add eax, ebx
loop @b loop @b
jmp .f jmp .f
.s: .s:
sub eax,ebx sub eax, ebx
.f: .f:
add eax,[fat32part] add eax, [known_part]; add eax,[fat32part]
dec eax dec eax
xor edx,edx xor edx, edx
imul eax,100 imul eax, 100
add eax,DRIVE_DATA+0xa add eax, DRIVE_DATA+0xa
mov [transfer_adress],eax mov [transfer_adress], eax
call partition_data_transfer_1 call partition_data_transfer_1
ret ret
old_path_harddisk: old_path_harddisk:
mov eax,[edi+1] mov eax, [edi+1]
cmp eax,'HD ' cmp eax, 'HD '
je fs_yesharddisk je fs_yesharddisk
cmp eax,'HARD' cmp eax, 'HARD'
jne fs_noharddisk jne fs_noharddisk
fs_yesharddisk: fs_yesharddisk:
cmp dword [esp+20],8 ; LBA read cmp dword [esp+20], 8; LBA read
jne fs_no_LBA_read jne fs_no_LBA_read
mov eax,[esp+16] ; LBA block to read mov eax, [esp+16] ; LBA block to read
lea ebx,[edi+1+12] ; pointer to FIRST/SECOND/THIRD/FOURTH lea ebx, [edi+1+12] ; pointer to FIRST/SECOND/THIRD/FOURTH
mov ecx,[esp+8] ; abs pointer to return area mov ecx, [esp+8] ; abs pointer to return area
call LBA_read call LBA_read
jmp file_system_return jmp file_system_return
fs_no_LBA_read: fs_no_LBA_read:
cmp byte [edi+1+11],0 ; directory read cmp byte [edi+1+11], 0; directory read
je fs_give_dir1 je fs_give_dir1
call reserve_hd1 call reserve_hd1
fs_for_new_semantic: fs_for_new_semantic:
call choice_necessity_partition call choice_necessity_partition
fs_yesharddisk_all: fs_yesharddisk_all:
mov eax,1 mov eax, 1
mov ebx, [esp+24+24] mov ebx, [esp+24+24]
cmp [hdpos],0 ; is hd base set? cmp [hdpos], 0 ; is hd base set?
jz hd_err_return jz hd_err_return
cmp [fat32part],0 ; is partition set? cmp [fat32part], 0 ; is partition set?
jnz @f jnz @f
hd_err_return: hd_err_return:
call free_hd_channel call free_hd_channel
@@ -434,25 +437,25 @@ hd_err_return:
jmp file_system_return jmp file_system_return
@@: @@:
cmp dword [esp+20],0 ; READ cmp dword [esp+20], 0; READ
jne fs_noharddisk_read jne fs_noharddisk_read
mov eax,[esp+0] ; /fname mov eax, [esp+0] ; /fname
lea edi,[eax+12] lea edi, [eax+12]
mov byte [eax],0 ; path to asciiz mov byte [eax], 0 ; path to asciiz
inc eax ; filename start inc eax ; filename start
mov ebx,[esp+12] ; count to read mov ebx, [esp+12] ; count to read
mov ecx,[esp+8] ; buffer mov ecx, [esp+8] ; buffer
mov edx,[esp+4] mov edx, [esp+4]
add edx,12*2 ; dir start add edx, 12*2 ; dir start
sub edi,edx ; path length sub edi, edx ; path length
mov esi,[esp+16] ; blocks to read mov esi, [esp+16] ; blocks to read
call file_read call file_read
mov edi,[esp+0] mov edi, [esp+0]
mov byte [edi],'/' mov byte [edi], '/'
call free_hd_channel call free_hd_channel
and [hd1_status], 0 and [hd1_status], 0
@@ -467,15 +470,15 @@ hd_err_return:
; \begin{diamond}[18.03.2006] ; \begin{diamond}[18.03.2006]
mov eax, 5 ; file not found mov eax, 5 ; file not found
; <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? ; <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
mov ebx, [esp+24+24] ; do not change ebx in application mov ebx, [esp+24+24]; do not change ebx in application
; \end{diamond}[18.03.2006] ; \end{diamond}[18.03.2006]
file_system_return: file_system_return:
add esp,24 add esp, 24
mov [esp+36],eax mov [esp+36], eax
mov [esp+24],ebx mov [esp+24], ebx
ret ret
@@ -493,42 +496,42 @@ hd_err_return:
ret ret
.read: .read:
; \end{diamond}[18.03.2006] ; \end{diamond}[18.03.2006]
mov al,0x10 mov al, 0x10
mov ebx,1 mov ebx, 1
mov edi,[esp+8] mov edi, [esp+8]
mov esi,dir1 mov esi, dir1
fs_d1_new: fs_d1_new:
mov ecx,11 mov ecx, 11
; cld ; cld
rep movsb rep movsb
stosb stosb
add edi,32-11-1 add edi, 32-11-1
dec ebx dec ebx
jne fs_d1_new jne fs_d1_new
add esp,24 add esp, 24
and dword [esp+36],0 ; ok read and dword [esp+36], 0; ok read
mov dword [esp+24],32*1 ; dir/data size mov dword [esp+24], 32*1; dir/data size
ret ret
LBA_read_ramdisk: LBA_read_ramdisk:
cmp [lba_read_enabled],1 cmp [lba_read_enabled], 1
je lbarrl1 je lbarrl1
xor ebx,ebx xor ebx, ebx
mov eax,2 mov eax, 2
ret ret
lbarrl1: lbarrl1:
cmp eax,18*2*80 cmp eax, 18*2*80
jb lbarrl2 jb lbarrl2
xor ebx,ebx xor ebx, ebx
mov eax,3 mov eax, 3
ret ret
lbarrl2: lbarrl2:
@@ -537,19 +540,19 @@ LBA_read_ramdisk:
call restorefatchain call restorefatchain
mov edi,ecx mov edi, ecx
mov esi,eax mov esi, eax
shl esi,9 shl esi, 9
add esi,RAMDISK add esi, RAMDISK
mov ecx,512/4 mov ecx, 512/4
; cld ; cld
rep movsd rep movsd
popad popad
xor ebx,ebx xor ebx, ebx
xor eax,eax xor eax, eax
ret ret
LBA_read: LBA_read:
@@ -560,9 +563,9 @@ LBA_read:
; ebx = pointer to FIRST/SECOND/THIRD/FOURTH ; ebx = pointer to FIRST/SECOND/THIRD/FOURTH
; ecx = abs pointer to return area ; ecx = abs pointer to return area
cmp [lba_read_enabled],1 cmp [lba_read_enabled], 1
je lbarl1 je lbarl1
mov eax,2 mov eax, 2
ret ret
lbarl1: lbarl1:
@@ -572,35 +575,35 @@ LBA_read:
push eax push eax
push ecx push ecx
mov edi,hd_address_table mov edi, hd_address_table
mov esi,dir1 mov esi, dir1
mov eax,[ebx] mov eax, [ebx]
mov edx,'1 ' mov edx, '1 '
mov ecx,4 mov ecx, 4
blar0: blar0:
cmp eax,[esi] cmp eax, [esi]
je blar2 je blar2
cmp eax,edx cmp eax, edx
je blar2 je blar2
inc edx inc edx
add edi,8 add edi, 8
add esi,11 add esi, 11
dec ecx dec ecx
jnz blar0 jnz blar0
mov eax,1 mov eax, 1
mov ebx,1 mov ebx, 1
jmp LBA_read_ret jmp LBA_read_ret
blar2: blar2:
mov eax,[edi+0] mov eax, [edi+0]
mov ebx,[edi+4] mov ebx, [edi+4]
mov [hdbase],eax mov [hdbase], eax
mov [hdid],ebx mov [hdid], ebx
call wait_for_hd_idle call wait_for_hd_idle
cmp [hd_error],0 cmp [hd_error], 0
jne hd_lba_error jne hd_lba_error
; eax = hd port ; eax = hd port
@@ -608,56 +611,56 @@ LBA_read:
cli cli
mov edx,eax mov edx, eax
inc edx inc edx
xor eax,eax xor eax, eax
out dx,al out dx, al
inc edx inc edx
inc eax inc eax
out dx,al out dx, al
inc edx inc edx
mov eax,[esp+4] mov eax, [esp+4]
out dx,al out dx, al
shr eax,8 shr eax, 8
inc edx inc edx
out dx,al out dx, al
shr eax,8 shr eax, 8
inc edx inc edx
out dx,al out dx, al
shr eax,8 shr eax, 8
inc edx inc edx
and al,1+2+4+8 and al, 1+2+4+8
add al,bl add al, bl
add al,128+64+32 add al, 128+64+32
out dx,al out dx, al
inc edx inc edx
mov al,20h mov al, 20h
out dx,al out dx, al
sti sti
call wait_for_sector_buffer call wait_for_sector_buffer
cmp [hd_error],0 cmp [hd_error], 0
jne hd_lba_error jne hd_lba_error
cli cli
mov edi,[esp+0] mov edi, [esp+0]
mov ecx,256 mov ecx, 256
sub edx,7 sub edx, 7
cld cld
rep insw rep insw
sti sti
xor eax,eax xor eax, eax
xor ebx,ebx xor ebx, ebx
LBA_read_ret: LBA_read_ret:
mov [hd_error],0 mov [hd_error], 0
mov [hd1_status],0 mov [hd1_status], 0
add esp,2*4 add esp, 2*4
ret ret
@@ -673,59 +676,59 @@ expand_pathz:
push eax push eax
push ecx push ecx
push edi ;[esp+0] push edi;[esp+0]
pathz_start: pathz_start:
mov byte [edi],'/' mov byte [edi], '/'
inc edi inc edi
mov al,32 mov al, 32
mov ecx,11 mov ecx, 11
cld cld
rep stosb ; clear filename area rep stosb ; clear filename area
sub edi,11 sub edi, 11
mov ebx,edi ; start of dir/file name mov ebx, edi ; start of dir/file name
pathz_new_char: pathz_new_char:
mov al,[esi] mov al, [esi]
inc esi inc esi
cmp al,0 cmp al, 0
je pathz_end je pathz_end
cmp al,'/' cmp al, '/'
jne pathz_not_path jne pathz_not_path
cmp edi,ebx ; skip first '/' cmp edi, ebx ; skip first '/'
jz pathz_new_char jz pathz_new_char
lea edi,[ebx+11] ; start of next directory lea edi, [ebx+11] ; start of next directory
jmp pathz_start jmp pathz_start
pathz_not_path: pathz_not_path:
cmp al,'.' cmp al, '.'
jne pathz_not_ext jne pathz_not_ext
lea edi,[ebx+8] ; start of extension lea edi, [ebx+8] ; start of extension
jmp pathz_new_char jmp pathz_new_char
pathz_not_ext: pathz_not_ext:
cmp al,'a' cmp al, 'a'
jb pathz_not_low jb pathz_not_low
cmp al,'z' cmp al, 'z'
ja pathz_not_low ja pathz_not_low
sub al,0x20 ; char to uppercase sub al, 0x20 ; char to uppercase
pathz_not_low: pathz_not_low:
mov [edi],al mov [edi], al
inc edi inc edi
mov eax,[esp+0] ; start_of_dest_path mov eax, [esp+0] ; start_of_dest_path
add eax,512 ; keep maximum path under 512 bytes add eax, 512 ; keep maximum path under 512 bytes
cmp edi,eax cmp edi, eax
jb pathz_new_char jb pathz_new_char
pathz_end: pathz_end:
cmp ebx,edi ; if path end with '/' cmp ebx, edi ; if path end with '/'
jnz pathz_put_zero ; go back 1 level jnz pathz_put_zero ; go back 1 level
sub ebx,12 sub ebx, 12
pathz_put_zero: pathz_put_zero:
mov byte [ebx+11],0 mov byte [ebx+11], 0
dec ebx ; include '/' char into file name dec ebx ; include '/' char into file name
pop edi pop edi
pop ecx pop ecx
@@ -751,38 +754,38 @@ StringToNumber:
push cx push cx
push dx push dx
push edi push edi
mov [partition_string],eax mov [partition_string], eax
mov edi,partition_string mov edi, partition_string
xor cx,cx xor cx, cx
i1: i1:
mov al,[edi] mov al, [edi]
cmp al,32 ;13 cmp al, 32;13
je i_exit je i_exit
; cmp al,'0' ; cmp al,'0'
; jb err ; jb err
; cmp al,'9' ; cmp al,'9'
; ja err ; ja err
sub al,48 sub al, 48
shl cx,1 shl cx, 1
jc error jc error
mov bx,cx mov bx, cx
shl cx,1 shl cx, 1
jc error jc error
shl cx,1 shl cx, 1
jc error jc error
add cx,bx add cx, bx
jc error jc error
cbw cbw
add cx,ax add cx, ax
jc error jc error
i3: i3:
inc edi inc edi
jmp i1 jmp i1
i_exit: i_exit:
mov ax,cx mov ax, cx
clc clc
i4: i4:
movzx eax,ax movzx eax, ax
pop edi pop edi
pop dx pop dx
pop cx pop cx
@@ -793,5 +796,6 @@ error:
stc stc
jmp i4 jmp i4
partition_string: dd 0 partition_string:
dd 0
db 32 db 32

View File

@@ -8,8 +8,8 @@
$Revision$ $Revision$
image_of_eax EQU esp+36 image_of_eax EQU esp+32
image_of_ebx EQU esp+24 image_of_ebx EQU esp+20
; System function 70 - files with long names (LFN) ; System function 70 - files with long names (LFN)
; diamond, 2006 ; diamond, 2006
@@ -85,13 +85,13 @@ virtual_root_query:
fs_additional_handlers: fs_additional_handlers:
dd biosdisk_handler, biosdisk_enum_root dd biosdisk_handler, biosdisk_enum_root
dd dyndisk_handler, dyndisk_enum_root
; add new handlers here ; add new handlers here
dd 0 dd 0
endg endg
file_system_lfn: file_system_lfn:
; in: eax->fileinfo block ; in: ebx->fileinfo block
; operation codes: ; operation codes:
; 0 : read file ; 0 : read file
; 1 : read folder ; 1 : read folder
@@ -105,7 +105,6 @@ file_system_lfn:
; 9 : create directory ; 9 : create directory
; parse file name ; parse file name
xchg ebx, eax
lea esi, [ebx+20] lea esi, [ebx+20]
lodsb lodsb
test al, al test al, al
@@ -133,7 +132,7 @@ file_system_lfn:
jne @F jne @F
mov edx, [ebx+4] mov edx, [ebx+4]
mov ebx, [ebx+8] mov ebx, [ebx+8]
call fs_execute ; esi+ebp, ebx, edx call fs_execute; esi+ebp, ebx, edx
mov [image_of_eax], eax mov [image_of_eax], eax
ret ret
@@: @@:
@@ -169,8 +168,8 @@ file_system_lfn:
cmp dword [ebx], 1 cmp dword [ebx], 1
jnz .access_denied jnz .access_denied
xor eax, eax xor eax, eax
mov ebp, [ebx+12] mov ebp, [ebx+12] ;количество блоков для считывания
mov edx, [ebx+16] mov edx, [ebx+16] ;куда записывать рузельтат
; add edx, std_application_base_address ; add edx, std_application_base_address
push dword [ebx+4] ; first block push dword [ebx+4] ; first block
mov ebx, [ebx+8] ; flags mov ebx, [ebx+8] ; flags
@@ -385,7 +384,8 @@ file_system_lfn:
.notfounda: .notfounda:
cmp edi, esp cmp edi, esp
jnz .notfound jnz .notfound
add esp, 8 call dword [edi+4]
add esp, 16
jmp .notfound jmp .notfound
.found1: .found1:
@@ -537,7 +537,7 @@ fs_OnHdAndBd:
mov dword [image_of_eax], 5 ; not found mov dword [image_of_eax], 5 ; not found
ret ret
@@: @@:
mov [fat32part], ecx mov [known_part], ecx ; mov [fat32part], ecx
push ebx esi push ebx esi
call choice_necessity_partition_1 call choice_necessity_partition_1
pop esi ebx pop esi ebx
@@ -576,29 +576,29 @@ fs_NumHdServices = ($ - fs_HdServices)/4
;******************************************************* ;*******************************************************
fs_OnCd0: fs_OnCd0:
call reserve_cd call reserve_cd
mov [ChannelNumber],1 mov [ChannelNumber], 1
mov [DiskNumber],0 mov [DiskNumber], 0
push 6 push 6
push 1 push 1
jmp fs_OnCd jmp fs_OnCd
fs_OnCd1: fs_OnCd1:
call reserve_cd call reserve_cd
mov [ChannelNumber],1 mov [ChannelNumber], 1
mov [DiskNumber],1 mov [DiskNumber], 1
push 4 push 4
push 2 push 2
jmp fs_OnCd jmp fs_OnCd
fs_OnCd2: fs_OnCd2:
call reserve_cd call reserve_cd
mov [ChannelNumber],2 mov [ChannelNumber], 2
mov [DiskNumber],0 mov [DiskNumber], 0
push 2 push 2
push 3 push 3
jmp fs_OnCd jmp fs_OnCd
fs_OnCd3: fs_OnCd3:
call reserve_cd call reserve_cd
mov [ChannelNumber],2 mov [ChannelNumber], 2
mov [DiskNumber],1 mov [DiskNumber], 1
push 0 push 0
push 4 push 4
fs_OnCd: fs_OnCd:
@@ -609,10 +609,10 @@ fs_OnCd:
cmp ecx, 0x100 cmp ecx, 0x100
jae .nf jae .nf
push ecx ebx push ecx ebx
mov cl,al mov cl, al
mov bl,[DRIVE_DATA+1] mov bl, [DRIVE_DATA+1]
shr bl,cl shr bl, cl
test bl,2 test bl, 2
pop ebx ecx pop ebx ecx
jnz @f jnz @f
@@ -626,7 +626,7 @@ fs_OnCd:
mov edx, [ebx+16] mov edx, [ebx+16]
; add edx, std_application_base_address ; add edx, std_application_base_address
mov eax, [ebx] mov eax, [ebx]
cmp eax,fs_NumCdServices cmp eax, fs_NumCdServices
jae .not_impl jae .not_impl
add ebx, 4 add ebx, 4
call dword [fs_CdServices + eax*4] call dword [fs_CdServices + eax*4]
@@ -852,6 +852,8 @@ biosdisk_handler:
jmp file_system_lfn.maindir_noesi jmp file_system_lfn.maindir_noesi
@@: @@:
push ecx push ecx
push ecx
push biosdisk_cleanup
push fs_OnBd push fs_OnBd
mov edi, esp mov edi, esp
jmp file_system_lfn.found2 jmp file_system_lfn.found2
@@ -860,10 +862,11 @@ fs_BdNext:
cmp eax, [BiosDiskPartitions+ecx*4] cmp eax, [BiosDiskPartitions+ecx*4]
inc eax inc eax
cmc cmc
biosdisk_cleanup:
ret ret
fs_OnBd: fs_OnBd:
pop edx edx pop edx edx edx edx
; edx = disk number, ecx = partition number ; edx = disk number, ecx = partition number
; esi+ebp = name ; esi+ebp = name
call reserve_hd1 call reserve_hd1
@@ -904,7 +907,7 @@ biosdisk_enum_root:
xor eax, eax xor eax, eax
ret ret
.big: .big:
push ecx push ecx edx
push -'0' push -'0'
mov ecx, 10 mov ecx, 10
@@: @@:
@@ -919,7 +922,7 @@ biosdisk_enum_root:
add al, '0' add al, '0'
stosb stosb
jnz @b jnz @b
pop ecx pop edx ecx
pop eax pop eax
inc eax inc eax
ret ret
@@ -985,20 +988,20 @@ sys_current_directory:
; for our code: ebx->buffer,ecx=len ; for our code: ebx->buffer,ecx=len
max_cur_dir equ 0x1000 max_cur_dir equ 0x1000
mov ebx,edi mov ebx, edi
push ecx push ecx
push edi push edi
xor eax,eax xor eax, eax
mov ecx,max_cur_dir mov ecx, max_cur_dir
repne scasb ;find zerro at and string repne scasb ;find zerro at and string
jnz .error ; no zero in cur_dir: internal error, should not happen jnz .error ; no zero in cur_dir: internal error, should not happen
sub edi,ebx ;lenght for copy sub edi, ebx ;lenght for copy
inc edi inc edi
mov [esp+32+8],edi ;return in eax mov [esp+32+8], edi ;return in eax
cmp edx, edi cmp edx, edi
jbe @f jbe @f
@@ -1011,14 +1014,16 @@ max_cur_dir equ 0x1000
cmp edx, 1 cmp edx, 1
jbe .ret jbe .ret
mov al,'/' ;start string with '/' mov al, '/' ;start string with '/'
stosb stosb
mov ecx,edx mov ecx, edx
rep movsb ;copy string rep movsb ;copy string
.ret: ret .ret:
ret
.error: add esp,8 .error:
or dword [esp+32],-1 ;error not found zerro at string ->[eax+APPDATA.cur_dir] add esp, 8
or dword [esp+32], -1 ;error not found zerro at string ->[eax+APPDATA.cur_dir]
ret ret
.set: .set:
; sysfunction 30.1: [for app] eax=30,ebx=1,ecx->string ; sysfunction 30.1: [for app] eax=30,ebx=1,ecx->string
@@ -1026,7 +1031,7 @@ max_cur_dir equ 0x1000
; use generic resolver with APPDATA.cur_dir as destination ; use generic resolver with APPDATA.cur_dir as destination
push max_cur_dir ;0x1000 push max_cur_dir ;0x1000
push edi ;destination push edi ;destination
mov ebx,ecx mov ebx, ecx
call get_full_file_name call get_full_file_name
ret ret

View File

@@ -5,7 +5,7 @@
;; ;; ;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision:1322 $ $Revision$
uglobal uglobal
@@ -20,7 +20,7 @@ endg
reserve_cd: reserve_cd:
cli cli
cmp [cd_status],0 cmp [cd_status], 0
je reserve_ok2 je reserve_ok2
sti sti
@@ -30,46 +30,50 @@ reserve_cd:
reserve_ok2: reserve_ok2:
push eax push eax
mov eax,[CURRENT_TASK] mov eax, [CURRENT_TASK]
shl eax,5 shl eax, 5
mov eax,[eax+CURRENT_TASK+TASKDATA.pid] mov eax, [eax+CURRENT_TASK+TASKDATA.pid]
mov [cd_status],eax mov [cd_status], eax
pop eax pop eax
sti sti
ret ret
reserve_cd_channel: reserve_cd_channel:
cmp [ChannelNumber],1 cmp [ChannelNumber], 1
jne .IDE_Channel_2 jne .IDE_Channel_2
.IDE_Channel_1: .IDE_Channel_1:
cli cli
cmp [IDE_Channel_1],0 cmp [IDE_Channel_1], 0
je .reserve_ok_1 je .reserve_ok_1
sti sti
call change_task call change_task
jmp .IDE_Channel_1 jmp .IDE_Channel_1
.IDE_Channel_2: .IDE_Channel_2:
cli cli
cmp [IDE_Channel_2],0 cmp [IDE_Channel_2], 0
je .reserve_ok_2 je .reserve_ok_2
sti sti
call change_task call change_task
jmp .IDE_Channel_1 jmp .IDE_Channel_2
.reserve_ok_1: .reserve_ok_1:
mov [IDE_Channel_1],1 mov [IDE_Channel_1], 1
sti
ret ret
.reserve_ok_2: .reserve_ok_2:
mov [IDE_Channel_2],1 mov [IDE_Channel_2], 1
sti
ret ret
free_cd_channel: free_cd_channel:
cmp [ChannelNumber],1 cmp [ChannelNumber], 1
jne .IDE_Channel_2 jne .IDE_Channel_2
.IDE_Channel_1: .IDE_Channel_1:
mov [IDE_Channel_1],0 mov [IDE_Channel_1], 0
sti
ret ret
.IDE_Channel_2: .IDE_Channel_2:
mov [IDE_Channel_2],0 mov [IDE_Channel_2], 0
sti
ret ret
uglobal uglobal
@@ -109,15 +113,15 @@ fs_CdRead:
call cd_find_lfn call cd_find_lfn
jnc .found jnc .found
pop edi pop edi
cmp [DevErrorCode],0 cmp [DevErrorCode], 0
jne .noaccess_2 jne .noaccess_2
or ebx, -1 or ebx, -1
mov eax, ERROR_FILE_NOT_FOUND mov eax, ERROR_FILE_NOT_FOUND
ret ret
.found: .found:
mov edi,[cd_current_pointer_of_input] mov edi, [cd_current_pointer_of_input]
test byte [edi+25],10b ; do not allow read directories test byte [edi+25], 10b; do not allow read directories
jnz .noaccess jnz .noaccess
test ebx, ebx test ebx, ebx
jz .l1 jz .l1
@@ -125,7 +129,7 @@ fs_CdRead:
jz @f jz @f
xor ebx, ebx xor ebx, ebx
.reteof: .reteof:
mov eax, 6 ; end of file mov eax, 6; end of file
pop edi pop edi
ret ret
@@: @@:
@@ -141,8 +145,8 @@ fs_CdRead:
mov ecx, eax mov ecx, eax
mov byte [esp], 6 mov byte [esp], 6
@@: @@:
mov eax,[edi+2] mov eax, [edi+2]
mov [CDSectorAddress],eax mov [CDSectorAddress], eax
; now eax=cluster, ebx=position, ecx=count, edx=buffer for data ; now eax=cluster, ebx=position, ecx=count, edx=buffer for data
.new_sector: .new_sector:
test ecx, ecx test ecx, ecx
@@ -154,9 +158,9 @@ fs_CdRead:
cmp ecx, 2048 cmp ecx, 2048
jb .incomplete_sector jb .incomplete_sector
; we may read and memmove complete sector ; we may read and memmove complete sector
mov [CDDataBuf_pointer],edx mov [CDDataBuf_pointer], edx
call ReadCDWRetr ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> call ReadCDWRetr; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cmp [DevErrorCode],0 cmp [DevErrorCode], 0
jne .noaccess_3 jne .noaccess_3
add edx, 2048 add edx, 2048
sub ecx, 2048 sub ecx, 2048
@@ -165,9 +169,9 @@ fs_CdRead:
jmp .new_sector jmp .new_sector
.incomplete_sector: .incomplete_sector:
; we must read and memmove incomplete sector ; we must read and memmove incomplete sector
mov [CDDataBuf_pointer],CDDataBuf mov [CDDataBuf_pointer], CDDataBuf
call ReadCDWRetr ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> call ReadCDWRetr; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cmp [DevErrorCode],0 cmp [DevErrorCode], 0
jne .noaccess_3 jne .noaccess_3
push ecx push ecx
add ecx, ebx add ecx, ebx
@@ -177,7 +181,7 @@ fs_CdRead:
@@: @@:
sub ecx, ebx sub ecx, ebx
push edi esi ecx push edi esi ecx
mov edi,edx mov edi, edx
lea esi, [CDDataBuf + ebx] lea esi, [CDDataBuf + ebx]
cld cld
rep movsb rep movsb
@@ -260,7 +264,7 @@ fs_CdReadFolder:
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne .noaccess_1 jne .noaccess_1
call .get_names_from_buffer call .get_names_from_buffer
sub eax,2048 sub eax, 2048
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
ja .read_to_buffer ja .read_to_buffer
mov edi, [cd_counter_block] mov edi, [cd_counter_block]
@@ -277,102 +281,102 @@ fs_CdReadFolder:
ret ret
.get_names_from_buffer: .get_names_from_buffer:
mov [cd_current_pointer_of_input_2],CDDataBuf mov [cd_current_pointer_of_input_2], CDDataBuf
push eax esi edi edx push eax esi edi edx
.get_names_from_buffer_1: .get_names_from_buffer_1:
call cd_get_name call cd_get_name
jc .end_buffer jc .end_buffer
inc dword [cd_counter_block] inc dword [cd_counter_block]
mov eax,[cd_counter_block] mov eax, [cd_counter_block]
cmp [ebx],eax cmp [ebx], eax
jae .get_names_from_buffer_1 jae .get_names_from_buffer_1
test ecx, ecx test ecx, ecx
jz .get_names_from_buffer_1 jz .get_names_from_buffer_1
mov edi,[cd_counter_block] mov edi, [cd_counter_block]
mov [edx+4],edi mov [edx+4], edi
dec ecx dec ecx
mov esi,ebp mov esi, ebp
mov edi,[cd_mem_location] mov edi, [cd_mem_location]
add edi,40 add edi, 40
test dword [ebx+4], 1 ; 0=ANSI, 1=UNICODE test dword [ebx+4], 1; 0=ANSI, 1=UNICODE
jnz .unicode jnz .unicode
; jmp .unicode ; jmp .unicode
.ansi: .ansi:
cmp [cd_counter_block],2 cmp [cd_counter_block], 2
jbe .ansi_parent_directory jbe .ansi_parent_directory
cld cld
lodsw lodsw
xchg ah,al xchg ah, al
call uni2ansi_char call uni2ansi_char
cld cld
stosb stosb
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov ax,[esi] mov ax, [esi]
cmp ax,word 3B00h ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ';' cmp ax, word 3B00h; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ';'
je .cd_get_parameters_of_file_1 je .cd_get_parameters_of_file_1
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
movzx eax,byte [ebp-33] movzx eax, byte [ebp-33]
add eax,ebp add eax, ebp
sub eax,34 sub eax, 34
cmp esi,eax cmp esi, eax
je .cd_get_parameters_of_file_1 je .cd_get_parameters_of_file_1
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
movzx eax,byte [ebp-1] movzx eax, byte [ebp-1]
add eax,ebp add eax, ebp
cmp esi,eax cmp esi, eax
jb .ansi jb .ansi
.cd_get_parameters_of_file_1: .cd_get_parameters_of_file_1:
mov [edi],byte 0 mov [edi], byte 0
call cd_get_parameters_of_file call cd_get_parameters_of_file
add [cd_mem_location],304 add [cd_mem_location], 304
jmp .get_names_from_buffer_1 jmp .get_names_from_buffer_1
.ansi_parent_directory: .ansi_parent_directory:
cmp [cd_counter_block],2 cmp [cd_counter_block], 2
je @f je @f
mov [edi],byte '.' mov [edi], byte '.'
inc edi inc edi
jmp .cd_get_parameters_of_file_1 jmp .cd_get_parameters_of_file_1
@@: @@:
mov [edi],word '..' mov [edi], word '..'
add edi,2 add edi, 2
jmp .cd_get_parameters_of_file_1 jmp .cd_get_parameters_of_file_1
.unicode: .unicode:
cmp [cd_counter_block],2 cmp [cd_counter_block], 2
jbe .unicode_parent_directory jbe .unicode_parent_directory
cld cld
movsw movsw
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov ax,[esi] mov ax, [esi]
cmp ax,word 3B00h ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ';' cmp ax, word 3B00h; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ';'
je .cd_get_parameters_of_file_2 je .cd_get_parameters_of_file_2
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
movzx eax,byte [ebp-33] movzx eax, byte [ebp-33]
add eax,ebp add eax, ebp
sub eax,34 sub eax, 34
cmp esi,eax cmp esi, eax
je .cd_get_parameters_of_file_2 je .cd_get_parameters_of_file_2
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
movzx eax,byte [ebp-1] movzx eax, byte [ebp-1]
add eax,ebp add eax, ebp
cmp esi,eax cmp esi, eax
jb .unicode jb .unicode
.cd_get_parameters_of_file_2: .cd_get_parameters_of_file_2:
mov [edi],word 0 mov [edi], word 0
call cd_get_parameters_of_file call cd_get_parameters_of_file
add [cd_mem_location],560 add [cd_mem_location], 560
jmp .get_names_from_buffer_1 jmp .get_names_from_buffer_1
.unicode_parent_directory: .unicode_parent_directory:
cmp [cd_counter_block],2 cmp [cd_counter_block], 2
je @f je @f
mov [edi],word 2E00h ; '.' mov [edi], word 2E00h; '.'
add edi,2 add edi, 2
jmp .cd_get_parameters_of_file_2 jmp .cd_get_parameters_of_file_2
@@: @@:
mov [edi],dword 2E002E00h ; '..' mov [edi], dword 2E002E00h; '..'
add edi,4 add edi, 4
jmp .cd_get_parameters_of_file_2 jmp .cd_get_parameters_of_file_2
.end_buffer: .end_buffer:
@@ -380,76 +384,76 @@ fs_CdReadFolder:
ret ret
cd_get_parameters_of_file: cd_get_parameters_of_file:
mov edi,[cd_mem_location] mov edi, [cd_mem_location]
cd_get_parameters_of_file_1: cd_get_parameters_of_file_1:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
xor eax,eax xor eax, eax
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
inc eax inc eax
shl eax,1 shl eax, 1
; <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? ; <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
test [ebp-8],byte 2 test [ebp-8], byte 2
jz .file jz .file
inc eax inc eax
.file: .file:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD> FAT, <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD> FAT, <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
shl eax,3 shl eax, 3
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? (<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? (<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>)
test [ebp-8],byte 1 test [ebp-8], byte 1
jz .hidden jz .hidden
inc eax inc eax
.hidden: .hidden:
shl eax,1 shl eax, 1
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> CD ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> CD
inc eax inc eax
mov [edi],eax mov [edi], eax
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
;<EFBFBD><EFBFBD><EFBFBD> ;<EFBFBD><EFBFBD><EFBFBD>
movzx eax,byte [ebp-12] movzx eax, byte [ebp-12]
shl eax,8 shl eax, 8
;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov al,[ebp-11] mov al, [ebp-11]
shl eax,8 shl eax, 8
;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov al,[ebp-10] mov al, [ebp-10]
;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [edi+8],eax mov [edi+8], eax
;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [edi+16],eax mov [edi+16], eax
;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [edi+24],eax mov [edi+24], eax
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
;<EFBFBD><EFBFBD><EFBFBD> ;<EFBFBD><EFBFBD><EFBFBD>
movzx eax,byte [ebp-15] movzx eax, byte [ebp-15]
add eax,1900 add eax, 1900
shl eax,8 shl eax, 8
;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov al,[ebp-14] mov al, [ebp-14]
shl eax,8 shl eax, 8
;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov al,[ebp-13] mov al, [ebp-13]
;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [edi+12],eax mov [edi+12], eax
;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [edi+20],eax mov [edi+20], eax
;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [edi+28],eax mov [edi+28], eax
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
xor eax,eax xor eax, eax
test dword [ebx+4], 1 ; 0=ANSI, 1=UNICODE test dword [ebx+4], 1; 0=ANSI, 1=UNICODE
jnz .unicode_1 jnz .unicode_1
mov [edi+4],eax mov [edi+4], eax
jmp @f jmp @f
.unicode_1: .unicode_1:
inc eax inc eax
mov [edi+4],eax mov [edi+4], eax
@@: @@:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
xor eax,eax xor eax, eax
mov [edi+32+4],eax mov [edi+32+4], eax
mov eax,[ebp-23] mov eax, [ebp-23]
mov [edi+32],eax mov [edi+32], eax
ret ret
;---------------------------------------------------------------- ;----------------------------------------------------------------
@@ -494,7 +498,7 @@ fs_CdGetFileInfo:
;---------------------------------------------------------------- ;----------------------------------------------------------------
cd_find_lfn: cd_find_lfn:
mov [cd_appl_data],0 mov [cd_appl_data], 0
; in: esi+ebp -> name ; in: esi+ebp -> name
; out: CF=1 - file not found ; out: CF=1 - file not found
; else CF=0 and [cd_current_pointer_of_input] direntry ; else CF=0 and [cd_current_pointer_of_input] direntry
@@ -502,61 +506,61 @@ cd_find_lfn:
; 16 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; 16 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call WaitUnitReady call WaitUnitReady
cmp [DevErrorCode],0 cmp [DevErrorCode], 0
jne .access_denied jne .access_denied
call prevent_medium_removal call prevent_medium_removal
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [CDSectorAddress],dword 16 mov [CDSectorAddress], dword 16
mov [CDDataBuf_pointer],CDDataBuf mov [CDDataBuf_pointer], CDDataBuf
call ReadCDWRetr ;_1 call ReadCDWRetr;_1
cmp [DevErrorCode],0 cmp [DevErrorCode], 0
jne .access_denied jne .access_denied
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
call WaitUnitReady call WaitUnitReady
cmp [DevErrorCode],0 cmp [DevErrorCode], 0
jne .access_denied jne .access_denied
call Read_TOC call Read_TOC
mov ah,[CDDataBuf+4+4] mov ah, [CDDataBuf+4+4]
mov al,[CDDataBuf+4+5] mov al, [CDDataBuf+4+5]
shl eax,16 shl eax, 16
mov ah,[CDDataBuf+4+6] mov ah, [CDDataBuf+4+6]
mov al,[CDDataBuf+4+7] mov al, [CDDataBuf+4+7]
add eax,15 add eax, 15
mov [CDSectorAddress],eax mov [CDSectorAddress], eax
; mov [CDSectorAddress],dword 15 ; mov [CDSectorAddress],dword 15
mov [CDDataBuf_pointer],CDDataBuf mov [CDDataBuf_pointer], CDDataBuf
.start: .start:
inc dword [CDSectorAddress] inc dword [CDSectorAddress]
call ReadCDWRetr ;_1 call ReadCDWRetr;_1
cmp [DevErrorCode],0 cmp [DevErrorCode], 0
jne .access_denied jne .access_denied
.start_check: .start_check:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cmp [CDDataBuf+1],dword 'CD00' cmp [CDDataBuf+1], dword 'CD00'
jne .access_denied jne .access_denied
cmp [CDDataBuf+5],byte '1' cmp [CDDataBuf+5], byte '1'
jne .access_denied jne .access_denied
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
cmp [CDDataBuf],byte 0xff cmp [CDDataBuf], byte 0xff
je .access_denied je .access_denied
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>? ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
cmp [CDDataBuf],byte 0x2 cmp [CDDataBuf], byte 0x2
jne .start jne .start
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>? ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
cmp [CDDataBuf+6],byte 0x1 cmp [CDDataBuf+6], byte 0x1
jne .start jne .start
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> root <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> root <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov eax,[CDDataBuf+0x9c+2] ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> root <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov eax, [CDDataBuf+0x9c+2]; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> root <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [CDSectorAddress],eax mov [CDSectorAddress], eax
mov eax,[CDDataBuf+0x9c+10] ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> root <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov eax, [CDDataBuf+0x9c+10]; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> root <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cmp byte [esi], 0 cmp byte [esi], 0
jnz @f jnz @f
mov [cd_current_pointer_of_input],CDDataBuf+0x9c mov [cd_current_pointer_of_input], CDDataBuf+0x9c
jmp .done jmp .done
@@: @@:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@ -564,22 +568,22 @@ cd_find_lfn:
dec dword [CDSectorAddress] dec dword [CDSectorAddress]
.read_to_buffer: .read_to_buffer:
inc dword [CDSectorAddress] inc dword [CDSectorAddress]
mov [CDDataBuf_pointer],CDDataBuf mov [CDDataBuf_pointer], CDDataBuf
call ReadCDWRetr ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> call ReadCDWRetr ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cmp [DevErrorCode],0 cmp [DevErrorCode], 0
jne .access_denied jne .access_denied
push ebp push ebp
call cd_find_name_in_buffer call cd_find_name_in_buffer
pop ebp pop ebp
jnc .found jnc .found
sub eax,2048 sub eax, 2048
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
cmp eax,0 cmp eax, 0
ja .read_to_buffer ja .read_to_buffer
; <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
.access_denied: .access_denied:
pop esi eax pop esi eax
mov [cd_appl_data],1 mov [cd_appl_data], 1
stc stc
ret ret
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@ -588,10 +592,10 @@ cd_find_lfn:
cmp byte [esi-1], 0 cmp byte [esi-1], 0
jz .done jz .done
.nested: .nested:
mov eax,[cd_current_pointer_of_input] mov eax, [cd_current_pointer_of_input]
push dword [eax+2] push dword [eax+2]
pop dword [CDSectorAddress] ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> pop dword [CDSectorAddress] ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov eax,[eax+2+8] ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov eax, [eax+2+8]; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
jmp .mainloop jmp .mainloop
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
.done: .done:
@@ -602,12 +606,12 @@ cd_find_lfn:
jmp .nested jmp .nested
@@: @@:
pop esi eax pop esi eax
mov [cd_appl_data],1 mov [cd_appl_data], 1
clc clc
ret ret
cd_find_name_in_buffer: cd_find_name_in_buffer:
mov [cd_current_pointer_of_input_2],CDDataBuf mov [cd_current_pointer_of_input_2], CDDataBuf
.start: .start:
call cd_get_name call cd_get_name
jc .not_found jc .not_found
@@ -622,16 +626,16 @@ cd_find_name_in_buffer:
cd_get_name: cd_get_name:
push eax push eax
mov ebp,[cd_current_pointer_of_input_2] mov ebp, [cd_current_pointer_of_input_2]
mov [cd_current_pointer_of_input],ebp mov [cd_current_pointer_of_input], ebp
mov eax,[ebp] mov eax, [ebp]
test eax,eax ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? test eax, eax ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
jz .next_sector jz .next_sector
cmp ebp,CDDataBuf+2048 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? cmp ebp, CDDataBuf+2048 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
jae .next_sector jae .next_sector
movzx eax, byte [ebp] movzx eax, byte [ebp]
add [cd_current_pointer_of_input_2],eax ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> add [cd_current_pointer_of_input_2], eax; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
add ebp,33 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> add ebp, 33; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
pop eax pop eax
clc clc
ret ret
@@ -647,27 +651,27 @@ cd_compare_name:
; else: ZF=0, esi is not changed ; else: ZF=0, esi is not changed
; destroys eax ; destroys eax
push esi eax edi push esi eax edi
mov edi,ebp mov edi, ebp
.loop: .loop:
cld cld
lodsb lodsb
push eax push eax
call char_todown call char_todown
call ansi2uni_char call ansi2uni_char
xchg ah,al xchg ah, al
scasw scasw
pop eax pop eax
je .coincides je .coincides
call char_toupper call char_toupper
call ansi2uni_char call ansi2uni_char
xchg ah,al xchg ah, al
sub edi,2 sub edi, 2
scasw scasw
jne .name_not_coincide jne .name_not_coincide
.coincides: .coincides:
cmp [esi],byte '/' ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> cmp [esi], byte '/'; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
je .done je .done
cmp [esi],byte 0 ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> cmp [esi], byte 0; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
je .done je .done
jmp .loop jmp .loop
.name_not_coincide: .name_not_coincide:
@@ -676,22 +680,22 @@ cd_compare_name:
ret ret
.done: .done:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cmp [edi],word 3B00h ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ';' cmp [edi], word 3B00h; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ';'
je .done_1 je .done_1
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
movzx eax,byte [ebp-33] movzx eax, byte [ebp-33]
add eax,ebp add eax, ebp
sub eax,34 sub eax, 34
cmp edi,eax cmp edi, eax
je .done_1 je .done_1
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
movzx eax,byte [ebp-1] movzx eax, byte [ebp-1]
add eax,ebp add eax, ebp
cmp edi,eax cmp edi, eax
jne .name_not_coincide jne .name_not_coincide
.done_1: .done_1:
pop edi eax pop edi eax
add esp,4 add esp, 4
inc esi inc esi
clc clc
ret ret

View File

@@ -95,8 +95,8 @@ ntfs_test_bootsec:
ntfs_setup: ; CODE XREF: part_set.inc ntfs_setup: ; CODE XREF: part_set.inc
; By given bootsector, initialize some NTFS variables ; By given bootsector, initialize some NTFS variables
call ntfs_test_bootsec ; call ntfs_test_bootsec ; checking boot sector was already
jc problem_fat_dec_count ; jc problem_fat_dec_count
movzx eax, byte [ebx+13] movzx eax, byte [ebx+13]
mov [ntfs_data.sectors_per_cluster], eax mov [ntfs_data.sectors_per_cluster], eax
mov eax, [ebx+0x28] mov eax, [ebx+0x28]
@@ -942,6 +942,18 @@ ntfs_decode_mcb_entry:
pop edi ecx eax pop edi ecx eax
ret ret
unichar_toupper:
push eax
call uni2ansi_char
cmp al, '_'
jz .unk
add esp, 4
call char_toupper
jmp ansi2uni_char
.unk:
pop eax
ret
ntfs_find_lfn: ntfs_find_lfn:
; in: esi+ebp -> name ; in: esi+ebp -> name
; out: CF=1 - file not found ; out: CF=1 - file not found
@@ -1030,15 +1042,15 @@ ntfs_find_lfn:
push edi push edi
@@: @@:
lodsw lodsw
call uni2ansi_char call unichar_toupper
call char_toupper
push eax push eax
mov al, [edi] mov al, [edi]
inc edi inc edi
cmp al, '/' cmp al, '/'
jz .slash jz .slash
call char_toupper call char_toupper
cmp al, [esp] call ansi2uni_char
cmp ax, [esp]
pop eax pop eax
loopz @b loopz @b
jz .found jz .found
@@ -1641,6 +1653,7 @@ ntfs_datetime_to_bdfe:
xchg eax, [esp] xchg eax, [esp]
div [_10000000] div [_10000000]
pop edx pop edx
.sec:
; edx:eax = number of seconds since January 1, 1601 ; edx:eax = number of seconds since January 1, 1601
push eax push eax
mov eax, edx mov eax, edx
@@ -1813,3 +1826,4 @@ ntfs_HdGetFileInfo:
pop edi esi pop edi esi
xor eax, eax xor eax, eax
ret ret

View File

@@ -40,63 +40,63 @@ proc Parser_params
locals locals
buff db 4 dup(?) ; for test cd buff db 4 dup(?) ; for test cd
endl endl
mov eax,[OS_BASE+0x10000+bx_from_load] mov eax, [OS_BASE+0x10000+bx_from_load]
mov ecx,sysdir_path mov ecx, sysdir_path
mov [ecx-64],dword 'sys' mov [ecx-64], dword 'sys'
cmp al,'r' ; if ram disk cmp al, 'r'; if ram disk
jnz @f jnz @f
mov [ecx],dword 'RD/?' mov [ecx], dword 'RD/?'
mov [ecx+3],byte ah mov [ecx+3], byte ah
mov [ecx+4],byte 0 mov [ecx+4], byte 0
ret ret
@@: @@:
cmp al,'m' ; if ram disk cmp al, 'm'; if ram disk
jnz @f jnz @f
mov [ecx],dword 'CD?/' ; if cd disk {m} mov [ecx], dword 'CD?/'; if cd disk {m}
mov [ecx+4],byte '1' mov [ecx+4], byte '1'
mov [ecx+5],dword '/KOL' mov [ecx+5], dword '/KOL'
mov [ecx+9],dword 'IBRI' mov [ecx+9], dword 'IBRI'
mov [ecx+13],byte 0 mov [ecx+13], byte 0
.next_cd: .next_cd:
mov [ecx+2],byte ah mov [ecx+2], byte ah
inc ah inc ah
cmp ah,'5' cmp ah, '5'
je .not_found_cd je .not_found_cd
lea edx,[buff] lea edx, [buff]
pushad pushad
stdcall read_file,read_firstapp,edx,0,4 stdcall read_file, read_firstapp, edx, 0, 4
popad popad
cmp [edx],dword 'MENU' cmp [edx], dword 'MENU'
jne .next_cd jne .next_cd
jmp .ok jmp .ok
@@: @@:
sub al,49 sub al, 49
mov [ecx],dword 'HD?/' ; if hard disk mov [ecx], dword 'HD?/'; if hard disk
mov [ecx+2],byte al mov [ecx+2], byte al
mov [ecx+4],byte ah mov [ecx+4], byte ah
mov [ecx+5],dword '/KOL' mov [ecx+5], dword '/KOL'
mov [ecx+9],dword 'IBRI' mov [ecx+9], dword 'IBRI'
mov [ecx+13],byte 0 mov [ecx+13], byte 0
.ok: .ok:
.not_found_cd: .not_found_cd:
ret ret
endp endp
proc load_file_parse_table proc load_file_parse_table
stdcall kernel_alloc,0x1000 stdcall kernel_alloc, 0x1000
mov [tmp_file_name_table],eax mov [tmp_file_name_table], eax
mov edi,eax mov edi, eax
mov esi,sysdir_name mov esi, sysdir_name
mov ecx,128/4 mov ecx, 128/4
rep movsd rep movsd
invoke ini.enum_keys,conf_fname,conf_path_sect,get_every_key invoke ini.enum_keys, conf_fname, conf_path_sect, get_every_key
mov eax,[tmp_file_name_table] mov eax, [tmp_file_name_table]
mov [full_file_name_table],eax mov [full_file_name_table], eax
mov eax,[tmp_file_name_size] mov eax, [tmp_file_name_size]
mov [full_file_name_table.size],eax mov [full_file_name_table.size], eax
ret ret
endp endp
@@ -129,7 +129,7 @@ proc get_every_key stdcall, f_name, sec_name, key_name
@@: @@:
stosb stosb
invoke ini.get_str, [f_name],[sec_name],ecx,ebx,64,def_val_1 invoke ini.get_str, [f_name], [sec_name], ecx, ebx, 64, def_val_1
cmp byte [ebx], '/' cmp byte [ebx], '/'
jnz @f jnz @f

View File

@@ -9,6 +9,7 @@ $Revision$
;************************************************************* ;*************************************************************
;* 13.02.2010 Find all partition and check supported FS
;* 12.07.2007 Check all 4 entry of MBR and EMBR ;* 12.07.2007 Check all 4 entry of MBR and EMBR
;* 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
@@ -26,7 +27,7 @@ align 4
;****************************************************** ;******************************************************
PARTITION_START dd 0x3f PARTITION_START dd 0x3f
PARTITION_END dd 0 PARTITION_END dd 0
fs_type db 0 ; 0=none, 1=NTFS, 16=FAT16, 32=FAT32 fs_type db 0 ; 1=NTFS, 2=EXT2/3, 16=FAT16, 32=FAT32
align 4 align 4
fs_dependent_data_start: fs_dependent_data_start:
@@ -54,7 +55,8 @@ fatStartScan dd 2
fs_dependent_data_end: fs_dependent_data_end:
file_system_data_size = $ - PARTITION_START file_system_data_size = $ - PARTITION_START
if file_system_data_size > 96 if file_system_data_size > 96
ERROR: sizeof(file system data) too big! ERROR:
sizeof(file system data) too big!
end if end if
virtual at fs_dependent_data_start virtual at fs_dependent_data_start
@@ -74,7 +76,33 @@ ntfs_data:
.cur_index_size dd ? .cur_index_size dd ?
.cur_index_buf dd ? .cur_index_buf dd ?
if $ > fs_dependent_data_end if $ > fs_dependent_data_end
ERROR: increase sizeof(fs_dependent_data)! ERROR:
increase sizeof(fs_dependent_data)!
end if
end virtual
virtual at fs_dependent_data_start
; EXT2 data
ext2_data:
.log_block_size dd ?
.block_size dd ?
.count_block_in_block dd ?
.blocks_per_group dd ?
.inodes_per_group dd ?
.global_desc_table dd ?
.root_inode dd ? ; pointer to root inode in memory
.inode_size dd ?
.count_pointer_in_block dd ? ; block_size / 4
.count_pointer_in_block_square dd ? ; (block_size / 4)**2
.ext2_save_block dd ? ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 1 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
.ext2_temp_block dd ? ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
.ext2_save_inode dd ? ; inode <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
.ext2_temp_inode dd ? ; inode <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
.sb dd ? ; superblock
.groups_count dd ?
if $ > fs_dependent_data_end
ERROR:
increase sizeof(fs_dependent_data)!
end if end if
end virtual end virtual
@@ -105,6 +133,7 @@ iglobal
db 0xd6 ; Old Multiuser DOS secured: fat16 >32M db 0xd6 ; Old Multiuser DOS secured: fat16 >32M
db 0x07 ; NTFS db 0x07 ; NTFS
db 0x27 ; NTFS, hidden db 0x27 ; NTFS, hidden
db 0x83 ; Linux native file system (ext2fs)
partition_types_end: partition_types_end:
@@ -118,196 +147,205 @@ iglobal
endg endg
; Partition chain used: ; Partition chain used:
; MBR ; PARTITION2 ; PARTITION3 ; PARTITION4 ; MBR <---------------------
;========================================================== ; | |
; fat16/32 +-- fat16/32 +-- fat16/32 +-- fat16/32 +-- ; |-> PARTITION1 |
; extended --+ extended --+ extended --+ extended --+ ; |-> EXTENDED PARTITION - ;not need be second partition
; 0 0 0 0 ; |-> PARTITION3
; 0 0 0 0 ; |-> PARTITION4
; Notes:
; - extended partition need to be in second entry on table
; - it will skip over removed partitions
set_FAT32_variables: set_PARTITION_variables:
mov [problem_partition],0 set_FAT32_variables: ;deprecated
and [problem_partition], 0
call reserve_hd1 call reserve_hd1
call reserve_hd_channel call reserve_hd_channel
pushad pushad
cmp dword [hdpos],0 cmp dword [hdpos], 0
je problem_hd je problem_hd
xor ecx,ecx ; partition count xor ecx, ecx ; partition count
mov edx,-1 ; flag for partition ;or edx,-1 ; flag for partition
xor eax,eax ; read MBR xor eax, eax ; address MBR
xor ebp,ebp ; extended partition start xor ebp, ebp ; extended partition start
new_partition: new_mbr:
test ebp,ebp ; is there extended partition? test ebp, ebp ; is there extended partition? (MBR or EMBR)
jnz extended_already_set ; yes jnz extended_already_set; yes
xchg ebp,eax ; no. set it now xchg ebp, eax ; no. set it now
extended_already_set: extended_already_set:
add eax,ebp ; mbr=mbr+0, ext_part=ext_start+relat_start add eax, ebp ; mbr=mbr+0, ext_part=ext_start+relat_start
mov ebx,buffer mov ebx, buffer
call hd_read call hd_read
cmp [hd_error],0 cmp [hd_error], 0
jne problem_hd jne problem_hd
cmp word [ebx+0x1fe],0xaa55 ; is it valid boot sector? cmp word [ebx+0x1fe], 0xaa55; is it valid boot sector?
jnz end_partition_chain jnz end_partition_chain
cmp dword [ebx+0x1be+0xc],0 ; skip over empty partition push eax ; push only one time
; jz next_partition cmp dword [ebx+0x1be+0xc], 0; skip over empty partition
jnz .next_primary_partition jnz test_primary_partition_0
cmp dword [ebx+0x1be+0xc+16],0 cmp dword [ebx+0x1be+0xc+16], 0
jnz next_primary_partition jnz test_primary_partition_1
cmp dword [ebx+0x1be+0xc+16+16],0 cmp dword [ebx+0x1be+0xc+16+16], 0
jnz next_primary_partition_1 jnz test_primary_partition_2
cmp dword [ebx+0x1be+0xc+16+16+16],0 cmp dword [ebx+0x1be+0xc+16+16+16], 0
jnz next_primary_partition_2 jnz test_primary_partition_3
jmp next_partition
.next_primary_partition:
push eax
mov al,[ebx+0x1be+4] ; get primary partition type
call scan_partition_types
pop eax pop eax
jnz next_primary_partition ; no. skip over jmp end_partition_chain
test_primary_partition_0:
mov al, [ebx+0x1be+4]; get primary partition type
call scan_partition_types
jnz test_primary_partition_1; no. skip over
inc ecx inc ecx
cmp ecx,[fat32part] ; is it wanted partition? cmp ecx, [known_part]; is it wanted partition?
jnz next_primary_partition ; no jnz test_primary_partition_1; no
mov edx, eax ; start sector pop eax
add edx, [ebx+0x1be+8] ; add relative start ;mov edx, eax ; start sector
push edx add eax, [ebx+0x1be+8] ; add relative start
add edx, [ebx+0x1be+12] ; add length ;mov [PARTITON_START],edx
dec edx ; PARTITION_END is inclusive ;push edx
mov [PARTITION_END], edx ; note that this can be changed mov edx, [ebx+0x1be+12] ; length
;add edx, eax ; add length
;dec edx ; PARTITION_END is inclusive
;mov [PARTITION_END], edx ; note that this can be changed
; when file system data will be available ; when file system data will be available
mov dl, [ebx+0x1be+4] mov cl, [ebx+0x1be+4] ; fs_type
mov [fs_type], dl ; save for FS recognizer (separate FAT vs NTFS) ;mov [fs_type], dl ; save for FS recognizer (separate FAT vs NTFS)
pop edx ;pop edx
jmp hd_and_partition_ok
next_primary_partition: test_primary_partition_1:
push eax mov al, [ebx+0x1be+4+16]; get primary partition type
mov al,[ebx+0x1be+4+16] ; get primary partition type
call scan_partition_types call scan_partition_types
pop eax jnz test_primary_partition_2 ; no. skip over
jnz next_primary_partition_1 ; no. skip over
inc ecx inc ecx
cmp ecx,[fat32part] ; is it wanted partition? cmp ecx, [known_part]; is it wanted partition?
jnz next_primary_partition_1 ; no jnz test_primary_partition_2 ; no
mov edx, eax
add edx, [ebx+0x1be+8+16]
push edx
add edx, [ebx+0x1be+12+16]
dec edx
mov [PARTITION_END], edx
mov dl, [ebx+0x1be+4+16]
mov [fs_type], dl
pop edx
next_primary_partition_1:
push eax
mov al,[ebx+0x1be+4+16+16] ; get primary partition type
call scan_partition_types
pop eax pop eax
jnz next_primary_partition_2 ; no. skip over add eax, [ebx+0x1be+8+16]
mov edx, [ebx+0x1be+12+16]
mov cl, [ebx+0x1be+4+16]
jmp hd_and_partition_ok
;mov edx, eax
;add edx, [ebx+0x1be+8+16]
;push edx
;add edx, [ebx+0x1be+12+16]
;dec edx
;mov [PARTITION_END], edx
;mov al, [ebx+0x1be+4+16]
;mov [fs_type], dl
;pop edx
test_primary_partition_2:
mov al, [ebx+0x1be+4+16+16]; get primary partition type
call scan_partition_types
jnz test_primary_partition_3 ; no. skip over
inc ecx inc ecx
cmp ecx,[fat32part] ; is it wanted partition? cmp ecx, [known_part]; is it wanted partition?
jnz next_primary_partition_2 ; no jnz test_primary_partition_3 ; no
mov edx, eax
add edx, [ebx+0x1be+8+16+16]
push edx
add edx, [ebx+0x1be+12+16+16]
dec edx
mov [PARTITION_END], edx
mov dl, [ebx+0x1be+4+16+16]
mov [fs_type], dl
pop edx
next_primary_partition_2:
push eax
mov al,[ebx+0x1be+4+16+16+16] ; get primary partition type
call scan_partition_types
pop eax pop eax
jnz next_partition ; no. skip over add eax, [ebx+0x1be+8+16+16]
mov edx, [ebx+0x1be+12+16+16]
mov cl, [ebx+0x1be+4+16+16]
jmp hd_and_partition_ok
;mov edx, eax
;add edx, [ebx+0x1be+8+16+16]
;push edx
;add edx, [ebx+0x1be+12+16+16]
;dec edx
;mov [PARTITION_END], edx
;mov al, [ebx+0x1be+4+16+16]
;mov [fs_type], dl
;pop edx
test_primary_partition_3:
mov al, [ebx+0x1be+4+16+16+16]; get primary partition type
call scan_partition_types
jnz test_ext_partition_0 ; no. skip over
inc ecx inc ecx
cmp ecx,[fat32part] ; is it wanted partition? cmp ecx, [known_part]; is it wanted partition?
jnz next_partition ; no jnz test_ext_partition_0; no
mov edx, eax
add edx, [ebx+0x1be+8+16+16+16]
push edx
add edx, [ebx+0x1be+12+16+16+16]
dec edx
mov [PARTITION_END], edx
mov dl, [ebx+0x1be+4+16+16+16]
mov [fs_type], dl
pop edx
next_partition:
push eax
mov al,[ebx+0x1be+4] ; get extended partition type
call scan_extended_types
pop eax pop eax
jnz next_partition_1 add eax, [ebx+0x1be+8+16+16+16]
mov edx, [ebx+0x1be+12+16+16+16]
mov cl, [ebx+0x1be+4+16+16+16]
jmp hd_and_partition_ok
mov eax,[ebx+0x1be+8] ; add relative start ;mov edx, eax
test eax,eax ; is there extended partition? ;add edx, [ebx+0x1be+8+16+16+16]
jnz new_partition ; yes. read it ;push edx
;add edx, [ebx+0x1be+12+16+16+16]
;dec edx
;mov [PARTITION_END], edx
;mov al, [ebx+0x1be+4+16+16+16]
;mov [fs_type], dl
;pop edx
next_partition_1: test_ext_partition_0:
push eax pop eax ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD>
mov al,[ebx+0x1be+4+16] ; get extended partition type mov al, [ebx+0x1be+4]; get extended partition type
call scan_extended_types call scan_extended_types
pop eax jnz test_ext_partition_1
jnz next_partition_2
mov eax,[ebx+0x1be+8+16] ; add relative start mov eax, [ebx+0x1be+8]; add relative start
test eax,eax ; is there extended partition? test eax, eax ; is there extended partition?
jnz new_partition ; yes. read it jnz new_mbr ; yes. read it
next_partition_2: test_ext_partition_1:
push eax mov al, [ebx+0x1be+4+16]; get extended partition type
mov al,[ebx+0x1be+4+16+16] ; get extended partition type
call scan_extended_types call scan_extended_types
pop eax jnz test_ext_partition_2
jnz next_partition_3
mov eax,[ebx+0x1be+8+16+16] ; add relative start mov eax, [ebx+0x1be+8+16]; add relative start
test eax,eax ; is there extended partition? test eax, eax ; is there extended partition?
jnz new_partition ; yes. read it jnz new_mbr ; yes. read it
next_partition_3: test_ext_partition_2:
push eax mov al, [ebx+0x1be+4+16+16]; get extended partition type
mov al,[ebx+0x1be+4+16+16+16] ; get extended partition type
call scan_extended_types call scan_extended_types
pop eax jnz test_ext_partition_3
jnz end_partition_chain ; no. end chain
mov eax,[ebx+0x1be+8+16+16+16] ; get start of extended partition mov eax, [ebx+0x1be+8+16+16]; add relative start
test eax,eax ; is there extended partition? test eax, eax ; is there extended partition?
jnz new_partition ; yes. read it jnz new_mbr ; yes. read it
test_ext_partition_3:
mov al, [ebx+0x1be+4+16+16+16]; get extended partition type
call scan_extended_types
jnz end_partition_chain; no. end chain
mov eax, [ebx+0x1be+8+16+16+16]; get start of extended partition
test eax, eax ; is there extended partition?
jnz new_mbr ; yes. read it
end_partition_chain: end_partition_chain:
mov [partition_count],ecx ;mov [partition_count],ecx
;cmp edx,-1 ; found wanted partition?
;jnz hd_and_partition_ok ; yes. install it
;jmp problem_partition_or_fat
problem_hd:
or [problem_partition], 2
jmp return_from_part_set
cmp edx,-1 ; found wanted partition?
jnz hd_and_partition_ok ; yes. install it
jmp problem_partition_or_fat
scan_partition_types: scan_partition_types:
push ecx push ecx
mov edi,partition_types mov edi, partition_types
mov ecx,partition_types_end-partition_types mov ecx, partition_types_end-partition_types
cld cld
repne scasb ; is partition type ok? repne scasb ; is partition type ok?
pop ecx pop ecx
@@ -315,35 +353,42 @@ scan_partition_types:
scan_extended_types: scan_extended_types:
push ecx push ecx
mov edi,extended_types mov edi, extended_types
mov ecx,extended_types_end-extended_types mov ecx, extended_types_end-extended_types
cld cld
repne scasb ; is it extended partition? repne scasb ; is it extended partition?
pop ecx pop ecx
ret ret
problem_fat_dec_count: ; bootsector is missing or another problem problem_fat_dec_count: ; bootsector is missing or another problem
dec [partition_count] ; remove it from partition_count ; dec [partition_count] ; remove it from partition_count
problem_partition_or_fat: problem_partition_or_fat:
problem_hd: or [problem_partition], 1
popad
mov [fs_type],0 return_from_part_set:
popad
;mov [fs_type],0
call free_hd_channel call free_hd_channel
mov [hd1_status],0 ; free mov [hd1_status], 0 ; free
mov [problem_partition],1
ret ret
hd_and_partition_ok: hd_and_partition_ok:
mov eax,edx
mov [PARTITION_START],eax ;eax = PARTITION_START edx=PARTITION_LENGTH cl=fs_type
mov edx, [PARTITION_END] mov [fs_type], cl
sub edx, eax ;mov eax,edx
inc edx ; edx = length of partition mov [PARTITION_START], eax
add edx, eax
dec edx
mov [PARTITION_END], edx
; mov edx, [PARTITION_END]
; sub edx, eax
; inc edx ; edx = length of partition <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>??
; mov [hd_setup],1 ; mov [hd_setup],1
mov ebx,buffer mov ebx, buffer
call hd_read ; read boot sector of partition call hd_read ; read boot sector of partition
cmp [hd_error], 0 cmp [hd_error], 0
jz boot_read_ok jz boot_read_ok
@@ -366,116 +411,124 @@ hd_and_partition_ok:
add eax, [PARTITION_START] add eax, [PARTITION_START]
call hd_read call hd_read
cmp [hd_error], 0 cmp [hd_error], 0
jnz problem_fat_dec_count ; <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>... jnz problem_fat_dec_count ; no chance...
boot_read_ok: boot_read_ok:
; mov [hd_setup], 0
; if we are running on NTFS, check bootsector ; if we are running on NTFS, check bootsector
; cmp [fs_type], 7
; jz ntfs_setup call ntfs_test_bootsec ; test ntfs
call ntfs_test_bootsec
jnc ntfs_setup jnc ntfs_setup
cmp word [ebx+0x1fe],0xaa55 ; is it valid boot sector? call ext2_test_superblock ; test ext2fs
jnc ext2_setup
mov eax, [PARTITION_START] ;ext2 test changes [buffer]
call hd_read
cmp [hd_error], 0
jnz problem_fat_dec_count jnz problem_fat_dec_count
movzx eax,word [ebx+0xe] ; sectors reserved cmp word [ebx+0x1fe], 0xaa55; is it valid boot sector?
add eax,[PARTITION_START] jnz problem_fat_dec_count
mov [FAT_START],eax ; fat_start = partition_start + reserved
movzx eax,byte [ebx+0xd] ; sectors per cluster movzx eax, word [ebx+0xe]; sectors reserved
test eax,eax add eax, [PARTITION_START]
mov [FAT_START], eax; fat_start = partition_start + reserved
movzx eax, byte [ebx+0xd]; sectors per cluster
test eax, eax
jz problem_fat_dec_count jz problem_fat_dec_count
mov [SECTORS_PER_CLUSTER],eax mov [SECTORS_PER_CLUSTER], eax
movzx ecx,word [ebx+0xb] ; bytes per sector movzx ecx, word [ebx+0xb]; bytes per sector
cmp ecx,0x200 cmp ecx, 0x200
jnz problem_fat_dec_count jnz problem_fat_dec_count
mov [BYTES_PER_SECTOR],ecx mov [BYTES_PER_SECTOR], ecx
movzx eax,word [ebx+0x11] ; count of rootdir entries (=0 fat32) movzx eax, word [ebx+0x11]; count of rootdir entries (=0 fat32)
mov edx,32 mov edx, 32
mul edx mul edx
dec ecx dec ecx
add eax,ecx ; round up if not equal count add eax, ecx ; round up if not equal count
inc ecx ; bytes per sector inc ecx ; bytes per sector
div ecx div ecx
mov [ROOT_SECTORS],eax ; count of rootdir sectors mov [ROOT_SECTORS], eax; count of rootdir sectors
movzx eax,word [ebx+0x16] ; sectors per fat <65536 movzx eax, word [ebx+0x16]; sectors per fat <65536
test eax,eax test eax, eax
jnz fat16_fatsize jnz fat16_fatsize
mov eax,[ebx+0x24] ; sectors per fat mov eax, [ebx+0x24] ; sectors per fat
fat16_fatsize: fat16_fatsize:
mov [SECTORS_PER_FAT],eax mov [SECTORS_PER_FAT], eax
movzx eax,byte [ebx+0x10] ; number of fats movzx eax, byte [ebx+0x10]; number of fats
test eax,eax ; if 0 it's not fat partition test eax, eax ; if 0 it's not fat partition
jz problem_fat_dec_count jz problem_fat_dec_count
mov [NUMBER_OF_FATS],eax mov [NUMBER_OF_FATS], eax
imul eax,[SECTORS_PER_FAT] imul eax, [SECTORS_PER_FAT]
add eax,[FAT_START] add eax, [FAT_START]
mov [ROOT_START],eax ; rootdir = fat_start + fat_size * fat_count mov [ROOT_START], eax; rootdir = fat_start + fat_size * fat_count
add eax,[ROOT_SECTORS] ; rootdir sectors should be 0 on fat32 add eax, [ROOT_SECTORS]; rootdir sectors should be 0 on fat32
mov [DATA_START],eax ; data area = rootdir + rootdir_size mov [DATA_START], eax; data area = rootdir + rootdir_size
movzx eax,word [ebx+0x13] ; total sector count <65536 movzx eax, word [ebx+0x13]; total sector count <65536
test eax,eax test eax, eax
jnz fat16_total jnz fat16_total
mov eax,[ebx+0x20] ; total sector count mov eax, [ebx+0x20] ; total sector count
fat16_total: fat16_total:
add eax,[PARTITION_START] add eax, [PARTITION_START]
dec eax dec eax
mov [PARTITION_END],eax mov [PARTITION_END], eax
inc eax inc eax
sub eax,[DATA_START] ; eax = count of data sectors sub eax, [DATA_START]; eax = count of data sectors
xor edx,edx xor edx, edx
div dword [SECTORS_PER_CLUSTER] div dword [SECTORS_PER_CLUSTER]
inc eax inc eax
mov [LAST_CLUSTER],eax mov [LAST_CLUSTER], eax
dec eax ; cluster count dec eax ; cluster count
mov [fatStartScan],2 mov [fatStartScan], 2
; limits by Microsoft Hardware White Paper v1.03 ; limits by Microsoft Hardware White Paper v1.03
cmp eax,4085 ; 0xff5 cmp eax, 4085 ; 0xff5
jb problem_fat_dec_count ; fat12 not supported jb problem_fat_dec_count; fat12 not supported
cmp eax,65525 ; 0xfff5 cmp eax, 65525 ; 0xfff5
jb fat16_partition jb fat16_partition
fat32_partition: fat32_partition:
mov eax,[ebx+0x2c] ; rootdir cluster mov eax, [ebx+0x2c] ; rootdir cluster
mov [ROOT_CLUSTER],eax mov [ROOT_CLUSTER], eax
movzx eax,word [ebx+0x30] ; fs info sector movzx eax, word [ebx+0x30]; fs info sector
add eax,[PARTITION_START] add eax, [PARTITION_START]
mov [ADR_FSINFO],eax mov [ADR_FSINFO], eax
call hd_read call hd_read
mov eax,[ebx+0x1ec] mov eax, [ebx+0x1ec]
cmp eax,-1 cmp eax, -1
jz @f jz @f
mov [fatStartScan],eax mov [fatStartScan], eax
@@: @@:
popad popad
mov [fatRESERVED],0x0FFFFFF6 mov [fatRESERVED], 0x0FFFFFF6
mov [fatBAD],0x0FFFFFF7 mov [fatBAD], 0x0FFFFFF7
mov [fatEND],0x0FFFFFF8 mov [fatEND], 0x0FFFFFF8
mov [fatMASK],0x0FFFFFFF mov [fatMASK], 0x0FFFFFFF
mov [fs_type],32 ; Fat32 mov [fs_type], 32 ; Fat32
call free_hd_channel call free_hd_channel
mov [hd1_status],0 ; free mov [hd1_status], 0 ; free
ret ret
fat16_partition: fat16_partition:
xor eax,eax xor eax, eax
mov [ROOT_CLUSTER],eax mov [ROOT_CLUSTER], eax
popad popad
mov [fatRESERVED],0x0000FFF6 mov [fatRESERVED], 0x0000FFF6
mov [fatBAD],0x0000FFF7 mov [fatBAD], 0x0000FFF7
mov [fatEND],0x0000FFF8 mov [fatEND], 0x0000FFF8
mov [fatMASK],0x0000FFFF mov [fatMASK], 0x0000FFFF
mov [fs_type],16 ; Fat16 mov [fs_type], 16 ; Fat16
call free_hd_channel call free_hd_channel
mov [hd1_status],0 ; free mov [hd1_status], 0 ; free
ret ret

View File

@@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2008. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2010. All rights reserved. ;;
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;; ;; ;;
@@ -8,14 +8,12 @@
$Revision$ $Revision$
button._.MAX_BUTTONS = 4095
;============================================================================== ;==============================================================================
;///// public functions /////////////////////////////////////////////////////// ;///// public functions ///////////////////////////////////////////////////////
;============================================================================== ;==============================================================================
button.MAX_BUTTONS = 4095
struc SYS_BUTTON struc SYS_BUTTON
{ {
.pslot dw ? .pslot dw ?
@@ -25,19 +23,13 @@ struc SYS_BUTTON
.top dw ? .top dw ?
.height dw ? .height dw ?
.id_hi dw ? .id_hi dw ?
dw ?
.sizeof: .sizeof:
} }
virtual at 0 virtual at 0
SYS_BUTTON SYS_BUTTON SYS_BUTTON SYS_BUTTON
end virtual end virtual
iglobal
mx dw 0x0 ; keeps the x mouse's position when it was clicked
my dw 0x0 ; keeps the y mouse's position when it was clicked
bPressedMouseXY_B db 0x0
btn_down_determ db 0x0
endg
align 4 align 4
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
syscall_button: ;///// system function 8 ////////////////////////////////////// syscall_button: ;///// system function 8 //////////////////////////////////////
@@ -66,7 +58,7 @@ syscall_button: ;///// system function 8 //////////////////////////////////////
; do we have free button slots available? ; do we have free button slots available?
mov edi, [BTN_ADDR] mov edi, [BTN_ADDR]
mov eax, [edi] mov eax, [edi]
cmp eax, button._.MAX_BUTTONS cmp eax, button.MAX_BUTTONS
jge .exit jge .exit
; does it have positive size? (otherwise it doesn't have sense) ; does it have positive size? (otherwise it doesn't have sense)
@@ -139,7 +131,8 @@ syscall_button: ;///// system function 8 //////////////////////////////////////
call button._.incecx2 call button._.incecx2
; set button height counter ; set button height counter
@@: mov edx, edi @@:
mov edx, edi
.next_line: .next_line:
call button._.button_dececx call button._.button_dececx
@@ -227,6 +220,7 @@ syscall_button.remove_button:
add esi, edi add esi, edi
xor ecx, ecx xor ecx, ecx
add ecx, -SYS_BUTTON.sizeof add ecx, -SYS_BUTTON.sizeof
add esi, SYS_BUTTON.sizeof
.next_button: .next_button:
dec ebx dec ebx
@@ -262,201 +256,123 @@ syscall_button.remove_button:
align 4 align 4
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
check_buttons: ;/////////////////////////////////////////////////////////////// sys_button_activate_handler: ;/////////////////////////////////////////////////
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
;? <description> ;? <description>
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
cmp byte[BTN_DOWN], 0 ; mouse buttons pressed ;> eax = pack[8(process slot), 24(button id)]
jnz @f ;> ebx = pack[16(button x coord), 16(button y coord)]
mov [bPressedMouseXY_B], 0 ;> cl = mouse button mask this system button was pressed with
ret ;------------------------------------------------------------------------------
call button._.find_button
or eax, eax
jz .exit
@@: pushad mov ebx, dword[eax + SYS_BUTTON.id_hi - 2]
xor esi, esi
mov edi, [BTN_ADDR]
mov edx, [edi]
test edx, edx
jne @f
popad
ret
;here i catch the coordinates when the mouse's button is clicked
@@: push ax
cmp [bPressedMouseXY_B], 0 ; FALSE
jnz @f
mov [bPressedMouseXY_B], 1 ; TRUE - it was already clicked
mov ax, [MOUSE_X]
mov [mx], ax
mov ax, [MOUSE_Y]
mov [my], ax
@@: pop ax
;and it is only refreshed after the mouse's button release
push esi
inc edx
push edx
.buttonnewcheck:
pop edx
pop esi
inc esi
cmp edx, esi
jge .bch
popad
ret
.bch:
push esi
push edx
mov eax, esi
shl eax, 4
add eax, edi
; check that button is at top of windowing stack
movzx ebx, [eax + SYS_BUTTON.pslot]
movzx ecx, word[WIN_STACK + ebx * 2]
cmp ecx, [TASK_COUNT]
jne .buttonnewcheck
; check that button start is inside window x/y end
shl ebx, 5
test [ebx + window_data + WDATA.fl_wstate], WSTATE_MINIMIZED
jnz .buttonnewcheck
movzx edx, [eax + SYS_BUTTON.left]
cmp edx, [window_data + ebx + WDATA.box.width] ;ecx
jge .buttonnewcheck
movzx edx, [eax + SYS_BUTTON.top]
cmp edx, [window_data + ebx + WDATA.box.height] ;ecx
jge .buttonnewcheck
; check coordinates
; mouse x >= button x ?
add ebx, window_data
mov ecx, [ebx + WDATA.box.left]
movzx edx, [eax + SYS_BUTTON.left]
add edx, ecx
mov cx, [mx] ;mov cx,[MOUSE_X]
cmp edx, ecx
jg .buttonnewcheck
movzx ebx, [eax + SYS_BUTTON.width]
add edx, ebx
cmp ecx, edx
jg .buttonnewcheck
; mouse y >= button y ?
movzx ebx, [eax + SYS_BUTTON.pslot]
shl ebx, 5
add ebx, window_data
mov ecx, [ebx + WDATA.box.top]
movzx edx, [eax + SYS_BUTTON.top]
add edx, ecx
mov cx, [my] ;mov cx,[MOUSE_Y]
cmp edx, ecx
jg .buttonnewcheck
movzx ebx, [eax + SYS_BUTTON.height]
add edx, ebx
cmp ecx, edx
jg .buttonnewcheck
; mouse on button
pop edx
pop esi
mov ebx, dword[eax + SYS_BUTTON.id_hi - 2] ; button id : bits 16-31
mov bx, [eax + SYS_BUTTON.id_lo] ; button id : bits 00-16
push ebx
mov byte[MOUSE_DOWN], 1 ; no mouse down checks
call button._.negative_button call button._.negative_button
pushad .exit:
push eax ret
mov al, [BTN_DOWN]
mov byte[btn_down_determ], al
pop eax
.cbwaitmouseup: align 4
call checkidle ;------------------------------------------------------------------------------
call [draw_pointer] sys_button_deactivate_handler: ;///////////////////////////////////////////////
;------------------------------------------------------------------------------
pushad ;? <description>
call stack_handler ;------------------------------------------------------------------------------
popad ;> eax = pack[8(process slot), 24(button id)]
;> ebx = pack[16(button x coord), 16(button y coord)]
cmp byte[BTN_DOWN], 0 ; mouse buttons pressed ? ;> cl = mouse button mask this system button was pressed with
jnz .cbwaitmouseup ;------------------------------------------------------------------------------
popad call button._.find_button
or eax, eax
jz .exit
mov ebx, dword[eax + SYS_BUTTON.id_hi - 2]
call button._.negative_button call button._.negative_button
mov byte[MOUSE_BACKGROUND], 0 ; no mouse background
mov byte[DONT_DRAW_MOUSE], 0 ; draw mouse
; check coordinates .exit:
pusha ret
; mouse x >= button x ? align 4
movzx ebx, [eax + SYS_BUTTON.pslot] ;------------------------------------------------------------------------------
shl ebx, 5 sys_button_perform_handler: ;//////////////////////////////////////////////////
add ebx, window_data ;------------------------------------------------------------------------------
mov ecx, [ebx + WDATA.box.left] ;? <description>
movzx edx, [eax + SYS_BUTTON.left] ;------------------------------------------------------------------------------
add edx, ecx ;> eax = pack[8(process slot), 24(button id)]
mov cx, [MOUSE_X] ;> ebx = pack[16(button x coord), 16(button y coord)]
cmp edx, ecx ;> cl = mouse button mask this system button was pressed with
jg .no_on_button ;if we release the pointer out of the button area ;------------------------------------------------------------------------------
shl eax, 8
movzx ebx, [eax + SYS_BUTTON.width] mov al, cl
add edx, ebx movzx ebx, byte[BTN_COUNT]
cmp ecx, edx mov [BTN_BUFF + ebx * 4], eax
jg .no_on_button inc bl
mov [BTN_COUNT], bl
; mouse y >= button y ?
movzx ebx, [eax + SYS_BUTTON.pslot]
shl ebx, 5
add ebx, window_data
mov ecx, [ebx + WDATA.box.top]
movzx edx, [eax + SYS_BUTTON.top]
add edx, ecx
mov cx, [MOUSE_Y]
cmp edx, ecx
jg .no_on_button
movzx ebx, [eax + SYS_BUTTON.height]
add edx, ebx
cmp ecx, edx
jg .no_on_button
popa
mov byte[BTN_COUNT], 1 ; no of buttons in buffer
pop ebx
mov [BTN_BUFF], ebx ; lets put the button id in buffer
push ebx
pusha
jmp .yes_on_button
.no_on_button:
mov byte[BTN_COUNT], 0 ; no of buttons in buffer
.yes_on_button:
mov byte[MOUSE_DOWN], 0 ; mouse down -> do not draw
popa
pop ebx
popa
ret ret
;============================================================================== ;==============================================================================
;///// private functions ////////////////////////////////////////////////////// ;///// private functions //////////////////////////////////////////////////////
;============================================================================== ;==============================================================================
;------------------------------------------------------------------------------
button._.find_button: ;////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? Find system button by specified process slot, id and coordinates
;------------------------------------------------------------------------------
;> eax = pack[8(process slot), 24(button id)] or 0
;> ebx = pack[16(button x coord), 16(button y coord)]
;------------------------------------------------------------------------------
;< eax = pointer to SYS_BUTTON struct or 0
;------------------------------------------------------------------------------
push ecx edx esi edi
mov edx, eax
shr edx, 24
and eax, 0x0ffffff
mov edi, [BTN_ADDR]
mov ecx, [edi]
imul esi, ecx, SYS_BUTTON.sizeof
add esi, edi
inc ecx
add esi, SYS_BUTTON.sizeof
.next_button:
dec ecx
jz .not_found
add esi, -SYS_BUTTON.sizeof
; does it belong to our process?
cmp dx, [esi + SYS_BUTTON.pslot]
jne .next_button
; does id match?
mov edi, dword[esi + SYS_BUTTON.id_hi - 2]
mov di, [esi + SYS_BUTTON.id_lo]
and edi, 0x0ffffff
cmp eax, edi
jne .next_button
; does coordinates match?
mov edi, dword[esi + SYS_BUTTON.left - 2]
mov di, [esi + SYS_BUTTON.top]
cmp ebx, edi
jne .next_button
; okay, return it
mov eax, esi
jmp .exit
.not_found:
xor eax, eax
.exit:
pop edi esi edx ecx
ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
button._.dececx: ;///////////////////////////////////////////////////////////// button._.dececx: ;/////////////////////////////////////////////////////////////
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
@@ -465,14 +381,17 @@ button._.dececx: ;/////////////////////////////////////////////////////////////
sub cl, 0x20 sub cl, 0x20
jnc @f jnc @f
xor cl, cl xor cl, cl
@@: sub ch, 0x20 @@:
sub ch, 0x20
jnc @f jnc @f
xor ch, ch xor ch, ch
@@: rol ecx, 16 @@:
rol ecx, 16
sub cl, 0x20 sub cl, 0x20
jnc @f jnc @f
xor cl, cl xor cl, cl
@@: rol ecx, 16 @@:
rol ecx, 16
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
@@ -483,14 +402,17 @@ button._.incecx: ;/////////////////////////////////////////////////////////////
add cl, 0x20 add cl, 0x20
jnc @f jnc @f
or cl, -1 or cl, -1
@@: add ch, 0x20 @@:
add ch, 0x20
jnc @f jnc @f
or ch, -1 or ch, -1
@@: rol ecx, 16 @@:
rol ecx, 16
add cl, 0x20 add cl, 0x20
jnc @f jnc @f
or cl, -1 or cl, -1
@@: rol ecx, 16 @@:
rol ecx, 16
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
@@ -501,14 +423,17 @@ button._.incecx2: ;////////////////////////////////////////////////////////////
add cl, 0x14 add cl, 0x14
jnc @f jnc @f
or cl, -1 or cl, -1
@@: add ch, 0x14 @@:
add ch, 0x14
jnc @f jnc @f
or ch, -1 or ch, -1
@@: rol ecx, 16 @@:
rol ecx, 16
add cl, 0x14 add cl, 0x14
jnc @f jnc @f
or cl, -1 or cl, -1
@@: rol ecx, 16 @@:
rol ecx, 16
ret ret
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
@@ -525,17 +450,21 @@ button._.button_dececx: ;//////////////////////////////////////////////////////
jg @f jg @f
mov al, 2 mov al, 2
@@: sub cl, al @@:
jnc @f
xor cl, cl
@@: sub ch, al
jnc @f
xor ch, ch
@@: rol ecx, 16
sub cl, al sub cl, al
jnc @f jnc @f
xor cl, cl xor cl, cl
@@: rol ecx, 16 @@:
sub ch, al
jnc @f
xor ch, ch
@@:
rol ecx, 16
sub cl, al
jnc @f
xor cl, cl
@@:
rol ecx, 16
pop eax pop eax
@@ -545,7 +474,7 @@ button._.button_dececx: ;//////////////////////////////////////////////////////
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
button._.negative_button: ;//////////////////////////////////////////////////// button._.negative_button: ;////////////////////////////////////////////////////
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
;? <description> ;? Invert system button border
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; if requested, do not display button border on press. ; if requested, do not display button border on press.
test ebx, 0x20000000 test ebx, 0x20000000

View File

@@ -7,6 +7,13 @@
$Revision$ $Revision$
WINDOW_MOVE_AND_RESIZE_FLAGS = \
mouse.WINDOW_RESIZE_N_FLAG + \
mouse.WINDOW_RESIZE_W_FLAG + \
mouse.WINDOW_RESIZE_S_FLAG + \
mouse.WINDOW_RESIZE_E_FLAG + \
mouse.WINDOW_MOVE_FLAG
uglobal uglobal
align 4 align 4
event_start dd ? event_start dd ?
@@ -18,22 +25,24 @@ FreeEvents = event_start-EVENT.fd ; "
; FreeEvents.fd=event_start <EFBFBD> FreeEvents.bk=event_end ; FreeEvents.fd=event_start <EFBFBD> FreeEvents.bk=event_end
align 4 align 4
init_events: ;; used from kernel.asm init_events: ;; used from kernel.asm
stdcall kernel_alloc,EV_SPACE*EVENT.size stdcall kernel_alloc, EV_SPACE*EVENT.size
or eax,eax or eax, eax
jz .fail jz .fail
; eax - current event, ebx - previos event below ; eax - current event, ebx - previos event below
mov ecx,EV_SPACE ; current - in allocated space mov ecx, EV_SPACE ; current - in allocated space
mov ebx,FreeEvents ; previos - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> mov ebx, FreeEvents ; previos - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
push ebx ; <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> push ebx ; <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@: mov [ebx+EVENT.fd],eax @@:
mov [eax+EVENT.bk],ebx mov [ebx+EVENT.fd], eax
mov ebx,eax ; previos <- current mov [eax+EVENT.bk], ebx
add eax,EVENT.size ; new current mov ebx, eax ; previos <- current
add eax, EVENT.size ; new current
loop @b loop @b
pop eax ; <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> pop eax ; <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
mov [ebx+EVENT.fd],eax mov [ebx+EVENT.fd], eax
mov [eax+EVENT.bk],ebx mov [eax+EVENT.bk], ebx
.fail: ret .fail:
ret
EVENT_WATCHED equ 0x10000000 ;<EFBFBD><EFBFBD><EFBFBD> 28 EVENT_WATCHED equ 0x10000000 ;<EFBFBD><EFBFBD><EFBFBD> 28
EVENT_SIGNALED equ 0x20000000 ;<EFBFBD><EFBFBD><EFBFBD> 29 EVENT_SIGNALED equ 0x20000000 ;<EFBFBD><EFBFBD><EFBFBD> 29
@@ -52,10 +61,10 @@ create_event: ;; EXPORT use
; eax - event (=0 => fail) ; eax - event (=0 => fail)
; edx - uid ; edx - uid
;scratched: ebx,ecx,esi,edi ;scratched: ebx,ecx,esi,edi
mov ebx,[current_slot] mov ebx, [current_slot]
add ebx,APP_OBJ_OFFSET add ebx, APP_OBJ_OFFSET
mov edx,[TASK_BASE] mov edx, [TASK_BASE]
mov edx,[edx+TASKDATA.pid] mov edx, [edx+TASKDATA.pid]
pushfd pushfd
cli cli
@@ -73,24 +82,25 @@ set_event: ;; INTERNAL use !!! don't use
; eax - event (=0 => fail) ; eax - event (=0 => fail)
; edx - uid ; edx - uid
;scratched: ebx,ecx,esi,edi ;scratched: ebx,ecx,esi,edi
mov eax,FreeEvents mov eax, FreeEvents
cmp eax,[eax+EVENT.fd] cmp eax, [eax+EVENT.fd]
jne @f ; not empty ??? jne @f ; not empty ???
pushad pushad
call init_events call init_events
popad popad
jz RemoveEventTo.break ; POPF+RET jz RemoveEventTo.break ; POPF+RET
@@: mov eax,[eax+EVENT.fd] @@:
mov [eax+EVENT.magic],'EVNT' mov eax, [eax+EVENT.fd]
mov [eax+EVENT.destroy],destroy_event.internal mov [eax+EVENT.magic], 'EVNT'
mov [eax+EVENT.state],ecx mov [eax+EVENT.destroy], destroy_event.internal
mov [eax+EVENT.pid],edx mov [eax+EVENT.state], ecx
mov [eax+EVENT.pid], edx
inc [event_uid] inc [event_uid]
Mov [eax+EVENT.id],edx,[event_uid] Mov [eax+EVENT.id],edx,[event_uid]
or esi,esi or esi, esi
jz RemoveEventTo jz RemoveEventTo
lea edi,[eax+EVENT.code] lea edi, [eax+EVENT.code]
mov ecx,EVENT.codesize/4 mov ecx, EVENT.codesize/4
cld cld
rep movsd rep movsd
@@ -99,31 +109,32 @@ RemoveEventTo: ;; INTERNAL use !!! don't use
; eax - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> event, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; eax - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> event, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; ebx - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> event, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; ebx - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> event, <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
;scratched: ebx,ecx ;scratched: ebx,ecx
mov ecx,eax ; ecx=eax=Self, ebx=NewLeft mov ecx, eax ; ecx=eax=Self, ebx=NewLeft
xchg ecx,[ebx+EVENT.fd] ; NewLeft.fd=Self, ecx=NewRight xchg ecx, [ebx+EVENT.fd] ; NewLeft.fd=Self, ecx=NewRight
cmp eax,ecx ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>... cmp eax, ecx ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...
je .break ; - <EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD>? je .break ; - <EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD>?
mov [ecx+EVENT.bk],eax ; NewRight.bk=Self mov [ecx+EVENT.bk], eax ; NewRight.bk=Self
xchg ebx,[eax+EVENT.bk] ; Self.bk=NewLeft, ebx=OldLeft xchg ebx, [eax+EVENT.bk] ; Self.bk=NewLeft, ebx=OldLeft
xchg ecx,[eax+EVENT.fd] ; Self.fd=NewRight, ecx=OldRight xchg ecx, [eax+EVENT.fd] ; Self.fd=NewRight, ecx=OldRight
mov [ebx+EVENT.fd],ecx ; OldLeft.fd=OldRight mov [ebx+EVENT.fd], ecx ; OldLeft.fd=OldRight
mov [ecx+EVENT.bk],ebx ; OldRight.bk=OldLeft mov [ecx+EVENT.bk], ebx ; OldRight.bk=OldLeft
.break: popfd .break:
popfd
ret ret
align 4 align 4
NotDummyTest: ;; INTERNAL use (not returned for fail !!!) NotDummyTest: ;; INTERNAL use (not returned for fail !!!)
pop edi pop edi
call DummyTest ; not returned for fail !!! call DummyTest ; not returned for fail !!!
mov ebx,eax mov ebx, eax
mov eax,[ebx+EVENT.pid] mov eax, [ebx+EVENT.pid]
push edi push edi
.small: ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD>... .small: ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>-<EFBFBD><EFBFBD>...
pop edi pop edi
pushfd pushfd
cli cli
call pid_to_slot ; saved all registers (eax - retval) call pid_to_slot ; saved all registers (eax - retval)
shl eax,8 shl eax, 8
jz RemoveEventTo.break ; POPF+RET jz RemoveEventTo.break ; POPF+RET
jmp edi ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> jmp edi ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
@@ -141,10 +152,10 @@ raise_event: ;; EXPORT use
; esi - event data (=0 => skip) ; esi - event data (=0 => skip)
;scratched: ebx,ecx,esi,edi ;scratched: ebx,ecx,esi,edi
call NotDummyTest ; not returned for fail !!! call NotDummyTest ; not returned for fail !!!
or esi,esi or esi, esi
jz @f jz @f
lea edi,[ebx+EVENT.code] lea edi, [ebx+EVENT.code]
mov ecx,EVENT.codesize/4 mov ecx, EVENT.codesize/4
cld cld
rep movsd rep movsd
@@: @@:
@@ -156,8 +167,8 @@ raise_event: ;; EXPORT use
jz RemoveEventTo.break ; POPF+RET jz RemoveEventTo.break ; POPF+RET
@@: @@:
or byte[ebx+EVENT.state+3], EVENT_SIGNALED shr 24 or byte[ebx+EVENT.state+3], EVENT_SIGNALED shr 24
add eax,SLOT_BASE+APP_EV_OFFSET add eax, SLOT_BASE+APP_EV_OFFSET
xchg eax,ebx xchg eax, ebx
jmp RemoveEventTo jmp RemoveEventTo
align 4 align 4
@@ -169,9 +180,9 @@ clear_event: ;; EXPORT use
; ebx - uid (for Dummy testing) ; ebx - uid (for Dummy testing)
;scratched: ebx,ecx ;scratched: ebx,ecx
call NotDummyTest ; not returned for fail !!! call NotDummyTest ; not returned for fail !!!
add eax,SLOT_BASE+APP_OBJ_OFFSET add eax, SLOT_BASE+APP_OBJ_OFFSET
and byte[ebx+EVENT.state+3], not((EVENT_SIGNALED+EVENT_WATCHED)shr 24) and byte[ebx+EVENT.state+3], not((EVENT_SIGNALED+EVENT_WATCHED)shr 24)
xchg eax,ebx xchg eax, ebx
jmp RemoveEventTo jmp RemoveEventTo
align 4 align 4
@@ -191,10 +202,10 @@ send_event: ;; EXPORT use
; mov eax,[esp+4] ; mov eax,[esp+4]
; but not as STDCALL :( ; but not as STDCALL :(
;scratched: ebx,ecx,esi,edi ;scratched: ebx,ecx,esi,edi
mov edx,eax mov edx, eax
call NotDummyTest.small ; not returned for fail !!! call NotDummyTest.small ; not returned for fail !!!
lea ebx,[eax+SLOT_BASE+APP_EV_OFFSET] lea ebx, [eax+SLOT_BASE+APP_EV_OFFSET]
mov ecx,EVENT_SIGNALED mov ecx, EVENT_SIGNALED
jmp set_event jmp set_event
align 4 align 4
@@ -202,18 +213,20 @@ DummyTest: ;; INTERNAL use (not returned
;param: ;param:
; eax - event ; eax - event
; ebx - uid (for Dummy testing) ; ebx - uid (for Dummy testing)
cmp [eax+EVENT.magic],'EVNT' cmp [eax+EVENT.magic], 'EVNT'
jne @f jne @f
cmp [eax+EVENT.id],ebx cmp [eax+EVENT.id], ebx
je .ret je .ret
@@: pop eax @@:
xor eax,eax pop eax
.ret: ret xor eax, eax
.ret:
ret
align 4 align 4
Wait_events: Wait_events:
or ebx,-1 ; infinite timeout or ebx, -1; infinite timeout
Wait_events_ex: Wait_events_ex:
;info: ;info:
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> 5-<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>. ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> 5-<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
@@ -228,26 +241,27 @@ Wait_events_ex:
;retval: ;retval:
; eax - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> [wait_test] (=0 => timeout) ; eax - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> [wait_test] (=0 => timeout)
;scratched: esi ;scratched: esi
mov esi,[current_slot] mov esi, [current_slot]
mov [esi+APPDATA.wait_param],ecx mov [esi+APPDATA.wait_param], ecx
pushad pushad
mov ebx,esi;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.......... mov ebx, esi;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>..........
pushfd ; <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>-<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> pushfd ; <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>-<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cli ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> shed cli ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> shed
call edx call edx
popfd popfd
mov [esp+28],eax mov [esp+28], eax
popad popad
or eax,eax or eax, eax
jnz @f ;RET jnz @f ;RET
mov [esi+APPDATA.wait_test],edx mov [esi+APPDATA.wait_test], edx
mov [esi+APPDATA.wait_timeout],ebx mov [esi+APPDATA.wait_timeout], ebx
Mov [esi+APPDATA.wait_begin],eax,[timer_ticks] Mov [esi+APPDATA.wait_begin],eax,[timer_ticks]
mov eax,[TASK_BASE] mov eax, [TASK_BASE]
mov [eax+TASKDATA.state], 5 mov [eax+TASKDATA.state], 5
call change_task call change_task
mov eax,[esi+APPDATA.wait_param] mov eax, [esi+APPDATA.wait_param]
@@: ret @@:
ret
align 4 align 4
wait_event: ;; EXPORT use wait_event: ;; EXPORT use
@@ -263,7 +277,7 @@ wait_event: ;; EXPORT use
; ebx - uid (for Dummy testing) ; ebx - uid (for Dummy testing)
;scratched: ecx,edx,esi ;scratched: ecx,edx,esi
call DummyTest call DummyTest
mov ecx,eax ; wait_param mov ecx, eax ; wait_param
mov edx, get_event_alone ; wait_test mov edx, get_event_alone ; wait_test
call Wait_events ; timeout ignored call Wait_events ; timeout ignored
jmp wait_finish jmp wait_finish
@@ -284,19 +298,19 @@ get_event_ex: ;; f68:14
;scratched: ebx,ecx,edx,esi,edi ;scratched: ebx,ecx,edx,esi,edi
mov edx, get_event_queue ; wait_test mov edx, get_event_queue ; wait_test
call Wait_events ; timeout ignored call Wait_events ; timeout ignored
lea esi,[eax+EVENT.code] lea esi, [eax+EVENT.code]
mov ecx,EVENT.codesize/4 mov ecx, EVENT.codesize/4
cld cld
rep movsd rep movsd
mov [edi-EVENT.codesize+2],cl ;clear priority field mov [edi-EVENT.codesize+2], cl;clear priority field
wait_finish: wait_finish:
test byte[eax+EVENT.state+3], MANUAL_RESET shr 24 test byte[eax+EVENT.state+3], MANUAL_RESET shr 24
jnz get_event_queue.ret ; RET jnz get_event_queue.ret ; RET
and byte[eax+EVENT.state+3], not((EVENT_SIGNALED+EVENT_WATCHED)shr 24) and byte[eax+EVENT.state+3], not((EVENT_SIGNALED+EVENT_WATCHED)shr 24)
test byte[eax+EVENT.state+3], MANUAL_DESTROY shr 24 test byte[eax+EVENT.state+3], MANUAL_DESTROY shr 24
jz destroy_event.internal jz destroy_event.internal
mov ebx,[current_slot] mov ebx, [current_slot]
add ebx,APP_OBJ_OFFSET add ebx, APP_OBJ_OFFSET
pushfd pushfd
cli cli
jmp RemoveEventTo jmp RemoveEventTo
@@ -313,14 +327,14 @@ destroy_event: ;; EXPORT use
;scratched: ebx,ecx ;scratched: ebx,ecx
call DummyTest ; not returned for fail !!! call DummyTest ; not returned for fail !!!
.internal: .internal:
xor ecx,ecx ; clear common header xor ecx, ecx ; clear common header
pushfd pushfd
cli cli
mov [eax+EVENT.magic],ecx mov [eax+EVENT.magic], ecx
mov [eax+EVENT.destroy],ecx mov [eax+EVENT.destroy], ecx
mov [eax+EVENT.pid],ecx mov [eax+EVENT.pid], ecx
mov [eax+EVENT.id],ecx mov [eax+EVENT.id], ecx
mov ebx,FreeEvents mov ebx, FreeEvents
jmp RemoveEventTo jmp RemoveEventTo
align 4 align 4
@@ -335,11 +349,12 @@ get_event_queue:
; ebx - <20><><EFBFBD><EFBFBD><EFBFBD> APPDATA <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; ebx - <20><><EFBFBD><EFBFBD><EFBFBD> APPDATA <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
;retval: ;retval:
; eax - <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> EVENT (=0 => fail) ; eax - <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> EVENT (=0 => fail)
add ebx,APP_EV_OFFSET add ebx, APP_EV_OFFSET
mov eax,[ebx+APPOBJ.bk] ; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FIFO mov eax, [ebx+APPOBJ.bk] ; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> FIFO
cmp eax,ebx ; empty ??? cmp eax, ebx ; empty ???
je get_event_alone.ret0 je get_event_alone.ret0
.ret: ret .ret:
ret
align 4 align 4
get_event_alone: get_event_alone:
@@ -353,12 +368,14 @@ get_event_alone:
; ebx - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> APPDATA <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; ebx - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> APPDATA <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
;retval: ;retval:
; eax - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> EVENT (=0 => fail) ; eax - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> EVENT (=0 => fail)
mov eax,[ebx+APPDATA.wait_param] mov eax, [ebx+APPDATA.wait_param]
test byte[eax+EVENT.state+3], EVENT_SIGNALED shr 24 test byte[eax+EVENT.state+3], EVENT_SIGNALED shr 24
jnz .ret jnz .ret
or byte[eax+EVENT.state+3], EVENT_WATCHED shr 24 or byte[eax+EVENT.state+3], EVENT_WATCHED shr 24
.ret0: xor eax,eax ; NO event!!! .ret0:
.ret: ret xor eax, eax; NO event!!!
.ret:
ret
align 4 align 4
sys_sendwindowmsg: ;; f72 sys_sendwindowmsg: ;; f72
@@ -366,43 +383,46 @@ sys_sendwindowmsg: ;; f72
jnz .ret ;subfunction==1 ? jnz .ret ;subfunction==1 ?
;pushfd ;<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>? ;pushfd ;<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>?
cli cli
sub ecx,2 sub ecx, 2
je .sendkey je .sendkey
loop .retf dec ecx
jnz .retf
.sendbtn: .sendbtn:
cmp byte[BTN_COUNT],1 cmp byte[BTN_COUNT], 1
jae .result ;overflow jae .result ;overflow
inc byte[BTN_COUNT] inc byte[BTN_COUNT]
mov [BTN_BUFF],edx shl edx, 8
mov [BTN_BUFF], edx
jmp .result jmp .result
.sendkey: .sendkey:
movzx eax,byte[KEY_COUNT] movzx eax, byte[KEY_COUNT]
cmp al,120 cmp al, 120
jae .result ;overflow jae .result ;overflow
inc byte[KEY_COUNT] inc byte[KEY_COUNT]
mov [KEY_COUNT+1+eax],dl mov [KEY_COUNT+1+eax], dl
.result: .result:
setae byte[esp+32] ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: dword[esp+32]==72 setae byte[esp+32] ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: dword[esp+32]==72
.retf: ;popfd .retf: ;popfd
.ret: ret .ret:
ret
align 4 align 4
sys_getevent: ;; f11 sys_getevent: ;; f11
mov ebx,[current_slot] ;<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.......... mov ebx, [current_slot];<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>..........
pushfd ; <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>-<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> pushfd ; <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD>-<EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cli ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> shed cli ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> shed
call get_event_for_app call get_event_for_app
popfd popfd
mov [esp+32],eax mov [esp+32], eax
ret ret
align 4 align 4
sys_waitforevent: ;; f10 sys_waitforevent: ;; f10
or ebx,-1 ; infinite timeout or ebx, -1; infinite timeout
sys_wait_event_timeout: ;; f23 sys_wait_event_timeout: ;; f23
mov edx,get_event_for_app ; wait_test mov edx, get_event_for_app; wait_test
call Wait_events_ex ; ebx - timeout call Wait_events_ex ; ebx - timeout
mov [esp+32],eax mov [esp+32], eax
ret ret
align 4 align 4
@@ -417,70 +437,73 @@ get_event_for_app: ;; used from f10,f11,f23
; ebx - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> APPDATA <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; ebx - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> APPDATA <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
;retval: ;retval:
; eax - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (=0 => no events) ; eax - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (=0 => no events)
movzx edi,bh ; bh is assumed as [CURRENT_TASK] movzx edi, bh ; bh is assumed as [CURRENT_TASK]
shl edi,5 shl edi, 5
add edi,CURRENT_TASK ; edi is assumed as [TASK_BASE] add edi, CURRENT_TASK ; edi is assumed as [TASK_BASE]
mov ecx,[edi+TASKDATA.event_mask] mov ecx, [edi+TASKDATA.event_mask]
.loop: ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> .loop: ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
bsr eax,ecx ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (31 -> 0) bsr eax, ecx ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (31 -> 0)
jz .no_events ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ??? jz .no_events ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ???
btr ecx,eax ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> btr ecx, eax ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (eax) <EFBFBD><EFBFBD><EFBFBD><EFBFBD> ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (eax) <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cmp eax,16 cmp eax, 9
jae .IRQ ; eax=[16..31]=retvals, events irq0..irq15 jae .loop ; eax=[9..31], ignored
cmp eax,9 cmp eax, 3
jae .loop ; eax=[9..15], ignored
cmp eax,3
je .loop ; eax=3, ignored je .loop ; eax=3, ignored
ja .FlagAutoReset ; eax=[4..8], retvals=eax+1 ja .FlagAutoReset ; eax=[4..8], retvals=eax+1
cmp eax,1 cmp eax, 1
jae .BtKy ; eax=[1,2], retvals=eax+1 jae .BtKy ; eax=[1,2], retvals=eax+1
.WndRedraw: ; eax=0, retval WndRedraw=1 .WndRedraw: ; eax=0, retval WndRedraw=1
cmp [edi-twdw+WDATA.fl_redraw],al ;al==0 cmp [edi-twdw+WDATA.fl_redraw], al;al==0
jne .result jne .result
jmp .loop jmp .loop
.no_events: .no_events:
xor eax,eax xor eax, eax
ret ret
.IRQ:
;TODO: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD> FlagAutoReset (BgrRedraw,Mouse,IPC,Stack,Debug)
mov edx,[irq_owner+eax*4-64] ; eax==16+irq
cmp edx,[edi+TASKDATA.pid]
jne .loop
mov edx,eax
shl edx,12
cmp dword[IRQ_SAVE+edx-0x10000],0 ; edx==(16+irq)*0x1000
je .loop ; empty ???
ret ; retval = eax
.FlagAutoReset: ; retvals: BgrRedraw=5, Mouse=6, IPC=7, Stack=8, Debug=9 .FlagAutoReset: ; retvals: BgrRedraw=5, Mouse=6, IPC=7, Stack=8, Debug=9
btr [ebx+APPDATA.event_mask],eax cmp eax, 5; Mouse 5+1=6
jne @f
push eax
; If the window is captured and moved by the user, then no mouse events!!!
mov al, [mouse.active_sys_window.action]
and al, WINDOW_MOVE_AND_RESIZE_FLAGS
test al, al
pop eax
jnz .loop
@@:
btr [ebx+APPDATA.event_mask], eax
jnc .loop jnc .loop
.result: ; retval = eax+1 .result: ; retval = eax+1
inc eax inc eax
ret ret
.BtKy: .BtKy:
movzx edx,bh movzx edx, bh
movzx edx, word[WIN_STACK+edx*2] movzx edx, word[WIN_STACK+edx*2]
je .Keys ; eax=1, retval Keys=2 je .Keys ; eax=1, retval Keys=2
.Buttons: ; eax=2, retval Buttons=3 .Buttons: ; eax=2, retval Buttons=3
cmp byte[BTN_COUNT],0 cmp byte[BTN_COUNT], 0
je .loop ; empty ??? je .loop ; empty ???
cmp edx,[TASK_COUNT] cmp edx, [TASK_COUNT]
jne .loop ; not Top ??? jne .loop ; not Top ???
cmp dword[BTN_BUFF],0xFFFF ;-ID for Minimize-Button of Form mov edx, [BTN_BUFF]
shr edx, 8
cmp edx, 0xFFFF ;-ID for Minimize-Button of Form
jne .result jne .result
mov [window_minimize],1 mov [window_minimize], 1
dec byte[BTN_COUNT] dec byte[BTN_COUNT]
jmp .loop jmp .loop
.Keys: ; eax==1 .Keys: ; eax==1
cmp edx,[TASK_COUNT] cmp edx, [TASK_COUNT]
jne @f ; not Top ??? jne @f ; not Top ???
cmp [KEY_COUNT],al ; al==1 cmp [KEY_COUNT], al; al==1
jae .result ; not empty ??? jae .result ; not empty ???
@@: mov edx, hotkey_buffer @@:
@@: cmp [edx],bh ; bh - slot for testing mov edx, hotkey_buffer
@@:
cmp [edx], bh ; bh - slot for testing
je .result je .result
add edx,8 add edx, 8
cmp edx, hotkey_buffer+120*8 cmp edx, hotkey_buffer+120*8
jb @b jb @b
jmp .loop jmp .loop

View File

@@ -1,250 +1,715 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2010. All rights reserved. ;;
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision$ $Revision$
include 'mousepointer.inc'
iglobal ;==============================================================================
;///// public functions ///////////////////////////////////////////////////////
;==============================================================================
mouse.LEFT_BUTTON_FLAG = 0001b
mouse.RIGHT_BUTTON_FLAG = 0010b
mouse.MIDDLE_BUTTON_FLAG = 0100b
mouse.BUTTONS_MASK = \
mouse.LEFT_BUTTON_FLAG or \
mouse.RIGHT_BUTTON_FLAG or \
mouse.MIDDLE_BUTTON_FLAG
mouse.WINDOW_RESIZE_N_FLAG = 000001b
mouse.WINDOW_RESIZE_W_FLAG = 000010b
mouse.WINDOW_RESIZE_S_FLAG = 000100b
mouse.WINDOW_RESIZE_E_FLAG = 001000b
mouse.WINDOW_MOVE_FLAG = 010000b
mouse.WINDOW_RESIZE_SW_FLAG = \
mouse.WINDOW_RESIZE_S_FLAG or \
mouse.WINDOW_RESIZE_W_FLAG
mouse.WINDOW_RESIZE_SE_FLAG = \
mouse.WINDOW_RESIZE_S_FLAG or \
mouse.WINDOW_RESIZE_E_FLAG
align 4 align 4
mousepointer: ;------------------------------------------------------------------------------
db 0x00,0x00,0x00,0x74,0x74,0x74,0x6e,0x6e,0x6e,0x6f mouse_check_events: ;//////////////////////////////////////////////////////////
db 0x6f,0x6f,0x71,0x71,0x71,0x75,0x75,0x75,0x79,0x79 ;------------------------------------------------------------------------------
db 0x79,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x80,0x80,0x80 ;? Check if mouse buttons state or cursor position has changed and call
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80 ;? appropriate handlers
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80 ;------------------------------------------------------------------------------
db 0x80,0x00,0x00,0x00,0x63,0x63,0x63,0x63,0x63,0x63 push eax ebx
db 0x66,0x66,0x66,0x6c,0x6c,0x6c,0x72,0x72,0x72,0x78
db 0x78,0x78,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc0
db 0xc0,0xc0,0x00,0x00,0x00,0x54,0x54,0x54,0x57,0x57
db 0x57,0x5f,0x5f,0x5f,0x68,0x68,0x68,0x71,0x71,0x71
db 0x77,0x77,0x77,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc0,0xc0,0xc0
db 0xc0,0xc0,0xc0,0x00,0x00,0x00,0x47,0x47,0x47,0x50
db 0x50,0x50,0x5b,0x5b,0x5b,0x67,0x67,0x67,0x70,0x70
db 0x70,0x77,0x77,0x77,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0xff,0xff,0xff,0xc0,0xc0
db 0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x3f,0x3f,0x3f
db 0x4b,0x4b,0x4b,0x59,0x59,0x59,0x66,0x66,0x66,0x70
db 0x70,0x70,0x77,0x77,0x77,0x7c,0x7c,0x7c,0x7e,0x7e
db 0x7e,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x80,0x80,0xff,0xff,0xff,0xc0,0xc0,0xc0,0xc0
db 0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x3a,0x3a
db 0x3a,0x49,0x49,0x49,0x59,0x59,0x59,0x66,0x66,0x66
db 0x70,0x70,0x70,0x77,0x77,0x77,0x7c,0x7c,0x7c,0x7e
db 0x7e,0x7e,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xc0,0xc0
db 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x39
db 0x39,0x39,0x49,0x49,0x49,0x59,0x59,0x59,0x66,0x66
db 0x66,0x71,0x71,0x71,0x78,0x78,0x78,0x7c,0x7c,0x7c
db 0x7e,0x7e,0x7e,0x80,0x80,0x80,0x80,0x80,0x80,0xff
db 0xff,0xff,0xff,0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0
db 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00
db 0x39,0x39,0x39,0x4a,0x4a,0x4a,0x5a,0x5a,0x5a,0x68
db 0x68,0x68,0x72,0x72,0x72,0x79,0x79,0x79,0x7d,0x7d
db 0x7d,0x7f,0x7f,0x7f,0x80,0x80,0x80,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xc0,0xc0,0xc0
db 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00
db 0x00,0x3c,0x3c,0x3c,0x4e,0x4e,0x4e,0x5e,0x5e,0x5e
db 0x6b,0x6b,0x6b,0x75,0x75,0x75,0x7a,0x7a,0x7a,0x7e
db 0x7e,0x7e,0x80,0x80,0x80,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0
db 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00
db 0x00,0x00,0x43,0x43,0x43,0x55,0x55,0x55,0x64,0x64
db 0x64,0x70,0x70,0x70,0x78,0x78,0x78,0x7d,0x7d,0x7d
db 0x80,0x80,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xc0
db 0xc0,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x4e,0x4e,0x4e,0x5f,0x5f,0x5f,0x6d
db 0x6d,0x6d,0x76,0x76,0x76,0x7c,0x7c,0x7c,0x80,0x80
db 0x80,0xff,0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00
db 0xff,0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x14
db 0x14,0x14,0x1b,0x1b,0x1b,0x29,0x29,0x29,0x3a,0x3a
db 0x3a,0x4c,0x4c,0x4c,0x5d,0x5d,0x5d,0x6c,0x6c,0x6c
db 0x75,0x75,0x75,0x7b,0x7b,0x7b,0x80,0x80,0x80,0xc0
db 0xc0,0xc0,0x00,0x00,0x00,0x2f,0x2f,0x2f,0x80,0x80
db 0x80,0xff,0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00
db 0x21,0x21,0x21,0x2e,0x2e,0x2e,0x40,0x40,0x40,0x52
db 0x52,0x52,0x62,0x62,0x62,0x6f,0x6f,0x6f,0x77,0x77
db 0x77,0x7c,0x7c,0x7c,0x80,0x80,0x80,0x00,0x00,0x00
db 0x47,0x47,0x47,0x3b,0x3b,0x3b,0x80,0x80,0x80,0xff
db 0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x25,0x25
db 0x25,0x30,0x30,0x30,0x42,0x42,0x42,0x54,0x54,0x54
db 0x64,0x64,0x64,0x70,0x70,0x70,0x78,0x78,0x78,0x7d
db 0x7d,0x7d,0x00,0x00,0x00,0x62,0x62,0x62,0x52,0x52
db 0x52,0x4a,0x4a,0x4a,0x43,0x43,0x43,0x80,0x80,0x80
db 0xff,0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x33
db 0x33,0x33,0x42,0x42,0x42,0x54,0x54,0x54,0x64,0x64
db 0x64,0x71,0x71,0x71,0x79,0x79,0x79,0x7d,0x7d,0x7d
db 0x72,0x72,0x72,0x6b,0x6b,0x6b,0x5f,0x5f,0x5f,0x5a
db 0x5a,0x5a,0x54,0x54,0x54,0x80,0x80,0x80,0xff,0xff
db 0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x35,0x35,0x35
db 0x41,0x41,0x41,0x53,0x53,0x53,0x63,0x63,0x63,0x70
db 0x70,0x70,0x78,0x78,0x78,0x7d,0x7d,0x7d,0x77,0x77
db 0x77,0x73,0x73,0x73,0x6c,0x6c,0x6c,0x68,0x68,0x68
db 0x62,0x62,0x62,0x5a,0x5a,0x5a,0x80,0x80,0x80,0xff
db 0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x41,0x41
db 0x41,0x52,0x52,0x52,0x62,0x62,0x62,0x6f,0x6f,0x6f
db 0x78,0x78,0x78,0x7d,0x7d,0x7d,0x7b,0x7b,0x7b,0x79
db 0x79,0x79,0x74,0x74,0x74,0x72,0x72,0x72,0x6e,0x6e
db 0x6e,0x66,0x66,0x66,0x80,0x80,0x80,0xc0,0xc0,0xc0
db 0xc0,0xc0,0xc0,0x00,0x00,0x00,0x44,0x44,0x44,0x52
db 0x52,0x52,0x62,0x62,0x62,0x6e,0x6e,0x6e,0x77,0x77
db 0x77,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x7c,0x7c,0x7c
db 0x7a,0x7a,0x7a,0x79,0x79,0x79,0x75,0x75,0x75,0x6f
db 0x6f,0x6f,0x65,0x65,0x65,0x00,0x00,0x00,0x00,0x00
db 0x00,0x48,0x48,0x48,0x4b,0x4b,0x4b,0x56,0x56,0x56
db 0x65,0x65,0x65,0x70,0x70,0x70,0x78,0x78,0x78,0x7d
db 0x7d,0x7d,0x80,0x80,0x80,0x7f,0x7f,0x7f,0x7e,0x7e
db 0x7e,0x7d,0x7d,0x7d,0x7a,0x7a,0x7a,0x76,0x76,0x76
db 0x6f,0x6f,0x6f,0x65,0x65,0x65,0x5c,0x5c,0x5c,0x56
db 0x56,0x56,0x58,0x58,0x58,0x60,0x60,0x60,0x6b,0x6b
db 0x6b,0x73,0x73,0x73,0x7a,0x7a,0x7a,0x7d,0x7d,0x7d
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x7f
db 0x7f,0x7f,0x7d,0x7d,0x7d,0x7a,0x7a,0x7a,0x76,0x76
db 0x76,0x70,0x70,0x70,0x6a,0x6a,0x6a,0x66,0x66,0x66
db 0x66,0x66,0x66,0x6c,0x6c,0x6c,0x72,0x72,0x72,0x78
db 0x78,0x78,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x7f,0x7f,0x7f,0x7d,0x7d,0x7d,0x7b,0x7b,0x7b,0x77
db 0x77,0x77,0x73,0x73,0x73,0x71,0x71,0x71,0x71,0x71
db 0x71,0x74,0x74,0x74,0x78,0x78,0x78,0x7b,0x7b,0x7b
db 0x7d,0x7d,0x7d,0x7f,0x7f,0x7f,0x80,0x80,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x7f,0x7f,0x7f,0x7d,0x7d,0x7d,0x7c,0x7c,0x7c
db 0x7a,0x7a,0x7a,0x78,0x78,0x78,0x78,0x78,0x78,0x7a
db 0x7a,0x7a,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x7f,0x7f
db 0x7f,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x80,0x7f,0x7f,0x7f,0x7e,0x7e,0x7e,0x7e,0x7e
db 0x7e,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7e,0x7e,0x7e
db 0x7e,0x7e,0x7e,0x7f,0x7f,0x7f,0x80,0x80,0x80,0x80
db 0x80,0x80
mousepointer1: mov al, [BTN_DOWN]
db 0xff,0xff,0xff,0x06,0x06,0x06,0x0a,0x0a mov bl, [mouse.state.buttons]
db 0x0a,0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00 and al, mouse.BUTTONS_MASK
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 mov cl, al
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 xchg cl, [mouse.state.buttons]
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 xor bl, al
db 0xff,0xff,0xff,0xff,0xff,0xff,0x19,0x19,0x19,0x16 push eax ebx
db 0x16,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x2e,0x2e,0x2e
db 0x23,0x23,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f
db 0x3f,0x29,0x29,0x29,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x47
db 0x47,0x47,0x2c,0x2c,0x2c,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0x48,0x48,0x48,0x2c,0x2c,0x2c,0x16,0x16,0x16,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0x48,0x48,0x48,0x2c,0x2c,0x2c,0x16,0x16,0x16
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0x48,0x48,0x48,0x2c,0x2c,0x2c,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0x48,0x48,0x48,0x2c,0x2c,0x2c,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0x47,0x47,0x47,0x29,0x29,0x29
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0x40,0x40,0x40,0x23,0x23
db 0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xaa,0xaa,0xaa,0x9f,0x9f,0x9f,0x8c,0x8c,0x8c
db 0x70,0x70,0x70,0x4f,0x4f,0x4f,0x30,0x30,0x30,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x8f,0x8f,0x8f
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0x9c,0x9c,0x9c,0x87,0x87,0x87,0x6c,0x6c
db 0x6c,0x4f,0x4f,0x4f,0x32,0x32,0x32,0x19,0x19,0x19
db 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff
db 0xff,0xff,0x69,0x69,0x69,0x84,0x84,0x84,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0x92,0x92,0x92,0x79,0x79,0x79,0x59,0x59,0x59,0x3c
db 0x3c,0x3c,0x24,0x24,0x24,0x11,0x11,0x11,0x00,0x00
db 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x37,0x37,0x37
db 0x5d,0x5d,0x5d,0x70,0x70,0x70,0x76,0x76,0x76,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0x75,0x75,0x75,0x51,0x51,0x51,0x31,0x31,0x31
db 0x19,0x19,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x16,0x16,0x16,0x2d,0x2d,0x2d,0x49,0x49
db 0x49,0x53,0x53,0x53,0x54,0x54,0x54,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x78
db 0x78,0x78,0x54,0x54,0x54,0x30,0x30,0x30,0x16,0x16
db 0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x0f,0x0f,0x0f,0x1f,0x1f,0x1f,0x30,0x30,0x30,0x33
db 0x33,0x33,0x33,0x33,0x33,0x3b,0x3b,0x3b,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0x62,0x62,0x62,0x3b,0x3b,0x3b,0x1c,0x1c,0x1c,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x08
db 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x24,0x24,0x24,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x6e,0x6e
db 0x6e,0x48,0x48,0x48,0x25,0x25,0x25,0x0e,0x0e,0x0e
db 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x00
db 0x00,0x00,0x0a,0x0a,0x0a,0x09,0x09,0x09,0x00,0x00
db 0x00,0x00,0x00,0x00,0x29,0x29,0x29,0xff,0xff,0xff
db 0xff,0xff,0xff,0x7c,0x7c,0x7c,0x71,0x71,0x71,0x50
db 0x50,0x50,0x2b,0x2b,0x2b,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x02,0x02,0x02,0x04,0x04,0x04,0x00
db 0x00,0x00,0x00,0x00,0x00,0x36,0x36,0x36,0x56,0x56
db 0x56,0x69,0x69,0x69,0x64,0x64,0x64,0x4a,0x4a,0x4a
db 0x28,0x28,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x05,0x05,0x05
db 0x00,0x00,0x00,0x21,0x21,0x21,0x39,0x39,0x39,0x49
db 0x49,0x49,0x48,0x48,0x48,0x35,0x35,0x35,0x1d,0x1d
db 0x1d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x00,0x00
db 0x00,0x00,0x00,0x00,0x1d,0x1d,0x1d,0x27,0x27,0x27
db 0x27,0x27,0x27,0x1d,0x1d,0x1d,0x0f,0x0f,0x0f,0x06
db 0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00
; did any mouse button changed its state?
or bl, bl
jz .check_position
; yes it did, is that the first button of all pressed down?
or cl, cl
jnz .check_buttons_released
; yes it is, activate window user is pointing at, if needed
call mouse._.activate_sys_window_under_cursor
; NOTE: this code wouldn't be necessary if we knew window did
; already redraw itself after call above
or eax, eax
jz @f
and [mouse.state.buttons], 0
jmp .exit
; is there any system button under cursor?
@@:
call mouse._.find_sys_button_under_cursor
or eax, eax
jz .check_buttons_released
; yes there is, activate it and exit
mov [mouse.active_sys_button.pbid], eax
mov [mouse.active_sys_button.coord], ebx
mov cl, [mouse.state.buttons]
mov [mouse.active_sys_button.buttons], cl
call sys_button_activate_handler
jmp .exit
.check_buttons_released:
cmp [mouse.state.buttons], 0
jnz .buttons_changed
; did we press some button earlier?
cmp [mouse.active_sys_button.pbid], 0
je .buttons_changed
; yes we did, deactivate it
xor eax, eax
xchg eax, [mouse.active_sys_button.pbid]
mov ebx, [mouse.active_sys_button.coord]
mov cl, [mouse.active_sys_button.buttons]
push eax ebx
call sys_button_deactivate_handler
pop edx ecx
; is the button under cursor the one we deactivated?
call mouse._.find_sys_button_under_cursor
cmp eax, ecx
jne .exit
cmp ebx, edx
jne .exit
; yes it is, perform associated action
mov cl, [mouse.active_sys_button.buttons]
call sys_button_perform_handler
jmp .exit
.buttons_changed:
test byte[esp], mouse.LEFT_BUTTON_FLAG
jz @f
mov eax, [esp + 4]
call .call_left_button_handler
@@:
test byte[esp], mouse.RIGHT_BUTTON_FLAG
jz @f
mov eax, [esp + 4]
call .call_right_button_handler
@@:
test byte[esp], mouse.MIDDLE_BUTTON_FLAG
jz .check_position
mov eax, [esp + 4]
call .call_middle_button_handler
.check_position:
movzx eax, word[MOUSE_X]
movzx ebx, word[MOUSE_Y]
cmp eax, [mouse.state.pos.x]
jne .position_changed
cmp ebx, [mouse.state.pos.y]
je .exit
.position_changed:
xchg eax, [mouse.state.pos.x]
xchg ebx, [mouse.state.pos.y]
call mouse._.move_handler
.exit:
add esp, 8
pop ebx eax
ret
.call_left_button_handler:
test eax, mouse.LEFT_BUTTON_FLAG
jnz mouse._.left_button_press_handler
jmp mouse._.left_button_release_handler
.call_right_button_handler:
test eax, mouse.RIGHT_BUTTON_FLAG
jnz mouse._.right_button_press_handler
jmp mouse._.right_button_release_handler
.call_middle_button_handler:
test eax, mouse.MIDDLE_BUTTON_FLAG
jnz mouse._.middle_button_press_handler
jmp mouse._.middle_button_release_handler
;==============================================================================
;///// private functions //////////////////////////////////////////////////////
;==============================================================================
uglobal
mouse.state:
.pos POINT
.buttons db ?
; NOTE: since there's no unique and lifetime-constant button identifiers,
; we're using two dwords to identify each of them:
; * pbid - process slot (high 8 bits) and button id (low 24 bits) pack
; * coord - left (high 16 bits) and top (low 16 bits) coordinates pack
align 4
mouse.active_sys_button:
.pbid dd ?
.coord dd ?
.buttons db ?
align 4
mouse.active_sys_window:
.pslot dd ?
.old_box BOX
.new_box BOX
.delta POINT
.last_ticks dd ?
.action db ?
endg endg
align 4
;------------------------------------------------------------------------------
mouse._.left_button_press_handler: ;///////////////////////////////////////////
;------------------------------------------------------------------------------
;? Called when left mouse button has been pressed down
;------------------------------------------------------------------------------
test [mouse.state.buttons], not mouse.LEFT_BUTTON_FLAG
jnz .exit
call mouse._.find_sys_window_under_cursor
call mouse._.check_sys_window_actions
mov [mouse.active_sys_window.action], al
or eax, eax
jz .exit
xchg eax, edx
test dl, mouse.WINDOW_MOVE_FLAG
jz @f
mov eax, [timer_ticks]
mov ebx, eax
xchg ebx, [mouse.active_sys_window.last_ticks]
sub eax, ebx
cmp eax, 50
jg @f
mov [mouse.active_sys_window.last_ticks], 0
call sys_window_maximize_handler
jmp .exit
@@:
test [edi + WDATA.fl_wstate], WSTATE_MAXIMIZED
jnz .exit
mov [mouse.active_sys_window.pslot], esi
lea eax, [edi + WDATA.box]
mov ebx, mouse.active_sys_window.old_box
mov ecx, sizeof.BOX
call memmove
mov ebx, mouse.active_sys_window.new_box
call memmove
test edx, mouse.WINDOW_MOVE_FLAG
jz @f
call .calculate_n_delta
call .calculate_w_delta
jmp .call_window_handler
@@:
test dl, mouse.WINDOW_RESIZE_W_FLAG
jz @f
call .calculate_w_delta
@@:
test dl, mouse.WINDOW_RESIZE_S_FLAG
jz @f
call .calculate_s_delta
@@:
test dl, mouse.WINDOW_RESIZE_E_FLAG
jz .call_window_handler
call .calculate_e_delta
.call_window_handler:
mov eax, mouse.active_sys_window.old_box
call sys_window_start_moving_handler
.exit:
ret
.calculate_n_delta:
mov eax, [mouse.state.pos.y]
sub eax, [mouse.active_sys_window.old_box.top]
mov [mouse.active_sys_window.delta.y], eax
ret
.calculate_w_delta:
mov eax, [mouse.state.pos.x]
sub eax, [mouse.active_sys_window.old_box.left]
mov [mouse.active_sys_window.delta.x], eax
ret
.calculate_s_delta:
mov eax, [mouse.active_sys_window.old_box.top]
add eax, [mouse.active_sys_window.old_box.height]
sub eax, [mouse.state.pos.y]
mov [mouse.active_sys_window.delta.y], eax
ret
.calculate_e_delta:
mov eax, [mouse.active_sys_window.old_box.left]
add eax, [mouse.active_sys_window.old_box.width]
sub eax, [mouse.state.pos.x]
mov [mouse.active_sys_window.delta.x], eax
ret
align 4
;------------------------------------------------------------------------------
mouse._.left_button_release_handler: ;/////////////////////////////////////////
;------------------------------------------------------------------------------
;? Called when left mouse button has been released
;------------------------------------------------------------------------------
xor esi, esi
xchg esi, [mouse.active_sys_window.pslot]
or esi, esi
jz .exit
mov eax, esi
shl eax, 5
add eax, window_data + WDATA.box
mov ebx, mouse.active_sys_window.old_box
mov ecx, sizeof.BOX
call memmove
mov eax, mouse.active_sys_window.old_box
mov ebx, mouse.active_sys_window.new_box
call sys_window_end_moving_handler
.exit:
and [mouse.active_sys_window.action], 0
ret
align 4
;------------------------------------------------------------------------------
mouse._.right_button_press_handler: ;//////////////////////////////////////////
;------------------------------------------------------------------------------
;? Called when right mouse button has been pressed down
;------------------------------------------------------------------------------
test [mouse.state.buttons], not mouse.RIGHT_BUTTON_FLAG
jnz .exit
call mouse._.find_sys_window_under_cursor
call mouse._.check_sys_window_actions
test al, mouse.WINDOW_MOVE_FLAG
jz .exit
call sys_window_rollup_handler
.exit:
ret
align 4
;------------------------------------------------------------------------------
mouse._.right_button_release_handler: ;////////////////////////////////////////
;------------------------------------------------------------------------------
;? Called when right mouse button has been released
;------------------------------------------------------------------------------
ret
align 4
;------------------------------------------------------------------------------
mouse._.middle_button_press_handler: ;/////////////////////////////////////////
;------------------------------------------------------------------------------
;? Called when middle mouse button has been pressed down
;------------------------------------------------------------------------------
ret
align 4
;------------------------------------------------------------------------------
mouse._.middle_button_release_handler: ;///////////////////////////////////////
;------------------------------------------------------------------------------
;? Called when middle mouse button has been released
;------------------------------------------------------------------------------
ret
align 4
;------------------------------------------------------------------------------
mouse._.move_handler: ;////////////////////////////////////////////////////////
;------------------------------------------------------------------------------
;? Called when cursor has been moved
;------------------------------------------------------------------------------
;> eax = old x coord
;> ebx = old y coord
;------------------------------------------------------------------------------
cmp [mouse.active_sys_button.pbid], 0
jnz .exit
mov esi, [mouse.active_sys_window.pslot]
or esi, esi
jz .exit
mov eax, mouse.active_sys_window.new_box
mov ebx, mouse.active_sys_window.old_box
mov ecx, sizeof.BOX
call memmove
mov dl, [mouse.active_sys_window.action]
test dl, mouse.WINDOW_MOVE_FLAG
jz .check_resize_w
mov eax, [mouse.state.pos.x]
sub eax, [mouse.active_sys_window.delta.x]
mov [mouse.active_sys_window.new_box.left], eax
mov eax, [mouse.state.pos.y]
sub eax, [mouse.active_sys_window.delta.y]
mov [mouse.active_sys_window.new_box.top], eax
mov eax, [mouse.active_sys_window.new_box.left]
or eax, eax
jge @f
xor eax, eax
mov [mouse.active_sys_window.new_box.left], eax
@@:
add eax, [mouse.active_sys_window.new_box.width]
cmp eax, [Screen_Max_X]
jl @f
sub eax, [Screen_Max_X]
sub [mouse.active_sys_window.new_box.left], eax
@@:
mov eax, [mouse.active_sys_window.new_box.top]
or eax, eax
jge @f
xor eax, eax
mov [mouse.active_sys_window.new_box.top], eax
@@:
add eax, [mouse.active_sys_window.new_box.height]
cmp eax, [Screen_Max_Y]
jle .call_window_handler
sub eax, [Screen_Max_Y]
sub [mouse.active_sys_window.new_box.top], eax
jmp .call_window_handler
.check_resize_w:
test dl, mouse.WINDOW_RESIZE_W_FLAG
jz .check_resize_s
mov eax, [mouse.state.pos.x]
sub eax, [mouse.active_sys_window.delta.x]
mov [mouse.active_sys_window.new_box.left], eax
sub eax, [mouse.active_sys_window.old_box.left]
sub [mouse.active_sys_window.new_box.width], eax
mov eax, [mouse.active_sys_window.new_box.width]
sub eax, 127
jge @f
add [mouse.active_sys_window.new_box.left], eax
mov [mouse.active_sys_window.new_box.width], 127
@@:
mov eax, [mouse.active_sys_window.new_box.left]
or eax, eax
jge .check_resize_s
add [mouse.active_sys_window.new_box.width], eax
xor eax, eax
mov [mouse.active_sys_window.new_box.left], eax
.check_resize_s:
test dl, mouse.WINDOW_RESIZE_S_FLAG
jz .check_resize_e
mov eax, [mouse.state.pos.y]
add eax, [mouse.active_sys_window.delta.y]
sub eax, [mouse.active_sys_window.old_box.top]
mov [mouse.active_sys_window.new_box.height], eax
push eax
mov edi, esi
shl edi, 5
add edi, window_data
call window._.get_rolledup_height
mov ecx, eax
pop eax
mov eax, [mouse.active_sys_window.new_box.height]
cmp eax, ecx
jge @f
mov eax, ecx
mov [mouse.active_sys_window.new_box.height], eax
@@:
add eax, [mouse.active_sys_window.new_box.top]
cmp eax, [Screen_Max_Y]
jle .check_resize_e
sub eax, [Screen_Max_Y]
neg eax
add [mouse.active_sys_window.new_box.height], eax
mov ecx, [Screen_Max_Y]
cmp ecx, eax
jge .check_resize_e
mov [mouse.active_sys_window.new_box.height], ecx
.check_resize_e:
test dl, mouse.WINDOW_RESIZE_E_FLAG
jz .call_window_handler
mov eax, [mouse.state.pos.x]
add eax, [mouse.active_sys_window.delta.x]
sub eax, [mouse.active_sys_window.old_box.left]
mov [mouse.active_sys_window.new_box.width], eax
mov eax, [mouse.active_sys_window.new_box.width]
cmp eax, 127
jge @f
mov eax, 127
mov [mouse.active_sys_window.new_box.width], eax
@@:
add eax, [mouse.active_sys_window.new_box.left]
cmp eax, [Screen_Max_X]
jle .call_window_handler
sub eax, [Screen_Max_X]
neg eax
add [mouse.active_sys_window.new_box.width], eax
mov ecx, [Screen_Max_X]
cmp ecx, eax
jge .call_window_handler
mov [mouse.active_sys_window.new_box.width], ecx
.call_window_handler:
mov eax, mouse.active_sys_window.old_box
mov ebx, mouse.active_sys_window.new_box
push esi
mov esi, mouse.active_sys_window.old_box
mov edi, mouse.active_sys_window.new_box
mov ecx, sizeof.BOX / 4
repe
cmpsd
pop esi
je .exit
mov [mouse.active_sys_window.last_ticks], 0
call sys_window_moving_handler
.exit:
ret
align 4
;------------------------------------------------------------------------------
mouse._.find_sys_window_under_cursor: ;////////////////////////////////////////
;------------------------------------------------------------------------------
;? Find system window object which is currently visible on screen and has
;? mouse cursor within its bounds
;------------------------------------------------------------------------------
;< esi = process slot
;< edi = pointer to WDATA struct
;------------------------------------------------------------------------------
mov esi, [Screen_Max_X]
inc esi
imul esi, [mouse.state.pos.y]
add esi, [_WinMapAddress]
add esi, [mouse.state.pos.x]
movzx esi, byte[esi]
mov edi, esi
shl edi, 5
add edi, window_data
ret
align 4
;------------------------------------------------------------------------------
mouse._.activate_sys_window_under_cursor: ;////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
; activate and redraw window under cursor (if necessary)
call mouse._.find_sys_window_under_cursor
movzx esi, word[WIN_STACK + esi * 2]
lea esi, [WIN_POS + esi * 2]
jmp waredraw
align 4
;------------------------------------------------------------------------------
mouse._.find_sys_button_under_cursor: ;////////////////////////////////////////
;------------------------------------------------------------------------------
;? Find system button object which is currently visible on screen and has
;? mouse cursor within its bounds
;------------------------------------------------------------------------------
;< eax = pack[8(process slot), 24(button id)] or 0
;< ebx = pack[16(button x coord), 16(button y coord)]
;------------------------------------------------------------------------------
push ecx edx esi edi
call mouse._.find_sys_window_under_cursor
mov edx, esi
; check if any process button contains cursor
mov eax, [BTN_ADDR]
mov ecx, [eax]
imul esi, ecx, SYS_BUTTON.sizeof
add esi, eax
inc ecx
add esi, SYS_BUTTON.sizeof
.next_button:
dec ecx
jz .not_found
add esi, -SYS_BUTTON.sizeof
; does it belong to our process?
cmp dx, [esi + SYS_BUTTON.pslot]
jne .next_button
; does it contain cursor coordinates?
mov eax, [mouse.state.pos.x]
sub eax, [edi + WDATA.box.left]
sub ax, [esi + SYS_BUTTON.left]
jl .next_button
sub ax, [esi + SYS_BUTTON.width]
jge .next_button
mov eax, [mouse.state.pos.y]
sub eax, [edi + WDATA.box.top]
sub ax, [esi + SYS_BUTTON.top]
jl .next_button
sub ax, [esi + SYS_BUTTON.height]
jge .next_button
; okay, return it
shl edx, 24
mov eax, dword[esi + SYS_BUTTON.id_hi - 2]
mov ax, [esi + SYS_BUTTON.id_lo]
and eax, 0x0ffffff
or eax, edx
mov ebx, dword[esi + SYS_BUTTON.left - 2]
mov bx, [esi + SYS_BUTTON.top]
jmp .exit
.not_found:
xor eax, eax
xor ebx, ebx
.exit:
pop edi esi edx ecx
ret
align 4
;------------------------------------------------------------------------------
mouse._.check_sys_window_actions: ;////////////////////////////////////////////
;------------------------------------------------------------------------------
;? <description>
;------------------------------------------------------------------------------
;< eax = action flags or 0
;------------------------------------------------------------------------------
; is window movable?
test byte[edi + WDATA.cl_titlebar + 3], 0x01
jnz .no_action
mov eax, [mouse.state.pos.x]
mov ebx, [mouse.state.pos.y]
sub eax, [edi + WDATA.box.left]
sub ebx, [edi + WDATA.box.top]
; is there a window titlebar under cursor?
push eax
call window._.get_titlebar_height
cmp ebx, eax
pop eax
jl .move_action
; no there isn't, can it be resized then?
mov dl, [edi + WDATA.fl_wstyle]
and dl, 0x0f
; NOTE: dangerous optimization, revise if window types changed;
; this currently implies only types 2 and 3 could be resized
test dl, 2
jz .no_action
mov ecx, [edi + WDATA.box.width]
add ecx, -window.BORDER_SIZE
mov edx, [edi + WDATA.box.height]
add edx, -window.BORDER_SIZE
; is it rolled up?
test [edi + WDATA.fl_wstate], WSTATE_ROLLEDUP
jnz .resize_w_or_e_action
cmp eax, window.BORDER_SIZE
jl .resize_w_action
cmp eax, ecx
jg .resize_e_action
cmp ebx, edx
jle .no_action
.resize_s_action:
cmp eax, window.BORDER_SIZE + 10
jl .resize_sw_action
add ecx, -10
cmp eax, ecx
jge .resize_se_action
mov eax, mouse.WINDOW_RESIZE_S_FLAG
jmp .exit
.resize_w_or_e_action:
cmp eax, window.BORDER_SIZE + 10
jl .resize_w_action.direct
add ecx, -10
cmp eax, ecx
jg .resize_e_action.direct
jmp .no_action
.resize_w_action:
add edx, -10
cmp ebx, edx
jge .resize_sw_action
.resize_w_action.direct:
mov eax, mouse.WINDOW_RESIZE_W_FLAG
jmp .exit
.resize_e_action:
add edx, -10
cmp ebx, edx
jge .resize_se_action
.resize_e_action.direct:
mov eax, mouse.WINDOW_RESIZE_E_FLAG
jmp .exit
.resize_sw_action:
mov eax, mouse.WINDOW_RESIZE_SW_FLAG
jmp .exit
.resize_se_action:
mov eax, mouse.WINDOW_RESIZE_SE_FLAG
jmp .exit
.move_action:
mov eax, mouse.WINDOW_MOVE_FLAG
jmp .exit
.no_action:
xor eax, eax
.exit:
ret

View File

@@ -0,0 +1,250 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;;
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
;; Distributed under terms of the GNU General Public License ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision: 2288 $
iglobal
align 4
mousepointer:
db 0x00,0x00,0x00,0x74,0x74,0x74,0x6e,0x6e,0x6e,0x6f
db 0x6f,0x6f,0x71,0x71,0x71,0x75,0x75,0x75,0x79,0x79
db 0x79,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x80,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x00,0x00,0x00,0x63,0x63,0x63,0x63,0x63,0x63
db 0x66,0x66,0x66,0x6c,0x6c,0x6c,0x72,0x72,0x72,0x78
db 0x78,0x78,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc0
db 0xc0,0xc0,0x00,0x00,0x00,0x54,0x54,0x54,0x57,0x57
db 0x57,0x5f,0x5f,0x5f,0x68,0x68,0x68,0x71,0x71,0x71
db 0x77,0x77,0x77,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xc0,0xc0,0xc0
db 0xc0,0xc0,0xc0,0x00,0x00,0x00,0x47,0x47,0x47,0x50
db 0x50,0x50,0x5b,0x5b,0x5b,0x67,0x67,0x67,0x70,0x70
db 0x70,0x77,0x77,0x77,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0xff,0xff,0xff,0xc0,0xc0
db 0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x3f,0x3f,0x3f
db 0x4b,0x4b,0x4b,0x59,0x59,0x59,0x66,0x66,0x66,0x70
db 0x70,0x70,0x77,0x77,0x77,0x7c,0x7c,0x7c,0x7e,0x7e
db 0x7e,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x80,0x80,0xff,0xff,0xff,0xc0,0xc0,0xc0,0xc0
db 0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x3a,0x3a
db 0x3a,0x49,0x49,0x49,0x59,0x59,0x59,0x66,0x66,0x66
db 0x70,0x70,0x70,0x77,0x77,0x77,0x7c,0x7c,0x7c,0x7e
db 0x7e,0x7e,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xc0,0xc0
db 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x39
db 0x39,0x39,0x49,0x49,0x49,0x59,0x59,0x59,0x66,0x66
db 0x66,0x71,0x71,0x71,0x78,0x78,0x78,0x7c,0x7c,0x7c
db 0x7e,0x7e,0x7e,0x80,0x80,0x80,0x80,0x80,0x80,0xff
db 0xff,0xff,0xff,0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0
db 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00,0x00
db 0x39,0x39,0x39,0x4a,0x4a,0x4a,0x5a,0x5a,0x5a,0x68
db 0x68,0x68,0x72,0x72,0x72,0x79,0x79,0x79,0x7d,0x7d
db 0x7d,0x7f,0x7f,0x7f,0x80,0x80,0x80,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xc0,0xc0,0xc0,0xc0
db 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00,0x00
db 0x00,0x3c,0x3c,0x3c,0x4e,0x4e,0x4e,0x5e,0x5e,0x5e
db 0x6b,0x6b,0x6b,0x75,0x75,0x75,0x7a,0x7a,0x7a,0x7e
db 0x7e,0x7e,0x80,0x80,0x80,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0
db 0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0xc0,0x00
db 0x00,0x00,0x43,0x43,0x43,0x55,0x55,0x55,0x64,0x64
db 0x64,0x70,0x70,0x70,0x78,0x78,0x78,0x7d,0x7d,0x7d
db 0x80,0x80,0x80,0xff,0xff,0xff,0xff,0xff,0xff,0xc0
db 0xc0,0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x4e,0x4e,0x4e,0x5f,0x5f,0x5f,0x6d
db 0x6d,0x6d,0x76,0x76,0x76,0x7c,0x7c,0x7c,0x80,0x80
db 0x80,0xff,0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00
db 0xff,0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x14
db 0x14,0x14,0x1b,0x1b,0x1b,0x29,0x29,0x29,0x3a,0x3a
db 0x3a,0x4c,0x4c,0x4c,0x5d,0x5d,0x5d,0x6c,0x6c,0x6c
db 0x75,0x75,0x75,0x7b,0x7b,0x7b,0x80,0x80,0x80,0xc0
db 0xc0,0xc0,0x00,0x00,0x00,0x2f,0x2f,0x2f,0x80,0x80
db 0x80,0xff,0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00
db 0x21,0x21,0x21,0x2e,0x2e,0x2e,0x40,0x40,0x40,0x52
db 0x52,0x52,0x62,0x62,0x62,0x6f,0x6f,0x6f,0x77,0x77
db 0x77,0x7c,0x7c,0x7c,0x80,0x80,0x80,0x00,0x00,0x00
db 0x47,0x47,0x47,0x3b,0x3b,0x3b,0x80,0x80,0x80,0xff
db 0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x25,0x25
db 0x25,0x30,0x30,0x30,0x42,0x42,0x42,0x54,0x54,0x54
db 0x64,0x64,0x64,0x70,0x70,0x70,0x78,0x78,0x78,0x7d
db 0x7d,0x7d,0x00,0x00,0x00,0x62,0x62,0x62,0x52,0x52
db 0x52,0x4a,0x4a,0x4a,0x43,0x43,0x43,0x80,0x80,0x80
db 0xff,0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x33
db 0x33,0x33,0x42,0x42,0x42,0x54,0x54,0x54,0x64,0x64
db 0x64,0x71,0x71,0x71,0x79,0x79,0x79,0x7d,0x7d,0x7d
db 0x72,0x72,0x72,0x6b,0x6b,0x6b,0x5f,0x5f,0x5f,0x5a
db 0x5a,0x5a,0x54,0x54,0x54,0x80,0x80,0x80,0xff,0xff
db 0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x35,0x35,0x35
db 0x41,0x41,0x41,0x53,0x53,0x53,0x63,0x63,0x63,0x70
db 0x70,0x70,0x78,0x78,0x78,0x7d,0x7d,0x7d,0x77,0x77
db 0x77,0x73,0x73,0x73,0x6c,0x6c,0x6c,0x68,0x68,0x68
db 0x62,0x62,0x62,0x5a,0x5a,0x5a,0x80,0x80,0x80,0xff
db 0xff,0xff,0xc0,0xc0,0xc0,0x00,0x00,0x00,0x41,0x41
db 0x41,0x52,0x52,0x52,0x62,0x62,0x62,0x6f,0x6f,0x6f
db 0x78,0x78,0x78,0x7d,0x7d,0x7d,0x7b,0x7b,0x7b,0x79
db 0x79,0x79,0x74,0x74,0x74,0x72,0x72,0x72,0x6e,0x6e
db 0x6e,0x66,0x66,0x66,0x80,0x80,0x80,0xc0,0xc0,0xc0
db 0xc0,0xc0,0xc0,0x00,0x00,0x00,0x44,0x44,0x44,0x52
db 0x52,0x52,0x62,0x62,0x62,0x6e,0x6e,0x6e,0x77,0x77
db 0x77,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x7c,0x7c,0x7c
db 0x7a,0x7a,0x7a,0x79,0x79,0x79,0x75,0x75,0x75,0x6f
db 0x6f,0x6f,0x65,0x65,0x65,0x00,0x00,0x00,0x00,0x00
db 0x00,0x48,0x48,0x48,0x4b,0x4b,0x4b,0x56,0x56,0x56
db 0x65,0x65,0x65,0x70,0x70,0x70,0x78,0x78,0x78,0x7d
db 0x7d,0x7d,0x80,0x80,0x80,0x7f,0x7f,0x7f,0x7e,0x7e
db 0x7e,0x7d,0x7d,0x7d,0x7a,0x7a,0x7a,0x76,0x76,0x76
db 0x6f,0x6f,0x6f,0x65,0x65,0x65,0x5c,0x5c,0x5c,0x56
db 0x56,0x56,0x58,0x58,0x58,0x60,0x60,0x60,0x6b,0x6b
db 0x6b,0x73,0x73,0x73,0x7a,0x7a,0x7a,0x7d,0x7d,0x7d
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x7f
db 0x7f,0x7f,0x7d,0x7d,0x7d,0x7a,0x7a,0x7a,0x76,0x76
db 0x76,0x70,0x70,0x70,0x6a,0x6a,0x6a,0x66,0x66,0x66
db 0x66,0x66,0x66,0x6c,0x6c,0x6c,0x72,0x72,0x72,0x78
db 0x78,0x78,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x7f,0x7f,0x7f,0x7d,0x7d,0x7d,0x7b,0x7b,0x7b,0x77
db 0x77,0x77,0x73,0x73,0x73,0x71,0x71,0x71,0x71,0x71
db 0x71,0x74,0x74,0x74,0x78,0x78,0x78,0x7b,0x7b,0x7b
db 0x7d,0x7d,0x7d,0x7f,0x7f,0x7f,0x80,0x80,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x7f,0x7f,0x7f,0x7d,0x7d,0x7d,0x7c,0x7c,0x7c
db 0x7a,0x7a,0x7a,0x78,0x78,0x78,0x78,0x78,0x78,0x7a
db 0x7a,0x7a,0x7c,0x7c,0x7c,0x7e,0x7e,0x7e,0x7f,0x7f
db 0x7f,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80
db 0x80,0x80,0x7f,0x7f,0x7f,0x7e,0x7e,0x7e,0x7e,0x7e
db 0x7e,0x7d,0x7d,0x7d,0x7d,0x7d,0x7d,0x7e,0x7e,0x7e
db 0x7e,0x7e,0x7e,0x7f,0x7f,0x7f,0x80,0x80,0x80,0x80
db 0x80,0x80
mousepointer1:
db 0xff,0xff,0xff,0x06,0x06,0x06,0x0a,0x0a
db 0x0a,0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0xff,0xff,0xff,0xff,0xff,0xff,0x19,0x19,0x19,0x16
db 0x16,0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x2e,0x2e,0x2e
db 0x23,0x23,0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x3f,0x3f
db 0x3f,0x29,0x29,0x29,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x47
db 0x47,0x47,0x2c,0x2c,0x2c,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0x48,0x48,0x48,0x2c,0x2c,0x2c,0x16,0x16,0x16,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0x48,0x48,0x48,0x2c,0x2c,0x2c,0x16,0x16,0x16
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0x48,0x48,0x48,0x2c,0x2c,0x2c,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0x48,0x48,0x48,0x2c,0x2c,0x2c,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0x47,0x47,0x47,0x29,0x29,0x29
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0x40,0x40,0x40,0x23,0x23
db 0x23,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xaa,0xaa,0xaa,0x9f,0x9f,0x9f,0x8c,0x8c,0x8c
db 0x70,0x70,0x70,0x4f,0x4f,0x4f,0x30,0x30,0x30,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x8f,0x8f,0x8f
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0xff,0x9c,0x9c,0x9c,0x87,0x87,0x87,0x6c,0x6c
db 0x6c,0x4f,0x4f,0x4f,0x32,0x32,0x32,0x19,0x19,0x19
db 0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff
db 0xff,0xff,0x69,0x69,0x69,0x84,0x84,0x84,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0x92,0x92,0x92,0x79,0x79,0x79,0x59,0x59,0x59,0x3c
db 0x3c,0x3c,0x24,0x24,0x24,0x11,0x11,0x11,0x00,0x00
db 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0x37,0x37,0x37
db 0x5d,0x5d,0x5d,0x70,0x70,0x70,0x76,0x76,0x76,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0xff,0x75,0x75,0x75,0x51,0x51,0x51,0x31,0x31,0x31
db 0x19,0x19,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x16,0x16,0x16,0x2d,0x2d,0x2d,0x49,0x49
db 0x49,0x53,0x53,0x53,0x54,0x54,0x54,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x78
db 0x78,0x78,0x54,0x54,0x54,0x30,0x30,0x30,0x16,0x16
db 0x16,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x0f,0x0f,0x0f,0x1f,0x1f,0x1f,0x30,0x30,0x30,0x33
db 0x33,0x33,0x33,0x33,0x33,0x3b,0x3b,0x3b,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
db 0x62,0x62,0x62,0x3b,0x3b,0x3b,0x1c,0x1c,0x1c,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x08
db 0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x24,0x24,0x24,0xff,0xff,0xff,0xff
db 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x6e,0x6e
db 0x6e,0x48,0x48,0x48,0x25,0x25,0x25,0x0e,0x0e,0x0e
db 0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0x04,0x00
db 0x00,0x00,0x0a,0x0a,0x0a,0x09,0x09,0x09,0x00,0x00
db 0x00,0x00,0x00,0x00,0x29,0x29,0x29,0xff,0xff,0xff
db 0xff,0xff,0xff,0x7c,0x7c,0x7c,0x71,0x71,0x71,0x50
db 0x50,0x50,0x2b,0x2b,0x2b,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x02,0x02,0x02,0x04,0x04,0x04,0x00
db 0x00,0x00,0x00,0x00,0x00,0x36,0x36,0x36,0x56,0x56
db 0x56,0x69,0x69,0x69,0x64,0x64,0x64,0x4a,0x4a,0x4a
db 0x28,0x28,0x28,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x05,0x05,0x05
db 0x00,0x00,0x00,0x21,0x21,0x21,0x39,0x39,0x39,0x49
db 0x49,0x49,0x48,0x48,0x48,0x35,0x35,0x35,0x1d,0x1d
db 0x1d,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x00,0x00
db 0x00,0x00,0x00,0x00,0x1d,0x1d,0x1d,0x27,0x27,0x27
db 0x27,0x27,0x27,0x1d,0x1d,0x1d,0x0f,0x0f,0x0f,0x06
db 0x06,0x06,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
db 0x00,0x00,0x00,0x00
endg

View File

@@ -68,10 +68,10 @@ ends
struct SKIN_BUTTONS struct SKIN_BUTTONS
type dd ? type dd ?
; pos: ; position
left dw ? left dw ?
top dw ? top dw ?
; size: ; size
width dw ? width dw ?
height dw ? height dw ?
ends ends
@@ -83,126 +83,131 @@ struct SKIN_BITMAPS
ends ends
load_default_skin: load_default_skin:
mov [_skinh],22 mov [_skinh], 22
mov ebx,_skin_file_default mov ebx, _skin_file_default
call read_skin_file call read_skin_file
ret ret
parse_skin_data: parse_skin_data:
mov ebp,skin_data mov ebp, skin_data
cmp [ebp+SKIN_HEADER.ident],'SKIN' cmp [ebp+SKIN_HEADER.ident], 'SKIN'
jne .exit jne .exit
mov edi,skin_udata mov edi, skin_udata
mov ecx,(skin_udata.end-skin_udata)/4 mov ecx, (skin_udata.end-skin_udata)/4
xor eax,eax xor eax, eax
cld cld
rep stosd rep stosd
mov ebx,[ebp+SKIN_HEADER.params] mov ebx, [ebp+SKIN_HEADER.params]
add ebx,skin_data add ebx, skin_data
mov eax,[ebx+SKIN_PARAMS.skin_height] mov eax, [ebx+SKIN_PARAMS.skin_height]
mov [_skinh],eax mov [_skinh], eax
mov eax,[ebx+SKIN_PARAMS.colors.inner] mov eax, [ebx+SKIN_PARAMS.colors.inner]
mov [skin_active.colors.inner],eax mov [skin_active.colors.inner], eax
mov eax,[ebx+SKIN_PARAMS.colors.outer] mov eax, [ebx+SKIN_PARAMS.colors.outer]
mov [skin_active.colors.outer],eax mov [skin_active.colors.outer], eax
mov eax,[ebx+SKIN_PARAMS.colors.frame] mov eax, [ebx+SKIN_PARAMS.colors.frame]
mov [skin_active.colors.frame],eax mov [skin_active.colors.frame], eax
mov eax,[ebx+SKIN_PARAMS.colors_1.inner] mov eax, [ebx+SKIN_PARAMS.colors_1.inner]
mov [skin_inactive.colors.inner],eax mov [skin_inactive.colors.inner], eax
mov eax,[ebx+SKIN_PARAMS.colors_1.outer] mov eax, [ebx+SKIN_PARAMS.colors_1.outer]
mov [skin_inactive.colors.outer],eax mov [skin_inactive.colors.outer], eax
mov eax,[ebx+SKIN_PARAMS.colors_1.frame] mov eax, [ebx+SKIN_PARAMS.colors_1.frame]
mov [skin_inactive.colors.frame],eax mov [skin_inactive.colors.frame], eax
lea esi,[ebx+SKIN_PARAMS.dtp.data] lea esi, [ebx+SKIN_PARAMS.dtp.data]
mov edi,common_colours mov edi, common_colours
mov ecx,[ebx+SKIN_PARAMS.dtp.size] mov ecx, [ebx+SKIN_PARAMS.dtp.size]
and ecx,127 and ecx, 127
rep movsb rep movsb
mov eax,dword[ebx+SKIN_PARAMS.margin.right] mov eax, dword[ebx+SKIN_PARAMS.margin.right]
mov dword[_skinmargins+0],eax mov dword[_skinmargins+0], eax
mov eax,dword[ebx+SKIN_PARAMS.margin.bottom] mov eax, dword[ebx+SKIN_PARAMS.margin.bottom]
mov dword[_skinmargins+4],eax mov dword[_skinmargins+4], eax
mov ebx,[ebp+SKIN_HEADER.bitmaps] mov ebx, [ebp+SKIN_HEADER.bitmaps]
add ebx,skin_data add ebx, skin_data
.lp1: cmp dword[ebx],0 .lp1:
cmp dword[ebx], 0
je .end_bitmaps je .end_bitmaps
movzx eax,[ebx+SKIN_BITMAPS.kind] movzx eax, [ebx+SKIN_BITMAPS.kind]
movzx ecx,[ebx+SKIN_BITMAPS.type] movzx ecx, [ebx+SKIN_BITMAPS.type]
dec eax dec eax
jnz .not_left jnz .not_left
xor eax,eax xor eax, eax
mov edx,skin_active.left.data mov edx, skin_active.left.data
or ecx,ecx or ecx, ecx
jnz @f jnz @f
mov edx,skin_inactive.left.data mov edx, skin_inactive.left.data
@@: jmp .next_bitmap @@:
jmp .next_bitmap
.not_left: .not_left:
dec eax dec eax
jnz .not_oper jnz .not_oper
mov esi,[ebx+SKIN_BITMAPS.data] mov esi, [ebx+SKIN_BITMAPS.data]
add esi,skin_data add esi, skin_data
mov eax,[esi+0] mov eax, [esi+0]
neg eax neg eax
mov edx,skin_active.oper.data mov edx, skin_active.oper.data
or ecx,ecx or ecx, ecx
jnz @f jnz @f
mov edx,skin_inactive.oper.data mov edx, skin_inactive.oper.data
@@: jmp .next_bitmap @@:
jmp .next_bitmap
.not_oper: .not_oper:
dec eax dec eax
jnz .not_base jnz .not_base
mov eax,[skin_active.left.width] mov eax, [skin_active.left.width]
mov edx,skin_active.base.data mov edx, skin_active.base.data
or ecx,ecx or ecx, ecx
jnz @f jnz @f
mov eax,[skin_inactive.left.width] mov eax, [skin_inactive.left.width]
mov edx,skin_inactive.base.data mov edx, skin_inactive.base.data
@@: jmp .next_bitmap @@:
jmp .next_bitmap
.not_base: .not_base:
add ebx,8 add ebx, 8
jmp .lp1 jmp .lp1
.next_bitmap: .next_bitmap:
mov ecx,[ebx+SKIN_BITMAPS.data] mov ecx, [ebx+SKIN_BITMAPS.data]
add ecx,skin_data add ecx, skin_data
mov [edx+4],eax mov [edx+4], eax
mov eax,[ecx+0] mov eax, [ecx+0]
mov [edx+8],eax mov [edx+8], eax
add ecx,8 add ecx, 8
mov [edx+0],ecx mov [edx+0], ecx
add ebx,8 add ebx, 8
jmp .lp1 jmp .lp1
.end_bitmaps: .end_bitmaps:
mov ebx,[ebp+SKIN_HEADER.buttons] mov ebx, [ebp+SKIN_HEADER.buttons]
add ebx,skin_data add ebx, skin_data
.lp2: cmp dword[ebx],0 .lp2:
cmp dword[ebx], 0
je .end_buttons je .end_buttons
mov eax,[ebx+SKIN_BUTTONS.type] mov eax, [ebx+SKIN_BUTTONS.type]
dec eax dec eax
jnz .not_close jnz .not_close
mov edx,skin_btn_close mov edx, skin_btn_close
jmp .next_button jmp .next_button
.not_close: .not_close:
dec eax dec eax
jnz .not_minimize jnz .not_minimize
mov edx,skin_btn_minimize mov edx, skin_btn_minimize
jmp .next_button jmp .next_button
.not_minimize: .not_minimize:
add ebx,12 add ebx, 12
jmp .lp2 jmp .lp2
.next_button: .next_button:
movsx eax,[ebx+SKIN_BUTTONS.left] movsx eax, [ebx+SKIN_BUTTONS.left]
mov [edx+SKIN_BUTTON.left],eax mov [edx+SKIN_BUTTON.left], eax
movsx eax,[ebx+SKIN_BUTTONS.top] movsx eax, [ebx+SKIN_BUTTONS.top]
mov [edx+SKIN_BUTTON.top],eax mov [edx+SKIN_BUTTON.top], eax
movsx eax,[ebx+SKIN_BUTTONS.width] movsx eax, [ebx+SKIN_BUTTONS.width]
mov [edx+SKIN_BUTTON.width],eax mov [edx+SKIN_BUTTON.width], eax
movsx eax,[ebx+SKIN_BUTTONS.height] movsx eax, [ebx+SKIN_BUTTONS.height]
mov [edx+SKIN_BUTTON.height],eax mov [edx+SKIN_BUTTON.height], eax
add ebx,12 add ebx, 12
jmp .lp2 jmp .lp2
.end_buttons: .end_buttons:
@@ -210,54 +215,55 @@ parse_skin_data:
ret ret
sys_putimage_with_check: sys_putimage_with_check:
or ebx,ebx or ebx, ebx
jz @f jz @f
call sys_putimage.forced call sys_putimage.forced
@@: ret @@:
ret
drawwindow_IV_caption: drawwindow_IV_caption:
mov ebp,skin_active mov ebp, skin_active
or al,al or al, al
jnz @f jnz @f
mov ebp,skin_inactive mov ebp, skin_inactive
@@: @@:
mov esi,[esp+4] mov esi, [esp+4]
mov eax,[esi+WDATA.box.width] ; window width mov eax, [esi+WDATA.box.width] ; window width
mov edx,[ebp+SKIN_DATA.left.left] mov edx, [ebp+SKIN_DATA.left.left]
shl edx,16 shl edx, 16
mov ecx,[ebp+SKIN_DATA.left.width] mov ecx, [ebp+SKIN_DATA.left.width]
shl ecx,16 shl ecx, 16
add ecx,[_skinh] add ecx, [_skinh]
mov ebx, [ebp+SKIN_DATA.left.data] mov ebx, [ebp+SKIN_DATA.left.data]
call sys_putimage_with_check call sys_putimage_with_check
mov esi,[esp+4] mov esi, [esp+4]
mov eax,[esi+WDATA.box.width] mov eax, [esi+WDATA.box.width]
sub eax,[ebp+SKIN_DATA.left.width] sub eax, [ebp+SKIN_DATA.left.width]
sub eax,[ebp+SKIN_DATA.oper.width] sub eax, [ebp+SKIN_DATA.oper.width]
cmp eax,[ebp+SKIN_DATA.base.left] cmp eax, [ebp+SKIN_DATA.base.left]
jng .non_base jng .non_base
xor edx,edx xor edx, edx
mov ecx,[ebp+SKIN_DATA.base.width] mov ecx, [ebp+SKIN_DATA.base.width]
jecxz .non_base jecxz .non_base
div ecx div ecx
inc eax inc eax
mov ebx,[ebp+SKIN_DATA.base.data] mov ebx, [ebp+SKIN_DATA.base.data]
mov ecx,[ebp+SKIN_DATA.base.width] mov ecx, [ebp+SKIN_DATA.base.width]
shl ecx,16 shl ecx, 16
add ecx,[_skinh] add ecx, [_skinh]
mov edx,[ebp+SKIN_DATA.base.left] mov edx, [ebp+SKIN_DATA.base.left]
sub edx,[ebp+SKIN_DATA.base.width] sub edx, [ebp+SKIN_DATA.base.width]
shl edx,16 shl edx, 16
.baseskinloop: .baseskinloop:
shr edx,16 shr edx, 16
add edx,[ebp+SKIN_DATA.base.width] add edx, [ebp+SKIN_DATA.base.width]
shl edx,16 shl edx, 16
push eax ebx ecx edx push eax ebx ecx edx
call sys_putimage_with_check call sys_putimage_with_check
@@ -267,16 +273,16 @@ drawwindow_IV_caption:
jnz .baseskinloop jnz .baseskinloop
.non_base: .non_base:
mov esi,[esp+4] mov esi, [esp+4]
mov edx,[esi+WDATA.box.width] mov edx, [esi+WDATA.box.width]
sub edx,[ebp+SKIN_DATA.oper.width] sub edx, [ebp+SKIN_DATA.oper.width]
inc edx inc edx
shl edx,16 shl edx, 16
mov ebx,[ebp+SKIN_DATA.oper.data] mov ebx, [ebp+SKIN_DATA.oper.data]
mov ecx,[ebp+SKIN_DATA.oper.width] mov ecx, [ebp+SKIN_DATA.oper.width]
shl ecx,16 shl ecx, 16
add ecx,[_skinh] add ecx, [_skinh]
call sys_putimage_with_check call sys_putimage_with_check
ret ret
@@ -291,166 +297,166 @@ drawwindow_IV:
push edx push edx
mov edi,edx mov edi, edx
mov ebp,skin_active mov ebp, skin_active
cmp byte [esp+32+4+4],0 cmp byte [esp+32+4+4], 0
jne @f jne @f
mov ebp,skin_inactive mov ebp, skin_inactive
@@: @@:
mov eax,[edi+WDATA.box.left] mov eax, [edi+WDATA.box.left]
shl eax,16 shl eax, 16
mov ax,word [edi+WDATA.box.left] mov ax, word [edi+WDATA.box.left]
add ax,word [edi+WDATA.box.width] add ax, word [edi+WDATA.box.width]
mov ebx,[edi+WDATA.box.top] mov ebx, [edi+WDATA.box.top]
shl ebx,16 shl ebx, 16
mov bx,word [edi+WDATA.box.top] mov bx, word [edi+WDATA.box.top]
add bx,word [edi+WDATA.box.height] add bx, word [edi+WDATA.box.height]
; mov esi,[edi+24] ; mov esi,[edi+24]
; shr esi,1 ; shr esi,1
; and esi,0x007f7f7f ; and esi,0x007f7f7f
mov esi,[ebp+SKIN_DATA.colors.outer] mov esi, [ebp+SKIN_DATA.colors.outer]
call draw_rectangle call draw_rectangle
mov ecx,3 mov ecx, 3
_dw3l: _dw3l:
add eax,1*65536-1 add eax, 1*65536-1
add ebx,1*65536-1 add ebx, 1*65536-1
test ax,ax test ax, ax
js no_skin_add_button js no_skin_add_button
test bx,bx test bx, bx
js no_skin_add_button js no_skin_add_button
mov esi,[ebp+SKIN_DATA.colors.frame] ;[edi+24] mov esi, [ebp+SKIN_DATA.colors.frame];[edi+24]
call draw_rectangle call draw_rectangle
dec ecx dec ecx
jnz _dw3l jnz _dw3l
mov esi,[ebp+SKIN_DATA.colors.inner] mov esi, [ebp+SKIN_DATA.colors.inner]
add eax,1*65536-1 add eax, 1*65536-1
add ebx,1*65536-1 add ebx, 1*65536-1
test ax,ax test ax, ax
js no_skin_add_button js no_skin_add_button
test bx,bx test bx, bx
js no_skin_add_button js no_skin_add_button
call draw_rectangle call draw_rectangle
cmp dword[skin_data],'SKIN' cmp dword[skin_data], 'SKIN'
je @f je @f
xor eax,eax xor eax, eax
xor ebx,ebx xor ebx, ebx
mov esi,[esp] mov esi, [esp]
mov ecx,[esi+WDATA.box.width] mov ecx, [esi+WDATA.box.width]
inc ecx inc ecx
mov edx,[_skinh] mov edx, [_skinh]
mov edi,[common_colours+4] ; standard grab color mov edi, [common_colours+4]; standard grab color
call [drawbar] call [drawbar]
jmp draw_clientbar jmp draw_clientbar
@@: @@:
mov al,[esp+32+4+4] mov al, [esp+32+4+4]
call drawwindow_IV_caption call drawwindow_IV_caption
draw_clientbar: draw_clientbar:
mov esi,[esp] mov esi, [esp]
mov edx,[esi+WDATA.box.top] ; WORK AREA mov edx, [esi+WDATA.box.top] ; WORK AREA
add edx,21+5 add edx, 21+5
mov ebx,[esi+WDATA.box.top] mov ebx, [esi+WDATA.box.top]
add ebx,[esi+WDATA.box.height] add ebx, [esi+WDATA.box.height]
cmp edx,ebx cmp edx, ebx
jg _noinside2 jg _noinside2
mov eax,5 mov eax, 5
mov ebx,[_skinh] mov ebx, [_skinh]
mov ecx,[esi+WDATA.box.width] mov ecx, [esi+WDATA.box.width]
mov edx,[esi+WDATA.box.height] mov edx, [esi+WDATA.box.height]
sub ecx,4 sub ecx, 4
sub edx,4 sub edx, 4
mov edi,[esi+WDATA.cl_workarea] mov edi, [esi+WDATA.cl_workarea]
test edi,0x40000000 test edi, 0x40000000
jnz _noinside2 jnz _noinside2
call [drawbar] call [drawbar]
_noinside2: _noinside2:
cmp dword[skin_data],'SKIN' cmp dword[skin_data], 'SKIN'
jne no_skin_add_button jne no_skin_add_button
;* close button ;* close button
mov edi,[BTN_ADDR] mov edi, [BTN_ADDR]
movzx eax,word [edi] movzx eax, word [edi]
cmp eax,1000 cmp eax, 1000
jge no_skin_add_button jge no_skin_add_button
inc eax inc eax
mov [edi],ax mov [edi], ax
shl eax,4 shl eax, 4
add eax,edi add eax, edi
mov bx,[CURRENT_TASK] mov bx, [CURRENT_TASK]
mov [eax],bx mov [eax], bx
add eax,2 ; save button id number add eax, 2 ; save button id number
mov bx,1 mov bx, 1
mov [eax],bx mov [eax], bx
add eax,2 ; x start add eax, 2 ; x start
xor ebx,ebx xor ebx, ebx
cmp [skin_btn_close.left],0 cmp [skin_btn_close.left], 0
jge _bCx_at_right jge _bCx_at_right
mov ebx,[esp] mov ebx, [esp]
mov ebx,[ebx+WDATA.box.width] mov ebx, [ebx+WDATA.box.width]
inc ebx inc ebx
_bCx_at_right: _bCx_at_right:
add ebx,[skin_btn_close.left] add ebx, [skin_btn_close.left]
mov [eax],bx mov [eax], bx
add eax,2 ; x size add eax, 2 ; x size
mov ebx,[skin_btn_close.width] mov ebx, [skin_btn_close.width]
dec ebx dec ebx
mov [eax],bx mov [eax], bx
add eax,2 ; y start add eax, 2 ; y start
mov ebx,[skin_btn_close.top] mov ebx, [skin_btn_close.top]
mov [eax],bx mov [eax], bx
add eax,2 ; y size add eax, 2 ; y size
mov ebx,[skin_btn_close.height] mov ebx, [skin_btn_close.height]
dec ebx dec ebx
mov [eax],bx mov [eax], bx
;* minimize button ;* minimize button
mov edi,[BTN_ADDR] mov edi, [BTN_ADDR]
movzx eax,word [edi] movzx eax, word [edi]
cmp eax,1000 cmp eax, 1000
jge no_skin_add_button jge no_skin_add_button
inc eax inc eax
mov [edi],ax mov [edi], ax
shl eax,4 shl eax, 4
add eax,edi add eax, edi
mov bx,[CURRENT_TASK] mov bx, [CURRENT_TASK]
mov [eax],bx mov [eax], bx
add eax,2 ; save button id number add eax, 2 ; save button id number
mov bx,65535 ;999 mov bx, 65535;999
mov [eax],bx mov [eax], bx
add eax,2 ; x start add eax, 2 ; x start
xor ebx,ebx xor ebx, ebx
cmp [skin_btn_minimize.left],0 cmp [skin_btn_minimize.left], 0
jge _bMx_at_right jge _bMx_at_right
mov ebx,[esp] mov ebx, [esp]
mov ebx,[ebx+WDATA.box.width] mov ebx, [ebx+WDATA.box.width]
inc ebx inc ebx
_bMx_at_right: _bMx_at_right:
add ebx,[skin_btn_minimize.left] add ebx, [skin_btn_minimize.left]
mov [eax],bx mov [eax], bx
add eax,2 ; x size add eax, 2 ; x size
mov ebx,[skin_btn_minimize.width] mov ebx, [skin_btn_minimize.width]
dec ebx dec ebx
mov [eax],bx mov [eax], bx
add eax,2 ; y start add eax, 2 ; y start
mov ebx,[skin_btn_minimize.top] mov ebx, [skin_btn_minimize.top]
mov [eax],bx mov [eax], bx
add eax,2 ; y size add eax, 2 ; y size
mov ebx,[skin_btn_minimize.height] mov ebx, [skin_btn_minimize.height]
dec ebx dec ebx
mov [eax],bx mov [eax], bx
no_skin_add_button: no_skin_add_button:
pop edi pop edi

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;; ;; ;;
;; Copyright (C) KolibriOS team 2004-2007. All rights reserved. ;; ;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;; ;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
;; Distributed under terms of the GNU General Public License ;; ;; Distributed under terms of the GNU General Public License ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -8,8 +8,6 @@
$Revision$ $Revision$
;// mike.dld [
VKEY_LSHIFT = 0000000000000001b VKEY_LSHIFT = 0000000000000001b
VKEY_RSHIFT = 0000000000000010b VKEY_RSHIFT = 0000000000000010b
VKEY_LCONTROL = 0000000000000100b VKEY_LCONTROL = 0000000000000100b
@@ -51,28 +49,32 @@ hotkey_tests dd hotkey_test0
dd hotkey_test4 dd hotkey_test4
hotkey_tests_num = 5 hotkey_tests_num = 5
endg endg
;---------------------------------------------------------------------
hotkey_test0: hotkey_test0:
test al, al test al, al
setz al setz al
ret ret
;---------------------------------------------------------------------
hotkey_test1: hotkey_test1:
test al, al test al, al
setnp al setnp al
ret ret
;---------------------------------------------------------------------
hotkey_test2: hotkey_test2:
cmp al, 3 cmp al, 3
setz al setz al
ret ret
;---------------------------------------------------------------------
hotkey_test3: hotkey_test3:
cmp al, 1 cmp al, 1
setz al setz al
ret ret
;---------------------------------------------------------------------
hotkey_test4: hotkey_test4:
cmp al, 2 cmp al, 2
setz al setz al
ret ret
;---------------------------------------------------------------------
hotkey_do_test: hotkey_do_test:
push eax push eax
mov edx, [kb_state] mov edx, [kb_state]
@@ -83,166 +85,232 @@ hotkey_do_test:
and eax, 15 and eax, 15
cmp al, hotkey_tests_num cmp al, hotkey_tests_num
jae .fail jae .fail
xchg eax, edx xchg eax, edx
and al, 3 and al, 3
call [hotkey_tests + edx*4] call [hotkey_tests + edx*4]
cmp al, 1 cmp al, 1
pop eax pop eax
ret ret
;--------------------------------------
.fail: .fail:
stc stc
pop eax pop eax
ret ret
;---------------------------------------------------------------------
align 4
set_keyboard_data:
movzx eax, word[TASK_COUNT]; top window process
movzx eax, word[WIN_POS+eax*2]
shl eax, 8
mov al, [SLOT_BASE+eax+APPDATA.keyboard_mode]
mov [keyboard_mode], al
mov eax, ecx
push ebx esi edi ebp
call send_scancode
pop ebp edi esi ebx
ret
;---------------------------------------------------------------------
align 4 align 4
irq1: irq1:
; save_ring3_context movzx eax, word[TASK_COUNT]; top window process
; mov ax, os_data movzx eax, word[WIN_POS+eax*2]
; mov ds, ax shl eax, 8
; mov es, ax mov al, [SLOT_BASE+eax+APPDATA.keyboard_mode]
mov [keyboard_mode], al
movzx eax,word[TASK_COUNT] ; top window process
movzx eax,word[WIN_POS+eax*2]
shl eax,8
mov al,[SLOT_BASE+eax+APPDATA.keyboard_mode]
mov [keyboard_mode],al
in al,0x60
mov [keyboard_data],al
in al, 0x60
;--------------------------------------
send_scancode:
mov [keyboard_data], al
; ch = scancode ; ch = scancode
; cl = ext_code ; cl = ext_code
; bh = 0 - normal key ; bh = 0 - normal key
; bh = 1 - modifier (Shift/Ctrl/Alt) ; bh = 1 - modifier (Shift/Ctrl/Alt)
; bh = 2 - extended code ; bh = 2 - extended code
mov ch, al
mov ch,al cmp al, 0xE0
cmp al,0xE0
je @f je @f
cmp al,0xE1
cmp al, 0xE1
jne .normal_code jne .normal_code
@@: @@:
mov bh, 2 mov bh, 2
mov [ext_code], al mov [ext_code], al
jmp .writekey jmp .writekey
.normal_code: ;--------------------------------------
.normal_code:
mov cl, 0 mov cl, 0
xchg cl, [ext_code] xchg cl, [ext_code]
and al,0x7F and al, 0x7F
mov bh, 1 mov bh, 1
@@: cmp al,0x2A @@:
cmp al, 0x2A
jne @f jne @f
cmp cl,0xE0
cmp cl, 0xE0
je .writekey je .writekey
mov eax,VKEY_LSHIFT
mov eax, VKEY_LSHIFT
jmp .modifier jmp .modifier
@@: cmp al,0x36 ;--------------------------------------
@@:
cmp al, 0x36
jne @f jne @f
cmp cl,0xE0
cmp cl, 0xE0
je .writekey je .writekey
mov eax,VKEY_RSHIFT
mov eax, VKEY_RSHIFT
jmp .modifier jmp .modifier
@@: cmp al,0x38 ;--------------------------------------
@@:
cmp al, 0x38
jne @f jne @f
mov eax, VKEY_LALT mov eax, VKEY_LALT
test cl, cl test cl, cl
jz .modifier jz .modifier
mov al, VKEY_RALT mov al, VKEY_RALT
jmp .modifier jmp .modifier
@@: cmp al,0x1D ;--------------------------------------
@@:
cmp al, 0x1D
jne @f jne @f
mov eax, VKEY_LCONTROL mov eax, VKEY_LCONTROL
test cl, cl test cl, cl
jz .modifier jz .modifier
mov al, VKEY_RCONTROL mov al, VKEY_RCONTROL
cmp cl, 0xE0 cmp cl, 0xE0
jz .modifier jz .modifier
mov [ext_code], cl mov [ext_code], cl
jmp .writekey jmp .writekey
@@: cmp al,0x3A ;--------------------------------------
@@:
cmp al, 0x3A
jne @f jne @f
mov bl,4
mov eax,VKEY_CAPSLOCK mov bl, 4
mov eax, VKEY_CAPSLOCK
jmp .no_key.xor jmp .no_key.xor
@@: cmp al,0x45 ;--------------------------------------
@@:
cmp al, 0x45
jne @f jne @f
test cl, cl test cl, cl
jnz .writekey jnz .writekey
mov bl,2
mov eax,VKEY_NUMLOCK mov bl, 2
mov eax, VKEY_NUMLOCK
jmp .no_key.xor jmp .no_key.xor
@@: cmp al,0x46 ;--------------------------------------
@@:
cmp al, 0x46
jne @f jne @f
mov bl,1
mov eax,VKEY_SCRLOCK mov bl, 1
mov eax, VKEY_SCRLOCK
jmp .no_key.xor jmp .no_key.xor
@@: ;--------------------------------------
test ch,ch @@:
xor ebx, ebx
test ch, ch
js .writekey js .writekey
movzx eax,ch ; plain key
mov bl,[keymap+eax] movzx eax, ch ; plain key
mov edx,[kb_state] mov bl, [keymap+eax]
test dl,VKEY_CONTROL ; ctrl alt del mov edx, [kb_state]
test dl, VKEY_CONTROL ; ctrl alt del
jz .noctrlaltdel jz .noctrlaltdel
test dl,VKEY_ALT
test dl, VKEY_ALT
jz .noctrlaltdel jz .noctrlaltdel
cmp ch,53h
cmp ch, 53h
jne .noctrlaltdel jne .noctrlaltdel
mov [ctrl_alt_del],1
.noctrlaltdel: mov [ctrl_alt_del], 1
test dl,VKEY_CONTROL ; ctrl on ? .noctrlaltdel:
test dl, VKEY_CONTROL ; ctrl on ?
jz @f jz @f
sub bl,0x60
@@: test dl,VKEY_SHIFT ; shift on ? sub bl, 0x60
@@:
test dl, VKEY_CAPSLOCK ; caps lock on ?
jz .no_caps_lock
test dl, VKEY_SHIFT ; shift on ?
jz .keymap_shif
jmp @f
;--------------------------------------
.no_caps_lock:
test dl, VKEY_SHIFT ; shift on ?
jz @f jz @f
mov bl,[keymap_shift+eax] .keymap_shif:
@@: test dl,VKEY_ALT ; alt on ? mov bl, [keymap_shift+eax]
@@:
test dl, VKEY_ALT ; alt on ?
jz @f jz @f
mov bl,[keymap_alt+eax]
@@: mov bl, [keymap_alt+eax]
mov bh, 0 @@:
jmp .writekey jmp .writekey
;--------------------------------------
.modifier: .modifier:
test ch, ch test ch, ch
js .modifier.up js .modifier.up
or [kb_state], eax or [kb_state], eax
jmp .writekey jmp .writekey
;--------------------------------------
.modifier.up: .modifier.up:
not eax not eax
and [kb_state], eax and [kb_state], eax
jmp .writekey jmp .writekey
;--------------------------------------
.no_key.xor: .no_key.xor:
mov bh, 0 mov bh, 0
test ch, ch test ch, ch
js .writekey js .writekey
xor [kb_state], eax xor [kb_state], eax
xor [kb_lights], bl xor [kb_lights], bl
call set_lights call set_lights
.writekey: .writekey:
; test for system hotkeys ; test for system hotkeys
movzx eax, ch movzx eax, ch
cmp bh, 1 cmp bh, 1
ja .nohotkey ja .nohotkey
jb @f jb @f
xor eax, eax xor eax, eax
@@: @@:
mov eax, [hotkey_scancodes + eax*4] mov eax, [hotkey_scancodes + eax*4]
.hotkey_loop: .hotkey_loop:
test eax, eax test eax, eax
jz .nohotkey jz .nohotkey
mov cl, 0 mov cl, 0
call hotkey_do_test call hotkey_do_test
jc .hotkey_cont jc .hotkey_cont
mov cl, 2 mov cl, 2
call hotkey_do_test call hotkey_do_test
jc .hotkey_cont jc .hotkey_cont
mov cl, 4 mov cl, 4
call hotkey_do_test call hotkey_do_test
jnc .hotkey_found jnc .hotkey_found
.hotkey_cont: .hotkey_cont:
mov eax, [eax] mov eax, [eax]
jmp .hotkey_loop jmp .hotkey_loop
;--------------------------------------
.hotkey_found: .hotkey_found:
mov eax, [eax+8] mov eax, [eax+8]
; put key in buffer for process in slot eax ; put key in buffer for process in slot eax
@@ -250,6 +318,7 @@ irq1:
@@: @@:
cmp dword [edi], 0 cmp dword [edi], 0
jz .found_free jz .found_free
add edi, 8 add edi, 8
cmp edi, hotkey_buffer+120*8 cmp edi, hotkey_buffer+120*8
jb @b jb @b
@@ -260,72 +329,67 @@ irq1:
movzx eax, ch movzx eax, ch
cmp bh, 1 cmp bh, 1
jnz @f jnz @f
xor eax, eax xor eax, eax
@@: @@:
mov [edi+4], ax mov [edi+4], ax
mov eax, [kb_state] mov eax, [kb_state]
mov [edi+6], ax mov [edi+6], ax
jmp .exit.irq1 jmp .exit.irq1
;--------------------------------------
.nohotkey: .nohotkey:
cmp [keyboard_mode],0 ; return from keymap cmp [keyboard_mode], 0; return from keymap
jne .scancode jne .scancode
test bh, bh test bh, bh
jnz .exit.irq1 jnz .exit.irq1
test bl, bl test bl, bl
jz .exit.irq1 jz .exit.irq1
;.........................Part1 Start.......Code by Rus, optimize by Ghost...................................
test [kb_state], VKEY_NUMLOCK test [kb_state], VKEY_NUMLOCK
jz .dowrite jz .dowrite
cmp cl, 0xE0 cmp cl, 0xE0
jz .dowrite jz .dowrite
cmp ch, 55 cmp ch, 55
jnz @f jnz @f
mov bl, 0x2A ;* mov bl, 0x2A ;*
jmp .dowrite jmp .dowrite
@@: ;--------------------------------------
@@:
cmp ch, 71 cmp ch, 71
jb .dowrite jb .dowrite
cmp ch, 83 cmp ch, 83
ja .dowrite ja .dowrite
;push eax
movzx eax, ch movzx eax, ch
mov bl, [numlock_map + eax - 71] mov bl, [numlock_map + eax - 71]
;pop eax
;.........................Part1 End.................................................
jmp .dowrite jmp .dowrite
;--------------------------------------
.scancode: .scancode:
mov bl, ch mov bl, ch
.dowrite: .dowrite:
movzx eax,byte[KEY_COUNT] movzx eax, byte[KEY_COUNT]
cmp al,120 cmp al, 120
jae .exit.irq1 jae .exit.irq1
inc eax inc eax
mov [KEY_COUNT],al mov [KEY_COUNT], al
mov [KEY_COUNT+eax],bl mov [KEY_COUNT+eax], bl
.exit.irq1:
.exit.irq1: mov [check_idle_semaphore], 5
mov [check_idle_semaphore],5
; mov al,0x20 ; ready for next irq
; out 0x20,al
; restore_ring3_context
; iret
ret ret
;---------------------------------------------------------------------
set_lights: set_lights:
mov al,0xED mov al, 0xED
call kb_write call kb_write
mov al,[kb_lights] mov al, [kb_lights]
call kb_write call kb_write
ret ret
;---------------------------------------------------------------------
;// mike.dld ]
;..........................Part2 Start.......Code by Rus.......................................
numlock_map: numlock_map:
db 0x37 ;Num 7 db 0x37 ;Num 7
db 0x38 ;Num 8 db 0x38 ;Num 8
@@ -340,4 +404,4 @@ numlock_map:
db 0x33 ;Num 3 db 0x33 ;Num 3
db 0x30 ;Num 0 db 0x30 ;Num 0
db 0x2E ;Num . db 0x2E ;Num .
;..........................Part2 End................................................ ;---------------------------------------------------------------------

View File

@@ -28,7 +28,8 @@ endg
iglobal iglobal
mouse_delay dd 10 mouse_delay dd 10
mouse_speed_factor: dd 3 mouse_speed_factor:
dd 3
mouse_timer_ticks dd 0 mouse_timer_ticks dd 0
endg endg
@@ -55,34 +56,34 @@ draw_mouse_under:
je @F je @F
pushad pushad
movzx eax,word [X_UNDER] movzx eax, word [X_UNDER]
movzx ebx,word [Y_UNDER] movzx ebx, word [Y_UNDER]
stdcall [_display.restore_cursor], eax, ebx stdcall [_display.restore_cursor], eax, ebx
popad popad
ret ret
@@: @@:
pushad pushad
xor ecx,ecx xor ecx, ecx
xor edx,edx xor edx, edx
align 4 align 4
mres: mres:
movzx eax,word [X_UNDER] movzx eax, word [X_UNDER]
movzx ebx,word [Y_UNDER] movzx ebx, word [Y_UNDER]
add eax,ecx add eax, ecx
add ebx,edx add ebx, edx
push ecx push ecx
push edx push edx
push eax push eax
push ebx push ebx
mov eax,edx mov eax, edx
shl eax,6 shl eax, 6
shl ecx,2 shl ecx, 2
add eax,ecx add eax, ecx
add eax,mouseunder add eax, mouseunder
mov ecx,[eax] mov ecx, [eax]
pop ebx pop ebx
pop eax pop eax
mov edi, 1 ;force mov edi, 1;force
call [putpixel] call [putpixel]
pop edx pop edx
pop ecx pop ecx
@@ -102,10 +103,10 @@ save_draw_mouse:
je .no_hw_cursor je .no_hw_cursor
pushad pushad
mov [X_UNDER],ax mov [X_UNDER], ax
mov [Y_UNDER],bx mov [Y_UNDER], bx
movzx eax,word [MOUSE_Y] movzx eax, word [MOUSE_Y]
movzx ebx,word [MOUSE_X] movzx ebx, word [MOUSE_X]
push eax push eax
push ebx push ebx
@@ -137,12 +138,12 @@ save_draw_mouse:
.no_hw_cursor: .no_hw_cursor:
pushad pushad
; save & draw ; save & draw
mov [X_UNDER],ax mov [X_UNDER], ax
mov [Y_UNDER],bx mov [Y_UNDER], bx
push eax push eax
push ebx push ebx
mov ecx,0 mov ecx, 0
mov edx,0 mov edx, 0
align 4 align 4
drm: drm:
push eax push eax
@@ -151,27 +152,27 @@ drm:
push edx push edx
; helloworld ; helloworld
push ecx push ecx
add eax,ecx ; save picture under mouse add eax, ecx; save picture under mouse
add ebx,edx add ebx, edx
push ecx push ecx
call getpixel call getpixel
mov [COLOR_TEMP],ecx mov [COLOR_TEMP], ecx
pop ecx pop ecx
mov eax,edx mov eax, edx
shl eax,6 shl eax, 6
shl ecx,2 shl ecx, 2
add eax,ecx add eax, ecx
add eax,mouseunder add eax, mouseunder
mov ebx,[COLOR_TEMP] mov ebx, [COLOR_TEMP]
mov [eax],ebx mov [eax], ebx
pop ecx pop ecx
mov edi,edx ; y cycle mov edi, edx ; y cycle
shl edi,4 ; *16 bytes per row shl edi, 4 ; *16 bytes per row
add edi,ecx ; x cycle add edi, ecx ; x cycle
mov esi, edi mov esi, edi
add edi, esi add edi, esi
add edi, esi ; *3 add edi, esi ; *3
add edi,[MOUSE_PICTURE] ; we have our str address add edi, [MOUSE_PICTURE] ; we have our str address
mov esi, edi mov esi, edi
add esi, 16*24*3 add esi, 16*24*3
push ecx push ecx
@@ -183,23 +184,23 @@ drm:
pop ecx pop ecx
pop ebx pop ebx
pop eax pop eax
add eax,ecx ; we have x coord+cycle add eax, ecx ; we have x coord+cycle
add ebx,edx ; and y coord+cycle add ebx, edx ; and y coord+cycle
push ecx push ecx
mov ecx, [MOUSE_COLOR_MEM] mov ecx, [MOUSE_COLOR_MEM]
mov edi, 1 mov edi, 1
call [putpixel] call [putpixel]
pop ecx pop ecx
mov ebx,[esp+0] ; pure y coord again mov ebx, [esp+0] ; pure y coord again
mov eax,[esp+4] ; and x mov eax, [esp+4] ; and x
inc ecx ; +1 cycle inc ecx ; +1 cycle
cmp ecx,16 ; if more than 16 cmp ecx, 16 ; if more than 16
jnz drm jnz drm
xor ecx, ecx xor ecx, ecx
inc edx inc edx
cmp edx,24 cmp edx, 24
jnz drm jnz drm
add esp,8 add esp, 8
popad popad
ret ret
@@ -274,97 +275,96 @@ combine_colors:
__sys_disable_mouse: __sys_disable_mouse:
cmp dword [MOUSE_VISIBLE],dword 0 cmp dword [MOUSE_VISIBLE], dword 0
je @f je @f
ret ret
@@: @@:
pushad pushad
cmp [CURRENT_TASK],dword 1 cmp [CURRENT_TASK], dword 1
je disable_m je disable_m
mov edx,[CURRENT_TASK] mov edx, [CURRENT_TASK]
shl edx,5 shl edx, 5
add edx,window_data add edx, window_data
movzx eax, word [MOUSE_X] movzx eax, word [MOUSE_X]
movzx ebx, word [MOUSE_Y] movzx ebx, word [MOUSE_Y]
mov ecx,[Screen_Max_X] mov ecx, [Screen_Max_X]
inc ecx inc ecx
imul ecx,ebx imul ecx, ebx
add ecx,eax add ecx, eax
add ecx, [_WinMapAddress] add ecx, [_WinMapAddress]
mov eax, [CURRENT_TASK] mov eax, [CURRENT_TASK]
movzx ebx, byte [ecx] cmp al, [ecx]
cmp eax,ebx
je yes_mouse_disable je yes_mouse_disable
movzx ebx, byte [ecx+16] cmp al, [ecx+16]
cmp eax,ebx
je yes_mouse_disable je yes_mouse_disable
mov ebx,[Screen_Max_X] add ebx, 10
cmp ebx, [Screen_Max_Y]
jae no_mouse_disable
mov ebx, [Screen_Max_X]
inc ebx inc ebx
imul ebx,10 imul ebx, 10
add ecx,ebx add ecx, ebx
movzx ebx, byte [ecx] cmp al, [ecx]
cmp eax,ebx
je yes_mouse_disable je yes_mouse_disable
movzx ebx, byte [ecx+16] cmp al, [ecx+16]
cmp eax,ebx
je yes_mouse_disable je yes_mouse_disable
jmp no_mouse_disable jmp no_mouse_disable
yes_mouse_disable: yes_mouse_disable:
mov edx,[CURRENT_TASK] mov edx, [CURRENT_TASK]
shl edx,5 shl edx, 5
add edx,window_data add edx, window_data
movzx eax, word [MOUSE_X] movzx eax, word [MOUSE_X]
movzx ebx, word [MOUSE_Y] movzx ebx, word [MOUSE_Y]
mov ecx,[edx+0] ; mouse inside the area ? mov ecx, [edx+0]; mouse inside the area ?
add eax,10 add eax, 10
cmp eax,ecx cmp eax, ecx
jb no_mouse_disable jb no_mouse_disable
sub eax,10 sub eax, 10
add ecx,[edx+8] add ecx, [edx+8]
cmp eax,ecx cmp eax, ecx
jg no_mouse_disable jg no_mouse_disable
mov ecx,[edx+4] mov ecx, [edx+4]
add ebx,14 add ebx, 14
cmp ebx,ecx cmp ebx, ecx
jb no_mouse_disable jb no_mouse_disable
sub ebx,14 sub ebx, 14
add ecx,[edx+12] add ecx, [edx+12]
cmp ebx,ecx cmp ebx, ecx
jg no_mouse_disable jg no_mouse_disable
disable_m: disable_m:
cmp dword [MOUSE_VISIBLE],dword 0 cmp dword [MOUSE_VISIBLE], dword 0
jne no_mouse_disable jne no_mouse_disable
pushf pushf
cli cli
call draw_mouse_under call draw_mouse_under
popf popf
mov [MOUSE_VISIBLE],dword 1 mov [MOUSE_VISIBLE], dword 1
no_mouse_disable: no_mouse_disable:
popad popad
ret ret
__sys_draw_pointer: __sys_draw_pointer:
cmp [mouse_pause],0 cmp [mouse_pause], 0
je @f je @f
ret ret
@@: @@:
push eax push eax
mov eax,[timer_ticks] mov eax, [timer_ticks]
sub eax,[MouseTickCounter] sub eax, [MouseTickCounter]
cmp eax,1 cmp eax, 1
ja @f ja @f
pop eax pop eax
ret ret
@@: @@:
mov eax,[timer_ticks] mov eax, [timer_ticks]
mov [MouseTickCounter],eax mov [MouseTickCounter], eax
pop eax pop eax
pushad pushad
cmp dword [MOUSE_VISIBLE],dword 0 ; mouse visible ? cmp dword [MOUSE_VISIBLE], dword 0; mouse visible ?
je chms00 je chms00
mov [MOUSE_VISIBLE], dword 0 mov [MOUSE_VISIBLE], dword 0
movzx ebx,word [MOUSE_Y] movzx ebx, word [MOUSE_Y]
movzx eax,word [MOUSE_X] movzx eax, word [MOUSE_X]
pushfd pushfd
cli cli
call save_draw_mouse call save_draw_mouse
@@ -373,13 +373,13 @@ nodmu2:
popad popad
ret ret
chms00: chms00:
movzx ecx,word [X_UNDER] movzx ecx, word [X_UNDER]
movzx edx,word [Y_UNDER] movzx edx, word [Y_UNDER]
movzx ebx,word [MOUSE_Y] movzx ebx, word [MOUSE_Y]
movzx eax,word [MOUSE_X] movzx eax, word [MOUSE_X]
cmp eax,ecx cmp eax, ecx
jne redrawmouse jne redrawmouse
cmp ebx,edx cmp ebx, edx
jne redrawmouse jne redrawmouse
jmp nodmp jmp nodmp
redrawmouse: redrawmouse:
@@ -394,62 +394,62 @@ nodmp:
proc set_mouse_data stdcall, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword proc set_mouse_data stdcall, BtnState:dword, XMoving:dword, YMoving:dword, VScroll:dword, HScroll:dword
mov eax,[BtnState] mov eax, [BtnState]
mov [BTN_DOWN],eax mov [BTN_DOWN], eax
mov eax,[XMoving] mov eax, [XMoving]
call mouse_acceleration call mouse_acceleration
add ax,[MOUSE_X] ;[XCoordinate] add ax, [MOUSE_X];[XCoordinate]
cmp ax,0 cmp ax, 0
jge @@M1 jge @@M1
mov eax,0 mov eax, 0
jmp @@M2 jmp @@M2
@@M1: @@M1:
cmp ax,[Screen_Max_X] ;ScreenLength cmp ax, [Screen_Max_X];ScreenLength
jl @@M2 jl @@M2
mov ax,[Screen_Max_X] ;ScreenLength-1 mov ax, [Screen_Max_X];ScreenLength-1
@@M2: @@M2:
mov [MOUSE_X],ax ;[XCoordinate] mov [MOUSE_X], ax;[XCoordinate]
mov eax,[YMoving] mov eax, [YMoving]
neg eax neg eax
call mouse_acceleration call mouse_acceleration
add ax,[MOUSE_Y] ;[YCoordinate] add ax, [MOUSE_Y];[YCoordinate]
cmp ax,0 cmp ax, 0
jge @@M3 jge @@M3
mov ax,0 mov ax, 0
jmp @@M4 jmp @@M4
@@M3: @@M3:
cmp ax,[Screen_Max_Y] ;ScreenHeigth cmp ax, [Screen_Max_Y];ScreenHeigth
jl @@M4 jl @@M4
mov ax,[Screen_Max_Y] ;ScreenHeigth-1 mov ax, [Screen_Max_Y];ScreenHeigth-1
@@M4: @@M4:
mov [MOUSE_Y],ax ;[YCoordinate] mov [MOUSE_Y], ax;[YCoordinate]
mov eax,[VScroll] mov eax, [VScroll]
add [MOUSE_SCROLL_V],ax add [MOUSE_SCROLL_V], ax
mov eax,[HScroll] mov eax, [HScroll]
add [MOUSE_SCROLL_H],ax add [MOUSE_SCROLL_H], ax
mov [mouse_active],1 mov [mouse_active], 1
mov eax,[timer_ticks] mov eax, [timer_ticks]
mov [mouse_timer_ticks],eax mov [mouse_timer_ticks], eax
ret ret
endp endp
mouse_acceleration: mouse_acceleration:
push eax push eax
mov eax,[timer_ticks] mov eax, [timer_ticks]
sub eax,[mouse_timer_ticks] sub eax, [mouse_timer_ticks]
cmp eax,[mouse_delay] cmp eax, [mouse_delay]
pop eax pop eax
ja @f ja @f
;push edx ;push edx
imul eax,[mouse_speed_factor] imul eax, [mouse_speed_factor]
;pop edx ;pop edx
@@: @@:
ret ret

View File

@@ -19,185 +19,185 @@ $Revision$
sys_settime: sys_settime:
cli cli
mov al,0x0d mov al, 0x0d
out 0x70,al out 0x70, al
in al,0x71 in al, 0x71
bt ax,7 bt ax, 7
jnc bat_low jnc bat_low
cmp ebx,2 ;day of week cmp ebx, 2;day of week
jne nosetweek jne nosetweek
test ecx,ecx ;test day of week test ecx, ecx ;test day of week
je wrongtime je wrongtime
cmp ecx,7 cmp ecx, 7
ja wrongtime ja wrongtime
mov edx,0x70 mov edx, 0x70
call startstopclk call startstopclk
dec edx dec edx
mov al,6 mov al, 6
out dx,al out dx, al
inc edx inc edx
mov al,cl mov al, cl
out dx,al out dx, al
jmp endsettime jmp endsettime
nosetweek: ;set date nosetweek: ;set date
cmp ebx,1 cmp ebx, 1
jne nosetdate jne nosetdate
cmp cl,0x99 ;test year cmp cl, 0x99;test year
ja wrongtime ja wrongtime
shl ecx,4 shl ecx, 4
cmp cl,0x90 cmp cl, 0x90
ja wrongtime ja wrongtime
cmp ch,0x99 ;test month cmp ch, 0x99;test month
ja wrongtime ja wrongtime
shr ecx,4 shr ecx, 4
test ch,ch test ch, ch
je wrongtime je wrongtime
cmp ch,0x12 cmp ch, 0x12
ja wrongtime ja wrongtime
shl ecx,8 shl ecx, 8
bswap ecx ;ebx=00YYMMDD bswap ecx ;ebx=00YYMMDD
test cl,cl ;test day test cl, cl ;test day
je wrongtime je wrongtime
shl ecx,4 shl ecx, 4
cmp cl,0x90 cmp cl, 0x90
ja wrongtime ja wrongtime
shr ecx,4 shr ecx, 4
cmp ch,2 ;February cmp ch, 2 ;February
jne testday jne testday
cmp cl,0x29 cmp cl, 0x29
ja wrongtime ja wrongtime
jmp setdate jmp setdate
testday: testday:
cmp ch,8 cmp ch, 8
jb testday1 ;Aug-Dec jb testday1;Aug-Dec
bt cx,8 bt cx, 8
jnc days31 jnc days31
jmp days30 jmp days30
testday1: testday1:
bt cx,8 ;Jan-Jul ex.Feb bt cx, 8 ;Jan-Jul ex.Feb
jnc days30 jnc days30
days31: days31:
cmp cl,0x31 cmp cl, 0x31
ja wrongtime ja wrongtime
jmp setdate jmp setdate
days30: days30:
cmp cl,0x30 cmp cl, 0x30
ja wrongtime ja wrongtime
setdate: setdate:
mov edx,0x70 mov edx, 0x70
call startstopclk call startstopclk
dec edx dec edx
mov al,7 ;set days mov al, 7 ;set days
out dx,al out dx, al
inc edx inc edx
mov al,cl mov al, cl
out dx,al out dx, al
dec edx dec edx
mov al,8 ;set months mov al, 8 ;set months
out dx,al out dx, al
inc edx inc edx
mov al,ch mov al, ch
out dx,al out dx, al
dec edx dec edx
mov al,9 ;set years mov al, 9 ;set years
out dx,al out dx, al
inc edx inc edx
shr ecx,8 shr ecx, 8
mov al,ch mov al, ch
out dx,al out dx, al
jmp endsettime jmp endsettime
nosetdate: ;set time or alarm-clock nosetdate: ;set time or alarm-clock
cmp ebx,3 cmp ebx, 3
ja wrongtime ja wrongtime
cmp cl,0x23 cmp cl, 0x23
ja wrongtime ja wrongtime
cmp ch,0x59 cmp ch, 0x59
ja wrongtime ja wrongtime
shl ecx,4 shl ecx, 4
cmp cl,0x90 cmp cl, 0x90
ja wrongtime ja wrongtime
cmp ch,0x92 cmp ch, 0x92
ja wrongtime ja wrongtime
shl ecx,4 shl ecx, 4
bswap ecx ;00HHMMSS bswap ecx ;00HHMMSS
cmp cl,0x59 cmp cl, 0x59
ja wrongtime ja wrongtime
shl ecx,4 shl ecx, 4
cmp cl,0x90 cmp cl, 0x90
ja wrongtime ja wrongtime
shr ecx,4 shr ecx, 4
mov edx,0x70 mov edx, 0x70
call startstopclk call startstopclk
dec edx dec edx
cmp ebx,3 cmp ebx, 3
je setalarm je setalarm
xor eax,eax ;al=0-set seconds xor eax, eax;al=0-set seconds
out dx,al out dx, al
inc edx inc edx
mov al,cl mov al, cl
out dx,al out dx, al
dec edx dec edx
mov al,2 ;set minutes mov al, 2 ;set minutes
out dx,al out dx, al
inc edx inc edx
mov al,ch mov al, ch
out dx,al out dx, al
dec edx dec edx
mov al,4 ;set hours mov al, 4 ;set hours
out dx,al out dx, al
inc edx inc edx
shr ecx,8 shr ecx, 8
mov al,ch mov al, ch
out dx,al out dx, al
jmp endsettime jmp endsettime
setalarm: setalarm:
mov al,1 ;set seconds for al. mov al, 1;set seconds for al.
out dx,al out dx, al
inc edx inc edx
mov al,cl mov al, cl
out dx,al out dx, al
dec edx dec edx
mov al,3 ;set minutes for al. mov al, 3;set minutes for al.
out dx,al out dx, al
inc edx inc edx
mov al,ch mov al, ch
out dx,al out dx, al
dec edx dec edx
mov al,5 ;set hours for al. mov al, 5;set hours for al.
out dx,al out dx, al
inc edx inc edx
shr ecx,8 shr ecx, 8
mov al,ch mov al, ch
out dx,al out dx, al
dec edx dec edx
mov al,0x0b ;enable irq's mov al, 0x0b;enable irq's
out dx,al out dx, al
inc dx inc dx
in al,dx in al, dx
bts ax,5 ;set bit 5 bts ax, 5;set bit 5
out dx,al out dx, al
endsettime: endsettime:
dec edx dec edx
call startstopclk call startstopclk
sti sti
and [esp+36-4],dword 0 and [esp+36-4], dword 0
ret ret
bat_low: bat_low:
sti sti
mov [esp+36-4],dword 2 mov [esp+36-4], dword 2
ret ret
wrongtime: wrongtime:
sti sti
mov [esp+36-4],dword 1 mov [esp+36-4], dword 1
ret ret
startstopclk: startstopclk:
mov al,0x0b mov al, 0x0b
out dx,al out dx, al
inc dx inc dx
in al,dx in al, dx
btc ax,7 btc ax, 7
out dx,al out dx, al
ret ret

View File

@@ -50,8 +50,8 @@ proc init_mem
; calculate maximum allocatable address and number of allocatable pages ; calculate maximum allocatable address and number of allocatable pages
mov edi, BOOT_VAR-OS_BASE + 0x9104 mov edi, BOOT_VAR-OS_BASE + 0x9104
mov ecx, [edi-4] mov ecx, [edi-4]
xor esi, esi ; esi will hold total amount of memory xor esi, esi; esi will hold total amount of memory
xor edx, edx ; edx will hold maximum allocatable address xor edx, edx; edx will hold maximum allocatable address
.calcmax: .calcmax:
; round all to pages ; round all to pages
mov eax, [edi] mov eax, [edi]
@@ -139,14 +139,10 @@ proc init_mem
dec [pg_data.kernel_tables-OS_BASE] dec [pg_data.kernel_tables-OS_BASE]
mov [edx], eax mov [edx], eax
add eax, 0x00400000
add edx, 4 add edx, 4
mov eax, 0x400000+PG_SW mov edi, [tmp_page_tabs]
mov ecx, [tmp_page_tabs] jmp .map_kernel_heap ; new kernel fits to the first 4Mb - nothing to do with ".map_low"
sub ecx, 0x400000
shr ecx, 12 ;ecx/=4096
jmp .map_low
.no_PSE: .no_PSE:
mov eax, PG_SW mov eax, PG_SW
mov ecx, [tmp_page_tabs] mov ecx, [tmp_page_tabs]
@@ -159,6 +155,7 @@ proc init_mem
dec ecx dec ecx
jnz @B jnz @B
.map_kernel_heap:
mov ecx, [pg_data.kernel_tables-OS_BASE] mov ecx, [pg_data.kernel_tables-OS_BASE]
shl ecx, 10 shl ecx, 10
xor eax, eax xor eax, eax
@@ -170,7 +167,6 @@ proc init_mem
mov edi, edx mov edi, edx
.map_kernel_tabs: .map_kernel_tabs:
stosd stosd
add eax, 0x1000 add eax, 0x1000
dec ecx dec ecx
@@ -200,10 +196,10 @@ proc init_page_map
mov edx, [ebx-4] mov edx, [ebx-4]
.scanmap: .scanmap:
mov ecx, [ebx+8] mov ecx, [ebx+8]
shr ecx, 12 ; ecx = number of pages shr ecx, 12; ecx = number of pages
jz .next jz .next
mov edi, [ebx] mov edi, [ebx]
shr edi, 12 ; edi = first page shr edi, 12; edi = first page
mov eax, edi mov eax, edi
shr edi, 5 shr edi, 5
shl edi, 2 shl edi, 2
@@ -270,7 +266,6 @@ proc init_page_map
add ebx, [pg_data.pagemap_size-OS_BASE] add ebx, [pg_data.pagemap_size-OS_BASE]
mov [page_end-OS_BASE], ebx mov [page_end-OS_BASE], ebx
mov [pg_data.pg_mutex-OS_BASE], 0
ret ret
endp endp
@@ -279,7 +274,7 @@ align 4
init_BIOS32: init_BIOS32:
mov edi, 0xE0000 mov edi, 0xE0000
.pcibios_nxt: .pcibios_nxt:
cmp dword[edi], '_32_' ; "magic" word cmp dword[edi], '_32_'; "magic" word
je .BIOS32_found je .BIOS32_found
.pcibios_nxt2: .pcibios_nxt2:
add edi, 0x10 add edi, 0x10
@@ -293,10 +288,11 @@ init_BIOS32:
mov esi, edi mov esi, edi
xor eax, eax xor eax, eax
cld ; paranoia cld ; paranoia
@@: lodsb @@:
lodsb
add ah, al add ah, al
loop @b loop @b
jnz .pcibios_nxt2 ; control summ must be zero jnz .pcibios_nxt2; control summ must be zero
; BIOS32 service found ! ; BIOS32 service found !
mov ebp, [edi + 4] mov ebp, [edi + 4]
mov [bios32_entry], ebp mov [bios32_entry], ebp
@@ -396,7 +392,7 @@ proc test_cpu
mov [cpu_sign-OS_BASE], eax mov [cpu_sign-OS_BASE], eax
mov [cpu_info-OS_BASE], ebx mov [cpu_info-OS_BASE], ebx
mov [cpu_caps-OS_BASE], edx mov [cpu_caps-OS_BASE], edx
mov [cpu_caps+4-OS_BASE],ecx mov [cpu_caps+4-OS_BASE], ecx
shr eax, 8 shr eax, 8
and eax, 0x0f and eax, 0x0f
@@ -420,7 +416,7 @@ proc test_cpu
mov [cpu_sign-OS_BASE], eax mov [cpu_sign-OS_BASE], eax
mov [cpu_info-OS_BASE], ebx mov [cpu_info-OS_BASE], ebx
mov [cpu_caps-OS_BASE], edx mov [cpu_caps-OS_BASE], edx
mov [cpu_caps+4-OS_BASE],ecx mov [cpu_caps+4-OS_BASE], ecx
shr eax, 8 shr eax, 8
and eax, 0x0f and eax, 0x0f
ret ret
@@ -430,9 +426,129 @@ proc test_cpu
mov [cpu_sign-OS_BASE], eax mov [cpu_sign-OS_BASE], eax
mov [cpu_info-OS_BASE], ebx mov [cpu_info-OS_BASE], ebx
mov [cpu_caps-OS_BASE], edx mov [cpu_caps-OS_BASE], edx
mov [cpu_caps+4-OS_BASE],ecx mov [cpu_caps+4-OS_BASE], ecx
shr eax, 8 shr eax, 8
and eax, 0x0f and eax, 0x0f
ret ret
endp endp
uglobal
align 4
acpi_rsdp rd 1
acpi_rsdt rd 1
acpi_madt rd 1
acpi_dev_data rd 1
acpi_dev_size rd 1
acpi_rsdt_base rd 1
acpi_madt_base rd 1
acpi_lapic_base rd 1
acpi_ioapic_base rd 1
endg
ACPI_HI_RSDP_WINDOW_START equ 0x000E0000
ACPI_HI_RSDP_WINDOW_END equ 0x00100000
ACPI_RSDP_CHECKSUM_LENGTH equ 20
ACPI_MADT_SIGN equ 0x43495041
acpi_locate:
push ebx
mov ebx, ACPI_HI_RSDP_WINDOW_START
.check:
cmp [ebx], dword 0x20445352
jne .next
cmp [ebx+4], dword 0x20525450
jne .next
mov edx, ebx
mov ecx, ACPI_RSDP_CHECKSUM_LENGTH
xor eax, eax
.sum:
add al, [edx]
inc edx
loop .sum
test al, al
jnz .next
mov eax, ebx
pop ebx
ret
.next:
add ebx, 16
cmp ebx, ACPI_HI_RSDP_WINDOW_END
jb .check
pop ebx
xor eax, eax
ret
align 4
rsdt_find: ;ecx= rsdt edx= SIG
push ebx
push esi
lea ebx, [ecx+36]
mov esi, [ecx+4]
add esi, ecx
.next:
mov eax, [ebx]
cmp [eax], edx
je .done
add ebx, 4
cmp ebx, esi
jb .next
xor eax, eax
pop esi
pop ebx
ret
.done:
mov eax, [ebx]
pop esi
pop ebx
ret
align 4
check_acpi:
call acpi_locate
test eax, eax
jz .done
mov ecx, [eax+16]
mov edx, ACPI_MADT_SIGN
mov [acpi_rsdt_base-OS_BASE], ecx
call rsdt_find
test eax, eax
jz .done
mov [acpi_madt_base-OS_BASE], eax
mov ecx, [eax+36]
mov [acpi_lapic_base-OS_BASE], ecx
lea edx, [eax+44]
mov ecx, [eax+4]
add ecx, eax
.check:
mov eax, [edx]
cmp al, 1
je .ioapic
.next:
movzx eax, ah
add edx, eax
cmp edx, ecx
jb .check
.done:
ret
.ioapic:
mov eax, [edx+4]
mov [acpi_ioapic_base-OS_BASE], eax
ret

File diff suppressed because it is too large Load Diff

View File

@@ -15,58 +15,31 @@
$Revision$ $Revision$
struct POINT
x dd ?
y dd ?
ends
;struc db [a] { common . db a struct RECT
; if ~used . left dd ?
; display 'not used db: ',`.,13,10 top dd ?
; end if } right dd ?
;struc dw [a] { common . dw a bottom dd ?
; if ~used . ends
; display 'not used dw: ',`.,13,10
; end if }
;struc dd [a] { common . dd a
; if ~used .
; display 'not used dd: ',`.,13,10
; end if }
;struc dp [a] { common . dp a
; if ~used .
; display 'not used dp: ',`.,13,10
; end if }
;struc dq [a] { common . dq a
; if ~used .
; display 'not used dq: ',`.,13,10
; end if }
;struc dt [a] { common . dt a
; if ~used .
; display 'not used dt: ',`.,13,10
; end if }
struc RECT { struct BOX
.left dd ? left dd ?
.top dd ? top dd ?
.right dd ? width dd ?
.bottom dd ? height dd ?
} ends
virtual at 0
RECT RECT
end virtual
struc BOX { struct DISPMODE
.left dd ? width dw ?
.top dd ? height dw ?
.width dd ? bpp dw ?
.height dd ? freq dw ?
} ends
virtual at 0
BOX BOX
end virtual
struc DISPMODE {
.width rw 1
.height rw 1
.bpp rw 1
.freq rw 1
}
; constants definition ; constants definition
WSTATE_NORMAL = 00000000b WSTATE_NORMAL = 00000000b
@@ -80,24 +53,20 @@ WSTATE_WNDDRAWN = 00000010b
WSTYLE_HASCAPTION = 00010000b WSTYLE_HASCAPTION = 00010000b
WSTYLE_CLIENTRELATIVE = 00100000b WSTYLE_CLIENTRELATIVE = 00100000b
struc TASKDATA struct TASKDATA
{ event_mask dd ?
.event_mask dd ? pid dd ?
.pid dd ?
dw ? dw ?
.state db ? state db ?
db ? db ?
dw ? dw ?
.wnd_number db ? wnd_number db ?
db ? db ?
.mem_start dd ? mem_start dd ?
.counter_sum dd ? counter_sum dd ?
.counter_add dd ? counter_add dd ?
.cpu_usage dd ? cpu_usage dd ?
} ends
virtual at 0
TASKDATA TASKDATA
end virtual
TSTATE_RUNNING = 0 TSTATE_RUNNING = 0
TSTATE_RUN_SUSPENDED = 1 TSTATE_RUN_SUSPENDED = 1
@@ -108,81 +77,86 @@ TSTATE_WAITING = 5
TSTATE_FREE = 9 TSTATE_FREE = 9
; structures definition ; structures definition
struc WDATA { struct WDATA
.box BOX box BOX
.cl_workarea dd ? cl_workarea dd ?
.cl_titlebar dd ? cl_titlebar dd ?
.cl_frames dd ? cl_frames dd ?
.reserved db ? reserved db ?
.fl_wstate db ? fl_wstate db ?
.fl_wdrawn db ? fl_wdrawn db ?
.fl_redraw db ? fl_redraw db ?
.sizeof: ends
}
virtual at 0
WDATA WDATA
end virtual
label WDATA.fl_wstyle byte at WDATA.cl_workarea + 3 label WDATA.fl_wstyle byte at WDATA.cl_workarea + 3
struc APPDATA struct DBG_REGS
{ dr0 dd ?
.app_name db 11 dup(?) dr1 dd ?
db 5 dup(?) dr2 dd ?
dr3 dd ?
dr7 dd ?
ends
.fpu_state dd ? ;+16 struct APPDATA
.ev_count_ dd ? ;unused ;+20 app_name rb 11
.exc_handler dd ? ;+24 rb 5
.except_mask dd ? ;+28
.pl0_stack dd ? ;unused ;+32
.heap_base dd ? ;+36
.heap_top dd ? ;+40
.cursor dd ? ;+44
.fd_ev dd ? ;+48
.bk_ev dd ? ;+52
.fd_obj dd ? ;+56
.bk_obj dd ? ;+60
.saved_esp dd ? ;+64
.io_map rd 2 ;+68
.dbg_state dd ? ;+76
.cur_dir dd ? ;+80
.wait_timeout dd ? ;+84
.saved_esp0 dd ? ;+88
.wait_begin dd ? ;+92 +++
.wait_test dd ? ;+96 +++
.wait_param dd ? ;+100 +++
.tls_base dd ? ;+104
.dlls_list_ptr dd ? ;+108
db 16 dup(?) ;+112
.wnd_shape dd ? ;+128 fpu_state dd ? ;+16
.wnd_shape_scale dd ? ;+132 ev_count_ dd ? ;unused ;+20
exc_handler dd ? ;+24
except_mask dd ? ;+28
pl0_stack dd ? ;+32
heap_base dd ? ;+36
heap_top dd ? ;+40
cursor dd ? ;+44
fd_ev dd ? ;+48
bk_ev dd ? ;+52
fd_obj dd ? ;+56
bk_obj dd ? ;+60
saved_esp dd ? ;+64
io_map rd 2 ;+68
dbg_state dd ? ;+76
cur_dir dd ? ;+80
wait_timeout dd ? ;+84
saved_esp0 dd ? ;+88
wait_begin dd ? ;+92 +++
wait_test dd ? ;+96 +++
wait_param dd ? ;+100 +++
tls_base dd ? ;+104
dlls_list_ptr dd ? ;+108
rb 16 ;+112
wnd_shape dd ? ;+128
wnd_shape_scale dd ? ;+132
dd ? ;+136 dd ? ;+136
.mem_size dd ? ;+140 mem_size dd ? ;+140
.saved_box BOX saved_box BOX
.ipc_start dd ? ipc_start dd ?
.ipc_size dd ? ipc_size dd ?
.event_mask dd ? event_mask dd ?
.debugger_slot dd ? debugger_slot dd ?
dd ? dd ?
.keyboard_mode db ? keyboard_mode db ?
db 3 dup(?) rb 3
.dir_table dd ? dir_table dd ?
.dbg_event_mem dd ? dbg_event_mem dd ?
.dbg_regs: dbg_regs DBG_REGS
.dbg_regs.dr0 dd ? wnd_caption dd ?
.dbg_regs.dr1 dd ? wnd_clientbox BOX
.dbg_regs.dr2 dd ?
.dbg_regs.dr3 dd ? ends
.dbg_regs.dr7 dd ?
.wnd_caption dd ?
.wnd_clientbox BOX
}
virtual at 0
APPDATA APPDATA
end virtual
;// mike.dld, 2006-29-01 ] ;// mike.dld, 2006-29-01 ]
struct MUTEX
lhead LHEAD
count dd ?
ends
; Core functions ; Core functions
include "core/sync.inc" ; macros for synhronization objects include "core/sync.inc" ; macros for synhronization objects
@@ -199,6 +173,9 @@ include "core/peload.inc" ;
include "core/exports.inc" include "core/exports.inc"
include "core/string.inc" include "core/string.inc"
include "core/v86.inc" ; virtual-8086 manager include "core/v86.inc" ; virtual-8086 manager
include "core/irq.inc" ; irq handling functions
include "core/apic.inc" ; Interrupt Controller functions
include "core/timers.inc"
; GUI stuff ; GUI stuff
include "gui/window.inc" include "gui/window.inc"
@@ -210,6 +187,8 @@ include "gui/button.inc"
; file system ; file system
include "blkdev/disk.inc" ; support for plug-n-play disks
include "blkdev/disk_cache.inc" ; caching for plug-n-play disks
include "fs/fs.inc" ; syscall include "fs/fs.inc" ; syscall
include "fs/fat32.inc" ; read / write for fat32 filesystem include "fs/fat32.inc" ; read / write for fat32 filesystem
include "fs/ntfs.inc" ; read / write for ntfs filesystem include "fs/ntfs.inc" ; read / write for ntfs filesystem
@@ -217,6 +196,7 @@ include "fs/fat12.inc" ; read / write for fat12 filesystem
include "blkdev/rd.inc" ; ramdisk read /write include "blkdev/rd.inc" ; ramdisk read /write
include "fs/fs_lfn.inc" ; syscall, version 2 include "fs/fs_lfn.inc" ; syscall, version 2
include "fs/iso9660.inc" ; read for iso9660 filesystem CD include "fs/iso9660.inc" ; read for iso9660 filesystem CD
include "fs/ext2.inc" ; read / write for ext2 filesystem
; sound ; sound
@@ -226,6 +206,7 @@ include "sound/playnote.inc" ; player Note for Speaker PC
include "video/vesa12.inc" ; Vesa 1.2 functions include "video/vesa12.inc" ; Vesa 1.2 functions
include "video/vesa20.inc" ; Vesa 2.0 functions include "video/vesa20.inc" ; Vesa 2.0 functions
include "video/blitter.inc" ;
include "video/vga.inc" ; VGA 16 color functions include "video/vga.inc" ; VGA 16 color functions
include "video/cursors.inc" ; cursors functions include "video/cursors.inc" ; cursors functions

View File

@@ -11,6 +11,9 @@ macro $Revision a {
$Revision$ $Revision$
;// mike.dld, 2006-29-01 [
; macros definition ; macros definition
macro diff16 title,l1,l2 macro diff16 title,l1,l2
{ {
@@ -76,49 +79,35 @@ end if
macro Mov op1,op2,op3 ; op1 = op2 = op3 macro Mov op1,op2,op3 ; op1 = op2 = op3
{ {
mov op2,op3 mov op2, op3
mov op1,op2 mov op1, op2
} }
macro __list_add new, prev, next
if __CPU_type eq p5 ; CMOVcc isnt supported on the P5 {
mov [next+LHEAD.prev], new
cmove fix cmovz mov [new+LHEAD.next], next
macro cmovz reg1, reg2 { mov [new+LHEAD.prev], prev
mov [prev+LHEAD.next], new
local .jumpaddr
jnz .jumpaddr
mov reg1, reg2
.jumpaddr:
} }
cmovne fix cmovnz macro list_add new, head
macro cmovnz reg1, reg2 { {
mov eax, [head+LHEAD.next]
local .jumpaddr __list_add new, head, eax
jz .jumpaddr
mov reg1, reg2
.jumpaddr:
} }
macro cmovg reg1, reg2 { macro list_add_tail new, head
{
local .jumpaddr mov eax, [head+LHEAD.prev]
__list_add new, eax, head
jle .jumpaddr
mov reg1, reg2
.jumpaddr:
} }
macro cmovl reg1, reg2 { macro list_del entry
{
local .jumpaddr mov edx, [entry+list_fd]
mov ecx, [entry+list_bk]
jge .jumpaddr mov [edx+list_bk], ecx
mov reg1, reg2 mov [ecx+list_fd], edx
.jumpaddr:
} }
end if

View File

@@ -62,33 +62,36 @@
; 3c dword cpu usage in cpu timer tics ; 3c dword cpu usage in cpu timer tics
; ;
; ;
; 5000 -> 68FF free ; 5000 -> 68FF free (6k6)
; 6900 -> 6EFF saved picture under mouse pointer ; 6900 -> 6EFF saved picture under mouse pointer (1k5)
; ;
; 6F00 -> 6FFF free ; 6F00 -> 6FFF free (256)
; ;
; 7000 -> 7FFF used CD driver ; 7000 -> 7FFF used CD driver
; ;
; 8000 -> A3FF used FLOPPY driver ; 8000 -> A3FF used FLOPPY driver
; ;
; A400 -> B0FF free ; A400 -> B0FF free (3k3), unused ACTIVE_PROC_STACK
; B100 -> B307 IDT for int_0x00..int_0x40 ; B100 -> B307 IDT for int_0x00..int_0x40
; B308 -> BFFF free ; B308 -> BFFF free (3k3)
; C000 -> C3FF window stack C000 no of windows - all in words ; C000 -> C3FF window stack C000 no of windows - all in words
; C402 -> C7FF window position in stack ; C402 -> C7FF window position in stack
; D000 -> D1FF FDC controller ; D000 -> D1FF FDC controller
; D200 -> D3FF FDC controller for Fat12 ; D200 -> D3FF FDC controller for Fat12
; D400 -> DFFF free ; D400 -> DFFF free (3k)
; E000 byte multitasking started ; E000 byte multitasking started
; E020 dword putpixel address ; E020 dword putpixel address
; E024 dword getpixel address ; E024 dword getpixel address
; E030 dword Vesa 1.2 pm bank switch address ; E030 dword Vesa 1.2 pm bank switch address
; E034 -> F1FF free (4k5)
; F200 dword mousepicture -pointer ; F200 dword mousepicture -pointer
; F204 dword mouse appearance counter ; F204 dword mouse appearance counter
; F208 -> F2FF free (248)
; F300 dword x & y temp for windowmove ; F300 dword x & y temp for windowmove
; F304 -> F3FF free (252)
; F400 byte no of keys in buffer ; F400 byte no of keys in buffer
; F401 byte 'buffer' ; F401 byte 'buffer'
; F402 -> F4FF reserved for keys ; F402 -> F4FF reserved for keys
@@ -96,8 +99,13 @@
; F501 dword 'buffer' ; F501 dword 'buffer'
; F502 -> F5FF reserved for buttons ; F502 -> F5FF reserved for buttons
; F600 dword tsc / second ; F600 dword tsc / second
; F604 byte mouse port: 1 ps2, 2 com1, 3 com2 ; F604 byte (unused?) mouse port: 1 ps2, 2 com1, 3 com2
; FB00 -> FB0F mouse memory 00 chunk count - FB0A-B x - FB0C-D y ; F605 -> FAFF free (1k2)
; FB00 -> FB0F mouse memory 00 chunk count, that includes:
; FB08 word -- mouse H-scroll
; FB0A word -- mouse x
; FB0C word -- mouse y
; FB0E word -- mouse V-scroll
; FB10 -> FB17 mouse color mem ; FB10 -> FB17 mouse color mem
; FB21 x move ; FB21 x move
; FB22 y move ; FB22 y move
@@ -109,18 +117,21 @@
; FBF1 byte bits per pixel ; FBF1 byte bits per pixel
; FC00 -> FCFE com1/ps2 buffer ; FC00 -> FCFE com1/ps2 buffer
; FCFF com1/ps2 buffer count starting from FC00 ; FCFF com1/ps2 buffer count starting from FC00
; FD00 -> FDFF free (256)
; FE00 dword screen x size ; FE00 dword screen x size
; FE04 dword screen y size ; FE04 dword screen y size
; FE08 dword screen y multiplier ; FE08 dword screen y multiplier
; FE0C dword screen mode ; FE0C dword screen mode
; FE10 -> FE7F free (112)
; FE80 dword address of LFB in physical ; FE80 dword address of LFB in physical
; FE84 dword address of applications memory start in physical ; FE84 dword address of applications memory start in physical ?
; FE88 dword address of button list ; FE88 dword address of button list
; FE8C dword memory to use ; FE8C dword memory to use
; FE90 -> FEFF free (112)
; FF00 byte 1 = system shutdown request ; FF00 byte 1 = system shutdown request
; FF01 dword free ; FF01 byte task activation request?
; FFF0 byte 1 = redraw background request from app ; FFF0 byte >0 if redraw background request from app
; FFF1 byte 1 = diskette int occur ; FFF1 byte >0 if background changed
; FFF2 write and read bank in screen ; FFF2 write and read bank in screen
; FFF4 byte 0 if first mouse draw & do not return picture under ; FFF4 byte 0 if first mouse draw & do not return picture under
; FFF5 byte 1 do not draw pointer ; FFF5 byte 1 do not draw pointer
@@ -177,20 +188,22 @@
; BC dword address of debug event memory ; BC dword address of debug event memory
; C0 5 dd thread debug registers: DR0,DR1,DR2,DR3,DR7 ; C0 5 dd thread debug registers: DR0,DR1,DR2,DR3,DR7
; ;
; 0x80090000 -> 9FFFF tmp ; 0x80090000 -> 9FFFF tmp (64k) - unused?
; 0x800A0000 -> AFFFF screen access area ; 0x800A0000 -> AFFFF screen access area
; 0x800B0000 -> FFFFF bios rest in peace -area ; 0x800B0000 -> FFFFF bios rest in peace -area (320k) ?
; 0x80100000 -> 27FFFF diskette image ; 0x80100000 -> 27FFFF diskette image (1m5)
; 0x80280000 -> 281FFF ramdisk fat ; 0x80280000 -> 281FFF ramdisk fat (8k)
; 0x80282000 -> 283FFF floppy fat ; 0x80282000 -> 283FFF floppy fat (8k)
; ;
; 0x80284000 -> 28BFFF HDD DMA AREA ; 0x80284000 -> 28BFFF HDD DMA AREA (32k)
; 0x8028C000 -> 297FFF free (48 Kb) ; 0x8028C000 -> 297FFF free (48k)
; ;
; 0x80298000 -> 29ffff auxiliary table for background smoothing code ; 0x80298000 -> 29ffff auxiliary table for background smoothing code (32k)
; ;
; 0x802A0000 -> 2B00ff wav device data ; 0x802A0000 -> 2B00ff wav device buffer (64k)
; 0x802C0000 -> 2C3fff button info ; 0x802A0000 -> 2B00ff wav device status (256)
; 0x802B0100 -> 2Bffff free (63k8)
; 0x802C0000 -> 2C3fff button info (8k)
; ;
; 0000 word number of buttons ; 0000 word number of buttons
; first button entry at 0x10 ; first button entry at 0x10
@@ -202,9 +215,9 @@
; +000A word y size ; +000A word y size
; +000C word button id number : bits 16-31 ; +000C word button id number : bits 16-31
; ;
; 0x802C4000 -> 2CFFFF free (48Kb) ; 0x802C4000 -> 2CFFFF free (48k)
; ;
; 0x802D0000 -> 2DFFFF reserved port area ; 0x802D0000 -> 2DFFFF reserved port area (64k)
; ;
; 0000 dword no of port areas reserved ; 0000 dword no of port areas reserved
; 0010 dword process id ; 0010 dword process id
@@ -212,34 +225,37 @@
; dword end port ; dword end port
; dword 0 ; dword 0
; ;
; 0x802E0000 -> 2EFFFF irq data area ; 0x802E0000 -> 2EFFFF irq data area (64k)
; 0x802F0000 -> 2FFFFF low memory save ; 0x802F0000 -> 2FFFFF low memory save (64k)
; ;
; 0x80300000 -> 31FFFF tcp memory 128 Kb ; 0x80300000 -> 31FFFF tcp memory (128k)
; 0x80320000 -> 327FFF tcp memory 32 Kb ; 0x80320000 -> 327FFF tcp memory (32k)
; ;
; 0x80328000 -> 32FFFF !vrr driver 32 Kb ; 0x80328000 -> 32FFFF !vrr driver (32k)
; 0x80330000 -> 377FFF skin data ; 0x80330000 -> 377FFF skin data (32k)
; 0x80338000 -> 33AFFF draw data - 256 entries ; 0x80338000 -> 338FFF draw data - 256 entries (4k)
; 00 dword draw limit - x start ; 00 dword draw limit - x start
; 04 dword draw limit - y start ; 04 dword draw limit - y start
; 08 dword draw limit - x end ; 08 dword draw limit - x end
; 0C dword draw limit - y end ; 0C dword draw limit - y end
; 0x80339000 -> 3BFFF3 free (12k)
; 0x8033BFF4 -> 33BFFF background info
; 0x8033C000 page map (length b = memsize shr 15)
; 0x8033C000 + b start of static pagetables
; 0x8033C000 -> 47BFFF display info ; 0x803FFFFF <- no direct address translation beyond this point
; =============================================================
; 0x8047CF80 -> 47CFFF TSS 128 bytes ; 0x805FF000 -> 5FFF80 TSS
; 0x8047D000 -> 47EFFF IO map for (8192*8)=65536 ports ; 0x80600000 -> 601FFF i/o maps
; 0x8047F000 -> 48FFFF page map max 128 Kb
;
; 0x80800000 -> kernel heap ; 0x80800000 -> kernel heap
; 0x81FFFFFF heap min limit ; 0x80FFFFFF heap min limit
; 0xFDBFFFFF heap max limit ; 0xFDBFFFFF heap max limit
; 0xF0000000 -> 0xF1FFFFFF PCI-express extended config space
; 0xFDC00000 -> 0xFDFFFFFF page tables 4Mb ; 0xFDC00000 -> 0xFDFFFFFF page tables 4Mb
; 0xFE000000 -> 0xFFFFFFFF LFB 32Mb ; 0xFE000000 -> 0xFFFFFFFF LFB 32Mb
; 0xFE000000 -> 0xFE7FFFFF application available LFB 8Mb ; 0xFE000000 -> 0xFE7FFFFF application available LFB 8Mb

View File

@@ -150,6 +150,13 @@ macro ntohw reg {
} }
wait_mutex: ; stub
inc dword [ebx]
ret
include "queue.inc" include "queue.inc"
include "ethernet.inc" include "ethernet.inc"

View File

@@ -33,7 +33,7 @@ macro ccall proc,[arg] ; directly call CDECL procedure
end if end if
call proc call proc
if size@ccall if size@ccall
add esp,size@ccall add esp, size@ccall
end if } end if }
macro cinvoke proc,[arg] ; indirectly call CDECL procedure macro cinvoke proc,[arg] ; indirectly call CDECL procedure
@@ -47,7 +47,7 @@ macro cinvoke proc,[arg] ; indirectly call CDECL procedure
end if end if
call [proc] call [proc]
if size@ccall if size@ccall
add esp,size@ccall add esp, size@ccall
end if } end if }
macro proc [args] ; define procedure macro proc [args] ; define procedure
@@ -60,9 +60,9 @@ prologue@proc equ prologuedef
macro prologuedef procname,flag,parmbytes,localbytes,reglist macro prologuedef procname,flag,parmbytes,localbytes,reglist
{ if parmbytes | localbytes { if parmbytes | localbytes
push ebp push ebp
mov ebp,esp mov ebp, esp
if localbytes if localbytes
sub esp,localbytes sub esp, localbytes
end if end if
end if end if
irps reg, reglist \{ push reg \} } irps reg, reglist \{ push reg \} }
@@ -203,11 +203,11 @@ macro initlocal@proc name,def
end if end if
end virtual end virtual
if current@initlocal = 1 if current@initlocal = 1
mov byte [name+position@initlocal],byte@initlocal mov byte [name+position@initlocal], byte@initlocal
else if current@initlocal = 2 else if current@initlocal = 2
mov word [name+position@initlocal],word@initlocal mov word [name+position@initlocal], word@initlocal
else else
mov dword [name+position@initlocal],dword@initlocal mov dword [name+position@initlocal], dword@initlocal
end if end if
position@initlocal = position@initlocal + current@initlocal position@initlocal = position@initlocal + current@initlocal
end while } end while }

View File

@@ -21,22 +21,22 @@ $Revision$
align 4 align 4
sound_interface: sound_interface:
cmp eax, edi ; this is subfunction #55 ? cmp eax, ebx ; this is subfunction #55 ?
jne retFunc55 ; if no then return. jne retFunc55 ; if no then return.
cmp byte [sound_flag],0 cmp byte [sound_flag], 0
jne retFunc55 jne retFunc55
movzx eax, byte [countDelayNote] movzx eax, byte [countDelayNote]
or al, al ; player is busy ? or al, al ; player is busy ?
jnz retFunc55 ; return counter delay Note jnz retFunc55 ; return counter delay Note
mov [memAdrNote],edx mov [memAdrNote], esi;edx
call get_pid call get_pid
mov [pidProcessNote],eax mov [pidProcessNote], eax
xor eax, eax ; Ok! EAX = 0 xor eax, eax ; Ok! EAX = 0
retFunc55: retFunc55:
mov [esp+36], eax ; return value EAX for application mov [esp+32], eax ; return value EAX for application
ret ret
iglobal iglobal
@@ -84,9 +84,9 @@ playNote:
mov [countDelayNote], al mov [countDelayNote], al
; lodsw ; load AX - counter for Note! ; lodsw ; load AX - counter for Note!
call ReadNoteByte call ReadNoteByte
mov ah,al mov ah, al
call ReadNoteByte call ReadNoteByte
xchg al,ah xchg al, ah
jmp pokeNote jmp pokeNote
EndPlayNote: ; THE END Play Notes! EndPlayNote: ; THE END Play Notes!
@@ -99,16 +99,16 @@ playNote:
mov al, ah ; AL = Upper byte counter channel 2 mov al, ah ; AL = Upper byte counter channel 2
out 0x42, al ; restore Upper byte channel 2 out 0x42, al ; restore Upper byte channel 2
xor eax, eax ; EAX = 0 xor eax, eax ; EAX = 0
mov [memAdrNote], eax ; clear header control Delay-Note string mov [memAdrNote], eax; clear header control Delay-Note string
NextDelayNote: NextDelayNote:
mov [countDelayNote], al ; save new counter delay Note mov [countDelayNote], al; save new counter delay Note
pop eax pop eax
NotPlayNotes: NotPlayNotes:
RET RET
NoteforOctave: NoteforOctave:
sub al, 0x81 ; correction value for delay Note sub al, 0x81 ; correction value for delay Note
mov [countDelayNote], al ; save counter delay this new Note mov [countDelayNote], al; save counter delay this new Note
; lodsb ; load pack control code ; lodsb ; load pack control code
call ReadNoteByte call ReadNoteByte
cmp al, 0xFF ; this is PAUSE ? cmp al, 0xFF ; this is PAUSE ?
@@ -124,7 +124,7 @@ playNote:
dec al ; correction dec al ; correction
add al, al ; transform number to offset constant add al, al ; transform number to offset constant
movsx eax, al ; EAX - offset movsx eax, al ; EAX - offset
add eax, dword kontrOctave ; EAX - address from constant add eax, dword kontrOctave; EAX - address from constant
mov ax, [eax] ; read constant mov ax, [eax] ; read constant
shr cl, 4 ; transform for number Octave shr cl, 4 ; transform for number Octave
shr ax, cl ; calculate from Note this Octave! shr ax, cl ; calculate from Note this Octave!
@@ -147,13 +147,13 @@ ReadNoteByte:
push edx push edx
push esi push esi
mov eax,[pidProcessNote] mov eax, [pidProcessNote]
call pid_to_slot call pid_to_slot
test eax,eax test eax, eax
jz .failed jz .failed
lea ecx,[esp+12] lea ecx, [esp+12]
mov edx,1 mov edx, 1
mov esi,[memAdrNote] mov esi, [memAdrNote]
inc [memAdrNote] inc [memAdrNote]
call read_process_memory call read_process_memory

View File

@@ -21,7 +21,7 @@ unpack:
push eax push eax
add esi, 12 add esi, 12
and al, not 0xC0 and al, not 0xC0
dec eax dec al
jz .lzma jz .lzma
.failed: .failed:
pop eax pop eax
@@ -219,7 +219,8 @@ end if
cmp bl, 10 cmp bl, 10
jb @f jb @f
mov al, 6 mov al, 6
@@: sub bl, al @@:
sub bl, al
jmp .main_loop jmp .main_loop
.1: .1:
lea eax, [.IsRep*4 + ebx*4] lea eax, [.IsRep*4 + ebx*4]

View File

@@ -0,0 +1,444 @@
struc BLITTER
{
.dc.xmin rd 1 ; 0
.dc.ymin rd 1 ; 4
.dc.xmax rd 1 ; 8
.dc.ymax rd 1 ; 12
.sc:
.sc.xmin rd 1 ; 16
.sc.ymin rd 1 ; 20
.sc.xmax rd 1 ; 24
.sc.ymax rd 1 ; 28
.dst_x rd 1 ; 32
.dst_y rd 1 ; 36
.src_x rd 1 ; 40
.src_y rd 1 ; 44
.w rd 1 ; 48
.h rd 1 ; 52
.bitmap rd 1 ; 56
.stride rd 1 ; 60
}
virtual at 0
BLITTER BLITTER
end virtual
align 4
__L1OutCode:
push ebx
mov ebx, 8
cmp edx, [eax]
jl .L2
xor ebx, ebx
cmp edx, [eax+8]
setg bl
sal ebx, 2
.L2:
cmp ecx, [eax+4]
jge .L3
or ebx, 1
jmp .L4
.L3:
cmp ecx, [eax+12]
jle .L4
or ebx, 2
.L4:
mov eax, ebx
pop ebx
ret
align 4
block_clip:
push ebp
push edi
push esi
push ebx
sub esp, 4
mov ebx, eax
mov [esp], edx
mov ebp, ecx
mov ecx, [ecx]
mov edx, [edx]
call __L1OutCode
mov esi, eax
mov edx, [esp+28]
mov ecx, [edx]
.L21:
mov eax, [esp+24]
mov edx, [eax]
mov eax, ebx
call __L1OutCode
mov edi, eax
.L20:
mov eax, edi
and eax, esi
jne .L9
cmp esi, edi
je .L9
test esi, esi
jne .L10
test edi, 1
je .L11
mov eax, [ebx+4]
jmp .L25
.L11:
test edi, 2
je .L13
mov eax, [ebx+12]
.L25:
mov edx, [esp+28]
jmp .L22
.L13:
test edi, 4
je .L14
mov eax, [ebx+8]
jmp .L26
.L14:
and edi, 8
je .L12
mov eax, [ebx]
.L26:
mov edx, [esp+24]
.L22:
mov [edx], eax
.L12:
mov eax, [esp+28]
mov ecx, [eax]
jmp .L21
.L10:
test esi, 1
je .L16
mov eax, [ebx+4]
jmp .L23
.L16:
test esi, 2
je .L18
mov eax, [ebx+12]
.L23:
mov [ebp+0], eax
jmp .L17
.L18:
test esi, 4
je .L19
mov eax, [ebx+8]
jmp .L24
.L19:
and esi, 8
je .L17
mov eax, [ebx]
.L24:
mov edx, [esp]
mov [edx], eax
.L17:
mov ecx, [ebp+0]
mov eax, [esp]
mov edx, [eax]
mov eax, ebx
call __L1OutCode
mov esi, eax
jmp .L20
.L9:
add esp, 4
pop ebx
pop esi
pop edi
pop ebp
ret
align 4
blit_clip:
.sx0 equ 36
.sy0 equ 32
.sx1 equ 28
.sy1 equ 24
.dx0 equ 20
.dy0 equ 16
.dx1 equ 12
.dy1 equ 8
push edi
push esi
push ebx
sub esp, 40
mov ebx, ecx
mov edx, [ecx+BLITTER.src_x]
mov [esp+.sx0], edx
mov eax, [ecx+BLITTER.src_y]
mov [esp+.sy0], eax
add edx, [ecx+BLITTER.w]
dec edx
mov [esp+.sx1], edx
add eax, [ecx+BLITTER.h]
dec eax
mov [esp+.sy1], eax
lea ecx, [esp+.sy0]
lea edx, [esp+.sx0]
lea eax, [ebx+BLITTER.sc]
lea esi, [esp+.sy1]
mov [esp+4], esi
lea esi, [esp+.sx1]
mov [esp], esi
call block_clip
mov esi, 1
test eax, eax
jne .L28
mov edi, [esp+.sx0]
mov edx, [ebx+BLITTER.dst_x]
add edx, edi
sub edx, [ebx+BLITTER.src_x]
mov [esp+.dx0], edx
mov ecx, [esp+.sy0]
mov eax, [ebx+BLITTER.dst_y]
add eax, ecx
sub eax, [ebx+BLITTER.src_y]
mov [esp+.dy0], eax
sub edx, edi
add edx, [esp+.sx1]
mov [esp+.dx1], edx
sub eax, ecx
add eax, [esp+.sy1]
mov [esp+.dy1], eax
lea ecx, [esp+.dy0]
lea edx, [esp+.dx0]
lea eax, [esp+.dy1]
mov [esp+4], eax
lea eax, [esp+.dx1]
mov [esp], eax
mov eax, ebx
call block_clip
test eax, eax
jne .L28
mov edx, [esp+.dx0]
mov eax, [esp+.dx1]
inc eax
sub eax, edx
mov [ebx+BLITTER.w], eax
mov eax, [esp+.dy0]
mov ecx, [esp+.dy1]
inc ecx
sub ecx, eax
mov [ebx+BLITTER.h], ecx
mov ecx, [ebx+BLITTER.src_x]
add ecx, edx
sub ecx, [ebx+BLITTER.dst_x]
mov [ebx+BLITTER.src_x], ecx
mov ecx, [ebx+BLITTER.src_y]
add ecx, eax
sub ecx, [ebx+BLITTER.dst_y]
mov [ebx+BLITTER.src_y], ecx
mov [ebx+BLITTER.dst_x], edx
mov [ebx+BLITTER.dst_y], eax
xor esi, esi
.L28:
mov eax, esi
add esp, 40
pop ebx
pop esi
pop edi
purge .sx0
purge .sy0
purge .sx1
purge .sy1
purge .dx0
purge .dy0
purge .dx1
purge .dy1
ret
align 4
blit_32:
push ebp
push edi
push esi
push ebx
sub esp, 72
mov eax, [TASK_BASE]
mov ebx, [eax-twdw + WDATA.box.width]
mov edx, [eax-twdw + WDATA.box.height]
xor eax, eax
mov [esp+BLITTER.dc.xmin], eax
mov [esp+BLITTER.dc.ymin], eax
mov [esp+BLITTER.dc.xmax], ebx
mov [esp+BLITTER.dc.ymax], edx
mov [esp+BLITTER.sc.xmin], eax
mov [esp+BLITTER.sc.ymin], eax
mov eax, [ecx+24]
dec eax
mov [esp+BLITTER.sc.xmax], eax
mov eax, [ecx+28]
dec eax
mov [esp+BLITTER.sc.ymax], eax
mov eax, [ecx]
mov [esp+BLITTER.dst_x], eax
mov eax, [ecx+4]
mov [esp+BLITTER.dst_y], eax
mov eax, [ecx+16]
mov [esp+BLITTER.src_x], eax
mov eax, [ecx+20]
mov [esp+BLITTER.src_y], eax
mov eax, [ecx+8]
mov [esp+BLITTER.w], eax
mov eax, [ecx+12]
mov [esp+BLITTER.h], eax
mov eax, [ecx+32]
mov [esp+56], eax
mov eax, [ecx+36]
mov [esp+60], eax
mov ecx, esp
call blit_clip
test eax, eax
jne .L57
inc [mouse_pause]
call [_display.disable_mouse]
mov eax, [TASK_BASE]
mov ebx, [esp+BLITTER.dst_x]
mov ebp, [esp+BLITTER.dst_y]
add ebx, [eax-twdw + WDATA.box.left]
add ebp, [eax-twdw + WDATA.box.top]
mov edi, ebp
imul edi, [_display.pitch]
imul ebp, [_display.width]
add ebp, ebx
add ebp, [_WinMapAddress]
mov eax, [esp+BLITTER.src_y]
imul eax, [esp+BLITTER.stride]
mov esi, [esp+BLITTER.src_x]
lea esi, [eax+esi*4]
add esi, [esp+BLITTER.bitmap]
mov ecx, [esp+BLITTER.h]
mov edx, [esp+BLITTER.w]
test ecx, ecx ;FIXME check clipping
jz .L57
test edx, edx
jz .L57
cmp [_display.bpp], 32
jne .core_24
lea edi, [edi+ebx*4]
mov ebx, [CURRENT_TASK]
align 4
.outer32:
xor ecx, ecx
align 4
.inner32:
cmp [ebp+ecx], bl
jne @F
mov eax, [esi+ecx*4]
mov [LFB_BASE+edi+ecx*4], eax
@@:
inc ecx
dec edx
jnz .inner32
add esi, [esp+BLITTER.stride]
add edi, [_display.pitch]
add ebp, [_display.width]
mov edx, [esp+BLITTER.w]
dec [esp+BLITTER.h]
jnz .outer32
.done:
dec [mouse_pause]
call [draw_pointer]
.L57:
add esp, 72
pop ebx
pop esi
pop edi
pop ebp
ret
.core_24:
lea ebx, [ebx+ebx*2]
lea edi, [LFB_BASE+edi+ebx]
mov ebx, [CURRENT_TASK]
align 4
.outer24:
mov [esp+64], edi
xor ecx, ecx
align 4
.inner24:
cmp [ebp+ecx], bl
jne @F
mov eax, [esi+ecx*4]
lea edi, [edi+ecx*2]
mov [edi+ecx], ax
shr eax, 16
mov [edi+ecx+2], al
@@:
mov edi, [esp+64]
inc ecx
dec edx
jnz .inner24
add esi, [esp+BLITTER.stride]
add edi, [_display.pitch]
add ebp, [_display.width]
mov edx, [esp+BLITTER.w]
dec [esp+BLITTER.h]
jnz .outer24
jmp .done

View File

@@ -44,8 +44,8 @@ proc init_cursor stdcall, dst:dword, src:dword
endl endl
mov esi, [src] mov esi, [src]
add esi,[esi+18] add esi, [esi+18]
mov eax,esi mov eax, esi
cmp [esi+BI.biBitCount], 24 cmp [esi+BI.biBitCount], 24
je .img_24 je .img_24
@@ -56,22 +56,22 @@ proc init_cursor stdcall, dst:dword, src:dword
.img_2: .img_2:
add eax, [esi] add eax, [esi]
mov [pQuad],eax mov [pQuad], eax
add eax,8 add eax, 8
mov [pBits],eax mov [pBits], eax
add eax, 128 add eax, 128
mov [pAnd],eax mov [pAnd], eax
mov eax,[esi+4] mov eax, [esi+4]
mov [width],eax mov [width], eax
mov ebx,[esi+8] mov ebx, [esi+8]
shr ebx,1 shr ebx, 1
mov [height],ebx mov [height], ebx
mov edi, [dst] mov edi, [dst]
add edi, 32*31*4 add edi, 32*31*4
mov [rBase],edi mov [rBase], edi
mov esi,[pQuad] mov esi, [pQuad]
.l21: .l21:
mov ebx, [pBits] mov ebx, [pBits]
mov ebx, [ebx] mov ebx, [ebx]
@@ -82,12 +82,12 @@ proc init_cursor stdcall, dst:dword, src:dword
mov [counter], 32 mov [counter], 32
@@: @@:
xor edx, edx xor edx, edx
shl eax,1 shl eax, 1
setc dl setc dl
dec edx dec edx
xor ecx, ecx xor ecx, ecx
shl ebx,1 shl ebx, 1
setc cl setc cl
mov ecx, [esi+ecx*4] mov ecx, [esi+ecx*4]
and ecx, edx and ecx, edx
@@ -101,31 +101,31 @@ proc init_cursor stdcall, dst:dword, src:dword
add [pBits], 4 add [pBits], 4
add [pAnd], 4 add [pAnd], 4
mov edi,[rBase] mov edi, [rBase]
sub edi,128 sub edi, 128
mov [rBase],edi mov [rBase], edi
sub [height],1 sub [height], 1
jnz .l21 jnz .l21
ret ret
.img_4: .img_4:
add eax, [esi] add eax, [esi]
mov [pQuad],eax mov [pQuad], eax
add eax,64 add eax, 64
mov [pBits],eax mov [pBits], eax
add eax, 0x200 add eax, 0x200
mov [pAnd],eax mov [pAnd], eax
mov eax,[esi+4] mov eax, [esi+4]
mov [width],eax mov [width], eax
mov ebx,[esi+8] mov ebx, [esi+8]
shr ebx,1 shr ebx, 1
mov [height],ebx mov [height], ebx
mov edi, [dst] mov edi, [dst]
add edi, 32*31*4 add edi, 32*31*4
mov [rBase],edi mov [rBase], edi
mov esi,[pQuad] mov esi, [pQuad]
mov ebx, [pBits] mov ebx, [pBits]
.l4: .l4:
mov eax, [pAnd] mov eax, [pAnd]
@@ -134,7 +134,7 @@ proc init_cursor stdcall, dst:dword, src:dword
mov [counter], 16 mov [counter], 16
@@: @@:
xor edx, edx xor edx, edx
shl eax,1 shl eax, 1
setc dl setc dl
dec edx dec edx
@@ -148,7 +148,7 @@ proc init_cursor stdcall, dst:dword, src:dword
mov [edi], edx mov [edi], edx
xor edx, edx xor edx, edx
shl eax,1 shl eax, 1
setc dl setc dl
dec edx dec edx
@@ -166,30 +166,30 @@ proc init_cursor stdcall, dst:dword, src:dword
jnz @B jnz @B
add [pAnd], 4 add [pAnd], 4
mov edi,[rBase] mov edi, [rBase]
sub edi,128 sub edi, 128
mov [rBase],edi mov [rBase], edi
sub [height],1 sub [height], 1
jnz .l4 jnz .l4
ret ret
.img_8: .img_8:
add eax, [esi] add eax, [esi]
mov [pQuad],eax mov [pQuad], eax
add eax,1024
mov [pBits],eax
add eax, 1024 add eax, 1024
mov [pAnd],eax mov [pBits], eax
mov eax,[esi+4] add eax, 1024
mov [width],eax mov [pAnd], eax
mov ebx,[esi+8] mov eax, [esi+4]
shr ebx,1 mov [width], eax
mov [height],ebx mov ebx, [esi+8]
shr ebx, 1
mov [height], ebx
mov edi, [dst] mov edi, [dst]
add edi, 32*31*4 add edi, 32*31*4
mov [rBase],edi mov [rBase], edi
mov esi,[pQuad] mov esi, [pQuad]
mov ebx, [pBits] mov ebx, [pBits]
.l81: .l81:
mov eax, [pAnd] mov eax, [pAnd]
@@ -198,7 +198,7 @@ proc init_cursor stdcall, dst:dword, src:dword
mov [counter], 32 mov [counter], 32
@@: @@:
xor edx, edx xor edx, edx
shl eax,1 shl eax, 1
setc dl setc dl
dec edx dec edx
@@ -215,28 +215,28 @@ proc init_cursor stdcall, dst:dword, src:dword
jnz @B jnz @B
add [pAnd], 4 add [pAnd], 4
mov edi,[rBase] mov edi, [rBase]
sub edi,128 sub edi, 128
mov [rBase],edi mov [rBase], edi
sub [height],1 sub [height], 1
jnz .l81 jnz .l81
ret ret
.img_24: .img_24:
add eax, [esi] add eax, [esi]
mov [pQuad],eax mov [pQuad], eax
add eax, 0xC00 add eax, 0xC00
mov [pAnd],eax mov [pAnd], eax
mov eax,[esi+BI.biWidth] mov eax, [esi+BI.biWidth]
mov [width],eax mov [width], eax
mov ebx,[esi+BI.biHeight] mov ebx, [esi+BI.biHeight]
shr ebx,1 shr ebx, 1
mov [height],ebx mov [height], ebx
mov edi, [dst] mov edi, [dst]
add edi, 32*31*4 add edi, 32*31*4
mov [rBase],edi mov [rBase], edi
mov esi,[pAnd] mov esi, [pAnd]
mov ebx, [pQuad] mov ebx, [pQuad]
.row_24: .row_24:
mov eax, [esi] mov eax, [esi]
@@ -244,7 +244,7 @@ proc init_cursor stdcall, dst:dword, src:dword
mov [counter], 32 mov [counter], 32
@@: @@:
xor edx, edx xor edx, edx
shl eax,1 shl eax, 1
setc dl setc dl
dec edx dec edx
@@ -260,10 +260,10 @@ proc init_cursor stdcall, dst:dword, src:dword
jnz @B jnz @B
add esi, 4 add esi, 4
mov edi,[rBase] mov edi, [rBase]
sub edi,128 sub edi, 128
mov [rBase],edi mov [rBase], edi
sub [height],1 sub [height], 1
jnz .row_24 jnz .row_24
ret ret
endp endp
@@ -305,7 +305,7 @@ create_cursor:
test eax, eax test eax, eax
jz .fail jz .fail
mov [.hcursor],eax mov [.hcursor], eax
xor ebx, ebx xor ebx, ebx
mov [eax+CURSOR.magic], 'CURS' mov [eax+CURSOR.magic], 'CURS'
@@ -332,19 +332,13 @@ create_cursor:
stdcall init_cursor, eax, esi stdcall init_cursor, eax, esi
mov eax, [.hcursor] mov ecx, [.hcursor]
lea eax, [eax+CURSOR.list_next] lea ecx, [ecx+CURSOR.list_next]
lea edx, [_display.cr_list.next] lea edx, [_display.cr_list.next]
pushfd pushfd
cli cli
mov ecx, [edx] list_add ecx, edx ;list_add_tail(new, head)
mov [eax], ecx
mov [eax+4], edx
mov [ecx+4], eax
mov [edx], eax
popfd popfd
mov eax, [.hcursor] mov eax, [.hcursor]
@@ -458,8 +452,16 @@ destroy_cursor:
push eax push eax
stdcall kernel_free, [eax+CURSOR.base] stdcall kernel_free, [eax+CURSOR.base]
pop eax
mov eax, [esp]
lea eax, [eax+CURSOR.list_next]
pushfd
cli
list_del eax
popfd
pop eax
call destroy_kernel_object call destroy_kernel_object
ret ret
@@ -573,7 +575,7 @@ proc move_cursor_24 stdcall, hcursor:dword, x:dword, y:dword
mul dword [BytesPerScanLine] mul dword [BytesPerScanLine]
lea edx, [LFB_BASE+ecx*3] lea edx, [LFB_BASE+ecx*3]
add edx, eax add edx, eax
mov [cur_saved_base],edx mov [cur_saved_base], edx
cmp ebx, [Screen_Max_X] cmp ebx, [Screen_Max_X]
jbe @F jbe @F
@@ -627,7 +629,7 @@ proc move_cursor_24 stdcall, hcursor:dword, x:dword, y:dword
jz @F jz @F
mov [edi], ax mov [edi], ax
shr eax, 16 shr eax, 16
mov [edi+2],al mov [edi+2], al
@@: @@:
add edi, 3 add edi, 3
dec ecx dec ecx
@@ -677,7 +679,7 @@ proc move_cursor_32 stdcall, hcursor:dword, x:dword, y:dword
mul dword [BytesPerScanLine] mul dword [BytesPerScanLine]
lea edx, [LFB_BASE+eax+ecx*4] lea edx, [LFB_BASE+eax+ecx*4]
mov [cur_saved_base],edx mov [cur_saved_base], edx
cmp ebx, [Screen_Max_X] cmp ebx, [Screen_Max_X]
jbe @F jbe @F
@@ -761,7 +763,7 @@ init_display:
mov [edi+display_t.cr_list.next], ecx mov [edi+display_t.cr_list.next], ecx
mov [edi+display_t.cr_list.prev], ecx mov [edi+display_t.cr_list.prev], ecx
cmp [SCR_MODE],word 0x13 cmp [SCR_MODE], word 0x13
jbe .fail jbe .fail
test word [SCR_MODE], 0x4000 test word [SCR_MODE], 0x4000
@@ -792,14 +794,6 @@ init_display:
ret ret
align 4 align 4
def_arrow: def_arrow:
file 'arrow.cur' file 'arrow.cur'

File diff suppressed because it is too large Load Diff

View File

@@ -51,7 +51,7 @@ Vesa20_getpixel24:
; eax = x ; eax = x
; ebx = y ; ebx = y
imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier
lea edi, [eax+eax*2] ; edi = x*3 lea edi, [eax+eax*2]; edi = x*3
add edi, ebx ; edi = x*3+(y*y multiplier) add edi, ebx ; edi = x*3+(y*y multiplier)
mov ecx, [LFB_BASE+edi] mov ecx, [LFB_BASE+edi]
and ecx, 0xffffff and ecx, 0xffffff
@@ -59,7 +59,7 @@ Vesa20_getpixel24:
Vesa20_getpixel32: Vesa20_getpixel32:
imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier
lea edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier) lea edi, [ebx+eax*4]; edi = x*4+(y*y multiplier)
mov ecx, [LFB_BASE+edi] mov ecx, [LFB_BASE+edi]
and ecx, 0xffffff and ecx, 0xffffff
ret ret
@@ -128,7 +128,7 @@ vesa20_putimage:
add ebx, [putimg.image_cy] add ebx, [putimg.image_cy]
mov [putimg.abs_cy], ebx mov [putimg.abs_cy], ebx
; real_sx = MIN(wnd_sx-image_cx, image_sx); ; real_sx = MIN(wnd_sx-image_cx, image_sx);
mov ebx, [eax-twdw + WDATA.box.width] ; ebx = wnd_sx mov ebx, [eax-twdw + WDATA.box.width]; ebx = wnd_sx
; \begin{diamond}[20.08.2006] ; \begin{diamond}[20.08.2006]
; note that WDATA.box.width is one pixel less than real window x-size ; note that WDATA.box.width is one pixel less than real window x-size
inc ebx inc ebx
@@ -145,7 +145,7 @@ vesa20_putimage:
.end_x: .end_x:
mov [putimg.real_sx], ebx mov [putimg.real_sx], ebx
; init real_sy ; init real_sy
mov ebx, [eax-twdw + WDATA.box.height] ; ebx = wnd_sy mov ebx, [eax-twdw + WDATA.box.height]; ebx = wnd_sy
; \begin{diamond}[20.08.2006] ; \begin{diamond}[20.08.2006]
inc ebx inc ebx
; \end{diamond}[20.08.2006] ; \end{diamond}[20.08.2006]
@@ -227,8 +227,8 @@ align 4
jnz .new_x jnz .new_x
; pop edx ebp ; pop edx ebp
add esi, [putimg.line_increment] add esi, [putimg.line_increment]
add edx, [putimg.screen_newline] ;[BytesPerScanLine] add edx, [putimg.screen_newline];[BytesPerScanLine]
add ebp, [putimg.winmap_newline] ;[Screen_Max_X] add ebp, [putimg.winmap_newline];[Screen_Max_X]
; inc ebp ; inc ebp
cmp [putimg.ebp], putimage_get1bpp cmp [putimg.ebp], putimage_get1bpp
jz .correct jz .correct
@@ -270,8 +270,8 @@ align 4
jnz .new_x jnz .new_x
; pop edx ebp ; pop edx ebp
add esi, [putimg.line_increment] add esi, [putimg.line_increment]
add edx, [putimg.screen_newline] ;[BytesPerScanLine] add edx, [putimg.screen_newline];[BytesPerScanLine]
add ebp, [putimg.winmap_newline] ;[Screen_Max_X] add ebp, [putimg.winmap_newline];[Screen_Max_X]
; inc ebp ; inc ebp
cmp [putimg.ebp], putimage_get1bpp cmp [putimg.ebp], putimage_get1bpp
jz .correct jz .correct
@@ -289,7 +289,7 @@ align 4
add esp, putimg.stack_data add esp, putimg.stack_data
popad popad
call VGA__putimage call VGA__putimage
mov [EGA_counter],1 mov [EGA_counter], 1
ret ret
@@ -308,13 +308,13 @@ __sys_putpixel:
jb .exit jb .exit
cmp [Screen_Max_Y], ebx cmp [Screen_Max_Y], ebx
jb .exit jb .exit
test edi,1 ; force ? test edi, 1 ; force ?
jnz .forced jnz .forced
; not forced: ; not forced:
push eax push eax
mov edx,[_display.width] ; screen x size mov edx, [_display.width]; screen x size
imul edx, ebx imul edx, ebx
add eax, [_WinMapAddress] add eax, [_WinMapAddress]
movzx edx, byte [eax+edx] movzx edx, byte [eax+edx]
@@ -324,14 +324,14 @@ __sys_putpixel:
.forced: .forced:
; check if negation ; check if negation
test ecx,0x01000000 test ecx, 0x01000000
jz .noneg jz .noneg
call getpixel call getpixel
not ecx not ecx
mov [esp+32-8],ecx mov [esp+32-8], ecx
.noneg: .noneg:
; OK to set pixel ; OK to set pixel
call dword [PUTPIXEL] ; call the real put_pixel function call dword [PUTPIXEL]; call the real put_pixel function
.exit: .exit:
popad popad
ret ret
@@ -341,7 +341,7 @@ Vesa20_putpixel24:
; eax = x ; eax = x
; ebx = y ; ebx = y
imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier
lea edi, [eax+eax*2] ; edi = x*3 lea edi, [eax+eax*2]; edi = x*3
mov eax, [esp+32-8+4] mov eax, [esp+32-8+4]
mov [LFB_BASE+ebx+edi], ax mov [LFB_BASE+ebx+edi], ax
shr eax, 16 shr eax, 16
@@ -354,8 +354,8 @@ Vesa20_putpixel32:
; eax = x ; eax = x
; ebx = y ; ebx = y
imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier imul ebx, [BytesPerScanLine] ; ebx = y * y multiplier
lea edi, [ebx+eax*4] ; edi = x*4+(y*y multiplier) lea edi, [ebx+eax*4]; edi = x*4+(y*y multiplier)
mov eax, [esp+32-8+4] ; eax = color mov eax, [esp+32-8+4]; eax = color
mov [LFB_BASE+edi], eax mov [LFB_BASE+edi], eax
ret ret
@@ -422,7 +422,7 @@ dl_dy equ esp+0
push ebp ; save y2-y1 push ebp ; save y2-y1
jl .y2ly1 ; is y2 less than y1 ? jl .y2ly1 ; is y2 less than y1 ?
jg .no_hline ; y1 > y2 ? jg .no_hline ; y1 > y2 ?
mov edx, [dl_x2] ; else (if y1=y2) mov edx, [dl_x2]; else (if y1=y2)
call hline call hline
jmp .exit jmp .exit
@@ -431,7 +431,7 @@ dl_dy equ esp+0
.no_hline: .no_hline:
cmp ebp, esi cmp ebp, esi
jle .x_rules ; |y2-y1| < |x2-x1| ? jle .x_rules ; |y2-y1| < |x2-x1| ?
cmp [dl_y2], ebx ; make sure y1 is at the begining cmp [dl_y2], ebx; make sure y1 is at the begining
jge .no_reverse1 jge .no_reverse1
neg dword [dl_dx] neg dword [dl_dx]
mov edx, [dl_x2] mov edx, [dl_x2]
@@ -445,8 +445,16 @@ dl_dy equ esp+0
cdq ; extend eax sing to edx cdq ; extend eax sing to edx
shl eax, 16 ; using 16bit fix-point maths shl eax, 16 ; using 16bit fix-point maths
idiv ebp ; eax = ((x2-x1)*65536)/(y2-y1) idiv ebp ; eax = ((x2-x1)*65536)/(y2-y1)
;--------------------------------------
; correction for the remainder of the division
shl edx, 1
cmp ebp, edx
jb @f
inc eax
@@:
;--------------------------------------
mov edx, ebp ; edx = counter (number of pixels to draw) mov edx, ebp ; edx = counter (number of pixels to draw)
mov ebp, 1 *65536 ; <<16 ; ebp = dy = 1.0 mov ebp, 1 *65536; <<16 ; ebp = dy = 1.0
mov esi, eax ; esi = dx mov esi, eax ; esi = dx
jmp .y_rules jmp .y_rules
@@ -466,18 +474,41 @@ dl_dy equ esp+0
cdq ; extend eax sing to edx cdq ; extend eax sing to edx
shl eax, 16 ; using 16bit fix-point maths shl eax, 16 ; using 16bit fix-point maths
idiv esi ; eax = ((y2-y1)*65536)/(x2-x1) idiv esi ; eax = ((y2-y1)*65536)/(x2-x1)
;--------------------------------------
; correction for the remainder of the division
shl edx, 1
cmp esi, edx
jb @f
inc eax
@@:
;--------------------------------------
mov edx, esi ; edx = counter (number of pixels to draw) mov edx, esi ; edx = counter (number of pixels to draw)
mov esi, 1 *65536 ;<< 16 ; esi = dx = 1.0 mov esi, 1 *65536;<< 16 ; esi = dx = 1.0
mov ebp, eax ; ebp = dy mov ebp, eax ; ebp = dy
.y_rules: .y_rules:
mov eax, [dl_x1] mov eax, [dl_x1]
mov ebx, [dl_y1] mov ebx, [dl_y1]
shl eax, 16 shl eax, 16
shl ebx, 16 shl ebx, 16
;-----------------------------------------------------------------------------
align 4 align 4
.draw: .draw:
push eax ebx push eax ebx
;--------------------------------------
; correction for the remainder of the division
test ah, 0x80
jz @f
add eax, 1 shl 16
@@:
;--------------------------------------
shr eax, 16 shr eax, 16
;--------------------------------------
; correction for the remainder of the division
test bh, 0x80
jz @f
add ebx, 1 shl 16
@@:
;--------------------------------------
shr ebx, 16 shr ebx, 16
call [putpixel] call [putpixel]
pop ebx eax pop ebx eax
@@ -578,12 +609,12 @@ vesa20_drawbar:
mov [drbar.bar_cx], eax mov [drbar.bar_cx], eax
mov [drbar.bar_cy], ebx mov [drbar.bar_cy], ebx
mov edi, [TASK_BASE] mov edi, [TASK_BASE]
add eax, [edi-twdw + WDATA.box.left] ; win_cx add eax, [edi-twdw + WDATA.box.left]; win_cx
add ebx, [edi-twdw + WDATA.box.top] ; win_cy add ebx, [edi-twdw + WDATA.box.top]; win_cy
mov [drbar.abs_cx], eax mov [drbar.abs_cx], eax
mov [drbar.abs_cy], ebx mov [drbar.abs_cy], ebx
; real_sx = MIN(wnd_sx-bar_cx, bar_sx); ; real_sx = MIN(wnd_sx-bar_cx, bar_sx);
mov ebx, [edi-twdw + WDATA.box.width] ; ebx = wnd_sx mov ebx, [edi-twdw + WDATA.box.width]; ebx = wnd_sx
; \begin{diamond}[20.08.2006] ; \begin{diamond}[20.08.2006]
; note that WDATA.box.width is one pixel less than real window x-size ; note that WDATA.box.width is one pixel less than real window x-size
inc ebx inc ebx
@@ -603,7 +634,7 @@ vesa20_drawbar:
.end_x: .end_x:
mov [drbar.real_sx], ebx mov [drbar.real_sx], ebx
; real_sy = MIN(wnd_sy-bar_cy, bar_sy); ; real_sy = MIN(wnd_sy-bar_cy, bar_sy);
mov ebx, [edi-twdw + WDATA.box.height] ; ebx = wnd_sy mov ebx, [edi-twdw + WDATA.box.height]; ebx = wnd_sy
; \begin{diamond}[20.08.2006] ; \begin{diamond}[20.08.2006]
inc ebx inc ebx
; \end{diamond} ; \end{diamond}
@@ -733,7 +764,7 @@ align 4
popad popad
call VGA_draw_bar call VGA_draw_bar
xor eax, eax xor eax, eax
mov [EGA_counter],1 mov [EGA_counter], 1
ret ret
align 4 align 4
@@ -1002,7 +1033,7 @@ sdp4:
sdpdone: sdpdone:
add esp, 44 add esp, 44
popad popad
mov [EGA_counter],1 mov [EGA_counter], 1
call VGA_drawbackground call VGA_drawbackground
ret ret

View File

@@ -17,44 +17,44 @@ $Revision$
paletteVGA: paletteVGA:
;16 colour palette ;16 colour palette
mov dx,0x3c8 mov dx, 0x3c8
mov al,0 mov al, 0
out dx,al out dx, al
mov ecx,16 mov ecx, 16
mov dx,0x3c9 mov dx, 0x3c9
xor eax,eax xor eax, eax
palvganew: palvganew:
mov al,0 mov al, 0
test ah,4 test ah, 4
jz palvgalbl1 jz palvgalbl1
add al,31 add al, 31
test ah,8 test ah, 8
jz palvgalbl1 jz palvgalbl1
add al,32 add al, 32
palvgalbl1: palvgalbl1:
out dx,al ; red 0,31 or 63 out dx, al; red 0,31 or 63
mov al,0 mov al, 0
test ah,2 test ah, 2
jz palvgalbl2 jz palvgalbl2
add al,31 add al, 31
test ah,8 test ah, 8
jz palvgalbl2 jz palvgalbl2
add al,32 add al, 32
palvgalbl2: palvgalbl2:
out dx,al ; blue 0,31 or 63 out dx, al; blue 0,31 or 63
mov al,0 mov al, 0
test ah,1 test ah, 1
jz palvgalbl3 jz palvgalbl3
add al,31 add al, 31
test ah,8 test ah, 8
jz palvgalbl3 jz palvgalbl3
add al,32 add al, 32
palvgalbl3: palvgalbl3:
out dx,al ; green 0,31 or 63 out dx, al; green 0,31 or 63
add ah,1 add ah, 1
loop palvganew loop palvganew
; mov dx, 3ceh ; mov dx, 3ceh
; mov ax, 0005h ; mov ax, 0005h
@@ -63,53 +63,53 @@ paletteVGA:
palette320x200: palette320x200:
mov edx,0x3c8 mov edx, 0x3c8
xor eax, eax
out dx, al
mov ecx, 256
mov edx, 0x3c9
xor eax, eax xor eax, eax
out dx,al
mov ecx,256
mov edx,0x3c9
xor eax,eax
palnew: palnew:
mov al,0 mov al, 0
test ah,64 test ah, 64
jz pallbl1 jz pallbl1
add al,21 add al, 21
pallbl1: pallbl1:
test ah,128 test ah, 128
jz pallbl2 jz pallbl2
add al,42 add al, 42
pallbl2: pallbl2:
out dx,al out dx, al
mov al,0 mov al, 0
test ah,8 test ah, 8
jz pallbl3 jz pallbl3
add al,8 add al, 8
pallbl3: pallbl3:
test ah,16 test ah, 16
jz pallbl4 jz pallbl4
add al,15 add al, 15
pallbl4: pallbl4:
test ah,32 test ah, 32
jz pallbl5 jz pallbl5
add al,40 add al, 40
pallbl5: pallbl5:
out dx,al out dx, al
mov al,0 mov al, 0
test ah,1 test ah, 1
jz pallbl6 jz pallbl6
add al,8 add al, 8
pallbl6: pallbl6:
test ah,2 test ah, 2
jz pallbl7 jz pallbl7
add al,15 add al, 15
pallbl7: pallbl7:
test ah,4 test ah, 4
jz pallbl8 jz pallbl8
add al,40 add al, 40
pallbl8: pallbl8:
out dx,al out dx, al
add ah,1 add ah, 1
loop palnew loop palnew
ret ret
@@ -126,95 +126,95 @@ endg
align 4 align 4
checkVga_N13: checkVga_N13:
cmp [SCR_MODE],dword 0x13 cmp [SCR_MODE], dword 0x13
jne @f jne @f
; cnvl: ; cnvl:
pushad pushad
cmp [EGA_counter],1 cmp [EGA_counter], 1
je novesal je novesal
mov ecx,[MOUSE_X] mov ecx, [MOUSE_X]
cmp ecx,[novesachecksum] cmp ecx, [novesachecksum]
jne novesal jne novesal
popad popad
@@: @@:
ret ret
novesal: novesal:
mov [novesachecksum],ecx mov [novesachecksum], ecx
mov ecx,0 mov ecx, 0
movzx eax,word [MOUSE_Y] movzx eax, word [MOUSE_Y]
cmp eax,100 cmp eax, 100
jge m13l3 jge m13l3
mov eax,100 mov eax, 100
m13l3: m13l3:
cmp eax,480-100 cmp eax, 480-100
jbe m13l4 jbe m13l4
mov eax,480-100 mov eax, 480-100
m13l4: m13l4:
sub eax,100 sub eax, 100
imul eax,640*4 imul eax, 640*4
add ecx,eax add ecx, eax
movzx eax,word [MOUSE_X] movzx eax, word [MOUSE_X]
cmp eax,160 cmp eax, 160
jge m13l1 jge m13l1
mov eax,160 mov eax, 160
m13l1: m13l1:
cmp eax,640-160 cmp eax, 640-160
jbe m13l2 jbe m13l2
mov eax,640-160 mov eax, 640-160
m13l2: m13l2:
sub eax,160 sub eax, 160
shl eax,2 shl eax, 2
add ecx,eax add ecx, eax
mov esi,[LFBAddress] mov esi, [LFBAddress]
add esi,ecx add esi, ecx
mov edi,VGABasePtr mov edi, VGABasePtr
mov edx,200 mov edx, 200
mov ecx,320 mov ecx, 320
cld cld
m13pix: m13pix:
lodsd lodsd
test eax,eax test eax, eax
jz .save_pixel jz .save_pixel
push eax push eax
mov ebx,eax mov ebx, eax
and eax,(128+64+32) ; blue and eax, (128+64+32) ; blue
shr eax,5 shr eax, 5
and ebx,(128+64+32)*256 ; green and ebx, (128+64+32)*256; green
shr ebx,8+2 shr ebx, 8+2
add eax,ebx add eax, ebx
pop ebx pop ebx
and ebx,(128+64)*256*256 ; red and ebx, (128+64)*256*256; red
shr ebx,8+8 shr ebx, 8+8
add eax,ebx add eax, ebx
.save_pixel: .save_pixel:
stosb stosb
loop m13pix loop m13pix
mov ecx,320 mov ecx, 320
add esi,4*(640-320) add esi, 4*(640-320)
dec edx dec edx
jnz m13pix jnz m13pix
mov [EGA_counter],0 mov [EGA_counter], 0
popad popad
ret ret
VGA_drawbackground: VGA_drawbackground:
; draw all ; draw all
cmp [SCR_MODE],dword 0x12 cmp [SCR_MODE], dword 0x12
jne .end jne .end
pushad pushad
mov esi,[LFBAddress] mov esi, [LFBAddress]
mov edi,VGABasePtr mov edi, VGABasePtr
mov ebx,640/32 ; 640*480/(8*4) mov ebx, 640/32; 640*480/(8*4)
mov edx,480 mov edx, 480
@@: @@:
push ebx edx esi edi push ebx edx esi edi
shl edx,9 shl edx, 9
lea edx,[edx+edx*4] lea edx, [edx+edx*4]
add esi,edx add esi, edx
shr edx,5 shr edx, 5
add edi,edx add edi, edx
call VGA_draw_long_line call VGA_draw_long_line
pop edi esi edx ebx pop edi esi edx ebx
dec edx dec edx
@@ -225,72 +225,72 @@ VGA_drawbackground:
ret ret
VGA_draw_long_line: VGA_draw_long_line:
mov dx,3ceh mov dx, 3ceh
mov ax,0ff08h mov ax, 0ff08h
cli cli
out dx, ax out dx, ax
mov ax,0005h mov ax, 0005h
out dx, ax out dx, ax
m12pix: m12pix:
call VGA_draw_32_pixels call VGA_draw_32_pixels
dec ebx dec ebx
jnz m12pix jnz m12pix
mov dx,3c4h mov dx, 3c4h
mov ax,0ff02h mov ax, 0ff02h
out dx,ax out dx, ax
mov dx,3ceh mov dx, 3ceh
mov ax,0205h mov ax, 0205h
out dx,ax out dx, ax
mov dx,3ceh mov dx, 3ceh
mov al,08h mov al, 08h
out dx,al out dx, al
sti sti
ret ret
VGA_draw_32_pixels: VGA_draw_32_pixels:
xor eax,eax xor eax, eax
mov ebp,VGA_8_pixels mov ebp, VGA_8_pixels
mov [ebp],eax mov [ebp], eax
mov [ebp+4],eax mov [ebp+4], eax
mov [ebp+8],eax mov [ebp+8], eax
mov [ebp+12],eax mov [ebp+12], eax
mov ch,4 mov ch, 4
.main_loop: .main_loop:
mov cl,8 mov cl, 8
.convert_pixels_to_VGA: .convert_pixels_to_VGA:
lodsd ; eax = 24bit colour lodsd ; eax = 24bit colour
test eax,eax test eax, eax
jz .end jz .end
rol eax,8 rol eax, 8
mov al,ch mov al, ch
ror eax,8 ror eax, 8
mov ch,1 mov ch, 1
dec cl dec cl
shl ch,cl shl ch, cl
cmp al,85 cmp al, 85
jbe .p13green jbe .p13green
or [ebp],ch or [ebp], ch
cmp al,170 cmp al, 170
jbe .p13green jbe .p13green
or [ebp+12],ch or [ebp+12], ch
.p13green: .p13green:
cmp ah,85 cmp ah, 85
jbe .p13red jbe .p13red
or [ebp+4],ch or [ebp+4], ch
cmp ah,170 cmp ah, 170
jbe .p13red jbe .p13red
or [ebp+12],ch or [ebp+12], ch
.p13red: .p13red:
shr eax,8 shr eax, 8
cmp ah,85 cmp ah, 85
jbe .p13cont jbe .p13cont
or [ebp+8],ch or [ebp+8], ch
cmp ah,170 cmp ah, 170
jbe .p13cont jbe .p13cont
or [ebp+12],ch or [ebp+12], ch
.p13cont: .p13cont:
ror eax,8 ror eax, 8
mov ch,ah mov ch, ah
inc cl inc cl
.end: .end:
dec cl dec cl
@@ -299,77 +299,77 @@ VGA_draw_32_pixels:
dec ch dec ch
jnz .main_loop jnz .main_loop
push esi push esi
sub ebp,4 sub ebp, 4
mov esi,ebp mov esi, ebp
mov dx, 3c4h mov dx, 3c4h
mov ah, 1h mov ah, 1h
@@: @@:
mov al, 02h mov al, 02h
out dx,ax out dx, ax
xchg ax,bp xchg ax, bp
lodsd lodsd
mov [edi],eax mov [edi], eax
xchg ax,bp xchg ax, bp
shl ah, 1 shl ah, 1
cmp ah, 10h cmp ah, 10h
jnz @r jnz @r
add edi,4 add edi, 4
pop esi pop esi
ret ret
VGA_putpixel: VGA_putpixel:
; eax = x ; eax = x
; ebx = y ; ebx = y
mov ecx,eax mov ecx, eax
mov eax, [esp+32-8+4] ; color mov eax, [esp+32-8+4] ; color
shl ebx,9 shl ebx, 9
lea ebx,[ebx+ebx*4] ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> 5 lea ebx, [ebx+ebx*4] ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> 5
lea edx, [ebx+ecx*4] ; + x*BytesPerPixel (Vesa2.0 32) lea edx, [ebx+ecx*4] ; + x*BytesPerPixel (Vesa2.0 32)
mov edi,edx mov edi, edx
add edi, [LFBAddress] ; + LFB address add edi, [LFBAddress] ; + LFB address
mov [edi], eax ; write to LFB for Vesa2.0 mov [edi], eax ; write to LFB for Vesa2.0
shr edx,5 ; change BytesPerPixel to 1/8 shr edx, 5 ; change BytesPerPixel to 1/8
mov edi,edx mov edi, edx
add edi, VGABasePtr ; address of pixel in VGA area add edi, VGABasePtr ; address of pixel in VGA area
and ecx,0x07 ; bit no. (modulo 8) and ecx, 0x07 ; bit no. (modulo 8)
pushfd pushfd
; edi = address, eax = 24bit colour, ecx = bit no. (modulo 8) ; edi = address, eax = 24bit colour, ecx = bit no. (modulo 8)
xor edx,edx xor edx, edx
test eax,eax test eax, eax
jz .p13cont jz .p13cont
cmp al,85 cmp al, 85
jbe .p13green jbe .p13green
or dl,0x01 or dl, 0x01
cmp al,170 cmp al, 170
jbe .p13green jbe .p13green
or dl,0x08 or dl, 0x08
.p13green: .p13green:
cmp ah,85 cmp ah, 85
jbe .p13red jbe .p13red
or dl,0x02 or dl, 0x02
cmp ah,170 cmp ah, 170
jbe .p13red jbe .p13red
or dl,0x08 or dl, 0x08
.p13red: .p13red:
shr eax,8 shr eax, 8
cmp ah,85 cmp ah, 85
jbe .p13cont jbe .p13cont
or dl,0x04 or dl, 0x04
cmp ah,170 cmp ah, 170
jbe .p13cont jbe .p13cont
or dl,0x08 or dl, 0x08
.p13cont: .p13cont:
ror edx,8 ror edx, 8
inc cl inc cl
xor eax,eax xor eax, eax
inc ah inc ah
shr ax,cl shr ax, cl
mov dx,3cfh mov dx, 3cfh
cli cli
out dx,al out dx, al
mov al,[edi] ; dummy read mov al, [edi] ; dummy read
rol edx,8 rol edx, 8
mov [edi],dl mov [edi], dl
popfd popfd
;.end: ;.end:
ret ret
@@ -377,16 +377,16 @@ VGA_putpixel:
VGA__putimage: VGA__putimage:
; ecx = size [x|y] ; ecx = size [x|y]
; edx = coordinates [x|y] ; edx = coordinates [x|y]
cmp [SCR_MODE],dword 0x12 cmp [SCR_MODE], dword 0x12
jne @f jne @f
pushad pushad
rol edx,16 rol edx, 16
movzx eax,dx movzx eax, dx
rol edx,16 rol edx, 16
movzx ebx,dx movzx ebx, dx
movzx edx,cx movzx edx, cx
rol ecx,16 rol ecx, 16
movzx ecx,cx movzx ecx, cx
call VGA_draw_bar_1 call VGA_draw_bar_1
popad popad
@@: @@:
@@ -397,37 +397,37 @@ VGA_draw_bar:
; ebx cy ; ebx cy
; ecx xe ; ecx xe
; edx ye ; edx ye
cmp [SCR_MODE],dword 0x12 cmp [SCR_MODE], dword 0x12
jne @f jne @f
pushad pushad
sub ecx,eax sub ecx, eax
sub edx,ebx sub edx, ebx
and eax,0xffff and eax, 0xffff
and ebx,0xffff and ebx, 0xffff
and ecx,0xffff and ecx, 0xffff
and edx,0xffff and edx, 0xffff
call VGA_draw_bar_1 call VGA_draw_bar_1
popad popad
@@: @@:
ret ret
VGA_draw_bar_1: VGA_draw_bar_1:
mov [temp.cx],eax mov [temp.cx], eax
mov eax, [TASK_BASE] mov eax, [TASK_BASE]
add ebx, [eax-twdw + 4] add ebx, [eax-twdw + 4]
mov eax, [eax-twdw + 0] mov eax, [eax-twdw + 0]
add eax, [temp.cx] add eax, [temp.cx]
and eax,0xfff8 and eax, 0xfff8
shl ebx,9 shl ebx, 9
lea ebx,[ebx+ebx*4] ; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> 5 lea ebx, [ebx+ebx*4]; <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> 5
lea ebx, [ebx+eax*4] ; + x*BytesPerPixel (Vesa2.0 32) lea ebx, [ebx+eax*4] ; + x*BytesPerPixel (Vesa2.0 32)
mov esi,ebx mov esi, ebx
add esi, [LFBAddress] ; + LFB address add esi, [LFBAddress] ; + LFB address
shr ebx,5 ; change BytesPerPixel to 1/8 shr ebx, 5 ; change BytesPerPixel to 1/8
mov edi,ebx mov edi, ebx
add edi, VGABasePtr ; address of pixel in VGA area add edi, VGABasePtr ; address of pixel in VGA area
mov ebx,ecx mov ebx, ecx
shr ebx,5 shr ebx, 5
inc ebx inc ebx
.main_loop: .main_loop:
call VGA_draw_long_line_1 call VGA_draw_long_line_1
@@ -438,11 +438,11 @@ VGA_draw_bar_1:
VGA_draw_long_line_1: VGA_draw_long_line_1:
push ebx edx esi edi push ebx edx esi edi
shl edx,9 shl edx, 9
lea edx,[edx+edx*4] lea edx, [edx+edx*4]
add esi,edx add esi, edx
shr edx,5 shr edx, 5
add edi,edx add edi, edx
call VGA_draw_long_line call VGA_draw_long_line
pop edi esi edx ebx pop edi esi edx ebx
ret ret