From 87aa62f2160d3d82418edcf021e833936e5a8023 Mon Sep 17 00:00:00 2001 From: "Marat Zakiyanov (Mario79)" Date: Sun, 30 Mar 2014 21:09:44 +0000 Subject: [PATCH] Fix for r.4700 git-svn-id: svn://kolibrios.org@4720 a494cfbc-eb01-0410-851d-a64ba20cac60 --- kernel/trunk/blkdev/hd_drv.inc | 53 +++++++++++++++++--------- kernel/trunk/detect/init_ata.inc | 64 ++++++++++++++++++++------------ kernel/trunk/kernel32.inc | 3 +- 3 files changed, 79 insertions(+), 41 deletions(-) diff --git a/kernel/trunk/blkdev/hd_drv.inc b/kernel/trunk/blkdev/hd_drv.inc index b93f58c5e4..75ecb9d8c9 100644 --- a/kernel/trunk/blkdev/hd_drv.inc +++ b/kernel/trunk/blkdev/hd_drv.inc @@ -114,7 +114,21 @@ endl cmp [allow_dma_access], 2 ja .nodma - cmp [ecx+IDE_DATA.dma_hdd], 1 + push eax ecx + mov ecx, [hdpos] + dec ecx + shr ecx, 2 + imul ecx, sizeof.IDE_DATA + add ecx, IDE_controller_1 + mov [IDE_controller_pointer], ecx + + mov eax, [hdpos] + dec eax + and eax, 11b + shr eax, 1 + add eax, ecx + cmp [eax+IDE_DATA.dma_hdd_channel_1], 1 + pop ecx eax jnz .nodma call hd_read_dma @@ -219,7 +233,21 @@ endl cmp [allow_dma_access], 2 jae .nodma - cmp [ecx+IDE_DATA.dma_hdd], 1 + push eax ecx + mov ecx, [hdpos] + dec ecx + shr ecx, 2 + imul ecx, sizeof.IDE_DATA + add ecx, IDE_controller_1 + mov [IDE_controller_pointer], ecx + + mov eax, [hdpos] + dec eax + and eax, 11b + shr eax, 1 + add eax, ecx + cmp [eax+IDE_DATA.dma_hdd_channel_1], 1 + pop ecx eax jnz .nodma call cache_write_dma @@ -846,13 +874,7 @@ hd_read_dma: mov word [eax+4], 0x2000 sub eax, OS_BASE ; select controller Primary or Secondary -; 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 ecx, [IDE_controller_pointer] mov dx, [ecx+IDE_DATA.RegsBaseAddres] push eax @@ -1039,13 +1061,7 @@ cache_write_dma: sub eax, OS_BASE ; select controller Primary or Secondary -; 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 ecx, [IDE_controller_pointer] mov dx, [ecx+IDE_DATA.RegsBaseAddres] push eax @@ -1219,7 +1235,10 @@ align 4 cmp esi, pcidev_list jz .done - cmp [esi+PCIDEV.class], 0x01018F +; cmp [esi+PCIDEV.class], 0x01018F + mov eax, [esi+PCIDEV.class] + shr eax, 4 + cmp eax, 0x01018 jnz .loop mov ah, [esi+PCIDEV.bus] diff --git a/kernel/trunk/detect/init_ata.inc b/kernel/trunk/detect/init_ata.inc index ddaaf2759d..f73ec0c2f1 100644 --- a/kernel/trunk/detect/init_ata.inc +++ b/kernel/trunk/detect/init_ata.inc @@ -146,8 +146,11 @@ endg ;----------------------------------------------------------------------------- Init_IDE_ATA_controller: cmp [ecx+IDE_DATA.ProgrammingInterface], 0 - je set_interrupts_for_IDE_controllers.continue + jne @f + ret +;-------------------------------------- +@@: mov esi, boot_disabling_ide call boot_log ;-------------------------------------- @@ -173,8 +176,18 @@ Init_IDE_ATA_controller: mov esi, boot_detecthdcd call boot_log +;-------------------------------------- include 'dev_hdcd.inc' +;-------------------------------------- + ret ;----------------------------------------------------------------------------- +Init_IDE_ATA_controller_2: + cmp [ecx+IDE_DATA.ProgrammingInterface], 0 + jne @f + + ret +;-------------------------------------- +@@: mov dx, [ecx+IDE_DATA.RegsBaseAddres] ; test whether it is our interrupt? add dx, 2 @@ -204,26 +217,26 @@ include 'dev_hdcd.inc' add dx, 0x7 ;0x177 in al, dx ;----------------------------------------------------------------------------- - push eax edx - mov dx, [ecx+IDE_DATA.RegsBaseAddres] - xor eax, eax - add dx, 2 - in al, dx +; push eax edx +; mov dx, [ecx+IDE_DATA.RegsBaseAddres] +; xor eax, eax +; add dx, 2 +; in al, dx ; DEBUGF 1, "K : Primary Bus Master IDE Status Register %x\n", eax - add dx, 8 - in al, dx +; add dx, 8 +; in al, dx ; DEBUGF 1, "K : Secondary Bus Master IDE Status Register %x\n", eax - pop edx eax +; pop edx eax - cmp [ecx+IDE_DATA.RegsBaseAddres], 0 - setnz [ecx+IDE_DATA.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: +.set_interrupts_for_IDE_controllers: mov eax, [ecx+IDE_DATA.ProgrammingInterface] cmp ax, 0x0180 je .pata_ide @@ -286,6 +299,8 @@ set_interrupts_for_IDE_controllers: jz @f DEBUGF 1, "K : IDE CH1 PIO, because ATAPI drive present\n" + mov [ecx+IDE_DATA.dma_hdd_channel_1], byte 0 + jmp .ch2_check ;-------------------------------------- @@: @@ -293,12 +308,15 @@ set_interrupts_for_IDE_controllers: add dx, 2 ;0x3F6 out dx, al DEBUGF 1, "K : IDE CH1 DMA enabled\n" + mov [ecx+IDE_DATA.dma_hdd_channel_1], byte 1 ;-------------------------------------- .ch2_check: test ah, 1010b jz @f DEBUGF 1, "K : IDE CH2 PIO, because ATAPI drive present\n" + mov [ecx+IDE_DATA.dma_hdd_channel_2], byte 0 + jmp .end_set_interrupts ;-------------------------------------- @@: @@ -306,19 +324,9 @@ set_interrupts_for_IDE_controllers: add dx, 2 ;0x376 out dx, al DEBUGF 1, "K : IDE CH2 DMA enabled\n" + mov [ecx+IDE_DATA.dma_hdd_channel_2], byte 1 ;-------------------------------------- .end_set_interrupts: -;----------------------------------------------------------------------------- - 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 @@ -341,4 +349,14 @@ include 'getcache.inc' mov esi, boot_detectpart call boot_log include 'sear_par.inc' +;----------------------------------------------------------------------------- + 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 ;----------------------------------------------------------------------------- diff --git a/kernel/trunk/kernel32.inc b/kernel/trunk/kernel32.inc index 9f86c38409..6575e570f0 100644 --- a/kernel/trunk/kernel32.inc +++ b/kernel/trunk/kernel32.inc @@ -160,7 +160,8 @@ struct IDE_DATA BAR1_val dw ? BAR2_val dw ? BAR3_val dw ? - dma_hdd db ? + dma_hdd_channel_1 db ? + dma_hdd_channel_2 db ? ends struct IDE_CACHE