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

Last change on this file since 250 was 243, checked in by aitotat@…, 13 years ago

Changes to XTIDE Universal BIOS:

  • Brought back optional "A then C" boot loader.
  • Now there is only one INT 19h handler that remains unchanged.
File size: 6.7 KB
RevLine 
[90]1; Project name : XTIDE Universal BIOS
[33]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
[86]16;--------------------------------------------------------------------
[33]17Interrupts_InitializeInterruptVectors:
[97]18 ; Fall to .InitializeInt13hAnd40h
[33]19
20;--------------------------------------------------------------------
[97]21; .InitializeInt13hAnd40h
[33]22; Parameters:
23; DS: RAMVARS segment
24; ES: BDA and Interrupt Vector segment (zero)
25; Returns:
26; Nothing
27; Corrupts registers:
28; AX, BX, CX, DX, SI, DI
[86]29;--------------------------------------------------------------------
[97]30.InitializeInt13hAnd40h:
[181]31 mov ax, [es:BIOS_DISK_INTERRUPT_13h*4+2]; Load old INT 13h segment
32 mov [RAMVARS.fpOldI13h+2], ax ; Store old INT 13h segment
33 xchg dx, ax
[152]34 mov ax, [es:BIOS_DISK_INTERRUPT_13h*4] ; Load old INT 13h offset
[33]35 mov [RAMVARS.fpOldI13h], ax ; Store old INT 13h offset
[181]36
[152]37 mov bx, BIOS_DISK_INTERRUPT_13h ; INT 13h interrupt vector offset
[148]38 mov si, Int13h_DiskFunctionsHandler ; Interrupt handler offset
[33]39 call Interrupts_InstallHandlerToVectorInBXFromCSSI
40
41 ; Only store INT 13h handler to 40h if 40h is not already installed.
42 ; At least AMI BIOS for 286 stores 40h handler by itself and calls
43 ; 40h from 13h. That system locks to infinite loop if we copy 13h to 40h.
44 call FloppyDrive_IsInt40hInstalled
[243]45 jc SHORT .Int40hAlreadyInstalled
[152]46 mov [es:BIOS_DISKETTE_INTERRUPT_40h*4], ax ; Store old INT 13h offset
47 mov [es:BIOS_DISKETTE_INTERRUPT_40h*4+2], dx ; Store old INT 13h segment
[243]48.Int40hAlreadyInstalled:
[97]49 ; Fall to .InitializeHardwareIrqHandlers
[33]50
51;--------------------------------------------------------------------
[97]52; .InitializeHardwareIrqHandlers
[33]53; Parameters:
54; ES: BDA and Interrupt Vector segment (zero)
55; Returns:
56; Nothing
57; Corrupts registers:
58; BX, CX, DX, SI, DI
[86]59;--------------------------------------------------------------------
[97]60.InitializeHardwareIrqHandlers:
[33]61 call RamVars_GetIdeControllerCountToCX
62 mov di, ROMVARS.ideVars0 ; CS:SI points to first IDEVARS
63.IdeControllerLoop:
64 eMOVZX bx, BYTE [cs:di+IDEVARS.bIRQ]
65 add di, BYTE IDEVARS_size ; Increment to next controller
66 call .InstallLowOrHighIrqHandler
67 loop .IdeControllerLoop
[86]68.Return:
69 ret ; This ret is shared with .InstallLowOrHighIrqHandler
[33]70
71;--------------------------------------------------------------------
72; .InstallLowOrHighIrqHandler
73; Parameters:
74; BX: IRQ number, 0 if IRQ disabled
75; ES: BDA and Interrupt Vector segment (zero)
76; Returns:
77; Nothing
78; Corrupts registers:
79; BX, SI
[86]80;--------------------------------------------------------------------
[33]81.InstallLowOrHighIrqHandler:
[86]82 test bl, bl
83 jz SHORT .Return ; IRQ not used
[33]84 cmp bl, 8
[86]85 jb SHORT .InstallLowIrqHandler
[162]86 ; Fall to .InstallHighIrqHandler
[33]87
88;--------------------------------------------------------------------
89; .InstallHighIrqHandler
90; Parameters:
91; BX: IRQ number (8...15)
92; ES: BDA and Interrupt Vector segment (zero)
93; Returns:
94; Nothing
95; Corrupts registers:
96; BX, SI
[86]97;--------------------------------------------------------------------
[97]98.InstallHighIrqHandler:
[152]99 add bx, BYTE HARDWARE_IRQ_8_INTERRUPT_70h - 8 ; Interrupt vector number
[150]100 mov si, IdeIrq_InterruptServiceRoutineForIrqs8to15
[33]101 jmp SHORT Interrupts_InstallHandlerToVectorInBXFromCSSI
102
103;--------------------------------------------------------------------
104; .InstallLowIrqHandler
105; Parameters:
106; BX: IRQ number (0...7)
107; ES: BDA and Interrupt Vector segment (zero)
108; Returns:
109; Nothing
110; Corrupts registers:
111; BX, SI
[86]112;--------------------------------------------------------------------
[33]113.InstallLowIrqHandler:
[152]114 add bx, BYTE HARDWARE_IRQ_0_INTERRUPT_08h ; Interrupt vector number
[150]115 mov si, IdeIrq_InterruptServiceRoutineForIrqs2to7
[33]116 ; Fall to Interrupts_InstallHandlerToVectorInBXFromCSSI
117
118
119;--------------------------------------------------------------------
120; Interrupts_InstallHandlerToVectorInBXFromCSSI
121; Parameters:
122; BX: Interrupt vector number (for example 13h)
123; ES: BDA and Interrupt Vector segment (zero)
124; CS:SI: Ptr to interrupt handler
125; Returns:
126; Nothing
127; Corrupts registers:
128; BX
[86]129;--------------------------------------------------------------------
[33]130Interrupts_InstallHandlerToVectorInBXFromCSSI:
[123]131 eSHL_IM bx, 2 ; Shift for DWORD offset
[33]132 mov [es:bx], si ; Store offset
133 mov [es:bx+2], cs ; Store segment
134 ret
135
136
137;--------------------------------------------------------------------
138; Interrupts_UnmaskInterruptControllerForDriveInDSDI
139; Parameters:
140; DS:DI: Ptr to DPT
141; Returns:
142; Nothing
143; Corrupts registers:
144; AX, BX, DX
145;--------------------------------------------------------------------
146Interrupts_UnmaskInterruptControllerForDriveInDSDI:
[150]147 eMOVZX bx, BYTE [di+DPT.bIdevarsOffset]
[33]148 mov al, [cs:bx+IDEVARS.bIRQ]
[86]149 test al, al
150 jz SHORT .Return ; Interrupts disabled
[33]151 cmp al, 8
[86]152 jb SHORT .UnmaskLowIrqController
[162]153 ; Fall to .UnmaskHighIrqController
[33]154
155;--------------------------------------------------------------------
156; .UnmaskHighIrqController
157; Parameters:
158; AL: IRQ number (8...15)
159; Returns:
160; Nothing
161; Corrupts registers:
162; AX, DX
163;--------------------------------------------------------------------
[97]164.UnmaskHighIrqController:
[33]165 sub al, 8 ; Slave interrupt number
[152]166 mov dx, SLAVE_8259_IMR
[33]167 call .ClearBitFrom8259MaskRegister
168 mov al, 2 ; Master IRQ 2 to allow slave IRQs
169 ; Fall to .UnmaskLowIrqController
170
171;--------------------------------------------------------------------
172; .UnmaskLowIrqController
173; Parameters:
174; AL: IRQ number (0...7)
175; Returns:
176; Nothing
177; Corrupts registers:
178; AX, DX
179;--------------------------------------------------------------------
180.UnmaskLowIrqController:
[152]181 mov dx, MASTER_8259_IMR
[33]182 ; Fall to .ClearBitFrom8259MaskRegister
183
184;--------------------------------------------------------------------
185; .ClearBitFrom8259MaskRegister
186; Parameters:
187; AL: 8259 interrupt index (0...7)
188; DX: Port address to Interrupt Mask Register
189; Returns:
190; Nothing
191; Corrupts registers:
192; AX
193;--------------------------------------------------------------------
194.ClearBitFrom8259MaskRegister:
195 push cx
196 xchg ax, cx ; IRQ index to CL
197 mov ch, 1 ; Load 1 to be shifted
198 shl ch, cl ; Shift bit to correct position
199 not ch ; Invert to create bit mask for clearing
200 in al, dx ; Read Interrupt Mask Register
201 and al, ch ; Clear wanted bit
202 out dx, al ; Write modified Interrupt Mask Register
203 pop cx
[86]204.Return:
[33]205 ret
Note: See TracBrowser for help on using the repository browser.