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

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

Changes to XTIDE Universal BIOS:

  • Removed INT 13h format and diagnostics functions.
  • Removed INT 18h callback handler.
  • Removed configuration for early/late initialization. Now XT builds always use late and AT build early initialization.
  • Reduced number of supported IDE controllers from 5 to 4.
  • Removed reserved configuration bytes.
  • Removed simple and system boot loaders.
File size: 10.9 KB
RevLine 
[90]1; Project name : XTIDE Universal BIOS
[3]2; Description : Int 13h BIOS functions (Floppy and Hard disk).
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; Macro that prints drive and function number.
9; Used only for debugging.
10;
11; DEBUG_PRINT_DRIVE_AND_FUNCTION
12; Parameters:
13; AH: INT 13h function number
14; DL: Drive number
15; Returns:
16; Nothing
17; Corrupts registers:
18; Nothing
19;--------------------------------------------------------------------
20%macro DEBUG_PRINT_DRIVE_AND_FUNCTION 0
21 push dx
22 push ax
23 mov al, dl
24 call Print_IntHexW
25 pop ax
26 pop dx
27%endmacro
28
29
30;--------------------------------------------------------------------
31; Int 13h software interrupt handler.
32; Jumps to specific function defined in AH.
33;
34; Int13h_Jump
35; Parameters:
36; AH: Bios function
37; DL: Drive number
38; Returns:
39; Depends on function
40; Corrupts registers:
41; Flags
42;--------------------------------------------------------------------
43ALIGN JUMP_ALIGN
44Int13h_DiskFunctions:
45 ; Save registers
46 sti ; Enable interrupts
47 push ds ; Store DS
48 push di ; Store DI
49
50 ;DEBUG_PRINT_DRIVE_AND_FUNCTION
51 call RamVars_GetSegmentToDS
52 call DriveXlate_WhenEnteringInt13h
53 call RamVars_IsFunctionHandledByThisBIOS
54 jnc SHORT Int13h_DirectCallToAnotherBios
[28]55 ;DEBUG_PRINT_DRIVE_AND_FUNCTION
[3]56
57 ; Jump to correct BIOS function
58 cmp ah, 25h ; Valid BIOS function?
59 ja SHORT Int13h_UnsupportedFunction
60 mov di, ax
[84]61%ifndef USE_186 ; This uses 9 bytes less and is about 5 cycles faster
62 mov al, ah ; Copy bits in AH to AL and then
63 shl al, 1 ; shift them "back" 1 step
64 and al, 7Eh ; AND them (clears the MSB)
65 cbw ; Clear AH using sign extension
66 xchg di, ax ; and finally swap DI with AX
67%else
[3]68 eSHR_IM di, 7 ; Shift function to DI...
69 and di, BYTE 7Eh ; ...and prepare for word lookup
[84]70%endif
[3]71 jmp [cs:di+g_rgw13hFuncJump] ; Jump to BIOS function
72
73
74;--------------------------------------------------------------------
75; Directs call to another INT13h function whose pointer is
76; stored to RAMVARS.
77;
78; Int13h_DirectCallToAnotherBios
79; Parameters:
80; AH: Bios function
81; DL: Drive number
82; DS: RAMVARS segment
83; DI: Corrupted
84; Stack from top to down:
85; Original DI
86; Original DS
87; Returns:
88; Depends on function
89; Corrupts registers:
90; Flags
91;--------------------------------------------------------------------
92ALIGN JUMP_ALIGN
93Int13h_UnsupportedFunction:
94Int13h_DirectCallToAnotherBios:
[27]95 ; Temporarily store original DI and DS from stack to RAMVARS
[3]96 pop WORD [RAMVARS.wI13hDI]
97 pop WORD [RAMVARS.wI13hDS]
98
99 ; Special return processing required if target function
100 ; returns something in DL
[35]101 mov di, Int13h_ReturnFromAnotherBiosWithValueInDL
[3]102 call DriveXlate_DoesFunctionReturnSomethingInDL
103 jc SHORT .PushIretAddress
[35]104 add di, BYTE Int13h_ReturnFromAnotherBios - Int13h_ReturnFromAnotherBiosWithValueInDL
[3]105.PushIretAddress:
106 pushf ; Push FLAGS to simulate INT
107 push cs ; Push return segment
108 push di ; Push return offset
109
110 ; "Return" to another INT 13h with original DI and DS
111 push WORD [RAMVARS.fpOldI13h+2] ; Segment
112 push WORD [RAMVARS.fpOldI13h] ; Offset
113 lds di, [RAMVARS.dwI13DIDS]
114 cli ; Disable interrupts as INT would
115 retf
116
117
118;--------------------------------------------------------------------
[32]119; Int13h_CallPreviousInt13hHandler
120; Parameters:
121; AH: Bios function
122; DS: RAMVARS segment
123; Other: Depends on function to call
124; Returns:
125; Depends on function to call
126; Corrupts registers:
[43]127; Nothing
[32]128;--------------------------------------------------------------------
129ALIGN JUMP_ALIGN
130Int13h_CallPreviousInt13hHandler:
131 pushf ; Push flags to simulate INT
132 cli ; Disable interrupts since INT does that
133 call FAR [RAMVARS.fpOldI13h]
134 sti
135 ret
136
137
138;--------------------------------------------------------------------
[35]139; Int13h_ReturnFromAnotherBiosWithValueInDL
[3]140; Int13h_ReturnFromAnotherBios
141; Parameters:
142; AH: Error code
143; DL: Drive number (only on Int13h_ReturnFromAnotherBios)
144; CF: Error status
145; Returns:
146; Depends on function
147; Corrupts registers:
148; Nothing (not even FLAGS)
149;--------------------------------------------------------------------
150ALIGN JUMP_ALIGN
[35]151Int13h_ReturnFromAnotherBiosWithValueInDL:
[3]152 push ds
153 push di
154 pushf ; Store return flags
155 call RamVars_GetSegmentToDS
[35]156 call DriveXlate_WhenLeavingInt13hWithReturnValueInDL
[3]157 jmp SHORT Int13h_Leave
[35]158
[3]159ALIGN JUMP_ALIGN
160Int13h_ReturnFromAnotherBios:
161 push ds
162 push di
163 pushf ; Store return flags
164 call RamVars_GetSegmentToDS
165 call DriveXlate_WhenLeavingInt13h
166 jmp SHORT Int13h_Leave
167
168
169;--------------------------------------------------------------------
170; Returns from any BIOS function implemented by this BIOS.
171;
[35]172; Int13h_ReturnWithValueInDL
[3]173; Int13h_PopXRegsAndReturn
174; Int13h_PopDiDsAndReturn
175; Parameters:
176; DL: Drive number (not Int13h_ReturnWithoutSwappingDrives)
177; DS: RAMVARS segment
178; Returns:
179; Depends on function
180; Corrupts registers:
181; Nothing (not even FLAGS)
182;--------------------------------------------------------------------
183ALIGN JUMP_ALIGN
[35]184Int13h_ReturnWithValueInDL:
[3]185 pushf
[35]186 call DriveXlate_WhenLeavingInt13hWithReturnValueInDL
187 jmp SHORT Int13h_LeaveAfterStoringErrorCodeToBDA
[28]188
[3]189ALIGN JUMP_ALIGN
190Int13h_PopXRegsAndReturn:
191 pop bx ; Pop old AX to BX
192 mov al, bl ; Restore AL
193 pop bx
194 pop cx
195 pop dx
[35]196 ; Fall to Int13h_PopDiDsAndReturn
197
[3]198ALIGN JUMP_ALIGN
199Int13h_PopDiDsAndReturn:
200 pushf
201 call DriveXlate_WhenLeavingInt13h
[35]202 ; Fall to Int13h_LeaveAfterStoringErrorCodeToBDA
203
204Int13h_LeaveAfterStoringErrorCodeToBDA:
205 LOAD_BDA_SEGMENT_TO ds, di
206 mov [BDA.bHDStatus], ah
207 ; Fall to Int13h_Leave
208
[3]209Int13h_Leave:
210 popf
211 pop di
212 pop ds
213 retf 2
214
215
216; Jump table for correct BIOS function
217ALIGN WORD_ALIGN
218g_rgw13hFuncJump:
219 dw AH0h_HandlerForDiskControllerReset ; 00h, Disk Controller Reset (All)
220 dw AH1h_HandlerForReadDiskStatus ; 01h, Read Disk Status (All)
221 dw AH2h_HandlerForReadDiskSectors ; 02h, Read Disk Sectors (All)
222 dw AH3h_HandlerForWriteDiskSectors ; 03h, Write Disk Sectors (All)
223 dw AH4h_HandlerForVerifyDiskSectors ; 04h, Verify Disk Sectors (All)
[90]224 dw Int13h_UnsupportedFunction ; 05h, Format Disk Track (XT, AT, EISA)
[3]225 dw Int13h_UnsupportedFunction ; 06h, Format Disk Track with Bad Sectors (XT)
226 dw Int13h_UnsupportedFunction ; 07h, Format Multiple Cylinders (XT)
227 dw AH8h_HandlerForReadDiskDriveParameters ; 08h, Read Disk Drive Parameters (All)
228 dw AH9h_HandlerForInitializeDriveParameters ; 09h, Initialize Drive Parameters (All)
229 dw Int13h_UnsupportedFunction ; 0Ah, Read Disk Sectors with ECC (XT, AT, EISA)
230 dw Int13h_UnsupportedFunction ; 0Bh, Write Disk Sectors with ECC (XT, AT, EISA)
231 dw AHCh_HandlerForSeek ; 0Ch, Seek (All)
232 dw AHDh_HandlerForResetHardDisk ; 0Dh, Alternate Disk Reset (All)
233 dw Int13h_UnsupportedFunction ; 0Eh, Read Sector Buffer (XT, PS/1), ESDI Undocumented Diagnostic (PS/2)
234 dw Int13h_UnsupportedFunction ; 0Fh, Write Sector Buffer (XT, PS/1), ESDI Undocumented Diagnostic (PS/2)
235 dw AH10h_HandlerForCheckDriveReady ; 10h, Check Drive Ready (All)
236 dw AH11h_HandlerForRecalibrate ; 11h, Recalibrate (All)
237 dw Int13h_UnsupportedFunction ; 12h, Controller RAM Diagnostic (XT)
238 dw Int13h_UnsupportedFunction ; 13h, Drive Diagnostic (XT)
[90]239 dw Int13h_UnsupportedFunction ; 14h, Controller Internal Diagnostic (All)
[3]240 dw AH15h_HandlerForReadDiskDriveSize ; 15h, Read Disk Drive Size (AT+)
241 dw Int13h_UnsupportedFunction ; 16h,
242 dw Int13h_UnsupportedFunction ; 17h,
243 dw Int13h_UnsupportedFunction ; 18h,
244 dw Int13h_UnsupportedFunction ; 19h, Park Heads (PS/2)
245 dw Int13h_UnsupportedFunction ; 1Ah, Format ESDI Drive (PS/2)
246 dw Int13h_UnsupportedFunction ; 1Bh, Get ESDI Manufacturing Header (PS/2)
247 dw Int13h_UnsupportedFunction ; 1Ch, ESDI Special Functions (PS/2)
248 dw Int13h_UnsupportedFunction ; 1Dh,
249 dw Int13h_UnsupportedFunction ; 1Eh,
250 dw Int13h_UnsupportedFunction ; 1Fh,
251 dw Int13h_UnsupportedFunction ; 20h,
252 dw Int13h_UnsupportedFunction ; 21h, Read Disk Sectors, Multiple Blocks (PS/1)
253 dw Int13h_UnsupportedFunction ; 22h, Write Disk Sectors, Multiple Blocks (PS/1)
254 dw AH23h_HandlerForSetControllerFeatures ; 23h, Set Controller Features Register (PS/1)
255 dw AH24h_HandlerForSetMultipleBlocks ; 24h, Set Multiple Blocks (PS/1)
256 dw AH25h_HandlerForGetDriveInformation ; 25h, Get Drive Information (PS/1)
257; dw Int13h_UnsupportedFunction ; 26h,
258; dw Int13h_UnsupportedFunction ; 27h,
259; dw Int13h_UnsupportedFunction ; 28h,
260; dw Int13h_UnsupportedFunction ; 29h,
261; dw Int13h_UnsupportedFunction ; 2Ah,
262; dw Int13h_UnsupportedFunction ; 2Bh,
263; dw Int13h_UnsupportedFunction ; 2Ch,
264; dw Int13h_UnsupportedFunction ; 2Dh,
265; dw Int13h_UnsupportedFunction ; 2Eh,
266; dw Int13h_UnsupportedFunction ; 2Fh,
267; dw Int13h_UnsupportedFunction ; 30h,
268; dw Int13h_UnsupportedFunction ; 31h,
269; dw Int13h_UnsupportedFunction ; 32h,
270; dw Int13h_UnsupportedFunction ; 33h,
271; dw Int13h_UnsupportedFunction ; 34h,
272; dw Int13h_UnsupportedFunction ; 35h,
273; dw Int13h_UnsupportedFunction ; 36h,
274; dw Int13h_UnsupportedFunction ; 37h,
275; dw Int13h_UnsupportedFunction ; 38h,
276; dw Int13h_UnsupportedFunction ; 39h,
277; dw Int13h_UnsupportedFunction ; 3Ah,
278; dw Int13h_UnsupportedFunction ; 3Bh,
279; dw Int13h_UnsupportedFunction ; 3Ch,
280; dw Int13h_UnsupportedFunction ; 3Dh,
281; dw Int13h_UnsupportedFunction ; 3Eh,
282; dw Int13h_UnsupportedFunction ; 3Fh,
283; dw Int13h_UnsupportedFunction ; 40h,
284; dw Int13h_UnsupportedFunction ; 41h, Check if Extensions Present (EBIOS)
285; dw Int13h_UnsupportedFunction ; 42h, Extended Read Sectors (EBIOS)
286; dw Int13h_UnsupportedFunction ; 43h, Extended Write Sectors (EBIOS)
287; dw Int13h_UnsupportedFunction ; 44h, Extended Verify Sectors (EBIOS)
288; dw Int13h_UnsupportedFunction ; 45h, Lock and Unlock Drive (EBIOS)
289; dw Int13h_UnsupportedFunction ; 46h, Eject Media Request (EBIOS)
290; dw Int13h_UnsupportedFunction ; 47h, Extended Seek (EBIOS)
291; dw Int13h_UnsupportedFunction ; 48h, Get Extended Drive Parameters (EBIOS)
292; dw Int13h_UnsupportedFunction ; 49h, Get Extended Disk Change Status (EBIOS)
293; dw Int13h_UnsupportedFunction ; 4Ah, Initiate Disk Emulation (Bootable CD-ROM)
294; dw Int13h_UnsupportedFunction ; 4Bh, Terminate Disk Emulation (Bootable CD-ROM)
295; dw Int13h_UnsupportedFunction ; 4Ch, Initiate Disk Emulation and Boot (Bootable CD-ROM)
296; dw Int13h_UnsupportedFunction ; 4Dh, Return Boot Catalog (Bootable CD-ROM)
297; dw Int13h_UnsupportedFunction ; 4Eh, Set Hardware Configuration (EBIOS)
Note: See TracBrowser for help on using the repository browser.