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

Last change on this file since 154 was 150, checked in by Tomi Tilli, 13 years ago

Changes to XTIDE Universal BIOS:

  • Redesigned Disk Parameter Tables.
  • Code generalizations for supporting non-IDE devices in the future.
File size: 11.2 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; Int 13h software interrupt handler.
9; Jumps to specific function defined in AH.
10;
[148]11; Note to developers: Do not make recursive INT 13h calls!
12;
13; Int13h_DiskFunctionsHandler
[3]14; Parameters:
15; AH: Bios function
16; DL: Drive number
[148]17; Other: Depends on function
[3]18; Returns:
19; Depends on function
20;--------------------------------------------------------------------
21ALIGN JUMP_ALIGN
[148]22Int13h_DiskFunctionsHandler:
[3]23 sti ; Enable interrupts
[150]24 cld ; String instructions to increment pointers
25 SAVE_AND_GET_INTPACK_WITH_EXTRA_WORDS_TO_SSBP EXTRA_WORDS_TO_RESERVE_FOR_INTPACK
[3]26
27 call RamVars_GetSegmentToDS
[148]28 call DriveXlate_ToOrBack
29 mov [RAMVARS.xlateVars+XLATEVARS.bXlatedDrv], dl
[3]30 call RamVars_IsFunctionHandledByThisBIOS
31 jnc SHORT Int13h_DirectCallToAnotherBios
[148]32 call FindDPT_ForDriveNumber ; DS:DI now points to DPT
[3]33
34 ; Jump to correct BIOS function
[148]35JumpToBiosFunctionInAH:
[3]36 cmp ah, 25h ; Valid BIOS function?
37 ja SHORT Int13h_UnsupportedFunction
[148]38 eMOVZX bx, ah
39 shl bx, 1
40 jmp [cs:bx+g_rgw13hFuncJump] ; Jump to BIOS function
[3]41
42
43;--------------------------------------------------------------------
[148]44; Int13h_UnsupportedFunction
[3]45; Int13h_DirectCallToAnotherBios
46; Parameters:
[148]47; DL: Translated drive number
[3]48; DS: RAMVARS segment
[150]49; SS:BP: Ptr to IDEPACK
[148]50; BX, DI: Corrupted on Int13h_DiskFunctionsHandler
51; Other: Function specific INT 13h parameters
[3]52; Returns:
53; Depends on function
54; Corrupts registers:
55; Flags
56;--------------------------------------------------------------------
57ALIGN JUMP_ALIGN
58Int13h_UnsupportedFunction:
59Int13h_DirectCallToAnotherBios:
[148]60 call ExchangeCurrentInt13hHandlerWithOldInt13hHandler
[150]61 mov bx, [bp+IDEPACK.intpack+INTPACK.bx]
62 mov di, [bp+IDEPACK.intpack+INTPACK.di]
63 mov ds, [bp+IDEPACK.intpack+INTPACK.ds]
64 push WORD [bp+IDEPACK.intpack+INTPACK.flags]
[148]65 popf
66 push bp
[150]67 mov bp, [bp+IDEPACK.intpack+INTPACK.bp]
[148]68 int BIOS_DISK_INTERRUPT_13h ; Can safely do as much recursion as it wants
[3]69
[148]70 ; Store returned values to INTPACK
71 pop bp ; Standard INT 13h functions never uses BP as return register
72%ifdef USE_386
[150]73 mov [bp+IDEPACK.intpack+INTPACK.gs], gs
74 mov [bp+IDEPACK.intpack+INTPACK.fs], fs
[148]75%endif
[150]76 mov [bp+IDEPACK.intpack+INTPACK.es], es
77 mov [bp+IDEPACK.intpack+INTPACK.ds], ds
78 mov [bp+IDEPACK.intpack+INTPACK.di], di
79 mov [bp+IDEPACK.intpack+INTPACK.si], si
80 mov [bp+IDEPACK.intpack+INTPACK.bx], bx
81 mov [bp+IDEPACK.intpack+INTPACK.dh], dh
82 mov [bp+IDEPACK.intpack+INTPACK.cx], cx
83 mov [bp+IDEPACK.intpack+INTPACK.ax], ax
[148]84 pushf
[150]85 pop WORD [bp+IDEPACK.intpack+INTPACK.flags]
[148]86 call RamVars_GetSegmentToDS
87 cmp dl, [RAMVARS.xlateVars+XLATEVARS.bXlatedDrv]
88 je SHORT .ExchangeInt13hHandlers
[150]89 mov [bp+IDEPACK.intpack+INTPACK.dl], dl ; Something is returned in DL
[148]90ALIGN JUMP_ALIGN
91.ExchangeInt13hHandlers:
92 call ExchangeCurrentInt13hHandlerWithOldInt13hHandler
93 ; Fall to Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
[3]94
95
96;--------------------------------------------------------------------
[148]97; Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH
98; Int13h_ReturnFromHandlerWithoutStoringErrorCode
[32]99; Parameters:
[148]100; AH: BIOS Error code
[150]101; SS:BP: Ptr to IDEPACK
[32]102; Returns:
[148]103; All registers are loaded from INTPACK
[32]104;--------------------------------------------------------------------
105ALIGN JUMP_ALIGN
[148]106Int13h_ReturnFromHandlerAfterStoringErrorCodeFromAH:
[150]107 call Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH
[148]108Int13h_ReturnFromHandlerWithoutStoringErrorCode:
[150]109 or WORD [bp+IDEPACK.intpack+INTPACK.flags], FLG_FLAGS_IF ; Return with interrupts enabled
[148]110 mov sp, bp ; Now we can exit anytime
[150]111 RESTORE_INTPACK_WITH_EXTRA_WORDS_FROM_SSBP EXTRA_WORDS_TO_RESERVE_FOR_INTPACK
[32]112
113
114;--------------------------------------------------------------------
[148]115; Int13h_CallPreviousInt13hHandler
[3]116; Parameters:
[148]117; AH: INT 13h function to call
118; DL: Drive number
119; DS: RAMVARS segment
[3]120; Returns:
121; Depends on function
122; Corrupts registers:
[148]123; BX, DI, ES
[3]124;--------------------------------------------------------------------
125ALIGN JUMP_ALIGN
[148]126Int13h_CallPreviousInt13hHandler:
[3]127 push di
[148]128 call ExchangeCurrentInt13hHandlerWithOldInt13hHandler
129 int BIOS_DISK_INTERRUPT_13h
130 call ExchangeCurrentInt13hHandlerWithOldInt13hHandler
131 pop di
132 ret
[35]133
[3]134
135;--------------------------------------------------------------------
[148]136; ExchangeCurrentInt13hHandlerWithOldInt13hHandler
[3]137; Parameters:
138; DS: RAMVARS segment
139; Returns:
[148]140; Nothing
[3]141; Corrupts registers:
[148]142; DI
[3]143;--------------------------------------------------------------------
144ALIGN JUMP_ALIGN
[148]145ExchangeCurrentInt13hHandlerWithOldInt13hHandler:
146 push es
147 LOAD_BDA_SEGMENT_TO es, di
148 mov di, [RAMVARS.fpOldI13h]
[150]149 cli
[148]150 xchg di, [es:BIOS_DISK_INTERRUPT_13h*4]
151 mov [RAMVARS.fpOldI13h], di
152 mov di, [RAMVARS.fpOldI13h+2]
153 xchg di, [es:BIOS_DISK_INTERRUPT_13h*4+2]
154 mov [RAMVARS.fpOldI13h+2], di
155 pop es
[150]156 sti
[148]157 ret
[28]158
[35]159
[150]160;--------------------------------------------------------------------
161; Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH
162; Int13h_SetErrorCodeToIntpackInSSBPfromAH
163; Parameters:
164; AH: BIOS error code (00h = no error)
165; SS:BP: Ptr to IDEPACK
166; Returns:
167; SS:BP: Ptr to IDEPACK with error condition set
168; Corrupts registers:
169; DS, DI
170;--------------------------------------------------------------------
171ALIGN JUMP_ALIGN
172Int13h_SetErrorCodeToBdaAndToIntpackInSSBPfromAH:
173 ; Store error code to BDA
174 LOAD_BDA_SEGMENT_TO ds, di
175 mov [BDA.bHDLastSt], ah
[35]176
[150]177 ; Store error code to INTPACK
178Int13h_SetErrorCodeToIntpackInSSBPfromAH:
179 mov [bp+IDEPACK.intpack+INTPACK.ah], ah
180 test ah, ah
181 jnz SHORT .SetCFtoIntpack
182 and BYTE [bp+IDEPACK.intpack+INTPACK.flags], ~FLG_FLAGS_CF
183 ret
184.SetCFtoIntpack:
185 or BYTE [bp+IDEPACK.intpack+INTPACK.flags], FLG_FLAGS_CF
186 ret
187
188
189
[3]190; Jump table for correct BIOS function
191ALIGN WORD_ALIGN
192g_rgw13hFuncJump:
193 dw AH0h_HandlerForDiskControllerReset ; 00h, Disk Controller Reset (All)
194 dw AH1h_HandlerForReadDiskStatus ; 01h, Read Disk Status (All)
195 dw AH2h_HandlerForReadDiskSectors ; 02h, Read Disk Sectors (All)
196 dw AH3h_HandlerForWriteDiskSectors ; 03h, Write Disk Sectors (All)
197 dw AH4h_HandlerForVerifyDiskSectors ; 04h, Verify Disk Sectors (All)
[90]198 dw Int13h_UnsupportedFunction ; 05h, Format Disk Track (XT, AT, EISA)
[3]199 dw Int13h_UnsupportedFunction ; 06h, Format Disk Track with Bad Sectors (XT)
200 dw Int13h_UnsupportedFunction ; 07h, Format Multiple Cylinders (XT)
201 dw AH8h_HandlerForReadDiskDriveParameters ; 08h, Read Disk Drive Parameters (All)
202 dw AH9h_HandlerForInitializeDriveParameters ; 09h, Initialize Drive Parameters (All)
203 dw Int13h_UnsupportedFunction ; 0Ah, Read Disk Sectors with ECC (XT, AT, EISA)
204 dw Int13h_UnsupportedFunction ; 0Bh, Write Disk Sectors with ECC (XT, AT, EISA)
205 dw AHCh_HandlerForSeek ; 0Ch, Seek (All)
206 dw AHDh_HandlerForResetHardDisk ; 0Dh, Alternate Disk Reset (All)
207 dw Int13h_UnsupportedFunction ; 0Eh, Read Sector Buffer (XT, PS/1), ESDI Undocumented Diagnostic (PS/2)
208 dw Int13h_UnsupportedFunction ; 0Fh, Write Sector Buffer (XT, PS/1), ESDI Undocumented Diagnostic (PS/2)
209 dw AH10h_HandlerForCheckDriveReady ; 10h, Check Drive Ready (All)
210 dw AH11h_HandlerForRecalibrate ; 11h, Recalibrate (All)
211 dw Int13h_UnsupportedFunction ; 12h, Controller RAM Diagnostic (XT)
212 dw Int13h_UnsupportedFunction ; 13h, Drive Diagnostic (XT)
[90]213 dw Int13h_UnsupportedFunction ; 14h, Controller Internal Diagnostic (All)
[3]214 dw AH15h_HandlerForReadDiskDriveSize ; 15h, Read Disk Drive Size (AT+)
215 dw Int13h_UnsupportedFunction ; 16h,
216 dw Int13h_UnsupportedFunction ; 17h,
217 dw Int13h_UnsupportedFunction ; 18h,
218 dw Int13h_UnsupportedFunction ; 19h, Park Heads (PS/2)
219 dw Int13h_UnsupportedFunction ; 1Ah, Format ESDI Drive (PS/2)
220 dw Int13h_UnsupportedFunction ; 1Bh, Get ESDI Manufacturing Header (PS/2)
221 dw Int13h_UnsupportedFunction ; 1Ch, ESDI Special Functions (PS/2)
222 dw Int13h_UnsupportedFunction ; 1Dh,
223 dw Int13h_UnsupportedFunction ; 1Eh,
224 dw Int13h_UnsupportedFunction ; 1Fh,
225 dw Int13h_UnsupportedFunction ; 20h,
226 dw Int13h_UnsupportedFunction ; 21h, Read Disk Sectors, Multiple Blocks (PS/1)
227 dw Int13h_UnsupportedFunction ; 22h, Write Disk Sectors, Multiple Blocks (PS/1)
228 dw AH23h_HandlerForSetControllerFeatures ; 23h, Set Controller Features Register (PS/1)
229 dw AH24h_HandlerForSetMultipleBlocks ; 24h, Set Multiple Blocks (PS/1)
230 dw AH25h_HandlerForGetDriveInformation ; 25h, Get Drive Information (PS/1)
231; dw Int13h_UnsupportedFunction ; 26h,
232; dw Int13h_UnsupportedFunction ; 27h,
233; dw Int13h_UnsupportedFunction ; 28h,
234; dw Int13h_UnsupportedFunction ; 29h,
235; dw Int13h_UnsupportedFunction ; 2Ah,
236; dw Int13h_UnsupportedFunction ; 2Bh,
237; dw Int13h_UnsupportedFunction ; 2Ch,
238; dw Int13h_UnsupportedFunction ; 2Dh,
239; dw Int13h_UnsupportedFunction ; 2Eh,
240; dw Int13h_UnsupportedFunction ; 2Fh,
241; dw Int13h_UnsupportedFunction ; 30h,
242; dw Int13h_UnsupportedFunction ; 31h,
243; dw Int13h_UnsupportedFunction ; 32h,
244; dw Int13h_UnsupportedFunction ; 33h,
245; dw Int13h_UnsupportedFunction ; 34h,
246; dw Int13h_UnsupportedFunction ; 35h,
247; dw Int13h_UnsupportedFunction ; 36h,
248; dw Int13h_UnsupportedFunction ; 37h,
249; dw Int13h_UnsupportedFunction ; 38h,
250; dw Int13h_UnsupportedFunction ; 39h,
251; dw Int13h_UnsupportedFunction ; 3Ah,
252; dw Int13h_UnsupportedFunction ; 3Bh,
253; dw Int13h_UnsupportedFunction ; 3Ch,
254; dw Int13h_UnsupportedFunction ; 3Dh,
255; dw Int13h_UnsupportedFunction ; 3Eh,
256; dw Int13h_UnsupportedFunction ; 3Fh,
257; dw Int13h_UnsupportedFunction ; 40h,
[150]258; dw Int13h_UnsupportedFunction ; 41h, Check if Extensions Present (EBIOS)*
259; dw Int13h_UnsupportedFunction ; 42h, Extended Read Sectors (EBIOS)*
260; dw Int13h_UnsupportedFunction ; 43h, Extended Write Sectors (EBIOS)*
261; dw Int13h_UnsupportedFunction ; 44h, Extended Verify Sectors (EBIOS)*
262; dw Int13h_UnsupportedFunction ; 45h, Lock and Unlock Drive (EBIOS)***
263; dw Int13h_UnsupportedFunction ; 46h, Eject Media Request (EBIOS)***
264; dw Int13h_UnsupportedFunction ; 47h, Extended Seek (EBIOS)*
265; dw Int13h_UnsupportedFunction ; 48h, Get Extended Drive Parameters (EBIOS)*
266; dw Int13h_UnsupportedFunction ; 49h, Get Extended Disk Change Status (EBIOS)***
[3]267; dw Int13h_UnsupportedFunction ; 4Ah, Initiate Disk Emulation (Bootable CD-ROM)
268; dw Int13h_UnsupportedFunction ; 4Bh, Terminate Disk Emulation (Bootable CD-ROM)
269; dw Int13h_UnsupportedFunction ; 4Ch, Initiate Disk Emulation and Boot (Bootable CD-ROM)
270; dw Int13h_UnsupportedFunction ; 4Dh, Return Boot Catalog (Bootable CD-ROM)
[150]271; dw Int13h_UnsupportedFunction ; 4Eh, Set Hardware Configuration (EBIOS)**
272;
273; * = Enhanced Drive Access Support (minimum required EBIOS functions)
274; ** = Enhanced Disk Drive (EDD) Support
275; *** = Drive Locking and Ejecting Support
Note: See TracBrowser for help on using the repository browser.