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