diff --git a/kernel/trunk/blkdev/hd_drv.inc b/kernel/trunk/blkdev/hd_drv.inc index bbb4ae2bc..5d50aa8a0 100644 --- a/kernel/trunk/blkdev/hd_drv.inc +++ b/kernel/trunk/blkdev/hd_drv.inc @@ -77,7 +77,10 @@ endl call mutex_lock mov ecx, ide_channel2_mutex 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 mov ecx, ide_channel1_mutex .IDE_Channel_2: @@ -158,7 +161,10 @@ endl call mutex_lock mov ecx, ide_channel2_mutex 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 mov ecx, ide_channel1_mutex .IDE_Channel_2: @@ -848,7 +854,10 @@ hd_read_dma: mov word [eax+4], 0x2000 sub eax, OS_BASE mov dx, [IDEContrRegsBaseAddr] - cmp [hdbase], 0x1F0 + push eax + mov eax, [hd_address_table] + cmp [hdbase], eax ; 0x1F0 + pop eax jz @f add edx, 8 @@: @@ -1005,7 +1014,10 @@ cache_write_dma: popa sub eax, OS_BASE mov dx, [IDEContrRegsBaseAddr] - cmp [hdbase], 0x1F0 + push eax + mov eax, [hd_address_table] + cmp [hdbase], eax ; 0x1F0 + pop eax jz @f add edx, 8 @@: diff --git a/kernel/trunk/boot/bootcode.inc b/kernel/trunk/boot/bootcode.inc index 74b53a86d..1340ace72 100644 --- a/kernel/trunk/boot/bootcode.inc +++ b/kernel/trunk/boot/bootcode.inc @@ -434,8 +434,11 @@ sayerr: xor si, si ; device index = 0 int 0x1A jnc .found_1 ; Parallel IDE Controller - +; Controller not found! + xor ax, ax + mov [es:BOOT_IDE_PI_16], ax jmp .nopci +;-------------------------------------- .found_1: ; get memory base BAR4 mov ax, 0xB10A @@ -443,10 +446,11 @@ sayerr: push cx int 0x1A 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 .no_BAR4: pop cx +;-------------------------------------- .found: ; get Interrupt Line mov ax, 0xB10A @@ -454,46 +458,55 @@ sayerr: push cx int 0x1A jc .no_Interrupt ;.nopci - ; and cx, 0xFFF0 ; clear address decode type + mov [es:BOOT_IDE_INTERR_16], cx .no_Interrupt: pop cx +;-------------------------------------- ; get memory base BAR0 mov ax, 0xB10A mov di, 0x10 ; memory base is config register at 0x10 push cx int 0x1A jc .no_BAR0 ;.nopci + mov [es:BOOT_IDE_BAR0_16], cx .no_BAR0: pop cx +;-------------------------------------- ; get memory base BAR1 mov ax, 0xB10A mov di, 0x14 ; memory base is config register at 0x14 push cx int 0x1A jc .no_BAR1 ;.nopci + mov [es:BOOT_IDE_BAR1_16], cx .no_BAR1: pop cx +;-------------------------------------- ; get memory base BAR2 mov ax, 0xB10A mov di, 0x18 ; memory base is config register at 0x18 push cx int 0x1A jc .no_BAR2 ;.nopci + mov [es:BOOT_IDE_BAR2_16], cx .no_BAR2: pop cx +;-------------------------------------- ; get memory base BAR3 mov ax, 0xB10A mov di, 0x1C ; memory base is config register at 0x1c push cx int 0x1A jc .no_BAR3 ;.nopci + mov [es:BOOT_IDE_BAR3_16], cx .no_BAR3: pop cx +;-------------------------------------- .nopci: ; \end{Mario79} diff --git a/kernel/trunk/core/irq.inc b/kernel/trunk/core/irq.inc index 7dfed0226..f0ceb23e0 100644 --- a/kernel/trunk/core/irq.inc +++ b/kernel/trunk/core/irq.inc @@ -50,6 +50,8 @@ proc attach_int_handler stdcall, irq:dword, handler:dword, user_data:dword locals .irqh dd ? endl + + DEBUGF 1, "K : Attach Interrupt %d Handler %x\n", [irq], [handler] and [.irqh], 0 diff --git a/kernel/trunk/kernel.asm b/kernel/trunk/kernel.asm index 1ef59706e..17886f44c 100644 --- a/kernel/trunk/kernel.asm +++ b/kernel/trunk/kernel.asm @@ -362,42 +362,76 @@ high_code: call mutex_init mov ecx, ide_channel2_mutex call mutex_init - +;----------------------------------------------------------------------------- ; SAVE REAL MODE VARIABLES +;----------------------------------------------------------------------------- +save_variables_IDE_controller: xor eax, eax mov ax, [BOOT_VARS + BOOT_IDE_INTERR_16] mov [IDE_Interrupt], ax +;-------------------------------------- mov ax, [BOOT_VARS + BOOT_IDE_PI_16] mov [IDEContrProgrammingInterface], ax +;-------------------------------------- mov ax, [BOOT_VARS + BOOT_IDE_BASE_ADDR] mov [IDEContrRegsBaseAddr], ax +;-------------------------------------- mov ax, [BOOT_VARS + BOOT_IDE_BAR0_16] - mov [IDE_BAR0_val], ax - cmp ax, 0 je @f cmp ax, 1 - je @f - and ax, 0xfff0 + jne .no_PATA_BAR0 +@@: + mov ax, 0x1F0 + jmp @f +.no_PATA_BAR0: + and ax, 0xFFFC +@@: mov [StandardATABases], ax mov [hd_address_table], eax mov [hd_address_table+8], eax -@@: + mov [IDE_BAR0_val], ax +;-------------------------------------- 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 je @f 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 - 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 [hd_address_table+16], eax mov [hd_address_table+24], eax -@@: + mov [IDE_BAR2_val], ax +;-------------------------------------- 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 ; --------------- APM --------------------- @@ -728,11 +762,11 @@ no_mode_0x12: .disable_IDE_interrupt: ; Disable interrupts in IDE controller for PIO mov al, 2 - mov dx, [IDE_BAR1_val] ;0x3F6 - add dx, 2 + mov dx, [IDE_BAR1_val] ;0x3F4 + add dx, 2 ;0x3F6 out dx, al - mov dx, [IDE_BAR3_val] ;0x76 - add dx, 2 + mov dx, [IDE_BAR3_val] ;0x374 + add dx, 2 ;0x376 out dx, al ;----------------------------------------------------------------------------- ;!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -983,7 +1017,7 @@ endg call set_lights ;// mike.dld ] 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: ; SET MOUSE @@ -1108,7 +1142,7 @@ set_interrupts_for_IDE_controllers: mov ax, [IDE_Interrupt] movzx eax, al 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 ;-------------------------------------- @@ -1117,11 +1151,11 @@ set_interrupts_for_IDE_controllers: call boot_log ; Enable interrupts in IDE controller for DMA mov al, 0 - mov dx, [IDE_BAR1_val] ;0x3F6 - add dx, 2 + mov dx, [IDE_BAR1_val] ;0x3F4 + add dx, 2 ;0x3F6 out dx, al - mov dx, [IDE_BAR3_val] ;0x76 - add dx, 2 + mov dx, [IDE_BAR3_val] ;0x374 + add dx, 2 ;0x376 out dx, al ;-------------------------------------- .end_set_interrupts: