source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Handlers/Int13h/Common/HError.asm@ 17

Last change on this file since 17 was 3, checked in by Tomi Tilli, 15 years ago
File size: 3.2 KB
Line 
1; File name : HError.asm
2; Project name : IDE BIOS
3; Created date : 30.11.2007
4; Last update : 8.4.2010
5; Author : Tomi Tilli
6; Description : Error checking functions for BIOS Hard disk functions.
7
8; Section containing code
9SECTION .text
10
11;--------------------------------------------------------------------
12; Converts Status Register error to BIOS error code.
13;
14; HError_GetErrorCodeForStatusReg
15; Parameters:
16; AL: IDE Status Register contents
17; DX: IDE Status Register Address
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;--------------------------------------------------------------------
25ALIGN JUMP_ALIGN
26HError_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
55; Corrupts registers:
56; AL
57;--------------------------------------------------------------------
58ALIGN JUMP_ALIGN
59HError_ConvertIdeErrorToBiosRet:
60 ; Any error?
61 test al, FLG_IDE_ST_DF | FLG_IDE_ST_CORR | FLG_IDE_ST_ERR
62 jnz SHORT .ReadErrorFromStatusReg
63 xor ah, ah ; No errors, zero AH and CF
64 ret
65
66; Convert error code based on status or error register
67.ReadErrorFromStatusReg:
68 test al, FLG_IDE_ST_ERR ; Error specified in Error register?
69 jnz SHORT .ReadErrorFromErrorReg
70 mov ah, RET_HD_ECC ; Assume ECC corrected error
71 test al, FLG_IDE_ST_CORR ; ECC corrected error?
72 jnz SHORT .Return
73 mov ah, RET_HD_CONTROLLER ; Must be Device Fault
74 jmp SHORT .Return
75
76; Convert error register to bios error code
77.ReadErrorFromErrorReg:
78 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
84 mov ah, [cs:bx+.rgbRetCodeLookup]
85.SkipLookup:
86 pop bx
87.Return:
88 stc ; Set CF since error
89 ret
90
91.rgbRetCodeLookup:
92 db RET_HD_ADDRMARK ; Bit0=AMNF, Address Mark Not Found
93 db RET_HD_SEEK_FAIL ; Bit1=TK0NF, Track 0 Not Found
94 db RET_HD_INVALID ; Bit2=ABRT, Aborted Command
95 db RET_HD_NOTLOCKED ; Bit3=MCR, Media Change Requested
96 db RET_HD_NOT_FOUND ; Bit4=IDNF, ID Not Found
97 db RET_HD_LOCKED ; Bit5=MC, Media Changed
98 db RET_HD_UNCORRECC ; Bit6=UNC, Uncorrectable Data Error
99 db RET_HD_BADSECTOR ; Bit7=BBK, Bad Block Detected
Note: See TracBrowser for help on using the repository browser.