Changeset 28 in xtideuniversalbios for trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HError.asm
- Timestamp:
- Aug 1, 2010, 5:57:24 PM (15 years ago)
- google:author:
- aitotat
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HError.asm
r27 r28 2 2 ; Project name : IDE BIOS 3 3 ; Created date : 30.11.2007 4 ; Last update : 28.7.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 ; HError_ GetErrorCodeToAHforBitPollingTimeout12 ; HError_ProcessErrorsAfterPollingTaskFlag 13 13 ; Parameters: 14 ; AL: IDE Status Register contents 15 ; 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 16 18 ; Returns: 17 ; AH: Hard disk BIOS error code 18 ; CF: Set since error 19 ; Corrupts registers: 20 ; AL, CX 21 ;-------------------------------------------------------------------- 22 ALIGN JUMP_ALIGN 23 HError_GetErrorCodeToAHforBitPollingTimeout: 24 test al, FLG_IDE_ST_BSY ; Other bits undefined when BSY set 25 jnz SHORT HError_GetErrorCodeForStatusReg ; Busy, normal timeout 26 test al, FLG_IDE_ST_DF | FLG_IDE_ST_CORR | FLG_IDE_ST_ERR 27 jnz SHORT HError_GetErrorCodeForStatusReg ; Not busy but some error 28 or al, FLG_IDE_ST_BSY ; Polled bit got never set, force timeout 29 ; Fall to HError_GetErrorCodeForStatusReg 30 31 ;-------------------------------------------------------------------- 32 ; Converts Status Register error to BIOS error code. 33 ; 34 ; HError_GetErrorCodeForStatusReg 35 ; Parameters: 36 ; AL: IDE Status Register contents 37 ; DX: IDE Status Register Address 38 ; Returns: 39 ; AH: Hard disk BIOS error code 40 ; CF: 0 if no errors (AH=RET_HD_SUCCESS) 41 ; 1 if some error 42 ; Corrupts registers: 43 ; AL, CX 44 ;-------------------------------------------------------------------- 45 ALIGN JUMP_ALIGN 46 HError_GetErrorCodeForStatusReg: 47 ; Get Error Register contents to AH 48 mov ah, al ; Backup Status Reg to AH 49 sub dx, BYTE REGR_IDE_ST-REGR_IDE_ERROR ; Status Reg to Error Reg 50 in al, dx ; Read Error Register to AL 51 xchg al, ah ; Swap status and error 52 add dx, BYTE REGR_IDE_ST-REGR_IDE_ERROR ; Restore DX 53 54 ; Store Register contents to BDA 55 push ds 56 LOAD_BDA_SEGMENT_TO ds, cx 57 mov [HDBDA.wHDStAndErr], ax ; Store Status and Error to BDA 58 pop ds 59 ; Fall to HError_ConvertIdeErrorToBiosRet 60 61 ;-------------------------------------------------------------------- 62 ; Converts error flags from IDE status and error register contents 63 ; to BIOS Int 13h return value. 64 ; 65 ; HError_ConvertIdeErrorToBiosRet 66 ; Parameters: 67 ; AL: Status Register Contents 68 ; AH: Error Register Contents 69 ; Returns: 70 ; AH: Hard disk BIOS error code 71 ; CF: 0 if no errors (AH=RET_HD_SUCCESS) 72 ; 1 if any error 19 ; AH: BIOS error code 20 ; CF: Set if error 21 ; Cleared if no error 73 22 ; Corrupts registers: 74 23 ; AL 75 24 ;-------------------------------------------------------------------- 76 25 ALIGN JUMP_ALIGN 77 HError_ConvertIdeErrorToBiosRet: 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: 78 125 test al, FLG_IDE_ST_BSY 79 jnz SHORT .TimeoutError 126 jz SHORT .CheckErrorBitsFromStatusRegisterInAL 127 mov ah, RET_HD_TIMEOUT 128 jmp SHORT .ReturnBiosErrorCodeInAH 129 130 ALIGN JUMP_ALIGN 131 .CheckErrorBitsFromStatusRegisterInAL: 80 132 test al, FLG_IDE_ST_DF | FLG_IDE_ST_CORR | FLG_IDE_ST_ERR 81 jnz SHORT . ReadErrorFromStatusReg133 jnz SHORT .ProcessErrorFromStatusRegisterInAL 82 134 xor ah, ah ; No errors, zero AH and CF 83 135 ret 84 136 85 .TimeoutError: 86 mov ah, RET_HD_TIMEOUT 87 stc 88 ret 89 90 ; Convert error code based on status or error register 91 .ReadErrorFromStatusReg: 137 .ProcessErrorFromStatusRegisterInAL: 92 138 test al, FLG_IDE_ST_ERR ; Error specified in Error register? 93 jnz SHORT . ReadErrorFromErrorReg139 jnz SHORT .ConvertBiosErrorToAHfromErrorRegisterInAH 94 140 mov ah, RET_HD_ECC ; Assume ECC corrected error 95 141 test al, FLG_IDE_ST_CORR ; ECC corrected error? 96 jnz SHORT .Return 142 jnz SHORT .ReturnBiosErrorCodeInAH 97 143 mov ah, RET_HD_CONTROLLER ; Must be Device Fault 98 jmp SHORT .Return 144 jmp SHORT .ReturnBiosErrorCodeInAH 99 145 100 ; Convert error register to bios error code 101 .ReadErrorFromErrorReg: 146 .ConvertBiosErrorToAHfromErrorRegisterInAH: 102 147 push bx 103 mov al, ah ; Copy error reg to AL... 104 xor ah, ah ; ...and zero extend to AX 105 eBSF bx, ax ; Get bit index to BX 106 mov ah, RET_HD_STATUSERR ; Error code if Error Reg is zero 107 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: 108 156 mov ah, [cs:bx+.rgbRetCodeLookup] 109 .SkipLookup:110 157 pop bx 111 .Return: 158 159 .ReturnBiosErrorCodeInAH: 112 160 stc ; Set CF since error 113 161 ret … … 122 170 db RET_HD_UNCORRECC ; Bit6=UNC, Uncorrectable Data Error 123 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.