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