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