[3] | 1 | ; File name : HIRQ.asm
|
---|
| 2 | ; Project name : IDE BIOS
|
---|
| 3 | ; Created date : 11.12.2009
|
---|
[35] | 4 | ; Last update : 24.8.2010
|
---|
[3] | 5 | ; Author : Tomi Tilli
|
---|
| 6 | ; Description : Interrupt handling related functions.
|
---|
| 7 |
|
---|
| 8 | ; Section containing code
|
---|
| 9 | SECTION .text
|
---|
| 10 |
|
---|
| 11 | ;--------------------------------------------------------------------
|
---|
[34] | 12 | ; HIRQ_WaitForIRQ
|
---|
[3] | 13 | ; Parameters:
|
---|
| 14 | ; DS: RAMVARS segment
|
---|
| 15 | ; Returns:
|
---|
[34] | 16 | ; CF: Set if wait done by operating system
|
---|
| 17 | ; Cleared if BIOS must perform task flag polling
|
---|
[3] | 18 | ; Corrupts registers:
|
---|
[34] | 19 | ; AX
|
---|
[3] | 20 | ;--------------------------------------------------------------------
|
---|
| 21 | ALIGN JUMP_ALIGN
|
---|
[34] | 22 | HIRQ_WaitForIRQ:
|
---|
| 23 | test BYTE [bx+DPT.bDrvCtrl], FLG_IDE_CTRL_nIEN ; Clears CF
|
---|
| 24 | jz SHORT .NotifyOperatingSystemAboutWaitingForIRQ
|
---|
| 25 | ret ; Go to poll status register
|
---|
[3] | 26 |
|
---|
[28] | 27 | ;--------------------------------------------------------------------
|
---|
| 28 | ; .NotifyOperatingSystemAboutWaitingForIRQ
|
---|
| 29 | ; Parameters:
|
---|
[34] | 30 | ; Nothing
|
---|
[28] | 31 | ; Returns:
|
---|
| 32 | ; CF: Set if wait done by operating system
|
---|
| 33 | ; Cleared if BIOS must perform task flag polling
|
---|
| 34 | ; Corrupts registers:
|
---|
| 35 | ; AX
|
---|
| 36 | ;--------------------------------------------------------------------
|
---|
| 37 | ALIGN JUMP_ALIGN
|
---|
| 38 | .NotifyOperatingSystemAboutWaitingForIRQ:
|
---|
[34] | 39 | push ds
|
---|
| 40 |
|
---|
| 41 | LOAD_BDA_SEGMENT_TO ds, ax ; Zero AX
|
---|
[3] | 42 | cli ; Disable interrupts
|
---|
[34] | 43 | cmp al, [ds:BDA.bHDTaskFlg] ; Task flag already set?
|
---|
[28] | 44 | jc SHORT .ReturnFromWaitNotify ; If so, skip OS notification
|
---|
[3] | 45 |
|
---|
| 46 | mov ah, 90h ; Hard disk busy (AX=9000h)
|
---|
| 47 | int INTV_SYSTEM_SERVICES ; OS hook, device busy
|
---|
[28] | 48 | jnc SHORT .ReturnFromWaitNotify ; CF cleared, BIOS handles waiting
|
---|
[3] | 49 |
|
---|
[28] | 50 | ; Make sure that OS hooks are supported, otherwise the CF means unsupported function
|
---|
| 51 | test ah, ah ; OS hook supported? (clears CF)
|
---|
| 52 | jnz SHORT .ReturnFromWaitNotify ; AH has error, BIOS must do the wait
|
---|
| 53 | stc ; Set CF since wait done by OS
|
---|
| 54 | .ReturnFromWaitNotify:
|
---|
[34] | 55 | pop ds
|
---|
[3] | 56 | sti ; Enable interrupts
|
---|
| 57 | ret
|
---|
| 58 |
|
---|
[28] | 59 |
|
---|
[3] | 60 | ;--------------------------------------------------------------------
|
---|
| 61 | ; Clears task (interrupt) flag from BIOS Data Area.
|
---|
| 62 | ;
|
---|
| 63 | ; HIRQ_ClearTaskFlag
|
---|
| 64 | ; Parameters:
|
---|
| 65 | ; Nothing
|
---|
| 66 | ; Returns:
|
---|
| 67 | ; Nothing
|
---|
| 68 | ; Corrupts registers:
|
---|
| 69 | ; AX
|
---|
| 70 | ;--------------------------------------------------------------------
|
---|
| 71 | ALIGN JUMP_ALIGN
|
---|
| 72 | HIRQ_ClearTaskFlag:
|
---|
| 73 | push ds
|
---|
| 74 | LOAD_BDA_SEGMENT_TO ds, ax ; Also zero AX
|
---|
| 75 | mov [BDA.bHDTaskFlg], al
|
---|
| 76 | pop ds
|
---|
| 77 | ret
|
---|
| 78 |
|
---|
| 79 |
|
---|
| 80 | ;--------------------------------------------------------------------
|
---|
| 81 | ; IDE Interrupt Service Routines.
|
---|
| 82 | ;
|
---|
| 83 | ; HIRQ_InterruptServiceRoutineForIrqs2to7
|
---|
| 84 | ; HIRQ_InterruptServiceRoutineForIrqs8to15
|
---|
| 85 | ; Parameters:
|
---|
| 86 | ; Nothing
|
---|
| 87 | ; Returns:
|
---|
| 88 | ; Nothing
|
---|
| 89 | ; Corrupts registers:
|
---|
| 90 | ; Nothing
|
---|
| 91 | ;--------------------------------------------------------------------
|
---|
| 92 | ALIGN JUMP_ALIGN
|
---|
| 93 | HIRQ_InterruptServiceRoutineForIrqs2to7:
|
---|
| 94 | push ax
|
---|
[28] | 95 | call AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA
|
---|
| 96 |
|
---|
[3] | 97 | mov al, CMD_END_OF_INTERRUPT
|
---|
[28] | 98 | jmp SHORT AcknowledgeMasterInterruptController
|
---|
[3] | 99 |
|
---|
[35] | 100 |
|
---|
[3] | 101 | ALIGN JUMP_ALIGN
|
---|
| 102 | HIRQ_InterruptServiceRoutineForIrqs8to15:
|
---|
| 103 | push ax
|
---|
[28] | 104 | call AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA
|
---|
[3] | 105 |
|
---|
| 106 | mov al, CMD_END_OF_INTERRUPT ; Load EOI command to AL
|
---|
| 107 | out WPORT_8259SL_COMMAND, al ; Acknowledge Slave 8259
|
---|
[28] | 108 | AcknowledgeMasterInterruptController:
|
---|
[3] | 109 | out WPORT_8259MA_COMMAND, al ; Acknowledge Master 8259
|
---|
| 110 |
|
---|
| 111 | ; Issue Int 15h, function AX=9100h (Interrupt ready)
|
---|
| 112 | mov ax, 9100h ; Interrupt ready, device 0 (HD)
|
---|
| 113 | int INTV_SYSTEM_SERVICES
|
---|
| 114 |
|
---|
| 115 | pop ax ; Restore AX
|
---|
| 116 | iret
|
---|
| 117 |
|
---|
| 118 | ;--------------------------------------------------------------------
|
---|
| 119 | ; Acknowledges IDE interrupt by reading status register and
|
---|
| 120 | ; stores Status and Error Registers to BDA. Task flag in BDA will
|
---|
| 121 | ; also be set.
|
---|
| 122 | ;
|
---|
[28] | 123 | ; AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA
|
---|
[3] | 124 | ; Parameters:
|
---|
| 125 | ; Nothing
|
---|
| 126 | ; Returns:
|
---|
| 127 | ; Nothing
|
---|
| 128 | ; Corrupts registers:
|
---|
| 129 | ; AX
|
---|
| 130 | ;--------------------------------------------------------------------
|
---|
| 131 | ALIGN JUMP_ALIGN
|
---|
[28] | 132 | AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA:
|
---|
[3] | 133 | push ds
|
---|
| 134 | push di
|
---|
| 135 |
|
---|
| 136 | ; Reading Status Register acknowledges IDE interrupt
|
---|
[34] | 137 | call RamVars_GetSegmentToDS
|
---|
| 138 | call HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA
|
---|
[35] | 139 |
|
---|
| 140 | ; Set Task Flag
|
---|
| 141 | LOAD_BDA_SEGMENT_TO ds, ax
|
---|
[28] | 142 | mov BYTE [BDA.bHDTaskFlg], 0FFh ; Set task flag
|
---|
[3] | 143 |
|
---|
| 144 | pop di
|
---|
| 145 | pop ds
|
---|
| 146 | ret
|
---|