Rev 5852 | Rev 6650 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5852 | Rev 6015 | ||
---|---|---|---|
Line 3... | Line 3... | ||
3 | ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; |
3 | ;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
4 | ;; Distributed under terms of the GNU General Public License ;; |
5 | ;; ;; |
5 | ;; ;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
6 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
Line 7... | Line 7... | ||
7 | 7 | ||
Line 8... | Line 8... | ||
8 | $Revision: 5852 $ |
8 | $Revision: 6015 $ |
Line 9... | Line 9... | ||
9 | 9 | ||
10 | ; HDD driver |
10 | ; HDD driver |
Line 502... | Line 502... | ||
502 | ;----------------------------------------------------------------- |
502 | ;----------------------------------------------------------------- |
503 | align 4 |
503 | align 4 |
504 | IDE_irq_14_handler: |
504 | IDE_irq_14_handler: |
505 | IDE_irq_15_handler: |
505 | IDE_irq_15_handler: |
506 | IDE_common_irq_handler: |
506 | IDE_common_irq_handler: |
- | 507 | ; Most of the time, we are here because we have requested |
|
- | 508 | ; a DMA transfer for the corresponding drive. |
|
- | 509 | ; However, |
|
- | 510 | ; a) we can be here because IDE IRQ is shared with some other device, |
|
- | 511 | ; that device has actually raised IRQ, |
|
- | 512 | ; it has nothing to do with IDE; |
|
- | 513 | ; b) we can be here because IDE controller just does not want |
|
- | 514 | ; to be silent and reacts to something even though |
|
- | 515 | ; we have, in theory, disabled IRQs. |
|
- | 516 | ; If the interrupt corresponds to our current request, |
|
- | 517 | ; remove the interrupt request and raise the event for the waiting code. |
|
- | 518 | ; In the case a), just return zero - not our interrupt. |
|
- | 519 | ; In the case b), remove the interrupt request and hope for the best. |
|
507 | ; DEBUGF 1, 'K : IDE_irq_handler %x\n', [IDE_common_irq_param]:2 |
520 | ; DEBUGF 1, 'K : IDE_irq_handler %x\n', [IDE_common_irq_param]:2 |
508 | cmp [IDE_common_irq_param], 0 |
- | |
509 | jz .exit |
521 | mov ecx, [esp+4] |
510 | pushfd |
- | |
511 | cli |
- | |
512 | pushad |
- | |
513 | mov ecx, [IDE_controller_pointer] |
- | |
514 | mov dx, [ecx+IDE_DATA.RegsBaseAddres] |
522 | mov dx, [ecx+IDE_DATA.RegsBaseAddres] |
515 | cmp [IDE_common_irq_param], 14 |
- | |
516 | jz @f |
- | |
517 | add dx, 8 |
- | |
518 | @@: |
- | |
519 | add edx, 2 ; Bus Master IDE Status register |
523 | add edx, 2 ; Bus Master IDE Status register |
520 | in al, dx |
524 | in al, dx |
521 | test al, 4 |
525 | test al, 4 |
- | 526 | jnz .interrupt_from_primary |
|
- | 527 | add edx, 8 |
|
522 | jz @f |
528 | in al, dx |
- | 529 | test al, 4 |
|
523 | mov [IDE_common_irq_param], 0 |
530 | jnz .interrupt_from_secondary |
- | 531 | .exit_notour: |
|
- | 532 | xor eax, eax ; not our interrupt |
|
- | 533 | ret |
|
- | 534 | .interrupt_from_primary: |
|
524 | out dx, al ; clear Interrupt bit |
535 | out dx, al ; clear Interrupt bit |
525 | sub edx, 2 |
536 | sub edx, 2 |
526 | xor eax, eax |
537 | xor eax, eax |
527 | out dx, al ; clear Bus Master IDE Command register |
538 | out dx, al ; clear Bus Master IDE Command register |
- | 539 | mov dx, [ecx+IDE_DATA.BAR0_val] |
|
- | 540 | add edx, 7 |
|
- | 541 | in al, dx ; read status register |
|
- | 542 | cmp [IDE_common_irq_param], 14 |
|
- | 543 | jz .raise |
|
- | 544 | .exit_our: |
|
- | 545 | mov al, 1 |
|
- | 546 | ret |
|
- | 547 | .interrupt_from_secondary: |
|
- | 548 | out dx, al ; clear Interrupt bit |
|
- | 549 | sub edx, 2 |
|
528 | mov edx, [hdbase] |
550 | xor eax, eax |
- | 551 | out dx, al ; clear Bus Master IDE Command register |
|
- | 552 | mov dx, [ecx+IDE_DATA.BAR2_val] |
|
529 | add edx, 7 |
553 | add edx, 7 |
530 | in al, dx ; read status register |
554 | in al, dx ; read status register |
- | 555 | cmp [IDE_common_irq_param], 15 |
|
- | 556 | jnz .exit_our |
|
- | 557 | .raise: |
|
- | 558 | cmp ecx, [IDE_controller_pointer] |
|
- | 559 | jnz .exit_our |
|
- | 560 | pushad |
|
531 | mov eax, [eventPointer] |
561 | mov eax, [eventPointer] |
532 | mov ebx, [eventID] |
562 | mov ebx, [eventID] |
533 | xor edx, edx |
563 | xor edx, edx |
534 | xor esi, esi |
564 | xor esi, esi |
535 | call raise_event |
565 | call raise_event |
536 | popad |
566 | popad |
537 | popfd |
- | |
538 | mov al, 1 ; remove the interrupt request |
567 | mov al, 1 ; remove the interrupt request |
539 | ret |
568 | ret |
540 | @@: |
- | |
541 | popad |
- | |
542 | popfd |
- | |
543 | .exit: |
- | |
544 | xor eax, eax ; not our interrupt |
- | |
545 | ret |
- | |
546 | ;----------------------------------------------------------------- |
569 | ;----------------------------------------------------------------- |
547 | proc clear_pci_ide_interrupts |
- | |
548 | mov esi, pcidev_list |
- | |
549 | align 4 |
- | |
550 | .loop: |
- | |
551 | mov esi, [esi+PCIDEV.fd] |
- | |
552 | cmp esi, pcidev_list |
- | |
553 | jz .done |
- | |
554 | - | ||
555 | ; cmp [esi+PCIDEV.class], 0x01018F |
- | |
556 | mov eax, [esi+PCIDEV.class] |
- | |
557 | shr eax, 4 |
- | |
558 | cmp eax, 0x01018 |
- | |
559 | jnz .loop |
- | |
560 | - | ||
561 | mov ah, [esi+PCIDEV.bus] |
- | |
562 | mov al, 2 |
- | |
563 | mov bh, [esi+PCIDEV.devfn] |
- | |
564 | mov bl, 0x20 |
- | |
565 | call pci_read_reg |
- | |
566 | - | ||
567 | and eax, 0FFFCh |
- | |
568 | mov edx, eax |
- | |
569 | add edx, 2 |
- | |
570 | in al, dx |
- | |
571 | DEBUGF 1,'K : clear_pci_ide_interrupts: port[%x] = %x ',dx,al |
- | |
572 | out dx, al |
- | |
573 | in al, dx |
- | |
574 | DEBUGF 1,'-> %x; ',al |
- | |
575 | add edx, 8 |
- | |
576 | in al, dx |
- | |
577 | DEBUGF 1,'port[%x] = %x ',dx,al |
- | |
578 | out dx, al |
- | |
579 | in al, dx |
- | |
580 | DEBUGF 1,'-> %x\n',al |
- | |
581 | jmp .loop |
- | |
582 | .done: |
- | |
583 | ret |
- | |
584 | endp |
- |