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

Last change on this file since 167 was 167, checked in by aitotat@…, 13 years ago

Changes to XTIDE Universal BIOS:

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