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

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