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

Last change on this file was 567, checked in by krille_n_@…, 10 years ago

Changes:

  • Renamed MODULE_FEATURE_SETS to MODULE_POWER_MANAGEMENT.
  • Renamed MODULE_VERY_LATE_INITIALIZATION to MODULE_VERY_LATE_INIT and removed it from the official builds.
  • Removed the code that skips detection of slave drives on XT-CF controllers since slave drives can be used with Lo-tech ISA CompactFlash boards.
  • Added autodetection of the SVC ADP50L controller to XTIDECFG.
  • The autodetection of XT-CF controllers now requires MODULE_8BIT_IDE_ADVANCED in the loaded BIOS.
  • Fixed a bug in XTIDECFG from r502 where the "Base (cmd block) address" menu option would be displayed when a serial device was selected as the IDE controller.
  • XTIDECFG would display the "Enable interrupt" menu option for the XTIDE r1 but not for the XTIDE r2. It's now displayed for both controller types.
  • Disabled the "Internal Write Cache" menu option in the Master/Slave Drive menus for serial device type drives.
  • Optimizations and other fixes.
File size: 3.7 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-2013 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%ifndef CHECK_FOR_UNUSED_ENTRYPOINTS
24    %if $ <> PollBsyOnly.End
25        %error "IdeError.asm must come immediately after IdeWait.asm (PollBsyOnly falls into IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL)!"
26    %endif
27%endif
28
29;--------------------------------------------------------------------
30; IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL
31;   Parameters:
32;       AL:     IDE Status Register contents
33;       DS:DI:  Ptr to DPT (in RAMVARS segment)
34;   Returns:
35;       AH:     BIOS error code
36;       CF:     Set if error
37;               Cleared if no error
38;   Corrupts registers:
39;       AL, BX, DX
40;--------------------------------------------------------------------
41ALIGN JUMP_ALIGN
42IdeError_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL:
43    mov     ah, al          ; IDE Status Register to AH
44    INPUT_TO_AL_FROM_IDE_REGISTER   ERROR_REGISTER_in
45    xchg    al, ah          ; Status Register now in AL, Error Register now in AH
46    ; Fall to GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX
47
48
49;--------------------------------------------------------------------
50; GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX
51;   Parameters:
52;       AL:     IDE Status Register contents
53;       AH:     IDE Error Register contents
54;   Returns:
55;       AH:     BIOS INT 13h error code
56;       CF:     Set if error
57;               Cleared if no error
58;   Corrupts registers:
59;       BX
60;--------------------------------------------------------------------
61ALIGN JUMP_ALIGN
62GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX:
63    test    al, FLG_STATUS_BSY | FLG_STATUS_DF | FLG_STATUS_CORR | FLG_STATUS_ERR   ; Clears CF
64    jnz     SHORT .CheckErrorBitsFromStatusRegisterInAL
65    ; The MSB of AL (FLG_STATUS_BSY) is cleared at this point.
66    cbw                             ; No errors, zero AH (CF already cleared)
67    ret
68
69ALIGN JUMP_ALIGN
70.CheckErrorBitsFromStatusRegisterInAL:
71    js      SHORT .Flg_Status_Bsy   ; Jump if FLG_STATUS_BSY
72    test    al, FLG_STATUS_ERR      ; Error specified in Error register?
73    jnz     SHORT .ConvertBiosErrorToAHfromErrorRegisterInAH
74    mov     ah, RET_HD_ECC          ; Assume ECC corrected error
75    test    al, FLG_STATUS_CORR     ; ECC corrected error?
76    jnz     SHORT .ReturnBiosErrorCodeInAH
77    mov     ah, RET_HD_CONTROLLER   ; Must be Device Fault
78    SKIP2B  bx
79.Flg_Status_Bsy:
80    mov     ah, RET_HD_TIMEOUT
81.ReturnBiosErrorCodeInAH:
82    stc
83    ret
84
85.ConvertBiosErrorToAHfromErrorRegisterInAH:
86    stc                             ; Needed in case Error register (AH) is zero
87    mov     bx, .rgbRetCodeLookup-1
88.ErrorBitLoop:
89    inc     bx
90    rcr     ah, 1
91    jnc     SHORT .ErrorBitLoop     ; CF will be set eventually
92    mov     ah, [cs:bx]
93    ret
94
95
96.rgbRetCodeLookup:
97    db  RET_HD_ADDRMARK     ; Bit0=AMNF, Address Mark Not Found
98    db  RET_HD_SEEK_FAIL    ; Bit1=TK0NF, Track 0 Not Found
99    db  RET_HD_INVALID      ; Bit2=ABRT, Aborted Command
100    db  RET_HD_NOTLOCKED    ; Bit3=MCR, Media Change Requested
101    db  RET_HD_NOT_FOUND    ; Bit4=IDNF, ID Not Found
102    db  RET_HD_LOCKED       ; Bit5=MC, Media Changed
103    db  RET_HD_UNCORRECC    ; Bit6=UNC, Uncorrectable Data Error
104    db  RET_HD_BADSECTOR    ; Bit7=BBK, Bad Block Detected
105    db  RET_HD_STATUSERR    ; When Error Register is zero
Note: See TracBrowser for help on using the repository browser.