forked from KolibriOS/kolibrios
Some fixes code for IDE controllers.
git-svn-id: svn://kolibrios.org@3774 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
09ee9d676a
commit
25dd9e6530
kernel/trunk
@ -77,7 +77,10 @@ endl
|
|||||||
call mutex_lock
|
call mutex_lock
|
||||||
mov ecx, ide_channel2_mutex
|
mov ecx, ide_channel2_mutex
|
||||||
mov eax, [hd_data]
|
mov eax, [hd_data]
|
||||||
cmp [eax+HD_DATA.hdbase], 0x1F0
|
push ecx
|
||||||
|
mov ecx, [hd_address_table]
|
||||||
|
cmp [eax+HD_DATA.hdbase], ecx ; 0x1F0
|
||||||
|
pop ecx
|
||||||
jne .IDE_Channel_2
|
jne .IDE_Channel_2
|
||||||
mov ecx, ide_channel1_mutex
|
mov ecx, ide_channel1_mutex
|
||||||
.IDE_Channel_2:
|
.IDE_Channel_2:
|
||||||
@ -158,7 +161,10 @@ endl
|
|||||||
call mutex_lock
|
call mutex_lock
|
||||||
mov ecx, ide_channel2_mutex
|
mov ecx, ide_channel2_mutex
|
||||||
mov eax, [hd_data]
|
mov eax, [hd_data]
|
||||||
cmp [eax+HD_DATA.hdbase], 0x1F0
|
push ecx
|
||||||
|
mov ecx, [hd_address_table]
|
||||||
|
cmp [eax+HD_DATA.hdbase], ecx ; 0x1F0
|
||||||
|
pop ecx
|
||||||
jne .IDE_Channel_2
|
jne .IDE_Channel_2
|
||||||
mov ecx, ide_channel1_mutex
|
mov ecx, ide_channel1_mutex
|
||||||
.IDE_Channel_2:
|
.IDE_Channel_2:
|
||||||
@ -848,7 +854,10 @@ hd_read_dma:
|
|||||||
mov word [eax+4], 0x2000
|
mov word [eax+4], 0x2000
|
||||||
sub eax, OS_BASE
|
sub eax, OS_BASE
|
||||||
mov dx, [IDEContrRegsBaseAddr]
|
mov dx, [IDEContrRegsBaseAddr]
|
||||||
cmp [hdbase], 0x1F0
|
push eax
|
||||||
|
mov eax, [hd_address_table]
|
||||||
|
cmp [hdbase], eax ; 0x1F0
|
||||||
|
pop eax
|
||||||
jz @f
|
jz @f
|
||||||
add edx, 8
|
add edx, 8
|
||||||
@@:
|
@@:
|
||||||
@ -1005,7 +1014,10 @@ cache_write_dma:
|
|||||||
popa
|
popa
|
||||||
sub eax, OS_BASE
|
sub eax, OS_BASE
|
||||||
mov dx, [IDEContrRegsBaseAddr]
|
mov dx, [IDEContrRegsBaseAddr]
|
||||||
cmp [hdbase], 0x1F0
|
push eax
|
||||||
|
mov eax, [hd_address_table]
|
||||||
|
cmp [hdbase], eax ; 0x1F0
|
||||||
|
pop eax
|
||||||
jz @f
|
jz @f
|
||||||
add edx, 8
|
add edx, 8
|
||||||
@@:
|
@@:
|
||||||
|
@ -434,8 +434,11 @@ sayerr:
|
|||||||
xor si, si ; device index = 0
|
xor si, si ; device index = 0
|
||||||
int 0x1A
|
int 0x1A
|
||||||
jnc .found_1 ; Parallel IDE Controller
|
jnc .found_1 ; Parallel IDE Controller
|
||||||
|
; Controller not found!
|
||||||
|
xor ax, ax
|
||||||
|
mov [es:BOOT_IDE_PI_16], ax
|
||||||
jmp .nopci
|
jmp .nopci
|
||||||
|
;--------------------------------------
|
||||||
.found_1:
|
.found_1:
|
||||||
; get memory base BAR4
|
; get memory base BAR4
|
||||||
mov ax, 0xB10A
|
mov ax, 0xB10A
|
||||||
@ -443,10 +446,11 @@ sayerr:
|
|||||||
push cx
|
push cx
|
||||||
int 0x1A
|
int 0x1A
|
||||||
jc .no_BAR4 ;.nopci
|
jc .no_BAR4 ;.nopci
|
||||||
and cx, 0xFFF0 ; clear address decode type
|
and cx, 0xFFFC ; clear address decode type
|
||||||
mov [es:BOOT_IDE_BASE_ADDR], cx
|
mov [es:BOOT_IDE_BASE_ADDR], cx
|
||||||
.no_BAR4:
|
.no_BAR4:
|
||||||
pop cx
|
pop cx
|
||||||
|
;--------------------------------------
|
||||||
.found:
|
.found:
|
||||||
; get Interrupt Line
|
; get Interrupt Line
|
||||||
mov ax, 0xB10A
|
mov ax, 0xB10A
|
||||||
@ -454,46 +458,55 @@ sayerr:
|
|||||||
push cx
|
push cx
|
||||||
int 0x1A
|
int 0x1A
|
||||||
jc .no_Interrupt ;.nopci
|
jc .no_Interrupt ;.nopci
|
||||||
; and cx, 0xFFF0 ; clear address decode type
|
|
||||||
mov [es:BOOT_IDE_INTERR_16], cx
|
mov [es:BOOT_IDE_INTERR_16], cx
|
||||||
.no_Interrupt:
|
.no_Interrupt:
|
||||||
pop cx
|
pop cx
|
||||||
|
;--------------------------------------
|
||||||
; get memory base BAR0
|
; get memory base BAR0
|
||||||
mov ax, 0xB10A
|
mov ax, 0xB10A
|
||||||
mov di, 0x10 ; memory base is config register at 0x10
|
mov di, 0x10 ; memory base is config register at 0x10
|
||||||
push cx
|
push cx
|
||||||
int 0x1A
|
int 0x1A
|
||||||
jc .no_BAR0 ;.nopci
|
jc .no_BAR0 ;.nopci
|
||||||
|
|
||||||
mov [es:BOOT_IDE_BAR0_16], cx
|
mov [es:BOOT_IDE_BAR0_16], cx
|
||||||
.no_BAR0:
|
.no_BAR0:
|
||||||
pop cx
|
pop cx
|
||||||
|
;--------------------------------------
|
||||||
; get memory base BAR1
|
; get memory base BAR1
|
||||||
mov ax, 0xB10A
|
mov ax, 0xB10A
|
||||||
mov di, 0x14 ; memory base is config register at 0x14
|
mov di, 0x14 ; memory base is config register at 0x14
|
||||||
push cx
|
push cx
|
||||||
int 0x1A
|
int 0x1A
|
||||||
jc .no_BAR1 ;.nopci
|
jc .no_BAR1 ;.nopci
|
||||||
|
|
||||||
mov [es:BOOT_IDE_BAR1_16], cx
|
mov [es:BOOT_IDE_BAR1_16], cx
|
||||||
.no_BAR1:
|
.no_BAR1:
|
||||||
pop cx
|
pop cx
|
||||||
|
;--------------------------------------
|
||||||
; get memory base BAR2
|
; get memory base BAR2
|
||||||
mov ax, 0xB10A
|
mov ax, 0xB10A
|
||||||
mov di, 0x18 ; memory base is config register at 0x18
|
mov di, 0x18 ; memory base is config register at 0x18
|
||||||
push cx
|
push cx
|
||||||
int 0x1A
|
int 0x1A
|
||||||
jc .no_BAR2 ;.nopci
|
jc .no_BAR2 ;.nopci
|
||||||
|
|
||||||
mov [es:BOOT_IDE_BAR2_16], cx
|
mov [es:BOOT_IDE_BAR2_16], cx
|
||||||
.no_BAR2:
|
.no_BAR2:
|
||||||
pop cx
|
pop cx
|
||||||
|
;--------------------------------------
|
||||||
; get memory base BAR3
|
; get memory base BAR3
|
||||||
mov ax, 0xB10A
|
mov ax, 0xB10A
|
||||||
mov di, 0x1C ; memory base is config register at 0x1c
|
mov di, 0x1C ; memory base is config register at 0x1c
|
||||||
push cx
|
push cx
|
||||||
int 0x1A
|
int 0x1A
|
||||||
jc .no_BAR3 ;.nopci
|
jc .no_BAR3 ;.nopci
|
||||||
|
|
||||||
mov [es:BOOT_IDE_BAR3_16], cx
|
mov [es:BOOT_IDE_BAR3_16], cx
|
||||||
.no_BAR3:
|
.no_BAR3:
|
||||||
pop cx
|
pop cx
|
||||||
|
;--------------------------------------
|
||||||
.nopci:
|
.nopci:
|
||||||
; \end{Mario79}
|
; \end{Mario79}
|
||||||
|
|
||||||
|
@ -51,6 +51,8 @@ proc attach_int_handler stdcall, irq:dword, handler:dword, user_data:dword
|
|||||||
.irqh dd ?
|
.irqh dd ?
|
||||||
endl
|
endl
|
||||||
|
|
||||||
|
DEBUGF 1, "K : Attach Interrupt %d Handler %x\n", [irq], [handler]
|
||||||
|
|
||||||
and [.irqh], 0
|
and [.irqh], 0
|
||||||
|
|
||||||
push ebx
|
push ebx
|
||||||
|
@ -362,42 +362,76 @@ high_code:
|
|||||||
call mutex_init
|
call mutex_init
|
||||||
mov ecx, ide_channel2_mutex
|
mov ecx, ide_channel2_mutex
|
||||||
call mutex_init
|
call mutex_init
|
||||||
|
;-----------------------------------------------------------------------------
|
||||||
; SAVE REAL MODE VARIABLES
|
; SAVE REAL MODE VARIABLES
|
||||||
|
;-----------------------------------------------------------------------------
|
||||||
|
save_variables_IDE_controller:
|
||||||
xor eax, eax
|
xor eax, eax
|
||||||
mov ax, [BOOT_VARS + BOOT_IDE_INTERR_16]
|
mov ax, [BOOT_VARS + BOOT_IDE_INTERR_16]
|
||||||
mov [IDE_Interrupt], ax
|
mov [IDE_Interrupt], ax
|
||||||
|
;--------------------------------------
|
||||||
mov ax, [BOOT_VARS + BOOT_IDE_PI_16]
|
mov ax, [BOOT_VARS + BOOT_IDE_PI_16]
|
||||||
mov [IDEContrProgrammingInterface], ax
|
mov [IDEContrProgrammingInterface], ax
|
||||||
|
;--------------------------------------
|
||||||
mov ax, [BOOT_VARS + BOOT_IDE_BASE_ADDR]
|
mov ax, [BOOT_VARS + BOOT_IDE_BASE_ADDR]
|
||||||
mov [IDEContrRegsBaseAddr], ax
|
mov [IDEContrRegsBaseAddr], ax
|
||||||
|
;--------------------------------------
|
||||||
mov ax, [BOOT_VARS + BOOT_IDE_BAR0_16]
|
mov ax, [BOOT_VARS + BOOT_IDE_BAR0_16]
|
||||||
mov [IDE_BAR0_val], ax
|
|
||||||
|
|
||||||
cmp ax, 0
|
cmp ax, 0
|
||||||
je @f
|
je @f
|
||||||
cmp ax, 1
|
cmp ax, 1
|
||||||
je @f
|
jne .no_PATA_BAR0
|
||||||
and ax, 0xfff0
|
@@:
|
||||||
|
mov ax, 0x1F0
|
||||||
|
jmp @f
|
||||||
|
.no_PATA_BAR0:
|
||||||
|
and ax, 0xFFFC
|
||||||
|
@@:
|
||||||
mov [StandardATABases], ax
|
mov [StandardATABases], ax
|
||||||
mov [hd_address_table], eax
|
mov [hd_address_table], eax
|
||||||
mov [hd_address_table+8], eax
|
mov [hd_address_table+8], eax
|
||||||
@@:
|
mov [IDE_BAR0_val], ax
|
||||||
|
;--------------------------------------
|
||||||
mov ax, [BOOT_VARS + BOOT_IDE_BAR1_16]
|
mov ax, [BOOT_VARS + BOOT_IDE_BAR1_16]
|
||||||
mov [IDE_BAR1_val], ax
|
|
||||||
mov ax, [BOOT_VARS + BOOT_IDE_BAR2_16]
|
|
||||||
mov [IDE_BAR2_val], ax
|
|
||||||
|
|
||||||
cmp ax, 0
|
cmp ax, 0
|
||||||
je @f
|
je @f
|
||||||
cmp ax, 1
|
cmp ax, 1
|
||||||
|
jne .no_PATA_BAR1
|
||||||
|
@@:
|
||||||
|
mov ax, 0x3F4
|
||||||
|
jmp @f
|
||||||
|
.no_PATA_BAR1:
|
||||||
|
and ax, 0xFFFC
|
||||||
|
@@:
|
||||||
|
mov [IDE_BAR1_val], ax
|
||||||
|
;--------------------------------------
|
||||||
|
mov ax, [BOOT_VARS + BOOT_IDE_BAR2_16]
|
||||||
|
cmp ax, 0
|
||||||
je @f
|
je @f
|
||||||
and ax, 0xfff0
|
cmp ax, 1
|
||||||
|
jne .no_PATA_BAR2
|
||||||
|
@@:
|
||||||
|
mov ax, 0x170
|
||||||
|
jmp @f
|
||||||
|
.no_PATA_BAR2:
|
||||||
|
and ax, 0xFFFC
|
||||||
|
@@:
|
||||||
mov [StandardATABases+2], ax
|
mov [StandardATABases+2], ax
|
||||||
mov [hd_address_table+16], eax
|
mov [hd_address_table+16], eax
|
||||||
mov [hd_address_table+24], eax
|
mov [hd_address_table+24], eax
|
||||||
@@:
|
mov [IDE_BAR2_val], ax
|
||||||
|
;--------------------------------------
|
||||||
mov ax, [BOOT_VARS + BOOT_IDE_BAR3_16]
|
mov ax, [BOOT_VARS + BOOT_IDE_BAR3_16]
|
||||||
|
cmp ax, 0
|
||||||
|
je @f
|
||||||
|
cmp ax, 1
|
||||||
|
jne .no_PATA_BAR3
|
||||||
|
@@:
|
||||||
|
mov ax, 0x374
|
||||||
|
jmp @f
|
||||||
|
.no_PATA_BAR3:
|
||||||
|
and ax, 0xFFFC
|
||||||
|
@@:
|
||||||
mov [IDE_BAR3_val], ax
|
mov [IDE_BAR3_val], ax
|
||||||
|
|
||||||
; --------------- APM ---------------------
|
; --------------- APM ---------------------
|
||||||
@ -728,11 +762,11 @@ no_mode_0x12:
|
|||||||
.disable_IDE_interrupt:
|
.disable_IDE_interrupt:
|
||||||
; Disable interrupts in IDE controller for PIO
|
; Disable interrupts in IDE controller for PIO
|
||||||
mov al, 2
|
mov al, 2
|
||||||
mov dx, [IDE_BAR1_val] ;0x3F6
|
mov dx, [IDE_BAR1_val] ;0x3F4
|
||||||
add dx, 2
|
add dx, 2 ;0x3F6
|
||||||
out dx, al
|
out dx, al
|
||||||
mov dx, [IDE_BAR3_val] ;0x76
|
mov dx, [IDE_BAR3_val] ;0x374
|
||||||
add dx, 2
|
add dx, 2 ;0x376
|
||||||
out dx, al
|
out dx, al
|
||||||
;-----------------------------------------------------------------------------
|
;-----------------------------------------------------------------------------
|
||||||
;!!!!!!!!!!!!!!!!!!!!!!!!!!
|
;!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
@ -983,7 +1017,7 @@ endg
|
|||||||
call set_lights
|
call set_lights
|
||||||
;// mike.dld ]
|
;// mike.dld ]
|
||||||
stdcall attach_int_handler, 1, irq1, 0
|
stdcall attach_int_handler, 1, irq1, 0
|
||||||
DEBUGF 1, "K : IRQ0 error code %x\n", eax
|
DEBUGF 1, "K : IRQ1 error code %x\n", eax
|
||||||
.no_keyboard:
|
.no_keyboard:
|
||||||
|
|
||||||
; SET MOUSE
|
; SET MOUSE
|
||||||
@ -1108,7 +1142,7 @@ set_interrupts_for_IDE_controllers:
|
|||||||
mov ax, [IDE_Interrupt]
|
mov ax, [IDE_Interrupt]
|
||||||
movzx eax, al
|
movzx eax, al
|
||||||
stdcall attach_int_handler, eax, IDE_common_irq_handler, 0
|
stdcall attach_int_handler, eax, IDE_common_irq_handler, 0
|
||||||
DEBUGF 1, "K : Set IDE IRQ%d return code %x\n", [IDE_Interrupt]:2, eax
|
DEBUGF 1, "K : Set IDE IRQ%d return code %x\n", [IDE_Interrupt]:1, eax
|
||||||
|
|
||||||
stdcall enable_irq, eax
|
stdcall enable_irq, eax
|
||||||
;--------------------------------------
|
;--------------------------------------
|
||||||
@ -1117,11 +1151,11 @@ set_interrupts_for_IDE_controllers:
|
|||||||
call boot_log
|
call boot_log
|
||||||
; Enable interrupts in IDE controller for DMA
|
; Enable interrupts in IDE controller for DMA
|
||||||
mov al, 0
|
mov al, 0
|
||||||
mov dx, [IDE_BAR1_val] ;0x3F6
|
mov dx, [IDE_BAR1_val] ;0x3F4
|
||||||
add dx, 2
|
add dx, 2 ;0x3F6
|
||||||
out dx, al
|
out dx, al
|
||||||
mov dx, [IDE_BAR3_val] ;0x76
|
mov dx, [IDE_BAR3_val] ;0x374
|
||||||
add dx, 2
|
add dx, 2 ;0x376
|
||||||
out dx, al
|
out dx, al
|
||||||
;--------------------------------------
|
;--------------------------------------
|
||||||
.end_set_interrupts:
|
.end_set_interrupts:
|
||||||
|
Loading…
Reference in New Issue
Block a user