1 | ; Project name : XTIDE Universal BIOS |
---|
2 | ; Description : IDE Device error functions. |
---|
3 | |
---|
4 | ; |
---|
5 | ; XTIDE Universal BIOS and Associated Tools |
---|
6 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team. |
---|
7 | ; |
---|
8 | ; This program is free software; you can redistribute it and/or modify |
---|
9 | ; it under the terms of the GNU General Public License as published by |
---|
10 | ; the Free Software Foundation; either version 2 of the License, or |
---|
11 | ; (at your option) any later version. |
---|
12 | ; |
---|
13 | ; This program is distributed in the hope that it will be useful, |
---|
14 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | ; GNU General Public License for more details. |
---|
17 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
18 | ; |
---|
19 | |
---|
20 | ; Section containing code |
---|
21 | SECTION .text |
---|
22 | |
---|
23 | ;-------------------------------------------------------------------- |
---|
24 | ; IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL |
---|
25 | ; Parameters: |
---|
26 | ; AL: IDE Status Register contents |
---|
27 | ; DS:DI: Ptr to DPT (in RAMVARS segment) |
---|
28 | ; Returns: |
---|
29 | ; AH: BIOS error code |
---|
30 | ; CF: Set if error |
---|
31 | ; Cleared if no error |
---|
32 | ; Corrupts registers: |
---|
33 | ; AL, BX, DX |
---|
34 | ;-------------------------------------------------------------------- |
---|
35 | ALIGN JUMP_ALIGN |
---|
36 | IDEDEVICE%+Error_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL: |
---|
37 | mov ah, al ; IDE Status Register to AH |
---|
38 | INPUT_TO_AL_FROM_IDE_REGISTER ERROR_REGISTER_in |
---|
39 | |
---|
40 | %ifndef ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS ; JR-IDE/ISA |
---|
41 | jmp ContinueFromMemIdeError |
---|
42 | %else |
---|
43 | ContinueFromMemIdeError: |
---|
44 | xchg al, ah ; Status Register now in AL, Error Register now in AH |
---|
45 | |
---|
46 | ; I don't think anything actually reads these from BDA |
---|
47 | ;push ds |
---|
48 | ;LOAD_BDA_SEGMENT_TO ds, dx |
---|
49 | ;mov [HDBDA.wHDStAndErr], ax |
---|
50 | ;pop ds |
---|
51 | |
---|
52 | ; Fall to GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX |
---|
53 | |
---|
54 | |
---|
55 | ;-------------------------------------------------------------------- |
---|
56 | ; GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX |
---|
57 | ; Parameters: |
---|
58 | ; AL: IDE Status Register contents |
---|
59 | ; AH: IDE Error Register contents |
---|
60 | ; Returns: |
---|
61 | ; AH: BIOS INT 13h error code |
---|
62 | ; CF: Set if error |
---|
63 | ; Cleared if no error |
---|
64 | ; Corrupts registers: |
---|
65 | ; BX |
---|
66 | ;-------------------------------------------------------------------- |
---|
67 | ALIGN JUMP_ALIGN |
---|
68 | GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX: |
---|
69 | test al, FLG_STATUS_BSY |
---|
70 | jz SHORT .CheckErrorBitsFromStatusRegisterInAL |
---|
71 | mov ah, RET_HD_TIMEOUT |
---|
72 | jmp SHORT .ReturnBiosErrorCodeInAH |
---|
73 | |
---|
74 | ALIGN JUMP_ALIGN |
---|
75 | .CheckErrorBitsFromStatusRegisterInAL: |
---|
76 | test al, FLG_STATUS_DF | FLG_STATUS_CORR | FLG_STATUS_ERR |
---|
77 | jnz SHORT .ProcessErrorFromStatusRegisterInAL |
---|
78 | xor ah, ah ; No errors, zero AH and CF |
---|
79 | ret |
---|
80 | |
---|
81 | .ProcessErrorFromStatusRegisterInAL: |
---|
82 | test al, FLG_STATUS_ERR ; Error specified in Error register? |
---|
83 | jnz SHORT .ConvertBiosErrorToAHfromErrorRegisterInAH |
---|
84 | mov ah, RET_HD_ECC ; Assume ECC corrected error |
---|
85 | test al, FLG_STATUS_CORR ; ECC corrected error? |
---|
86 | jnz SHORT .ReturnBiosErrorCodeInAH |
---|
87 | mov ah, RET_HD_CONTROLLER ; Must be Device Fault |
---|
88 | jmp SHORT .ReturnBiosErrorCodeInAH |
---|
89 | |
---|
90 | .ConvertBiosErrorToAHfromErrorRegisterInAH: |
---|
91 | xor bx, bx ; Clear CF |
---|
92 | .ErrorBitLoop: |
---|
93 | rcr ah, 1 ; Set CF if error bit set |
---|
94 | jc SHORT .LookupErrorCode |
---|
95 | inc bx |
---|
96 | test ah, ah ; Clear CF |
---|
97 | jnz SHORT .ErrorBitLoop |
---|
98 | .LookupErrorCode: |
---|
99 | mov ah, [cs:bx+.rgbRetCodeLookup] |
---|
100 | .ReturnBiosErrorCodeInAH: |
---|
101 | stc ; Set CF since error |
---|
102 | ret |
---|
103 | |
---|
104 | .rgbRetCodeLookup: |
---|
105 | db RET_HD_ADDRMARK ; Bit0=AMNF, Address Mark Not Found |
---|
106 | db RET_HD_SEEK_FAIL ; Bit1=TK0NF, Track 0 Not Found |
---|
107 | db RET_HD_INVALID ; Bit2=ABRT, Aborted Command |
---|
108 | db RET_HD_NOTLOCKED ; Bit3=MCR, Media Change Requested |
---|
109 | db RET_HD_NOT_FOUND ; Bit4=IDNF, ID Not Found |
---|
110 | db RET_HD_LOCKED ; Bit5=MC, Media Changed |
---|
111 | db RET_HD_UNCORRECC ; Bit6=UNC, Uncorrectable Data Error |
---|
112 | db RET_HD_BADSECTOR ; Bit7=BBK, Bad Block Detected |
---|
113 | db RET_HD_STATUSERR ; When Error Register is zero |
---|
114 | %endif |
---|