source: xtideuniversalbios/tags/XTIDE_Universal_BIOS_v1.1.3/Src/Handlers/Int13h.asm@ 478

Last change on this file since 478 was 28, checked in by Tomi Tilli, 14 years ago
  • v1.1.1 broke booting from foreign drives, it is now fixed.
  • Improved error handling a bit.
  • Longer DRQ and IRQ timeouts to minimize write timouts with some (bad) CF cards.
  • Default boot menu drive should now be properly selected.
File size: 10.4 KB
Line 
1; File name : Int13h_Jump.asm
2; Project name : IDE BIOS
3; Created date : 21.9.2007
4; Last update : 1.8.2010
5; Author : Tomi Tilli
6; Description : Int 13h BIOS functions (Floppy and Hard disk).
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
12; Macro that prints drive and function number.
13; Used only for debugging.
14;
15; DEBUG_PRINT_DRIVE_AND_FUNCTION
16; Parameters:
17; AH: INT 13h function number
18; DL: Drive number
19; Returns:
20; Nothing
21; Corrupts registers:
22; Nothing
23;--------------------------------------------------------------------
24%macro DEBUG_PRINT_DRIVE_AND_FUNCTION 0
25 push dx
26 push ax
27 mov al, dl
28 call Print_IntHexW
29 pop ax
30 pop dx
31%endmacro
32
33
34;--------------------------------------------------------------------
35; Int 13h software interrupt handler.
36; Jumps to specific function defined in AH.
37;
38; Int13h_Jump
39; Parameters:
40; AH: Bios function
41; DL: Drive number
42; Returns:
43; Depends on function
44; Corrupts registers:
45; Flags
46;--------------------------------------------------------------------
47ALIGN JUMP_ALIGN
48Int13h_DiskFunctions:
49 ; Save registers
50 sti ; Enable interrupts
51 push ds ; Store DS
52 push di ; Store DI
53
54 ;DEBUG_PRINT_DRIVE_AND_FUNCTION
55 call RamVars_GetSegmentToDS
56 call DriveXlate_WhenEnteringInt13h
57 call RamVars_IsFunctionHandledByThisBIOS
58 jnc SHORT Int13h_DirectCallToAnotherBios
59 ;DEBUG_PRINT_DRIVE_AND_FUNCTION
60
61 ; Jump to correct BIOS function
62 cmp ah, 25h ; Valid BIOS function?
63 ja SHORT Int13h_UnsupportedFunction
64 mov di, ax
65 eSHR_IM di, 7 ; Shift function to DI...
66 and di, BYTE 7Eh ; ...and prepare for word lookup
67 jmp [cs:di+g_rgw13hFuncJump] ; Jump to BIOS function
68
69
70;--------------------------------------------------------------------
71; Directs call to another INT13h function whose pointer is
72; stored to RAMVARS.
73;
74; Int13h_DirectCallToAnotherBios
75; Parameters:
76; AH: Bios function
77; DL: Drive number
78; DS: RAMVARS segment
79; DI: Corrupted
80; Stack from top to down:
81; Original DI
82; Original DS
83; Returns:
84; Depends on function
85; Corrupts registers:
86; Flags
87;--------------------------------------------------------------------
88ALIGN JUMP_ALIGN
89Int13h_UnsupportedFunction:
90Int13h_DirectCallToAnotherBios:
91 ; Temporarily store original DI and DS from stack to RAMVARS
92 pop WORD [RAMVARS.wI13hDI]
93 pop WORD [RAMVARS.wI13hDS]
94
95 ; Special return processing required if target function
96 ; returns something in DL
97 mov di, Int13h_ReturnFromAnotherBiosWithoutSwappingDrives
98 call DriveXlate_DoesFunctionReturnSomethingInDL
99 jc SHORT .PushIretAddress
100 add di, BYTE Int13h_ReturnFromAnotherBios - Int13h_ReturnFromAnotherBiosWithoutSwappingDrives
101.PushIretAddress:
102 pushf ; Push FLAGS to simulate INT
103 push cs ; Push return segment
104 push di ; Push return offset
105
106 ; "Return" to another INT 13h with original DI and DS
107 push WORD [RAMVARS.fpOldI13h+2] ; Segment
108 push WORD [RAMVARS.fpOldI13h] ; Offset
109 lds di, [RAMVARS.dwI13DIDS]
110 cli ; Disable interrupts as INT would
111 retf
112
113
114;--------------------------------------------------------------------
115; Return handlers from another INT 13h BIOS.
116;
117; Int13h_ReturnFromAnotherBiosWithoutSwappingDrives
118; Int13h_ReturnFromAnotherBios
119; Parameters:
120; AH: Error code
121; DL: Drive number (only on Int13h_ReturnFromAnotherBios)
122; CF: Error status
123; Returns:
124; Depends on function
125; Corrupts registers:
126; Nothing (not even FLAGS)
127;--------------------------------------------------------------------
128ALIGN JUMP_ALIGN
129Int13h_ReturnFromAnotherBiosWithoutSwappingDrives:
130 push ds
131 push di
132 pushf ; Store return flags
133 call RamVars_GetSegmentToDS
134 dec BYTE [RAMVARS.xlateVars+XLATEVARS.bRecurCnt]
135 jmp SHORT Int13h_Leave
136ALIGN JUMP_ALIGN
137Int13h_ReturnFromAnotherBios:
138 push ds
139 push di
140 pushf ; Store return flags
141 call RamVars_GetSegmentToDS
142 call DriveXlate_WhenLeavingInt13h
143 jmp SHORT Int13h_Leave
144
145
146;--------------------------------------------------------------------
147; Returns from any BIOS function implemented by this BIOS.
148;
149; Int13h_ReturnWithoutSwappingDrives
150; Int13h_StoreErrorCodeToBDAandPopDSDIandReturn
151; Int13h_StoreErrorCodeToBDAandPopXRegsAndReturn
152; Int13h_PopXRegsAndReturn
153; Int13h_PopDiDsAndReturn
154; Parameters:
155; DL: Drive number (not Int13h_ReturnWithoutSwappingDrives)
156; DS: RAMVARS segment
157; Returns:
158; Depends on function
159; Corrupts registers:
160; Nothing (not even FLAGS)
161;--------------------------------------------------------------------
162ALIGN JUMP_ALIGN
163Int13h_ReturnWithoutSwappingDrives:
164 pushf
165 dec BYTE [RAMVARS.xlateVars+XLATEVARS.bRecurCnt] ; Preserves CF
166 call HError_StoreBiosErrorCodeFromAHtoBDA
167 jmp SHORT Int13h_Leave
168
169ALIGN JUMP_ALIGN
170Int13h_StoreErrorCodeToBDAandPopDSDIandReturn:
171 call HError_StoreBiosErrorCodeFromAHtoBDA
172 jmp SHORT Int13h_PopDiDsAndReturn
173
174ALIGN JUMP_ALIGN
175Int13h_StoreErrorCodeToBDAandPopXRegsAndReturn:
176 call HError_StoreBiosErrorCodeFromAHtoBDA
177ALIGN JUMP_ALIGN
178Int13h_PopXRegsAndReturn:
179 pop bx ; Pop old AX to BX
180 mov al, bl ; Restore AL
181 pop bx
182 pop cx
183 pop dx
184ALIGN JUMP_ALIGN
185Int13h_PopDiDsAndReturn:
186 pushf
187 call DriveXlate_WhenLeavingInt13h
188Int13h_Leave:
189 popf
190 pop di
191 pop ds
192 retf 2
193
194
195; Jump table for correct BIOS function
196ALIGN WORD_ALIGN
197g_rgw13hFuncJump:
198 dw AH0h_HandlerForDiskControllerReset ; 00h, Disk Controller Reset (All)
199 dw AH1h_HandlerForReadDiskStatus ; 01h, Read Disk Status (All)
200 dw AH2h_HandlerForReadDiskSectors ; 02h, Read Disk Sectors (All)
201 dw AH3h_HandlerForWriteDiskSectors ; 03h, Write Disk Sectors (All)
202 dw AH4h_HandlerForVerifyDiskSectors ; 04h, Verify Disk Sectors (All)
203 dw AH5h_HandlerForFormatDiskTrack ; 05h, Format Disk Track (XT, AT, EISA)
204 dw Int13h_UnsupportedFunction ; 06h, Format Disk Track with Bad Sectors (XT)
205 dw Int13h_UnsupportedFunction ; 07h, Format Multiple Cylinders (XT)
206 dw AH8h_HandlerForReadDiskDriveParameters ; 08h, Read Disk Drive Parameters (All)
207 dw AH9h_HandlerForInitializeDriveParameters ; 09h, Initialize Drive Parameters (All)
208 dw Int13h_UnsupportedFunction ; 0Ah, Read Disk Sectors with ECC (XT, AT, EISA)
209 dw Int13h_UnsupportedFunction ; 0Bh, Write Disk Sectors with ECC (XT, AT, EISA)
210 dw AHCh_HandlerForSeek ; 0Ch, Seek (All)
211 dw AHDh_HandlerForResetHardDisk ; 0Dh, Alternate Disk Reset (All)
212 dw Int13h_UnsupportedFunction ; 0Eh, Read Sector Buffer (XT, PS/1), ESDI Undocumented Diagnostic (PS/2)
213 dw Int13h_UnsupportedFunction ; 0Fh, Write Sector Buffer (XT, PS/1), ESDI Undocumented Diagnostic (PS/2)
214 dw AH10h_HandlerForCheckDriveReady ; 10h, Check Drive Ready (All)
215 dw AH11h_HandlerForRecalibrate ; 11h, Recalibrate (All)
216 dw Int13h_UnsupportedFunction ; 12h, Controller RAM Diagnostic (XT)
217 dw Int13h_UnsupportedFunction ; 13h, Drive Diagnostic (XT)
218 dw AH14h_HandlerForControllerInternalDiagnostic ; 14h, Controller Internal Diagnostic (All)
219 dw AH15h_HandlerForReadDiskDriveSize ; 15h, Read Disk Drive Size (AT+)
220 dw Int13h_UnsupportedFunction ; 16h,
221 dw Int13h_UnsupportedFunction ; 17h,
222 dw Int13h_UnsupportedFunction ; 18h,
223 dw Int13h_UnsupportedFunction ; 19h, Park Heads (PS/2)
224 dw Int13h_UnsupportedFunction ; 1Ah, Format ESDI Drive (PS/2)
225 dw Int13h_UnsupportedFunction ; 1Bh, Get ESDI Manufacturing Header (PS/2)
226 dw Int13h_UnsupportedFunction ; 1Ch, ESDI Special Functions (PS/2)
227 dw Int13h_UnsupportedFunction ; 1Dh,
228 dw Int13h_UnsupportedFunction ; 1Eh,
229 dw Int13h_UnsupportedFunction ; 1Fh,
230 dw Int13h_UnsupportedFunction ; 20h,
231 dw Int13h_UnsupportedFunction ; 21h, Read Disk Sectors, Multiple Blocks (PS/1)
232 dw Int13h_UnsupportedFunction ; 22h, Write Disk Sectors, Multiple Blocks (PS/1)
233 dw AH23h_HandlerForSetControllerFeatures ; 23h, Set Controller Features Register (PS/1)
234 dw AH24h_HandlerForSetMultipleBlocks ; 24h, Set Multiple Blocks (PS/1)
235 dw AH25h_HandlerForGetDriveInformation ; 25h, Get Drive Information (PS/1)
236; dw Int13h_UnsupportedFunction ; 26h,
237; dw Int13h_UnsupportedFunction ; 27h,
238; dw Int13h_UnsupportedFunction ; 28h,
239; dw Int13h_UnsupportedFunction ; 29h,
240; dw Int13h_UnsupportedFunction ; 2Ah,
241; dw Int13h_UnsupportedFunction ; 2Bh,
242; dw Int13h_UnsupportedFunction ; 2Ch,
243; dw Int13h_UnsupportedFunction ; 2Dh,
244; dw Int13h_UnsupportedFunction ; 2Eh,
245; dw Int13h_UnsupportedFunction ; 2Fh,
246; dw Int13h_UnsupportedFunction ; 30h,
247; dw Int13h_UnsupportedFunction ; 31h,
248; dw Int13h_UnsupportedFunction ; 32h,
249; dw Int13h_UnsupportedFunction ; 33h,
250; dw Int13h_UnsupportedFunction ; 34h,
251; dw Int13h_UnsupportedFunction ; 35h,
252; dw Int13h_UnsupportedFunction ; 36h,
253; dw Int13h_UnsupportedFunction ; 37h,
254; dw Int13h_UnsupportedFunction ; 38h,
255; dw Int13h_UnsupportedFunction ; 39h,
256; dw Int13h_UnsupportedFunction ; 3Ah,
257; dw Int13h_UnsupportedFunction ; 3Bh,
258; dw Int13h_UnsupportedFunction ; 3Ch,
259; dw Int13h_UnsupportedFunction ; 3Dh,
260; dw Int13h_UnsupportedFunction ; 3Eh,
261; dw Int13h_UnsupportedFunction ; 3Fh,
262; dw Int13h_UnsupportedFunction ; 40h,
263; dw Int13h_UnsupportedFunction ; 41h, Check if Extensions Present (EBIOS)
264; dw Int13h_UnsupportedFunction ; 42h, Extended Read Sectors (EBIOS)
265; dw Int13h_UnsupportedFunction ; 43h, Extended Write Sectors (EBIOS)
266; dw Int13h_UnsupportedFunction ; 44h, Extended Verify Sectors (EBIOS)
267; dw Int13h_UnsupportedFunction ; 45h, Lock and Unlock Drive (EBIOS)
268; dw Int13h_UnsupportedFunction ; 46h, Eject Media Request (EBIOS)
269; dw Int13h_UnsupportedFunction ; 47h, Extended Seek (EBIOS)
270; dw Int13h_UnsupportedFunction ; 48h, Get Extended Drive Parameters (EBIOS)
271; dw Int13h_UnsupportedFunction ; 49h, Get Extended Disk Change Status (EBIOS)
272; dw Int13h_UnsupportedFunction ; 4Ah, Initiate Disk Emulation (Bootable CD-ROM)
273; dw Int13h_UnsupportedFunction ; 4Bh, Terminate Disk Emulation (Bootable CD-ROM)
274; dw Int13h_UnsupportedFunction ; 4Ch, Initiate Disk Emulation and Boot (Bootable CD-ROM)
275; dw Int13h_UnsupportedFunction ; 4Dh, Return Boot Catalog (Bootable CD-ROM)
276; dw Int13h_UnsupportedFunction ; 4Eh, Set Hardware Configuration (EBIOS)
Note: See TracBrowser for help on using the repository browser.