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

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

Changes to XTIDE Universal BIOS:

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