2014-04-17 23:19:45 +02:00
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
;; ;;
|
2015-01-08 21:10:22 +01:00
|
|
|
;; Copyright (C) KolibriOS team 2014-2015. All rights reserved. ;;
|
2014-04-17 23:19:45 +02:00
|
|
|
;; Distributed under terms of the GNU General Public License ;;
|
|
|
|
;; ;;
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
$Revision$
|
|
|
|
|
|
|
|
|
2014-03-10 01:09:59 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
; find the IDE controller in the device list
|
|
|
|
;-----------------------------------------------------------------------------
|
2014-03-27 21:44:32 +01:00
|
|
|
mov ecx, IDE_controller_1
|
2014-03-10 01:09:59 +01:00
|
|
|
mov esi, pcidev_list
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
|
|
|
align 4
|
2014-03-10 01:09:59 +01:00
|
|
|
.loop:
|
|
|
|
mov esi, [esi+PCIDEV.fd]
|
|
|
|
cmp esi, pcidev_list
|
2014-03-27 21:44:32 +01:00
|
|
|
jz find_IDE_controller_done
|
|
|
|
|
2014-03-10 01:09:59 +01:00
|
|
|
mov eax, [esi+PCIDEV.class]
|
2014-10-24 07:13:52 +02:00
|
|
|
; shr eax, 4
|
|
|
|
; cmp eax, 0x01018
|
|
|
|
shr eax, 7
|
|
|
|
cmp eax, 0x010180 shr 7
|
2014-03-10 01:09:59 +01:00
|
|
|
jnz .loop
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2014-03-10 01:09:59 +01:00
|
|
|
.found:
|
|
|
|
mov eax, [esi+PCIDEV.class]
|
|
|
|
DEBUGF 1, 'K : IDE controller programming interface %x\n', eax
|
2014-03-27 21:44:32 +01:00
|
|
|
mov [ecx+IDE_DATA.ProgrammingInterface], eax
|
2016-12-26 22:52:58 +01:00
|
|
|
mov [ecx+IDE_DATA.pcidev], esi
|
2014-03-10 01:09:59 +01:00
|
|
|
|
|
|
|
mov ah, [esi+PCIDEV.bus]
|
|
|
|
mov al, 2
|
|
|
|
mov bh, [esi+PCIDEV.devfn]
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2014-04-15 20:41:49 +02:00
|
|
|
mov dx, 0x1F0
|
|
|
|
test byte [esi+PCIDEV.class], 1
|
|
|
|
jz @f
|
2014-03-10 01:09:59 +01:00
|
|
|
mov bl, 0x10
|
|
|
|
push eax
|
|
|
|
call pci_read_reg
|
|
|
|
and eax, 0xFFFC
|
2014-04-15 20:41:49 +02:00
|
|
|
mov edx, eax
|
2014-03-10 01:09:59 +01:00
|
|
|
pop eax
|
2014-04-15 20:41:49 +02:00
|
|
|
@@:
|
|
|
|
DEBUGF 1, 'K : BAR0 IDE base addr %x\n', dx
|
|
|
|
mov [StandardATABases], dx
|
|
|
|
mov [ecx+IDE_DATA.BAR0_val], dx
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2014-04-15 20:41:49 +02:00
|
|
|
mov dx, 0x3F4
|
|
|
|
test byte [esi+PCIDEV.class], 1
|
|
|
|
jz @f
|
2014-03-10 01:09:59 +01:00
|
|
|
mov bl, 0x14
|
|
|
|
push eax
|
|
|
|
call pci_read_reg
|
|
|
|
and eax, 0xFFFC
|
2014-04-15 20:41:49 +02:00
|
|
|
mov edx, eax
|
2014-03-10 01:09:59 +01:00
|
|
|
pop eax
|
2014-04-15 20:41:49 +02:00
|
|
|
@@:
|
|
|
|
DEBUGF 1, 'K : BAR1 IDE base addr %x\n', dx
|
|
|
|
mov [ecx+IDE_DATA.BAR1_val], dx
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2014-04-15 20:41:49 +02:00
|
|
|
mov dx, 0x170
|
|
|
|
test byte [esi+PCIDEV.class], 4
|
|
|
|
jz @f
|
2014-03-10 01:09:59 +01:00
|
|
|
mov bl, 0x18
|
|
|
|
push eax
|
|
|
|
call pci_read_reg
|
|
|
|
and eax, 0xFFFC
|
2014-04-15 20:41:49 +02:00
|
|
|
mov edx, eax
|
2014-03-10 01:09:59 +01:00
|
|
|
pop eax
|
2014-04-15 20:41:49 +02:00
|
|
|
@@:
|
|
|
|
DEBUGF 1, 'K : BAR2 IDE base addr %x\n', dx
|
|
|
|
mov [StandardATABases+2], dx
|
|
|
|
mov [ecx+IDE_DATA.BAR2_val], dx
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2014-04-15 20:41:49 +02:00
|
|
|
mov dx, 0x374
|
|
|
|
test byte [esi+PCIDEV.class], 4
|
|
|
|
jz @f
|
2014-03-10 01:09:59 +01:00
|
|
|
mov bl, 0x1C
|
|
|
|
push eax
|
|
|
|
call pci_read_reg
|
|
|
|
and eax, 0xFFFC
|
2014-04-15 20:41:49 +02:00
|
|
|
mov edx, eax
|
2014-03-10 01:09:59 +01:00
|
|
|
pop eax
|
2014-04-15 20:41:49 +02:00
|
|
|
@@:
|
|
|
|
DEBUGF 1, 'K : BAR3 IDE base addr %x\n', dx
|
|
|
|
mov [ecx+IDE_DATA.BAR3_val], dx
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2014-03-10 01:09:59 +01:00
|
|
|
mov bl, 0x20
|
|
|
|
push eax
|
|
|
|
call pci_read_reg
|
|
|
|
and eax, 0xFFFC
|
|
|
|
DEBUGF 1, 'K : BAR4 IDE controller register base addr %x\n', ax
|
2014-03-27 21:44:32 +01:00
|
|
|
mov [ecx+IDE_DATA.RegsBaseAddres], ax
|
2014-03-10 01:09:59 +01:00
|
|
|
pop eax
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2014-03-10 01:09:59 +01:00
|
|
|
mov bl, 0x3C
|
|
|
|
push eax
|
|
|
|
call pci_read_reg
|
|
|
|
and eax, 0xFF
|
|
|
|
DEBUGF 1, 'K : IDE Interrupt %x\n', al
|
2014-03-27 21:44:32 +01:00
|
|
|
mov [ecx+IDE_DATA.Interrupt], ax
|
2014-03-10 01:09:59 +01:00
|
|
|
pop eax
|
2014-03-27 21:44:32 +01:00
|
|
|
|
|
|
|
add ecx, sizeof.IDE_DATA
|
|
|
|
;--------------------------------------
|
|
|
|
jmp .loop
|
2014-03-10 01:09:59 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2014-03-27 21:44:32 +01:00
|
|
|
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
|
|
|
|
;--------------------------------------
|
2014-04-05 23:36:10 +02:00
|
|
|
IDE_device_1 rd 2
|
|
|
|
IDE_device_2 rd 2
|
|
|
|
IDE_device_3 rd 2
|
|
|
|
;--------------------------------------
|
2014-03-27 21:44:32 +01:00
|
|
|
endg
|
2016-12-26 22:52:58 +01:00
|
|
|
|
|
|
|
;--------------------------------------
|
|
|
|
; set Bus Master bit of Command PCI register
|
|
|
|
;--------------------------------------
|
|
|
|
set_pci_command_bus_master:
|
|
|
|
PCI_COMMAND_BUS_MASTER = 0x0004
|
|
|
|
push eax ecx
|
|
|
|
|
|
|
|
mov ecx, [ecx+IDE_DATA.pcidev]
|
|
|
|
mov ah, [ecx+PCIDEV.bus]
|
|
|
|
mov al, 1 ; word
|
|
|
|
mov bh, [ecx+PCIDEV.devfn]
|
|
|
|
mov bl, 0x4 ; Command register
|
|
|
|
push eax
|
|
|
|
call pci_read_reg
|
|
|
|
mov ecx, eax
|
|
|
|
pop eax
|
|
|
|
test ecx, PCI_COMMAND_BUS_MASTER ; already set?
|
|
|
|
jnz @f
|
|
|
|
or ecx, PCI_COMMAND_BUS_MASTER
|
|
|
|
call pci_write_reg
|
|
|
|
@@:
|
|
|
|
pop ecx eax
|
|
|
|
ret
|
|
|
|
|
2014-03-10 01:09:59 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
; START of initialisation IDE ATA code
|
|
|
|
;-----------------------------------------------------------------------------
|
2014-03-27 21:44:32 +01:00
|
|
|
Init_IDE_ATA_controller:
|
|
|
|
cmp [ecx+IDE_DATA.ProgrammingInterface], 0
|
2014-03-30 23:09:44 +02:00
|
|
|
jne @f
|
2014-03-10 01:09:59 +01:00
|
|
|
|
2014-03-30 23:09:44 +02:00
|
|
|
ret
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
2014-03-10 01:09:59 +01:00
|
|
|
mov esi, boot_disabling_ide
|
|
|
|
call boot_log
|
|
|
|
;--------------------------------------
|
|
|
|
; Disable IDE interrupts, because the search
|
|
|
|
; for IDE partitions is in the PIO mode.
|
|
|
|
;--------------------------------------
|
|
|
|
.disable_IDE_interrupt:
|
|
|
|
; Disable interrupts in IDE controller for PIO
|
|
|
|
mov al, 2
|
2014-03-27 21:44:32 +01:00
|
|
|
mov dx, [ecx+IDE_DATA.BAR1_val] ;0x3F4
|
2014-03-10 01:09:59 +01:00
|
|
|
add dx, 2 ;0x3F6
|
|
|
|
out dx, al
|
2014-03-27 21:44:32 +01:00
|
|
|
mov dx, [ecx+IDE_DATA.BAR3_val] ;0x374
|
2014-03-10 01:09:59 +01:00
|
|
|
add dx, 2 ;0x376
|
|
|
|
out dx, al
|
|
|
|
;-----------------------------------------------------------------------------
|
2014-03-27 21:44:32 +01:00
|
|
|
; 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
|
|
|
|
|
2014-03-10 01:09:59 +01:00
|
|
|
mov esi, boot_detecthdcd
|
|
|
|
call boot_log
|
2014-03-30 23:09:44 +02:00
|
|
|
;--------------------------------------
|
2014-03-10 01:14:09 +01:00
|
|
|
include 'dev_hdcd.inc'
|
2014-03-30 23:09:44 +02:00
|
|
|
;--------------------------------------
|
|
|
|
ret
|
2014-03-10 01:09:59 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
2014-03-30 23:09:44 +02:00
|
|
|
Init_IDE_ATA_controller_2:
|
|
|
|
cmp [ecx+IDE_DATA.ProgrammingInterface], 0
|
|
|
|
jne @f
|
|
|
|
|
|
|
|
ret
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
2014-03-27 21:44:32 +01:00
|
|
|
mov dx, [ecx+IDE_DATA.RegsBaseAddres]
|
2014-03-10 01:09:59 +01:00
|
|
|
; test whether it is our interrupt?
|
|
|
|
add dx, 2
|
|
|
|
in al, dx
|
|
|
|
test al, 100b
|
|
|
|
jz @f
|
|
|
|
; clear Bus Master IDE Status register
|
|
|
|
; clear Interrupt bit
|
|
|
|
out dx, al
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2014-03-10 01:09:59 +01:00
|
|
|
@@:
|
|
|
|
add dx, 8
|
|
|
|
; test whether it is our interrupt?
|
|
|
|
in al, dx
|
|
|
|
test al, 100b
|
|
|
|
jz @f
|
|
|
|
; clear Bus Master IDE Status register
|
|
|
|
; clear Interrupt bit
|
|
|
|
out dx, al
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2014-03-10 01:09:59 +01:00
|
|
|
@@:
|
|
|
|
; read status register and remove the interrupt request
|
2014-03-27 21:44:32 +01:00
|
|
|
mov dx, [ecx+IDE_DATA.BAR0_val] ;0x1F0
|
2014-03-10 01:09:59 +01:00
|
|
|
add dx, 0x7 ;0x1F7
|
|
|
|
in al, dx
|
2014-03-27 21:44:32 +01:00
|
|
|
mov dx, [ecx+IDE_DATA.BAR2_val] ;0x170
|
2014-03-10 01:09:59 +01:00
|
|
|
add dx, 0x7 ;0x177
|
|
|
|
in al, dx
|
|
|
|
;-----------------------------------------------------------------------------
|
2014-03-30 23:09:44 +02:00
|
|
|
; push eax edx
|
|
|
|
; mov dx, [ecx+IDE_DATA.RegsBaseAddres]
|
|
|
|
; xor eax, eax
|
|
|
|
; add dx, 2
|
|
|
|
; in al, dx
|
2014-03-28 21:04:31 +01:00
|
|
|
; DEBUGF 1, "K : Primary Bus Master IDE Status Register %x\n", eax
|
2014-03-10 01:09:59 +01:00
|
|
|
|
2014-03-30 23:09:44 +02:00
|
|
|
; add dx, 8
|
|
|
|
; in al, dx
|
2014-03-28 21:04:31 +01:00
|
|
|
; DEBUGF 1, "K : Secondary Bus Master IDE Status Register %x\n", eax
|
2014-03-30 23:09:44 +02:00
|
|
|
; pop edx eax
|
2014-03-10 01:09:59 +01:00
|
|
|
|
2014-03-30 23:09:44 +02:00
|
|
|
; cmp [ecx+IDE_DATA.RegsBaseAddres], 0
|
|
|
|
; setnz [ecx+IDE_DATA.dma_hdd]
|
2014-03-10 01:09:59 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
; set interrupts for IDE Controller
|
|
|
|
;-----------------------------------------------------------------------------
|
2014-04-15 12:01:23 +02:00
|
|
|
pushfd
|
|
|
|
cli
|
2014-03-10 01:09:59 +01:00
|
|
|
.enable_IDE_interrupt:
|
|
|
|
mov esi, boot_enabling_ide
|
|
|
|
call boot_log
|
|
|
|
; Enable interrupts in IDE controller for DMA
|
2014-03-27 21:44:32 +01:00
|
|
|
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:
|
2014-03-10 01:09:59 +01:00
|
|
|
mov al, 0
|
2014-03-27 21:44:32 +01:00
|
|
|
mov ah, [ebx+DRIVE_DATA+1]
|
2014-04-05 23:36:10 +02:00
|
|
|
test ah, 10100000b ; check for ATAPI devices
|
2014-03-10 01:09:59 +01:00
|
|
|
jz @f
|
2014-04-05 23:36:10 +02:00
|
|
|
;--------------------------------------
|
|
|
|
.ch1_pio_set_ATAPI:
|
2014-03-10 01:09:59 +01:00
|
|
|
DEBUGF 1, "K : IDE CH1 PIO, because ATAPI drive present\n"
|
2014-04-05 23:36:10 +02:00
|
|
|
jmp .ch1_pio_set_for_all
|
|
|
|
;--------------------------------------
|
|
|
|
.ch1_pio_set_no_devices:
|
|
|
|
DEBUGF 1, "K : IDE CH1 PIO because no devices\n"
|
|
|
|
jmp .ch1_pio_set_for_all
|
|
|
|
;-------------------------------------
|
|
|
|
.ch1_pio_set:
|
|
|
|
DEBUGF 1, "K : IDE CH1 PIO because device not support UDMA\n"
|
|
|
|
;-------------------------------------
|
|
|
|
.ch1_pio_set_for_all:
|
|
|
|
mov [ecx+IDE_DATA.dma_hdd_channel_1], al
|
2014-03-10 01:09:59 +01:00
|
|
|
jmp .ch2_check
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2014-04-05 23:36:10 +02:00
|
|
|
@@:
|
|
|
|
xor ebx, ebx
|
|
|
|
call calculate_IDE_device_values_storage
|
|
|
|
|
|
|
|
test ah, 1010000b
|
|
|
|
jz .ch1_pio_set_no_devices
|
|
|
|
|
|
|
|
test ah, 1000000b
|
|
|
|
jz @f
|
|
|
|
|
|
|
|
cmp [ebx+IDE_DEVICE.UDMA_possible_modes], al
|
|
|
|
je .ch1_pio_set
|
|
|
|
|
|
|
|
cmp [ebx+IDE_DEVICE.UDMA_set_mode], al
|
|
|
|
je .ch1_pio_set
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
test ah, 10000b
|
|
|
|
jz @f
|
|
|
|
|
|
|
|
add ebx, 2
|
|
|
|
|
|
|
|
cmp [ebx+IDE_DEVICE.UDMA_possible_modes], al
|
|
|
|
je .ch1_pio_set
|
|
|
|
|
|
|
|
cmp [ebx+IDE_DEVICE.UDMA_set_mode], al
|
|
|
|
je .ch1_pio_set
|
|
|
|
;--------------------------------------
|
2014-03-10 01:09:59 +01:00
|
|
|
@@:
|
2014-03-27 21:44:32 +01:00
|
|
|
mov dx, [ecx+IDE_DATA.BAR1_val] ;0x3F4
|
2014-03-10 01:09:59 +01:00
|
|
|
add dx, 2 ;0x3F6
|
|
|
|
out dx, al
|
2016-12-26 22:52:58 +01:00
|
|
|
call set_pci_command_bus_master
|
2014-03-10 01:09:59 +01:00
|
|
|
DEBUGF 1, "K : IDE CH1 DMA enabled\n"
|
2014-03-30 23:09:44 +02:00
|
|
|
mov [ecx+IDE_DATA.dma_hdd_channel_1], byte 1
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2014-03-10 01:09:59 +01:00
|
|
|
.ch2_check:
|
2014-04-05 23:36:10 +02:00
|
|
|
test ah, 1010b ; check for ATAPI devices
|
2014-03-10 01:09:59 +01:00
|
|
|
jz @f
|
2014-04-05 23:36:10 +02:00
|
|
|
;--------------------------------------
|
|
|
|
.ch2_pio_set_ATAPI:
|
2014-03-10 01:09:59 +01:00
|
|
|
DEBUGF 1, "K : IDE CH2 PIO, because ATAPI drive present\n"
|
2014-04-05 23:36:10 +02:00
|
|
|
jmp .ch2_pio_set_for_all
|
|
|
|
;--------------------------------------
|
|
|
|
.ch2_pio_set_no_devices:
|
|
|
|
DEBUGF 1, "K : IDE CH2 PIO because no devices\n"
|
|
|
|
jmp .ch2_pio_set_for_all
|
|
|
|
;--------------------------------------
|
|
|
|
.ch2_pio_set:
|
|
|
|
DEBUGF 1, "K : IDE CH2 PIO because device not support UDMA\n"
|
|
|
|
;--------------------------------------
|
|
|
|
.ch2_pio_set_for_all:
|
|
|
|
mov [ecx+IDE_DATA.dma_hdd_channel_2], al
|
2014-04-15 12:01:23 +02:00
|
|
|
jmp .set_interrupts_for_IDE_controllers
|
2014-03-27 21:44:32 +01:00
|
|
|
;--------------------------------------
|
2014-04-05 23:36:10 +02:00
|
|
|
@@:
|
|
|
|
mov ebx, 4
|
|
|
|
call calculate_IDE_device_values_storage
|
|
|
|
|
|
|
|
test ah, 101b
|
|
|
|
jz .ch2_pio_set_no_devices
|
|
|
|
|
|
|
|
test ah, 100b
|
|
|
|
jz @f
|
|
|
|
|
|
|
|
cmp [ebx+IDE_DEVICE.UDMA_possible_modes], al
|
|
|
|
je .ch2_pio_set
|
|
|
|
|
|
|
|
cmp [ebx+IDE_DEVICE.UDMA_set_mode], al
|
|
|
|
je .ch2_pio_set
|
|
|
|
;--------------------------------------
|
|
|
|
@@:
|
|
|
|
test ah, 1b
|
|
|
|
jz @f
|
|
|
|
|
|
|
|
add ebx, 2
|
|
|
|
|
|
|
|
cmp [ebx+IDE_DEVICE.UDMA_possible_modes], al
|
|
|
|
je .ch2_pio_set
|
|
|
|
|
|
|
|
cmp [ebx+IDE_DEVICE.UDMA_set_mode], al
|
|
|
|
je .ch2_pio_set
|
|
|
|
;--------------------------------------
|
2014-03-10 01:09:59 +01:00
|
|
|
@@:
|
2014-03-27 21:44:32 +01:00
|
|
|
mov dx, [ecx+IDE_DATA.BAR3_val] ;0x374
|
2014-03-10 01:09:59 +01:00
|
|
|
add dx, 2 ;0x376
|
|
|
|
out dx, al
|
2016-12-26 22:52:58 +01:00
|
|
|
call set_pci_command_bus_master
|
2014-03-10 01:09:59 +01:00
|
|
|
DEBUGF 1, "K : IDE CH2 DMA enabled\n"
|
2014-03-30 23:09:44 +02:00
|
|
|
mov [ecx+IDE_DATA.dma_hdd_channel_2], byte 1
|
2014-03-10 01:09:59 +01:00
|
|
|
;--------------------------------------
|
2014-04-15 12:01:23 +02:00
|
|
|
.set_interrupts_for_IDE_controllers:
|
|
|
|
mov esi, boot_set_int_IDE
|
|
|
|
call boot_log
|
|
|
|
;--------------------------------------
|
|
|
|
mov eax, [ecx+IDE_DATA.ProgrammingInterface]
|
2014-10-24 07:13:52 +02:00
|
|
|
; cmp ax, 0x0180
|
|
|
|
; je .pata_ide
|
2014-04-15 12:01:23 +02:00
|
|
|
|
2014-10-24 07:13:52 +02:00
|
|
|
; cmp ax, 0x018a
|
|
|
|
; jne .sata_ide
|
|
|
|
|
|
|
|
test al, 1 ; 0 - legacy PCI mode, 1 - native PCI mode
|
|
|
|
jnz .sata_ide
|
2014-04-15 12:01:23 +02:00
|
|
|
;--------------------------------------
|
|
|
|
.pata_ide:
|
|
|
|
cmp [ecx+IDE_DATA.RegsBaseAddres], 0
|
|
|
|
je .end_set_interrupts
|
|
|
|
|
|
|
|
push ecx
|
2015-12-30 16:48:01 +01:00
|
|
|
stdcall attach_int_handler, 14, IDE_irq_14_handler, ecx
|
|
|
|
pop ecx
|
2014-04-15 12:01:23 +02:00
|
|
|
DEBUGF 1, "K : Set IDE IRQ14 return code %x\n", eax
|
2015-12-30 16:48:01 +01:00
|
|
|
push ecx
|
|
|
|
stdcall attach_int_handler, 15, IDE_irq_15_handler, ecx
|
2014-04-15 12:01:23 +02:00
|
|
|
DEBUGF 1, "K : Set IDE IRQ15 return code %x\n", eax
|
|
|
|
pop ecx
|
|
|
|
|
|
|
|
jmp .end_set_interrupts
|
|
|
|
;--------------------------------------
|
|
|
|
.sata_ide:
|
2014-10-24 07:13:52 +02:00
|
|
|
; cmp ax, 0x0185
|
|
|
|
; je .sata_ide_1
|
2014-04-15 12:01:23 +02:00
|
|
|
|
2014-10-24 07:13:52 +02:00
|
|
|
; cmp ax, 0x018f
|
|
|
|
; jne .end_set_interrupts
|
2014-04-15 12:01:23 +02:00
|
|
|
;--------------------------------------
|
2014-10-24 07:13:52 +02:00
|
|
|
;.sata_ide_1:
|
2014-04-15 12:01:23 +02:00
|
|
|
; Some weird controllers generate an interrupt even if IDE interrupts
|
|
|
|
; are disabled and no IDE devices. For example, notebook ASUS K72F -
|
|
|
|
; IDE controller 010185 generates false interrupt when we work with
|
|
|
|
; the IDE controller 01018f. For this reason, the interrupt handler
|
|
|
|
; does not need to be installed if both channel IDE controller
|
|
|
|
; running in PIO mode.
|
2015-12-30 16:48:01 +01:00
|
|
|
|
|
|
|
; ...unfortunately, PCI interrupt can be shared with other devices
|
|
|
|
; which could enable it without consulting IDE code.
|
|
|
|
; So install the handler anyways and try to process
|
|
|
|
; even those interrupts which we are not expecting.
|
2014-04-15 12:01:23 +02:00
|
|
|
cmp [ecx+IDE_DATA.RegsBaseAddres], 0
|
|
|
|
je .end_set_interrupts
|
|
|
|
|
|
|
|
mov ax, [ecx+IDE_DATA.Interrupt]
|
|
|
|
movzx eax, al
|
|
|
|
push ecx
|
2015-12-30 16:48:01 +01:00
|
|
|
stdcall attach_int_handler, eax, IDE_common_irq_handler, ecx
|
2014-04-15 12:01:23 +02:00
|
|
|
pop ecx
|
|
|
|
DEBUGF 1, "K : Set IDE IRQ%d return code %x\n", [ecx+IDE_DATA.Interrupt]:1, eax
|
|
|
|
;--------------------------------------
|
2014-03-10 01:09:59 +01:00
|
|
|
.end_set_interrupts:
|
2014-04-15 12:01:23 +02:00
|
|
|
popfd
|
2014-03-27 21:44:32 +01:00
|
|
|
ret
|
2014-03-10 01:09:59 +01:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
; END of initialisation IDE ATA code
|
|
|
|
;-----------------------------------------------------------------------------
|
2014-03-27 21:44:32 +01:00
|
|
|
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'
|
2014-04-05 23:36:10 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
mov esi, boot_init_sys
|
|
|
|
call boot_log
|
|
|
|
call Parser_params
|
|
|
|
|
|
|
|
if ~ defined extended_primary_loader
|
|
|
|
; ramdisk image should be loaded by extended primary loader if it exists
|
|
|
|
; READ RAMDISK IMAGE FROM HD
|
|
|
|
include '../boot/rdload.inc'
|
|
|
|
end if
|
2014-03-30 23:09:44 +02:00
|
|
|
;-----------------------------------------------------------------------------
|
|
|
|
mov ecx, IDE_controller_1
|
|
|
|
mov [IDE_controller_pointer], ecx
|
|
|
|
call Init_IDE_ATA_controller_2
|
|
|
|
mov ecx, IDE_controller_2
|
|
|
|
mov [IDE_controller_pointer], ecx
|
|
|
|
call Init_IDE_ATA_controller_2
|
|
|
|
mov ecx, IDE_controller_3
|
|
|
|
mov [IDE_controller_pointer], ecx
|
|
|
|
call Init_IDE_ATA_controller_2
|
2014-03-27 21:44:32 +01:00
|
|
|
;-----------------------------------------------------------------------------
|