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
RevLine 
[90]1; Project name : XTIDE Universal BIOS
[33]2; Description : Functions for initializing the BIOS.
3
[376]4;
[491]5; XTIDE Universal BIOS and Associated Tools
[526]6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
[376]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.
[491]12;
[376]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
[491]16; GNU General Public License for more details.
[376]17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
[491]18;
[376]19
[33]20; Section containing code
21SECTION .text
22
23;--------------------------------------------------------------------
[580]24; Drives must be detected before this function is called unless
25; MODULE_DRIVEXLATE has been included in the BIOS.
[431]26;
[33]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
[86]35;--------------------------------------------------------------------
[33]36Interrupts_InitializeInterruptVectors:
[431]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.
[492]44%ifndef MODULE_DRIVEXLATE
[431]45 cmp BYTE [RAMVARS.bDrvCnt], 0
[489]46 je SHORT Interrupts_InstallHandlerToVectorInALFromCSSI.Interrupts_Return
[431]47%endif
[97]48 ; Fall to .InitializeInt13hAnd40h
[33]49
50;--------------------------------------------------------------------
[97]51; .InitializeInt13hAnd40h
[33]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
[86]59;--------------------------------------------------------------------
[97]60.InitializeInt13hAnd40h:
[181]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
[152]64 mov ax, [es:BIOS_DISK_INTERRUPT_13h*4] ; Load old INT 13h offset
[33]65 mov [RAMVARS.fpOldI13h], ax ; Store old INT 13h offset
[181]66
[33]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
[530]69 ; 40h from 13h. That system locks to infinite loop if we blindly copy 13h to 40h.
[33]70 call FloppyDrive_IsInt40hInstalled
[243]71 jc SHORT .Int40hAlreadyInstalled
[152]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
[243]74.Int40hAlreadyInstalled:
[258]75
76 mov al, BIOS_DISK_INTERRUPT_13h ; INT 13h interrupt vector offset
[522]77%ifdef RELOCATE_INT13H_STACK
78 mov si, Int13h_DiskFunctionsHandlerWithStackChange
79%else
[417]80 mov si, Int13h_DiskFunctionsHandler
81%endif
[392]82
[398]83%ifndef MODULE_IRQ
84 ; Fall to Interrupts_InstallHandlerToVectorInALFromCSSI
85%else
[392]86 call Interrupts_InstallHandlerToVectorInALFromCSSI
[97]87 ; Fall to .InitializeHardwareIrqHandlers
[33]88
89;--------------------------------------------------------------------
[97]90; .InitializeHardwareIrqHandlers
[33]91; Parameters:
92; ES: BDA and Interrupt Vector segment (zero)
93; Returns:
94; Nothing
95; Corrupts registers:
[258]96; BX, CX, DX, SI, DI, AX
[86]97;--------------------------------------------------------------------
[97]98.InitializeHardwareIrqHandlers:
[33]99 call RamVars_GetIdeControllerCountToCX
[558]100 mov di, ROMVARS.ideVars0+IDEVARS.bIRQ
[33]101.IdeControllerLoop:
[491]102 mov al, [cs:di]
[33]103 add di, BYTE IDEVARS_size ; Increment to next controller
104 call .InstallLowOrHighIrqHandler
105 loop .IdeControllerLoop
[86]106.Return:
107 ret ; This ret is shared with .InstallLowOrHighIrqHandler
[33]108
109;--------------------------------------------------------------------
110; .InstallLowOrHighIrqHandler
111; Parameters:
[258]112; AL: IRQ number, 0 if IRQ disabled
[33]113; ES: BDA and Interrupt Vector segment (zero)
114; Returns:
115; Nothing
116; Corrupts registers:
117; BX, SI
[86]118;--------------------------------------------------------------------
[33]119.InstallLowOrHighIrqHandler:
[258]120 test al, al
[86]121 jz SHORT .Return ; IRQ not used
[540]122%ifdef USE_AT
[258]123 cmp al, 8
[86]124 jb SHORT .InstallLowIrqHandler
[162]125 ; Fall to .InstallHighIrqHandler
[33]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:
[258]135; AL, BX, SI
[86]136;--------------------------------------------------------------------
[97]137.InstallHighIrqHandler:
[258]138 add al, BYTE HARDWARE_IRQ_8_INTERRUPT_70h - 8 ; Interrupt vector number
[150]139 mov si, IdeIrq_InterruptServiceRoutineForIrqs8to15
[258]140 jmp SHORT Interrupts_InstallHandlerToVectorInALFromCSSI
[540]141%endif ; USE_AT
[33]142
143;--------------------------------------------------------------------
144; .InstallLowIrqHandler
145; Parameters:
[258]146; AL: IRQ number (0...7)
[33]147; ES: BDA and Interrupt Vector segment (zero)
148; Returns:
149; Nothing
150; Corrupts registers:
[258]151; AL, BX, SI
[86]152;--------------------------------------------------------------------
[33]153.InstallLowIrqHandler:
[258]154 add al, BYTE HARDWARE_IRQ_0_INTERRUPT_08h ; Interrupt vector number
[150]155 mov si, IdeIrq_InterruptServiceRoutineForIrqs2to7
[258]156 ; Fall to Interrupts_InstallHandlerToVectorInALFromCSSI
[398]157%endif ; MODULE_IRQ
[33]158
159
160;--------------------------------------------------------------------
[258]161; Interrupts_InstallHandlerToVectorInALFromCSSI
[33]162; Parameters:
[258]163; AL: Interrupt vector number (for example 13h)
[33]164; ES: BDA and Interrupt Vector segment (zero)
165; CS:SI: Ptr to interrupt handler
166; Returns:
167; Nothing
168; Corrupts registers:
[258]169; AX, BX
[86]170;--------------------------------------------------------------------
[258]171Interrupts_InstallHandlerToVectorInALFromCSSI:
172 mov bl, 4 ; Shift for DWORD offset, MUL smaller than other alternatives
173 mul bl
174 xchg ax, bx
[33]175 mov [es:bx], si ; Store offset
176 mov [es:bx+2], cs ; Store segment
[489]177.Interrupts_Return:
[33]178 ret
179
180
[398]181%ifdef MODULE_IRQ
[33]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:
[294]192 eMOVZX bx, [di+DPT.bIdevarsOffset]
[33]193 mov al, [cs:bx+IDEVARS.bIRQ]
[86]194 test al, al
195 jz SHORT .Return ; Interrupts disabled
[33]196 cmp al, 8
[86]197 jb SHORT .UnmaskLowIrqController
[162]198 ; Fall to .UnmaskHighIrqController
[33]199
200;--------------------------------------------------------------------
201; .UnmaskHighIrqController
202; Parameters:
203; AL: IRQ number (8...15)
204; Returns:
205; Nothing
206; Corrupts registers:
207; AX, DX
208;--------------------------------------------------------------------
[97]209.UnmaskHighIrqController:
[33]210 sub al, 8 ; Slave interrupt number
[152]211 mov dx, SLAVE_8259_IMR
[33]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:
[152]226 mov dx, MASTER_8259_IMR
[33]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
[589]242 mov ch, ~1 ; Load bit mask to be rotated
243 rol ch, cl ; Rotate mask to correct position for clearing
[33]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
[86]248.Return:
[33]249 ret
[398]250
251%endif ; MODULE_IRQ
Note: See TracBrowser for help on using the repository browser.