Kernel supports up to three IDE controllers, and all the devices connected to them

git-svn-id: svn://kolibrios.org@4700 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Marat Zakiyanov (Mario79)
2014-03-27 20:44:32 +00:00
parent 5879ec3de3
commit ba19a6400d
17 changed files with 2134 additions and 2029 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,271 +0,0 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Copyright (C) KolibriOS team 2004-2011. All rights reserved. ;;
;; Copyright (C) MenuetOS 2000-2004 Ville Mikael Turjanmaa ;;
;; Distributed under terms of the GNU General Public License ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
$Revision$
sys_cd_audio:
cmp word [cdbase], word 0
jnz @f
mov eax, 1
ret
@@:
; eax=1 cdplay at ebx 0x00FFSSMM
; eax=2 get tracklist size of ecx to [ebx]
; eax=3 stop/pause playing
cmp eax, 1
jnz nocdp
call sys_cdplay
ret
nocdp:
cmp eax, 2
jnz nocdtl
mov edi, [TASK_BASE]
add edi, TASKDATA.mem_start
add ebx, [edi]
call sys_cdtracklist
ret
nocdtl:
cmp eax, 3
jnz nocdpause
call sys_cdpause
ret
nocdpause:
mov eax, 0xffffff01
ret
sys_cd_atapi_command:
pushad
mov dx, word [cdbase]
add dx, 6
mov ax, word [cdid]
out dx, al
mov esi, 10
call delay_ms
mov dx, word [cdbase]
add dx, 7
in al, dx
and al, 0x80
cmp al, 0
jnz res
jmp cdl6
res:
mov dx, word [cdbase]
add dx, 7
mov al, 0x8
out dx, al
mov dx, word [cdbase]
add dx, 0x206
mov al, 0xe
out dx, al
mov esi, 1
call delay_ms
mov dx, word [cdbase]
add dx, 0x206
mov al, 0x8
out dx, al
mov esi, 30
call delay_ms
xor cx, cx
cdl5:
inc cx
cmp cx, 10
jz cdl6
mov dx, word [cdbase]
add dx, 7
in al, dx
and al, 0x88
cmp al, 0x00
jz cdl5
mov esi, 100
call delay_ms
jmp cdl5
cdl6:
mov dx, word [cdbase]
add dx, 4
mov al, 0
out dx, al
mov dx, word [cdbase]
add dx, 5
mov al, 0
out dx, al
mov dx, word [cdbase]
add dx, 7
mov al, 0xec
out dx, al
mov esi, 5
call delay_ms
mov dx, word [cdbase]
add dx, 1
mov al, 0
out dx, al
add dx, 1
mov al, 0
out dx, al
add dx, 1
mov al, 0
out dx, al
add dx, 1
mov al, 0
out dx, al
add dx, 1
mov al, 128
out dx, al
add dx, 2
mov al, 0xa0
out dx, al
xor cx, cx
mov dx, word [cdbase]
add dx, 7
cdl1:
inc cx
cmp cx, 100
jz cdl2
in al, dx
and ax, 0x88
cmp al, 0x8
jz cdl2
mov esi, 2
call delay_ms
jmp cdl1
cdl2:
popad
ret
sys_cdplay:
mov ax, 5
push ax
push ebx
cdplay:
call sys_cd_atapi_command
cli
mov dx, word [cdbase]
mov ax, 0x0047
out dx, ax
mov al, 1
mov ah, [esp+0]; min xx
out dx, ax
mov ax, [esp+1]; fr sec
out dx, ax
mov ax, 256+99
out dx, ax
mov ax, 0x0001
out dx, ax
mov ax, 0x0000
out dx, ax
mov esi, 10
call delay_ms
sti
add dx, 7
in al, dx
test al, 1
jz cdplayok
mov ax, [esp+4]
dec ax
mov [esp+4], ax
cmp ax, 0
jz cdplayfail
jmp cdplay
cdplayfail:
cdplayok:
pop ebx
pop ax
xor eax, eax
ret
sys_cdtracklist:
push ebx
tcdplay:
call sys_cd_atapi_command
mov dx, word [cdbase]
mov ax, 0x43+2*256
out dx, ax
mov ax, 0x0
out dx, ax
mov ax, 0x0
out dx, ax
mov ax, 0x0
out dx, ax
mov ax, 200
out dx, ax
mov ax, 0x0
out dx, ax
in al, dx
mov cx, 1000
mov dx, word [cdbase]
add dx, 7
cld
cdtrnwewait:
mov esi, 10
call delay_ms
in al, dx
and al, 128
cmp al, 0
jz cdtrl1
loop cdtrnwewait
cdtrl1:
; read the result
mov ecx, [esp+0]
mov dx, word [cdbase]
cdtrread:
add dx, 7
in al, dx
and al, 8
cmp al, 8
jnz cdtrdone
sub dx, 7
in ax, dx
mov [ecx], ax
add ecx, 2
jmp cdtrread
cdtrdone:
pop ecx
xor eax, eax
ret
sys_cdpause:
call sys_cd_atapi_command
mov dx, word [cdbase]
mov ax, 0x004B
out dx, ax
mov ax, 0
out dx, ax
mov ax, 0
out dx, ax
mov ax, 0
out dx, ax
mov ax, 0
out dx, ax
mov ax, 0
out dx, ax
mov esi, 10
call delay_ms
add dx, 7
in al, dx
xor eax, eax
ret

View File

@@ -17,7 +17,7 @@ hdbase dd ?
hdid dd ? hdid dd ?
hdpos dd ? hdpos dd ?
ends ends
;-----------------------------------------------------------------------------
iglobal iglobal
align 4 align 4
ide_callbacks: ide_callbacks:
@@ -35,18 +35,34 @@ hd0_data HD_DATA ?, 0, 1
hd1_data HD_DATA ?, 0x10, 2 hd1_data HD_DATA ?, 0x10, 2
hd2_data HD_DATA ?, 0, 3 hd2_data HD_DATA ?, 0, 3
hd3_data HD_DATA ?, 0x10, 4 hd3_data HD_DATA ?, 0x10, 4
hd4_data HD_DATA ?, 0, 5
hd5_data HD_DATA ?, 0x10, 6
hd6_data HD_DATA ?, 0, 7
hd7_data HD_DATA ?, 0x10, 8
hd8_data HD_DATA ?, 0, 9
hd9_data HD_DATA ?, 0x10, 10
hd10_data HD_DATA ?, 0, 11
hd11_data HD_DATA ?, 0x10, 12
hd_address_table: ide_mutex_table:
dd 0x1f0, 0x00, 0x1f0, 0x10 dd ide_channel1_mutex
dd 0x170, 0x00, 0x170, 0x10 dd ide_channel2_mutex
dd ide_channel3_mutex
dd ide_channel4_mutex
dd ide_channel5_mutex
dd ide_channel6_mutex
endg endg
;-----------------------------------------------------------------------------
uglobal uglobal
ide_mutex MUTEX ide_mutex MUTEX
ide_channel1_mutex MUTEX ide_channel1_mutex MUTEX
ide_channel2_mutex MUTEX ide_channel2_mutex MUTEX
ide_channel3_mutex MUTEX
ide_channel4_mutex MUTEX
ide_channel5_mutex MUTEX
ide_channel6_mutex MUTEX
endg endg
;-----------------------------------------------------------------------------
proc ide_read stdcall uses edi, \ proc ide_read stdcall uses edi, \
hd_data, buffer, startsector:qword, numsectors hd_data, buffer, startsector:qword, numsectors
; hd_data = pointer to hd*_data ; hd_data = pointer to hd*_data
@@ -67,15 +83,13 @@ endl
; 2. Acquire the global lock. ; 2. Acquire the global lock.
mov ecx, ide_mutex mov ecx, ide_mutex
call mutex_lock call mutex_lock
mov ecx, ide_channel2_mutex
mov eax, [hd_data] mov ecx, [hd_data]
push ecx mov ecx, [ecx+HD_DATA.hdpos]
mov ecx, [hd_address_table] dec ecx
cmp [eax+HD_DATA.hdbase], ecx ; 0x1F0 shr ecx, 1
pop ecx shl ecx, 2
jne .IDE_Channel_2 mov ecx, [ecx + ide_mutex_table]
mov ecx, ide_channel1_mutex
.IDE_Channel_2:
mov [channel_lock], ecx mov [channel_lock], ecx
call mutex_lock call mutex_lock
; 3. Convert parameters to the form suitable for worker procedures. ; 3. Convert parameters to the form suitable for worker procedures.
@@ -83,6 +97,7 @@ endl
; Worker procedures use global variables and edi for [buffer]. ; Worker procedures use global variables and edi for [buffer].
cmp dword [startsector+4], 0 cmp dword [startsector+4], 0
jnz .fail jnz .fail
and [hd_error], 0 and [hd_error], 0
mov ecx, [hd_data] mov ecx, [hd_data]
mov eax, [ecx+HD_DATA.hdbase] mov eax, [ecx+HD_DATA.hdbase]
@@ -98,55 +113,51 @@ endl
; DMA read is permitted if [allow_dma_access]=1 or 2 ; DMA read is permitted if [allow_dma_access]=1 or 2
cmp [allow_dma_access], 2 cmp [allow_dma_access], 2
ja .nodma ja .nodma
cmp [dma_hdd], 1
jnz .nodma
;--------------------------------------
push eax
mov eax, [hd_address_table]
cmp [hdbase], eax ; 0x1F0
pop eax
jnz @f
test [DRIVE_DATA+1], byte 10100000b cmp [ecx+IDE_DATA.dma_hdd], 1
jnz .nodma jnz .nodma
jmp .dma
@@:
test [DRIVE_DATA+1], byte 1010b
jnz .nodma
.dma:
;--------------------------------------
call hd_read_dma call hd_read_dma
jmp @f jmp @f
;--------------------------------------
.nodma: .nodma:
call hd_read_pio call hd_read_pio
;--------------------------------------
@@: @@:
cmp [hd_error], 0 cmp [hd_error], 0
jnz .fail jnz .fail
mov ecx, [numsectors] mov ecx, [numsectors]
inc dword [ecx] ; one more sector is read inc dword [ecx] ; one more sector is read
dec [sectors_todo] dec [sectors_todo]
jz .done jz .done
inc eax inc eax
jnz .sectors_loop jnz .sectors_loop
;--------------------------------------
; 5. Loop is done, either due to error or because everything is done. ; 5. Loop is done, either due to error or because everything is done.
; Release the global lock and return the corresponding status. ; Release the global lock and return the corresponding status.
.fail: .fail:
mov ecx, [channel_lock] mov ecx, [channel_lock]
call mutex_unlock call mutex_unlock
mov ecx, ide_mutex mov ecx, ide_mutex
call mutex_unlock call mutex_unlock
or eax, -1 or eax, -1
ret ret
;--------------------------------------
.done: .done:
mov ecx, [channel_lock] mov ecx, [channel_lock]
call mutex_unlock call mutex_unlock
mov ecx, ide_mutex mov ecx, ide_mutex
call mutex_unlock call mutex_unlock
xor eax, eax xor eax, eax
ret ret
endp endp
;-----------------------------------------------------------------------------
proc ide_write stdcall uses esi edi, \ proc ide_write stdcall uses esi edi, \
hd_data, buffer, startsector:qword, numsectors hd_data, buffer, startsector:qword, numsectors
; hd_data = pointer to hd*_data ; hd_data = pointer to hd*_data
@@ -167,15 +178,13 @@ endl
; 2. Acquire the global lock. ; 2. Acquire the global lock.
mov ecx, ide_mutex mov ecx, ide_mutex
call mutex_lock call mutex_lock
mov ecx, ide_channel2_mutex
mov eax, [hd_data] mov ecx, [hd_data]
push ecx mov ecx, [ecx+HD_DATA.hdpos]
mov ecx, [hd_address_table] dec ecx
cmp [eax+HD_DATA.hdbase], ecx ; 0x1F0 shr ecx, 1
pop ecx shl ecx, 2
jne .IDE_Channel_2 mov ecx, [ecx + ide_mutex_table]
mov ecx, ide_channel1_mutex
.IDE_Channel_2:
mov [channel_lock], ecx mov [channel_lock], ecx
call mutex_lock call mutex_lock
; 3. Convert parameters to the form suitable for worker procedures. ; 3. Convert parameters to the form suitable for worker procedures.
@@ -183,6 +192,7 @@ endl
; Worker procedures use global variables and esi for [buffer]. ; Worker procedures use global variables and esi for [buffer].
cmp dword [startsector+4], 0 cmp dword [startsector+4], 0
jnz .fail jnz .fail
and [hd_error], 0 and [hd_error], 0
mov ecx, [hd_data] mov ecx, [hd_data]
mov eax, [ecx+HD_DATA.hdbase] mov eax, [ecx+HD_DATA.hdbase]
@@ -200,66 +210,65 @@ endl
mov ecx, 16 mov ecx, 16
cmp ecx, [sectors_todo] cmp ecx, [sectors_todo]
jbe @f jbe @f
mov ecx, [sectors_todo] mov ecx, [sectors_todo]
;--------------------------------------
@@: @@:
mov [cache_chain_size], cl mov [cache_chain_size], cl
; DMA write is permitted only if [allow_dma_access]=1 ; DMA write is permitted only if [allow_dma_access]=1
cmp [allow_dma_access], 2 cmp [allow_dma_access], 2
jae .nodma jae .nodma
cmp [dma_hdd], 1
jnz .nodma
;--------------------------------------
push eax
mov eax, [hd_address_table]
cmp [hdbase], eax ; 0x1F0
pop eax
jnz @f
test [DRIVE_DATA+1], byte 10100000b cmp [ecx+IDE_DATA.dma_hdd], 1
jnz .nodma jnz .nodma
jmp .dma
@@:
test [DRIVE_DATA+1], byte 1010b
jnz .nodma
.dma:
;--------------------------------------
call cache_write_dma call cache_write_dma
jmp .common jmp .common
;--------------------------------------
.nodma: .nodma:
mov [cache_chain_size], 1 mov [cache_chain_size], 1
call cache_write_pio call cache_write_pio
;--------------------------------------
.common: .common:
cmp [hd_error], 0 cmp [hd_error], 0
jnz .fail jnz .fail
movzx ecx, [cache_chain_size] movzx ecx, [cache_chain_size]
mov eax, [numsectors] mov eax, [numsectors]
add [eax], ecx add [eax], ecx
sub [sectors_todo], ecx sub [sectors_todo], ecx
jz .done jz .done
add [edi], ecx add [edi], ecx
jc .fail jc .fail
shl ecx, 9 shl ecx, 9
add esi, ecx add esi, ecx
jmp .sectors_loop jmp .sectors_loop
;--------------------------------------
; 5. Loop is done, either due to error or because everything is done. ; 5. Loop is done, either due to error or because everything is done.
; Release the global lock and return the corresponding status. ; Release the global lock and return the corresponding status.
.fail: .fail:
mov ecx, [channel_lock] mov ecx, [channel_lock]
call mutex_unlock call mutex_unlock
mov ecx, ide_mutex mov ecx, ide_mutex
call mutex_unlock call mutex_unlock
or eax, -1 or eax, -1
ret ret
;--------------------------------------
.done: .done:
mov ecx, [channel_lock] mov ecx, [channel_lock]
call mutex_unlock call mutex_unlock
mov ecx, ide_mutex mov ecx, ide_mutex
call mutex_unlock call mutex_unlock
xor eax, eax xor eax, eax
ret ret
endp endp
;-----------------------------------------------------------------------------
; This is a stub. ; This is a stub.
proc ide_querymedia stdcall, hd_data, mediainfo proc ide_querymedia stdcall, hd_data, mediainfo
mov eax, [mediainfo] mov eax, [mediainfo]
@@ -270,14 +279,12 @@ proc ide_querymedia stdcall, hd_data, mediainfo
xor eax, eax xor eax, eax
ret ret
endp endp
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
align 4 align 4
; input: eax = sector, edi -> buffer ; input: eax = sector, edi -> buffer
; output: edi = edi + 512 ; output: edi = edi + 512
hd_read_pio: hd_read_pio:
push eax edx push eax edx
; Select the desired drive ; Select the desired drive
mov edx, [hdbase] mov edx, [hdbase]
add edx, 6 ;адрес регистра головок add edx, 6 ;адрес регистра головок
@@ -286,9 +293,9 @@ hd_read_pio:
out dx, al; номер головки/номер диска out dx, al; номер головки/номер диска
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
; ATA with 28 or 48 bit for sector number? ; ATA with 28 or 48 bit for sector number?
mov eax, [esp+4] mov eax, [esp+4]
cmp eax, 0x10000000 cmp eax, 0x10000000
@@ -372,7 +379,6 @@ hd_read_pio:
pushfd pushfd
cli cli
mov ecx, 256 mov ecx, 256
mov edx, [hdbase] mov edx, [hdbase]
cld cld
@@ -393,6 +399,7 @@ cache_write_pio:
out dx, al ; номер головки/номер диска out dx, al ; номер головки/номер диска
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
@@ -550,13 +557,14 @@ wait_for_hd_idle:
align 4 align 4
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
;--------------------------------------
@@: @@:
pop edx eax pop edx eax
ret ret
@@ -573,6 +581,7 @@ wait_for_sector_buffer:
align 4 align 4
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
@@ -587,9 +596,10 @@ hdwait_sbuf: ; wait for sector buffer to be ready
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:
pop edx eax pop edx eax
ret ret
@@ -606,22 +616,17 @@ wait_for_sector_dma_ide0:
align 4 align 4
.wait: .wait:
call change_task call change_task
cmp [IDE_common_irq_param], 0 cmp [IDE_common_irq_param], 0
jz .done jz .done
call check_hd_wait_timeout call check_hd_wait_timeout
cmp [hd_error], 0 cmp [hd_error], 0
jz .wait jz .wait
; clear Bus Master IDE Command register
pushfd
cli
mov [IDE_common_irq_param], 0 mov [IDE_common_irq_param], 0
mov dx, [IDEContrRegsBaseAddr]
mov al, 0
out dx, al
popfd
;-------------------------------------- ;--------------------------------------
align 4
.done: .done:
pop edx pop edx
pop eax pop eax
@@ -636,23 +641,17 @@ wait_for_sector_dma_ide1:
align 4 align 4
.wait: .wait:
call change_task call change_task
cmp [IDE_common_irq_param], 0 cmp [IDE_common_irq_param], 0
jz .done jz .done
call check_hd_wait_timeout call check_hd_wait_timeout
cmp [hd_error], 0 cmp [hd_error], 0
jz .wait jz .wait
; clear Bus Master IDE Command register
pushfd
cli
mov [IDE_common_irq_param], 0 mov [IDE_common_irq_param], 0
mov dx, [IDEContrRegsBaseAddr]
add dx, 8
mov al, 0
out dx, al
popfd
;-------------------------------------- ;--------------------------------------
align 4
.done: .done:
pop edx pop edx
pop eax pop eax
@@ -660,7 +659,8 @@ align 4
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
iglobal iglobal
align 4 align 4
; note that IDE descriptor table must be 4-byte aligned and do not cross 4K boundary ; note that IDE descriptor table must be 4-byte aligned
; and do not cross 4K boundary
IDE_descriptor_table: IDE_descriptor_table:
dd IDE_DMA dd IDE_DMA
dw 0x2000 dw 0x2000
@@ -673,14 +673,8 @@ endg
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
uglobal uglobal
; all uglobals are zeroed at boot ; all uglobals are zeroed at boot
dma_process dd 0
dma_slot_ptr dd 0
cache_chain_pos dd 0
cache_chain_ptr dd 0 cache_chain_ptr dd 0
cache_chain_size db 0 cache_chain_size db 0
cache_chain_started db 0
dma_task_switched db 0
dma_hdd db 0
allow_dma_access db 0 allow_dma_access db 0
endg endg
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
@@ -693,7 +687,8 @@ IDE_irq_14_handler:
cli cli
pushad pushad
mov [IDE_common_irq_param], 0 mov [IDE_common_irq_param], 0
mov dx, [IDEContrRegsBaseAddr] mov ecx, [IDE_controller_pointer]
mov dx, [ecx+IDE_DATA.RegsBaseAddres]
; test whether it is our interrupt? ; test whether it is our interrupt?
add edx, 2 add edx, 2
in al, dx in al, dx
@@ -715,12 +710,10 @@ IDE_irq_14_handler:
mov al, 1 mov al, 1
ret ret
;-------------------------------------- ;--------------------------------------
align 4
@@: @@:
popad popad
popfd popfd
;-------------------------------------- ;--------------------------------------
align 4
.exit: .exit:
mov al, 0 mov al, 0
ret ret
@@ -734,7 +727,8 @@ IDE_irq_15_handler:
cli cli
pushad pushad
mov [IDE_common_irq_param], 0 mov [IDE_common_irq_param], 0
mov dx, [IDEContrRegsBaseAddr] mov ecx, [IDE_controller_pointer]
mov dx, [ecx+IDE_DATA.RegsBaseAddres]
add dx, 8 add dx, 8
; test whether it is our interrupt? ; test whether it is our interrupt?
add edx, 2 add edx, 2
@@ -757,12 +751,10 @@ IDE_irq_15_handler:
mov al, 1 mov al, 1
ret ret
;-------------------------------------- ;--------------------------------------
align 4
@@: @@:
popad popad
popfd popfd
;-------------------------------------- ;--------------------------------------
align 4
.exit: .exit:
mov al, 0 mov al, 0
ret ret
@@ -776,7 +768,8 @@ IDE_common_irq_handler:
cli cli
pushad pushad
xor ebx, ebx xor ebx, ebx
mov dx, [IDEContrRegsBaseAddr] mov ecx, [IDE_controller_pointer]
mov dx, [ecx+IDE_DATA.RegsBaseAddres]
mov eax, IDE_common_irq_param mov eax, IDE_common_irq_param
cmp [eax], irq14_num cmp [eax], irq14_num
mov [eax], bl mov [eax], bl
@@ -784,7 +777,6 @@ IDE_common_irq_handler:
add dx, 8 add dx, 8
;-------------------------------------- ;--------------------------------------
align 4
@@: @@:
; test whether it is our interrupt? ; test whether it is our interrupt?
add edx, 2 add edx, 2
@@ -807,12 +799,10 @@ align 4
mov al, 1 mov al, 1
ret ret
;-------------------------------------- ;--------------------------------------
align 4
@@: @@:
popad popad
popfd popfd
;-------------------------------------- ;--------------------------------------
align 4
.exit: .exit:
mov al, 0 mov al, 0
ret ret
@@ -824,26 +814,31 @@ hd_read_dma:
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
jb .notread jb .notread
add edx, 15 add edx, 15
cmp [esp+4], edx cmp [esp+4], edx
ja .notread ja .notread
mov eax, [esp+4] mov eax, [esp+4]
sub eax, [dma_cur_sector] sub eax, [dma_cur_sector]
shl eax, 9 shl eax, 9
add eax, (OS_BASE+IDE_DMA) add eax, (OS_BASE+IDE_DMA)
push ecx esi push ecx esi
mov esi, eax mov esi, eax
mov ecx, 512/4 mov ecx, 512/4
cld cld
rep movsd rep movsd
pop esi ecx pop esi ecx
pop edx pop edx
pop eax pop eax
ret ret
;--------------------------------------
.notread: .notread:
; set data for PRD Table ; set data for PRD Table
mov eax, IDE_descriptor_table mov eax, IDE_descriptor_table
@@ -851,13 +846,24 @@ hd_read_dma:
mov word [eax+4], 0x2000 mov word [eax+4], 0x2000
sub eax, OS_BASE sub eax, OS_BASE
; select controller Primary or Secondary ; select controller Primary or Secondary
mov dx, [IDEContrRegsBaseAddr] ; mov ecx,[IDE_controller_pointer]
mov ecx, [hdpos]
dec ecx
shr ecx, 2
imul ecx, sizeof.IDE_DATA
add ecx, IDE_controller_1
mov [IDE_controller_pointer], ecx
mov dx, [ecx+IDE_DATA.RegsBaseAddres]
push eax push eax
mov eax, [hd_address_table] mov eax, [hdpos]
cmp [hdbase], eax ; 0x1F0 dec eax
test eax, 10b
pop eax pop eax
jz @f jz @f
add edx, 8 add edx, 8
;--------------------------------------
@@: @@:
push edx push edx
; Bus Master IDE PRD Table Address ; Bus Master IDE PRD Table Address
@@ -881,9 +887,9 @@ hd_read_dma:
out dx, al ; номер головки/номер диска out dx, al ; номер головки/номер диска
call wait_for_hd_idle call wait_for_hd_idle
cmp [hd_error], 0 cmp [hd_error], 0
jnz hd_read_error jnz hd_read_error
; ATA with 28 or 48 bit for sector number? ; ATA with 28 or 48 bit for sector number?
mov eax, [esp+4] mov eax, [esp+4]
; -10h because the PreCache hits the boundary between lba28 and lba48 ; -10h because the PreCache hits the boundary between lba28 and lba48
@@ -961,47 +967,55 @@ hd_read_dma:
;-------------------------------------- ;--------------------------------------
.continue: .continue:
; select controller Primary or Secondary ; select controller Primary or Secondary
mov dx, [IDEContrRegsBaseAddr] mov ecx, [IDE_controller_pointer]
mov eax, [hd_address_table] mov dx, [ecx+IDE_DATA.RegsBaseAddres]
cmp [hdbase], eax ; 0x1F0
mov eax, [hdpos]
dec eax
test eax, 10b
jz @f jz @f
add dx, 8 add dx, 8
;--------------------------------------
@@: @@:
; set write to memory and Start Bus Master ; set write to memory and Start Bus Master
mov al, 9 mov al, 9
out dx, al out dx, al
mov eax, [CURRENT_TASK] mov eax, [hdpos]
mov [dma_process], eax dec eax
test eax, 10b
mov eax, [TASK_BASE]
mov [dma_slot_ptr], eax
mov eax, [hd_address_table]
cmp [hdbase], eax ; 0x1F0
jnz .ide1 jnz .ide1
mov [IDE_common_irq_param], irq14_num mov [IDE_common_irq_param], irq14_num
jmp @f jmp @f
;--------------------------------------
.ide1: .ide1:
mov [IDE_common_irq_param], irq15_num mov [IDE_common_irq_param], irq15_num
;--------------------------------------
@@: @@:
popfd popfd
; wait for interrupt ; wait for interrupt
mov eax, [hd_address_table] mov eax, [hdpos]
cmp [hdbase], eax ; 0x1F0 dec eax
test eax, 10b
jnz .wait_ide1 jnz .wait_ide1
call wait_for_sector_dma_ide0 call wait_for_sector_dma_ide0
jmp @f jmp @f
;--------------------------------------
.wait_ide1: .wait_ide1:
call wait_for_sector_dma_ide1 call wait_for_sector_dma_ide1
;--------------------------------------
@@: @@:
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
jmp hd_read_dma jmp hd_read_dma
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
@@ -1011,6 +1025,7 @@ cache_write_dma:
; set data for PRD Table ; set data for PRD Table
mov eax, IDE_descriptor_table mov eax, IDE_descriptor_table
mov edx, eax mov edx, eax
pusha pusha
mov edi, (OS_BASE+IDE_DMA) mov edi, (OS_BASE+IDE_DMA)
mov dword [edx], IDE_DMA mov dword [edx], IDE_DMA
@@ -1021,15 +1036,27 @@ cache_write_dma:
cld cld
rep movsd rep movsd
popa popa
sub eax, OS_BASE sub eax, OS_BASE
; select controller Primary or Secondary ; select controller Primary or Secondary
mov dx, [IDEContrRegsBaseAddr] ; mov ecx,[IDE_controller_pointer]
mov ecx, [hdpos]
dec ecx
shr ecx, 2
imul ecx, sizeof.IDE_DATA
add ecx, IDE_controller_1
mov [IDE_controller_pointer], ecx
mov dx, [ecx+IDE_DATA.RegsBaseAddres]
push eax push eax
mov eax, [hd_address_table] mov eax, [hdpos]
cmp [hdbase], eax ; 0x1F0 dec eax
test eax, 10b
pop eax pop eax
jz @f jz @f
add edx, 8 add edx, 8
;--------------------------------------
@@: @@:
push edx push edx
; Bus Master IDE PRD Table Address ; Bus Master IDE PRD Table Address
@@ -1053,9 +1080,9 @@ cache_write_dma:
out dx, al ; номер головки/номер диска out dx, al ; номер головки/номер диска
call wait_for_hd_idle call wait_for_hd_idle
cmp [hd_error], 0 cmp [hd_error], 0
jnz hd_write_error_dma jnz hd_write_error_dma
; ATA with 28 or 48 bit for sector number? ; ATA with 28 or 48 bit for sector number?
mov esi, [cache_chain_ptr] mov esi, [cache_chain_ptr]
mov eax, [esi] mov eax, [esi]
@@ -1134,69 +1161,73 @@ cache_write_dma:
;-------------------------------------- ;--------------------------------------
.continue: .continue:
; select controller Primary or Secondary ; select controller Primary or Secondary
mov dx, [IDEContrRegsBaseAddr] mov ecx, [IDE_controller_pointer]
mov eax, [hd_address_table] mov dx, [ecx+IDE_DATA.RegsBaseAddres]
cmp [hdbase], eax ; 0x1F0
mov eax, [hdpos]
dec eax
test eax, 10b
jz @f jz @f
add dx, 8 add dx, 8
;--------------------------------------
@@: @@:
; set write to device and Start Bus Master ; set write to device and Start Bus Master
mov al, 1 mov al, 1
out dx, al out dx, al
mov eax, [CURRENT_TASK]
mov [dma_process], eax mov eax, [hdpos]
mov eax, [TASK_BASE] dec eax
mov [dma_slot_ptr], eax test eax, 10b
mov eax, [hd_address_table]
cmp [hdbase], eax ; 0x1F0
jnz .ide1 jnz .ide1
mov [IDE_common_irq_param], irq14_num mov [IDE_common_irq_param], irq14_num
jmp @f jmp @f
;--------------------------------------
.ide1: .ide1:
mov [IDE_common_irq_param], irq15_num mov [IDE_common_irq_param], irq15_num
;--------------------------------------
@@: @@:
popfd popfd
; wait for interrupt ; wait for interrupt
mov [dma_cur_sector], not 0x40 mov [dma_cur_sector], not 0x40
mov eax, [hd_address_table]
cmp [hdbase], eax ; 0x1F0 mov eax, [hdpos]
dec eax
test eax, 10b
jnz .wait_ide1 jnz .wait_ide1
call wait_for_sector_dma_ide0 call wait_for_sector_dma_ide0
jmp @f jmp @f
;--------------------------------------
.wait_ide1: .wait_ide1:
call wait_for_sector_dma_ide1 call wait_for_sector_dma_ide1
;--------------------------------------
@@: @@:
cmp [hd_error], 0 cmp [hd_error], 0
jnz hd_write_error_dma jnz hd_write_error_dma
pop esi pop esi
ret ret
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
uglobal
align 4
IDEContrProgrammingInterface dd ?
IDE_Interrupt dw ?
IDEContrRegsBaseAddr dw ?
IDE_BAR0_val dw ?
IDE_BAR1_val dw ?
IDE_BAR2_val dw ?
IDE_BAR3_val dw ?
endg
;-----------------------------------------------------------------------------
proc clear_pci_ide_interrupts proc clear_pci_ide_interrupts
mov esi, pcidev_list mov esi, pcidev_list
;--------------------------------------
align 4
.loop: .loop:
mov esi, [esi+PCIDEV.fd] mov esi, [esi+PCIDEV.fd]
cmp esi, pcidev_list cmp esi, pcidev_list
jz .done jz .done
cmp [esi+PCIDEV.class], 0x01018F cmp [esi+PCIDEV.class], 0x01018F
jnz .loop jnz .loop
mov ah, [esi+PCIDEV.bus] mov ah, [esi+PCIDEV.bus]
mov al, 2 mov al, 2
mov bh, [esi+PCIDEV.devfn] mov bh, [esi+PCIDEV.devfn]
mov bl, 0x20 mov bl, 0x20
call pci_read_reg call pci_read_reg
and eax, 0FFFCh and eax, 0FFFCh
mov edx, eax mov edx, eax
add edx, 2 add edx, 2
@@ -1212,6 +1243,8 @@ proc clear_pci_ide_interrupts
in al, dx in al, dx
DEBUGF 1,'-> %x\n',al DEBUGF 1,'-> %x\n',al
jmp .loop jmp .loop
;--------------------------------------
.done: .done:
ret ret
endp endp
;-----------------------------------------------------------------------------

View File

@@ -41,53 +41,29 @@ find_empty_slot_CD_cache:
ret ret
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
clear_CD_cache: clear_CD_cache:
DEBUGF 1, 'K : clear_CD_cache\n'
pusha pusha
.ide0:
mov esi, [cdpos]
dec esi
imul esi, sizeof.IDE_CACHE
add esi, cache_ide0
xor eax, eax xor eax, eax
cmp [cdpos], 1
jne .ide1 mov [esi+IDE_CACHE.search_start], eax
mov [cache_ide0_search_start], eax mov ecx, [esi+IDE_CACHE.system_sad_size]
mov ecx, [cache_ide0_system_sad_size] mov edi, [esi+IDE_CACHE.pointer]
mov edi, [cache_ide0_pointer]
call .clear call .clear
mov [cache_ide0_appl_search_start], eax
mov ecx, [cache_ide0_appl_sad_size] mov [esi+IDE_CACHE.appl_search_start], eax
mov edi, [cache_ide0_data_pointer] mov ecx, [esi+IDE_CACHE.appl_sad_size]
jmp .continue mov edi, [esi+IDE_CACHE.data_pointer]
.ide1:
cmp [cdpos], 2
jne .ide2
mov [cache_ide1_search_start], eax
mov ecx, [cache_ide1_system_sad_size]
mov edi, [cache_ide1_pointer]
call .clear
mov [cache_ide1_appl_search_start], eax
mov ecx, [cache_ide1_appl_sad_size]
mov edi, [cache_ide1_data_pointer]
jmp .continue
.ide2:
cmp [cdpos], 3
jne .ide3
mov [cache_ide2_search_start], eax
mov ecx, [cache_ide2_system_sad_size]
mov edi, [cache_ide2_pointer]
call .clear
mov [cache_ide2_appl_search_start], eax
mov ecx, [cache_ide2_appl_sad_size]
mov edi, [cache_ide2_data_pointer]
jmp .continue
.ide3:
mov [cache_ide3_search_start], eax
mov ecx, [cache_ide3_system_sad_size]
mov edi, [cache_ide3_pointer]
call .clear
mov [cache_ide3_appl_search_start], eax
mov ecx, [cache_ide3_appl_sad_size]
mov edi, [cache_ide3_data_pointer]
.continue:
call .clear call .clear
popa popa
ret ret
;--------------------------------------
.clear: .clear:
shl ecx, 1 shl ecx, 1
cld cld
@@ -96,272 +72,131 @@ clear_CD_cache:
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
align 4 align 4
cd_calculate_cache: cd_calculate_cache:
; 1 - IDE0 ... 4 - IDE3 ; 1 - IDE0 ... 12 - IDE11
.ide0: push eax
cmp [cdpos], 1
jne .ide1 mov eax, [cdpos]
dec eax
imul eax, sizeof.IDE_CACHE
add eax, cache_ide0
cmp [cd_appl_data], 0 cmp [cd_appl_data], 0
jne .ide0_appl_data jne @f
mov ecx, [cache_ide0_system_sad_size]
mov esi, [cache_ide0_pointer] mov ecx, [eax+IDE_CACHE.system_sad_size]
mov esi, [eax+IDE_CACHE.pointer]
pop eax
ret ret
.ide0_appl_data: ;--------------------------------------
mov ecx, [cache_ide0_appl_sad_size] @@:
mov esi, [cache_ide0_data_pointer] mov ecx, [eax+IDE_CACHE.appl_sad_size]
ret mov esi, [eax+IDE_CACHE.data_pointer]
.ide1: pop eax
cmp [cdpos], 2
jne .ide2
cmp [cd_appl_data], 0
jne .ide1_appl_data
mov ecx, [cache_ide1_system_sad_size]
mov esi, [cache_ide1_pointer]
ret
.ide1_appl_data:
mov ecx, [cache_ide1_appl_sad_size]
mov esi, [cache_ide1_data_pointer]
ret
.ide2:
cmp [cdpos], 3
jne .ide3
cmp [cd_appl_data], 0
jne .ide2_appl_data
mov ecx, [cache_ide2_system_sad_size]
mov esi, [cache_ide2_pointer]
ret
.ide2_appl_data:
mov ecx, [cache_ide2_appl_sad_size]
mov esi, [cache_ide2_data_pointer]
ret
.ide3:
cmp [cd_appl_data], 0
jne .ide3_appl_data
mov ecx, [cache_ide3_system_sad_size]
mov esi, [cache_ide3_pointer]
ret
.ide3_appl_data:
mov ecx, [cache_ide3_appl_sad_size]
mov esi, [cache_ide3_data_pointer]
ret ret
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
align 4 align 4
cd_calculate_cache_1: cd_calculate_cache_1:
; 1 - IDE0 ... 4 - IDE3 ; 1 - IDE0 ... 12 - IDE11
.ide0: push eax
cmp [cdpos], 1
jne .ide1 mov eax, [cdpos]
dec eax
imul eax, sizeof.IDE_CACHE
add eax, cache_ide0
cmp [cd_appl_data], 0 cmp [cd_appl_data], 0
jne .ide0_appl_data jne @f
mov esi, [cache_ide0_pointer]
mov esi, [eax+IDE_CACHE.pointer]
pop eax
ret ret
.ide0_appl_data: ;--------------------------------------
mov esi, [cache_ide0_data_pointer] @@:
ret mov esi, [eax+IDE_CACHE.data_pointer]
.ide1: pop eax
cmp [cdpos], 2
jne .ide2
cmp [cd_appl_data], 0
jne .ide1_appl_data
mov esi, [cache_ide1_pointer]
ret
.ide1_appl_data:
mov esi, [cache_ide1_data_pointer]
ret
.ide2:
cmp [cdpos], 3
jne .ide3
cmp [cd_appl_data], 0
jne .ide2_appl_data
mov esi, [cache_ide2_pointer]
ret
.ide2_appl_data:
mov esi, [cache_ide2_data_pointer]
ret
.ide3:
cmp [cd_appl_data], 0
jne .ide3_appl_data
mov esi, [cache_ide3_pointer]
ret
.ide3_appl_data:
mov esi, [cache_ide3_data_pointer]
ret ret
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
align 4 align 4
cd_calculate_cache_2: cd_calculate_cache_2:
; 1 - IDE0 ... 4 - IDE3 ; 1 - IDE0 ... 12 - IDE11
.ide0: mov eax, [cdpos]
cmp [cdpos], 1 dec eax
jne .ide1 imul eax, sizeof.IDE_CACHE
add eax, cache_ide0
cmp [cd_appl_data], 0 cmp [cd_appl_data], 0
jne .ide0_appl_data jne @f
mov eax, [cache_ide0_system_data]
mov eax, [eax+IDE_CACHE.system_data]
ret ret
.ide0_appl_data: ;--------------------------------------
mov eax, [cache_ide0_appl_data] @@:
ret mov eax, [eax+IDE_CACHE.appl_data]
.ide1:
cmp [cdpos], 2
jne .ide2
cmp [cd_appl_data], 0
jne .ide1_appl_data
mov eax, [cache_ide1_system_data]
ret
.ide1_appl_data:
mov eax, [cache_ide1_appl_data]
ret
.ide2:
cmp [cdpos], 3
jne .ide3
cmp [cd_appl_data], 0
jne .ide2_appl_data
mov eax, [cache_ide2_system_data]
ret
.ide2_appl_data:
mov eax, [cache_ide2_appl_data]
ret
.ide3:
cmp [cd_appl_data], 0
jne .ide3_appl_data
mov eax, [cache_ide3_system_data]
ret
.ide3_appl_data:
mov eax, [cache_ide3_appl_data]
ret ret
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
align 4 align 4
cd_calculate_cache_3: cd_calculate_cache_3:
; mov ecx,cache_max*10/100 ; 1 - IDE0 ... 12 - IDE11
; mov edi,[cache_search_start] push eax
mov eax, [cdpos]
dec eax
imul eax, sizeof.IDE_CACHE
add eax, cache_ide0
; 1 - IDE0 ... 4 - IDE3
.ide0:
cmp [cdpos], 1
jne .ide1
cmp [cd_appl_data], 0 cmp [cd_appl_data], 0
jne .ide0_appl_data jne @f
mov edi, [cache_ide0_search_start]
mov edi, [eax+IDE_CACHE.search_start]
pop eax
ret ret
.ide0_appl_data: ;--------------------------------------
mov edi, [cache_ide0_appl_search_start] @@:
ret mov edi, [eax+IDE_CACHE.appl_search_start]
.ide1: pop eax
cmp [cdpos], 2
jne .ide2
cmp [cd_appl_data], 0
jne .ide1_appl_data
mov edi, [cache_ide1_search_start]
ret
.ide1_appl_data:
mov edi, [cache_ide1_appl_search_start]
ret
.ide2:
cmp [cdpos], 3
jne .ide3
cmp [cd_appl_data], 0
jne .ide2_appl_data
mov edi, [cache_ide2_search_start]
ret
.ide2_appl_data:
mov edi, [cache_ide2_appl_search_start]
ret
.ide3:
cmp [cd_appl_data], 0
jne .ide3_appl_data
mov edi, [cache_ide3_search_start]
ret
.ide3_appl_data:
mov edi, [cache_ide3_appl_search_start]
ret ret
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
align 4 align 4
cd_calculate_cache_4: cd_calculate_cache_4:
; cmp edi,cache_max ; 1 - IDE0 ... 12 - IDE11
; 1 - IDE0 ... 4 - IDE3 push eax
.ide0:
cmp [cdpos], 1 mov eax, [cdpos]
jne .ide1 dec eax
imul eax, sizeof.IDE_CACHE
add eax, cache_ide0
cmp [cd_appl_data], 0 cmp [cd_appl_data], 0
jne .ide0_appl_data jne @f
cmp edi, [cache_ide0_system_sad_size]
cmp edi, [eax+IDE_CACHE.system_sad_size]
pop eax
ret ret
.ide0_appl_data: ;--------------------------------------
cmp edi, [cache_ide0_appl_sad_size] @@:
ret cmp edi, [eax+IDE_CACHE.appl_sad_size]
.ide1: pop eax
cmp [cdpos], 2
jne .ide2
cmp [cd_appl_data], 0
jne .ide1_appl_data
cmp edi, [cache_ide1_system_sad_size]
ret
.ide1_appl_data:
cmp edi, [cache_ide1_appl_sad_size]
ret
.ide2:
cmp [cdpos], 3
jne .ide3
cmp [cd_appl_data], 0
jne .ide2_appl_data
cmp edi, [cache_ide2_system_sad_size]
ret
.ide2_appl_data:
cmp edi, [cache_ide2_appl_sad_size]
ret
.ide3:
cmp [cd_appl_data], 0
jne .ide3_appl_data
cmp edi, [cache_ide3_system_sad_size]
ret
.ide3_appl_data:
cmp edi, [cache_ide3_appl_sad_size]
ret ret
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
align 4 align 4
cd_calculate_cache_5: cd_calculate_cache_5:
; mov [cache_search_start],edi ; 1 - IDE0 ... 12 - IDE11
; 1 - IDE0 ... 4 - IDE3 push eax
.ide0:
cmp [cdpos], 1 mov eax, [cdpos]
jne .ide1 dec eax
imul eax, sizeof.IDE_CACHE
add eax, cache_ide0
cmp [cd_appl_data], 0 cmp [cd_appl_data], 0
jne .ide0_appl_data jne @f
mov [cache_ide0_search_start], edi
mov [eax+IDE_CACHE.search_start], edi
pop eax
ret ret
.ide0_appl_data: ;--------------------------------------
mov [cache_ide0_appl_search_start], edi @@:
ret mov [eax+IDE_CACHE.appl_search_start], edi
.ide1: pop eax
cmp [cdpos], 2
jne .ide2
cmp [cd_appl_data], 0
jne .ide1_appl_data
mov [cache_ide1_search_start], edi
ret
.ide1_appl_data:
mov [cache_ide1_appl_search_start], edi
ret
.ide2:
cmp [cdpos], 3
jne .ide3
cmp [cd_appl_data], 0
jne .ide2_appl_data
mov [cache_ide2_search_start], edi
ret
.ide2_appl_data:
mov [cache_ide2_appl_search_start], edi
ret
.ide3:
cmp [cd_appl_data], 0
jne .ide3_appl_data
mov [cache_ide3_search_start], edi
ret
.ide3_appl_data:
mov [cache_ide3_appl_search_start], edi
ret ret
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
;align 4
;calculate_linear_to_real:
; shr eax, 12
; mov eax, [page_tabs+eax*4]
; and eax, 0xFFFFF000
; ret

View File

@@ -179,7 +179,7 @@ struct TSS
_io_map_1 rb 4096 _io_map_1 rb 4096
ends ends
DRIVE_DATA_SIZE equ 10 DRIVE_DATA_SIZE equ 16
OS_BASE equ 0x80000000 OS_BASE equ 0x80000000

View File

@@ -29,8 +29,7 @@ irq0:
.nocounter: .nocounter:
xor ecx, ecx ; send End Of Interrupt signal xor ecx, ecx ; send End Of Interrupt signal
call irq_eoi call irq_eoi
; btr dword[DONT_SWITCH], 0
; jc .return
mov bl, SCHEDULE_ANY_PRIORITY mov bl, SCHEDULE_ANY_PRIORITY
call find_next_task call find_next_task
jz .return ; if there is only one running process jz .return ; if there is only one running process
@@ -44,26 +43,10 @@ change_task:
pushfd pushfd
cli cli
pushad pushad
if 0
; \begin{Mario79} ; <- must be refractoried, if used...
cmp [dma_task_switched], 1
jne .find_next_task
mov [dma_task_switched], 0
mov ebx, [dma_process]
cmp [CURRENT_TASK], ebx
je .return
mov edi, [dma_slot_ptr]
mov [CURRENT_TASK], ebx
mov [TASK_BASE], edi
jmp @f
.find_next_task:
; \end{Mario79}
end if
mov bl, SCHEDULE_ANY_PRIORITY mov bl, SCHEDULE_ANY_PRIORITY
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
call do_change_task call do_change_task
.return: .return:
popad popad

View File

@@ -493,58 +493,6 @@ BgrDataHeight rd 1
skin_data rd 1 skin_data rd 1
cache_ide0:
cache_ide0_pointer rd 1
cache_ide0_size rd 1 ; not use
cache_ide0_data_pointer rd 1
cache_ide0_system_data_size rd 1 ; not use
cache_ide0_appl_data_size rd 1 ; not use
cache_ide0_system_data rd 1
cache_ide0_appl_data rd 1
cache_ide0_system_sad_size rd 1
cache_ide0_appl_sad_size rd 1
cache_ide0_search_start rd 1
cache_ide0_appl_search_start rd 1
cache_ide1:
cache_ide1_pointer rd 1
cache_ide1_size rd 1 ; not use
cache_ide1_data_pointer rd 1
cache_ide1_system_data_size rd 1 ; not use
cache_ide1_appl_data_size rd 1 ; not use
cache_ide1_system_data rd 1
cache_ide1_appl_data rd 1
cache_ide1_system_sad_size rd 1
cache_ide1_appl_sad_size rd 1
cache_ide1_search_start rd 1
cache_ide1_appl_search_start rd 1
cache_ide2:
cache_ide2_pointer rd 1
cache_ide2_size rd 1 ; not use
cache_ide2_data_pointer rd 1
cache_ide2_system_data_size rd 1 ; not use
cache_ide2_appl_data_size rd 1 ; not use
cache_ide2_system_data rd 1
cache_ide2_appl_data rd 1
cache_ide2_system_sad_size rd 1
cache_ide2_appl_sad_size rd 1
cache_ide2_search_start rd 1
cache_ide2_appl_search_start rd 1
cache_ide3:
cache_ide3_pointer rd 1
cache_ide3_size rd 1 ; not use
cache_ide3_data_pointer rd 1
cache_ide3_system_data_size rd 1 ; not use
cache_ide3_appl_data_size rd 1 ; not use
cache_ide3_system_data rd 1
cache_ide3_appl_data rd 1
cache_ide3_system_sad_size rd 1
cache_ide3_appl_sad_size rd 1
cache_ide3_search_start rd 1
cache_ide3_appl_search_start rd 1
debug_step_pointer rd 1 debug_step_pointer rd 1
lba_read_enabled rd 1 ; 0 = disabled , 1 = enabled lba_read_enabled rd 1 ; 0 = disabled , 1 = enabled

View File

@@ -17,44 +17,85 @@ $Revision$
;**************************************************** ;****************************************************
;* ПОИСК HDD и CD * ;* ПОИСК HDD и CD *
;**************************************************** ;****************************************************
cmp [IDEContrProgrammingInterface], 0 cmp [ecx+IDE_DATA.ProgrammingInterface], 0
je EndFindHDD je EndFindHDD
FindHDD: FindHDD:
push ecx
xor ebx, ebx
inc ebx
cmp ecx, IDE_controller_2
jne @f
add bl, 5
jmp .find
@@:
cmp ecx, IDE_controller_3
jne .find
add bl, 10
;--------------------------------------
.find:
mov [ChannelNumber], 1 mov [ChannelNumber], 1
mov [DiskNumber], 0 mov [DiskNumber], 0
call FindHDD_3 call FindHDD_2
mov [DiskNumber], 1 mov [DiskNumber], 1
call FindHDD_3 call FindHDD_2
inc [ChannelNumber] inc [ChannelNumber]
mov [DiskNumber], 0 mov [DiskNumber], 0
call FindHDD_3 call FindHDD_2
mov [DiskNumber], 1 mov [DiskNumber], 1
call FindHDD_1 call FindHDD_1
jmp EndFindHDD
pop ecx
jmp EndFindHDD
;-----------------------------------------------------------------------------
FindHDD_2:
call FindHDD_1
shl byte [ebx+DRIVE_DATA], 2
ret
;-----------------------------------------------------------------------------
FindHDD_1: FindHDD_1:
DEBUGF 1, "K : Channel %d ",[ChannelNumber]:2 DEBUGF 1, "K : Channel %d ",[ChannelNumber]:2
DEBUGF 1, "Disk %d\n",[DiskNumber]:1 DEBUGF 1, "Disk %d\n",[DiskNumber]:1
push ebx
call ReadHDD_ID call ReadHDD_ID
pop ebx
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne FindHDD_2 jne .FindCD
cmp [Sector512+6], word 16 cmp [Sector512+6], word 16
ja FindHDD_2 ja .FindCD
cmp [Sector512+12], word 255 cmp [Sector512+12], word 255
ja FindHDD_2 ja .FindCD
inc byte [DRIVE_DATA+1]
jmp Print_Device_Name inc byte [ebx+DRIVE_DATA]
FindHDD_2: jmp .Print_Device_Name
;--------------------------------------
.FindCD:
push ebx
call DeviceReset call DeviceReset
pop ebx
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne FindHDD_2_2 jne .end
push ebx
call ReadCD_ID call ReadCD_ID
pop ebx
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne FindHDD_2_2 jne .end
inc byte [DRIVE_DATA+1]
inc byte [DRIVE_DATA+1] add [ebx+DRIVE_DATA], byte 2
Print_Device_Name: ;--------------------------------------
.Print_Device_Name:
pushad pushad
pushfd pushfd
mov esi, Sector512+27*2 mov esi, Sector512+27*2
@@ -66,33 +107,38 @@ Print_Device_Name:
xchg ah, al xchg ah, al
stosw stosw
loop @b loop @b
popfd
popad
DEBUGF 1, "K : Dev: %s \n", dev_name DEBUGF 1, "K : Dev: %s \n", dev_name
xor eax, eax xor eax, eax
mov ax, [Sector512+64*2] mov ax, [Sector512+64*2]
DEBUGF 1, "K : PIO mode possible modes %x\n", al DEBUGF 1, "K : PIO mode possible modes %x\n", al
mov ax, [Sector512+51*2] mov ax, [Sector512+51*2]
mov al, ah mov al, ah
call convert_Sector512_value call convert_Sector512_value
DEBUGF 1, "K : PIO mode set mode %x\n", ah DEBUGF 1, "K : PIO mode set mode %x\n", ah
mov ax, [Sector512+63*2] mov ax, [Sector512+63*2]
DEBUGF 1, "K : Multiword DMA possible modes %x\n", al DEBUGF 1, "K : Multiword DMA possible modes %x\n", al
mov al, ah mov al, ah
call convert_Sector512_value call convert_Sector512_value
DEBUGF 1, "K : Multiword DMA set mode %x\n", ah DEBUGF 1, "K : Multiword DMA set mode %x\n", ah
mov ax, [Sector512+88*2] mov ax, [Sector512+88*2]
DEBUGF 1, "K : Ultra DMA possible modes %x\n", al DEBUGF 1, "K : Ultra DMA possible modes %x\n", al
mov al, ah mov al, ah
call convert_Sector512_value call convert_Sector512_value
DEBUGF 1, "K : Ultra DMA set mode %x\n", ah DEBUGF 1, "K : Ultra DMA set mode %x\n", ah
FindHDD_2_2:
popfd
popad
ret ret
;----------------------------------------------------------------------------- ;--------------------------------------
FindHDD_3: .end:
call FindHDD_1 DEBUGF 1, "K : Device not found\n"
shl byte [DRIVE_DATA+1], 2
ret ret
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
convert_Sector512_value: convert_Sector512_value:
@@ -112,10 +158,11 @@ convert_Sector512_value:
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
; Адрес считываемого сектора в режиме LBA ; Адрес считываемого сектора в режиме LBA
uglobal uglobal
SectorAddress DD ? SectorAddress dd ?
dev_name: dev_name:
rb 41 rb 41
endg endg
;-----------------------------------------------------------------------------
;************************************************* ;*************************************************
;* ЧТЕНИЕ ИДЕНТИФИКАТОРА ЖЕСТКОГО ДИСКА * ;* ЧТЕНИЕ ИДЕНТИФИКАТОРА ЖЕСТКОГО ДИСКА *
;* Входные параметры передаются через глобальные * ;* Входные параметры передаются через глобальные *
@@ -131,32 +178,32 @@ ReadHDD_ID:
; Послать команду идентификации устройства ; Послать команду идентификации устройства
mov [ATAFeatures], 0 mov [ATAFeatures], 0
mov [ATAHead], 0 mov [ATAHead], 0
mov [ATACommand], 0ECh mov [ATACommand], 0xEC
call SendCommandToHDD call SendCommandToHDD
cmp [DevErrorCode], 0;проверить код ошибки cmp [DevErrorCode], 0 ;проверить код ошибки
jne @@End ;закончить, сохранив код ошибки jne @@End ;закончить, сохранив код ошибки
mov DX, [ATABasePortAddr]
add DX, 7 ;адрес регистра состояни mov dx, [ATABasePortAddr]
add dx, 7 ;адрес регистра состояни
mov ecx, 0xffff mov ecx, 0xffff
@@WaitCompleet: @@WaitCompleet:
; Проверить время выполнения команды ; Проверить время выполнения команды
dec ecx dec ecx
; cmp ecx,0
jz @@Error1 ;ошибка тайм-аута jz @@Error1 ;ошибка тайм-аута
; Проверить готовность ; Проверить готовность
in AL, DX in al, dx
test AL, 80h ;состояние сигнала BSY test al, 80h ;состояние сигнала BSY
jnz @@WaitCompleet jnz @@WaitCompleet
test AL, 1 ;состояние сигнала ERR
test al, 1 ;состояние сигнала ERR
jnz @@Error6 jnz @@Error6
test AL, 08h ;состояние сигнала DRQ
test al, 08h ;состояние сигнала DRQ
jz @@WaitCompleet jz @@WaitCompleet
; Принять блок данных от контроллера ; Принять блок данных от контроллера
; mov AX,DS mov edi, Sector512
; mov ES,AX mov dx, [ATABasePortAddr];регистр данных
mov EDI, Sector512 ;offset Sector512 mov cx, 256 ;число считываемых слов
mov DX, [ATABasePortAddr];регистр данных
mov CX, 256 ;число считываемых слов
rep insw ;принять блок данных rep insw ;принять блок данных
ret ret
; Записать код ошибки ; Записать код ошибки
@@ -167,27 +214,24 @@ ReadHDD_ID:
mov [DevErrorCode], 6 mov [DevErrorCode], 6
@@End: @@End:
ret ret
;-----------------------------------------------------------------------------
iglobal
; Стандартные базовые адреса каналов 1 и 2
StandardATABases DW 1F0h, 170h
endg
uglobal uglobal
; Стандартные базовые адреса каналов 1 и 2
StandardATABases dw ?, ? ; 1F0h, 170h
; Номер канала ; Номер канала
ChannelNumber DW ? ChannelNumber dw ?
; Номер диска ; Номер диска
DiskNumber DB ? DiskNumber db ?
; Базовый адрес группы портов контроллера ATA ; Базовый адрес группы портов контроллера ATA
ATABasePortAddr DW ? ATABasePortAddr dw ?
; Параметры ATA-команды ; Параметры ATA-команды
ATAFeatures DB ? ;особенности ATAFeatures db ? ;особенности
ATASectorCount DB ? ;количество обрабатываемых секторов ATASectorCount db ? ;количество обрабатываемых секторов
ATASectorNumber DB ? ;номер начального сектора ATASectorNumber db ? ;номер начального сектора
ATACylinder DW ? ;номер начального цилиндра ATACylinder dw ? ;номер начального цилиндра
ATAHead DB ? ;номер начальной головки ATAHead db ? ;номер начальной головки
ATAAddressMode DB ? ;режим адресации (0 - CHS, 1 - LBA) ATAAddressMode db ? ;режим адресации (0 - CHS, 1 - LBA)
ATACommand DB ? ;код команды, подлежащей выполнению ATACommand db ? ;код команды, подлежащей выполнению
; Код ошибки (0 - нет ошибок, 1 - превышен допустимый ; Код ошибки (0 - нет ошибок, 1 - превышен допустимый
; интервал ожидания, 2 - неверный код режима адресации, ; интервал ожидания, 2 - неверный код режима адресации,
; 3 - неверный номер канала, 4 - неверный номер диска, ; 3 - неверный номер канала, 4 - неверный номер диска,
@@ -195,6 +239,7 @@ ATACommand DB ? ;код команды, подлежащей выполне
; команды) ; команды)
DevErrorCode dd ? DevErrorCode dd ?
endg endg
;-----------------------------------------------------------------------------
;**************************************************** ;****************************************************
;* ПОСЛАТЬ КОМАНДУ ЗАДАННОМУ ДИСКУ * ;* ПОСЛАТЬ КОМАНДУ ЗАДАННОМУ ДИСКУ *
;* Входные параметры передаются через глобальные * ;* Входные параметры передаются через глобальные *
@@ -219,82 +264,78 @@ SendCommandToHDD:
cmp [ATAAddressMode], 1 cmp [ATAAddressMode], 1
ja @@Err2 ja @@Err2
; Проверить корректность номера канала ; Проверить корректность номера канала
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
; Установить базовый адрес ; Установить базовый адрес
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
; Ожидание готовности HDD к приему команды ; Ожидание готовности HDD к приему команды
; Выбрать нужный диск ; Выбрать нужный диск
mov DX, [ATABasePortAddr] mov dx, [ATABasePortAddr]
add DX, 6 ;адрес регистра головок add dx, 6 ;адрес регистра головок
mov AL, [DiskNumber] mov al, [DiskNumber]
cmp AL, 1 ;проверить номера диска cmp al, 1 ;проверить номера диска
ja @@Err4 ja @@Err4
shl AL, 4
or AL, 10100000b shl al, 4
out DX, AL or al, 10100000b
out dx, al
; Ожидать, пока диск не будет готов ; Ожидать, пока диск не будет готов
inc DX inc dx
mov ecx, 0xfff mov ecx, 0xfff
; mov eax,[timer_ticks]
; mov [TickCounter_1],eax
@@WaitHDReady: @@WaitHDReady:
; Проверить время ожидани ; Проверить время ожидани
dec ecx dec ecx
; cmp ecx,0
jz @@Err1 jz @@Err1
; mov eax,[timer_ticks]
; sub eax,[TickCounter_1]
; cmp eax,300 ;ожидать 300 тиков
; ja @@Err1 ;ошибка тайм-аута
; Прочитать регистр состояни ; Прочитать регистр состояни
in AL, DX in al, dx
; Проверить состояние сигнала BSY ; Проверить состояние сигнала BSY
test AL, 80h test al, 80h
jnz @@WaitHDReady jnz @@WaitHDReady
; Проверить состояние сигнала DRQ ; Проверить состояние сигнала DRQ
test AL, 08h test al, 08h
jnz @@WaitHDReady jnz @@WaitHDReady
; Загрузить команду в регистры контроллера ; Загрузить команду в регистры контроллера
cli cli
mov DX, [ATABasePortAddr] mov dx, [ATABasePortAddr]
inc DX ;регистр "особенностей" inc dx ;регистр "особенностей"
mov AL, [ATAFeatures] mov al, [ATAFeatures]
out DX, AL out dx, AL
inc DX ;счетчик секторов inc dx ;счетчик секторов
mov AL, [ATASectorCount] mov al, [ATASectorCount]
out DX, AL out dx, AL
inc DX ;регистр номера сектора inc dx ;регистр номера сектора
mov AL, [ATASectorNumber] mov al, [ATASectorNumber]
out DX, AL out dx, AL
inc DX ;номер цилиндра (младший байт) inc dx ;номер цилиндра (младший байт)
mov AX, [ATACylinder] mov ax, [ATACylinder]
out DX, AL out dx, AL
inc DX ;номер цилиндра (старший байт) inc dx ;номер цилиндра (старший байт)
mov AL, AH mov al, AH
out DX, AL out dx, AL
inc DX ;номер головки/номер диска inc dx ;номер головки/номер диска
mov AL, [DiskNumber] mov al, [DiskNumber]
shl AL, 4 shl al, 4
cmp [ATAHead], 0Fh;проверить номер головки cmp [ATAHead], 0xF ;проверить номер головки
ja @@Err5 ja @@Err5
or AL, [ATAHead]
or AL, 10100000b or al, [ATAHead]
mov AH, [ATAAddressMode] or al, 10100000b
shl AH, 6 mov ah, [ATAAddressMode]
or AL, AH shl ah, 6
out DX, AL or al, ah
out dx, al
; Послать команду ; Послать команду
mov AL, [ATACommand] mov al, [ATACommand]
inc DX ;регистр команд inc dx ;регистр команд
out DX, AL out dx, al
sti sti
; Сбросить признак ошибки ; Сбросить признак ошибки
mov [DevErrorCode], 0 mov [DevErrorCode], 0
@@ -316,7 +357,7 @@ SendCommandToHDD:
mov [DevErrorCode], 5 mov [DevErrorCode], 5
; Завершение работы программы ; Завершение работы программы
ret ret
;-----------------------------------------------------------------------------
;************************************************* ;*************************************************
;* ЧТЕНИЕ ИДЕНТИФИКАТОРА УСТРОЙСТВА ATAPI * ;* ЧТЕНИЕ ИДЕНТИФИКАТОРА УСТРОЙСТВА ATAPI *
;* Входные параметры передаются через глобальные * ;* Входные параметры передаются через глобальные *
@@ -335,33 +376,32 @@ ReadCD_ID:
mov [ATASectorNumber], 0 mov [ATASectorNumber], 0
mov [ATACylinder], 0 mov [ATACylinder], 0
mov [ATAHead], 0 mov [ATAHead], 0
mov [ATACommand], 0A1h mov [ATACommand], 0xA1
call SendCommandToHDD call SendCommandToHDD
cmp [DevErrorCode], 0;проверить код ошибки cmp [DevErrorCode], 0;проверить код ошибки
jne @@End_1 ;закончить, сохранив код ошибки jne @@End_1 ;закончить, сохранив код ошибки
; Ожидать готовность данных HDD ; Ожидать готовность данных HDD
mov DX, [ATABasePortAddr] mov dx, [ATABasePortAddr]
add DX, 7 ;порт 1х7h add dx, 7 ;порт 1х7h
mov ecx, 0xffff mov ecx, 0xffff
@@WaitCompleet_1: @@WaitCompleet_1:
; Проверить врем ; Проверить врем
dec ecx dec ecx
; cmp ecx,0
jz @@Error1_1 ;ошибка тайм-аута jz @@Error1_1 ;ошибка тайм-аута
; Проверить готовность ; Проверить готовность
in AL, DX in al, dx
test AL, 80h ;состояние сигнала BSY test al, 80h ;состояние сигнала BSY
jnz @@WaitCompleet_1 jnz @@WaitCompleet_1
test AL, 1 ;состояние сигнала ERR
test al, 1 ;состояние сигнала ERR
jnz @@Error6_1 jnz @@Error6_1
test AL, 08h ;состояние сигнала DRQ
test al, 08h ;состояние сигнала DRQ
jz @@WaitCompleet_1 jz @@WaitCompleet_1
; Принять блок данных от контроллера ; Принять блок данных от контроллера
; mov AX,DS mov edi, Sector512 ;offset Sector512
; mov ES,AX mov dx, [ATABasePortAddr];порт 1x0h
mov EDI, Sector512 ;offset Sector512 mov cx, 256;число считываемых слов
mov DX, [ATABasePortAddr];порт 1x0h
mov CX, 256;число считываемых слов
rep insw rep insw
ret ret
; Записать код ошибки ; Записать код ошибки
@@ -372,7 +412,7 @@ ReadCD_ID:
mov [DevErrorCode], 6 mov [DevErrorCode], 6
@@End_1: @@End_1:
ret ret
;-----------------------------------------------------------------------------
;************************************************* ;*************************************************
;* СБРОС УСТРОЙСТВА * ;* СБРОС УСТРОЙСТВА *
;* Входные параметры передаются через глобальные * ;* Входные параметры передаются через глобальные *
@@ -382,39 +422,40 @@ ReadCD_ID:
;************************************************* ;*************************************************
DeviceReset: DeviceReset:
; Проверить корректность номера канала ; Проверить корректность номера канала
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
; Установить базовый адрес ; Установить базовый адрес
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
; Выбрать нужный диск ; Выбрать нужный диск
add DX, 6 ;адрес регистра головок add dx, 6 ;адрес регистра головок
mov AL, [DiskNumber] mov al, [DiskNumber]
cmp AL, 1 ;проверить номера диска cmp al, 1 ;проверить номера диска
ja @@Err4_2 ja @@Err4_2
shl AL, 4
or AL, 10100000b shl al, 4
out DX, AL or al, 10100000b
out dx, al
; Послать команду "Сброс" ; Послать команду "Сброс"
mov AL, 08h mov al, 0x8
inc DX ;регистр команд inc dx ;регистр команд
out DX, AL out dx, al
mov ecx, 0x80000 mov ecx, 0x80000
@@WaitHDReady_1: @@WaitHDReady_1:
; Проверить время ожидани ; Проверить время ожидани
dec ecx dec ecx
; cmp ecx,0
je @@Err1_2 ;ошибка тайм-аута je @@Err1_2 ;ошибка тайм-аута
; Прочитать регистр состояни ; Прочитать регистр состояни
in AL, DX in al, dx
; Проверить состояние сигнала BSY ; Проверить состояние сигнала BSY
test AL, 80h test al, 80h
jnz @@WaitHDReady_1 jnz @@WaitHDReady_1
; Сбросить признак ошибки ; Сбросить признак ошибки
mov [DevErrorCode], 0 mov [DevErrorCode], 0
@@ -430,6 +471,5 @@ DeviceReset:
mov [DevErrorCode], 4 mov [DevErrorCode], 4
; Записать код ошибки ; Записать код ошибки
ret ret
;-----------------------------------------------------------------------------
EndFindHDD: EndFindHDD:

View File

@@ -7,6 +7,7 @@
$Revision$ $Revision$
;-----------------------------------------------------------------------------
pusha pusha
mov eax, [pg_data.pages_free] mov eax, [pg_data.pages_free]
@@ -20,89 +21,167 @@ $Revision$
; 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 .continue
mov eax, 128*1024
@@:
.continue:
mov [cache_ide0_size], eax
mov [cache_ide1_size], eax
mov [cache_ide2_size], eax
mov [cache_ide3_size], eax
xor eax, eax
mov [hdd_appl_data], 1;al
mov [cd_appl_data], 1
test byte [DRIVE_DATA+1], 2 mov eax, 128*1024
je .ide2 ;--------------------------------------
mov esi, cache_ide3 .continue:
call get_cache_ide push ecx
.ide2: mov ecx, 12
test byte [DRIVE_DATA+1], 8 mov esi, cache_ide0+IDE_CACHE.size
je .ide1 cld
mov esi, cache_ide2 @@:
call get_cache_ide mov [esi], eax
.ide1: add esi, sizeof.IDE_CACHE
test byte [DRIVE_DATA+1], 0x20 loop @b
je .ide0
mov esi, cache_ide1 pop ecx
call get_cache_ide
.ide0: xor eax, eax
mov [hdd_appl_data], 1 ;al
mov [cd_appl_data], 1
;--------------------------------------
test byte [DRIVE_DATA+1], 0x80 test byte [DRIVE_DATA+1], 0x80
je @f je @f
mov esi, cache_ide0 mov esi, cache_ide0
call get_cache_ide call get_cache_ide
;--------------------------------------
@@: @@:
jmp end_get_cache test byte [DRIVE_DATA+1], 0x20
je @f
mov esi, cache_ide1
call get_cache_ide
;--------------------------------------
@@:
test byte [DRIVE_DATA+1], 8
je @f
mov esi, cache_ide2
call get_cache_ide
;--------------------------------------
@@:
test byte [DRIVE_DATA+1], 2
je @f
mov esi, cache_ide3
call get_cache_ide
;--------------------------------------
@@:
test byte [DRIVE_DATA+6], 0x80
je @f
mov esi, cache_ide4
call get_cache_ide
;--------------------------------------
@@:
test byte [DRIVE_DATA+6], 0x20
je @f
mov esi, cache_ide5
call get_cache_ide
;--------------------------------------
@@:
test byte [DRIVE_DATA+6], 8
je @f
mov esi, cache_ide6
call get_cache_ide
;--------------------------------------
@@:
test byte [DRIVE_DATA+6], 2
je @f
mov esi, cache_ide7
call get_cache_ide
;--------------------------------------
@@:
test byte [DRIVE_DATA+11], 0x80
je @f
mov esi, cache_ide8
call get_cache_ide
;--------------------------------------
@@:
test byte [DRIVE_DATA+11], 0x20
je @f
mov esi, cache_ide9
call get_cache_ide
;--------------------------------------
@@:
test byte [DRIVE_DATA+11], 8
je @f
mov esi, cache_ide10
call get_cache_ide
;--------------------------------------
@@:
test byte [DRIVE_DATA+11], 2
je end_get_cache
mov esi, cache_ide11
call get_cache_ide
jmp end_get_cache
;-----------------------------------------------------------------------------
get_cache_ide: get_cache_ide:
and [esi+cache_ide0_search_start-cache_ide0], 0 and [esi+IDE_CACHE.search_start], 0
and [esi+cache_ide0_appl_search_start-cache_ide0], 0 and [esi+IDE_CACHE.appl_search_start], 0
push ecx push ecx
stdcall kernel_alloc, [esi+cache_ide0_size-cache_ide0] DEBUGF 1, "K : IDE_CACHE.size %x\n", [esi+IDE_CACHE.size]
mov [esi+cache_ide0_pointer-cache_ide0], eax stdcall kernel_alloc, [esi+IDE_CACHE.size]
mov [esi+IDE_CACHE.pointer], eax
pop ecx pop ecx
mov edx, eax mov edx, eax
mov eax, [esi+cache_ide0_size-cache_ide0] mov eax, [esi+IDE_CACHE.size]
shr eax, 3 shr eax, 3
mov [esi+cache_ide0_system_data_size-cache_ide0], eax DEBUGF 1, "K : IDE_CACHE.system_data_size %x\n", eax
mov [esi+IDE_CACHE.system_data_size], eax
mov ebx, eax mov ebx, eax
imul eax, 7 imul eax, 7
mov [esi+cache_ide0_appl_data_size-cache_ide0], eax DEBUGF 1, "K : IDE_CACHE.appl_data_size %x\n", eax
mov [esi+IDE_CACHE.appl_data_size], eax
add ebx, edx add ebx, edx
mov [esi+cache_ide0_data_pointer-cache_ide0], ebx mov [esi+IDE_CACHE.data_pointer], ebx
.cd: .cd:
push ecx push ecx
mov eax, [esi+cache_ide0_system_data_size-cache_ide0] mov eax, [esi+IDE_CACHE.system_data_size]
call calculate_for_cd call calculate_for_cd
add eax, [esi+cache_ide0_pointer-cache_ide0] add eax, [esi+IDE_CACHE.pointer]
mov [esi+cache_ide0_system_data-cache_ide0], eax mov [esi+IDE_CACHE.system_data], eax
mov [esi+cache_ide0_system_sad_size-cache_ide0], ecx mov [esi+IDE_CACHE.system_sad_size], ecx
push edi push edi
mov edi, [esi+cache_ide0_pointer-cache_ide0] mov edi, [esi+IDE_CACHE.pointer]
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+IDE_CACHE.appl_data_size]
call calculate_for_cd call calculate_for_cd
add eax, [esi+cache_ide0_data_pointer-cache_ide0] add eax, [esi+IDE_CACHE.data_pointer]
mov [esi+cache_ide0_appl_data-cache_ide0], eax mov [esi+IDE_CACHE.appl_data], eax
mov [esi+cache_ide0_appl_sad_size-cache_ide0], ecx mov [esi+IDE_CACHE.appl_sad_size], ecx
push edi push edi
mov edi, [esi+cache_ide0_data_pointer-cache_ide0] mov edi, [esi+IDE_CACHE.data_pointer]
call clear_ide_cache call clear_ide_cache
pop edi pop edi
pop ecx pop ecx
ret ret
;-----------------------------------------------------------------------------
calculate_for_cd: calculate_for_cd:
push eax push eax
mov ebx, eax mov ebx, eax
@@ -116,7 +195,7 @@ calculate_for_cd:
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
@@ -125,6 +204,6 @@ clear_ide_cache:
rep stosd rep stosd
pop eax pop eax
ret ret
;-----------------------------------------------------------------------------
end_get_cache: end_get_cache:
popa popa

View File

@@ -1,111 +1,151 @@
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
; find the IDE controller in the device list ; find the IDE controller in the device list
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
mov ecx, IDE_controller_1
mov esi, pcidev_list mov esi, pcidev_list
;--------------------------------------
align 4
.loop: .loop:
mov esi, [esi+PCIDEV.fd] mov esi, [esi+PCIDEV.fd]
cmp esi, pcidev_list cmp esi, pcidev_list
jz .done jz find_IDE_controller_done
mov eax, [esi+PCIDEV.class] mov eax, [esi+PCIDEV.class]
shr eax, 4 shr eax, 4
cmp eax, 0x01018 cmp eax, 0x01018
jnz .loop jnz .loop
;--------------------------------------
.found: .found:
mov eax, [esi+PCIDEV.class] mov eax, [esi+PCIDEV.class]
DEBUGF 1, 'K : IDE controller programming interface %x\n', eax DEBUGF 1, 'K : IDE controller programming interface %x\n', eax
mov [IDEContrProgrammingInterface], eax mov [ecx+IDE_DATA.ProgrammingInterface], eax
mov ah, [esi+PCIDEV.bus] mov ah, [esi+PCIDEV.bus]
mov al, 2 mov al, 2
mov bh, [esi+PCIDEV.devfn] mov bh, [esi+PCIDEV.devfn]
;----------------------------------------------------------------------------- ;--------------------------------------
mov bl, 0x10 mov bl, 0x10
push eax push eax
call pci_read_reg call pci_read_reg
and eax, 0xFFFC and eax, 0xFFFC
cmp ax, 0 cmp ax, 0
je @f je @f
cmp ax, 1 cmp ax, 1
jne .show_BAR0 jne .show_BAR0
;--------------------------------------
@@: @@:
mov ax, 0x1F0 mov ax, 0x1F0
;--------------------------------------
.show_BAR0: .show_BAR0:
DEBUGF 1, 'K : BAR0 IDE base addr %x\n', ax DEBUGF 1, 'K : BAR0 IDE base addr %x\n', ax
mov [StandardATABases], ax mov [StandardATABases], ax
mov [hd_address_table], eax mov [ecx+IDE_DATA.BAR0_val], ax
mov [hd_address_table+8], eax
mov [IDE_BAR0_val], ax
pop eax pop eax
;----------------------------------------------------------------------------- ;--------------------------------------
mov bl, 0x14 mov bl, 0x14
push eax push eax
call pci_read_reg call pci_read_reg
and eax, 0xFFFC and eax, 0xFFFC
cmp ax, 0 cmp ax, 0
je @f je @f
cmp ax, 1 cmp ax, 1
jne .show_BAR1 jne .show_BAR1
;--------------------------------------
@@: @@:
mov ax, 0x3F4 mov ax, 0x3F4
;--------------------------------------
.show_BAR1: .show_BAR1:
DEBUGF 1, 'K : BAR1 IDE base addr %x\n', ax DEBUGF 1, 'K : BAR1 IDE base addr %x\n', ax
mov [IDE_BAR1_val], ax mov [ecx+IDE_DATA.BAR1_val], ax
pop eax pop eax
;----------------------------------------------------------------------------- ;--------------------------------------
mov bl, 0x18 mov bl, 0x18
push eax push eax
call pci_read_reg call pci_read_reg
and eax, 0xFFFC and eax, 0xFFFC
cmp ax, 0 cmp ax, 0
je @f je @f
cmp ax, 1 cmp ax, 1
jne .show_BAR2 jne .show_BAR2
;--------------------------------------
@@: @@:
mov ax, 0x170 mov ax, 0x170
;--------------------------------------
.show_BAR2: .show_BAR2:
DEBUGF 1, 'K : BAR2 IDE base addr %x\n', ax DEBUGF 1, 'K : BAR2 IDE base addr %x\n', ax
mov [StandardATABases+2], ax mov [StandardATABases+2], ax
mov [hd_address_table+16], eax mov [ecx+IDE_DATA.BAR2_val], ax
mov [hd_address_table+24], eax
mov [IDE_BAR2_val], ax
pop eax pop eax
;----------------------------------------------------------------------------- ;--------------------------------------
mov bl, 0x1C mov bl, 0x1C
push eax push eax
call pci_read_reg call pci_read_reg
and eax, 0xFFFC and eax, 0xFFFC
cmp ax, 0 cmp ax, 0
je @f je @f
cmp ax, 1 cmp ax, 1
jne .show_BAR3 jne .show_BAR3
;--------------------------------------
@@: @@:
mov ax, 0x374 mov ax, 0x374
;--------------------------------------
.show_BAR3: .show_BAR3:
DEBUGF 1, 'K : BAR3 IDE base addr %x\n', ax DEBUGF 1, 'K : BAR3 IDE base addr %x\n', ax
mov [IDE_BAR3_val], ax mov [ecx+IDE_DATA.BAR3_val], ax
pop eax pop eax
;----------------------------------------------------------------------------- ;--------------------------------------
mov bl, 0x20 mov bl, 0x20
push eax push eax
call pci_read_reg call pci_read_reg
and eax, 0xFFFC and eax, 0xFFFC
DEBUGF 1, 'K : BAR4 IDE controller register base addr %x\n', ax DEBUGF 1, 'K : BAR4 IDE controller register base addr %x\n', ax
mov [IDEContrRegsBaseAddr], ax mov [ecx+IDE_DATA.RegsBaseAddres], ax
pop eax pop eax
;----------------------------------------------------------------------------- ;--------------------------------------
mov bl, 0x3C mov bl, 0x3C
push eax push eax
call pci_read_reg call pci_read_reg
and eax, 0xFF and eax, 0xFF
DEBUGF 1, 'K : IDE Interrupt %x\n', al DEBUGF 1, 'K : IDE Interrupt %x\n', al
mov [IDE_Interrupt], ax mov [ecx+IDE_DATA.Interrupt], ax
pop eax pop eax
add ecx, sizeof.IDE_DATA
;--------------------------------------
jmp .loop
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
.done: uglobal
align 4
;--------------------------------------
IDE_controller_pointer dd ?
;--------------------------------------
IDE_controller_1 IDE_DATA
IDE_controller_2 IDE_DATA
IDE_controller_3 IDE_DATA
;--------------------------------------
cache_ide0 IDE_CACHE
cache_ide1 IDE_CACHE
cache_ide2 IDE_CACHE
cache_ide3 IDE_CACHE
cache_ide4 IDE_CACHE
cache_ide5 IDE_CACHE
cache_ide6 IDE_CACHE
cache_ide7 IDE_CACHE
cache_ide8 IDE_CACHE
cache_ide9 IDE_CACHE
cache_ide10 IDE_CACHE
cache_ide11 IDE_CACHE
;--------------------------------------
endg
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
; START of initialisation IDE ATA code ; START of initialisation IDE ATA code
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
cmp [IDEContrProgrammingInterface], 0 Init_IDE_ATA_controller:
cmp [ecx+IDE_DATA.ProgrammingInterface], 0
je set_interrupts_for_IDE_controllers.continue je set_interrupts_for_IDE_controllers.continue
mov esi, boot_disabling_ide mov esi, boot_disabling_ide
@@ -117,33 +157,25 @@
.disable_IDE_interrupt: .disable_IDE_interrupt:
; Disable interrupts in IDE controller for PIO ; Disable interrupts in IDE controller for PIO
mov al, 2 mov al, 2
mov dx, [IDE_BAR1_val] ;0x3F4 mov dx, [ecx+IDE_DATA.BAR1_val] ;0x3F4
add dx, 2 ;0x3F6 add dx, 2 ;0x3F6
out dx, al out dx, al
mov dx, [IDE_BAR3_val] ;0x374 mov dx, [ecx+IDE_DATA.BAR3_val] ;0x374
add dx, 2 ;0x376 add dx, 2 ;0x376
out dx, al out dx, al
@@:
; show base variables of IDE controller
; DEBUGF 1, "K : BAR0 %x \n", [IDE_BAR0_val]:4
; DEBUGF 1, "K : BAR1 %x \n", [IDE_BAR1_val]:4
; DEBUGF 1, "K : BAR2 %x \n", [IDE_BAR2_val]:4
; DEBUGF 1, "K : BAR3 %x \n", [IDE_BAR3_val]:4
; DEBUGF 1, "K : BAR4 %x \n", [IDEContrRegsBaseAddr]:4
; DEBUGF 1, "K : IDEContrProgrammingInterface %x \n", [IDEContrProgrammingInterface]:4
; DEBUGF 1, "K : IDE_Interrupt %x \n", [IDE_Interrupt]:4
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
; set current ata bases
@@:
mov ax, [ecx+IDE_DATA.BAR0_val]
mov [StandardATABases], ax
mov ax, [ecx+IDE_DATA.BAR2_val]
mov [StandardATABases+2], ax
mov esi, boot_detecthdcd mov esi, boot_detecthdcd
call boot_log call boot_log
include 'dev_hdcd.inc' include 'dev_hdcd.inc'
mov esi, boot_getcache
call boot_log
include 'getcache.inc'
mov esi, boot_detectpart
call boot_log
include 'sear_par.inc'
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
mov dx, [IDEContrRegsBaseAddr] mov dx, [ecx+IDE_DATA.RegsBaseAddres]
; test whether it is our interrupt? ; test whether it is our interrupt?
add dx, 2 add dx, 2
in al, dx in al, dx
@@ -152,6 +184,7 @@ include 'sear_par.inc'
; clear Bus Master IDE Status register ; clear Bus Master IDE Status register
; clear Interrupt bit ; clear Interrupt bit
out dx, al out dx, al
;--------------------------------------
@@: @@:
add dx, 8 add dx, 8
; test whether it is our interrupt? ; test whether it is our interrupt?
@@ -161,17 +194,18 @@ include 'sear_par.inc'
; clear Bus Master IDE Status register ; clear Bus Master IDE Status register
; clear Interrupt bit ; clear Interrupt bit
out dx, al out dx, al
;--------------------------------------
@@: @@:
; read status register and remove the interrupt request ; read status register and remove the interrupt request
mov dx, [IDE_BAR0_val] ;0x1F0 mov dx, [ecx+IDE_DATA.BAR0_val] ;0x1F0
add dx, 0x7 ;0x1F7 add dx, 0x7 ;0x1F7
in al, dx in al, dx
mov dx, [IDE_BAR2_val] ;0x170 mov dx, [ecx+IDE_DATA.BAR2_val] ;0x170
add dx, 0x7 ;0x177 add dx, 0x7 ;0x177
in al, dx in al, dx
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
push eax edx push eax edx
mov dx, [IDEContrRegsBaseAddr] mov dx, [ecx+IDE_DATA.RegsBaseAddres]
xor eax, eax xor eax, eax
add dx, 2 add dx, 2
in al, dx in al, dx
@@ -182,15 +216,15 @@ include 'sear_par.inc'
DEBUGF 1, "K : Secondary Bus Master IDE Status Register %x\n", eax DEBUGF 1, "K : Secondary Bus Master IDE Status Register %x\n", eax
pop edx eax pop edx eax
cmp [IDEContrRegsBaseAddr], 0 cmp [ecx+IDE_DATA.RegsBaseAddres], 0
setnz [dma_hdd] setnz [ecx+IDE_DATA.dma_hdd]
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
; set interrupts for IDE Controller ; set interrupts for IDE Controller
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
mov esi, boot_set_int_IDE mov esi, boot_set_int_IDE
call boot_log call boot_log
set_interrupts_for_IDE_controllers: set_interrupts_for_IDE_controllers:
mov eax, [IDEContrProgrammingInterface] mov eax, [ecx+IDE_DATA.ProgrammingInterface]
cmp ax, 0x0180 cmp ax, 0x0180
je .pata_ide je .pata_ide
@@ -198,13 +232,16 @@ set_interrupts_for_IDE_controllers:
jne .sata_ide jne .sata_ide
;-------------------------------------- ;--------------------------------------
.pata_ide: .pata_ide:
cmp [IDEContrRegsBaseAddr], 0 cmp [ecx+IDE_DATA.RegsBaseAddres], 0
je .end_set_interrupts je .end_set_interrupts
push ecx
stdcall attach_int_handler, 14, IDE_irq_14_handler, 0 stdcall attach_int_handler, 14, IDE_irq_14_handler, 0
DEBUGF 1, "K : Set IDE IRQ14 return code %x\n", eax DEBUGF 1, "K : Set IDE IRQ14 return code %x\n", eax
stdcall attach_int_handler, 15, IDE_irq_15_handler, 0 stdcall attach_int_handler, 15, IDE_irq_15_handler, 0
DEBUGF 1, "K : Set IDE IRQ15 return code %x\n", eax DEBUGF 1, "K : Set IDE IRQ15 return code %x\n", eax
pop ecx
jmp .enable_IDE_interrupt jmp .enable_IDE_interrupt
;-------------------------------------- ;--------------------------------------
.sata_ide: .sata_ide:
@@ -215,53 +252,93 @@ set_interrupts_for_IDE_controllers:
jne .end_set_interrupts jne .end_set_interrupts
;-------------------------------------- ;--------------------------------------
.sata_ide_1: .sata_ide_1:
cmp [IDEContrRegsBaseAddr], 0 cmp [ecx+IDE_DATA.RegsBaseAddres], 0
je .end_set_interrupts je .end_set_interrupts
mov ax, [IDE_Interrupt] mov ax, [ecx+IDE_DATA.Interrupt]
movzx eax, al movzx eax, al
push ecx
stdcall attach_int_handler, eax, IDE_common_irq_handler, 0 stdcall attach_int_handler, eax, IDE_common_irq_handler, 0
DEBUGF 1, "K : Set IDE IRQ%d return code %x\n", [IDE_Interrupt]:1, eax pop ecx
DEBUGF 1, "K : Set IDE IRQ%d return code %x\n", [ecx+IDE_DATA.Interrupt]:1, eax
;-------------------------------------- ;--------------------------------------
.enable_IDE_interrupt: .enable_IDE_interrupt:
mov esi, boot_enabling_ide mov esi, boot_enabling_ide
call boot_log call boot_log
; Enable interrupts in IDE controller for DMA ; Enable interrupts in IDE controller for DMA
xor ebx, ebx
cmp ecx, IDE_controller_2
jne @f
add ebx, 5
jmp .check_DRIVE_DATA
;--------------------------------------
@@:
cmp ecx, IDE_controller_3
jne .check_DRIVE_DATA
add ebx, 10
;--------------------------------------
.check_DRIVE_DATA:
mov al, 0 mov al, 0
mov ah, [DRIVE_DATA+1] mov ah, [ebx+DRIVE_DATA+1]
test ah, 10100000b test ah, 10100000b
jz @f jz @f
DEBUGF 1, "K : IDE CH1 PIO, because ATAPI drive present\n" DEBUGF 1, "K : IDE CH1 PIO, because ATAPI drive present\n"
jmp .ch2_check jmp .ch2_check
;--------------------------------------
@@: @@:
mov dx, [IDE_BAR1_val] ;0x3F4 mov dx, [ecx+IDE_DATA.BAR1_val] ;0x3F4
add dx, 2 ;0x3F6 add dx, 2 ;0x3F6
out dx, al out dx, al
DEBUGF 1, "K : IDE CH1 DMA enabled\n" DEBUGF 1, "K : IDE CH1 DMA enabled\n"
;--------------------------------------
.ch2_check: .ch2_check:
test ah, 1010b test ah, 1010b
jz @f jz @f
DEBUGF 1, "K : IDE CH2 PIO, because ATAPI drive present\n" DEBUGF 1, "K : IDE CH2 PIO, because ATAPI drive present\n"
jmp .end_set_interrupts jmp .end_set_interrupts
;--------------------------------------
@@: @@:
mov dx, [IDE_BAR3_val] ;0x374 mov dx, [ecx+IDE_DATA.BAR3_val] ;0x374
add dx, 2 ;0x376 add dx, 2 ;0x376
out dx, al out dx, al
DEBUGF 1, "K : IDE CH2 DMA enabled\n" DEBUGF 1, "K : IDE CH2 DMA enabled\n"
;-------------------------------------- ;--------------------------------------
.end_set_interrupts: .end_set_interrupts:
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
cmp [dma_hdd], 0 cmp [ecx+IDE_DATA.dma_hdd], 0
je .print_pio je .print_pio
;--------------------------------------
.print_dma: .print_dma:
DEBUGF 1, "K : IDE DMA mode\n" DEBUGF 1, "K : IDE DMA mode\n"
jmp .continue jmp .continue
;--------------------------------------
.print_pio: .print_pio:
DEBUGF 1, "K : IDE PIO mode\n" DEBUGF 1, "K : IDE PIO mode\n"
.continue: .continue:
ret
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
; END of initialisation IDE ATA code ; END of initialisation IDE ATA code
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
find_IDE_controller_done:
mov ecx, IDE_controller_1
mov [IDE_controller_pointer], ecx
call Init_IDE_ATA_controller
mov ecx, IDE_controller_2
mov [IDE_controller_pointer], ecx
call Init_IDE_ATA_controller
mov ecx, IDE_controller_3
mov [IDE_controller_pointer], ecx
call Init_IDE_ATA_controller
;-----------------------------------------------------------------------------
mov esi, boot_getcache
call boot_log
include 'getcache.inc'
;-----------------------------------------------------------------------------
mov esi, boot_detectpart
call boot_log
include 'sear_par.inc'
;-----------------------------------------------------------------------------

View File

@@ -8,63 +8,203 @@
$Revision$ $Revision$
search_partitions: search_partitions:
push ecx
; 1. Fill missing parameters in HD_DATA structures. ; 1. Fill missing parameters in HD_DATA structures.
mov eax, [hd_address_table] xor eax, eax
mov [hd0_data.hdbase], eax ;0x1f0 mov edx, IDE_controller_1
mov ax, [edx + IDE_DATA.BAR0_val]
mov [hd0_data.hdbase], eax
mov [hd1_data.hdbase], eax mov [hd1_data.hdbase], eax
mov eax, [hd_address_table+16] mov ax, [edx + IDE_DATA.BAR2_val]
mov [hd2_data.hdbase], eax mov [hd2_data.hdbase], eax
mov [hd3_data.hdbase], eax mov [hd3_data.hdbase], eax
mov edx, IDE_controller_2
mov ax, [edx + IDE_DATA.BAR0_val]
mov [hd4_data.hdbase], eax
mov [hd5_data.hdbase], eax
mov ax, [edx + IDE_DATA.BAR2_val]
mov [hd6_data.hdbase], eax
mov [hd7_data.hdbase], eax
mov edx, IDE_controller_3
mov ax, [edx + IDE_DATA.BAR0_val]
mov [hd8_data.hdbase], eax
mov [hd9_data.hdbase], eax
mov ax, [edx + IDE_DATA.BAR2_val]
mov [hd10_data.hdbase], eax
mov [hd11_data.hdbase], eax
; 2. Notify the system about /hd* disks. ; 2. Notify the system about /hd* disks.
; For every existing disk, call ide_disk_add with correct parameters. ; For every existing disk, call ide_disk_add with correct parameters.
; Generate name "hdN" on the stack; this is 4 bytes including terminating zero. ; Generate name "hdN" on the stack; this is 4 bytes including terminating zero.
;-----------------------------------------------------------------------------
; 2a. /hd0: exists if mask 0x40 in [DRIVE_DATA+1] is set, ; 2a. /hd0: exists if mask 0x40 in [DRIVE_DATA+1] is set,
; data: hd0_data, ; data: hd0_data,
; number of partitions: [DRIVE_DATA+2] ; number of partitions: [DRIVE_DATA+2]
test [DRIVE_DATA+1], byte 0x40 test [DRIVE_DATA+1], byte 0x40
jz @f jz @f
DEBUGF 1, "K : HD0\n"
push 'hd0' push 'hd0'
mov eax, esp ; name mov eax, esp ; name
mov edx, hd0_data mov edx, hd0_data
call ide_disk_add call ide_disk_add
mov [DRIVE_DATA+2], al mov [DRIVE_DATA+2], al
pop ecx ; restore the stack pop ecx ; restore the stack
;-----------------------------------------------------------------------------
@@: @@:
; 2b. /hd1: exists if mask 0x10 in [DRIVE_DATA+1] is set, ; 2b. /hd1: exists if mask 0x10 in [DRIVE_DATA+1] is set,
; data: hd1_data, ; data: hd1_data,
; number of partitions: [DRIVE_DATA+3] ; number of partitions: [DRIVE_DATA+3]
test [DRIVE_DATA+1], byte 0x10 test [DRIVE_DATA+1], byte 0x10
jz @f jz @f
DEBUGF 1, "K : HD1\n"
push 'hd1' push 'hd1'
mov eax, esp mov eax, esp
mov edx, hd1_data mov edx, hd1_data
call ide_disk_add call ide_disk_add
mov [DRIVE_DATA+3], al mov [DRIVE_DATA+3], al
pop ecx pop ecx
;-----------------------------------------------------------------------------
@@: @@:
; 2c. /hd2: exists if mask 4 in [DRIVE_DATA+1] is set, ; 2c. /hd2: exists if mask 4 in [DRIVE_DATA+1] is set,
; data: hd2_data, ; data: hd2_data,
; number of partitions: [DRIVE_DATA+4] ; number of partitions: [DRIVE_DATA+4]
test [DRIVE_DATA+1], byte 4 test [DRIVE_DATA+1], byte 4
jz @f jz @f
DEBUGF 1, "K : HD2\n"
push 'hd2' push 'hd2'
mov eax, esp mov eax, esp
mov edx, hd2_data mov edx, hd2_data
call ide_disk_add call ide_disk_add
mov [DRIVE_DATA+4], al mov [DRIVE_DATA+4], al
pop ecx pop ecx
;-----------------------------------------------------------------------------
@@: @@:
; 2d. /hd3: exists if mask 1 in [DRIVE_DATA+1] is set, ; 2d. /hd3: exists if mask 1 in [DRIVE_DATA+1] is set,
; data: hd3_data, ; data: hd3_data,
; number of partitions: [DRIVE_DATA+5] ; number of partitions: [DRIVE_DATA+5]
test [DRIVE_DATA+1], byte 1 test [DRIVE_DATA+1], byte 1
jz @f jz @f
DEBUGF 1, "K : HD3\n"
push 'hd3' push 'hd3'
mov eax, esp mov eax, esp
mov edx, hd3_data mov edx, hd3_data
call ide_disk_add call ide_disk_add
mov [DRIVE_DATA+5], al mov [DRIVE_DATA+5], al
pop ecx pop ecx
;-----------------------------------------------------------------------------
@@:
; 2e. /hd4: exists if mask 0x40 in [DRIVE_DATA+6] is set,
; data: hd4_data,
; number of partitions: [DRIVE_DATA+7]
test [DRIVE_DATA+6], byte 0x40
jz @f
DEBUGF 1, "K : HD4\n"
push 'hd4'
mov eax, esp ; name
mov edx, hd4_data
call ide_disk_add
mov [DRIVE_DATA+7], al
pop ecx
;-----------------------------------------------------------------------------
@@:
; 2f. /hd5: exists if mask 0x10 in [DRIVE_DATA+6] is set,
; data: hd5_data,
; number of partitions: [DRIVE_DATA+8]
test [DRIVE_DATA+6], byte 0x10
jz @f
DEBUGF 1, "K : HD5\n"
push 'hd5'
mov eax, esp
mov edx, hd5_data
call ide_disk_add
mov [DRIVE_DATA+8], al
pop ecx
;-----------------------------------------------------------------------------
@@:
; 2g. /hd6: exists if mask 4 in [DRIVE_DATA+6] is set,
; data: hd6_data,
; number of partitions: [DRIVE_DATA+9]
test [DRIVE_DATA+6], byte 4
jz @f
DEBUGF 1, "K : HD6\n"
push 'hd6'
mov eax, esp
mov edx, hd6_data
call ide_disk_add
mov [DRIVE_DATA+9], al
pop ecx
;-----------------------------------------------------------------------------
@@:
; 2h. /hd7: exists if mask 1 in [DRIVE_DATA+6] is set,
; data: hd7_data,
; number of partitions: [DRIVE_DATA+10]
test [DRIVE_DATA+6], byte 1
jz @f
DEBUGF 1, "K : HD7\n"
push 'hd7'
mov eax, esp
mov edx, hd7_data
call ide_disk_add
mov [DRIVE_DATA+10], al
pop ecx
;-----------------------------------------------------------------------------
@@:
; 2i. /hd8: exists if mask 0x40 in [DRIVE_DATA+11] is set,
; data: hd8_data,
; number of partitions: [DRIVE_DATA+12]
test [DRIVE_DATA+11], byte 0x40
jz @f
DEBUGF 1, "K : HD8\n"
push 'hd8'
mov eax, esp ; name
mov edx, hd8_data
call ide_disk_add
mov [DRIVE_DATA+12], al
pop ecx
;-----------------------------------------------------------------------------
@@:
; 2j. /hd9: exists if mask 0x10 in [DRIVE_DATA+11] is set,
; data: hd9_data,
; number of partitions: [DRIVE_DATA+13]
test [DRIVE_DATA+11], byte 0x10
jz @f
DEBUGF 1, "K : HD9\n"
push 'hd9'
mov eax, esp
mov edx, hd9_data
call ide_disk_add
mov [DRIVE_DATA+13], al
pop ecx
;-----------------------------------------------------------------------------
@@:
; 2k. /hd10: exists if mask 4 in [DRIVE_DATA+11] is set,
; data: hd10_data,
; number of partitions: [DRIVE_DATA+14]
test [DRIVE_DATA+14], byte 4
jz @f
DEBUGF 1, "K : HD10\n"
push 'hd10'
mov eax, esp
mov edx, hd10_data
call ide_disk_add
mov [DRIVE_DATA+9], al
pop ecx
;-----------------------------------------------------------------------------
@@:
; 2l. /hd11: exists if mask 1 in [DRIVE_DATA+11] is set,
; data: hd11_data,
; number of partitions: [DRIVE_DATA+15]
test [DRIVE_DATA+11], byte 1
jz @f
DEBUGF 1, "K : HD11\n"
push 'hd11'
mov eax, esp
mov edx, hd11_data
call ide_disk_add
mov [DRIVE_DATA+15], al
pop ecx
;-----------------------------------------------------------------------------
@@: @@:
; 3. Notify the system about /bd* disks. ; 3. Notify the system about /bd* disks.
; 3a. Check whether there are BIOS disks. If no, skip step 3. ; 3a. Check whether there are BIOS disks. If no, skip step 3.
@@ -114,11 +254,12 @@ endg
jnz .bdloop jnz .bdloop
pop ecx ecx ; restore stack after name pop ecx ecx ; restore stack after name
.nobd: .nobd:
DEBUGF 1, "K : jmp end_search_partitions\n"
jmp end_search_partitions jmp end_search_partitions
;-----------------------------------------------------------------------------
; Helper procedure for search_partitions, adds one IDE disk. ; Helper procedure for search_partitions, adds one IDE disk.
; For compatibility, number of partitions for IDE disks is kept in a separate variable, ; For compatibility, number of partitions for IDE disks is kept in a separate
; so the procedure returns number of partitions. ; variable, so the procedure returns number of partitions.
; eax -> name, edx -> disk data ; eax -> name, edx -> disk data
proc ide_disk_add proc ide_disk_add
stdcall disk_add, ide_callbacks, eax, edx, 0 stdcall disk_add, ide_callbacks, eax, edx, 0
@@ -134,6 +275,6 @@ proc ide_disk_add
@@: @@:
ret ret
endp endp
;-----------------------------------------------------------------------------
end_search_partitions: end_search_partitions:
pop ecx

View File

@@ -845,7 +845,7 @@
* eax = 18 - номер функции * eax = 18 - номер функции
* ebx = 11 - номер подфункции * ebx = 11 - номер подфункции
* ecx = тип таблицы: * ecx = тип таблицы:
* 1 = короткая версия, 10 байт * 1 = короткая версия, 16 байт
* edx = указатель на буфер (в приложении) для таблицы * edx = указатель на буфер (в приложении) для таблицы
Возвращаемое значение: Возвращаемое значение:
* функция не возвращает значения * функция не возвращает значения
@@ -862,6 +862,8 @@
Например, для стандартной конфигурации из одного 1.44-дисковода Например, для стандартной конфигурации из одного 1.44-дисковода
здесь будет 40h, а для случая 1.2Mb на A: и 1.44Mb на B: здесь будет 40h, а для случая 1.2Mb на A: и 1.44Mb на B:
значение оказывается 24h. значение оказывается 24h.
Первый контроллер IDE:
* +1: byte: информация о жёстких дисках и CD-приводах, AABBCCDD, * +1: byte: информация о жёстких дисках и CD-приводах, AABBCCDD,
где AA соответствует контроллеру IDE0, ..., DD - IDE3: где AA соответствует контроллеру IDE0, ..., DD - IDE3:
* 0 = устройство отсутствует * 0 = устройство отсутствует
@@ -870,15 +872,36 @@
Например, в случае HD на IDE0 и CD на IDE2 здесь будет 48h. Например, в случае HD на IDE0 и CD на IDE2 здесь будет 48h.
* +2: 4 db: число найденных разделов на жёстких дисках с * +2: 4 db: число найденных разделов на жёстких дисках с
соответственно IDE0,...,IDE3. соответственно IDE0,...,IDE3.
Второй контроллер IDE:
* +6: byte: информация о жёстких дисках и CD-приводах, AABBCCDD
где AA соответствует контроллеру IDE4, ..., DD - IDE7:
* 0 = устройство отсутствует
* 1 = жёсткий диск
* 2 = CD-привод
Например, в случае HD на IDE4 и CD на IDE6 здесь будет 48h.
* +7: 4 db: число найденных разделов на жёстких дисках с
соответственно IDE4,...,IDE7.
Третий контроллер IDE:
* +11: byte: информация о жёстких дисках и CD-приводах, AABBCCDD
где AA соответствует контроллеру IDE8, ..., DD - IDE11:
* 0 = устройство отсутствует
* 1 = жёсткий диск
* 2 = CD-привод
Например, в случае HD на IDE8 и CD на IDE10 здесь будет 48h.
* +12: 4 db: число найденных разделов на жёстких дисках с
соответственно IDE8,...,IDE11.
При отсутствии жёсткого диска на IDEx соответствующий байт При отсутствии жёсткого диска на IDEx соответствующий байт
нулевой, при наличии показывает число распознанных разделов, нулевой, при наличии показывает число распознанных разделов,
которых может и не быть (если носитель не отформатирован или которых может и не быть (если носитель не отформатирован или
если файловая система не поддерживается). В текущей версии ядра если файловая система не поддерживается). В текущей версии ядра
для жёстких дисков поддерживаются только FAT16, FAT32 и NTFS. для жёстких дисков поддерживаются только FAT12/16/32, NTFS,
* +6: 4 db: зарезервировано ext2/3/4 и XFS.
Замечания: Замечания:
* Короткая таблица может быть использована для получения информации * Таблица может быть использована для получения информации
об имеющихся устройствах. об имеющихся устройствах.
====================================================================== ======================================================================
@@ -1193,20 +1216,6 @@ dd 1675
соответствующую текущей стране иконку. соответствующую текущей стране иконку.
* Приложение @panel переключает раскладки по запросу пользователя. * Приложение @panel переключает раскладки по запросу пользователя.
======================================================================
=========== Функция 21, подфункция 3 - установить базу CD. ===========
======================================================================
Параметры:
* eax = 21 - номер функции
* ebx = 3 - номер подфункции
* ecx = база CD: 1=IDE0, 2=IDE1, 3=IDE2, 4=IDE3
Возвращаемое значение:
* eax = 0
Замечания:
* База CD используется функцией 24.
* Получить установленную базу CD можно вызовом
подфункции 3 функции 26.
====================================================================== ======================================================================
========= Функция 21, подфункция 5 - установить язык системы. ======== ========= Функция 21, подфункция 5 - установить язык системы. ========
====================================================================== ======================================================================
@@ -1254,122 +1263,6 @@ dd 1675
* Текущая реализация использует только младший бит ecx. * Текущая реализация использует только младший бит ecx.
* Получить текущее состояние можно вызовом подфункции 12 функции 26. * Получить текущее состояние можно вызовом подфункции 12 функции 26.
======================================================================
============= Функция 21, подфункция 13, подподфункция 1 =============
==== Инициализировать + получить информацию о драйвере vmode.mdr. ====
======================================================================
Параметры:
* eax = 21 - номер функции
* ebx = 13 - номер подфункции
* ecx = 1 - номер функции драйвера
* edx = указатель на буфер размера 512 байт
Возвращаемое значение:
* если драйвер не загружен (никогда не бывает в текущей реализации):
* eax = -1
* ebx, ecx разрушаются
* если драйвер загружен:
* eax = 'MDAZ' (в стиле fasm'а, т.е. 'M' - младший байт,
'Z' - старший) - сигнатура
* ebx = текущая частота развёртки (в Гц)
* ecx разрушается
* буфер, на который указывает edx, заполнен
Формат буфера:
* +0: 32*byte: имя драйвера, "Trans VideoDriver" (без кавычек,
дополнено пробелами)
* +32 = +0x20: dword: версия драйвера (версия x.y кодируется как
y*65536+x), для текущей реализации 1 (1.0)
* +36 = +0x24: 7*dword: зарезервировано (0 в текущей реализации)
* +64 = +0x40: 32*word: список поддерживаемых видеорежимов (каждое
слово - номер видеорежима, после собственно списка идут нули)
* +128 = +0x80: 32*(5*word): список поддерживаемых частот развёрток
для видеорежимов: для каждого видеорежима, указанного в предыдущем
поле, указано до 5 поддерживаемых частот
(в неиспользуемых позициях записаны нули)
Замечания:
* Функция инициализирует драйвер (если он ещё не инициализирован)
и должна вызываться первой, перед остальными (иначе они будут
возвращать -1, ничего не делая).
* В текущей реализации поддерживается только одна частота развёртки
на видеорежим.
======================================================================
============= Функция 21, подфункция 13, подподфункция 2 =============
============= Получить информацию о текущем видеорежиме. =============
======================================================================
Параметры:
* eax = 21 - номер функции
* ebx = 13 - номер подфункции
* ecx = 2 - номер функции драйвера
Возвращаемое значение:
* eax = -1 - драйвер не загружен или не инициализирован;
ebx,ecx разрушаются
* eax = [ширина]*65536 + [высота]
* ebx = частота вертикальной развёртки (в Гц)
* ecx = номер текущего видеорежима
Замечания:
* Драйвер предварительно должен быть инициализирован вызовом
функции драйвера 1.
* Если нужны только размеры экрана, целесообразней использовать
функцию 14 с учётом того, что она возвращает размеры на 1 меньше.
======================================================================
= Функция 21, подфункция 13, подподфункция 3 - установить видеорежим.
======================================================================
Параметры:
* eax = 21 - номер функции
* ebx = 13 - номер подфункции
* ecx = 3 - номер функции драйвера
* edx = [частота развёртки]*65536 + [номер видеорежима]
Возвращаемое значение:
* eax = -1 - драйвер не загружен, не инициализирован или
произошла ошибка
* eax = 0 - успешно
* ebx, ecx разрушаются
Замечания:
* Драйвер предварительно должен быть инициализирован вызовом
функции драйвера 1.
* Номер видеорежима и частота должны быть в таблице, возвращаемой
функцией драйвера 1.
======================================================================
============= Функция 21, подфункция 13, подподфункция 4 =============
================= Вернуться к начальному видеорежиму. ================
======================================================================
Возвращает экран в видеорежим, установленный при загрузке системы.
Параметры:
* eax = 21 - номер функции
* ebx = 13 - номер подфункции
* ecx = 4 - номер функции драйвера
Возвращаемое значение:
* eax = -1 - драйвер не загружен или не инициализирован
* eax = 0 - успешно
* ebx, ecx разрушаются
Замечания:
* Драйвер предварительно должен быть инициализирован вызовом
функции драйвера 1.
======================================================================
============= Функция 21, подфункция 13, подподфункция 5 =============
======== Увеличить/уменьшить размер видимой области монитора. ========
======================================================================
Параметры:
* eax = 21 - номер функции
* ebx = 13 - номер подфункции
* ecx = 5 - номер функции драйвера
* edx = 0/1 - уменьшить/увеличить размер по горизонтали
на одну позицию
* edx = 2/3 - в текущей реализации не поддерживается; планируется
как уменьшение/увеличение размера по вертикали на одну позицию
Возвращаемое значение:
* eax = -1 - драйвер не загружен или не инициализирован
* eax = 0 - успешно
* ebx, ecx разрушаются
Замечания:
* Драйвер предварительно должен быть инициализирован вызовом
функции драйвера 1.
* Функция влияет только на физический размер изображения
на мониторе; логический размер (число пикселей) не меняется.
====================================================================== ======================================================================
============ Функция 22 - установить системную дату/время. =========== ============ Функция 22 - установить системную дату/время. ===========
====================================================================== ======================================================================
@@ -1432,59 +1325,6 @@ dd 1675
с eax=0, если сложение ebx с текущим значением счётчика времени с eax=0, если сложение ebx с текущим значением счётчика времени
вызовет 32-битное переполнение. вызовет 32-битное переполнение.
======================================================================
======= Функция 24, подфункция 1 - начать проигрывать CD-audio. ======
======================================================================
Параметры:
* eax = 24 - номер функции
* ebx = 1 - номер подфункции
* ecx = 0x00FRSSMM, где
* MM = начальная минута
* SS = начальная секунда
* FR = начальный фрейм
Возвращаемое значение:
* eax = 0 - успешно
* eax = 1 - не определена база CD
Замечания:
* Предварительно нужно определить базовый порт CD вызовом
подфункции 3 функции 21.
* В секунде 75 фреймов, в минуте 60 секунд.
* Функция асинхронна (возвращает управление, когда началось
проигрывание).
======================================================================
===== Функция 24, подфункция 2 - получить информацию о дорожках. =====
======================================================================
Параметры:
* eax = 24 - номер функции
* ebx = 2 - номер подфункции
* ecx = указатель на буфер для таблицы
(максимум 8*64h+4 байт=100 дорожек)
Возвращаемое значение:
* eax = 0 - успешно
* eax = 1 - не определена база CD
Замечания:
* Формат таблицы с информацией о дорожках такой же, как и для
ATAPI-CD команды 43h (READ TOC), обычной таблицы (подкоманда 00h).
Адреса возвращаются в формате MSF.
* Предварительно нужно определить базовый порт CD вызовом
подфункции 3 функции 21.
* Функция возвращает информацию только о не более чем 100
первых дорожках. В большинстве случаев этого достаточно.
======================================================================
==== Функция 24, подфункция 3 - остановить проигрываемое CD-audio. ===
======================================================================
Параметры:
* eax = 24 - номер функции
* ebx = 1 - номер подфункции
Возвращаемое значение:
* eax = 0 - успешно
* eax = 1 - не определена база CD
Замечания:
* Предварительно нужно определить базовый порт CD вызовом
подфункции 3 функции 21.
====================================================================== ======================================================================
======= Функция 24, подфункция 4 - извлечь лоток привода диска. ====== ======= Функция 24, подфункция 4 - извлечь лоток привода диска. ======
====================================================================== ======================================================================
@@ -1587,18 +1427,6 @@ dd 1675
(используя описываемую функцию). (используя описываемую функцию).
* Приложение @panel переключает раскладки по запросу пользователя. * Приложение @panel переключает раскладки по запросу пользователя.
======================================================================
============ Функция 26, подфункция 3 - получить базу CD. ============
======================================================================
Параметры:
* eax = 26 - номер функции
* ebx = 3 - номер подфункции
Возвращаемое значение:
* eax = база CD: 1=IDE0, 2=IDE1, 3=IDE2, 4=IDE3
Замечания:
* База CD используется функцией 24.
* Установить базу CD можно вызовом подфункции 3 функции 21.
====================================================================== ======================================================================
========== Функция 26, подфункция 5 - получить язык системы. ========= ========== Функция 26, подфункция 5 - получить язык системы. =========
====================================================================== ======================================================================

View File

@@ -845,7 +845,7 @@ Parameters:
* eax = 18 - function number * eax = 18 - function number
* ebx = 11 - subfunction number * ebx = 11 - subfunction number
* ecx = type of the table: * ecx = type of the table:
* 1 = short version, 10 bytes * 1 = short version, 16 bytes
* edx = pointer to the buffer (in the application) for the table * edx = pointer to the buffer (in the application) for the table
Returned value: Returned value:
* function does not return value * function does not return value
@@ -861,25 +861,49 @@ Format of the table: short version:
* 5 = 2.88Mb, 3.5'' (such drives are not used anymore) * 5 = 2.88Mb, 3.5'' (such drives are not used anymore)
For example, for the standard configuration from one 1.44-drive For example, for the standard configuration from one 1.44-drive
here will be 40h, and for the case 1.2Mb on A: and 1.44Mb on B: here will be 40h, and for the case 1.2Mb on A: and 1.44Mb on B:
the value is 24h. the value is 24h.
First IDE controller:
* +1: byte: information about hard disks and CD-drives, AABBCCDD, * +1: byte: information about hard disks and CD-drives, AABBCCDD,
where AA corresponds to the controller IDE0, ..., DD - IDE3: where AA corresponds to the controller IDE0, ..., DD - IDE3:
* 0 = device is absent * 0 = device not found
* 1 = hard drive * 1 = hard drive
* 2 = CD-drive * 2 = CD-drive
For example, in the case HD on IDE0 and CD on IDE2 For example, in the case HD on IDE0 and CD on IDE2
this field contains 48h. this field contains 48h.
* +2: 4 db: number of the retrieved partitions on hard disks * +2: 4 db: number of the retrieved partitions on hard disks
at accordingly IDE0,...,IDE3. at accordingly IDE0,...,IDE3.
Second IDE controller:
* +6: byte: information about hard disks and CD-drives, AABBCCDD,
where AA corresponds to the controller IDE4, ..., DD - IDE7:
* 0 = device not found
* 1 = hard drive
* 2 = CD-drive
For example, in the case HD on IDE4 and CD on IDE6
this field contains 48h.
* +7: 4 db: number of the retrieved partitions on hard disks
at accordingly IDE4,...,IDE7.
Third IDE controller:
* +11: byte: information about hard disks and CD-drives, AABBCCDD,
where AA corresponds to the controller IDE8, ..., DD - IDE11:
* 0 = device not found
* 1 = hard drive
* 2 = CD-drive
For example, in the case HD on IDE8 and CD on IDE10
this field contains 48h.
* +12: 4 db: number of the retrieved partitions on hard disks
at accordingly IDE8,...,IDE11.
If the hard disk on IDEx is absent, appropriate byte is zero, If the hard disk on IDEx is absent, appropriate byte is zero,
otherwise it shows number of the recognized partitions, which otherwise it shows number of the recognized partitions, which
can be not presented (if the drive is not formatted or if can be not presented (if the drive is not formatted or if
the file system is not supported). Current version of the kernel the file system is not supported). Current version of the kernel
supports only FAT16, FAT32 and NTFS for hard disks. supports only FAT12/16/32, NTFS, ext2/3/4 and XFS for hard disks.
* +6: 4 db: reserved
Remarks: Remarks:
* The short table can be used for obtaining the information about * The table can be used for obtaining the information about
available devices. available devices.
====================================================================== ======================================================================
@@ -1193,19 +1217,6 @@ Remarks:
the corresponding icon. the corresponding icon.
* The application @panel switches layouts on user request. * The application @panel switches layouts on user request.
======================================================================
============== Function 21, subfunction 3 - set CD base. =============
======================================================================
Parameters:
* eax = 21 - function number
* ebx = 3 - subfunction number
* ecx = CD base: 1=IDE0, 2=IDE1, 3=IDE2, 4=IDE3
Returned value:
* eax = 0
Remarks:
* CD base is used by function 24.
* To get CD base use subfunction 3 of function 26.
====================================================================== ======================================================================
========== Function 21, subfunction 5 - set system language. ========= ========== Function 21, subfunction 5 - set system language. =========
====================================================================== ======================================================================
@@ -1251,120 +1262,6 @@ Remarks:
* The current implementation uses only low bit of ecx. * The current implementation uses only low bit of ecx.
* To get current status use subfunction 12 of function 26. * To get current status use subfunction 12 of function 26.
======================================================================
============ Function 21, subfunction 13, subsubfunction 1 ===========
======== Initialize + get information on the driver vmode.mdr. =======
======================================================================
Parameters:
* eax = 21 - function number
* ebx = 13 - subfunction number
* ecx = 1 - number of the driver function
* edx = pointer to 512-bytes buffer
Returned value:
* if driver is not loaded
(never happens in the current implementation):
* eax = -1
* ebx, ecx destroyed
* if driver is loaded:
* eax = 'MDAZ' (in fasm style, that is 'M' - low byte, 'Z' - high)
- signature
* ebx = current frequency of the scanning (in Hz)
* ecx destroyed
* buffer pointed to by edx is filled
Format of the buffer:
* +0: 32*byte: driver name, "Trans VideoDriver"
(without quotes, supplemented by spaces)
* +32 = +0x20: dword: driver version (version x.y is encoded as
y*65536+x), for the current implementation is 1 (1.0)
* +36 = +0x24: 7*dword: reserved (0 in the current implementation)
* +64 = +0x40: 32*word: list of supported videomodes (each word
is number of a videomode, after list itself there are zeroes)
* +128 = +0x80: 32*(5*word): list of supported frequences of the
scannings for videomodes: for each videomode listed in the
previous field up to 5 supported frequences are given
(unused positions contain zeroes)
Remarks:
* Function initializes the driver (if it is not initialized yet)
and must be called first, before others (otherwise they will do
nothing and return -1).
* The current implementation supports only one frequency
of the scanning on videomode.
======================================================================
============ Function 21, subfunction 13, subsubfunction 2 ===========
================ Get information on current videomode. ===============
======================================================================
Parameters:
* eax = 21 - function number
* ebx = 13 - subfunction number
* ecx = 2 - number of the driver function
Returned value:
* eax = -1 - driver is not loaded or not initialized;
ebx,ecx are destroyed
* eax = [width]*65536 + [height]
* ebx = frequency of the vertical scanning (in Hz)
* ecx = number of current videomode
Remarks:
* Driver must be initialized by call to
driver function 1.
* If only screen sizes are required, it is more expedient to use
function 14 taking into account that it
returns sizes on 1 less.
======================================================================
=== Function 21, subfunction 13, subsubfunction 3 - set videomode. ===
======================================================================
Parameters:
* eax = 21 - function number
* ebx = 13 - subfunction number
* ecx = 3 - number of the driver function
* edx = [scanning frequency]*65536 + [videomode number]
Returned value:
* eax = -1 - driver is not loaded, not initialized or
an error has occured
* eax = 0 - success
* ebx, ecx destroyed
Remarks:
* Driver must be initialized by driver function 1.
* The videomode number and frequency must be in the table
returned by driver function 1.
======================================================================
============ Function 21, subfunction 13, subsubfunction 4 ===========
================== Return to the initial videomode. ==================
======================================================================
Returns the screen to the videomode set at system boot.
Parameters:
* eax = 21 - function number
* ebx = 13 - subfunction number
* ecx = 4 - number of the driver function
Returned value:
* eax = -1 - driver is not loaded or not initialized
* eax = 0 - success
* ebx, ecx destroyed
Remarks:
* Driver must be initialized by call to driver function 1.
======================================================================
============ Function 21, subfunction 13, subsubfunction 5 ===========
===== Increase/decrease the size of the visible area of monitor. =====
======================================================================
Parameters:
* eax = 21 - function number
* ebx = 13 - subfunction number
* ecx = 5 - number of the driver function
* edx = 0/1 - decrease/increase horizontal size on 1 position
* edx = 2/3 - is not supported in the current implementation;
is planned as decrease/increase vertical size on 1 position
Returned value:
* eax = -1 - driver is not loaded or not initialized
* eax = 0 - success
* ebx, ecx destroyed
Remarks:
* Driver must be initialized by call to driver function 1.
* Function influences only the physical size of the screen image;
the logical size (number of pixels) does not change.
====================================================================== ======================================================================
================= Function 22 - set system date/time. ================ ================= Function 22 - set system date/time. ================
====================================================================== ======================================================================
@@ -1426,58 +1323,6 @@ Remarks:
if the addition of ebx with the current value of time counter if the addition of ebx with the current value of time counter
makes 32-bit overflow. makes 32-bit overflow.
======================================================================
======== Function 24, subfunction 1 - begin to play CD-audio. ========
======================================================================
Parameters:
* eax = 24 - function number
* ebx = 1 - subfunction number
* ecx = 0x00FRSSMM, where
* MM = starting minute
* SS = starting second
* FR = starting frame
Returned value:
* eax = 0 - success
* eax = 1 - CD base is not defined
Remarks:
* Previously CD base must be defined by the call to
subfunction 3 of function 21.
* One second includes 75 frames, one minute includes 60 seconds.
* The function is asynchronous (returns control, when play begins).
======================================================================
======= Function 24, subfunction 2 - get information on tracks. ======
======================================================================
Parameters:
* eax = 24 - function number
* ebx = 2 - subfunction number
* ecx = pointer to the buffer for the table
(maximum 8*64h+4 bytes=100 tracks)
Returned value:
* eax = 0 - success
* eax = 1 - CD base is not defined
Remarks:
* The format of the table with tracks information is the same as
for ATAPI-CD command 43h (READ TOC), usual table (subcommand 00h).
Function returns addresses in MSF.
* Previously CD base port must be set by call to
subfunction 3 of function 21.
* Function returns information only about no more than 100
first tracks. In most cases it is enough.
======================================================================
========== Function 24, subfunction 3 - stop play CD-audio. ==========
======================================================================
Parameters:
* eax = 24 - function number
* ebx = 1 - subfunction number
Returned value:
* eax = 0 - success
* eax = 1 - CD base is not defined
Remarks:
* Previously CD base port must be defined by call to
subfunction 3 of function 21.
====================================================================== ======================================================================
======= Function 24, subfunction 4 - eject tray of disk drive. ======= ======= Function 24, subfunction 4 - eject tray of disk drive. =======
====================================================================== ======================================================================
@@ -1577,18 +1422,6 @@ Remarks:
the corresponding icon (using this function). the corresponding icon (using this function).
* The application @panel switches layouts on user request. * The application @panel switches layouts on user request.
======================================================================
============== Function 26, subfunction 3 - get CD base. =============
======================================================================
Parameters:
* eax = 26 - function number
* ebx = 3 - subfunction number
Returned value:
* eax = CD base: 1=IDE0, 2=IDE1, 3=IDE2, 4=IDE3
Remarks:
* CD base is used by function 24.
* To set CD base use subfunction 3 of function 21.
====================================================================== ======================================================================
========== Function 26, subfunction 5 - get system language. ========= ========== Function 26, subfunction 5 - get system language. =========
====================================================================== ======================================================================

View File

@@ -43,6 +43,30 @@ rootdirs:
db 3,'cd3' db 3,'cd3'
dd fs_OnCd3 dd fs_OnCd3
dd fs_NextCd dd fs_NextCd
db 3,'cd4'
dd fs_OnCd4
dd fs_NextCd
db 3,'cd5'
dd fs_OnCd5
dd fs_NextCd
db 3,'cd6'
dd fs_OnCd6
dd fs_NextCd
db 3,'cd7'
dd fs_OnCd7
dd fs_NextCd
db 3,'cd8'
dd fs_OnCd8
dd fs_NextCd
db 3,'cd9'
dd fs_OnCd9
dd fs_NextCd
db 4,'cd10'
dd fs_OnCd10
dd fs_NextCd
db 4,'cd11'
dd fs_OnCd11
dd fs_NextCd
;*********************************************** ;***********************************************
db 0 db 0
@@ -57,6 +81,22 @@ virtual_root_query:
db 'cd2',0 db 'cd2',0
dd fs_HasCd3 dd fs_HasCd3
db 'cd3',0 db 'cd3',0
dd fs_HasCd4
db 'cd4',0
dd fs_HasCd5
db 'cd5',0
dd fs_HasCd6
db 'cd6',0
dd fs_HasCd7
db 'cd7',0
dd fs_HasCd8
db 'cd8',0
dd fs_HasCd9
db 'cd9',0
dd fs_HasCd10
db 'cd10',0
dd fs_HasCd11
db 'cd11',0
;********************************************** ;**********************************************
dd 0 dd 0
endg endg
@@ -149,8 +189,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] ;the number of blocks to read
mov edx, [ebx+16] ;куда записывать рузельтат mov edx, [ebx+16] ;where to write the result
; 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
@@ -404,8 +444,7 @@ file_system_lfn:
fs_NotImplemented: fs_NotImplemented:
mov eax, 2 mov eax, 2
ret ret
;-----------------------------------------------------------------------------
;*******************************************************
fs_OnCd0: fs_OnCd0:
call reserve_cd call reserve_cd
mov [ChannelNumber], 1 mov [ChannelNumber], 1
@@ -413,6 +452,7 @@ fs_OnCd0:
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
@@ -420,6 +460,7 @@ fs_OnCd1:
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
@@ -427,22 +468,96 @@ fs_OnCd2:
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
jmp fs_OnCd
;-----------------------------------------------------------------------------
fs_OnCd4:
call reserve_cd
mov [ChannelNumber], 1
mov [DiskNumber], 0
push 6
push 5
jmp fs_OnCd
;-----------------------------------------------------------------------------
fs_OnCd5:
call reserve_cd
mov [ChannelNumber], 1
mov [DiskNumber], 1
push 4
push 6
jmp fs_OnCd
;-----------------------------------------------------------------------------
fs_OnCd6:
call reserve_cd
mov [ChannelNumber], 2
mov [DiskNumber], 0
push 2
push 7
jmp fs_OnCd
;-----------------------------------------------------------------------------
fs_OnCd7:
call reserve_cd
mov [ChannelNumber], 2
mov [DiskNumber], 1
push 0
push 8
jmp fs_OnCd
;-----------------------------------------------------------------------------
fs_OnCd8:
call reserve_cd
mov [ChannelNumber], 1
mov [DiskNumber], 0
push 6
push 9
jmp fs_OnCd
;-----------------------------------------------------------------------------
fs_OnCd9:
call reserve_cd
mov [ChannelNumber], 1
mov [DiskNumber], 1
push 4
push 10
jmp fs_OnCd
;-----------------------------------------------------------------------------
fs_OnCd10:
call reserve_cd
mov [ChannelNumber], 2
mov [DiskNumber], 0
push 2
push 11
jmp fs_OnCd
;-----------------------------------------------------------------------------
fs_OnCd11:
call reserve_cd
mov [ChannelNumber], 2
mov [DiskNumber], 1
push 0
push 12
;-----------------------------------------------------------------------------
fs_OnCd: fs_OnCd:
call reserve_cd_channel
pop eax pop eax
mov [cdpos], eax mov [cdpos], eax
call reserve_cd_channel
pop eax pop eax
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]
push eax
mov eax, [cdpos]
dec eax
shr eax, 2
lea eax, [eax*5]
mov bl, [eax+DRIVE_DATA+1]
pop eax
shr bl, cl shr bl, cl
test bl, 2 test bl, 2
pop ebx ecx pop ebx ecx
@@ -472,7 +587,7 @@ fs_OnCd:
and [cd_status], 0 and [cd_status], 0
mov dword [image_of_eax], 2 ; not implemented mov dword [image_of_eax], 2 ; not implemented
ret ret
;-----------------------------------------------------------------------------
fs_CdServices: fs_CdServices:
dd fs_CdRead dd fs_CdRead
dd fs_CdReadFolder dd fs_CdReadFolder
@@ -485,32 +600,74 @@ fs_CdServices:
dd fs_NotImplemented dd fs_NotImplemented
dd fs_NotImplemented dd fs_NotImplemented
fs_NumCdServices = ($ - fs_CdServices)/4 fs_NumCdServices = ($ - fs_CdServices)/4
;-----------------------------------------------------------------------------
;*******************************************************
fs_HasCd0: fs_HasCd0:
test byte [DRIVE_DATA+1], 10000000b test byte [DRIVE_DATA+1], 10000000b
setnz al setnz al
ret ret
;--------------------------------------
fs_HasCd1: fs_HasCd1:
test byte [DRIVE_DATA+1], 00100000b test byte [DRIVE_DATA+1], 00100000b
setnz al setnz al
ret ret
;--------------------------------------
fs_HasCd2: fs_HasCd2:
test byte [DRIVE_DATA+1], 00001000b test byte [DRIVE_DATA+1], 00001000b
setnz al setnz al
ret ret
;--------------------------------------
fs_HasCd3: fs_HasCd3:
test byte [DRIVE_DATA+1], 00000010b test byte [DRIVE_DATA+1], 00000010b
setnz al setnz al
ret ret
;******************************************************* ;--------------------------------------
fs_HasCd4:
test byte [DRIVE_DATA+6], 10000000b
setnz al
ret
;--------------------------------------
fs_HasCd5:
test byte [DRIVE_DATA+6], 00100000b
setnz al
ret
;--------------------------------------
fs_HasCd6:
test byte [DRIVE_DATA+6], 00001000b
setnz al
ret
;--------------------------------------
fs_HasCd7:
test byte [DRIVE_DATA+6], 00000010b
setnz al
ret
;--------------------------------------
fs_HasCd8:
test byte [DRIVE_DATA+11], 10000000b
setnz al
ret
;--------------------------------------
fs_HasCd9:
test byte [DRIVE_DATA+11], 00100000b
setnz al
ret
;--------------------------------------
fs_HasCd10:
test byte [DRIVE_DATA+11], 00001000b
setnz al
ret
;--------------------------------------
fs_HasCd11:
test byte [DRIVE_DATA+11], 00000010b
setnz al
ret
;-----------------------------------------------------------------------------
;
; fs_NextXXX functions: ; fs_NextXXX functions:
; in: eax = partition number, from which start to scan ; in: eax = partition number, from which start to scan
; out: CF=1 => no more partitions ; out: CF=1 => no more partitions
; CF=0 => eax=next partition number ; CF=0 => eax=next partition number
;
;******************************************************* ;-----------------------------------------------------------------------------
fs_NextCd: fs_NextCd:
; we always have /cdX/1 ; we always have /cdX/1
test eax, eax test eax, eax
@@ -520,8 +677,6 @@ fs_NextCd:
clc clc
@@: @@:
ret ret
;*******************************************************
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
process_replace_file_name: process_replace_file_name:
; in ; in

View File

@@ -7,18 +7,15 @@
$Revision$ $Revision$
;-----------------------------------------------------------------------------
uglobal uglobal
cd_current_pointer_of_input dd 0 cd_current_pointer_of_input dd 0
cd_current_pointer_of_input_2 dd 0 cd_current_pointer_of_input_2 dd 0
cd_mem_location dd 0 cd_mem_location dd 0
cd_counter_block dd 0 cd_counter_block dd 0
IDE_Channel_1 db 0
IDE_Channel_2 db 0
endg endg
;-----------------------------------------------------------------------------
reserve_cd: reserve_cd:
cli cli
cmp [cd_status], 0 cmp [cd_status], 0
je reserve_ok2 je reserve_ok2
@@ -26,9 +23,8 @@ reserve_cd:
sti sti
call change_task call change_task
jmp reserve_cd jmp reserve_cd
;-----------------------------------------------------------------------------
reserve_ok2: reserve_ok2:
push eax push eax
mov eax, [CURRENT_TASK] mov eax, [CURRENT_TASK]
shl eax, 5 shl eax, 5
@@ -37,48 +33,105 @@ reserve_cd:
pop eax pop eax
sti sti
ret ret
;-----------------------------------------------------------------------------
reserve_cd_channel: reserve_cd_channel:
cmp [ChannelNumber], 1
jne .IDE_Channel_2
.IDE_Channel_1:
pushad pushad
mov ecx, ide_channel1_mutex mov eax, [cdpos]
call mutex_lock dec eax
mov [IDE_Channel_1], 1 shr eax, 2
popad
ret
.IDE_Channel_2:
pushad
mov ecx, ide_channel2_mutex
call mutex_lock
mov [IDE_Channel_2], 1
popad
ret
test eax, eax
jnz .1
cmp [ChannelNumber], 1
jne @f
mov ecx, ide_channel1_mutex
jmp .mutex_lock
;--------------------------------------
@@:
mov ecx, ide_channel2_mutex
jmp .mutex_lock
;--------------------------------------
.1:
dec eax
jnz .2
cmp [ChannelNumber], 1
jne @f
mov ecx, ide_channel3_mutex
jmp .mutex_lock
;--------------------------------------
@@:
mov ecx, ide_channel4_mutex
jmp .mutex_lock
;--------------------------------------
.2:
cmp [ChannelNumber], 1
jne @f
mov ecx, ide_channel5_mutex
jmp .mutex_lock
;--------------------------------------
@@:
mov ecx, ide_channel6_mutex
.mutex_lock:
call mutex_lock
popad
ret
;-----------------------------------------------------------------------------
free_cd_channel: free_cd_channel:
cmp [ChannelNumber], 1
jne .IDE_Channel_2
.IDE_Channel_1:
mov [IDE_Channel_1], 0
pushad pushad
mov ecx, ide_channel1_mutex mov eax, [cdpos]
call mutex_unlock dec eax
popad shr eax, 2
ret
.IDE_Channel_2:
mov [IDE_Channel_2], 0
pushad
mov ecx, ide_channel2_mutex
call mutex_unlock
popad
ret
test eax, eax
jnz .1
cmp [ChannelNumber], 1
jne @f
mov ecx, ide_channel1_mutex
jmp .mutex_unlock
;--------------------------------------
@@:
mov ecx, ide_channel2_mutex
jmp .mutex_unlock
;--------------------------------------
.1:
dec eax
jnz .2
cmp [ChannelNumber], 1
jne @f
mov ecx, ide_channel3_mutex
jmp .mutex_unlock
;--------------------------------------
@@:
mov ecx, ide_channel4_mutex
jmp .mutex_unlock
;--------------------------------------
.2:
cmp [ChannelNumber], 1
jne @f
mov ecx, ide_channel5_mutex
jmp .mutex_unlock
;--------------------------------------
@@:
mov ecx, ide_channel6_mutex
.mutex_unlock:
call mutex_unlock
popad
ret
;-----------------------------------------------------------------------------
uglobal uglobal
cd_status dd 0 cd_status dd 0
endg endg
;-----------------------------------------------------------------------------
;----------------------------------------------------------------
; ;
; fs_CdRead - LFN variant for reading CD disk ; fs_CdRead - LFN variant for reading CD disk
; ;
@@ -91,91 +144,114 @@ endg
; ret ebx = bytes read or 0xffffffff file not found ; ret ebx = bytes read or 0xffffffff file not found
; eax = 0 ok read or other = errormsg ; eax = 0 ok read or other = errormsg
; ;
;-------------------------------------------------------------- ;-----------------------------------------------------------------------------
fs_CdRead: fs_CdRead:
push edi push edi
cmp byte [esi], 0 cmp byte [esi], 0
jnz @f jnz @f
;--------------------------------------
.noaccess: .noaccess:
pop edi pop edi
;--------------------------------------
.noaccess_2: .noaccess_2:
or ebx, -1 or ebx, -1
mov eax, ERROR_ACCESS_DENIED mov eax, ERROR_ACCESS_DENIED
ret ret
;--------------------------------------
.noaccess_3: .noaccess_3:
pop eax edx ecx edi pop eax edx ecx edi
jmp .noaccess_2 jmp .noaccess_2
;--------------------------------------
@@: @@:
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
cmp dword [ebx+4], 0 cmp dword [ebx+4], 0
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
;--------------------------------------
@@: @@:
mov ebx, [ebx] mov ebx, [ebx]
;--------------------------------------
.l1: .l1:
push ecx edx push ecx edx
push 0 push 0
mov eax, [edi+10] ; реальный размер файловой секции mov eax, [edi+10] ; real size of the file section
sub eax, ebx sub eax, ebx
jb .eof jb .eof
cmp eax, ecx cmp eax, ecx
jae @f jae @f
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
jz .done jz .done
sub ebx, 2048 sub ebx, 2048
jae .next jae .next
add ebx, 2048 add ebx, 2048
jnz .incomplete_sector jnz .incomplete_sector
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; читаем сектор файла call ReadCDWRetr ; read sector of file
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne .noaccess_3 jne .noaccess_3
add edx, 2048 add edx, 2048
sub ecx, 2048 sub ecx, 2048
;--------------------------------------
.next: .next:
inc dword [CDSectorAddress] inc dword [CDSectorAddress]
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; читаем сектор файла call ReadCDWRetr ; read sector of file
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne .noaccess_3 jne .noaccess_3
push ecx push ecx
add ecx, ebx add ecx, ebx
cmp ecx, 2048 cmp ecx, 2048
jbe @f jbe @f
mov ecx, 2048 mov ecx, 2048
;--------------------------------------
@@: @@:
sub ecx, ebx sub ecx, ebx
push edi esi ecx push edi esi ecx
@@ -189,19 +265,19 @@ fs_CdRead:
pop ecx pop ecx
xor ebx, ebx xor ebx, ebx
jmp .next jmp .next
;--------------------------------------
.done: .done:
mov ebx, edx mov ebx, edx
pop eax edx ecx edi pop eax edx ecx edi
sub ebx, edx sub ebx, edx
ret ret
;--------------------------------------
.eof: .eof:
mov ebx, edx mov ebx, edx
pop eax edx ecx pop eax edx ecx
sub ebx, edx sub ebx, edx
jmp .reteof jmp .reteof
;-----------------------------------------------------------------------------
;----------------------------------------------------------------
; ;
; fs_CdReadFolder - LFN variant for reading CD disk folder ; fs_CdReadFolder - LFN variant for reading CD disk folder
; ;
@@ -215,30 +291,37 @@ fs_CdRead:
; ret ebx = blocks read or 0xffffffff folder not found ; ret ebx = blocks read or 0xffffffff folder not found
; eax = 0 ok read or other = errormsg ; eax = 0 ok read or other = errormsg
; ;
;-------------------------------------------------------------- ;-----------------------------------------------------------------------------
fs_CdReadFolder: fs_CdReadFolder:
push edi push edi
call cd_find_lfn call cd_find_lfn
jnc .found jnc .found
pop edi pop edi
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne .noaccess_1 jne .noaccess_1
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 .found_dir jnz .found_dir
pop edi pop edi
;--------------------------------------
.noaccess_1: .noaccess_1:
or ebx, -1 or ebx, -1
mov eax, ERROR_ACCESS_DENIED mov eax, ERROR_ACCESS_DENIED
ret ret
;--------------------------------------
.found_dir: .found_dir:
mov eax, [edi+2] ; eax=cluster mov eax, [edi+2] ; eax=cluster
mov [CDSectorAddress], eax mov [CDSectorAddress], eax
mov eax, [edi+10] ; размер директрории mov eax, [edi+10] ; directory size
;--------------------------------------
.doit: .doit:
; init header ; init header
push eax ecx push eax ecx
@@ -250,21 +333,23 @@ fs_CdReadFolder:
mov byte [edx], 1 ; version mov byte [edx], 1 ; version
mov [cd_mem_location], edx mov [cd_mem_location], edx
add [cd_mem_location], 32 add [cd_mem_location], 32
; начинаем переброску БДВК в УСВК
;.mainloop: ;.mainloop:
mov [cd_counter_block], dword 0 mov [cd_counter_block], dword 0
dec dword [CDSectorAddress] dec dword [CDSectorAddress]
push ecx push ecx
;--------------------------------------
.read_to_buffer: .read_to_buffer:
inc dword [CDSectorAddress] inc dword [CDSectorAddress]
mov [CDDataBuf_pointer], CDDataBuf mov [CDDataBuf_pointer], CDDataBuf
call ReadCDWRetr ; читаем сектор директории call ReadCDWRetr ; read sector of directory
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
; директория закончилась? ; directory is over?
ja .read_to_buffer ja .read_to_buffer
mov edi, [cd_counter_block] mov edi, [cd_counter_block]
mov [edx+8], edi mov [edx+8], edi
mov edi, [ebx] mov edi, [ebx]
@@ -272,24 +357,30 @@ fs_CdReadFolder:
xor eax, eax xor eax, eax
dec ecx dec ecx
js @f js @f
mov al, ERROR_END_OF_FILE mov al, ERROR_END_OF_FILE
;--------------------------------------
@@: @@:
pop ecx edi pop ecx edi
mov ebx, [edx+4] mov ebx, [edx+4]
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
@@ -298,189 +389,209 @@ fs_CdReadFolder:
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 ;--------------------------------------
.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
; проверка конца файла ; check end of file
mov ax, [esi] mov ax, [esi]
cmp ax, word 3B00h; сепаратор конца файла ';' cmp ax, word 3B00h ; separator end of file ';'
je .cd_get_parameters_of_file_1 je .cd_get_parameters_of_file_1
; проверка для файлов не заканчивающихся сепаратором ; check for files not ending with separator
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
; проверка конца папки ; check the end of the directory
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
; проверка конца файла ; check end of file
mov ax, [esi] mov ax, [esi]
cmp ax, word 3B00h; сепаратор конца файла ';' cmp ax, word 3B00h; separator end of file ';'
je .cd_get_parameters_of_file_2 je .cd_get_parameters_of_file_2
; проверка для файлов не заканчивающихся сепаратором ; check for files not ending with separator
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
; проверка конца папки ; check the end of the directory
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:
pop edx edi esi eax pop edx edi esi eax
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:
; получаем атрибуты файла ; get file attributes
xor eax, eax xor eax, eax
; файл не архивировался ; file is not archived
inc eax inc eax
shl eax, 1 shl eax, 1
; это каталог? ; is a directory?
test [ebp-8], byte 2 test [ebp-8], byte 2
jz .file jz .file
inc eax inc eax
;--------------------------------------
.file: .file:
; метка тома не как в FAT, в этом виде отсутсвует ; not as a volume label in the FAT, in this form not available
; файл не является системным ; file is not a system
shl eax, 3 shl eax, 3
; файл является скрытым? (атрибут существование) ; file is hidden? (attribute of existence)
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
; файл всегда только для чтения, так как это CD ; file is always read-only, as this CD
inc eax inc eax
mov [edi], eax mov [edi], eax
; получаем время для файла ; get the time to file
;час ; hour
movzx eax, byte [ebp-12] movzx eax, byte [ebp-12]
shl eax, 8 shl eax, 8
;минута ; minute
mov al, [ebp-11] mov al, [ebp-11]
shl eax, 8 shl eax, 8
;секунда ; second
mov al, [ebp-10] mov al, [ebp-10]
;время создания файла ; file creation time
mov [edi+8], eax mov [edi+8], eax
;время последнего доступа ; last access time
mov [edi+16], eax mov [edi+16], eax
;время последней записи ; last write time
mov [edi+24], eax mov [edi+24], eax
; получаем дату для файла ; get date for file
;год ; year
movzx eax, byte [ebp-15] movzx eax, byte [ebp-15]
add eax, 1900 add eax, 1900
shl eax, 8 shl eax, 8
;месяц ; month
mov al, [ebp-14] mov al, [ebp-14]
shl eax, 8 shl eax, 8
;день ; day
mov al, [ebp-13] mov al, [ebp-13]
;дата создания файла ; file creation date
mov [edi+12], eax mov [edi+12], eax
;время последнего доступа ; last access date
mov [edi+20], eax mov [edi+20], eax
;время последней записи ; last write date
mov [edi+28], eax mov [edi+28], eax
; получаем тип данных имени ; get the data type of name
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
;--------------------------------------
@@: @@:
; получаем размер файла в байтах ; get the file size in bytes
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
;-----------------------------------------------------------------------------
;----------------------------------------------------------------
; ;
; fs_CdGetFileInfo - LFN variant for CD ; fs_CdGetFileInfo - LFN variant for CD
; get file/directory attributes structure ; get file/directory attributes structure
; ;
;---------------------------------------------------------------- ;-----------------------------------------------------------------------------
fs_CdGetFileInfo: fs_CdGetFileInfo:
cmp byte [esi], 0 cmp byte [esi], 0
jnz @f jnz @f
mov eax, 2 mov eax, 2
ret ret
;--------------------------------------
@@: @@:
push edi push edi
call cd_find_lfn call cd_find_lfn
pushfd pushfd
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jz @f jz @f
popfd popfd
pop edi pop edi
mov eax, 11 mov eax, 11
ret ret
;--------------------------------------
@@: @@:
popfd popfd
jnc @f jnc @f
pop edi pop edi
mov eax, ERROR_FILE_NOT_FOUND mov eax, ERROR_FILE_NOT_FOUND
ret ret
;--------------------------------------
@@: @@:
mov edi, edx mov edi, edx
@@ -493,32 +604,31 @@ fs_CdGetFileInfo:
pop edi pop edi
xor eax, eax xor eax, eax
ret ret
;-----------------------------------------------------------------------------
;----------------------------------------------------------------
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
push eax esi push eax esi
; 16 сектор начало набора дескрипторов томов ; Sector 16 - start set of volume descriptors
call WaitUnitReady call WaitUnitReady
cmp [DevErrorCode], 0 cmp [DevErrorCode], 0
jne .access_denied jne .access_denied
call prevent_medium_removal call prevent_medium_removal
; тестовое чтение ; testing of reading
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
; вычисление последней сессии ; calculation of the last session
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]
@@ -529,7 +639,7 @@ cd_find_lfn:
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
@@ -537,111 +647,128 @@ cd_find_lfn:
jne .access_denied jne .access_denied
.start_check: .start_check:
; проверка на вшивость ; checking for "lice"
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
; сектор является терминатором набор дескрипторов томов? ; sector is the terminator of set of descriptors volumes?
cmp [CDDataBuf], byte 0xff cmp [CDDataBuf], byte 0xff
je .access_denied je .access_denied
; сектор является дополнительным и улучшенным дескриптором тома? ; sector is an additional and improved descriptor of volume?
cmp [CDDataBuf], byte 0x2 cmp [CDDataBuf], byte 0x2
jne .start jne .start
; сектор является дополнительным дескриптором тома? ; sector is an additional descriptor of volume?
cmp [CDDataBuf+6], byte 0x1 cmp [CDDataBuf+6], byte 0x1
jne .start jne .start
; параметры root директрории ; parameters of root directory
mov eax, [CDDataBuf+0x9c+2]; начало root директрории mov eax, [CDDataBuf+0x9c+2]; start of root directory
mov [CDSectorAddress], eax mov [CDSectorAddress], eax
mov eax, [CDDataBuf+0x9c+10]; размер root директрории mov eax, [CDDataBuf+0x9c+10]; size of root directory
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
;--------------------------------------
@@: @@:
; начинаем поиск ; start the search
.mainloop: .mainloop:
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 ; читаем сектор директории call ReadCDWRetr ; read sector of directory
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
; директория закончилась? ; directory is over?
cmp eax, 0 cmp eax, 0
ja .read_to_buffer ja .read_to_buffer
; нет искомого элемента цепочки ; desired element of chain is not found
.access_denied: .access_denied:
pop esi eax pop esi eax
mov [cd_appl_data], 1 mov [cd_appl_data], 1
stc stc
ret ret
; искомый элемент цепочки найден ;--------------------------------------
.found: ; desired element of chain found
; конец пути файла .found:
; the end of the file path
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] ; начало директории pop dword [CDSectorAddress] ; beginning of the directory
mov eax, [eax+2+8]; размер директории mov eax, [eax+2+8] ; size of directory
jmp .mainloop jmp .mainloop
; указатель файла найден ;--------------------------------------
.done: ; file pointer found
.done:
test ebp, ebp test ebp, ebp
jz @f jz @f
mov esi, ebp mov esi, ebp
xor ebp, ebp xor ebp, ebp
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
call cd_compare_name call cd_compare_name
jc .start jc .start
;--------------------------------------
.found: .found:
clc clc
ret ret
;--------------------------------------
.not_found: .not_found:
stc stc
ret ret
;-----------------------------------------------------------------------------
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 ; входы закончились? test eax, eax ; entry's is over?
jz .next_sector jz .next_sector
cmp ebp, CDDataBuf+2048 ; буфер закончился?
cmp ebp, CDDataBuf+2048 ; buffer is over?
jae .next_sector jae .next_sector
movzx eax, byte [ebp] movzx eax, byte [ebp]
add [cd_current_pointer_of_input_2], eax; следующий вход каталога add [cd_current_pointer_of_input_2], eax ; next entry of directory
add ebp, 33; указатель установлен на начало имени add ebp, 33; pointer is set to the beginning of the name
pop eax pop eax
clc clc
ret ret
;--------------------------------------
.next_sector: .next_sector:
pop eax pop eax
stc stc
ret ret
;-----------------------------------------------------------------------------
cd_compare_name: cd_compare_name:
; compares ASCIIZ-names, case-insensitive (cp866 encoding) ; compares ASCIIZ-names, case-insensitive (cp866 encoding)
; in: esi->name, ebp->name ; in: esi->name, ebp->name
@@ -650,6 +777,7 @@ cd_compare_name:
; destroys eax ; destroys eax
push esi eax edi push esi eax edi
mov edi, ebp mov edi, ebp
;--------------------------------------
.loop: .loop:
cld cld
lodsb lodsb
@@ -666,94 +794,118 @@ cd_compare_name:
sub edi, 2 sub edi, 2
scasw scasw
jne .name_not_coincide jne .name_not_coincide
;--------------------------------------
.coincides: .coincides:
cmp [esi], byte '/'; разделитель пути, конец имени текущего элемента cmp [esi], byte '/' ; path separator is end of current element
je .done je .done
cmp [esi], byte 0; разделитель пути, конец имени текущего элемента
cmp [esi], byte 0 ; path separator end of name
je .done je .done
jmp .loop jmp .loop
;--------------------------------------
.name_not_coincide: .name_not_coincide:
pop edi eax esi pop edi eax esi
stc stc
ret ret
;--------------------------------------
.done: .done:
; проверка конца файла ; check end of file
cmp [edi], word 3B00h; сепаратор конца файла ';' cmp [edi], word 3B00h; separator end of file ';'
je .done_1 je .done_1
; проверка для файлов не заканчивающихся сепаратором ; check for files not ending with separator
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
; проверка конца папки ; check the end of directory
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
;-----------------------------------------------------------------------------
char_todown: char_todown:
; convert character to uppercase, using cp866 encoding ; convert character to uppercase, using cp866 encoding
; in: al=symbol ; in: al=symbol
; out: al=converted symbol ; out: al=converted symbol
cmp al, 'A' cmp al, 'A'
jb .ret jb .ret
cmp al, 'Z' cmp al, 'Z'
jbe .az jbe .az
cmp al, 0x80 ; 'А' cmp al, 0x80 ; 'А'
jb .ret jb .ret
cmp al, 0x90 ; 'Р' cmp al, 0x90 ; 'Р'
jb .rus1 jb .rus1
cmp al, 0x9F ; 'Я' cmp al, 0x9F ; 'Я'
ja .ret ja .ret
; 0x90-0x9F -> 0xE0-0xEF ; 0x90-0x9F -> 0xE0-0xEF
add al, 0xE0-0x90 add al, 0xE0-0x90
;--------------------------------------
.ret: .ret:
ret ret
;--------------------------------------
.rus1: .rus1:
; 0x80-0x8F -> 0xA0-0xAF ; 0x80-0x8F -> 0xA0-0xAF
.az: .az:
add al, 0x20 add al, 0x20
ret ret
;-----------------------------------------------------------------------------
uni2ansi_char: uni2ansi_char:
; convert UNICODE character in al to ANSI character in ax, using cp866 encoding ; convert UNICODE character in al to ANSI character in ax, using cp866 encoding
; in: ax=UNICODE character ; in: ax=UNICODE character
; out: al=converted ANSI character ; out: al=converted ANSI character
cmp ax, 0x80 cmp ax, 0x80
jb .ascii jb .ascii
cmp ax, 0x401 cmp ax, 0x401
jz .yo1 jz .yo1
cmp ax, 0x451 cmp ax, 0x451
jz .yo2 jz .yo2
cmp ax, 0x410 cmp ax, 0x410
jb .unk jb .unk
cmp ax, 0x440 cmp ax, 0x440
jb .rus1 jb .rus1
cmp ax, 0x450 cmp ax, 0x450
jb .rus2 jb .rus2
;--------------------------------------
.unk: .unk:
mov al, '_' mov al, '_'
jmp .doit jmp .doit
;--------------------------------------
.yo1: .yo1:
mov al, 0xF0 ; 'Ё' in cp866 mov al, 0xF0 ; 'Ё' in cp866
jmp .doit jmp .doit
;--------------------------------------
.yo2: .yo2:
mov al, 0xF1 ; 'ё' in cp866 mov al, 0xF1 ; 'ё' in cp866
jmp .doit jmp .doit
;--------------------------------------
.rus1: .rus1:
; 0x410-0x43F -> 0x80-0xAF ; 0x410-0x43F -> 0x80-0xAF
add al, 0x70 add al, 0x70
jmp .doit jmp .doit
;--------------------------------------
.rus2: .rus2:
; 0x440-0x44F -> 0xE0-0xEF ; 0x440-0x44F -> 0xE0-0xEF
add al, 0xA0 add al, 0xA0
;--------------------------------------
.ascii: .ascii:
.doit: .doit:
ret ret
;-----------------------------------------------------------------------------

View File

@@ -369,6 +369,14 @@ high_code:
call mutex_init call mutex_init
mov ecx, ide_channel2_mutex mov ecx, ide_channel2_mutex
call mutex_init call mutex_init
mov ecx, ide_channel3_mutex
call mutex_init
mov ecx, ide_channel4_mutex
call mutex_init
mov ecx, ide_channel5_mutex
call mutex_init
mov ecx, ide_channel6_mutex
call mutex_init
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
; SAVE REAL MODE VARIABLES ; SAVE REAL MODE VARIABLES
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
@@ -1504,266 +1512,231 @@ draw_num_text:
mov eax, [esp+64+8] ; background color (if given) mov eax, [esp+64+8] ; background color (if given)
mov edi, [esp+64+4] mov edi, [esp+64+4]
jmp dtext jmp dtext
;-----------------------------------------------------------------------------
align 4
sys_setup:
; 1=roland mpu midi base , base io address
; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus
; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave
; 5=system language, 1eng 2fi 3ger 4rus
; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave
; 8=fat32 partition in hd
; 9
; 10 = sound dma channel
; 11 = enable lba read
; 12 = enable pci access
and [esp+32], dword 0
dec ebx ; MIDI
jnz nsyse1
cmp ecx, 0x100
jb nsyse1
mov esi, 65535
cmp esi, ecx
jb nsyse1
mov [midi_base], cx ;bx
mov word [mididp], cx;bx
inc cx ;bx
mov word [midisp], cx;bx
ret
iglobal iglobal
midi_base dw 0 midi_base dw 0
endg endg
;-----------------------------------------------------------------------------
align 4
sys_setup:
; 1 = roland mpu midi base , base io address
; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus
; 3 = not used
; 4 = not used
; 5 = system language, 1eng 2fi 3ger 4rus
; 6 = not used
; 7 = not used
; 8 = not used
; 9 = not used
; 10 = not used
; 11 = enable lba read
; 12 = enable pci access
;-----------------------------------------------------------------------------
and [esp+32], dword 0
; F.21.1 - set MPU MIDI base port
dec ebx
jnz @f
cmp ecx, 0x100
jb @f
mov esi, 65535
cmp esi, ecx
jb @f
mov [midi_base], cx
mov word [mididp], cx
inc cx
mov word [midisp], cx
ret
;--------------------------------------
@@:
; F.21.2 - set keyboard layout
dec ebx
jnz @f
nsyse1:
dec ebx ; KEYBOARD
jnz nsyse2
mov edi, [TASK_BASE] mov edi, [TASK_BASE]
mov eax, [edi+TASKDATA.mem_start] mov eax, [edi+TASKDATA.mem_start]
add eax, edx add eax, edx
; 1 = normal layout
dec ecx dec ecx
jnz kbnobase jnz .shift
mov ebx, keymap mov ebx, keymap
mov ecx, 128 mov ecx, 128
call memmove call memmove
ret ret
kbnobase: ;--------------------------------------
.shift:
; 2 = layout at pressed Shift
dec ecx dec ecx
jnz kbnoshift jnz .alt
mov ebx, keymap_shift mov ebx, keymap_shift
mov ecx, 128 mov ecx, 128
call memmove call memmove
ret ret
kbnoshift: ;--------------------------------------
.alt:
; 3 = layout at pressed Alt
dec ecx dec ecx
jnz kbnoalt jnz .country
mov ebx, keymap_alt mov ebx, keymap_alt
mov ecx, 128 mov ecx, 128
call memmove call memmove
ret ret
kbnoalt: ;--------------------------------------
.country:
; country identifier
sub ecx, 6 sub ecx, 6
jnz kbnocountry jnz .error
mov word [keyboard], dx mov word [keyboard], dx
ret ret
kbnocountry: ;--------------------------------------
mov [esp+32], dword 1 @@:
ret ; F.21.5 - set system language
nsyse2: sub ebx, 3
dec ebx ; CD jnz @f
jnz nsyse4
test ecx, ecx
jz nosesl
cmp ecx, 4
ja nosesl
mov [cd_base], cl
dec ecx
jnz noprma
mov eax, [hd_address_table]
mov [cdbase], eax ;0x1f0
mov [cdid], 0xa0
noprma:
dec ecx
jnz noprsl
mov eax, [hd_address_table]
mov [cdbase], eax ;0x1f0
mov [cdid], 0xb0
noprsl:
dec ecx
jnz nosema
mov eax, [hd_address_table+16]
mov [cdbase], eax ;0x170
mov [cdid], 0xa0
nosema:
dec ecx
jnz nosesl
mov eax, [hd_address_table+16]
mov [cdbase], eax ;0x170
mov [cdid], 0xb0
nosesl:
ret
iglobal
cd_base db 0
endg
nsyse4:
sub ebx, 2 ; SYSTEM LANGUAGE
jnz nsyse5
mov [syslang], ecx mov [syslang], ecx
ret ret
nsyse5: ;--------------------------------------
@@:
sub ebx, 2 ; HD BASE - obsolete ; F.21.11 - enable/disable low-level access to HD
jnz nsyse7
nosethd:
ret
nsyse7:
; cmp eax,8 ; HD PARTITION - obsolete
dec ebx
jnz nsyse8
ret
nsyse8:
; cmp eax,11 ; ENABLE LBA READ
and ecx, 1 and ecx, 1
sub ebx, 3 sub ebx, 6
jnz no_set_lba_read jnz @f
mov [lba_read_enabled], ecx mov [lba_read_enabled], ecx
ret ret
;--------------------------------------
no_set_lba_read: @@:
; cmp eax,12 ; ENABLE PCI ACCESS ; F.21.12 - enable/disable low-level access to PCI
dec ebx dec ebx
jnz sys_setup_err jnz .error
mov [pci_access_enabled], ecx mov [pci_access_enabled], ecx
ret ret
;--------------------------------------
sys_setup_err: .error:
or [esp+32], dword -1 or [esp+32], dword -1
ret ret
;-----------------------------------------------------------------------------
align 4 align 4
sys_getsetup: sys_getsetup:
; 1 = roland mpu midi base , base io address
; 1=roland mpu midi base , base io address ; 2 = keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus
; 2=keyboard 1, base kaybap 2, shift keymap, 9 country 1eng 2fi 3ger 4rus ; 3 = not used
; 3=cd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave ; 4 = not used
; 5=system language, 1eng 2fi 3ger 4rus ; 5 = system language, 1eng 2fi 3ger 4rus
; 7=hd base 1, pri.master 2, pri slave 3 sec master, 4 sec slave ; 6 = not used
; 8=fat32 partition in hd ; 7 = not used
; 9=get hs timer tic ; 8 = not used
; 9 = get hs timer tic
; cmp eax,1 ; 10 = not used
; 11 = get the state "lba read"
; 12 = get the state "pci access"
;-----------------------------------------------------------------------------
; F.26.1 - get MPU MIDI base port
dec ebx dec ebx
jnz ngsyse1 jnz @f
movzx eax, [midi_base] movzx eax, [midi_base]
mov [esp+32], eax mov [esp+32], eax
ret ret
ngsyse1: ;--------------------------------------
; cmp eax,2 @@:
; F.26.2 - get keyboard layout
dec ebx dec ebx
jnz ngsyse2 jnz @f
mov edi, [TASK_BASE] mov edi, [TASK_BASE]
mov ebx, [edi+TASKDATA.mem_start] mov ebx, [edi+TASKDATA.mem_start]
add ebx, edx add ebx, edx
; 1 = normal layout
; cmp ebx,1
dec ecx dec ecx
jnz kbnobaseret jnz .shift
mov eax, keymap mov eax, keymap
mov ecx, 128 mov ecx, 128
call memmove call memmove
ret ret
kbnobaseret: ;--------------------------------------
; cmp ebx,2 .shift:
; 2 = layout with pressed Shift
dec ecx dec ecx
jnz kbnoshiftret jnz .alt
mov eax, keymap_shift mov eax, keymap_shift
mov ecx, 128 mov ecx, 128
call memmove call memmove
ret ret
kbnoshiftret: ;--------------------------------------
; cmp ebx,3 .alt:
; 3 = layout with pressed Alt
dec ecx dec ecx
jne kbnoaltret jne .country
mov eax, keymap_alt mov eax, keymap_alt
mov ecx, 128 mov ecx, 128
call memmove call memmove
ret ret
kbnoaltret: ;--------------------------------------
; cmp ebx,9 .country:
; 9 = country identifier
sub ecx, 6 sub ecx, 6
jnz ngsyse2 jnz .error
movzx eax, word [keyboard] movzx eax, word [keyboard]
mov [esp+32], eax mov [esp+32], eax
ret ret
;--------------------------------------
@@:
; F.26.5 - get system language
sub ebx, 3
jnz @f
ngsyse2:
; cmp eax,3
dec ebx
jnz ngsyse3
movzx eax, [cd_base]
mov [esp+32], eax
ret
ngsyse3:
; cmp eax,5
sub ebx, 2
jnz ngsyse5
mov eax, [syslang] mov eax, [syslang]
mov [esp+32], eax mov [esp+32], eax
ret ret
ngsyse5: ;--------------------------------------
; cmp eax,9 @@:
; F.26.9 - get the value of the time counter
sub ebx, 4 sub ebx, 4
jnz ngsyse9 jnz @f
mov eax, [timer_ticks];[0xfdf0]
mov eax, [timer_ticks]
mov [esp+32], eax mov [esp+32], eax
ret ret
ngsyse9: ;--------------------------------------
; cmp eax,11 @@:
; F.26.11 - Find out whether low-level HD access is enabled
sub ebx, 2 sub ebx, 2
jnz ngsyse11 jnz @f
mov eax, [lba_read_enabled] mov eax, [lba_read_enabled]
mov [esp+32], eax mov [esp+32], eax
ret ret
ngsyse11: ;--------------------------------------
; cmp eax,12 @@:
; F.26.12 - Find out whether low-level PCI access is enabled
dec ebx dec ebx
jnz ngsyse12 jnz .error
mov eax, [pci_access_enabled] mov eax, [pci_access_enabled]
mov [esp+32], eax mov [esp+32], eax
ret ret
ngsyse12: ;--------------------------------------
mov [esp+32], dword 1 .error:
or [esp+32], dword -1
ret ret
;-----------------------------------------------------------------------------
get_timer_ticks: get_timer_ticks:
mov eax, [timer_ticks] mov eax, [timer_ticks]
ret ret
;-----------------------------------------------------------------------------
iglobal iglobal
align 4 align 4
mousefn dd msscreen, mswin, msbutton, msset mousefn dd msscreen, mswin, msbutton, msset
@@ -1772,7 +1745,7 @@ mousefn dd msscreen, mswin, msbutton, msset
dd app_delete_cursor dd app_delete_cursor
dd msz dd msz
endg endg
;-----------------------------------------------------------------------------
readmousepos: readmousepos:
; eax=0 screen relative ; eax=0 screen relative
@@ -5080,38 +5053,52 @@ syscall_getscreensize: ; GetScreenSize
mov ax, word [Screen_Max_Y] mov ax, word [Screen_Max_Y]
mov [esp + 32], eax mov [esp + 32], eax
ret ret
;-----------------------------------------------------------------------------
align 4 align 4
syscall_cdaudio: ; CD syscall_cdaudio: ; CD
cmp ebx, 4 cmp ebx, 4
jb .audio je .eject
jz .eject
cmp ebx, 5 cmp ebx, 5
jnz .ret je .load
ret
;--------------------------------------
.load: .load:
call .reserve call .reserve
call LoadMedium call LoadMedium
;call .free
jmp .free jmp .free
; ret ;--------------------------------------
.eject: .eject:
call .reserve call .reserve
call clear_CD_cache call clear_CD_cache
call allow_medium_removal call allow_medium_removal
call EjectMedium call EjectMedium
; call .free
jmp .free jmp .free
; ret ;--------------------------------------
.audio:
call sys_cd_audio
mov [esp+36-4], eax
.ret:
ret
.reserve: .reserve:
call reserve_cd call reserve_cd
mov ebx, ecx
inc ebx
mov [cdpos], ebx
mov eax, ebx
mov ebx, ecx
and ebx, 11b
shl ebx, 1
mov cl, 8
sub cl, bl
dec eax
shr eax, 2
lea eax, [eax*5]
mov al, [eax+DRIVE_DATA+1]
shr al, cl
test al, 2 ; it's not an ATAPI device
jz .ret
mov eax, ecx mov eax, ecx
shr eax, 1 shr eax, 1
and eax, 1 and eax, 1
@@ -5121,25 +5108,14 @@ syscall_cdaudio: ; CD
and eax, 1 and eax, 1
mov [DiskNumber], al mov [DiskNumber], al
call reserve_cd_channel call reserve_cd_channel
and ebx, 3 ;--------------------------------------
inc ebx .ret:
mov [cdpos], ebx
add ebx, ebx
mov cl, 8
sub cl, bl
mov al, [DRIVE_DATA+1]
shr al, cl
test al, 2
jz .free;.err
ret ret
;--------------------------------------
.free: .free:
call free_cd_channel call free_cd_channel
and [cd_status], 0 and [cd_status], 0
ret ret
.err:
call .free
; pop eax
ret
;----------------------------------------------------------------------------- ;-----------------------------------------------------------------------------
align 4 align 4
syscall_getpixel_WinMap: ; GetPixel WinMap syscall_getpixel_WinMap: ; GetPixel WinMap
@@ -5537,8 +5513,6 @@ system_shutdown: ; shut down the system
ret ret
@@: @@:
call stop_all_services call stop_all_services
movi eax, 3
call sys_cd_audio
yes_shutdown_param: yes_shutdown_param:
cli cli

View File

@@ -152,6 +152,30 @@ struct APPDATA
ends ends
struct IDE_DATA
ProgrammingInterface dd ?
Interrupt dw ?
RegsBaseAddres dw ?
BAR0_val dw ?
BAR1_val dw ?
BAR2_val dw ?
BAR3_val dw ?
dma_hdd db ?
ends
struct IDE_CACHE
pointer dd ?
size dd ? ; not use
data_pointer dd ?
system_data_size dd ? ; not use
appl_data_size dd ? ; not use
system_data dd ?
appl_data dd ?
system_sad_size dd ?
appl_sad_size dd ?
search_start dd ?
appl_search_start dd ?
ends
; Core functions ; Core functions
include "core/sync.inc" ; macros for synhronization objects include "core/sync.inc" ; macros for synhronization objects
@@ -243,7 +267,6 @@ include "blkdev/bd_drv.inc"
; CD drive controller ; CD drive controller
include "blkdev/cdrom.inc"
include "blkdev/cd_drv.inc" include "blkdev/cd_drv.inc"
; Character devices ; Character devices