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

Last change on this file since 89 was 84, checked in by krille_n_@…, 14 years ago

Minor size optimizations in various files.

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