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

Last change on this file since 590 was 589, checked in by Krister Nordvall, 9 years ago

Changes:

  • BIOS: Fixed a purely cosmetic bug from r542 where, in builds containing MODULE_EBIOS, the boot menu would display an incorrect drive size (0.4 kB with MODULE_STRINGS_COMPRESSED or 0.5 kB without) for old drives with no support for LBA.
  • Fixed a bug from r392 where Vision_DetectAndReturnIDinAXandPortInDXifControllerPresent would return the ID in AL instead of AH (if DANGEROUS_DETECTION had been defined).
  • Fixed a bug from r587 in AdvAtaInit.asm that would prevent detection of QDI Vision controllers.
  • Also changed how the QDI Vision IDs are defined (removed the need for shifting) to avoid confusion. This fixed a potential bug from r587 in AdvAtaInit.asm where some IDs were not being shifted.
  • Fixed a bug in PDC20x30.asm from r587 where GetPdcIDtoAX would not return with the IDE base port in DX so DisablePdcProgrammingMode would fail.
  • Made some changes to ModuleDependency.inc and other files so that MODULE_ADVANCED_ATA now requires USE_386. Consequently it is no longer included in the regular AT-builds, only in the 386_8k-build.
  • Moved the UNROLL_SECTORS_IN_CX_TO_xWORDS macros from IDE_8bit.inc to IdeIO.inc which means it's now possible to build a BIOS without MODULE_8BIT_IDE.
  • XTIDECFG: Added a minimum DOS version check (since it needs DOS version 2+) to allow the program to quit gracefully in the unlikely scenario where someone tries to run it under DOS version 1.
  • Made some changes to Drive.asm to improve drive enumeration. The old method using GET_DOS_DRIVE_PARAMETER_BLOCK_FOR_SPECIFIC_DRIVE worked well in Windows XP but not in Windows 98 SE (in Windows or in DOS mode). The two problems were; 1) The function call would access the drives which on single floppy drive systems would cause Windows to swap between A: and B: (throwing a blue screen asking the user to insert a disk etc). 2) Only floppy drives and FAT16 drives would be available in the list of drives, no FAT32/optical/network drives.
  • Improved code in IdeControllerMenu.asm so that the default port addresses for all IDE interfaces are now restored when (re-)selecting the (same) type of IDE device.
  • Also made it impossible to select a device type unless the required module is included in the loaded BIOS.
  • The version check done when loading a BIOS now uses the FLASH_SIGNATURE definition from Version.inc. Any changes affecting RomVars now only requires updating that definition. This means that changes to RomVars must be implemented in both the BIOS and XTIDECFG before being committed to the repository.
  • Added a compatibility fix for 3Com 3C503 cards to the ROM checksumming code in Buffers.asm (Buffers_GenerateChecksum).
  • SerDrive: Made some minor changes to file names and paths to improve compatibility with case sensitive environments.
  • BIOSDRVS: Made a minor size optimization which as a side effect also makes it compatible with all DOS versions including DOS version 1.
  • Library: Renamed the WAIT_RETRACE_IF_NECESSARY_THEN macro to CALL_WAIT_FOR_RETRACE_IF_NECESSARY_THEN and made a tail-call-optimized version of it (JMP_WAIT_FOR_RETRACE_IF_NECESSARY_THEN).
  • A speed optimization to the eRCL_IM macro for 386 and higher. This change breaks emulation in the sense that the macro will fail when given a memory operand as the first parameter.
  • Other minor optimizations and fixes.
File size: 8.3 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Functions for initializing the BIOS.
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
21SECTION .text
22
23;--------------------------------------------------------------------
24; Drives must be detected before this function is called unless
25; MODULE_DRIVEXLATE has been included in the BIOS.
26;
27; Interrupts_InitializeInterruptVectors
28; Parameters:
29; DS: RAMVARS segment
30; ES: BDA and Interrupt Vector segment (zero)
31; Returns:
32; Nothing
33; Corrupts registers:
34; All except segments
35;--------------------------------------------------------------------
36Interrupts_InitializeInterruptVectors:
37 ; Install INT 19h handler to properly reset the system
38 mov al, BIOS_BOOT_LOADER_INTERRUPT_19h ; INT 19h interrupt vector offset
39 mov si, Int19hReset_Handler ; INT 19h handler to reboot the system
40 call Interrupts_InstallHandlerToVectorInALFromCSSI
41
42 ; If no drives detected, leave system INT 13h and 40h handlers
43 ; in place. We need our INT 13h handler to swap drive letters.
44%ifndef MODULE_DRIVEXLATE
45 cmp BYTE [RAMVARS.bDrvCnt], 0
46 je SHORT Interrupts_InstallHandlerToVectorInALFromCSSI.Interrupts_Return
47%endif
48 ; Fall to .InitializeInt13hAnd40h
49
50;--------------------------------------------------------------------
51; .InitializeInt13hAnd40h
52; Parameters:
53; DS: RAMVARS segment
54; ES: BDA and Interrupt Vector segment (zero)
55; Returns:
56; Nothing
57; Corrupts registers:
58; AX, BX, CX, DX, SI, DI
59;--------------------------------------------------------------------
60.InitializeInt13hAnd40h:
61 mov ax, [es:BIOS_DISK_INTERRUPT_13h*4+2]; Load old INT 13h segment
62 mov [RAMVARS.fpOldI13h+2], ax ; Store old INT 13h segment
63 xchg dx, ax
64 mov ax, [es:BIOS_DISK_INTERRUPT_13h*4] ; Load old INT 13h offset
65 mov [RAMVARS.fpOldI13h], ax ; Store old INT 13h offset
66
67 ; Only store INT 13h handler to 40h if 40h is not already installed.
68 ; At least AMI BIOS for 286 stores 40h handler by itself and calls
69 ; 40h from 13h. That system locks to infinite loop if we blindly copy 13h to 40h.
70 call FloppyDrive_IsInt40hInstalled
71 jc SHORT .Int40hAlreadyInstalled
72 mov [es:BIOS_DISKETTE_INTERRUPT_40h*4], ax ; Store old INT 13h offset
73 mov [es:BIOS_DISKETTE_INTERRUPT_40h*4+2], dx ; Store old INT 13h segment
74.Int40hAlreadyInstalled:
75
76 mov al, BIOS_DISK_INTERRUPT_13h ; INT 13h interrupt vector offset
77%ifdef RELOCATE_INT13H_STACK
78 mov si, Int13h_DiskFunctionsHandlerWithStackChange
79%else
80 mov si, Int13h_DiskFunctionsHandler
81%endif
82
83%ifndef MODULE_IRQ
84 ; Fall to Interrupts_InstallHandlerToVectorInALFromCSSI
85%else
86 call Interrupts_InstallHandlerToVectorInALFromCSSI
87 ; Fall to .InitializeHardwareIrqHandlers
88
89;--------------------------------------------------------------------
90; .InitializeHardwareIrqHandlers
91; Parameters:
92; ES: BDA and Interrupt Vector segment (zero)
93; Returns:
94; Nothing
95; Corrupts registers:
96; BX, CX, DX, SI, DI, AX
97;--------------------------------------------------------------------
98.InitializeHardwareIrqHandlers:
99 call RamVars_GetIdeControllerCountToCX
100 mov di, ROMVARS.ideVars0+IDEVARS.bIRQ
101.IdeControllerLoop:
102 mov al, [cs:di]
103 add di, BYTE IDEVARS_size ; Increment to next controller
104 call .InstallLowOrHighIrqHandler
105 loop .IdeControllerLoop
106.Return:
107 ret ; This ret is shared with .InstallLowOrHighIrqHandler
108
109;--------------------------------------------------------------------
110; .InstallLowOrHighIrqHandler
111; Parameters:
112; AL: IRQ number, 0 if IRQ disabled
113; ES: BDA and Interrupt Vector segment (zero)
114; Returns:
115; Nothing
116; Corrupts registers:
117; BX, SI
118;--------------------------------------------------------------------
119.InstallLowOrHighIrqHandler:
120 test al, al
121 jz SHORT .Return ; IRQ not used
122%ifdef USE_AT
123 cmp al, 8
124 jb SHORT .InstallLowIrqHandler
125 ; Fall to .InstallHighIrqHandler
126
127;--------------------------------------------------------------------
128; .InstallHighIrqHandler
129; Parameters:
130; BX: IRQ number (8...15)
131; ES: BDA and Interrupt Vector segment (zero)
132; Returns:
133; Nothing
134; Corrupts registers:
135; AL, BX, SI
136;--------------------------------------------------------------------
137.InstallHighIrqHandler:
138 add al, BYTE HARDWARE_IRQ_8_INTERRUPT_70h - 8 ; Interrupt vector number
139 mov si, IdeIrq_InterruptServiceRoutineForIrqs8to15
140 jmp SHORT Interrupts_InstallHandlerToVectorInALFromCSSI
141%endif ; USE_AT
142
143;--------------------------------------------------------------------
144; .InstallLowIrqHandler
145; Parameters:
146; AL: IRQ number (0...7)
147; ES: BDA and Interrupt Vector segment (zero)
148; Returns:
149; Nothing
150; Corrupts registers:
151; AL, BX, SI
152;--------------------------------------------------------------------
153.InstallLowIrqHandler:
154 add al, BYTE HARDWARE_IRQ_0_INTERRUPT_08h ; Interrupt vector number
155 mov si, IdeIrq_InterruptServiceRoutineForIrqs2to7
156 ; Fall to Interrupts_InstallHandlerToVectorInALFromCSSI
157%endif ; MODULE_IRQ
158
159
160;--------------------------------------------------------------------
161; Interrupts_InstallHandlerToVectorInALFromCSSI
162; Parameters:
163; AL: Interrupt vector number (for example 13h)
164; ES: BDA and Interrupt Vector segment (zero)
165; CS:SI: Ptr to interrupt handler
166; Returns:
167; Nothing
168; Corrupts registers:
169; AX, BX
170;--------------------------------------------------------------------
171Interrupts_InstallHandlerToVectorInALFromCSSI:
172 mov bl, 4 ; Shift for DWORD offset, MUL smaller than other alternatives
173 mul bl
174 xchg ax, bx
175 mov [es:bx], si ; Store offset
176 mov [es:bx+2], cs ; Store segment
177.Interrupts_Return:
178 ret
179
180
181%ifdef MODULE_IRQ
182;--------------------------------------------------------------------
183; Interrupts_UnmaskInterruptControllerForDriveInDSDI
184; Parameters:
185; DS:DI: Ptr to DPT
186; Returns:
187; Nothing
188; Corrupts registers:
189; AX, BX, DX
190;--------------------------------------------------------------------
191Interrupts_UnmaskInterruptControllerForDriveInDSDI:
192 eMOVZX bx, [di+DPT.bIdevarsOffset]
193 mov al, [cs:bx+IDEVARS.bIRQ]
194 test al, al
195 jz SHORT .Return ; Interrupts disabled
196 cmp al, 8
197 jb SHORT .UnmaskLowIrqController
198 ; Fall to .UnmaskHighIrqController
199
200;--------------------------------------------------------------------
201; .UnmaskHighIrqController
202; Parameters:
203; AL: IRQ number (8...15)
204; Returns:
205; Nothing
206; Corrupts registers:
207; AX, DX
208;--------------------------------------------------------------------
209.UnmaskHighIrqController:
210 sub al, 8 ; Slave interrupt number
211 mov dx, SLAVE_8259_IMR
212 call .ClearBitFrom8259MaskRegister
213 mov al, 2 ; Master IRQ 2 to allow slave IRQs
214 ; Fall to .UnmaskLowIrqController
215
216;--------------------------------------------------------------------
217; .UnmaskLowIrqController
218; Parameters:
219; AL: IRQ number (0...7)
220; Returns:
221; Nothing
222; Corrupts registers:
223; AX, DX
224;--------------------------------------------------------------------
225.UnmaskLowIrqController:
226 mov dx, MASTER_8259_IMR
227 ; Fall to .ClearBitFrom8259MaskRegister
228
229;--------------------------------------------------------------------
230; .ClearBitFrom8259MaskRegister
231; Parameters:
232; AL: 8259 interrupt index (0...7)
233; DX: Port address to Interrupt Mask Register
234; Returns:
235; Nothing
236; Corrupts registers:
237; AX
238;--------------------------------------------------------------------
239.ClearBitFrom8259MaskRegister:
240 push cx
241 xchg ax, cx ; IRQ index to CL
242 mov ch, ~1 ; Load bit mask to be rotated
243 rol ch, cl ; Rotate mask to correct position for clearing
244 in al, dx ; Read Interrupt Mask Register
245 and al, ch ; Clear wanted bit
246 out dx, al ; Write modified Interrupt Mask Register
247 pop cx
248.Return:
249 ret
250
251%endif ; MODULE_IRQ
Note: See TracBrowser for help on using the repository browser.