1 | ; Project name : XTIDE Universal BIOS
|
---|
2 | ; Description : Interrupt handling related functions.
|
---|
3 |
|
---|
4 | ;
|
---|
5 | ; XTIDE Universal BIOS and Associated Tools
|
---|
6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
|
---|
7 | ;
|
---|
8 | ; This program is free software; you can redistribute it and/or modify
|
---|
9 | ; it under the terms of the GNU General Public License as published by
|
---|
10 | ; the Free Software Foundation; either version 2 of the License, or
|
---|
11 | ; (at your option) any later version.
|
---|
12 | ;
|
---|
13 | ; This program is distributed in the hope that it will be useful,
|
---|
14 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
16 | ; GNU General Public License for more details.
|
---|
17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
18 | ;
|
---|
19 |
|
---|
20 | ; Section containing code
|
---|
21 | SECTION .text
|
---|
22 |
|
---|
23 | ;--------------------------------------------------------------------
|
---|
24 | ; IdeIrq_WaitForIRQ
|
---|
25 | ; Parameters:
|
---|
26 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
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 | IdeIrq_WaitForIRQ:
|
---|
35 |
|
---|
36 | ;--------------------------------------------------------------------
|
---|
37 | ; .NotifyOperatingSystemAboutWaitingForIRQ
|
---|
38 | ; Parameters:
|
---|
39 | ; Nothing
|
---|
40 | ; Returns:
|
---|
41 | ; CF: Set if wait done by operating system
|
---|
42 | ; Cleared if BIOS must perform task flag polling
|
---|
43 | ; Corrupts registers:
|
---|
44 | ; AX
|
---|
45 | ;--------------------------------------------------------------------
|
---|
46 | .NotifyOperatingSystemAboutWaitingForIRQ:
|
---|
47 | push ds
|
---|
48 |
|
---|
49 | LOAD_BDA_SEGMENT_TO ds, ax, ! ; Zero AX
|
---|
50 | mov ah, OS_HOOK_DEVICE_BUSY ; Hard disk busy (AX=9000h)
|
---|
51 | cli ; Disable interrupts
|
---|
52 | cmp al, [BDA.bHDTaskFlg] ; Task flag already set?
|
---|
53 | jc SHORT .ReturnFromWaitNotify ; If so, skip OS notification
|
---|
54 | int BIOS_SYSTEM_INTERRUPT_15h ; OS hook, device busy
|
---|
55 | jnc SHORT .ReturnFromWaitNotify ; CF cleared, BIOS handles waiting
|
---|
56 |
|
---|
57 | ; Make sure that OS hooks are supported, otherwise the CF means unsupported function
|
---|
58 | test ah, ah ; OS hook supported? (clears CF)
|
---|
59 | jnz SHORT .ReturnFromWaitNotify ; AH has error, BIOS must do the wait
|
---|
60 | stc ; Set CF since wait done by OS
|
---|
61 | .ReturnFromWaitNotify:
|
---|
62 | sti ; Enable interrupts
|
---|
63 | pop ds
|
---|
64 | ret
|
---|
65 |
|
---|
66 |
|
---|
67 | ;--------------------------------------------------------------------
|
---|
68 | ; IDE Interrupt Service Routines.
|
---|
69 | ;
|
---|
70 | ; IdeIrq_InterruptServiceRoutineForIrqs2to7
|
---|
71 | ; IdeIrq_InterruptServiceRoutineForIrqs8to15
|
---|
72 | ; Parameters:
|
---|
73 | ; Nothing
|
---|
74 | ; Returns:
|
---|
75 | ; Nothing
|
---|
76 | ; Corrupts registers:
|
---|
77 | ; Nothing
|
---|
78 | ;--------------------------------------------------------------------
|
---|
79 | ALIGN JUMP_ALIGN
|
---|
80 | IdeIrq_InterruptServiceRoutineForIrqs2to7:
|
---|
81 | push di
|
---|
82 | push ax
|
---|
83 | call AcknowledgeIdeInterruptAndSetTaskFlag
|
---|
84 |
|
---|
85 | mov al, COMMAND_END_OF_INTERRUPT
|
---|
86 | jmp SHORT AcknowledgeMasterInterruptController
|
---|
87 |
|
---|
88 |
|
---|
89 | ALIGN JUMP_ALIGN
|
---|
90 | IdeIrq_InterruptServiceRoutineForIrqs8to15:
|
---|
91 | push di
|
---|
92 | push ax
|
---|
93 | call AcknowledgeIdeInterruptAndSetTaskFlag
|
---|
94 |
|
---|
95 | mov al, COMMAND_END_OF_INTERRUPT
|
---|
96 | out SLAVE_8259_COMMAND_out, al ; Acknowledge Slave 8259
|
---|
97 | AcknowledgeMasterInterruptController:
|
---|
98 | out MASTER_8259_COMMAND_out, al ; Acknowledge Master 8259
|
---|
99 |
|
---|
100 | ; Issue Int 15h, function AX=9100h (Interrupt ready)
|
---|
101 | mov ax, OS_HOOK_DEVICE_POST<<8 ; Interrupt ready, device 0 (HD)
|
---|
102 | int BIOS_SYSTEM_INTERRUPT_15h
|
---|
103 |
|
---|
104 | pop ax
|
---|
105 | pop di
|
---|
106 | iret
|
---|
107 |
|
---|
108 |
|
---|
109 | ;--------------------------------------------------------------------
|
---|
110 | ; AcknowledgeIdeInterruptAndSetTaskFlag
|
---|
111 | ; Parameters:
|
---|
112 | ; Nothing
|
---|
113 | ; Returns:
|
---|
114 | ; Nothing
|
---|
115 | ; Corrupts registers:
|
---|
116 | ; AX
|
---|
117 | ;--------------------------------------------------------------------
|
---|
118 | ALIGN JUMP_ALIGN
|
---|
119 | AcknowledgeIdeInterruptAndSetTaskFlag:
|
---|
120 | push ds
|
---|
121 | push si
|
---|
122 | push dx
|
---|
123 | push bx
|
---|
124 |
|
---|
125 | ; Reading Status Register acknowledges IDE interrupt
|
---|
126 | call RamVars_GetSegmentToDS
|
---|
127 | mov bl, FLGH_DPT_INTERRUPT_IN_SERVICE
|
---|
128 | call FindDPT_ToDSDIforFlagsHighInBL
|
---|
129 | INPUT_TO_AL_FROM_IDE_REGISTER STATUS_REGISTER_in
|
---|
130 |
|
---|
131 | ; Clear Interrupt In-Service Flag from DPT
|
---|
132 | and BYTE [di+DPT.bFlagsHigh], ~FLGH_DPT_INTERRUPT_IN_SERVICE
|
---|
133 |
|
---|
134 | ; Set Task Flag
|
---|
135 | LOAD_BDA_SEGMENT_TO ds, ax
|
---|
136 | mov BYTE [BDA.bHDTaskFlg], 0FFh ; Set task flag
|
---|
137 |
|
---|
138 | pop bx
|
---|
139 | pop dx
|
---|
140 | pop si
|
---|
141 | pop ds
|
---|
142 | ret
|
---|