source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeError.asm@ 196

Last change on this file since 196 was 160, checked in by Tomi Tilli, 13 years ago

Changes to XTIDE Universal BIOS:

  • Support for XTIDE mod now works.
File size: 3.0 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : IDE Device error functions.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL
9; Parameters:
10; AL: IDE Status Register contents
11; DS:DI: Ptr to DPT (in RAMVARS segment)
12; Returns:
13; AH: BIOS error code
14; CF: Set if error
15; Cleared if no error
16; Corrupts registers:
17; AL, BX, DX
18;--------------------------------------------------------------------
19ALIGN JUMP_ALIGN
20IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL:
21 mov ah, al ; IDE Status Register to AH
22 mov dl, ERROR_REGISTER_in
23 call IdeIO_InputToALfromIdeRegisterInDL
24 xchg al, ah ; Status Register now in AL, Error Register now in AH
25
26 ; I don't think anything actually reads these from BDA
27 push ds
28 LOAD_BDA_SEGMENT_TO ds, dx
29 mov [HDBDA.wHDStAndErr], ax
30 pop ds
31
32 ; Fall to GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX
33
34
35;--------------------------------------------------------------------
36; GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX
37; Parameters:
38; AL: IDE Status Register contents
39; AH: IDE Error Register contents
40; Returns:
41; AH: BIOS INT 13h error code
42; CF: Set if error
43; Cleared if no error
44; Corrupts registers:
45; BX
46;--------------------------------------------------------------------
47ALIGN JUMP_ALIGN
48GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX:
49 test al, FLG_STATUS_BSY
50 jz SHORT .CheckErrorBitsFromStatusRegisterInAL
51 mov ah, RET_HD_TIMEOUT
52 jmp SHORT .ReturnBiosErrorCodeInAH
53
54ALIGN JUMP_ALIGN
55.CheckErrorBitsFromStatusRegisterInAL:
56 test al, FLG_STATUS_DF | FLG_STATUS_CORR | FLG_STATUS_ERR
57 jnz SHORT .ProcessErrorFromStatusRegisterInAL
58 xor ah, ah ; No errors, zero AH and CF
59 ret
60
61.ProcessErrorFromStatusRegisterInAL:
62 test al, FLG_STATUS_ERR ; Error specified in Error register?
63 jnz SHORT .ConvertBiosErrorToAHfromErrorRegisterInAH
64 mov ah, RET_HD_ECC ; Assume ECC corrected error
65 test al, FLG_STATUS_CORR ; ECC corrected error?
66 jnz SHORT .ReturnBiosErrorCodeInAH
67 mov ah, RET_HD_CONTROLLER ; Must be Device Fault
68 jmp SHORT .ReturnBiosErrorCodeInAH
69
70.ConvertBiosErrorToAHfromErrorRegisterInAH:
71 xor bx, bx ; Clear CF
72.ErrorBitLoop:
73 rcr ah, 1 ; Set CF if error bit set
74 jc SHORT .LookupErrorCode
75 inc bx
76 test ah, ah ; Clear CF
77 jnz SHORT .ErrorBitLoop
78.LookupErrorCode:
79 mov ah, [cs:bx+.rgbRetCodeLookup]
80.ReturnBiosErrorCodeInAH:
81 stc ; Set CF since error
82 ret
83
84.rgbRetCodeLookup:
85 db RET_HD_ADDRMARK ; Bit0=AMNF, Address Mark Not Found
86 db RET_HD_SEEK_FAIL ; Bit1=TK0NF, Track 0 Not Found
87 db RET_HD_INVALID ; Bit2=ABRT, Aborted Command
88 db RET_HD_NOTLOCKED ; Bit3=MCR, Media Change Requested
89 db RET_HD_NOT_FOUND ; Bit4=IDNF, ID Not Found
90 db RET_HD_LOCKED ; Bit5=MC, Media Changed
91 db RET_HD_UNCORRECC ; Bit6=UNC, Uncorrectable Data Error
92 db RET_HD_BADSECTOR ; Bit7=BBK, Bad Block Detected
93 db RET_HD_STATUSERR ; When Error Register is zero
Note: See TracBrowser for help on using the repository browser.