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

Last change on this file since 324 was 324, checked in by aitotat@…, 12 years ago

Changes to XTIDE Universal BIOS:

  • Boot Menu now displays correct capacity when using user defined LBA.
File size: 3.2 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
20IDEDEVICE%+Error_GetBiosErrorCodeToAHfromPolledStatusRegisterInAL:
21    mov     ah, al          ; IDE Status Register to AH
22    INPUT_TO_AL_FROM_IDE_REGISTER   ERROR_REGISTER_in
23
24%ifndef ASSEMBLE_SHARED_IDE_DEVICE_FUNCTIONS    ; JR-IDE/ISA
25    jmp     ContinueFromMemIdeError     ; What's this supposed to do? *FIXME*
26%else
27ContinueFromMemIdeError:
28    xchg    al, ah          ; Status Register now in AL, Error Register now in AH
29
30    ; I don't think anything actually reads these from BDA
31    ;push   ds
32    ;LOAD_BDA_SEGMENT_TO    ds, dx
33    ;mov        [HDBDA.wHDStAndErr], ax
34    ;pop        ds
35
36    ; Fall to GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX
37
38
39;--------------------------------------------------------------------
40; GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX
41;   Parameters:
42;       AL:     IDE Status Register contents
43;       AH:     IDE Error Register contents
44;   Returns:
45;       AH:     BIOS INT 13h error code
46;       CF:     Set if error
47;               Cleared if no error
48;   Corrupts registers:
49;       BX
50;--------------------------------------------------------------------
51ALIGN JUMP_ALIGN
52GetBiosErrorCodeToAHfromStatusAndErrorRegistersInAX:
53    test    al, FLG_STATUS_BSY
54    jz      SHORT .CheckErrorBitsFromStatusRegisterInAL
55    mov     ah, RET_HD_TIMEOUT
56    jmp     SHORT .ReturnBiosErrorCodeInAH
57
58ALIGN JUMP_ALIGN
59.CheckErrorBitsFromStatusRegisterInAL:
60    test    al, FLG_STATUS_DF | FLG_STATUS_CORR | FLG_STATUS_ERR
61    jnz     SHORT .ProcessErrorFromStatusRegisterInAL
62    xor     ah, ah                  ; No errors, zero AH and CF
63    ret
64
65.ProcessErrorFromStatusRegisterInAL:
66    test    al, FLG_STATUS_ERR      ; Error specified in Error register?
67    jnz     SHORT .ConvertBiosErrorToAHfromErrorRegisterInAH
68    mov     ah, RET_HD_ECC          ; Assume ECC corrected error
69    test    al, FLG_STATUS_CORR     ; ECC corrected error?
70    jnz     SHORT .ReturnBiosErrorCodeInAH
71    mov     ah, RET_HD_CONTROLLER   ; Must be Device Fault
72    jmp     SHORT .ReturnBiosErrorCodeInAH
73
74.ConvertBiosErrorToAHfromErrorRegisterInAH:
75    xor     bx, bx                  ; Clear CF
76.ErrorBitLoop:
77    rcr     ah, 1                   ; Set CF if error bit set
78    jc      SHORT .LookupErrorCode
79    inc     bx
80    test    ah, ah                  ; Clear CF
81    jnz     SHORT .ErrorBitLoop
82.LookupErrorCode:
83    mov     ah, [cs:bx+.rgbRetCodeLookup]
84.ReturnBiosErrorCodeInAH:
85    stc                             ; Set CF since error
86    ret
87
88.rgbRetCodeLookup:
89    db  RET_HD_ADDRMARK     ; Bit0=AMNF, Address Mark Not Found
90    db  RET_HD_SEEK_FAIL    ; Bit1=TK0NF, Track 0 Not Found
91    db  RET_HD_INVALID      ; Bit2=ABRT, Aborted Command
92    db  RET_HD_NOTLOCKED    ; Bit3=MCR, Media Change Requested
93    db  RET_HD_NOT_FOUND    ; Bit4=IDNF, ID Not Found
94    db  RET_HD_LOCKED       ; Bit5=MC, Media Changed
95    db  RET_HD_UNCORRECC    ; Bit6=UNC, Uncorrectable Data Error
96    db  RET_HD_BADSECTOR    ; Bit7=BBK, Bad Block Detected
97    db  RET_HD_STATUSERR    ; When Error Register is zero
98%endif
Note: See TracBrowser for help on using the repository browser.