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
RevLine 
[150]1; Project name  :   XTIDE Universal BIOS
2; Description   :   IDE Register I/O functions.
3
4; Section containing code
5SECTION .text
6
7;--------------------------------------------------------------------
[332]8; IdeIO_OutputALtoIdeControlBlockRegisterInDL
[160]9; IdeIO_OutputALtoIdeRegisterInDL
[150]10;   Parameters:
11;       AL:     Byte to output
[332]12;       DL:     IDE Control Block Register  (IdeIO_OutputALtoIdeControlBlockRegisterInDL)
13;               IDE Register                (IdeIO_OutputALtoIdeRegisterInDL)
[160]14;       DS:DI:  Ptr to DPT (in RAMVARS segment)
[150]15;   Returns:
16;       Nothing
17;   Corrupts registers:
[160]18;       BX, DX
[150]19;--------------------------------------------------------------------
20ALIGN JUMP_ALIGN
[332]21IdeIO_OutputALtoIdeControlBlockRegisterInDL:
22    mov     bl, IDEVARS.wPortCtrl
23    SKIP2B  f   ; cmp ax, <next instruction>
24    ; Fall to IdeIO_OutputALtoIdeRegisterInDL
25
[160]26IdeIO_OutputALtoIdeRegisterInDL:
[181]27    mov     bl, IDEVARS.wPort
[160]28    call    GetPortToDXandTranslateA0andA3ifNecessary
[150]29    out     dx, al
30    ret
31
32
33;--------------------------------------------------------------------
[160]34; IdeIO_InputToALfromIdeRegisterInDL
[150]35;   Parameters:
[160]36;       DL:     IDE Register
37;       DS:DI:  Ptr to DPT (in RAMVARS segment)
[150]38;   Returns:
39;       AL:     Inputted byte
40;   Corrupts registers:
[160]41;       BX, DX
[150]42;--------------------------------------------------------------------
43ALIGN JUMP_ALIGN
[160]44IdeIO_InputToALfromIdeRegisterInDL:
[181]45    mov     bl, IDEVARS.wPort
[160]46    call    GetPortToDXandTranslateA0andA3ifNecessary
[150]47    in      al, dx
48    ret
[160]49
50
51;--------------------------------------------------------------------
52; GetPortToDXandTranslateA0andA3ifNecessary
53;   Parameters:
[181]54;       BL:     Offset to port in IDEVARS (IDEVARS.wPort or IDEVARS.wPortCtrl)
[160]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:
[181]64    xor     bh, bh
[332]65    add     bl, [di+DPT.bIdevarsOffset]     ; CS:BX now points port address
[160]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.