Changeset 28 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HIRQ.asm
- Timestamp:
- Aug 1, 2010, 5:57:24 PM (14 years ago)
- google:author:
- aitotat
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HIRQ.asm
r3 r28 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 11.12.2009 4 ; Last update : 28.3.20104 ; Last update : 1.8.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Interrupt handling related functions. … … 20 20 ; Set if any error 21 21 ; Corrupts registers: 22 ; AL , CX22 ; AL 23 23 ;-------------------------------------------------------------------- 24 24 ALIGN JUMP_ALIGN 25 25 HIRQ_WaitIRQ: 26 ; Load BDA segment to ES27 26 push es 28 xor ax, ax ; Zero AX and clear CF29 mov es, ax ; Copy BDA segment (zero) to ES30 27 31 ; Check if interrupt has already occurred 28 LOAD_BDA_SEGMENT_TO es, ax 29 %ifdef USE_AT ; OS hook only available on AT+ machines 30 call .NotifyOperatingSystemAboutWaitingForIRQ 31 cmc 32 jnc SHORT .TaskFlagPollingComplete 33 %endif 34 call .WaitUntilTaskFlagIsSet ; Process errors 35 36 ALIGN JUMP_ALIGN 37 .TaskFlagPollingComplete: 38 call HError_ProcessErrorsAfterPollingTaskFlag 39 pop es 40 ret 41 42 ;-------------------------------------------------------------------- 43 ; .NotifyOperatingSystemAboutWaitingForIRQ 44 ; Parameters: 45 ; ES: BDA segment (zero) 46 ; Returns: 47 ; CF: Set if wait done by operating system 48 ; Cleared if BIOS must perform task flag polling 49 ; Corrupts registers: 50 ; AX 51 ;-------------------------------------------------------------------- 52 %ifdef USE_AT 53 ALIGN JUMP_ALIGN 54 .NotifyOperatingSystemAboutWaitingForIRQ: 32 55 cli ; Disable interrupts 33 cmp [es:BDA.bHDTaskFlg], al ; Interrupt ready? 34 jne SHORT .CheckIdeErrors ; If so, return 56 xor ax, ax 57 cmp al, [es:BDA.bHDTaskFlg] ; Task flag already set? 58 jc SHORT .ReturnFromWaitNotify ; If so, skip OS notification 35 59 36 %ifdef USE_AT ; OS hook only available on AT+ machines37 ; OS device busy notification38 60 mov ah, 90h ; Hard disk busy (AX=9000h) 39 61 int INTV_SYSTEM_SERVICES ; OS hook, device busy 40 jnc SHORT .WaitUntilTaskFlagSet ; CF cleared, BIOS handles waiting 41 test ah, ah ; OS hook supported? (clear CF) 42 jz SHORT .CheckIdeErrors ; If so, waiting completed 43 ALIGN JUMP_ALIGN 44 .WaitUntilTaskFlagSet: 45 %endif 62 jnc SHORT .ReturnFromWaitNotify ; CF cleared, BIOS handles waiting 46 63 47 ; Poll task flag until it has been set by interrupt service routine 48 call HIRQ_WaitUntilTaskFlagIsSet 49 jc SHORT .ReturnTimeout ; Return if timeout 50 51 ALIGN JUMP_ALIGN 52 .CheckIdeErrors: 53 mov ax, [es:HDBDA.wHDStAndErr] ; Load Status and Error regs stored by ISR 54 call HError_ConvertIdeErrorToBiosRet 55 .ReturnTimeout: 56 mov BYTE [es:BDA.bHDTaskFlg], 0 ; Clear Task Flag 57 pop es 64 ; Make sure that OS hooks are supported, otherwise the CF means unsupported function 65 test ah, ah ; OS hook supported? (clears CF) 66 jnz SHORT .ReturnFromWaitNotify ; AH has error, BIOS must do the wait 67 stc ; Set CF since wait done by OS 68 .ReturnFromWaitNotify: 58 69 sti ; Enable interrupts 59 70 ret 60 71 %endif 61 72 62 73 ;-------------------------------------------------------------------- 63 74 ; Polls IRQ Task Flag until it has been set or timeout. 64 75 ; 65 ; HIRQ_WaitUntilTaskFlagIsSet76 ; .WaitUntilTaskFlagIsSet 66 77 ; Parameters: 67 78 ; DS: RAMVARS segment 68 79 ; ES: BDA segment 69 80 ; Returns: 70 ; AH: BIOS Error code 71 ; CF: Cleared if wait succesfull 72 ; Set if timeout 81 ; CF: Set if timeout 82 ; Cleared if Task Flag set 73 83 ; Corrupts registers: 74 ; A L, CX84 ; AX 75 85 ;-------------------------------------------------------------------- 76 86 ALIGN JUMP_ALIGN 77 HIRQ_WaitUntilTaskFlagIsSet: 78 sti ; Enable interrupts 87 .WaitUntilTaskFlagIsSet: 88 push cx 89 79 90 mov cl, B_TIMEOUT_DRQ ; Load timeout ticks 80 91 call SoftDelay_InitTimeout ; Initialize timeout counter … … 82 93 ALIGN JUMP_ALIGN 83 94 .PollIrqFlag: 84 cli ; Disable interrupt s85 cmp [es:BDA.bHDTaskFlg], al ; Task flag set? 86 jne SHORT . TaskFlagIsSet ; If so, return95 cli ; Disable interrupt until next HLT 96 cmp [es:BDA.bHDTaskFlg], al ; Task flag set? (clears CF) 97 jne SHORT .Return 87 98 call SoftDelay_UpdTimeout ; Update timeout 88 jc SHORT . Timeout; Return if timeout89 sti ; Enable interrupts ( one instruction delay)99 jc SHORT .Return ; Return if timeout 100 sti ; Enable interrupts (STI has delay so HLT will catch all interrupts) 90 101 hlt ; Sleep until any interrupt 91 102 jmp SHORT .PollIrqFlag ; Jump to check if IDE interrupt 92 93 103 ALIGN JUMP_ALIGN 94 .TaskFlagIsSet: 95 xor ah, ah ; Zero AH, clear CF 96 ret 97 .Timeout: 98 mov ah, RET_HD_TIMEOUT ; Load error code for timeout 104 .Return: 105 pop cx 106 sti 99 107 ret 100 108 … … 134 142 ALIGN JUMP_ALIGN 135 143 HIRQ_InterruptServiceRoutineForIrqs2to7: 136 ; Acknowledge IDE interrupt by reading status register137 144 push ax 138 call ISR_IDE_AcknowledgeIdeAndStoreStatusToBDA 145 call AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA 146 139 147 mov al, CMD_END_OF_INTERRUPT 140 jmp SHORT HIRQ_AcknowledgeMasterController148 jmp SHORT AcknowledgeMasterInterruptController 141 149 142 150 ALIGN JUMP_ALIGN 143 151 HIRQ_InterruptServiceRoutineForIrqs8to15: 144 152 push ax 145 call ISR_IDE_AcknowledgeIdeAndStoreStatusToBDA153 call AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA 146 154 147 155 mov al, CMD_END_OF_INTERRUPT ; Load EOI command to AL 148 156 out WPORT_8259SL_COMMAND, al ; Acknowledge Slave 8259 149 HIRQ_AcknowledgeMasterController:157 AcknowledgeMasterInterruptController: 150 158 out WPORT_8259MA_COMMAND, al ; Acknowledge Master 8259 151 159 … … 156 164 %endif 157 165 158 ; Restore registers and return from interrupt159 166 pop ax ; Restore AX 160 167 iret 161 162 168 163 169 ;-------------------------------------------------------------------- … … 166 172 ; also be set. 167 173 ; 168 ; ISR_IDE_AcknowledgeIdeAndStoreStatusToBDA174 ; AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA 169 175 ; Parameters: 170 176 ; Nothing … … 175 181 ;-------------------------------------------------------------------- 176 182 ALIGN JUMP_ALIGN 177 ISR_IDE_AcknowledgeIdeAndStoreStatusToBDA:183 AcknowledgeIdeInterruptAndStoreStatusAndErrorRegistersToBDA: 178 184 push ds 179 185 push di 180 186 push dx 181 187 182 ; Read Status and Error registers.183 188 ; Reading Status Register acknowledges IDE interrupt 184 189 call RamVars_GetSegmentToDS 185 mov dx, [RAMVARS.wIdeBase] ; Load IDE base port address 186 inc dx ; Increment to Error Register 187 in al, dx ; Read Error Register... 188 mov ah, al ; ...and copy it to AH 189 add dx, REGR_IDE_ST-REGR_IDE_ERROR 190 in al, dx ; Read Status Register to AL 191 192 ; Store Status and Error register to BDA and set task flag 193 LOAD_BDA_SEGMENT_TO ds, dx 194 mov [HDBDA.wHDStAndErr], ax ; Store Status and Error Registers 195 mov BYTE [BDA.bHDTaskFlg], 0FFh ; Set task flag 190 call HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA 191 mov BYTE [BDA.bHDTaskFlg], 0FFh ; Set task flag 196 192 197 193 pop dx
Note: See TracChangeset
for help on using the changeset viewer.