source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h.asm@ 48

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

Errors are now being checked when calling previous INT 13h handler on AH=08h Read Disk Drive Parameters. This fixes infinite drive checking loop on unofficial MS-DOS 7.10 installer.

File size: 10.7 KB
Line 
1; File name : Int13h_Jump.asm
2; Project name : IDE BIOS
3; Created date : 21.9.2007
4; Last update : 24.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_ReturnFromAnotherBiosWithValueInDL
98 call DriveXlate_DoesFunctionReturnSomethingInDL
99 jc SHORT .PushIretAddress
100 add di, BYTE Int13h_ReturnFromAnotherBios - Int13h_ReturnFromAnotherBiosWithValueInDL
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; Int13h_CallPreviousInt13hHandler
116; Parameters:
117; AH: Bios function
118; DS: RAMVARS segment
119; Other: Depends on function to call
120; Returns:
121; Depends on function to call
122; Corrupts registers:
123; Nothing
124;--------------------------------------------------------------------
125ALIGN JUMP_ALIGN
126Int13h_CallPreviousInt13hHandler:
127 pushf ; Push flags to simulate INT
128 cli ; Disable interrupts since INT does that
129 call FAR [RAMVARS.fpOldI13h]
130 sti
131 ret
132
133
134;--------------------------------------------------------------------
135; Int13h_ReturnFromAnotherBiosWithValueInDL
136; Int13h_ReturnFromAnotherBios
137; Parameters:
138; AH: Error code
139; DL: Drive number (only on Int13h_ReturnFromAnotherBios)
140; CF: Error status
141; Returns:
142; Depends on function
143; Corrupts registers:
144; Nothing (not even FLAGS)
145;--------------------------------------------------------------------
146ALIGN JUMP_ALIGN
147Int13h_ReturnFromAnotherBiosWithValueInDL:
148 push ds
149 push di
150 pushf ; Store return flags
151 call RamVars_GetSegmentToDS
152 call DriveXlate_WhenLeavingInt13hWithReturnValueInDL
153 jmp SHORT Int13h_Leave
154
155ALIGN JUMP_ALIGN
156Int13h_ReturnFromAnotherBios:
157 push ds
158 push di
159 pushf ; Store return flags
160 call RamVars_GetSegmentToDS
161 call DriveXlate_WhenLeavingInt13h
162 jmp SHORT Int13h_Leave
163
164
165;--------------------------------------------------------------------
166; Returns from any BIOS function implemented by this BIOS.
167;
168; Int13h_ReturnWithValueInDL
169; Int13h_PopXRegsAndReturn
170; Int13h_PopDiDsAndReturn
171; Parameters:
172; DL: Drive number (not Int13h_ReturnWithoutSwappingDrives)
173; DS: RAMVARS segment
174; Returns:
175; Depends on function
176; Corrupts registers:
177; Nothing (not even FLAGS)
178;--------------------------------------------------------------------
179ALIGN JUMP_ALIGN
180Int13h_ReturnWithValueInDL:
181 pushf
182 call DriveXlate_WhenLeavingInt13hWithReturnValueInDL
183 jmp SHORT Int13h_LeaveAfterStoringErrorCodeToBDA
184
185ALIGN JUMP_ALIGN
186Int13h_PopXRegsAndReturn:
187 pop bx ; Pop old AX to BX
188 mov al, bl ; Restore AL
189 pop bx
190 pop cx
191 pop dx
192 ; Fall to Int13h_PopDiDsAndReturn
193
194ALIGN JUMP_ALIGN
195Int13h_PopDiDsAndReturn:
196 pushf
197 call DriveXlate_WhenLeavingInt13h
198 ; Fall to Int13h_LeaveAfterStoringErrorCodeToBDA
199
200Int13h_LeaveAfterStoringErrorCodeToBDA:
201 LOAD_BDA_SEGMENT_TO ds, di
202 mov [BDA.bHDStatus], ah
203 ; Fall to Int13h_Leave
204
205Int13h_Leave:
206 popf
207 pop di
208 pop ds
209 retf 2
210
211
212; Jump table for correct BIOS function
213ALIGN WORD_ALIGN
214g_rgw13hFuncJump:
215 dw AH0h_HandlerForDiskControllerReset ; 00h, Disk Controller Reset (All)
216 dw AH1h_HandlerForReadDiskStatus ; 01h, Read Disk Status (All)
217 dw AH2h_HandlerForReadDiskSectors ; 02h, Read Disk Sectors (All)
218 dw AH3h_HandlerForWriteDiskSectors ; 03h, Write Disk Sectors (All)
219 dw AH4h_HandlerForVerifyDiskSectors ; 04h, Verify Disk Sectors (All)
220 dw AH5h_HandlerForFormatDiskTrack ; 05h, Format Disk Track (XT, AT, EISA)
221 dw Int13h_UnsupportedFunction ; 06h, Format Disk Track with Bad Sectors (XT)
222 dw Int13h_UnsupportedFunction ; 07h, Format Multiple Cylinders (XT)
223 dw AH8h_HandlerForReadDiskDriveParameters ; 08h, Read Disk Drive Parameters (All)
224 dw AH9h_HandlerForInitializeDriveParameters ; 09h, Initialize Drive Parameters (All)
225 dw Int13h_UnsupportedFunction ; 0Ah, Read Disk Sectors with ECC (XT, AT, EISA)
226 dw Int13h_UnsupportedFunction ; 0Bh, Write Disk Sectors with ECC (XT, AT, EISA)
227 dw AHCh_HandlerForSeek ; 0Ch, Seek (All)
228 dw AHDh_HandlerForResetHardDisk ; 0Dh, Alternate Disk Reset (All)
229 dw Int13h_UnsupportedFunction ; 0Eh, Read Sector Buffer (XT, PS/1), ESDI Undocumented Diagnostic (PS/2)
230 dw Int13h_UnsupportedFunction ; 0Fh, Write Sector Buffer (XT, PS/1), ESDI Undocumented Diagnostic (PS/2)
231 dw AH10h_HandlerForCheckDriveReady ; 10h, Check Drive Ready (All)
232 dw AH11h_HandlerForRecalibrate ; 11h, Recalibrate (All)
233 dw Int13h_UnsupportedFunction ; 12h, Controller RAM Diagnostic (XT)
234 dw Int13h_UnsupportedFunction ; 13h, Drive Diagnostic (XT)
235 dw AH14h_HandlerForControllerInternalDiagnostic ; 14h, Controller Internal Diagnostic (All)
236 dw AH15h_HandlerForReadDiskDriveSize ; 15h, Read Disk Drive Size (AT+)
237 dw Int13h_UnsupportedFunction ; 16h,
238 dw Int13h_UnsupportedFunction ; 17h,
239 dw Int13h_UnsupportedFunction ; 18h,
240 dw Int13h_UnsupportedFunction ; 19h, Park Heads (PS/2)
241 dw Int13h_UnsupportedFunction ; 1Ah, Format ESDI Drive (PS/2)
242 dw Int13h_UnsupportedFunction ; 1Bh, Get ESDI Manufacturing Header (PS/2)
243 dw Int13h_UnsupportedFunction ; 1Ch, ESDI Special Functions (PS/2)
244 dw Int13h_UnsupportedFunction ; 1Dh,
245 dw Int13h_UnsupportedFunction ; 1Eh,
246 dw Int13h_UnsupportedFunction ; 1Fh,
247 dw Int13h_UnsupportedFunction ; 20h,
248 dw Int13h_UnsupportedFunction ; 21h, Read Disk Sectors, Multiple Blocks (PS/1)
249 dw Int13h_UnsupportedFunction ; 22h, Write Disk Sectors, Multiple Blocks (PS/1)
250 dw AH23h_HandlerForSetControllerFeatures ; 23h, Set Controller Features Register (PS/1)
251 dw AH24h_HandlerForSetMultipleBlocks ; 24h, Set Multiple Blocks (PS/1)
252 dw AH25h_HandlerForGetDriveInformation ; 25h, Get Drive Information (PS/1)
253; dw Int13h_UnsupportedFunction ; 26h,
254; dw Int13h_UnsupportedFunction ; 27h,
255; dw Int13h_UnsupportedFunction ; 28h,
256; dw Int13h_UnsupportedFunction ; 29h,
257; dw Int13h_UnsupportedFunction ; 2Ah,
258; dw Int13h_UnsupportedFunction ; 2Bh,
259; dw Int13h_UnsupportedFunction ; 2Ch,
260; dw Int13h_UnsupportedFunction ; 2Dh,
261; dw Int13h_UnsupportedFunction ; 2Eh,
262; dw Int13h_UnsupportedFunction ; 2Fh,
263; dw Int13h_UnsupportedFunction ; 30h,
264; dw Int13h_UnsupportedFunction ; 31h,
265; dw Int13h_UnsupportedFunction ; 32h,
266; dw Int13h_UnsupportedFunction ; 33h,
267; dw Int13h_UnsupportedFunction ; 34h,
268; dw Int13h_UnsupportedFunction ; 35h,
269; dw Int13h_UnsupportedFunction ; 36h,
270; dw Int13h_UnsupportedFunction ; 37h,
271; dw Int13h_UnsupportedFunction ; 38h,
272; dw Int13h_UnsupportedFunction ; 39h,
273; dw Int13h_UnsupportedFunction ; 3Ah,
274; dw Int13h_UnsupportedFunction ; 3Bh,
275; dw Int13h_UnsupportedFunction ; 3Ch,
276; dw Int13h_UnsupportedFunction ; 3Dh,
277; dw Int13h_UnsupportedFunction ; 3Eh,
278; dw Int13h_UnsupportedFunction ; 3Fh,
279; dw Int13h_UnsupportedFunction ; 40h,
280; dw Int13h_UnsupportedFunction ; 41h, Check if Extensions Present (EBIOS)
281; dw Int13h_UnsupportedFunction ; 42h, Extended Read Sectors (EBIOS)
282; dw Int13h_UnsupportedFunction ; 43h, Extended Write Sectors (EBIOS)
283; dw Int13h_UnsupportedFunction ; 44h, Extended Verify Sectors (EBIOS)
284; dw Int13h_UnsupportedFunction ; 45h, Lock and Unlock Drive (EBIOS)
285; dw Int13h_UnsupportedFunction ; 46h, Eject Media Request (EBIOS)
286; dw Int13h_UnsupportedFunction ; 47h, Extended Seek (EBIOS)
287; dw Int13h_UnsupportedFunction ; 48h, Get Extended Drive Parameters (EBIOS)
288; dw Int13h_UnsupportedFunction ; 49h, Get Extended Disk Change Status (EBIOS)
289; dw Int13h_UnsupportedFunction ; 4Ah, Initiate Disk Emulation (Bootable CD-ROM)
290; dw Int13h_UnsupportedFunction ; 4Bh, Terminate Disk Emulation (Bootable CD-ROM)
291; dw Int13h_UnsupportedFunction ; 4Ch, Initiate Disk Emulation and Boot (Bootable CD-ROM)
292; dw Int13h_UnsupportedFunction ; 4Dh, Return Boot Catalog (Bootable CD-ROM)
293; dw Int13h_UnsupportedFunction ; 4Eh, Set Hardware Configuration (EBIOS)
Note: See TracBrowser for help on using the repository browser.