Changes in trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HError.asm [3:28] in xtideuniversalbios
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HError.asm
r3 r28 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 30.11.2007 4 ; Last update : 8.4.20104 ; Last update : 1.8.2010 5 5 ; Author : Tomi Tilli 6 6 ; Description : Error checking functions for BIOS Hard disk functions. … … 10 10 11 11 ;-------------------------------------------------------------------- 12 ; Converts Status Register error to BIOS error code. 13 ; 14 ; HError_GetErrorCodeForStatusReg 12 ; HError_ProcessErrorsAfterPollingTaskFlag 15 13 ; Parameters: 16 ; AL: IDE Status Register contents 17 ; DX: IDE Status Register Address 14 ; DS: RAMVARS segment 15 ; ES: BDA segment (zero) 16 ; CF: Set if timeout 17 ; Cleared if task flag was properly set 18 18 ; Returns: 19 ; AH: Hard disk BIOS error code 20 ; CF: 0 if no errors (AH=RET_HD_SUCCESS) 21 ; 1 if some error 22 ; Corrupts registers: 23 ; AL, CX 24 ;-------------------------------------------------------------------- 25 ALIGN JUMP_ALIGN 26 HError_GetErrorCodeForStatusReg: 27 ; Get Error Register contents to AH 28 mov ah, al ; Backup Status Reg to AH 29 sub dx, BYTE REGR_IDE_ST-REGR_IDE_ERROR ; Status Reg to Error Reg 30 in al, dx ; Read Error Register to AL 31 xchg al, ah ; Swap status and error 32 add dx, BYTE REGR_IDE_ST-REGR_IDE_ERROR ; Restore DX 33 34 ; Store Register contents to BDA 35 push ds 36 LOAD_BDA_SEGMENT_TO ds, cx 37 mov [HDBDA.wHDStAndErr], ax ; Store Status and Error to BDA 38 pop ds 39 40 ; Translate registers to BIOS error code 41 ; Fall to HError_ConvertIdeErrorToBiosRet 42 43 ;-------------------------------------------------------------------- 44 ; Converts error flags from IDE status and error register contents 45 ; to BIOS Int 13h return value. 46 ; 47 ; HError_ConvertIdeErrorToBiosRet 48 ; Parameters: 49 ; AL: Status Register Contents 50 ; AH: Error Register Contents 51 ; Returns: 52 ; AH: Hard disk BIOS error code 53 ; CF: 0 if no errors (AH=RET_HD_SUCCESS) 54 ; 1 if any error 19 ; AH: BIOS error code 20 ; CF: Set if error 21 ; Cleared if no error 55 22 ; Corrupts registers: 56 23 ; AL 57 24 ;-------------------------------------------------------------------- 58 25 ALIGN JUMP_ALIGN 59 HError_ConvertIdeErrorToBiosRet: 60 ; Any error? 26 HError_ProcessErrorsAfterPollingTaskFlag: 27 jc SHORT HError_ProcessTimeoutAfterPollingBSYandSomeOtherStatusBit 28 mov ax, [es:HDBDA.wHDStAndErr] 29 call GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX 30 mov [es:BDA.bHDLastSt], ah 31 mov BYTE [es:BDA.bHDTaskFlg], 0 32 ret 33 34 ;-------------------------------------------------------------------- 35 ; HError_ProcessTimeoutAfterPollingBSYandSomeOtherStatusBit 36 ; HError_ProcessErrorsAfterPollingBSY 37 ; Parameters: 38 ; DS: RAMVARS segment 39 ; Returns: 40 ; AH: BIOS error code 41 ; CF: Set if error 42 ; Cleared if no error 43 ; Corrupts registers: 44 ; AL 45 ;-------------------------------------------------------------------- 46 ALIGN JUMP_ALIGN 47 HError_ProcessTimeoutAfterPollingBSYandSomeOtherStatusBit: 48 push ds 49 push dx 50 51 call HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA 52 call GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX 53 jc SHORT StoreErrorCodeFromAHtoBDA 54 mov ah, RET_HD_TIMEOUT ; Force timeout since no actual error... 55 stc ; ...but wanted bit was never set 56 jmp SHORT StoreErrorCodeFromAHtoBDA 57 58 59 ALIGN JUMP_ALIGN 60 HError_ProcessErrorsAfterPollingBSY: 61 push ds 62 push dx 63 64 call HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA 65 call GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX 66 StoreErrorCodeFromAHtoBDA: 67 mov [BDA.bHDLastSt], ah ; Store BIOS error code to BDA 68 69 pop dx 70 pop ds 71 ret 72 73 74 ;-------------------------------------------------------------------- 75 ; HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA 76 ; Parameters: 77 ; DS: RAMVARS segment 78 ; Returns: 79 ; AL: IDE Status Register contents 80 ; AH: IDE Error Register contents 81 ; DS: BDA segment 82 ; Corrupts registers: 83 ; DX 84 ;-------------------------------------------------------------------- 85 ALIGN JUMP_ALIGN 86 HError_GetStatusAndErrorRegistersToAXandStoreThemToBDA: 87 mov dx, [RAMVARS.wIdeBase] ; Load IDE base port address 88 inc dx ; Increment to Error Register 89 in al, dx ; Read Error Register... 90 mov ah, al ; ...and copy it to AH 91 add dx, BYTE REGR_IDE_ST - REGR_IDE_ERROR 92 in al, dx ; Read Status Register to AL 93 ; Fall to .StoreStatusAndErrorRegistersFromAXtoBDA 94 95 ;-------------------------------------------------------------------- 96 ; .StoreStatusAndErrorRegistersFromAXtoBDA 97 ; Parameters: 98 ; AL: IDE Status Register contents 99 ; AH: IDE Error Register contents 100 ; Returns: 101 ; DS: BDA segment (zero) 102 ; Corrupts registers: 103 ; DX 104 ;-------------------------------------------------------------------- 105 .StoreStatusAndErrorRegistersFromAXtoBDA: 106 LOAD_BDA_SEGMENT_TO ds, dx 107 mov [HDBDA.wHDStAndErr], ax 108 ret 109 110 111 ;-------------------------------------------------------------------- 112 ; GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX 113 ; Parameters: 114 ; AL: IDE Status Register contents 115 ; AH: IDE Error Register contents 116 ; Returns: 117 ; AH: BIOS INT 13h error code 118 ; CF: Set if error 119 ; Cleared if no error 120 ; Corrupts registers: 121 ; Nothing 122 ;-------------------------------------------------------------------- 123 ALIGN JUMP_ALIGN 124 GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX: 125 test al, FLG_IDE_ST_BSY 126 jz SHORT .CheckErrorBitsFromStatusRegisterInAL 127 mov ah, RET_HD_TIMEOUT 128 jmp SHORT .ReturnBiosErrorCodeInAH 129 130 ALIGN JUMP_ALIGN 131 .CheckErrorBitsFromStatusRegisterInAL: 61 132 test al, FLG_IDE_ST_DF | FLG_IDE_ST_CORR | FLG_IDE_ST_ERR 62 jnz SHORT . ReadErrorFromStatusReg133 jnz SHORT .ProcessErrorFromStatusRegisterInAL 63 134 xor ah, ah ; No errors, zero AH and CF 64 135 ret 65 136 66 ; Convert error code based on status or error register 67 .ReadErrorFromStatusReg: 137 .ProcessErrorFromStatusRegisterInAL: 68 138 test al, FLG_IDE_ST_ERR ; Error specified in Error register? 69 jnz SHORT . ReadErrorFromErrorReg139 jnz SHORT .ConvertBiosErrorToAHfromErrorRegisterInAH 70 140 mov ah, RET_HD_ECC ; Assume ECC corrected error 71 141 test al, FLG_IDE_ST_CORR ; ECC corrected error? 72 jnz SHORT .Return 142 jnz SHORT .ReturnBiosErrorCodeInAH 73 143 mov ah, RET_HD_CONTROLLER ; Must be Device Fault 74 jmp SHORT .Return 144 jmp SHORT .ReturnBiosErrorCodeInAH 75 145 76 ; Convert error register to bios error code 77 .ReadErrorFromErrorReg: 146 .ConvertBiosErrorToAHfromErrorRegisterInAH: 78 147 push bx 79 mov al, ah ; Copy error reg to AL... 80 xor ah, ah ; ...and zero extend to AX 81 eBSF bx, ax ; Get bit index to BX 82 mov ah, RET_HD_STATUSERR ; Error code if Error Reg is zero 83 jz SHORT .SkipLookup ; Return if error register is zero 148 mov bx, .rgbRetCodeLookup 149 .ErrorBitLoop: 150 rcr ah, 1 ; Set CF if error bit set 151 jc SHORT .LookupErrorCode 152 inc bx 153 cmp bx, .rgbRetCodeLookup + 8 154 jb SHORT .ErrorBitLoop ; Loop until all bits checked 155 .LookupErrorCode: 84 156 mov ah, [cs:bx+.rgbRetCodeLookup] 85 .SkipLookup:86 157 pop bx 87 .Return: 158 159 .ReturnBiosErrorCodeInAH: 88 160 stc ; Set CF since error 89 161 ret … … 98 170 db RET_HD_UNCORRECC ; Bit6=UNC, Uncorrectable Data Error 99 171 db RET_HD_BADSECTOR ; Bit7=BBK, Bad Block Detected 172 db RET_HD_STATUSERR ; When Error Register is zero 173 174 175 ;-------------------------------------------------------------------- 176 ; HError_StoreBiosErrorCodeFromAHtoBDA 177 ; Parameters: 178 ; AH: BIOS error code 179 ; Returns: 180 ; Nothing 181 ; Corrupts registers: 182 ; DI 183 ;-------------------------------------------------------------------- 184 ALIGN JUMP_ALIGN 185 HError_StoreBiosErrorCodeFromAHtoBDA: 186 push ds 187 mov di, 0 ; Zero DI and preserve FLAGS 188 mov ds, di ; Copy BDA segment to DS 189 mov [BDA.bHDLastSt], ah 190 pop ds 191 ret
Note: See TracChangeset
for help on using the changeset viewer.