[150] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
| 2 | ; Description : Interrupt handling related functions.
|
---|
| 3 |
|
---|
| 4 | ; Section containing code
|
---|
| 5 | SECTION .text
|
---|
| 6 |
|
---|
| 7 | ;--------------------------------------------------------------------
|
---|
| 8 | ; IdeIrq_WaitForIRQ
|
---|
| 9 | ; Parameters:
|
---|
| 10 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
| 11 | ; Returns:
|
---|
| 12 | ; CF: Set if wait done by operating system
|
---|
| 13 | ; Cleared if BIOS must perform task flag polling
|
---|
| 14 | ; Corrupts registers:
|
---|
| 15 | ; AX
|
---|
| 16 | ;--------------------------------------------------------------------
|
---|
| 17 | ALIGN JUMP_ALIGN
|
---|
| 18 | IdeIrq_WaitForIRQ:
|
---|
| 19 |
|
---|
| 20 | ;--------------------------------------------------------------------
|
---|
| 21 | ; .NotifyOperatingSystemAboutWaitingForIRQ
|
---|
| 22 | ; Parameters:
|
---|
| 23 | ; Nothing
|
---|
| 24 | ; Returns:
|
---|
| 25 | ; CF: Set if wait done by operating system
|
---|
| 26 | ; Cleared if BIOS must perform task flag polling
|
---|
| 27 | ; Corrupts registers:
|
---|
| 28 | ; AX
|
---|
| 29 | ;--------------------------------------------------------------------
|
---|
| 30 | .NotifyOperatingSystemAboutWaitingForIRQ:
|
---|
| 31 | push ds
|
---|
| 32 |
|
---|
| 33 | LOAD_BDA_SEGMENT_TO ds, ax, ! ; Zero AX
|
---|
| 34 | mov ah, OS_HOOK_DEVICE_BUSY ; Hard disk busy (AX=9000h)
|
---|
| 35 | cli ; Disable interrupts
|
---|
| 36 | cmp al, [BDA.bHDTaskFlg] ; Task flag already set?
|
---|
| 37 | jc SHORT .ReturnFromWaitNotify ; If so, skip OS notification
|
---|
| 38 | int BIOS_SYSTEM_INTERRUPT_15h ; OS hook, device busy
|
---|
| 39 | jnc SHORT .ReturnFromWaitNotify ; CF cleared, BIOS handles waiting
|
---|
| 40 |
|
---|
| 41 | ; Make sure that OS hooks are supported, otherwise the CF means unsupported function
|
---|
| 42 | test ah, ah ; OS hook supported? (clears CF)
|
---|
| 43 | jnz SHORT .ReturnFromWaitNotify ; AH has error, BIOS must do the wait
|
---|
| 44 | stc ; Set CF since wait done by OS
|
---|
| 45 | .ReturnFromWaitNotify:
|
---|
| 46 | pop ds
|
---|
| 47 | sti ; Enable interrupts
|
---|
| 48 | ret
|
---|
| 49 |
|
---|
| 50 |
|
---|
| 51 | ;--------------------------------------------------------------------
|
---|
| 52 | ; IDE Interrupt Service Routines.
|
---|
| 53 | ;
|
---|
| 54 | ; IdeIrq_InterruptServiceRoutineForIrqs2to7
|
---|
| 55 | ; IdeIrq_InterruptServiceRoutineForIrqs8to15
|
---|
| 56 | ; Parameters:
|
---|
| 57 | ; Nothing
|
---|
| 58 | ; Returns:
|
---|
| 59 | ; Nothing
|
---|
| 60 | ; Corrupts registers:
|
---|
| 61 | ; Nothing
|
---|
| 62 | ;--------------------------------------------------------------------
|
---|
| 63 | ALIGN JUMP_ALIGN
|
---|
| 64 | IdeIrq_InterruptServiceRoutineForIrqs2to7:
|
---|
| 65 | push di
|
---|
| 66 | push ax
|
---|
| 67 | call AcknowledgeIdeInterruptAndSetTaskFlag
|
---|
| 68 |
|
---|
[152] | 69 | mov al, COMMAND_END_OF_INTERRUPT
|
---|
[150] | 70 | jmp SHORT AcknowledgeMasterInterruptController
|
---|
| 71 |
|
---|
| 72 |
|
---|
| 73 | ALIGN JUMP_ALIGN
|
---|
| 74 | IdeIrq_InterruptServiceRoutineForIrqs8to15:
|
---|
| 75 | push di
|
---|
| 76 | push ax
|
---|
| 77 | call AcknowledgeIdeInterruptAndSetTaskFlag
|
---|
| 78 |
|
---|
[152] | 79 | mov al, COMMAND_END_OF_INTERRUPT
|
---|
| 80 | out SLAVE_8259_COMMAND_out, al ; Acknowledge Slave 8259
|
---|
[150] | 81 | AcknowledgeMasterInterruptController:
|
---|
[152] | 82 | out MASTER_8259_COMMAND_out, al ; Acknowledge Master 8259
|
---|
[150] | 83 |
|
---|
| 84 | ; Issue Int 15h, function AX=9100h (Interrupt ready)
|
---|
| 85 | mov ax, OS_HOOK_DEVICE_POST<<8 ; Interrupt ready, device 0 (HD)
|
---|
| 86 | int BIOS_SYSTEM_INTERRUPT_15h
|
---|
| 87 |
|
---|
| 88 | pop ax
|
---|
| 89 | pop di
|
---|
| 90 | iret
|
---|
| 91 |
|
---|
| 92 |
|
---|
| 93 | ;--------------------------------------------------------------------
|
---|
| 94 | ; AcknowledgeIdeInterruptAndSetTaskFlag
|
---|
| 95 | ; Parameters:
|
---|
| 96 | ; Nothing
|
---|
| 97 | ; Returns:
|
---|
| 98 | ; Nothing
|
---|
| 99 | ; Corrupts registers:
|
---|
| 100 | ; AX
|
---|
| 101 | ;--------------------------------------------------------------------
|
---|
| 102 | ALIGN JUMP_ALIGN
|
---|
| 103 | AcknowledgeIdeInterruptAndSetTaskFlag:
|
---|
| 104 | push ds
|
---|
[152] | 105 | push si
|
---|
[150] | 106 | push dx
|
---|
| 107 | push bx
|
---|
| 108 |
|
---|
| 109 | ; Reading Status Register acknowledges IDE interrupt
|
---|
| 110 | call RamVars_GetSegmentToDS
|
---|
[152] | 111 | call FindDPT_ToDSDIforInterruptInService
|
---|
[150] | 112 | mov dl, STATUS_REGISTER_in
|
---|
| 113 | call Device_InputToALfromIdeRegisterInDL
|
---|
| 114 |
|
---|
[152] | 115 | ; Clear Interrupt In-Service Flag from DPT
|
---|
| 116 | and WORD [di+DPT.wFlags], ~FLG_DPT_INTERRUPT_IN_SERVICE
|
---|
| 117 |
|
---|
[150] | 118 | ; Set Task Flag
|
---|
| 119 | LOAD_BDA_SEGMENT_TO ds, ax
|
---|
| 120 | mov BYTE [BDA.bHDTaskFlg], 0FFh ; Set task flag
|
---|
| 121 |
|
---|
| 122 | pop bx
|
---|
| 123 | pop dx
|
---|
[152] | 124 | pop si
|
---|
[150] | 125 | pop ds
|
---|
| 126 | ret
|
---|