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

Last change on this file since 416 was 400, checked in by aitotat@…, 13 years ago

Changes to XTIDE Universal BIOS:

  • Moved 8-bit device support to MODULE_8BIT_IDE.
  • JR-IDE/ISA support requires a lot less bytes.
  • AT builds now always use full operating mode.
File size: 3.6 KB
Line 
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
21SECTION .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;--------------------------------------------------------------------
35ALIGN JUMP_ALIGN
36IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL:
37 mov ah, al ; IDE Status Register to AH
38 INPUT_TO_AL_FROM_IDE_REGISTER ERROR_REGISTER_in
39 xchg al, ah ; Status Register now in AL, Error Register now in AH
40 ; Fall to GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX
41
42
43;--------------------------------------------------------------------
44; GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX
45; Parameters:
46; AL: IDE Status Register contents
47; AH: IDE Error Register contents
48; Returns:
49; AH: BIOS INT 13h error code
50; CF: Set if error
51; Cleared if no error
52; Corrupts registers:
53; BX
54;--------------------------------------------------------------------
55ALIGN JUMP_ALIGN
56GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX:
57 test al, FLG_STATUS_BSY
58 jz SHORT .CheckErrorBitsFromStatusRegisterInAL
59 mov ah, RET_HD_TIMEOUT
60 jmp SHORT .ReturnBiosErrorCodeInAH
61
62ALIGN JUMP_ALIGN
63.CheckErrorBitsFromStatusRegisterInAL:
64 test al, FLG_STATUS_DF | FLG_STATUS_CORR | FLG_STATUS_ERR
65 jnz SHORT .ProcessErrorFromStatusRegisterInAL
66 xor ah, ah ; No errors, zero AH and CF
67 ret
68
69.ProcessErrorFromStatusRegisterInAL:
70 test al, FLG_STATUS_ERR ; Error specified in Error register?
71 jnz SHORT .ConvertBiosErrorToAHfromErrorRegisterInAH
72 mov ah, RET_HD_ECC ; Assume ECC corrected error
73 test al, FLG_STATUS_CORR ; ECC corrected error?
74 jnz SHORT .ReturnBiosErrorCodeInAH
75 mov ah, RET_HD_CONTROLLER ; Must be Device Fault
76 jmp SHORT .ReturnBiosErrorCodeInAH
77
78.ConvertBiosErrorToAHfromErrorRegisterInAH:
79 xor bx, bx ; Clear CF
80.ErrorBitLoop:
81 rcr ah, 1 ; Set CF if error bit set
82 jc SHORT .LookupErrorCode
83 inc bx
84 test ah, ah ; Clear CF
85 jnz SHORT .ErrorBitLoop
86.LookupErrorCode:
87 mov ah, [cs:bx+.rgbRetCodeLookup]
88.ReturnBiosErrorCodeInAH:
89 stc ; Set CF since error
90 ret
91
92.rgbRetCodeLookup:
93 db RET_HD_ADDRMARK ; Bit0=AMNF, Address Mark Not Found
94 db RET_HD_SEEK_FAIL ; Bit1=TK0NF, Track 0 Not Found
95 db RET_HD_INVALID ; Bit2=ABRT, Aborted Command
96 db RET_HD_NOTLOCKED ; Bit3=MCR, Media Change Requested
97 db RET_HD_NOT_FOUND ; Bit4=IDNF, ID Not Found
98 db RET_HD_LOCKED ; Bit5=MC, Media Changed
99 db RET_HD_UNCORRECC ; Bit6=UNC, Uncorrectable Data Error
100 db RET_HD_BADSECTOR ; Bit7=BBK, Bad Block Detected
101 db RET_HD_STATUSERR ; When Error Register is zero
Note: See TracBrowser for help on using the repository browser.