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

Last change on this file since 32 was 32, checked in by aitotat, 14 years ago

Correct number of drives is now returned from AH=08h even when it is redirected to foreign BIOS.

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