source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Initialization/Interrupts.asm@ 91

Last change on this file since 91 was 90, checked in by Tomi Tilli, 14 years ago

Changes to XTIDE Universal BIOS:

  • Removed INT 13h format and diagnostics functions.
  • Removed INT 18h callback handler.
  • Removed configuration for early/late initialization. Now XT builds always use late and AT build early initialization.
  • Reduced number of supported IDE controllers from 5 to 4.
  • Removed reserved configuration bytes.
  • Removed simple and system boot loaders.
File size: 7.4 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Functions for initializing the BIOS.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Interrupts_InitializeInterruptVectors
9; Parameters:
10; DS: RAMVARS segment
11; ES: BDA and Interrupt Vector segment (zero)
12; Returns:
13; Nothing
14; Corrupts registers:
15; All except segments
16;--------------------------------------------------------------------
17ALIGN JUMP_ALIGN
18Interrupts_InitializeInterruptVectors:
19 call Interrupts_InitializeInt13hAnd40h
20 call Interrupts_InitializeInt19h
21 jmp SHORT Interrupts_InitializeHardwareIrqHandlers
22 ; Maybe all this should be inlined?
23
24
25;--------------------------------------------------------------------
26; Interrupts_Int13hAnd40h
27; Parameters:
28; DS: RAMVARS segment
29; ES: BDA and Interrupt Vector segment (zero)
30; Returns:
31; Nothing
32; Corrupts registers:
33; AX, BX, CX, DX, SI, DI
34;--------------------------------------------------------------------
35ALIGN JUMP_ALIGN
36Interrupts_InitializeInt13hAnd40h:
37 mov ax, [es:INTV_DISK_FUNC*4] ; Load old INT 13h offset
38 mov dx, [es:INTV_DISK_FUNC*4+2] ; Load old INT 13h segment
39 mov [RAMVARS.fpOldI13h], ax ; Store old INT 13h offset
40 mov [RAMVARS.fpOldI13h+2], dx ; Store old INT 13h segment
41 mov bx, INTV_DISK_FUNC ; INT 13h interrupt vector offset
42 mov si, Int13h_DiskFunctions ; Interrupt handler offset
43 call Interrupts_InstallHandlerToVectorInBXFromCSSI
44
45 ; Only store INT 13h handler to 40h if 40h is not already installed.
46 ; At least AMI BIOS for 286 stores 40h handler by itself and calls
47 ; 40h from 13h. That system locks to infinite loop if we copy 13h to 40h.
48 call FloppyDrive_IsInt40hInstalled
49 jc SHORT .Return
50 mov [es:INTV_FLOPPY_FUNC*4], ax ; Store offset
51 mov [es:INTV_FLOPPY_FUNC*4+2], dx ; Store segment
52.Return:
53 ret
54
55
56;--------------------------------------------------------------------
57; Interrupts_InitializeInt19h
58; Parameters:
59; DS: RAMVARS segment
60; ES: BDA and Interrupt Vector segment (zero)
61; Returns:
62; Nothing
63; Corrupts registers:
64; BX, SI
65;--------------------------------------------------------------------
66ALIGN JUMP_ALIGN
67Interrupts_InitializeInt19h:
68 mov bx, INTV_BOOTSTRAP
69 mov si, Int19hMenu_BootLoader
70 jmp Interrupts_InstallHandlerToVectorInBXFromCSSI
71
72
73;--------------------------------------------------------------------
74; Interrupts_InitializeHardwareIrqHandlers
75; Parameters:
76; ES: BDA and Interrupt Vector segment (zero)
77; Returns:
78; Nothing
79; Corrupts registers:
80; BX, CX, DX, SI, DI
81;--------------------------------------------------------------------
82ALIGN JUMP_ALIGN
83Interrupts_InitializeHardwareIrqHandlers:
84 call RamVars_GetIdeControllerCountToCX
85 mov di, ROMVARS.ideVars0 ; CS:SI points to first IDEVARS
86ALIGN JUMP_ALIGN
87.IdeControllerLoop:
88 eMOVZX bx, BYTE [cs:di+IDEVARS.bIRQ]
89 add di, BYTE IDEVARS_size ; Increment to next controller
90 call .InstallLowOrHighIrqHandler
91 loop .IdeControllerLoop
92.Return:
93 ret ; This ret is shared with .InstallLowOrHighIrqHandler
94
95;--------------------------------------------------------------------
96; .InstallLowOrHighIrqHandler
97; Parameters:
98; BX: IRQ number, 0 if IRQ disabled
99; ES: BDA and Interrupt Vector segment (zero)
100; Returns:
101; Nothing
102; Corrupts registers:
103; BX, SI
104;--------------------------------------------------------------------
105ALIGN JUMP_ALIGN
106.InstallLowOrHighIrqHandler:
107 test bl, bl
108 jz SHORT .Return ; IRQ not used
109 cmp bl, 8
110 jb SHORT .InstallLowIrqHandler
111 ; Fall through to .InstallHighIrqHandler
112
113;--------------------------------------------------------------------
114; .InstallHighIrqHandler
115; Parameters:
116; BX: IRQ number (8...15)
117; ES: BDA and Interrupt Vector segment (zero)
118; Returns:
119; Nothing
120; Corrupts registers:
121; BX, SI
122;--------------------------------------------------------------------
123;ALIGN JUMP_ALIGN
124;.InstallHighIrqHandler:
125 add bx, BYTE INTV_IRQ8 - 8 ; Interrupt vector number
126 mov si, HIRQ_InterruptServiceRoutineForIrqs8to15
127 jmp SHORT Interrupts_InstallHandlerToVectorInBXFromCSSI
128
129;--------------------------------------------------------------------
130; .InstallLowIrqHandler
131; Parameters:
132; BX: IRQ number (0...7)
133; ES: BDA and Interrupt Vector segment (zero)
134; Returns:
135; Nothing
136; Corrupts registers:
137; BX, SI
138;--------------------------------------------------------------------
139ALIGN JUMP_ALIGN
140.InstallLowIrqHandler:
141 add bx, BYTE INTV_IRQ0 ; Interrupt vector number
142 mov si, HIRQ_InterruptServiceRoutineForIrqs2to7
143 ; Fall to Interrupts_InstallHandlerToVectorInBXFromCSSI
144
145
146;--------------------------------------------------------------------
147; Interrupts_InstallHandlerToVectorInBXFromCSSI
148; Parameters:
149; BX: Interrupt vector number (for example 13h)
150; ES: BDA and Interrupt Vector segment (zero)
151; CS:SI: Ptr to interrupt handler
152; Returns:
153; Nothing
154; Corrupts registers:
155; BX
156;--------------------------------------------------------------------
157ALIGN JUMP_ALIGN
158Interrupts_InstallHandlerToVectorInBXFromCSSI:
159 eSHL_IM bx, 2 ; Shift for DWORD offset
160 mov [es:bx], si ; Store offset
161 mov [es:bx+2], cs ; Store segment
162 ret
163
164
165;--------------------------------------------------------------------
166; Interrupts_UnmaskInterruptControllerForDriveInDSDI
167; Parameters:
168; DS:DI: Ptr to DPT
169; Returns:
170; Nothing
171; Corrupts registers:
172; AX, BX, DX
173;--------------------------------------------------------------------
174ALIGN JUMP_ALIGN
175Interrupts_UnmaskInterruptControllerForDriveInDSDI:
176 eMOVZX bx, BYTE [di+DPT.bIdeOff]
177 mov al, [cs:bx+IDEVARS.bIRQ]
178 test al, al
179 jz SHORT .Return ; Interrupts disabled
180 cmp al, 8
181 jb SHORT .UnmaskLowIrqController
182 ; Fall through to .UnmaskHighIrqController
183
184;--------------------------------------------------------------------
185; .UnmaskHighIrqController
186; Parameters:
187; AL: IRQ number (8...15)
188; Returns:
189; Nothing
190; Corrupts registers:
191; AX, DX
192;--------------------------------------------------------------------
193;ALIGN JUMP_ALIGN
194;.UnmaskHighIrqController:
195 sub al, 8 ; Slave interrupt number
196 mov dx, PORT_8259SL_IMR ; Load Slave Mask Register address
197 call .ClearBitFrom8259MaskRegister
198 mov al, 2 ; Master IRQ 2 to allow slave IRQs
199 ; Fall to .UnmaskLowIrqController
200
201;--------------------------------------------------------------------
202; .UnmaskLowIrqController
203; Parameters:
204; AL: IRQ number (0...7)
205; Returns:
206; Nothing
207; Corrupts registers:
208; AX, DX
209;--------------------------------------------------------------------
210ALIGN JUMP_ALIGN
211.UnmaskLowIrqController:
212 mov dx, PORT_8259MA_IMR ; Load Mask Register address
213 ; Fall to .ClearBitFrom8259MaskRegister
214
215;--------------------------------------------------------------------
216; .ClearBitFrom8259MaskRegister
217; Parameters:
218; AL: 8259 interrupt index (0...7)
219; DX: Port address to Interrupt Mask Register
220; Returns:
221; Nothing
222; Corrupts registers:
223; AX
224;--------------------------------------------------------------------
225;ALIGN JUMP_ALIGN
226.ClearBitFrom8259MaskRegister:
227 push cx
228 xchg ax, cx ; IRQ index to CL
229 mov ch, 1 ; Load 1 to be shifted
230 shl ch, cl ; Shift bit to correct position
231 not ch ; Invert to create bit mask for clearing
232 in al, dx ; Read Interrupt Mask Register
233 and al, ch ; Clear wanted bit
234 out dx, al ; Write modified Interrupt Mask Register
235 pop cx
236.Return:
237 ret
Note: See TracBrowser for help on using the repository browser.