forked from KolibriOS/kolibrios
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:
parent
5879ec3de3
commit
ba19a6400d
File diff suppressed because it is too large
Load Diff
@ -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
|
||||
|
@ -17,7 +17,7 @@ hdbase dd ?
|
||||
hdid dd ?
|
||||
hdpos dd ?
|
||||
ends
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
iglobal
|
||||
align 4
|
||||
ide_callbacks:
|
||||
@ -35,18 +35,34 @@ hd0_data HD_DATA ?, 0, 1
|
||||
hd1_data HD_DATA ?, 0x10, 2
|
||||
hd2_data HD_DATA ?, 0, 3
|
||||
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:
|
||||
dd 0x1f0, 0x00, 0x1f0, 0x10
|
||||
dd 0x170, 0x00, 0x170, 0x10
|
||||
ide_mutex_table:
|
||||
dd ide_channel1_mutex
|
||||
dd ide_channel2_mutex
|
||||
dd ide_channel3_mutex
|
||||
dd ide_channel4_mutex
|
||||
dd ide_channel5_mutex
|
||||
dd ide_channel6_mutex
|
||||
endg
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
uglobal
|
||||
ide_mutex MUTEX
|
||||
ide_channel1_mutex MUTEX
|
||||
ide_channel2_mutex MUTEX
|
||||
ide_channel3_mutex MUTEX
|
||||
ide_channel4_mutex MUTEX
|
||||
ide_channel5_mutex MUTEX
|
||||
ide_channel6_mutex MUTEX
|
||||
endg
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
proc ide_read stdcall uses edi, \
|
||||
hd_data, buffer, startsector:qword, numsectors
|
||||
; hd_data = pointer to hd*_data
|
||||
@ -67,15 +83,13 @@ endl
|
||||
; 2. Acquire the global lock.
|
||||
mov ecx, ide_mutex
|
||||
call mutex_lock
|
||||
mov ecx, ide_channel2_mutex
|
||||
mov eax, [hd_data]
|
||||
push ecx
|
||||
mov ecx, [hd_address_table]
|
||||
cmp [eax+HD_DATA.hdbase], ecx ; 0x1F0
|
||||
pop ecx
|
||||
jne .IDE_Channel_2
|
||||
mov ecx, ide_channel1_mutex
|
||||
.IDE_Channel_2:
|
||||
|
||||
mov ecx, [hd_data]
|
||||
mov ecx, [ecx+HD_DATA.hdpos]
|
||||
dec ecx
|
||||
shr ecx, 1
|
||||
shl ecx, 2
|
||||
mov ecx, [ecx + ide_mutex_table]
|
||||
mov [channel_lock], ecx
|
||||
call mutex_lock
|
||||
; 3. Convert parameters to the form suitable for worker procedures.
|
||||
@ -83,6 +97,7 @@ endl
|
||||
; Worker procedures use global variables and edi for [buffer].
|
||||
cmp dword [startsector+4], 0
|
||||
jnz .fail
|
||||
|
||||
and [hd_error], 0
|
||||
mov ecx, [hd_data]
|
||||
mov eax, [ecx+HD_DATA.hdbase]
|
||||
@ -98,55 +113,51 @@ endl
|
||||
; DMA read is permitted if [allow_dma_access]=1 or 2
|
||||
cmp [allow_dma_access], 2
|
||||
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
|
||||
|
||||
jmp .dma
|
||||
@@:
|
||||
test [DRIVE_DATA+1], byte 1010b
|
||||
jnz .nodma
|
||||
.dma:
|
||||
;--------------------------------------
|
||||
call hd_read_dma
|
||||
jmp @f
|
||||
;--------------------------------------
|
||||
.nodma:
|
||||
call hd_read_pio
|
||||
;--------------------------------------
|
||||
@@:
|
||||
cmp [hd_error], 0
|
||||
jnz .fail
|
||||
|
||||
mov ecx, [numsectors]
|
||||
inc dword [ecx] ; one more sector is read
|
||||
dec [sectors_todo]
|
||||
jz .done
|
||||
|
||||
inc eax
|
||||
jnz .sectors_loop
|
||||
;--------------------------------------
|
||||
; 5. Loop is done, either due to error or because everything is done.
|
||||
; Release the global lock and return the corresponding status.
|
||||
.fail:
|
||||
mov ecx, [channel_lock]
|
||||
call mutex_unlock
|
||||
|
||||
mov ecx, ide_mutex
|
||||
call mutex_unlock
|
||||
|
||||
or eax, -1
|
||||
ret
|
||||
;--------------------------------------
|
||||
.done:
|
||||
mov ecx, [channel_lock]
|
||||
call mutex_unlock
|
||||
|
||||
mov ecx, ide_mutex
|
||||
call mutex_unlock
|
||||
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
proc ide_write stdcall uses esi edi, \
|
||||
hd_data, buffer, startsector:qword, numsectors
|
||||
; hd_data = pointer to hd*_data
|
||||
@ -167,15 +178,13 @@ endl
|
||||
; 2. Acquire the global lock.
|
||||
mov ecx, ide_mutex
|
||||
call mutex_lock
|
||||
mov ecx, ide_channel2_mutex
|
||||
mov eax, [hd_data]
|
||||
push ecx
|
||||
mov ecx, [hd_address_table]
|
||||
cmp [eax+HD_DATA.hdbase], ecx ; 0x1F0
|
||||
pop ecx
|
||||
jne .IDE_Channel_2
|
||||
mov ecx, ide_channel1_mutex
|
||||
.IDE_Channel_2:
|
||||
|
||||
mov ecx, [hd_data]
|
||||
mov ecx, [ecx+HD_DATA.hdpos]
|
||||
dec ecx
|
||||
shr ecx, 1
|
||||
shl ecx, 2
|
||||
mov ecx, [ecx + ide_mutex_table]
|
||||
mov [channel_lock], ecx
|
||||
call mutex_lock
|
||||
; 3. Convert parameters to the form suitable for worker procedures.
|
||||
@ -183,6 +192,7 @@ endl
|
||||
; Worker procedures use global variables and esi for [buffer].
|
||||
cmp dword [startsector+4], 0
|
||||
jnz .fail
|
||||
|
||||
and [hd_error], 0
|
||||
mov ecx, [hd_data]
|
||||
mov eax, [ecx+HD_DATA.hdbase]
|
||||
@ -200,66 +210,65 @@ endl
|
||||
mov ecx, 16
|
||||
cmp ecx, [sectors_todo]
|
||||
jbe @f
|
||||
|
||||
mov ecx, [sectors_todo]
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov [cache_chain_size], cl
|
||||
; DMA write is permitted only if [allow_dma_access]=1
|
||||
cmp [allow_dma_access], 2
|
||||
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
|
||||
|
||||
jmp .dma
|
||||
@@:
|
||||
test [DRIVE_DATA+1], byte 1010b
|
||||
jnz .nodma
|
||||
.dma:
|
||||
;--------------------------------------
|
||||
call cache_write_dma
|
||||
jmp .common
|
||||
;--------------------------------------
|
||||
.nodma:
|
||||
mov [cache_chain_size], 1
|
||||
call cache_write_pio
|
||||
;--------------------------------------
|
||||
.common:
|
||||
cmp [hd_error], 0
|
||||
jnz .fail
|
||||
|
||||
movzx ecx, [cache_chain_size]
|
||||
mov eax, [numsectors]
|
||||
add [eax], ecx
|
||||
sub [sectors_todo], ecx
|
||||
jz .done
|
||||
|
||||
add [edi], ecx
|
||||
jc .fail
|
||||
|
||||
shl ecx, 9
|
||||
add esi, ecx
|
||||
jmp .sectors_loop
|
||||
;--------------------------------------
|
||||
; 5. Loop is done, either due to error or because everything is done.
|
||||
; Release the global lock and return the corresponding status.
|
||||
.fail:
|
||||
mov ecx, [channel_lock]
|
||||
call mutex_unlock
|
||||
|
||||
mov ecx, ide_mutex
|
||||
call mutex_unlock
|
||||
|
||||
or eax, -1
|
||||
ret
|
||||
;--------------------------------------
|
||||
.done:
|
||||
mov ecx, [channel_lock]
|
||||
call mutex_unlock
|
||||
|
||||
mov ecx, ide_mutex
|
||||
call mutex_unlock
|
||||
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
; This is a stub.
|
||||
proc ide_querymedia stdcall, hd_data, mediainfo
|
||||
mov eax, [mediainfo]
|
||||
@ -270,14 +279,12 @@ proc ide_querymedia stdcall, hd_data, mediainfo
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
align 4
|
||||
; input: eax = sector, edi -> buffer
|
||||
; output: edi = edi + 512
|
||||
hd_read_pio:
|
||||
push eax edx
|
||||
|
||||
; Select the desired drive
|
||||
mov edx, [hdbase]
|
||||
add edx, 6 ;адрес регистра головок
|
||||
@ -286,9 +293,9 @@ hd_read_pio:
|
||||
out dx, al; номер головки/номер диска
|
||||
|
||||
call wait_for_hd_idle
|
||||
|
||||
cmp [hd_error], 0
|
||||
jne hd_read_error
|
||||
|
||||
; ATA with 28 or 48 bit for sector number?
|
||||
mov eax, [esp+4]
|
||||
cmp eax, 0x10000000
|
||||
@ -372,7 +379,6 @@ hd_read_pio:
|
||||
|
||||
pushfd
|
||||
cli
|
||||
|
||||
mov ecx, 256
|
||||
mov edx, [hdbase]
|
||||
cld
|
||||
@ -393,6 +399,7 @@ cache_write_pio:
|
||||
out dx, al ; номер головки/номер диска
|
||||
|
||||
call wait_for_hd_idle
|
||||
|
||||
cmp [hd_error], 0
|
||||
jne hd_write_error
|
||||
|
||||
@ -550,13 +557,14 @@ wait_for_hd_idle:
|
||||
align 4
|
||||
wfhil1:
|
||||
call check_hd_wait_timeout
|
||||
|
||||
cmp [hd_error], 0
|
||||
jne @f
|
||||
|
||||
in al, dx
|
||||
test al, 128
|
||||
jnz wfhil1
|
||||
|
||||
;--------------------------------------
|
||||
@@:
|
||||
pop edx eax
|
||||
ret
|
||||
@ -573,6 +581,7 @@ wait_for_sector_buffer:
|
||||
align 4
|
||||
hdwait_sbuf: ; wait for sector buffer to be ready
|
||||
call check_hd_wait_timeout
|
||||
|
||||
cmp [hd_error], 0
|
||||
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
|
||||
jz buf_wait_ok
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov [hd_error], 1
|
||||
|
||||
;--------------------------------------
|
||||
buf_wait_ok:
|
||||
pop edx eax
|
||||
ret
|
||||
@ -606,22 +616,17 @@ wait_for_sector_dma_ide0:
|
||||
align 4
|
||||
.wait:
|
||||
call change_task
|
||||
|
||||
cmp [IDE_common_irq_param], 0
|
||||
jz .done
|
||||
|
||||
call check_hd_wait_timeout
|
||||
|
||||
cmp [hd_error], 0
|
||||
jz .wait
|
||||
; clear Bus Master IDE Command register
|
||||
pushfd
|
||||
cli
|
||||
|
||||
mov [IDE_common_irq_param], 0
|
||||
mov dx, [IDEContrRegsBaseAddr]
|
||||
mov al, 0
|
||||
out dx, al
|
||||
popfd
|
||||
;--------------------------------------
|
||||
align 4
|
||||
.done:
|
||||
pop edx
|
||||
pop eax
|
||||
@ -636,23 +641,17 @@ wait_for_sector_dma_ide1:
|
||||
align 4
|
||||
.wait:
|
||||
call change_task
|
||||
|
||||
cmp [IDE_common_irq_param], 0
|
||||
jz .done
|
||||
|
||||
call check_hd_wait_timeout
|
||||
|
||||
cmp [hd_error], 0
|
||||
jz .wait
|
||||
; clear Bus Master IDE Command register
|
||||
pushfd
|
||||
cli
|
||||
|
||||
mov [IDE_common_irq_param], 0
|
||||
mov dx, [IDEContrRegsBaseAddr]
|
||||
add dx, 8
|
||||
mov al, 0
|
||||
out dx, al
|
||||
popfd
|
||||
;--------------------------------------
|
||||
align 4
|
||||
.done:
|
||||
pop edx
|
||||
pop eax
|
||||
@ -660,7 +659,8 @@ align 4
|
||||
;-----------------------------------------------------------------------------
|
||||
iglobal
|
||||
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:
|
||||
dd IDE_DMA
|
||||
dw 0x2000
|
||||
@ -673,14 +673,8 @@ endg
|
||||
;-----------------------------------------------------------------------------
|
||||
uglobal
|
||||
; 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_size db 0
|
||||
cache_chain_started db 0
|
||||
dma_task_switched db 0
|
||||
dma_hdd db 0
|
||||
allow_dma_access db 0
|
||||
endg
|
||||
;-----------------------------------------------------------------------------
|
||||
@ -693,7 +687,8 @@ IDE_irq_14_handler:
|
||||
cli
|
||||
pushad
|
||||
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?
|
||||
add edx, 2
|
||||
in al, dx
|
||||
@ -715,12 +710,10 @@ IDE_irq_14_handler:
|
||||
mov al, 1
|
||||
ret
|
||||
;--------------------------------------
|
||||
align 4
|
||||
@@:
|
||||
popad
|
||||
popfd
|
||||
;--------------------------------------
|
||||
align 4
|
||||
.exit:
|
||||
mov al, 0
|
||||
ret
|
||||
@ -734,7 +727,8 @@ IDE_irq_15_handler:
|
||||
cli
|
||||
pushad
|
||||
mov [IDE_common_irq_param], 0
|
||||
mov dx, [IDEContrRegsBaseAddr]
|
||||
mov ecx, [IDE_controller_pointer]
|
||||
mov dx, [ecx+IDE_DATA.RegsBaseAddres]
|
||||
add dx, 8
|
||||
; test whether it is our interrupt?
|
||||
add edx, 2
|
||||
@ -757,12 +751,10 @@ IDE_irq_15_handler:
|
||||
mov al, 1
|
||||
ret
|
||||
;--------------------------------------
|
||||
align 4
|
||||
@@:
|
||||
popad
|
||||
popfd
|
||||
;--------------------------------------
|
||||
align 4
|
||||
.exit:
|
||||
mov al, 0
|
||||
ret
|
||||
@ -776,7 +768,8 @@ IDE_common_irq_handler:
|
||||
cli
|
||||
pushad
|
||||
xor ebx, ebx
|
||||
mov dx, [IDEContrRegsBaseAddr]
|
||||
mov ecx, [IDE_controller_pointer]
|
||||
mov dx, [ecx+IDE_DATA.RegsBaseAddres]
|
||||
mov eax, IDE_common_irq_param
|
||||
cmp [eax], irq14_num
|
||||
mov [eax], bl
|
||||
@ -784,7 +777,6 @@ IDE_common_irq_handler:
|
||||
|
||||
add dx, 8
|
||||
;--------------------------------------
|
||||
align 4
|
||||
@@:
|
||||
; test whether it is our interrupt?
|
||||
add edx, 2
|
||||
@ -807,12 +799,10 @@ align 4
|
||||
mov al, 1
|
||||
ret
|
||||
;--------------------------------------
|
||||
align 4
|
||||
@@:
|
||||
popad
|
||||
popfd
|
||||
;--------------------------------------
|
||||
align 4
|
||||
.exit:
|
||||
mov al, 0
|
||||
ret
|
||||
@ -824,26 +814,31 @@ hd_read_dma:
|
||||
mov edx, [dma_hdpos]
|
||||
cmp edx, [hdpos]
|
||||
jne .notread
|
||||
|
||||
mov edx, [dma_cur_sector]
|
||||
cmp eax, edx
|
||||
jb .notread
|
||||
|
||||
add edx, 15
|
||||
cmp [esp+4], edx
|
||||
ja .notread
|
||||
|
||||
mov eax, [esp+4]
|
||||
sub eax, [dma_cur_sector]
|
||||
shl eax, 9
|
||||
add eax, (OS_BASE+IDE_DMA)
|
||||
|
||||
push ecx esi
|
||||
mov esi, eax
|
||||
|
||||
mov ecx, 512/4
|
||||
cld
|
||||
rep movsd
|
||||
pop esi ecx
|
||||
|
||||
pop edx
|
||||
pop eax
|
||||
ret
|
||||
;--------------------------------------
|
||||
.notread:
|
||||
; set data for PRD Table
|
||||
mov eax, IDE_descriptor_table
|
||||
@ -851,13 +846,24 @@ hd_read_dma:
|
||||
mov word [eax+4], 0x2000
|
||||
sub eax, OS_BASE
|
||||
; 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
|
||||
mov eax, [hd_address_table]
|
||||
cmp [hdbase], eax ; 0x1F0
|
||||
mov eax, [hdpos]
|
||||
dec eax
|
||||
test eax, 10b
|
||||
pop eax
|
||||
jz @f
|
||||
|
||||
add edx, 8
|
||||
;--------------------------------------
|
||||
@@:
|
||||
push edx
|
||||
; Bus Master IDE PRD Table Address
|
||||
@ -881,9 +887,9 @@ hd_read_dma:
|
||||
out dx, al ; номер головки/номер диска
|
||||
|
||||
call wait_for_hd_idle
|
||||
|
||||
cmp [hd_error], 0
|
||||
jnz hd_read_error
|
||||
|
||||
; ATA with 28 or 48 bit for sector number?
|
||||
mov eax, [esp+4]
|
||||
; -10h because the PreCache hits the boundary between lba28 and lba48
|
||||
@ -961,47 +967,55 @@ hd_read_dma:
|
||||
;--------------------------------------
|
||||
.continue:
|
||||
; select controller Primary or Secondary
|
||||
mov dx, [IDEContrRegsBaseAddr]
|
||||
mov eax, [hd_address_table]
|
||||
cmp [hdbase], eax ; 0x1F0
|
||||
mov ecx, [IDE_controller_pointer]
|
||||
mov dx, [ecx+IDE_DATA.RegsBaseAddres]
|
||||
|
||||
mov eax, [hdpos]
|
||||
dec eax
|
||||
test eax, 10b
|
||||
jz @f
|
||||
|
||||
add dx, 8
|
||||
;--------------------------------------
|
||||
@@:
|
||||
; set write to memory and Start Bus Master
|
||||
mov al, 9
|
||||
out dx, al
|
||||
|
||||
mov eax, [CURRENT_TASK]
|
||||
mov [dma_process], eax
|
||||
|
||||
mov eax, [TASK_BASE]
|
||||
mov [dma_slot_ptr], eax
|
||||
|
||||
mov eax, [hd_address_table]
|
||||
cmp [hdbase], eax ; 0x1F0
|
||||
mov eax, [hdpos]
|
||||
dec eax
|
||||
test eax, 10b
|
||||
jnz .ide1
|
||||
|
||||
mov [IDE_common_irq_param], irq14_num
|
||||
jmp @f
|
||||
;--------------------------------------
|
||||
.ide1:
|
||||
mov [IDE_common_irq_param], irq15_num
|
||||
;--------------------------------------
|
||||
@@:
|
||||
popfd
|
||||
; wait for interrupt
|
||||
mov eax, [hd_address_table]
|
||||
cmp [hdbase], eax ; 0x1F0
|
||||
mov eax, [hdpos]
|
||||
dec eax
|
||||
test eax, 10b
|
||||
jnz .wait_ide1
|
||||
|
||||
call wait_for_sector_dma_ide0
|
||||
jmp @f
|
||||
;--------------------------------------
|
||||
.wait_ide1:
|
||||
call wait_for_sector_dma_ide1
|
||||
;--------------------------------------
|
||||
@@:
|
||||
cmp [hd_error], 0
|
||||
jnz hd_read_error
|
||||
|
||||
mov eax, [hdpos]
|
||||
mov [dma_hdpos], eax
|
||||
pop edx
|
||||
pop eax
|
||||
|
||||
mov [dma_cur_sector], eax
|
||||
jmp hd_read_dma
|
||||
;-----------------------------------------------------------------------------
|
||||
@ -1011,6 +1025,7 @@ cache_write_dma:
|
||||
; set data for PRD Table
|
||||
mov eax, IDE_descriptor_table
|
||||
mov edx, eax
|
||||
|
||||
pusha
|
||||
mov edi, (OS_BASE+IDE_DMA)
|
||||
mov dword [edx], IDE_DMA
|
||||
@ -1021,15 +1036,27 @@ cache_write_dma:
|
||||
cld
|
||||
rep movsd
|
||||
popa
|
||||
|
||||
sub eax, OS_BASE
|
||||
; 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
|
||||
mov eax, [hd_address_table]
|
||||
cmp [hdbase], eax ; 0x1F0
|
||||
mov eax, [hdpos]
|
||||
dec eax
|
||||
test eax, 10b
|
||||
pop eax
|
||||
jz @f
|
||||
|
||||
add edx, 8
|
||||
;--------------------------------------
|
||||
@@:
|
||||
push edx
|
||||
; Bus Master IDE PRD Table Address
|
||||
@ -1053,9 +1080,9 @@ cache_write_dma:
|
||||
out dx, al ; номер головки/номер диска
|
||||
|
||||
call wait_for_hd_idle
|
||||
|
||||
cmp [hd_error], 0
|
||||
jnz hd_write_error_dma
|
||||
|
||||
; ATA with 28 or 48 bit for sector number?
|
||||
mov esi, [cache_chain_ptr]
|
||||
mov eax, [esi]
|
||||
@ -1134,69 +1161,73 @@ cache_write_dma:
|
||||
;--------------------------------------
|
||||
.continue:
|
||||
; select controller Primary or Secondary
|
||||
mov dx, [IDEContrRegsBaseAddr]
|
||||
mov eax, [hd_address_table]
|
||||
cmp [hdbase], eax ; 0x1F0
|
||||
mov ecx, [IDE_controller_pointer]
|
||||
mov dx, [ecx+IDE_DATA.RegsBaseAddres]
|
||||
|
||||
mov eax, [hdpos]
|
||||
dec eax
|
||||
test eax, 10b
|
||||
jz @f
|
||||
|
||||
add dx, 8
|
||||
;--------------------------------------
|
||||
@@:
|
||||
; set write to device and Start Bus Master
|
||||
mov al, 1
|
||||
out dx, al
|
||||
mov eax, [CURRENT_TASK]
|
||||
mov [dma_process], eax
|
||||
mov eax, [TASK_BASE]
|
||||
mov [dma_slot_ptr], eax
|
||||
mov eax, [hd_address_table]
|
||||
cmp [hdbase], eax ; 0x1F0
|
||||
|
||||
mov eax, [hdpos]
|
||||
dec eax
|
||||
test eax, 10b
|
||||
jnz .ide1
|
||||
|
||||
mov [IDE_common_irq_param], irq14_num
|
||||
jmp @f
|
||||
;--------------------------------------
|
||||
.ide1:
|
||||
mov [IDE_common_irq_param], irq15_num
|
||||
;--------------------------------------
|
||||
@@:
|
||||
popfd
|
||||
; wait for interrupt
|
||||
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
|
||||
|
||||
call wait_for_sector_dma_ide0
|
||||
|
||||
jmp @f
|
||||
;--------------------------------------
|
||||
.wait_ide1:
|
||||
call wait_for_sector_dma_ide1
|
||||
;--------------------------------------
|
||||
@@:
|
||||
cmp [hd_error], 0
|
||||
jnz hd_write_error_dma
|
||||
pop esi
|
||||
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
|
||||
mov esi, pcidev_list
|
||||
;--------------------------------------
|
||||
align 4
|
||||
.loop:
|
||||
mov esi, [esi+PCIDEV.fd]
|
||||
cmp esi, pcidev_list
|
||||
jz .done
|
||||
|
||||
cmp [esi+PCIDEV.class], 0x01018F
|
||||
jnz .loop
|
||||
|
||||
mov ah, [esi+PCIDEV.bus]
|
||||
mov al, 2
|
||||
mov bh, [esi+PCIDEV.devfn]
|
||||
mov bl, 0x20
|
||||
call pci_read_reg
|
||||
|
||||
and eax, 0FFFCh
|
||||
mov edx, eax
|
||||
add edx, 2
|
||||
@ -1212,6 +1243,8 @@ proc clear_pci_ide_interrupts
|
||||
in al, dx
|
||||
DEBUGF 1,'-> %x\n',al
|
||||
jmp .loop
|
||||
;--------------------------------------
|
||||
.done:
|
||||
ret
|
||||
endp
|
||||
;-----------------------------------------------------------------------------
|
||||
|
@ -41,53 +41,29 @@ find_empty_slot_CD_cache:
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
clear_CD_cache:
|
||||
DEBUGF 1, 'K : clear_CD_cache\n'
|
||||
pusha
|
||||
.ide0:
|
||||
|
||||
mov esi, [cdpos]
|
||||
dec esi
|
||||
imul esi, sizeof.IDE_CACHE
|
||||
add esi, cache_ide0
|
||||
|
||||
xor eax, eax
|
||||
cmp [cdpos], 1
|
||||
jne .ide1
|
||||
mov [cache_ide0_search_start], eax
|
||||
mov ecx, [cache_ide0_system_sad_size]
|
||||
mov edi, [cache_ide0_pointer]
|
||||
|
||||
mov [esi+IDE_CACHE.search_start], eax
|
||||
mov ecx, [esi+IDE_CACHE.system_sad_size]
|
||||
mov edi, [esi+IDE_CACHE.pointer]
|
||||
call .clear
|
||||
mov [cache_ide0_appl_search_start], eax
|
||||
mov ecx, [cache_ide0_appl_sad_size]
|
||||
mov edi, [cache_ide0_data_pointer]
|
||||
jmp .continue
|
||||
.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:
|
||||
|
||||
mov [esi+IDE_CACHE.appl_search_start], eax
|
||||
mov ecx, [esi+IDE_CACHE.appl_sad_size]
|
||||
mov edi, [esi+IDE_CACHE.data_pointer]
|
||||
call .clear
|
||||
|
||||
popa
|
||||
ret
|
||||
;--------------------------------------
|
||||
.clear:
|
||||
shl ecx, 1
|
||||
cld
|
||||
@ -96,272 +72,131 @@ clear_CD_cache:
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
cd_calculate_cache:
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [cdpos], 1
|
||||
jne .ide1
|
||||
; 1 - IDE0 ... 12 - IDE11
|
||||
push eax
|
||||
|
||||
mov eax, [cdpos]
|
||||
dec eax
|
||||
imul eax, sizeof.IDE_CACHE
|
||||
add eax, cache_ide0
|
||||
|
||||
cmp [cd_appl_data], 0
|
||||
jne .ide0_appl_data
|
||||
mov ecx, [cache_ide0_system_sad_size]
|
||||
mov esi, [cache_ide0_pointer]
|
||||
jne @f
|
||||
|
||||
mov ecx, [eax+IDE_CACHE.system_sad_size]
|
||||
mov esi, [eax+IDE_CACHE.pointer]
|
||||
pop eax
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
mov ecx, [cache_ide0_appl_sad_size]
|
||||
mov esi, [cache_ide0_data_pointer]
|
||||
ret
|
||||
.ide1:
|
||||
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]
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov ecx, [eax+IDE_CACHE.appl_sad_size]
|
||||
mov esi, [eax+IDE_CACHE.data_pointer]
|
||||
pop eax
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
cd_calculate_cache_1:
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [cdpos], 1
|
||||
jne .ide1
|
||||
; 1 - IDE0 ... 12 - IDE11
|
||||
push eax
|
||||
|
||||
mov eax, [cdpos]
|
||||
dec eax
|
||||
imul eax, sizeof.IDE_CACHE
|
||||
add eax, cache_ide0
|
||||
|
||||
cmp [cd_appl_data], 0
|
||||
jne .ide0_appl_data
|
||||
mov esi, [cache_ide0_pointer]
|
||||
jne @f
|
||||
|
||||
mov esi, [eax+IDE_CACHE.pointer]
|
||||
pop eax
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
mov esi, [cache_ide0_data_pointer]
|
||||
ret
|
||||
.ide1:
|
||||
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]
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov esi, [eax+IDE_CACHE.data_pointer]
|
||||
pop eax
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
cd_calculate_cache_2:
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [cdpos], 1
|
||||
jne .ide1
|
||||
; 1 - IDE0 ... 12 - IDE11
|
||||
mov eax, [cdpos]
|
||||
dec eax
|
||||
imul eax, sizeof.IDE_CACHE
|
||||
add eax, cache_ide0
|
||||
|
||||
cmp [cd_appl_data], 0
|
||||
jne .ide0_appl_data
|
||||
mov eax, [cache_ide0_system_data]
|
||||
jne @f
|
||||
|
||||
mov eax, [eax+IDE_CACHE.system_data]
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
mov eax, [cache_ide0_appl_data]
|
||||
ret
|
||||
.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]
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov eax, [eax+IDE_CACHE.appl_data]
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
cd_calculate_cache_3:
|
||||
; mov ecx,cache_max*10/100
|
||||
; mov edi,[cache_search_start]
|
||||
; 1 - IDE0 ... 12 - IDE11
|
||||
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
|
||||
jne .ide0_appl_data
|
||||
mov edi, [cache_ide0_search_start]
|
||||
jne @f
|
||||
|
||||
mov edi, [eax+IDE_CACHE.search_start]
|
||||
pop eax
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
mov edi, [cache_ide0_appl_search_start]
|
||||
ret
|
||||
.ide1:
|
||||
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]
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov edi, [eax+IDE_CACHE.appl_search_start]
|
||||
pop eax
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
cd_calculate_cache_4:
|
||||
; cmp edi,cache_max
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [cdpos], 1
|
||||
jne .ide1
|
||||
; 1 - IDE0 ... 12 - IDE11
|
||||
push eax
|
||||
|
||||
mov eax, [cdpos]
|
||||
dec eax
|
||||
imul eax, sizeof.IDE_CACHE
|
||||
add eax, cache_ide0
|
||||
|
||||
cmp [cd_appl_data], 0
|
||||
jne .ide0_appl_data
|
||||
cmp edi, [cache_ide0_system_sad_size]
|
||||
jne @f
|
||||
|
||||
cmp edi, [eax+IDE_CACHE.system_sad_size]
|
||||
pop eax
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
cmp edi, [cache_ide0_appl_sad_size]
|
||||
ret
|
||||
.ide1:
|
||||
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]
|
||||
;--------------------------------------
|
||||
@@:
|
||||
cmp edi, [eax+IDE_CACHE.appl_sad_size]
|
||||
pop eax
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
align 4
|
||||
cd_calculate_cache_5:
|
||||
; mov [cache_search_start],edi
|
||||
; 1 - IDE0 ... 4 - IDE3
|
||||
.ide0:
|
||||
cmp [cdpos], 1
|
||||
jne .ide1
|
||||
; 1 - IDE0 ... 12 - IDE11
|
||||
push eax
|
||||
|
||||
mov eax, [cdpos]
|
||||
dec eax
|
||||
imul eax, sizeof.IDE_CACHE
|
||||
add eax, cache_ide0
|
||||
|
||||
cmp [cd_appl_data], 0
|
||||
jne .ide0_appl_data
|
||||
mov [cache_ide0_search_start], edi
|
||||
jne @f
|
||||
|
||||
mov [eax+IDE_CACHE.search_start], edi
|
||||
pop eax
|
||||
ret
|
||||
.ide0_appl_data:
|
||||
mov [cache_ide0_appl_search_start], edi
|
||||
ret
|
||||
.ide1:
|
||||
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
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov [eax+IDE_CACHE.appl_search_start], edi
|
||||
pop eax
|
||||
ret
|
||||
;--------------------------------------------------------------------
|
||||
;align 4
|
||||
;calculate_linear_to_real:
|
||||
; shr eax, 12
|
||||
; mov eax, [page_tabs+eax*4]
|
||||
; and eax, 0xFFFFF000
|
||||
; ret
|
||||
|
@ -179,7 +179,7 @@ struct TSS
|
||||
_io_map_1 rb 4096
|
||||
ends
|
||||
|
||||
DRIVE_DATA_SIZE equ 10
|
||||
DRIVE_DATA_SIZE equ 16
|
||||
|
||||
OS_BASE equ 0x80000000
|
||||
|
||||
|
@ -29,8 +29,7 @@ irq0:
|
||||
.nocounter:
|
||||
xor ecx, ecx ; send End Of Interrupt signal
|
||||
call irq_eoi
|
||||
; btr dword[DONT_SWITCH], 0
|
||||
; jc .return
|
||||
|
||||
mov bl, SCHEDULE_ANY_PRIORITY
|
||||
call find_next_task
|
||||
jz .return ; if there is only one running process
|
||||
@ -44,26 +43,10 @@ change_task:
|
||||
pushfd
|
||||
cli
|
||||
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
|
||||
call find_next_task
|
||||
jz .return ; the same task -> skip switch
|
||||
@@:
|
||||
; mov byte[DONT_SWITCH], 1
|
||||
|
||||
call do_change_task
|
||||
.return:
|
||||
popad
|
||||
|
@ -493,58 +493,6 @@ BgrDataHeight 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
|
||||
|
||||
lba_read_enabled rd 1 ; 0 = disabled , 1 = enabled
|
||||
|
@ -17,44 +17,85 @@ $Revision$
|
||||
;****************************************************
|
||||
;* ПОИСК HDD и CD *
|
||||
;****************************************************
|
||||
cmp [IDEContrProgrammingInterface], 0
|
||||
cmp [ecx+IDE_DATA.ProgrammingInterface], 0
|
||||
je EndFindHDD
|
||||
|
||||
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 [DiskNumber], 0
|
||||
call FindHDD_3
|
||||
call FindHDD_2
|
||||
|
||||
mov [DiskNumber], 1
|
||||
call FindHDD_3
|
||||
call FindHDD_2
|
||||
|
||||
inc [ChannelNumber]
|
||||
|
||||
mov [DiskNumber], 0
|
||||
call FindHDD_3
|
||||
call FindHDD_2
|
||||
|
||||
mov [DiskNumber], 1
|
||||
call FindHDD_1
|
||||
jmp EndFindHDD
|
||||
|
||||
pop ecx
|
||||
jmp EndFindHDD
|
||||
;-----------------------------------------------------------------------------
|
||||
FindHDD_2:
|
||||
call FindHDD_1
|
||||
shl byte [ebx+DRIVE_DATA], 2
|
||||
ret
|
||||
;-----------------------------------------------------------------------------
|
||||
FindHDD_1:
|
||||
DEBUGF 1, "K : Channel %d ",[ChannelNumber]:2
|
||||
DEBUGF 1, "Disk %d\n",[DiskNumber]:1
|
||||
push ebx
|
||||
call ReadHDD_ID
|
||||
pop ebx
|
||||
cmp [DevErrorCode], 0
|
||||
jne FindHDD_2
|
||||
jne .FindCD
|
||||
|
||||
cmp [Sector512+6], word 16
|
||||
ja FindHDD_2
|
||||
ja .FindCD
|
||||
|
||||
cmp [Sector512+12], word 255
|
||||
ja FindHDD_2
|
||||
inc byte [DRIVE_DATA+1]
|
||||
jmp Print_Device_Name
|
||||
FindHDD_2:
|
||||
ja .FindCD
|
||||
|
||||
inc byte [ebx+DRIVE_DATA]
|
||||
jmp .Print_Device_Name
|
||||
;--------------------------------------
|
||||
.FindCD:
|
||||
push ebx
|
||||
call DeviceReset
|
||||
pop ebx
|
||||
cmp [DevErrorCode], 0
|
||||
jne FindHDD_2_2
|
||||
jne .end
|
||||
|
||||
push ebx
|
||||
call ReadCD_ID
|
||||
pop ebx
|
||||
cmp [DevErrorCode], 0
|
||||
jne FindHDD_2_2
|
||||
inc byte [DRIVE_DATA+1]
|
||||
inc byte [DRIVE_DATA+1]
|
||||
Print_Device_Name:
|
||||
jne .end
|
||||
|
||||
add [ebx+DRIVE_DATA], byte 2
|
||||
;--------------------------------------
|
||||
.Print_Device_Name:
|
||||
pushad
|
||||
pushfd
|
||||
mov esi, Sector512+27*2
|
||||
@ -66,33 +107,38 @@ Print_Device_Name:
|
||||
xchg ah, al
|
||||
stosw
|
||||
loop @b
|
||||
popfd
|
||||
popad
|
||||
|
||||
DEBUGF 1, "K : Dev: %s \n", dev_name
|
||||
|
||||
xor eax, eax
|
||||
mov ax, [Sector512+64*2]
|
||||
DEBUGF 1, "K : PIO mode possible modes %x\n", al
|
||||
|
||||
mov ax, [Sector512+51*2]
|
||||
mov al, ah
|
||||
call convert_Sector512_value
|
||||
DEBUGF 1, "K : PIO mode set mode %x\n", ah
|
||||
|
||||
mov ax, [Sector512+63*2]
|
||||
DEBUGF 1, "K : Multiword DMA possible modes %x\n", al
|
||||
|
||||
mov al, ah
|
||||
call convert_Sector512_value
|
||||
DEBUGF 1, "K : Multiword DMA set mode %x\n", ah
|
||||
|
||||
mov ax, [Sector512+88*2]
|
||||
DEBUGF 1, "K : Ultra DMA possible modes %x\n", al
|
||||
|
||||
mov al, ah
|
||||
call convert_Sector512_value
|
||||
DEBUGF 1, "K : Ultra DMA set mode %x\n", ah
|
||||
FindHDD_2_2:
|
||||
|
||||
popfd
|
||||
popad
|
||||
ret
|
||||
;-----------------------------------------------------------------------------
|
||||
FindHDD_3:
|
||||
call FindHDD_1
|
||||
shl byte [DRIVE_DATA+1], 2
|
||||
;--------------------------------------
|
||||
.end:
|
||||
DEBUGF 1, "K : Device not found\n"
|
||||
ret
|
||||
;-----------------------------------------------------------------------------
|
||||
convert_Sector512_value:
|
||||
@ -112,10 +158,11 @@ convert_Sector512_value:
|
||||
;-----------------------------------------------------------------------------
|
||||
; Адрес считываемого сектора в режиме LBA
|
||||
uglobal
|
||||
SectorAddress DD ?
|
||||
SectorAddress dd ?
|
||||
dev_name:
|
||||
rb 41
|
||||
endg
|
||||
;-----------------------------------------------------------------------------
|
||||
;*************************************************
|
||||
;* ЧТЕНИЕ ИДЕНТИФИКАТОРА ЖЕСТКОГО ДИСКА *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
@ -131,32 +178,32 @@ ReadHDD_ID:
|
||||
; Послать команду идентификации устройства
|
||||
mov [ATAFeatures], 0
|
||||
mov [ATAHead], 0
|
||||
mov [ATACommand], 0ECh
|
||||
mov [ATACommand], 0xEC
|
||||
call SendCommandToHDD
|
||||
cmp [DevErrorCode], 0;проверить код ошибки
|
||||
cmp [DevErrorCode], 0 ;проверить код ошибки
|
||||
jne @@End ;закончить, сохранив код ошибки
|
||||
mov DX, [ATABasePortAddr]
|
||||
add DX, 7 ;адрес регистра состояни
|
||||
|
||||
mov dx, [ATABasePortAddr]
|
||||
add dx, 7 ;адрес регистра состояни
|
||||
mov ecx, 0xffff
|
||||
@@WaitCompleet:
|
||||
; Проверить время выполнения команды
|
||||
dec ecx
|
||||
; cmp ecx,0
|
||||
jz @@Error1 ;ошибка тайм-аута
|
||||
; Проверить готовность
|
||||
in AL, DX
|
||||
test AL, 80h ;состояние сигнала BSY
|
||||
in al, dx
|
||||
test al, 80h ;состояние сигнала BSY
|
||||
jnz @@WaitCompleet
|
||||
test AL, 1 ;состояние сигнала ERR
|
||||
|
||||
test al, 1 ;состояние сигнала ERR
|
||||
jnz @@Error6
|
||||
test AL, 08h ;состояние сигнала DRQ
|
||||
|
||||
test al, 08h ;состояние сигнала DRQ
|
||||
jz @@WaitCompleet
|
||||
; Принять блок данных от контроллера
|
||||
; mov AX,DS
|
||||
; mov ES,AX
|
||||
mov EDI, Sector512 ;offset Sector512
|
||||
mov DX, [ATABasePortAddr];регистр данных
|
||||
mov CX, 256 ;число считываемых слов
|
||||
mov edi, Sector512
|
||||
mov dx, [ATABasePortAddr];регистр данных
|
||||
mov cx, 256 ;число считываемых слов
|
||||
rep insw ;принять блок данных
|
||||
ret
|
||||
; Записать код ошибки
|
||||
@ -167,27 +214,24 @@ ReadHDD_ID:
|
||||
mov [DevErrorCode], 6
|
||||
@@End:
|
||||
ret
|
||||
|
||||
|
||||
iglobal
|
||||
; Стандартные базовые адреса каналов 1 и 2
|
||||
StandardATABases DW 1F0h, 170h
|
||||
endg
|
||||
;-----------------------------------------------------------------------------
|
||||
uglobal
|
||||
; Стандартные базовые адреса каналов 1 и 2
|
||||
StandardATABases dw ?, ? ; 1F0h, 170h
|
||||
; Номер канала
|
||||
ChannelNumber DW ?
|
||||
ChannelNumber dw ?
|
||||
; Номер диска
|
||||
DiskNumber DB ?
|
||||
DiskNumber db ?
|
||||
; Базовый адрес группы портов контроллера ATA
|
||||
ATABasePortAddr DW ?
|
||||
ATABasePortAddr dw ?
|
||||
; Параметры ATA-команды
|
||||
ATAFeatures DB ? ;особенности
|
||||
ATASectorCount DB ? ;количество обрабатываемых секторов
|
||||
ATASectorNumber DB ? ;номер начального сектора
|
||||
ATACylinder DW ? ;номер начального цилиндра
|
||||
ATAHead DB ? ;номер начальной головки
|
||||
ATAAddressMode DB ? ;режим адресации (0 - CHS, 1 - LBA)
|
||||
ATACommand DB ? ;код команды, подлежащей выполнению
|
||||
ATAFeatures db ? ;особенности
|
||||
ATASectorCount db ? ;количество обрабатываемых секторов
|
||||
ATASectorNumber db ? ;номер начального сектора
|
||||
ATACylinder dw ? ;номер начального цилиндра
|
||||
ATAHead db ? ;номер начальной головки
|
||||
ATAAddressMode db ? ;режим адресации (0 - CHS, 1 - LBA)
|
||||
ATACommand db ? ;код команды, подлежащей выполнению
|
||||
; Код ошибки (0 - нет ошибок, 1 - превышен допустимый
|
||||
; интервал ожидания, 2 - неверный код режима адресации,
|
||||
; 3 - неверный номер канала, 4 - неверный номер диска,
|
||||
@ -195,6 +239,7 @@ ATACommand DB ? ;код команды, подлежащей выполне
|
||||
; команды)
|
||||
DevErrorCode dd ?
|
||||
endg
|
||||
;-----------------------------------------------------------------------------
|
||||
;****************************************************
|
||||
;* ПОСЛАТЬ КОМАНДУ ЗАДАННОМУ ДИСКУ *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
@ -219,82 +264,78 @@ SendCommandToHDD:
|
||||
cmp [ATAAddressMode], 1
|
||||
ja @@Err2
|
||||
; Проверить корректность номера канала
|
||||
mov BX, [ChannelNumber]
|
||||
cmp BX, 1
|
||||
mov bx, [ChannelNumber]
|
||||
cmp bx, 1
|
||||
jb @@Err3
|
||||
cmp BX, 2
|
||||
|
||||
cmp bx, 2
|
||||
ja @@Err3
|
||||
; Установить базовый адрес
|
||||
dec BX
|
||||
shl BX, 1
|
||||
dec bx
|
||||
shl bx, 1
|
||||
movzx ebx, bx
|
||||
mov AX, [ebx+StandardATABases]
|
||||
mov [ATABasePortAddr], AX
|
||||
mov ax, [ebx+StandardATABases]
|
||||
mov [ATABasePortAddr], ax
|
||||
; Ожидание готовности HDD к приему команды
|
||||
; Выбрать нужный диск
|
||||
mov DX, [ATABasePortAddr]
|
||||
add DX, 6 ;адрес регистра головок
|
||||
mov AL, [DiskNumber]
|
||||
cmp AL, 1 ;проверить номера диска
|
||||
mov dx, [ATABasePortAddr]
|
||||
add dx, 6 ;адрес регистра головок
|
||||
mov al, [DiskNumber]
|
||||
cmp al, 1 ;проверить номера диска
|
||||
ja @@Err4
|
||||
shl AL, 4
|
||||
or AL, 10100000b
|
||||
out DX, AL
|
||||
|
||||
shl al, 4
|
||||
or al, 10100000b
|
||||
out dx, al
|
||||
; Ожидать, пока диск не будет готов
|
||||
inc DX
|
||||
inc dx
|
||||
mov ecx, 0xfff
|
||||
; mov eax,[timer_ticks]
|
||||
; mov [TickCounter_1],eax
|
||||
@@WaitHDReady:
|
||||
; Проверить время ожидани
|
||||
dec ecx
|
||||
; cmp ecx,0
|
||||
jz @@Err1
|
||||
; mov eax,[timer_ticks]
|
||||
; sub eax,[TickCounter_1]
|
||||
; cmp eax,300 ;ожидать 300 тиков
|
||||
; ja @@Err1 ;ошибка тайм-аута
|
||||
; Прочитать регистр состояни
|
||||
in AL, DX
|
||||
in al, dx
|
||||
; Проверить состояние сигнала BSY
|
||||
test AL, 80h
|
||||
test al, 80h
|
||||
jnz @@WaitHDReady
|
||||
; Проверить состояние сигнала DRQ
|
||||
test AL, 08h
|
||||
test al, 08h
|
||||
jnz @@WaitHDReady
|
||||
; Загрузить команду в регистры контроллера
|
||||
cli
|
||||
mov DX, [ATABasePortAddr]
|
||||
inc DX ;регистр "особенностей"
|
||||
mov AL, [ATAFeatures]
|
||||
out DX, AL
|
||||
inc DX ;счетчик секторов
|
||||
mov AL, [ATASectorCount]
|
||||
out DX, AL
|
||||
inc DX ;регистр номера сектора
|
||||
mov AL, [ATASectorNumber]
|
||||
out DX, AL
|
||||
inc DX ;номер цилиндра (младший байт)
|
||||
mov AX, [ATACylinder]
|
||||
out DX, AL
|
||||
inc DX ;номер цилиндра (старший байт)
|
||||
mov AL, AH
|
||||
out DX, AL
|
||||
inc DX ;номер головки/номер диска
|
||||
mov AL, [DiskNumber]
|
||||
shl AL, 4
|
||||
cmp [ATAHead], 0Fh;проверить номер головки
|
||||
mov dx, [ATABasePortAddr]
|
||||
inc dx ;регистр "особенностей"
|
||||
mov al, [ATAFeatures]
|
||||
out dx, AL
|
||||
inc dx ;счетчик секторов
|
||||
mov al, [ATASectorCount]
|
||||
out dx, AL
|
||||
inc dx ;регистр номера сектора
|
||||
mov al, [ATASectorNumber]
|
||||
out dx, AL
|
||||
inc dx ;номер цилиндра (младший байт)
|
||||
mov ax, [ATACylinder]
|
||||
out dx, AL
|
||||
inc dx ;номер цилиндра (старший байт)
|
||||
mov al, AH
|
||||
out dx, AL
|
||||
inc dx ;номер головки/номер диска
|
||||
mov al, [DiskNumber]
|
||||
shl al, 4
|
||||
cmp [ATAHead], 0xF ;проверить номер головки
|
||||
ja @@Err5
|
||||
or AL, [ATAHead]
|
||||
or AL, 10100000b
|
||||
mov AH, [ATAAddressMode]
|
||||
shl AH, 6
|
||||
or AL, AH
|
||||
out DX, AL
|
||||
|
||||
or al, [ATAHead]
|
||||
or al, 10100000b
|
||||
mov ah, [ATAAddressMode]
|
||||
shl ah, 6
|
||||
or al, ah
|
||||
out dx, al
|
||||
; Послать команду
|
||||
mov AL, [ATACommand]
|
||||
inc DX ;регистр команд
|
||||
out DX, AL
|
||||
mov al, [ATACommand]
|
||||
inc dx ;регистр команд
|
||||
out dx, al
|
||||
sti
|
||||
; Сбросить признак ошибки
|
||||
mov [DevErrorCode], 0
|
||||
@ -316,7 +357,7 @@ SendCommandToHDD:
|
||||
mov [DevErrorCode], 5
|
||||
; Завершение работы программы
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
;*************************************************
|
||||
;* ЧТЕНИЕ ИДЕНТИФИКАТОРА УСТРОЙСТВА ATAPI *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
@ -335,33 +376,32 @@ ReadCD_ID:
|
||||
mov [ATASectorNumber], 0
|
||||
mov [ATACylinder], 0
|
||||
mov [ATAHead], 0
|
||||
mov [ATACommand], 0A1h
|
||||
mov [ATACommand], 0xA1
|
||||
call SendCommandToHDD
|
||||
cmp [DevErrorCode], 0;проверить код ошибки
|
||||
jne @@End_1 ;закончить, сохранив код ошибки
|
||||
; Ожидать готовность данных HDD
|
||||
mov DX, [ATABasePortAddr]
|
||||
add DX, 7 ;порт 1х7h
|
||||
mov dx, [ATABasePortAddr]
|
||||
add dx, 7 ;порт 1х7h
|
||||
mov ecx, 0xffff
|
||||
@@WaitCompleet_1:
|
||||
; Проверить врем
|
||||
dec ecx
|
||||
; cmp ecx,0
|
||||
jz @@Error1_1 ;ошибка тайм-аута
|
||||
; Проверить готовность
|
||||
in AL, DX
|
||||
test AL, 80h ;состояние сигнала BSY
|
||||
in al, dx
|
||||
test al, 80h ;состояние сигнала BSY
|
||||
jnz @@WaitCompleet_1
|
||||
test AL, 1 ;состояние сигнала ERR
|
||||
|
||||
test al, 1 ;состояние сигнала ERR
|
||||
jnz @@Error6_1
|
||||
test AL, 08h ;состояние сигнала DRQ
|
||||
|
||||
test al, 08h ;состояние сигнала DRQ
|
||||
jz @@WaitCompleet_1
|
||||
; Принять блок данных от контроллера
|
||||
; mov AX,DS
|
||||
; mov ES,AX
|
||||
mov EDI, Sector512 ;offset Sector512
|
||||
mov DX, [ATABasePortAddr];порт 1x0h
|
||||
mov CX, 256;число считываемых слов
|
||||
mov edi, Sector512 ;offset Sector512
|
||||
mov dx, [ATABasePortAddr];порт 1x0h
|
||||
mov cx, 256;число считываемых слов
|
||||
rep insw
|
||||
ret
|
||||
; Записать код ошибки
|
||||
@ -372,7 +412,7 @@ ReadCD_ID:
|
||||
mov [DevErrorCode], 6
|
||||
@@End_1:
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
;*************************************************
|
||||
;* СБРОС УСТРОЙСТВА *
|
||||
;* Входные параметры передаются через глобальные *
|
||||
@ -382,39 +422,40 @@ ReadCD_ID:
|
||||
;*************************************************
|
||||
DeviceReset:
|
||||
; Проверить корректность номера канала
|
||||
mov BX, [ChannelNumber]
|
||||
cmp BX, 1
|
||||
mov bx, [ChannelNumber]
|
||||
cmp bx, 1
|
||||
jb @@Err3_2
|
||||
cmp BX, 2
|
||||
|
||||
cmp bx, 2
|
||||
ja @@Err3_2
|
||||
; Установить базовый адрес
|
||||
dec BX
|
||||
shl BX, 1
|
||||
dec bx
|
||||
shl bx, 1
|
||||
movzx ebx, bx
|
||||
mov DX, [ebx+StandardATABases]
|
||||
mov [ATABasePortAddr], DX
|
||||
mov dx, [ebx+StandardATABases]
|
||||
mov [ATABasePortAddr], dx
|
||||
; Выбрать нужный диск
|
||||
add DX, 6 ;адрес регистра головок
|
||||
mov AL, [DiskNumber]
|
||||
cmp AL, 1 ;проверить номера диска
|
||||
add dx, 6 ;адрес регистра головок
|
||||
mov al, [DiskNumber]
|
||||
cmp al, 1 ;проверить номера диска
|
||||
ja @@Err4_2
|
||||
shl AL, 4
|
||||
or AL, 10100000b
|
||||
out DX, AL
|
||||
|
||||
shl al, 4
|
||||
or al, 10100000b
|
||||
out dx, al
|
||||
; Послать команду "Сброс"
|
||||
mov AL, 08h
|
||||
inc DX ;регистр команд
|
||||
out DX, AL
|
||||
mov al, 0x8
|
||||
inc dx ;регистр команд
|
||||
out dx, al
|
||||
mov ecx, 0x80000
|
||||
@@WaitHDReady_1:
|
||||
; Проверить время ожидани
|
||||
dec ecx
|
||||
; cmp ecx,0
|
||||
je @@Err1_2 ;ошибка тайм-аута
|
||||
; Прочитать регистр состояни
|
||||
in AL, DX
|
||||
in al, dx
|
||||
; Проверить состояние сигнала BSY
|
||||
test AL, 80h
|
||||
test al, 80h
|
||||
jnz @@WaitHDReady_1
|
||||
; Сбросить признак ошибки
|
||||
mov [DevErrorCode], 0
|
||||
@ -430,6 +471,5 @@ DeviceReset:
|
||||
mov [DevErrorCode], 4
|
||||
; Записать код ошибки
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
EndFindHDD:
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
$Revision$
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
pusha
|
||||
|
||||
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
|
||||
cmp eax, 1024*1024
|
||||
jbe @f
|
||||
|
||||
mov eax, 1024*1024
|
||||
jmp .continue
|
||||
;--------------------------------------
|
||||
@@:
|
||||
; check a lower size of the cache, not less than 128 Kb on the physical device
|
||||
cmp eax, 128*1024
|
||||
jae @f
|
||||
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
|
||||
jae .continue
|
||||
|
||||
test byte [DRIVE_DATA+1], 2
|
||||
je .ide2
|
||||
mov esi, cache_ide3
|
||||
call get_cache_ide
|
||||
.ide2:
|
||||
test byte [DRIVE_DATA+1], 8
|
||||
je .ide1
|
||||
mov esi, cache_ide2
|
||||
call get_cache_ide
|
||||
.ide1:
|
||||
test byte [DRIVE_DATA+1], 0x20
|
||||
je .ide0
|
||||
mov esi, cache_ide1
|
||||
call get_cache_ide
|
||||
.ide0:
|
||||
mov eax, 128*1024
|
||||
;--------------------------------------
|
||||
.continue:
|
||||
push ecx
|
||||
mov ecx, 12
|
||||
mov esi, cache_ide0+IDE_CACHE.size
|
||||
cld
|
||||
@@:
|
||||
mov [esi], eax
|
||||
add esi, sizeof.IDE_CACHE
|
||||
loop @b
|
||||
|
||||
pop ecx
|
||||
|
||||
xor eax, eax
|
||||
mov [hdd_appl_data], 1 ;al
|
||||
mov [cd_appl_data], 1
|
||||
;--------------------------------------
|
||||
test byte [DRIVE_DATA+1], 0x80
|
||||
je @f
|
||||
|
||||
mov esi, cache_ide0
|
||||
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:
|
||||
and [esi+cache_ide0_search_start-cache_ide0], 0
|
||||
and [esi+cache_ide0_appl_search_start-cache_ide0], 0
|
||||
and [esi+IDE_CACHE.search_start], 0
|
||||
and [esi+IDE_CACHE.appl_search_start], 0
|
||||
|
||||
push ecx
|
||||
stdcall kernel_alloc, [esi+cache_ide0_size-cache_ide0]
|
||||
mov [esi+cache_ide0_pointer-cache_ide0], eax
|
||||
DEBUGF 1, "K : IDE_CACHE.size %x\n", [esi+IDE_CACHE.size]
|
||||
stdcall kernel_alloc, [esi+IDE_CACHE.size]
|
||||
mov [esi+IDE_CACHE.pointer], eax
|
||||
pop ecx
|
||||
|
||||
mov edx, eax
|
||||
mov eax, [esi+cache_ide0_size-cache_ide0]
|
||||
mov eax, [esi+IDE_CACHE.size]
|
||||
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
|
||||
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
|
||||
mov [esi+cache_ide0_data_pointer-cache_ide0], ebx
|
||||
mov [esi+IDE_CACHE.data_pointer], ebx
|
||||
|
||||
.cd:
|
||||
push ecx
|
||||
mov eax, [esi+cache_ide0_system_data_size-cache_ide0]
|
||||
mov eax, [esi+IDE_CACHE.system_data_size]
|
||||
call calculate_for_cd
|
||||
add eax, [esi+cache_ide0_pointer-cache_ide0]
|
||||
mov [esi+cache_ide0_system_data-cache_ide0], eax
|
||||
mov [esi+cache_ide0_system_sad_size-cache_ide0], ecx
|
||||
add eax, [esi+IDE_CACHE.pointer]
|
||||
mov [esi+IDE_CACHE.system_data], eax
|
||||
mov [esi+IDE_CACHE.system_sad_size], ecx
|
||||
|
||||
push edi
|
||||
mov edi, [esi+cache_ide0_pointer-cache_ide0]
|
||||
mov edi, [esi+IDE_CACHE.pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
mov eax, [esi+cache_ide0_appl_data_size-cache_ide0]
|
||||
mov eax, [esi+IDE_CACHE.appl_data_size]
|
||||
call calculate_for_cd
|
||||
add eax, [esi+cache_ide0_data_pointer-cache_ide0]
|
||||
mov [esi+cache_ide0_appl_data-cache_ide0], eax
|
||||
mov [esi+cache_ide0_appl_sad_size-cache_ide0], ecx
|
||||
add eax, [esi+IDE_CACHE.data_pointer]
|
||||
mov [esi+IDE_CACHE.appl_data], eax
|
||||
mov [esi+IDE_CACHE.appl_sad_size], ecx
|
||||
|
||||
push edi
|
||||
mov edi, [esi+cache_ide0_data_pointer-cache_ide0]
|
||||
mov edi, [esi+IDE_CACHE.data_pointer]
|
||||
call clear_ide_cache
|
||||
pop edi
|
||||
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
calculate_for_cd:
|
||||
push eax
|
||||
mov ebx, eax
|
||||
@ -116,7 +195,7 @@ calculate_for_cd:
|
||||
sub eax, ebx
|
||||
dec ecx
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
clear_ide_cache:
|
||||
push eax
|
||||
shl ecx, 1
|
||||
@ -125,6 +204,6 @@ clear_ide_cache:
|
||||
rep stosd
|
||||
pop eax
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
end_get_cache:
|
||||
popa
|
||||
|
@ -1,111 +1,151 @@
|
||||
;-----------------------------------------------------------------------------
|
||||
; find the IDE controller in the device list
|
||||
;-----------------------------------------------------------------------------
|
||||
mov ecx, IDE_controller_1
|
||||
mov esi, pcidev_list
|
||||
;--------------------------------------
|
||||
align 4
|
||||
.loop:
|
||||
mov esi, [esi+PCIDEV.fd]
|
||||
cmp esi, pcidev_list
|
||||
jz .done
|
||||
jz find_IDE_controller_done
|
||||
|
||||
mov eax, [esi+PCIDEV.class]
|
||||
shr eax, 4
|
||||
cmp eax, 0x01018
|
||||
jnz .loop
|
||||
;--------------------------------------
|
||||
.found:
|
||||
mov eax, [esi+PCIDEV.class]
|
||||
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 al, 2
|
||||
mov bh, [esi+PCIDEV.devfn]
|
||||
;-----------------------------------------------------------------------------
|
||||
;--------------------------------------
|
||||
mov bl, 0x10
|
||||
push eax
|
||||
call pci_read_reg
|
||||
and eax, 0xFFFC
|
||||
cmp ax, 0
|
||||
je @f
|
||||
|
||||
cmp ax, 1
|
||||
jne .show_BAR0
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov ax, 0x1F0
|
||||
;--------------------------------------
|
||||
.show_BAR0:
|
||||
DEBUGF 1, 'K : BAR0 IDE base addr %x\n', ax
|
||||
mov [StandardATABases], ax
|
||||
mov [hd_address_table], eax
|
||||
mov [hd_address_table+8], eax
|
||||
mov [IDE_BAR0_val], ax
|
||||
mov [ecx+IDE_DATA.BAR0_val], ax
|
||||
pop eax
|
||||
;-----------------------------------------------------------------------------
|
||||
;--------------------------------------
|
||||
mov bl, 0x14
|
||||
push eax
|
||||
call pci_read_reg
|
||||
and eax, 0xFFFC
|
||||
cmp ax, 0
|
||||
je @f
|
||||
|
||||
cmp ax, 1
|
||||
jne .show_BAR1
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov ax, 0x3F4
|
||||
;--------------------------------------
|
||||
.show_BAR1:
|
||||
DEBUGF 1, 'K : BAR1 IDE base addr %x\n', ax
|
||||
mov [IDE_BAR1_val], ax
|
||||
mov [ecx+IDE_DATA.BAR1_val], ax
|
||||
pop eax
|
||||
;-----------------------------------------------------------------------------
|
||||
;--------------------------------------
|
||||
mov bl, 0x18
|
||||
push eax
|
||||
call pci_read_reg
|
||||
and eax, 0xFFFC
|
||||
cmp ax, 0
|
||||
je @f
|
||||
|
||||
cmp ax, 1
|
||||
jne .show_BAR2
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov ax, 0x170
|
||||
;--------------------------------------
|
||||
.show_BAR2:
|
||||
DEBUGF 1, 'K : BAR2 IDE base addr %x\n', ax
|
||||
mov [StandardATABases+2], ax
|
||||
mov [hd_address_table+16], eax
|
||||
mov [hd_address_table+24], eax
|
||||
mov [IDE_BAR2_val], ax
|
||||
mov [ecx+IDE_DATA.BAR2_val], ax
|
||||
pop eax
|
||||
;-----------------------------------------------------------------------------
|
||||
;--------------------------------------
|
||||
mov bl, 0x1C
|
||||
push eax
|
||||
call pci_read_reg
|
||||
and eax, 0xFFFC
|
||||
cmp ax, 0
|
||||
je @f
|
||||
|
||||
cmp ax, 1
|
||||
jne .show_BAR3
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov ax, 0x374
|
||||
;--------------------------------------
|
||||
.show_BAR3:
|
||||
DEBUGF 1, 'K : BAR3 IDE base addr %x\n', ax
|
||||
mov [IDE_BAR3_val], ax
|
||||
mov [ecx+IDE_DATA.BAR3_val], ax
|
||||
pop eax
|
||||
;-----------------------------------------------------------------------------
|
||||
;--------------------------------------
|
||||
mov bl, 0x20
|
||||
push eax
|
||||
call pci_read_reg
|
||||
and eax, 0xFFFC
|
||||
DEBUGF 1, 'K : BAR4 IDE controller register base addr %x\n', ax
|
||||
mov [IDEContrRegsBaseAddr], ax
|
||||
mov [ecx+IDE_DATA.RegsBaseAddres], ax
|
||||
pop eax
|
||||
;-----------------------------------------------------------------------------
|
||||
;--------------------------------------
|
||||
mov bl, 0x3C
|
||||
push eax
|
||||
call pci_read_reg
|
||||
and eax, 0xFF
|
||||
DEBUGF 1, 'K : IDE Interrupt %x\n', al
|
||||
mov [IDE_Interrupt], ax
|
||||
mov [ecx+IDE_DATA.Interrupt], ax
|
||||
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
|
||||
;-----------------------------------------------------------------------------
|
||||
cmp [IDEContrProgrammingInterface], 0
|
||||
Init_IDE_ATA_controller:
|
||||
cmp [ecx+IDE_DATA.ProgrammingInterface], 0
|
||||
je set_interrupts_for_IDE_controllers.continue
|
||||
|
||||
mov esi, boot_disabling_ide
|
||||
@ -117,33 +157,25 @@
|
||||
.disable_IDE_interrupt:
|
||||
; Disable interrupts in IDE controller for PIO
|
||||
mov al, 2
|
||||
mov dx, [IDE_BAR1_val] ;0x3F4
|
||||
mov dx, [ecx+IDE_DATA.BAR1_val] ;0x3F4
|
||||
add dx, 2 ;0x3F6
|
||||
out dx, al
|
||||
mov dx, [IDE_BAR3_val] ;0x374
|
||||
mov dx, [ecx+IDE_DATA.BAR3_val] ;0x374
|
||||
add dx, 2 ;0x376
|
||||
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
|
||||
call boot_log
|
||||
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?
|
||||
add dx, 2
|
||||
in al, dx
|
||||
@ -152,6 +184,7 @@ include 'sear_par.inc'
|
||||
; clear Bus Master IDE Status register
|
||||
; clear Interrupt bit
|
||||
out dx, al
|
||||
;--------------------------------------
|
||||
@@:
|
||||
add dx, 8
|
||||
; test whether it is our interrupt?
|
||||
@ -161,17 +194,18 @@ include 'sear_par.inc'
|
||||
; clear Bus Master IDE Status register
|
||||
; clear Interrupt bit
|
||||
out dx, al
|
||||
;--------------------------------------
|
||||
@@:
|
||||
; 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
|
||||
in al, dx
|
||||
mov dx, [IDE_BAR2_val] ;0x170
|
||||
mov dx, [ecx+IDE_DATA.BAR2_val] ;0x170
|
||||
add dx, 0x7 ;0x177
|
||||
in al, dx
|
||||
;-----------------------------------------------------------------------------
|
||||
push eax edx
|
||||
mov dx, [IDEContrRegsBaseAddr]
|
||||
mov dx, [ecx+IDE_DATA.RegsBaseAddres]
|
||||
xor eax, eax
|
||||
add dx, 2
|
||||
in al, dx
|
||||
@ -182,15 +216,15 @@ include 'sear_par.inc'
|
||||
DEBUGF 1, "K : Secondary Bus Master IDE Status Register %x\n", eax
|
||||
pop edx eax
|
||||
|
||||
cmp [IDEContrRegsBaseAddr], 0
|
||||
setnz [dma_hdd]
|
||||
cmp [ecx+IDE_DATA.RegsBaseAddres], 0
|
||||
setnz [ecx+IDE_DATA.dma_hdd]
|
||||
;-----------------------------------------------------------------------------
|
||||
; set interrupts for IDE Controller
|
||||
;-----------------------------------------------------------------------------
|
||||
mov esi, boot_set_int_IDE
|
||||
call boot_log
|
||||
set_interrupts_for_IDE_controllers:
|
||||
mov eax, [IDEContrProgrammingInterface]
|
||||
mov eax, [ecx+IDE_DATA.ProgrammingInterface]
|
||||
cmp ax, 0x0180
|
||||
je .pata_ide
|
||||
|
||||
@ -198,13 +232,16 @@ set_interrupts_for_IDE_controllers:
|
||||
jne .sata_ide
|
||||
;--------------------------------------
|
||||
.pata_ide:
|
||||
cmp [IDEContrRegsBaseAddr], 0
|
||||
cmp [ecx+IDE_DATA.RegsBaseAddres], 0
|
||||
je .end_set_interrupts
|
||||
|
||||
push ecx
|
||||
stdcall attach_int_handler, 14, IDE_irq_14_handler, 0
|
||||
DEBUGF 1, "K : Set IDE IRQ14 return code %x\n", eax
|
||||
stdcall attach_int_handler, 15, IDE_irq_15_handler, 0
|
||||
DEBUGF 1, "K : Set IDE IRQ15 return code %x\n", eax
|
||||
pop ecx
|
||||
|
||||
jmp .enable_IDE_interrupt
|
||||
;--------------------------------------
|
||||
.sata_ide:
|
||||
@ -215,53 +252,93 @@ set_interrupts_for_IDE_controllers:
|
||||
jne .end_set_interrupts
|
||||
;--------------------------------------
|
||||
.sata_ide_1:
|
||||
cmp [IDEContrRegsBaseAddr], 0
|
||||
cmp [ecx+IDE_DATA.RegsBaseAddres], 0
|
||||
je .end_set_interrupts
|
||||
|
||||
mov ax, [IDE_Interrupt]
|
||||
mov ax, [ecx+IDE_DATA.Interrupt]
|
||||
movzx eax, al
|
||||
push ecx
|
||||
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:
|
||||
mov esi, boot_enabling_ide
|
||||
call boot_log
|
||||
; 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 ah, [DRIVE_DATA+1]
|
||||
mov ah, [ebx+DRIVE_DATA+1]
|
||||
test ah, 10100000b
|
||||
jz @f
|
||||
|
||||
DEBUGF 1, "K : IDE CH1 PIO, because ATAPI drive present\n"
|
||||
jmp .ch2_check
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov dx, [IDE_BAR1_val] ;0x3F4
|
||||
mov dx, [ecx+IDE_DATA.BAR1_val] ;0x3F4
|
||||
add dx, 2 ;0x3F6
|
||||
out dx, al
|
||||
DEBUGF 1, "K : IDE CH1 DMA enabled\n"
|
||||
;--------------------------------------
|
||||
.ch2_check:
|
||||
test ah, 1010b
|
||||
jz @f
|
||||
|
||||
DEBUGF 1, "K : IDE CH2 PIO, because ATAPI drive present\n"
|
||||
jmp .end_set_interrupts
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov dx, [IDE_BAR3_val] ;0x374
|
||||
mov dx, [ecx+IDE_DATA.BAR3_val] ;0x374
|
||||
add dx, 2 ;0x376
|
||||
out dx, al
|
||||
DEBUGF 1, "K : IDE CH2 DMA enabled\n"
|
||||
;--------------------------------------
|
||||
.end_set_interrupts:
|
||||
;-----------------------------------------------------------------------------
|
||||
cmp [dma_hdd], 0
|
||||
cmp [ecx+IDE_DATA.dma_hdd], 0
|
||||
je .print_pio
|
||||
;--------------------------------------
|
||||
.print_dma:
|
||||
DEBUGF 1, "K : IDE DMA mode\n"
|
||||
jmp .continue
|
||||
|
||||
;--------------------------------------
|
||||
.print_pio:
|
||||
DEBUGF 1, "K : IDE PIO mode\n"
|
||||
.continue:
|
||||
ret
|
||||
;-----------------------------------------------------------------------------
|
||||
; 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'
|
||||
;-----------------------------------------------------------------------------
|
||||
|
@ -8,63 +8,203 @@
|
||||
$Revision$
|
||||
|
||||
search_partitions:
|
||||
push ecx
|
||||
; 1. Fill missing parameters in HD_DATA structures.
|
||||
mov eax, [hd_address_table]
|
||||
mov [hd0_data.hdbase], eax ;0x1f0
|
||||
xor eax, eax
|
||||
mov edx, IDE_controller_1
|
||||
mov ax, [edx + IDE_DATA.BAR0_val]
|
||||
mov [hd0_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 [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.
|
||||
; For every existing disk, call ide_disk_add with correct parameters.
|
||||
; 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,
|
||||
; data: hd0_data,
|
||||
; number of partitions: [DRIVE_DATA+2]
|
||||
test [DRIVE_DATA+1], byte 0x40
|
||||
jz @f
|
||||
DEBUGF 1, "K : HD0\n"
|
||||
push 'hd0'
|
||||
mov eax, esp ; name
|
||||
mov edx, hd0_data
|
||||
call ide_disk_add
|
||||
mov [DRIVE_DATA+2], al
|
||||
pop ecx ; restore the stack
|
||||
;-----------------------------------------------------------------------------
|
||||
@@:
|
||||
; 2b. /hd1: exists if mask 0x10 in [DRIVE_DATA+1] is set,
|
||||
; data: hd1_data,
|
||||
; number of partitions: [DRIVE_DATA+3]
|
||||
test [DRIVE_DATA+1], byte 0x10
|
||||
jz @f
|
||||
DEBUGF 1, "K : HD1\n"
|
||||
push 'hd1'
|
||||
mov eax, esp
|
||||
mov edx, hd1_data
|
||||
call ide_disk_add
|
||||
mov [DRIVE_DATA+3], al
|
||||
pop ecx
|
||||
;-----------------------------------------------------------------------------
|
||||
@@:
|
||||
; 2c. /hd2: exists if mask 4 in [DRIVE_DATA+1] is set,
|
||||
; data: hd2_data,
|
||||
; number of partitions: [DRIVE_DATA+4]
|
||||
test [DRIVE_DATA+1], byte 4
|
||||
jz @f
|
||||
DEBUGF 1, "K : HD2\n"
|
||||
push 'hd2'
|
||||
mov eax, esp
|
||||
mov edx, hd2_data
|
||||
call ide_disk_add
|
||||
mov [DRIVE_DATA+4], al
|
||||
pop ecx
|
||||
;-----------------------------------------------------------------------------
|
||||
@@:
|
||||
; 2d. /hd3: exists if mask 1 in [DRIVE_DATA+1] is set,
|
||||
; data: hd3_data,
|
||||
; number of partitions: [DRIVE_DATA+5]
|
||||
test [DRIVE_DATA+1], byte 1
|
||||
jz @f
|
||||
DEBUGF 1, "K : HD3\n"
|
||||
push 'hd3'
|
||||
mov eax, esp
|
||||
mov edx, hd3_data
|
||||
call ide_disk_add
|
||||
mov [DRIVE_DATA+5], al
|
||||
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.
|
||||
; 3a. Check whether there are BIOS disks. If no, skip step 3.
|
||||
@ -114,11 +254,12 @@ endg
|
||||
jnz .bdloop
|
||||
pop ecx ecx ; restore stack after name
|
||||
.nobd:
|
||||
DEBUGF 1, "K : jmp end_search_partitions\n"
|
||||
jmp end_search_partitions
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
; Helper procedure for search_partitions, adds one IDE disk.
|
||||
; For compatibility, number of partitions for IDE disks is kept in a separate variable,
|
||||
; so the procedure returns number of partitions.
|
||||
; For compatibility, number of partitions for IDE disks is kept in a separate
|
||||
; variable, so the procedure returns number of partitions.
|
||||
; eax -> name, edx -> disk data
|
||||
proc ide_disk_add
|
||||
stdcall disk_add, ide_callbacks, eax, edx, 0
|
||||
@ -134,6 +275,6 @@ proc ide_disk_add
|
||||
@@:
|
||||
ret
|
||||
endp
|
||||
|
||||
end_search_partitions:
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
end_search_partitions:
|
||||
pop ecx
|
||||
|
@ -845,7 +845,7 @@
|
||||
* eax = 18 - номер функции
|
||||
* ebx = 11 - номер подфункции
|
||||
* ecx = тип таблицы:
|
||||
* 1 = короткая версия, 10 байт
|
||||
* 1 = короткая версия, 16 байт
|
||||
* edx = указатель на буфер (в приложении) для таблицы
|
||||
Возвращаемое значение:
|
||||
* функция не возвращает значения
|
||||
@ -862,6 +862,8 @@
|
||||
Например, для стандартной конфигурации из одного 1.44-дисковода
|
||||
здесь будет 40h, а для случая 1.2Mb на A: и 1.44Mb на B:
|
||||
значение оказывается 24h.
|
||||
|
||||
Первый контроллер IDE:
|
||||
* +1: byte: информация о жёстких дисках и CD-приводах, AABBCCDD,
|
||||
где AA соответствует контроллеру IDE0, ..., DD - IDE3:
|
||||
* 0 = устройство отсутствует
|
||||
@ -870,15 +872,36 @@
|
||||
Например, в случае HD на IDE0 и CD на IDE2 здесь будет 48h.
|
||||
* +2: 4 db: число найденных разделов на жёстких дисках с
|
||||
соответственно 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 соответствующий байт
|
||||
нулевой, при наличии показывает число распознанных разделов,
|
||||
которых может и не быть (если носитель не отформатирован или
|
||||
если файловая система не поддерживается). В текущей версии ядра
|
||||
для жёстких дисков поддерживаются только FAT16, FAT32 и NTFS.
|
||||
* +6: 4 db: зарезервировано
|
||||
для жёстких дисков поддерживаются только FAT12/16/32, NTFS,
|
||||
ext2/3/4 и XFS.
|
||||
|
||||
Замечания:
|
||||
* Короткая таблица может быть использована для получения информации
|
||||
* Таблица может быть использована для получения информации
|
||||
об имеющихся устройствах.
|
||||
|
||||
======================================================================
|
||||
@ -1193,20 +1216,6 @@ dd 1675
|
||||
соответствующую текущей стране иконку.
|
||||
* Приложение @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 - установить язык системы. ========
|
||||
======================================================================
|
||||
@ -1254,122 +1263,6 @@ dd 1675
|
||||
* Текущая реализация использует только младший бит ecx.
|
||||
* Получить текущее состояние можно вызовом подфункции 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 - установить системную дату/время. ===========
|
||||
======================================================================
|
||||
@ -1432,59 +1325,6 @@ dd 1675
|
||||
с eax=0, если сложение ebx с текущим значением счётчика времени
|
||||
вызовет 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 - извлечь лоток привода диска. ======
|
||||
======================================================================
|
||||
@ -1587,18 +1427,6 @@ dd 1675
|
||||
(используя описываемую функцию).
|
||||
* Приложение @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 - получить язык системы. =========
|
||||
======================================================================
|
||||
|
@ -845,7 +845,7 @@ Parameters:
|
||||
* eax = 18 - function number
|
||||
* ebx = 11 - subfunction number
|
||||
* 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
|
||||
Returned 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)
|
||||
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:
|
||||
the value is 24h.
|
||||
the value is 24h.
|
||||
|
||||
First IDE controller:
|
||||
* +1: byte: information about hard disks and CD-drives, AABBCCDD,
|
||||
where AA corresponds to the controller IDE0, ..., DD - IDE3:
|
||||
* 0 = device is absent
|
||||
* 0 = device not found
|
||||
* 1 = hard drive
|
||||
* 2 = CD-drive
|
||||
For example, in the case HD on IDE0 and CD on IDE2
|
||||
this field contains 48h.
|
||||
* +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,
|
||||
otherwise it shows number of the recognized partitions, which
|
||||
can be not presented (if the drive is not formatted or if
|
||||
the file system is not supported). Current version of the kernel
|
||||
supports only FAT16, FAT32 and NTFS for hard disks.
|
||||
* +6: 4 db: reserved
|
||||
supports only FAT12/16/32, NTFS, ext2/3/4 and XFS for hard disks.
|
||||
|
||||
Remarks:
|
||||
* The short table can be used for obtaining the information about
|
||||
* The table can be used for obtaining the information about
|
||||
available devices.
|
||||
|
||||
======================================================================
|
||||
@ -1193,19 +1217,6 @@ Remarks:
|
||||
the corresponding icon.
|
||||
* 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. =========
|
||||
======================================================================
|
||||
@ -1251,120 +1262,6 @@ Remarks:
|
||||
* The current implementation uses only low bit of ecx.
|
||||
* 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. ================
|
||||
======================================================================
|
||||
@ -1426,58 +1323,6 @@ Remarks:
|
||||
if the addition of ebx with the current value of time counter
|
||||
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. =======
|
||||
======================================================================
|
||||
@ -1577,18 +1422,6 @@ Remarks:
|
||||
the corresponding icon (using this function).
|
||||
* 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. =========
|
||||
======================================================================
|
||||
|
@ -43,6 +43,30 @@ rootdirs:
|
||||
db 3,'cd3'
|
||||
dd fs_OnCd3
|
||||
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
|
||||
|
||||
@ -57,6 +81,22 @@ virtual_root_query:
|
||||
db 'cd2',0
|
||||
dd fs_HasCd3
|
||||
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
|
||||
endg
|
||||
@ -149,8 +189,8 @@ file_system_lfn:
|
||||
cmp dword [ebx], 1
|
||||
jnz .access_denied
|
||||
xor eax, eax
|
||||
mov ebp, [ebx+12] ;количество блоков для считывания
|
||||
mov edx, [ebx+16] ;куда записывать рузельтат
|
||||
mov ebp, [ebx+12] ;the number of blocks to read
|
||||
mov edx, [ebx+16] ;where to write the result
|
||||
; add edx, std_application_base_address
|
||||
push dword [ebx+4] ; first block
|
||||
mov ebx, [ebx+8] ; flags
|
||||
@ -404,8 +444,7 @@ file_system_lfn:
|
||||
fs_NotImplemented:
|
||||
mov eax, 2
|
||||
ret
|
||||
|
||||
;*******************************************************
|
||||
;-----------------------------------------------------------------------------
|
||||
fs_OnCd0:
|
||||
call reserve_cd
|
||||
mov [ChannelNumber], 1
|
||||
@ -413,6 +452,7 @@ fs_OnCd0:
|
||||
push 6
|
||||
push 1
|
||||
jmp fs_OnCd
|
||||
;-----------------------------------------------------------------------------
|
||||
fs_OnCd1:
|
||||
call reserve_cd
|
||||
mov [ChannelNumber], 1
|
||||
@ -420,6 +460,7 @@ fs_OnCd1:
|
||||
push 4
|
||||
push 2
|
||||
jmp fs_OnCd
|
||||
;-----------------------------------------------------------------------------
|
||||
fs_OnCd2:
|
||||
call reserve_cd
|
||||
mov [ChannelNumber], 2
|
||||
@ -427,22 +468,96 @@ fs_OnCd2:
|
||||
push 2
|
||||
push 3
|
||||
jmp fs_OnCd
|
||||
;-----------------------------------------------------------------------------
|
||||
fs_OnCd3:
|
||||
call reserve_cd
|
||||
mov [ChannelNumber], 2
|
||||
mov [DiskNumber], 1
|
||||
push 0
|
||||
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:
|
||||
call reserve_cd_channel
|
||||
pop eax
|
||||
mov [cdpos], eax
|
||||
call reserve_cd_channel
|
||||
pop eax
|
||||
cmp ecx, 0x100
|
||||
jae .nf
|
||||
push ecx ebx
|
||||
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
|
||||
test bl, 2
|
||||
pop ebx ecx
|
||||
@ -472,7 +587,7 @@ fs_OnCd:
|
||||
and [cd_status], 0
|
||||
mov dword [image_of_eax], 2 ; not implemented
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
fs_CdServices:
|
||||
dd fs_CdRead
|
||||
dd fs_CdReadFolder
|
||||
@ -485,32 +600,74 @@ fs_CdServices:
|
||||
dd fs_NotImplemented
|
||||
dd fs_NotImplemented
|
||||
fs_NumCdServices = ($ - fs_CdServices)/4
|
||||
|
||||
;*******************************************************
|
||||
;-----------------------------------------------------------------------------
|
||||
fs_HasCd0:
|
||||
test byte [DRIVE_DATA+1], 10000000b
|
||||
setnz al
|
||||
ret
|
||||
;--------------------------------------
|
||||
fs_HasCd1:
|
||||
test byte [DRIVE_DATA+1], 00100000b
|
||||
setnz al
|
||||
ret
|
||||
;--------------------------------------
|
||||
fs_HasCd2:
|
||||
test byte [DRIVE_DATA+1], 00001000b
|
||||
setnz al
|
||||
ret
|
||||
;--------------------------------------
|
||||
fs_HasCd3:
|
||||
test byte [DRIVE_DATA+1], 00000010b
|
||||
setnz al
|
||||
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:
|
||||
; in: eax = partition number, from which start to scan
|
||||
; out: CF=1 => no more partitions
|
||||
; CF=0 => eax=next partition number
|
||||
|
||||
;*******************************************************
|
||||
;
|
||||
;-----------------------------------------------------------------------------
|
||||
fs_NextCd:
|
||||
; we always have /cdX/1
|
||||
test eax, eax
|
||||
@ -520,8 +677,6 @@ fs_NextCd:
|
||||
clc
|
||||
@@:
|
||||
ret
|
||||
;*******************************************************
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
process_replace_file_name:
|
||||
; in
|
||||
|
@ -7,18 +7,15 @@
|
||||
|
||||
$Revision$
|
||||
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
uglobal
|
||||
cd_current_pointer_of_input dd 0
|
||||
cd_current_pointer_of_input_2 dd 0
|
||||
cd_mem_location dd 0
|
||||
cd_counter_block dd 0
|
||||
IDE_Channel_1 db 0
|
||||
IDE_Channel_2 db 0
|
||||
endg
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
reserve_cd:
|
||||
|
||||
cli
|
||||
cmp [cd_status], 0
|
||||
je reserve_ok2
|
||||
@ -26,9 +23,8 @@ reserve_cd:
|
||||
sti
|
||||
call change_task
|
||||
jmp reserve_cd
|
||||
|
||||
reserve_ok2:
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
reserve_ok2:
|
||||
push eax
|
||||
mov eax, [CURRENT_TASK]
|
||||
shl eax, 5
|
||||
@ -37,48 +33,105 @@ reserve_cd:
|
||||
pop eax
|
||||
sti
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
reserve_cd_channel:
|
||||
cmp [ChannelNumber], 1
|
||||
jne .IDE_Channel_2
|
||||
.IDE_Channel_1:
|
||||
pushad
|
||||
mov ecx, ide_channel1_mutex
|
||||
call mutex_lock
|
||||
mov [IDE_Channel_1], 1
|
||||
popad
|
||||
ret
|
||||
.IDE_Channel_2:
|
||||
pushad
|
||||
mov ecx, ide_channel2_mutex
|
||||
call mutex_lock
|
||||
mov [IDE_Channel_2], 1
|
||||
popad
|
||||
ret
|
||||
mov eax, [cdpos]
|
||||
dec eax
|
||||
shr eax, 2
|
||||
|
||||
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:
|
||||
cmp [ChannelNumber], 1
|
||||
jne .IDE_Channel_2
|
||||
.IDE_Channel_1:
|
||||
mov [IDE_Channel_1], 0
|
||||
pushad
|
||||
mov ecx, ide_channel1_mutex
|
||||
call mutex_unlock
|
||||
popad
|
||||
ret
|
||||
.IDE_Channel_2:
|
||||
mov [IDE_Channel_2], 0
|
||||
pushad
|
||||
mov ecx, ide_channel2_mutex
|
||||
call mutex_unlock
|
||||
popad
|
||||
ret
|
||||
mov eax, [cdpos]
|
||||
dec eax
|
||||
shr eax, 2
|
||||
|
||||
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
|
||||
cd_status dd 0
|
||||
endg
|
||||
|
||||
;----------------------------------------------------------------
|
||||
;-----------------------------------------------------------------------------
|
||||
;
|
||||
; fs_CdRead - LFN variant for reading CD disk
|
||||
;
|
||||
@ -91,91 +144,114 @@ endg
|
||||
; ret ebx = bytes read or 0xffffffff file not found
|
||||
; eax = 0 ok read or other = errormsg
|
||||
;
|
||||
;--------------------------------------------------------------
|
||||
;-----------------------------------------------------------------------------
|
||||
fs_CdRead:
|
||||
push edi
|
||||
cmp byte [esi], 0
|
||||
jnz @f
|
||||
;--------------------------------------
|
||||
.noaccess:
|
||||
pop edi
|
||||
;--------------------------------------
|
||||
.noaccess_2:
|
||||
or ebx, -1
|
||||
mov eax, ERROR_ACCESS_DENIED
|
||||
ret
|
||||
|
||||
;--------------------------------------
|
||||
.noaccess_3:
|
||||
pop eax edx ecx edi
|
||||
jmp .noaccess_2
|
||||
|
||||
;--------------------------------------
|
||||
@@:
|
||||
call cd_find_lfn
|
||||
jnc .found
|
||||
|
||||
pop edi
|
||||
cmp [DevErrorCode], 0
|
||||
jne .noaccess_2
|
||||
|
||||
or ebx, -1
|
||||
mov eax, ERROR_FILE_NOT_FOUND
|
||||
ret
|
||||
|
||||
;--------------------------------------
|
||||
.found:
|
||||
mov edi, [cd_current_pointer_of_input]
|
||||
test byte [edi+25], 10b; do not allow read directories
|
||||
jnz .noaccess
|
||||
|
||||
test ebx, ebx
|
||||
jz .l1
|
||||
|
||||
cmp dword [ebx+4], 0
|
||||
jz @f
|
||||
|
||||
xor ebx, ebx
|
||||
;--------------------------------------
|
||||
.reteof:
|
||||
mov eax, 6; end of file
|
||||
pop edi
|
||||
ret
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov ebx, [ebx]
|
||||
;--------------------------------------
|
||||
.l1:
|
||||
push ecx edx
|
||||
push 0
|
||||
mov eax, [edi+10] ; реальный размер файловой секции
|
||||
mov eax, [edi+10] ; real size of the file section
|
||||
sub eax, ebx
|
||||
jb .eof
|
||||
|
||||
cmp eax, ecx
|
||||
jae @f
|
||||
|
||||
mov ecx, eax
|
||||
mov byte [esp], 6
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov eax, [edi+2]
|
||||
mov [CDSectorAddress], eax
|
||||
;--------------------------------------
|
||||
; now eax=cluster, ebx=position, ecx=count, edx=buffer for data
|
||||
.new_sector:
|
||||
test ecx, ecx
|
||||
jz .done
|
||||
|
||||
sub ebx, 2048
|
||||
jae .next
|
||||
|
||||
add ebx, 2048
|
||||
jnz .incomplete_sector
|
||||
|
||||
cmp ecx, 2048
|
||||
jb .incomplete_sector
|
||||
; we may read and memmove complete sector
|
||||
mov [CDDataBuf_pointer], edx
|
||||
call ReadCDWRetr; читаем сектор файла
|
||||
call ReadCDWRetr ; read sector of file
|
||||
cmp [DevErrorCode], 0
|
||||
jne .noaccess_3
|
||||
|
||||
add edx, 2048
|
||||
sub ecx, 2048
|
||||
;--------------------------------------
|
||||
.next:
|
||||
inc dword [CDSectorAddress]
|
||||
jmp .new_sector
|
||||
;--------------------------------------
|
||||
.incomplete_sector:
|
||||
; we must read and memmove incomplete sector
|
||||
mov [CDDataBuf_pointer], CDDataBuf
|
||||
call ReadCDWRetr; читаем сектор файла
|
||||
call ReadCDWRetr ; read sector of file
|
||||
cmp [DevErrorCode], 0
|
||||
jne .noaccess_3
|
||||
|
||||
push ecx
|
||||
add ecx, ebx
|
||||
cmp ecx, 2048
|
||||
jbe @f
|
||||
|
||||
mov ecx, 2048
|
||||
;--------------------------------------
|
||||
@@:
|
||||
sub ecx, ebx
|
||||
push edi esi ecx
|
||||
@ -189,19 +265,19 @@ fs_CdRead:
|
||||
pop ecx
|
||||
xor ebx, ebx
|
||||
jmp .next
|
||||
|
||||
;--------------------------------------
|
||||
.done:
|
||||
mov ebx, edx
|
||||
pop eax edx ecx edi
|
||||
sub ebx, edx
|
||||
ret
|
||||
;--------------------------------------
|
||||
.eof:
|
||||
mov ebx, edx
|
||||
pop eax edx ecx
|
||||
sub ebx, edx
|
||||
jmp .reteof
|
||||
|
||||
;----------------------------------------------------------------
|
||||
;-----------------------------------------------------------------------------
|
||||
;
|
||||
; fs_CdReadFolder - LFN variant for reading CD disk folder
|
||||
;
|
||||
@ -215,30 +291,37 @@ fs_CdRead:
|
||||
; ret ebx = blocks read or 0xffffffff folder not found
|
||||
; eax = 0 ok read or other = errormsg
|
||||
;
|
||||
;--------------------------------------------------------------
|
||||
;-----------------------------------------------------------------------------
|
||||
fs_CdReadFolder:
|
||||
push edi
|
||||
call cd_find_lfn
|
||||
jnc .found
|
||||
|
||||
pop edi
|
||||
cmp [DevErrorCode], 0
|
||||
jne .noaccess_1
|
||||
|
||||
or ebx, -1
|
||||
mov eax, ERROR_FILE_NOT_FOUND
|
||||
ret
|
||||
;--------------------------------------
|
||||
.found:
|
||||
mov edi, [cd_current_pointer_of_input]
|
||||
test byte [edi+25], 10b ; do not allow read directories
|
||||
jnz .found_dir
|
||||
|
||||
pop edi
|
||||
;--------------------------------------
|
||||
.noaccess_1:
|
||||
or ebx, -1
|
||||
mov eax, ERROR_ACCESS_DENIED
|
||||
ret
|
||||
;--------------------------------------
|
||||
.found_dir:
|
||||
mov eax, [edi+2] ; eax=cluster
|
||||
mov [CDSectorAddress], eax
|
||||
mov eax, [edi+10] ; размер директрории
|
||||
mov eax, [edi+10] ; directory size
|
||||
;--------------------------------------
|
||||
.doit:
|
||||
; init header
|
||||
push eax ecx
|
||||
@ -250,21 +333,23 @@ fs_CdReadFolder:
|
||||
mov byte [edx], 1 ; version
|
||||
mov [cd_mem_location], edx
|
||||
add [cd_mem_location], 32
|
||||
; начинаем переброску БДВК в УСВК
|
||||
;.mainloop:
|
||||
mov [cd_counter_block], dword 0
|
||||
dec dword [CDSectorAddress]
|
||||
push ecx
|
||||
;--------------------------------------
|
||||
.read_to_buffer:
|
||||
inc dword [CDSectorAddress]
|
||||
mov [CDDataBuf_pointer], CDDataBuf
|
||||
call ReadCDWRetr ; читаем сектор директории
|
||||
call ReadCDWRetr ; read sector of directory
|
||||
cmp [DevErrorCode], 0
|
||||
jne .noaccess_1
|
||||
|
||||
call .get_names_from_buffer
|
||||
sub eax, 2048
|
||||
; директория закончилась?
|
||||
; directory is over?
|
||||
ja .read_to_buffer
|
||||
|
||||
mov edi, [cd_counter_block]
|
||||
mov [edx+8], edi
|
||||
mov edi, [ebx]
|
||||
@ -272,24 +357,30 @@ fs_CdReadFolder:
|
||||
xor eax, eax
|
||||
dec ecx
|
||||
js @f
|
||||
|
||||
mov al, ERROR_END_OF_FILE
|
||||
;--------------------------------------
|
||||
@@:
|
||||
pop ecx edi
|
||||
mov ebx, [edx+4]
|
||||
ret
|
||||
|
||||
;--------------------------------------
|
||||
.get_names_from_buffer:
|
||||
mov [cd_current_pointer_of_input_2], CDDataBuf
|
||||
push eax esi edi edx
|
||||
;--------------------------------------
|
||||
.get_names_from_buffer_1:
|
||||
call cd_get_name
|
||||
jc .end_buffer
|
||||
|
||||
inc dword [cd_counter_block]
|
||||
mov eax, [cd_counter_block]
|
||||
cmp [ebx], eax
|
||||
jae .get_names_from_buffer_1
|
||||
|
||||
test ecx, ecx
|
||||
jz .get_names_from_buffer_1
|
||||
|
||||
mov edi, [cd_counter_block]
|
||||
mov [edx+4], edi
|
||||
dec ecx
|
||||
@ -298,189 +389,209 @@ fs_CdReadFolder:
|
||||
add edi, 40
|
||||
test dword [ebx+4], 1; 0=ANSI, 1=UNICODE
|
||||
jnz .unicode
|
||||
; jmp .unicode
|
||||
;--------------------------------------
|
||||
.ansi:
|
||||
cmp [cd_counter_block], 2
|
||||
jbe .ansi_parent_directory
|
||||
|
||||
cld
|
||||
lodsw
|
||||
xchg ah, al
|
||||
call uni2ansi_char
|
||||
cld
|
||||
stosb
|
||||
; проверка конца файла
|
||||
; check end of file
|
||||
mov ax, [esi]
|
||||
cmp ax, word 3B00h; сепаратор конца файла ';'
|
||||
cmp ax, word 3B00h ; separator end of file ';'
|
||||
je .cd_get_parameters_of_file_1
|
||||
; проверка для файлов не заканчивающихся сепаратором
|
||||
; check for files not ending with separator
|
||||
movzx eax, byte [ebp-33]
|
||||
add eax, ebp
|
||||
sub eax, 34
|
||||
cmp esi, eax
|
||||
je .cd_get_parameters_of_file_1
|
||||
; проверка конца папки
|
||||
; check the end of the directory
|
||||
movzx eax, byte [ebp-1]
|
||||
add eax, ebp
|
||||
cmp esi, eax
|
||||
jb .ansi
|
||||
;--------------------------------------
|
||||
.cd_get_parameters_of_file_1:
|
||||
mov [edi], byte 0
|
||||
call cd_get_parameters_of_file
|
||||
add [cd_mem_location], 304
|
||||
jmp .get_names_from_buffer_1
|
||||
|
||||
;--------------------------------------
|
||||
.ansi_parent_directory:
|
||||
cmp [cd_counter_block], 2
|
||||
je @f
|
||||
|
||||
mov [edi], byte '.'
|
||||
inc edi
|
||||
jmp .cd_get_parameters_of_file_1
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov [edi], word '..'
|
||||
add edi, 2
|
||||
jmp .cd_get_parameters_of_file_1
|
||||
|
||||
;--------------------------------------
|
||||
.unicode:
|
||||
cmp [cd_counter_block], 2
|
||||
jbe .unicode_parent_directory
|
||||
|
||||
cld
|
||||
movsw
|
||||
; проверка конца файла
|
||||
; check end of file
|
||||
mov ax, [esi]
|
||||
cmp ax, word 3B00h; сепаратор конца файла ';'
|
||||
cmp ax, word 3B00h; separator end of file ';'
|
||||
je .cd_get_parameters_of_file_2
|
||||
; проверка для файлов не заканчивающихся сепаратором
|
||||
; check for files not ending with separator
|
||||
movzx eax, byte [ebp-33]
|
||||
add eax, ebp
|
||||
sub eax, 34
|
||||
cmp esi, eax
|
||||
je .cd_get_parameters_of_file_2
|
||||
; проверка конца папки
|
||||
; check the end of the directory
|
||||
movzx eax, byte [ebp-1]
|
||||
add eax, ebp
|
||||
cmp esi, eax
|
||||
jb .unicode
|
||||
;--------------------------------------
|
||||
.cd_get_parameters_of_file_2:
|
||||
mov [edi], word 0
|
||||
call cd_get_parameters_of_file
|
||||
add [cd_mem_location], 560
|
||||
jmp .get_names_from_buffer_1
|
||||
|
||||
;--------------------------------------
|
||||
.unicode_parent_directory:
|
||||
cmp [cd_counter_block], 2
|
||||
je @f
|
||||
|
||||
mov [edi], word 2E00h; '.'
|
||||
add edi, 2
|
||||
jmp .cd_get_parameters_of_file_2
|
||||
;--------------------------------------
|
||||
@@:
|
||||
mov [edi], dword 2E002E00h; '..'
|
||||
add edi, 4
|
||||
jmp .cd_get_parameters_of_file_2
|
||||
|
||||
;--------------------------------------
|
||||
.end_buffer:
|
||||
pop edx edi esi eax
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
cd_get_parameters_of_file:
|
||||
mov edi, [cd_mem_location]
|
||||
cd_get_parameters_of_file_1:
|
||||
; получаем атрибуты файла
|
||||
; get file attributes
|
||||
xor eax, eax
|
||||
; файл не архивировался
|
||||
; file is not archived
|
||||
inc eax
|
||||
shl eax, 1
|
||||
; это каталог?
|
||||
; is a directory?
|
||||
test [ebp-8], byte 2
|
||||
jz .file
|
||||
|
||||
inc eax
|
||||
;--------------------------------------
|
||||
.file:
|
||||
; метка тома не как в FAT, в этом виде отсутсвует
|
||||
; файл не является системным
|
||||
; not as a volume label in the FAT, in this form not available
|
||||
; file is not a system
|
||||
shl eax, 3
|
||||
; файл является скрытым? (атрибут существование)
|
||||
; file is hidden? (attribute of existence)
|
||||
test [ebp-8], byte 1
|
||||
jz .hidden
|
||||
|
||||
inc eax
|
||||
;--------------------------------------
|
||||
.hidden:
|
||||
shl eax, 1
|
||||
; файл всегда только для чтения, так как это CD
|
||||
; file is always read-only, as this CD
|
||||
inc eax
|
||||
mov [edi], eax
|
||||
; получаем время для файла
|
||||
;час
|
||||
; get the time to file
|
||||
; hour
|
||||
movzx eax, byte [ebp-12]
|
||||
shl eax, 8
|
||||
;минута
|
||||
; minute
|
||||
mov al, [ebp-11]
|
||||
shl eax, 8
|
||||
;секунда
|
||||
; second
|
||||
mov al, [ebp-10]
|
||||
;время создания файла
|
||||
; file creation time
|
||||
mov [edi+8], eax
|
||||
;время последнего доступа
|
||||
; last access time
|
||||
mov [edi+16], eax
|
||||
;время последней записи
|
||||
; last write time
|
||||
mov [edi+24], eax
|
||||
; получаем дату для файла
|
||||
;год
|
||||
; get date for file
|
||||
; year
|
||||
movzx eax, byte [ebp-15]
|
||||
add eax, 1900
|
||||
shl eax, 8
|
||||
;месяц
|
||||
; month
|
||||
mov al, [ebp-14]
|
||||
shl eax, 8
|
||||
;день
|
||||
; day
|
||||
mov al, [ebp-13]
|
||||
;дата создания файла
|
||||
; file creation date
|
||||
mov [edi+12], eax
|
||||
;время последнего доступа
|
||||
; last access date
|
||||
mov [edi+20], eax
|
||||
;время последней записи
|
||||
; last write date
|
||||
mov [edi+28], eax
|
||||
; получаем тип данных имени
|
||||
; get the data type of name
|
||||
xor eax, eax
|
||||
test dword [ebx+4], 1; 0=ANSI, 1=UNICODE
|
||||
jnz .unicode_1
|
||||
|
||||
mov [edi+4], eax
|
||||
jmp @f
|
||||
;--------------------------------------
|
||||
.unicode_1:
|
||||
inc eax
|
||||
mov [edi+4], eax
|
||||
;--------------------------------------
|
||||
@@:
|
||||
; получаем размер файла в байтах
|
||||
; get the file size in bytes
|
||||
xor eax, eax
|
||||
mov [edi+32+4], eax
|
||||
mov eax, [ebp-23]
|
||||
mov [edi+32], eax
|
||||
ret
|
||||
|
||||
;----------------------------------------------------------------
|
||||
;-----------------------------------------------------------------------------
|
||||
;
|
||||
; fs_CdGetFileInfo - LFN variant for CD
|
||||
; get file/directory attributes structure
|
||||
;
|
||||
;----------------------------------------------------------------
|
||||
;-----------------------------------------------------------------------------
|
||||
fs_CdGetFileInfo:
|
||||
cmp byte [esi], 0
|
||||
jnz @f
|
||||
|
||||
mov eax, 2
|
||||
ret
|
||||
;--------------------------------------
|
||||
@@:
|
||||
push edi
|
||||
call cd_find_lfn
|
||||
pushfd
|
||||
cmp [DevErrorCode], 0
|
||||
jz @f
|
||||
|
||||
popfd
|
||||
pop edi
|
||||
mov eax, 11
|
||||
ret
|
||||
;--------------------------------------
|
||||
@@:
|
||||
popfd
|
||||
jnc @f
|
||||
|
||||
pop edi
|
||||
mov eax, ERROR_FILE_NOT_FOUND
|
||||
ret
|
||||
;--------------------------------------
|
||||
@@:
|
||||
|
||||
mov edi, edx
|
||||
@ -493,32 +604,31 @@ fs_CdGetFileInfo:
|
||||
pop edi
|
||||
xor eax, eax
|
||||
ret
|
||||
|
||||
;----------------------------------------------------------------
|
||||
;-----------------------------------------------------------------------------
|
||||
cd_find_lfn:
|
||||
mov [cd_appl_data], 0
|
||||
; in: esi+ebp -> name
|
||||
; out: CF=1 - file not found
|
||||
; else CF=0 and [cd_current_pointer_of_input] direntry
|
||||
push eax esi
|
||||
; 16 сектор начало набора дескрипторов томов
|
||||
|
||||
; Sector 16 - start set of volume descriptors
|
||||
call WaitUnitReady
|
||||
cmp [DevErrorCode], 0
|
||||
jne .access_denied
|
||||
|
||||
call prevent_medium_removal
|
||||
; тестовое чтение
|
||||
; testing of reading
|
||||
mov [CDSectorAddress], dword 16
|
||||
mov [CDDataBuf_pointer], CDDataBuf
|
||||
call ReadCDWRetr;_1
|
||||
cmp [DevErrorCode], 0
|
||||
jne .access_denied
|
||||
|
||||
; вычисление последней сессии
|
||||
; calculation of the last session
|
||||
call WaitUnitReady
|
||||
cmp [DevErrorCode], 0
|
||||
jne .access_denied
|
||||
|
||||
call Read_TOC
|
||||
mov ah, [CDDataBuf+4+4]
|
||||
mov al, [CDDataBuf+4+5]
|
||||
@ -529,7 +639,7 @@ cd_find_lfn:
|
||||
mov [CDSectorAddress], eax
|
||||
; mov [CDSectorAddress],dword 15
|
||||
mov [CDDataBuf_pointer], CDDataBuf
|
||||
|
||||
;--------------------------------------
|
||||
.start:
|
||||
inc dword [CDSectorAddress]
|
||||
call ReadCDWRetr;_1
|
||||
@ -537,111 +647,128 @@ cd_find_lfn:
|
||||
jne .access_denied
|
||||
|
||||
.start_check:
|
||||
; проверка на вшивость
|
||||
; checking for "lice"
|
||||
cmp [CDDataBuf+1], dword 'CD00'
|
||||
jne .access_denied
|
||||
|
||||
cmp [CDDataBuf+5], byte '1'
|
||||
jne .access_denied
|
||||
; сектор является терминатором набор дескрипторов томов?
|
||||
; sector is the terminator of set of descriptors volumes?
|
||||
cmp [CDDataBuf], byte 0xff
|
||||
je .access_denied
|
||||
; сектор является дополнительным и улучшенным дескриптором тома?
|
||||
; sector is an additional and improved descriptor of volume?
|
||||
cmp [CDDataBuf], byte 0x2
|
||||
jne .start
|
||||
; сектор является дополнительным дескриптором тома?
|
||||
; sector is an additional descriptor of volume?
|
||||
cmp [CDDataBuf+6], byte 0x1
|
||||
jne .start
|
||||
|
||||
; параметры root директрории
|
||||
mov eax, [CDDataBuf+0x9c+2]; начало root директрории
|
||||
; parameters of root directory
|
||||
mov eax, [CDDataBuf+0x9c+2]; start of root directory
|
||||
mov [CDSectorAddress], eax
|
||||
mov eax, [CDDataBuf+0x9c+10]; размер root директрории
|
||||
mov eax, [CDDataBuf+0x9c+10]; size of root directory
|
||||
cmp byte [esi], 0
|
||||
jnz @f
|
||||
|
||||
mov [cd_current_pointer_of_input], CDDataBuf+0x9c
|
||||
jmp .done
|
||||
;--------------------------------------
|
||||
@@:
|
||||
; начинаем поиск
|
||||
; start the search
|
||||
.mainloop:
|
||||
dec dword [CDSectorAddress]
|
||||
;--------------------------------------
|
||||
.read_to_buffer:
|
||||
inc dword [CDSectorAddress]
|
||||
mov [CDDataBuf_pointer], CDDataBuf
|
||||
call ReadCDWRetr ; читаем сектор директории
|
||||
call ReadCDWRetr ; read sector of directory
|
||||
cmp [DevErrorCode], 0
|
||||
jne .access_denied
|
||||
|
||||
push ebp
|
||||
call cd_find_name_in_buffer
|
||||
pop ebp
|
||||
jnc .found
|
||||
|
||||
sub eax, 2048
|
||||
; директория закончилась?
|
||||
; directory is over?
|
||||
cmp eax, 0
|
||||
ja .read_to_buffer
|
||||
; нет искомого элемента цепочки
|
||||
; desired element of chain is not found
|
||||
.access_denied:
|
||||
pop esi eax
|
||||
mov [cd_appl_data], 1
|
||||
stc
|
||||
ret
|
||||
; искомый элемент цепочки найден
|
||||
.found:
|
||||
; конец пути файла
|
||||
;--------------------------------------
|
||||
; desired element of chain found
|
||||
.found:
|
||||
; the end of the file path
|
||||
cmp byte [esi-1], 0
|
||||
jz .done
|
||||
.nested:
|
||||
mov eax, [cd_current_pointer_of_input]
|
||||
push dword [eax+2]
|
||||
pop dword [CDSectorAddress] ; начало директории
|
||||
mov eax, [eax+2+8]; размер директории
|
||||
pop dword [CDSectorAddress] ; beginning of the directory
|
||||
mov eax, [eax+2+8] ; size of directory
|
||||
jmp .mainloop
|
||||
; указатель файла найден
|
||||
.done:
|
||||
;--------------------------------------
|
||||
; file pointer found
|
||||
.done:
|
||||
test ebp, ebp
|
||||
jz @f
|
||||
|
||||
mov esi, ebp
|
||||
xor ebp, ebp
|
||||
jmp .nested
|
||||
;--------------------------------------
|
||||
@@:
|
||||
pop esi eax
|
||||
mov [cd_appl_data], 1
|
||||
clc
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
cd_find_name_in_buffer:
|
||||
mov [cd_current_pointer_of_input_2], CDDataBuf
|
||||
;--------------------------------------
|
||||
.start:
|
||||
call cd_get_name
|
||||
jc .not_found
|
||||
|
||||
call cd_compare_name
|
||||
jc .start
|
||||
;--------------------------------------
|
||||
.found:
|
||||
clc
|
||||
ret
|
||||
;--------------------------------------
|
||||
.not_found:
|
||||
stc
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
cd_get_name:
|
||||
push eax
|
||||
mov ebp, [cd_current_pointer_of_input_2]
|
||||
mov [cd_current_pointer_of_input], ebp
|
||||
mov eax, [ebp]
|
||||
test eax, eax ; входы закончились?
|
||||
test eax, eax ; entry's is over?
|
||||
jz .next_sector
|
||||
cmp ebp, CDDataBuf+2048 ; буфер закончился?
|
||||
|
||||
cmp ebp, CDDataBuf+2048 ; buffer is over?
|
||||
jae .next_sector
|
||||
|
||||
movzx eax, byte [ebp]
|
||||
add [cd_current_pointer_of_input_2], eax; следующий вход каталога
|
||||
add ebp, 33; указатель установлен на начало имени
|
||||
add [cd_current_pointer_of_input_2], eax ; next entry of directory
|
||||
add ebp, 33; pointer is set to the beginning of the name
|
||||
pop eax
|
||||
clc
|
||||
ret
|
||||
;--------------------------------------
|
||||
.next_sector:
|
||||
pop eax
|
||||
stc
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
cd_compare_name:
|
||||
; compares ASCIIZ-names, case-insensitive (cp866 encoding)
|
||||
; in: esi->name, ebp->name
|
||||
@ -650,6 +777,7 @@ cd_compare_name:
|
||||
; destroys eax
|
||||
push esi eax edi
|
||||
mov edi, ebp
|
||||
;--------------------------------------
|
||||
.loop:
|
||||
cld
|
||||
lodsb
|
||||
@ -666,94 +794,118 @@ cd_compare_name:
|
||||
sub edi, 2
|
||||
scasw
|
||||
jne .name_not_coincide
|
||||
;--------------------------------------
|
||||
.coincides:
|
||||
cmp [esi], byte '/'; разделитель пути, конец имени текущего элемента
|
||||
cmp [esi], byte '/' ; path separator is end of current element
|
||||
je .done
|
||||
cmp [esi], byte 0; разделитель пути, конец имени текущего элемента
|
||||
|
||||
cmp [esi], byte 0 ; path separator end of name
|
||||
je .done
|
||||
|
||||
jmp .loop
|
||||
;--------------------------------------
|
||||
.name_not_coincide:
|
||||
pop edi eax esi
|
||||
stc
|
||||
ret
|
||||
;--------------------------------------
|
||||
.done:
|
||||
; проверка конца файла
|
||||
cmp [edi], word 3B00h; сепаратор конца файла ';'
|
||||
; check end of file
|
||||
cmp [edi], word 3B00h; separator end of file ';'
|
||||
je .done_1
|
||||
; проверка для файлов не заканчивающихся сепаратором
|
||||
; check for files not ending with separator
|
||||
movzx eax, byte [ebp-33]
|
||||
add eax, ebp
|
||||
sub eax, 34
|
||||
cmp edi, eax
|
||||
je .done_1
|
||||
; проверка конца папки
|
||||
; check the end of directory
|
||||
movzx eax, byte [ebp-1]
|
||||
add eax, ebp
|
||||
cmp edi, eax
|
||||
jne .name_not_coincide
|
||||
;--------------------------------------
|
||||
.done_1:
|
||||
pop edi eax
|
||||
add esp, 4
|
||||
inc esi
|
||||
clc
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
char_todown:
|
||||
; convert character to uppercase, using cp866 encoding
|
||||
; in: al=symbol
|
||||
; out: al=converted symbol
|
||||
cmp al, 'A'
|
||||
jb .ret
|
||||
|
||||
cmp al, 'Z'
|
||||
jbe .az
|
||||
|
||||
cmp al, 0x80 ; 'А'
|
||||
jb .ret
|
||||
|
||||
cmp al, 0x90 ; 'Р'
|
||||
jb .rus1
|
||||
|
||||
cmp al, 0x9F ; 'Я'
|
||||
ja .ret
|
||||
; 0x90-0x9F -> 0xE0-0xEF
|
||||
add al, 0xE0-0x90
|
||||
;--------------------------------------
|
||||
.ret:
|
||||
ret
|
||||
;--------------------------------------
|
||||
.rus1:
|
||||
; 0x80-0x8F -> 0xA0-0xAF
|
||||
.az:
|
||||
add al, 0x20
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
uni2ansi_char:
|
||||
; convert UNICODE character in al to ANSI character in ax, using cp866 encoding
|
||||
; in: ax=UNICODE character
|
||||
; out: al=converted ANSI character
|
||||
cmp ax, 0x80
|
||||
jb .ascii
|
||||
|
||||
cmp ax, 0x401
|
||||
jz .yo1
|
||||
|
||||
cmp ax, 0x451
|
||||
jz .yo2
|
||||
|
||||
cmp ax, 0x410
|
||||
jb .unk
|
||||
|
||||
cmp ax, 0x440
|
||||
jb .rus1
|
||||
|
||||
cmp ax, 0x450
|
||||
jb .rus2
|
||||
;--------------------------------------
|
||||
.unk:
|
||||
mov al, '_'
|
||||
jmp .doit
|
||||
;--------------------------------------
|
||||
.yo1:
|
||||
mov al, 0xF0 ; 'Ё' in cp866
|
||||
jmp .doit
|
||||
;--------------------------------------
|
||||
.yo2:
|
||||
mov al, 0xF1 ; 'ё' in cp866
|
||||
jmp .doit
|
||||
;--------------------------------------
|
||||
.rus1:
|
||||
; 0x410-0x43F -> 0x80-0xAF
|
||||
add al, 0x70
|
||||
jmp .doit
|
||||
;--------------------------------------
|
||||
.rus2:
|
||||
; 0x440-0x44F -> 0xE0-0xEF
|
||||
add al, 0xA0
|
||||
;--------------------------------------
|
||||
.ascii:
|
||||
.doit:
|
||||
ret
|
||||
;-----------------------------------------------------------------------------
|
||||
|
@ -369,6 +369,14 @@ high_code:
|
||||
call mutex_init
|
||||
mov ecx, ide_channel2_mutex
|
||||
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
|
||||
;-----------------------------------------------------------------------------
|
||||
@ -1504,266 +1512,231 @@ draw_num_text:
|
||||
mov eax, [esp+64+8] ; background color (if given)
|
||||
mov edi, [esp+64+4]
|
||||
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
|
||||
midi_base dw 0
|
||||
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 eax, [edi+TASKDATA.mem_start]
|
||||
add eax, edx
|
||||
|
||||
; 1 = normal layout
|
||||
dec ecx
|
||||
jnz kbnobase
|
||||
jnz .shift
|
||||
|
||||
mov ebx, keymap
|
||||
mov ecx, 128
|
||||
call memmove
|
||||
ret
|
||||
kbnobase:
|
||||
;--------------------------------------
|
||||
.shift:
|
||||
; 2 = layout at pressed Shift
|
||||
dec ecx
|
||||
jnz kbnoshift
|
||||
jnz .alt
|
||||
|
||||
mov ebx, keymap_shift
|
||||
mov ecx, 128
|
||||
call memmove
|
||||
ret
|
||||
kbnoshift:
|
||||
;--------------------------------------
|
||||
.alt:
|
||||
; 3 = layout at pressed Alt
|
||||
dec ecx
|
||||
jnz kbnoalt
|
||||
jnz .country
|
||||
|
||||
mov ebx, keymap_alt
|
||||
mov ecx, 128
|
||||
call memmove
|
||||
ret
|
||||
kbnoalt:
|
||||
;--------------------------------------
|
||||
.country:
|
||||
; country identifier
|
||||
sub ecx, 6
|
||||
jnz kbnocountry
|
||||
jnz .error
|
||||
|
||||
mov word [keyboard], dx
|
||||
ret
|
||||
kbnocountry:
|
||||
mov [esp+32], dword 1
|
||||
ret
|
||||
nsyse2:
|
||||
dec ebx ; CD
|
||||
jnz nsyse4
|
||||
;--------------------------------------
|
||||
@@:
|
||||
; F.21.5 - set system language
|
||||
sub ebx, 3
|
||||
jnz @f
|
||||
|
||||
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
|
||||
ret
|
||||
nsyse5:
|
||||
|
||||
sub ebx, 2 ; HD BASE - obsolete
|
||||
jnz nsyse7
|
||||
|
||||
nosethd:
|
||||
ret
|
||||
|
||||
nsyse7:
|
||||
|
||||
; cmp eax,8 ; HD PARTITION - obsolete
|
||||
dec ebx
|
||||
jnz nsyse8
|
||||
ret
|
||||
|
||||
nsyse8:
|
||||
; cmp eax,11 ; ENABLE LBA READ
|
||||
;--------------------------------------
|
||||
@@:
|
||||
; F.21.11 - enable/disable low-level access to HD
|
||||
and ecx, 1
|
||||
sub ebx, 3
|
||||
jnz no_set_lba_read
|
||||
sub ebx, 6
|
||||
jnz @f
|
||||
|
||||
mov [lba_read_enabled], ecx
|
||||
ret
|
||||
|
||||
no_set_lba_read:
|
||||
; cmp eax,12 ; ENABLE PCI ACCESS
|
||||
;--------------------------------------
|
||||
@@:
|
||||
; F.21.12 - enable/disable low-level access to PCI
|
||||
dec ebx
|
||||
jnz sys_setup_err
|
||||
jnz .error
|
||||
|
||||
mov [pci_access_enabled], ecx
|
||||
ret
|
||||
|
||||
sys_setup_err:
|
||||
;--------------------------------------
|
||||
.error:
|
||||
or [esp+32], dword -1
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
align 4
|
||||
|
||||
sys_getsetup:
|
||||
|
||||
; 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=get hs timer tic
|
||||
|
||||
; cmp eax,1
|
||||
; 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 = get hs timer tic
|
||||
; 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
|
||||
jnz ngsyse1
|
||||
jnz @f
|
||||
|
||||
movzx eax, [midi_base]
|
||||
mov [esp+32], eax
|
||||
ret
|
||||
ngsyse1:
|
||||
; cmp eax,2
|
||||
;--------------------------------------
|
||||
@@:
|
||||
; F.26.2 - get keyboard layout
|
||||
dec ebx
|
||||
jnz ngsyse2
|
||||
jnz @f
|
||||
|
||||
mov edi, [TASK_BASE]
|
||||
mov ebx, [edi+TASKDATA.mem_start]
|
||||
add ebx, edx
|
||||
|
||||
; cmp ebx,1
|
||||
; 1 = normal layout
|
||||
dec ecx
|
||||
jnz kbnobaseret
|
||||
jnz .shift
|
||||
|
||||
mov eax, keymap
|
||||
mov ecx, 128
|
||||
call memmove
|
||||
ret
|
||||
kbnobaseret:
|
||||
; cmp ebx,2
|
||||
;--------------------------------------
|
||||
.shift:
|
||||
; 2 = layout with pressed Shift
|
||||
dec ecx
|
||||
jnz kbnoshiftret
|
||||
jnz .alt
|
||||
|
||||
mov eax, keymap_shift
|
||||
mov ecx, 128
|
||||
call memmove
|
||||
ret
|
||||
kbnoshiftret:
|
||||
; cmp ebx,3
|
||||
;--------------------------------------
|
||||
.alt:
|
||||
; 3 = layout with pressed Alt
|
||||
dec ecx
|
||||
jne kbnoaltret
|
||||
jne .country
|
||||
|
||||
mov eax, keymap_alt
|
||||
mov ecx, 128
|
||||
call memmove
|
||||
ret
|
||||
kbnoaltret:
|
||||
; cmp ebx,9
|
||||
;--------------------------------------
|
||||
.country:
|
||||
; 9 = country identifier
|
||||
sub ecx, 6
|
||||
jnz ngsyse2
|
||||
jnz .error
|
||||
|
||||
movzx eax, word [keyboard]
|
||||
mov [esp+32], eax
|
||||
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 [esp+32], eax
|
||||
ret
|
||||
ngsyse5:
|
||||
; cmp eax,9
|
||||
;--------------------------------------
|
||||
@@:
|
||||
; F.26.9 - get the value of the time counter
|
||||
sub ebx, 4
|
||||
jnz ngsyse9
|
||||
mov eax, [timer_ticks];[0xfdf0]
|
||||
jnz @f
|
||||
|
||||
mov eax, [timer_ticks]
|
||||
mov [esp+32], eax
|
||||
ret
|
||||
ngsyse9:
|
||||
; cmp eax,11
|
||||
;--------------------------------------
|
||||
@@:
|
||||
; F.26.11 - Find out whether low-level HD access is enabled
|
||||
sub ebx, 2
|
||||
jnz ngsyse11
|
||||
jnz @f
|
||||
|
||||
mov eax, [lba_read_enabled]
|
||||
mov [esp+32], eax
|
||||
ret
|
||||
ngsyse11:
|
||||
; cmp eax,12
|
||||
;--------------------------------------
|
||||
@@:
|
||||
; F.26.12 - Find out whether low-level PCI access is enabled
|
||||
dec ebx
|
||||
jnz ngsyse12
|
||||
jnz .error
|
||||
|
||||
mov eax, [pci_access_enabled]
|
||||
mov [esp+32], eax
|
||||
ret
|
||||
ngsyse12:
|
||||
mov [esp+32], dword 1
|
||||
;--------------------------------------
|
||||
.error:
|
||||
or [esp+32], dword -1
|
||||
ret
|
||||
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
get_timer_ticks:
|
||||
mov eax, [timer_ticks]
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
iglobal
|
||||
align 4
|
||||
mousefn dd msscreen, mswin, msbutton, msset
|
||||
@ -1772,7 +1745,7 @@ mousefn dd msscreen, mswin, msbutton, msset
|
||||
dd app_delete_cursor
|
||||
dd msz
|
||||
endg
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
readmousepos:
|
||||
|
||||
; eax=0 screen relative
|
||||
@ -5080,38 +5053,52 @@ syscall_getscreensize: ; GetScreenSize
|
||||
mov ax, word [Screen_Max_Y]
|
||||
mov [esp + 32], eax
|
||||
ret
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
align 4
|
||||
|
||||
syscall_cdaudio: ; CD
|
||||
|
||||
cmp ebx, 4
|
||||
jb .audio
|
||||
jz .eject
|
||||
je .eject
|
||||
|
||||
cmp ebx, 5
|
||||
jnz .ret
|
||||
je .load
|
||||
|
||||
ret
|
||||
;--------------------------------------
|
||||
.load:
|
||||
call .reserve
|
||||
call LoadMedium
|
||||
;call .free
|
||||
jmp .free
|
||||
; ret
|
||||
;--------------------------------------
|
||||
.eject:
|
||||
call .reserve
|
||||
call clear_CD_cache
|
||||
call allow_medium_removal
|
||||
call EjectMedium
|
||||
; call .free
|
||||
jmp .free
|
||||
; ret
|
||||
.audio:
|
||||
call sys_cd_audio
|
||||
mov [esp+36-4], eax
|
||||
.ret:
|
||||
ret
|
||||
|
||||
;--------------------------------------
|
||||
.reserve:
|
||||
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
|
||||
shr eax, 1
|
||||
and eax, 1
|
||||
@ -5121,25 +5108,14 @@ syscall_cdaudio: ; CD
|
||||
and eax, 1
|
||||
mov [DiskNumber], al
|
||||
call reserve_cd_channel
|
||||
and ebx, 3
|
||||
inc ebx
|
||||
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:
|
||||
call free_cd_channel
|
||||
and [cd_status], 0
|
||||
ret
|
||||
.err:
|
||||
call .free
|
||||
; pop eax
|
||||
ret
|
||||
;-----------------------------------------------------------------------------
|
||||
align 4
|
||||
syscall_getpixel_WinMap: ; GetPixel WinMap
|
||||
@ -5537,8 +5513,6 @@ system_shutdown: ; shut down the system
|
||||
ret
|
||||
@@:
|
||||
call stop_all_services
|
||||
movi eax, 3
|
||||
call sys_cd_audio
|
||||
|
||||
yes_shutdown_param:
|
||||
cli
|
||||
|
@ -152,6 +152,30 @@ struct APPDATA
|
||||
|
||||
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
|
||||
include "core/sync.inc" ; macros for synhronization objects
|
||||
@ -243,7 +267,6 @@ include "blkdev/bd_drv.inc"
|
||||
|
||||
; CD drive controller
|
||||
|
||||
include "blkdev/cdrom.inc"
|
||||
include "blkdev/cd_drv.inc"
|
||||
|
||||
; Character devices
|
||||
|
Loading…
Reference in New Issue
Block a user