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