source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdeIO.asm @ 332

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

Changes:

  • Fixed a bug in the new BIOS Drive Information Tool.
  • Very small changes to improve speed (I hope).
  • Changed AH48h_GetExtendedDriveParameters.asm to allow AT builds with USE_386 (won't affect any other builds).
  • Verified that most define combinations can be built and changed Strings.asm accordingly. "Most" meaning with or without any combination of EBIOS and/or Serial code defines.
File size: 2.5 KB
Line 
1; Project name  :   XTIDE Universal BIOS
2; Description   :   IDE Register I/O functions.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
8; IdeIO_OutputALtoIdeControlBlockRegisterInDL
9; IdeIO_OutputALtoIdeRegisterInDL
10;   Parameters:
11;       AL:     Byte to output
12;       DL:     IDE Control Block Register  (IdeIO_OutputALtoIdeControlBlockRegisterInDL)
13;               IDE Register                (IdeIO_OutputALtoIdeRegisterInDL)
14;       DS:DI:  Ptr to DPT (in RAMVARS segment)
15;   Returns:
16;       Nothing
17;   Corrupts registers:
18;       BX, DX
19;--------------------------------------------------------------------
20ALIGN JUMP_ALIGN
21IdeIO_OutputALtoIdeControlBlockRegisterInDL:
22    mov     bl, IDEVARS.wPortCtrl
23    SKIP2B  f   ; cmp ax, <next instruction>
24    ; Fall to IdeIO_OutputALtoIdeRegisterInDL
25
26IdeIO_OutputALtoIdeRegisterInDL:
27    mov     bl, IDEVARS.wPort
28    call    GetPortToDXandTranslateA0andA3ifNecessary
29    out     dx, al
30    ret
31
32
33;--------------------------------------------------------------------
34; IdeIO_InputToALfromIdeRegisterInDL
35;   Parameters:
36;       DL:     IDE Register
37;       DS:DI:  Ptr to DPT (in RAMVARS segment)
38;   Returns:
39;       AL:     Inputted byte
40;   Corrupts registers:
41;       BX, DX
42;--------------------------------------------------------------------
43ALIGN JUMP_ALIGN
44IdeIO_InputToALfromIdeRegisterInDL:
45    mov     bl, IDEVARS.wPort
46    call    GetPortToDXandTranslateA0andA3ifNecessary
47    in      al, dx
48    ret
49
50
51;--------------------------------------------------------------------
52; GetPortToDXandTranslateA0andA3ifNecessary
53;   Parameters:
54;       BL:     Offset to port in IDEVARS (IDEVARS.wPort or IDEVARS.wPortCtrl)
55;       DL:     IDE Register
56;       DS:DI:  Ptr to DPT (in RAMVARS segment)
57;   Returns:
58;       DX:     Source/Destination Port
59;   Corrupts registers:
60;       BX
61;--------------------------------------------------------------------
62ALIGN JUMP_ALIGN
63GetPortToDXandTranslateA0andA3ifNecessary:
64    xor     bh, bh
65    add     bl, [di+DPT.bIdevarsOffset]     ; CS:BX now points port address
66    xor     dh, dh                          ; DX now has IDE register offset
67    add     dx, [cs:bx]
68    test    BYTE [di+DPT.bFlagsHigh], FLGH_DPT_REVERSED_A0_AND_A3
69    jz      SHORT .ReturnPortInDX
70
71    ; Exchange address lines A0 and A3 from DL
72    mov     bl, dl
73    mov     bh, MASK_A3_AND_A0_ADDRESS_LINES
74    and     bh, bl                          ; BH = 0, 1, 8 or 9, we can ignore 0 and 9
75    jz      SHORT .ReturnPortInDX           ; Jump out since DH is 0
76    xor     bh, MASK_A3_AND_A0_ADDRESS_LINES
77    jz      SHORT .ReturnPortInDX           ; Jump out since DH was 9
78    and     dl, ~MASK_A3_AND_A0_ADDRESS_LINES
79    or      dl, bh                          ; Address lines now reversed
80.ReturnPortInDX:
81    ret
Note: See TracBrowser for help on using the repository browser.