[150] | 1 | ; Project name : XTIDE Universal BIOS
|
---|
| 2 | ; Description : IDE Register I/O functions.
|
---|
| 3 |
|
---|
| 4 | ; Section containing code
|
---|
| 5 | SECTION .text
|
---|
| 6 |
|
---|
| 7 | ;--------------------------------------------------------------------
|
---|
[160] | 8 | ; IdeIO_OutputALtoIdeRegisterInDL
|
---|
[181] | 9 | ; IdeIO_OutputALtoIdeControlBlockRegisterInDL
|
---|
[150] | 10 | ; Parameters:
|
---|
| 11 | ; AL: Byte to output
|
---|
[181] | 12 | ; DL: IDE Register (IdeIO_OutputALtoIdeRegisterInDL)
|
---|
| 13 | ; IDE Control Block Register (IdeIO_OutputALtoIdeControlBlockRegisterInDL)
|
---|
[160] | 14 | ; DS:DI: Ptr to DPT (in RAMVARS segment)
|
---|
[150] | 15 | ; Returns:
|
---|
| 16 | ; Nothing
|
---|
| 17 | ; Corrupts registers:
|
---|
[160] | 18 | ; BX, DX
|
---|
[150] | 19 | ;--------------------------------------------------------------------
|
---|
| 20 | ALIGN JUMP_ALIGN
|
---|
[160] | 21 | IdeIO_OutputALtoIdeRegisterInDL:
|
---|
[181] | 22 | mov bl, IDEVARS.wPort
|
---|
| 23 | SKIP2B f ; cmp ax, <next instruction>
|
---|
| 24 | ; Fall to IdeIO_OutputALtoIdeControlBlockRegisterInDL
|
---|
[150] | 25 |
|
---|
[160] | 26 | IdeIO_OutputALtoIdeControlBlockRegisterInDL:
|
---|
[181] | 27 | mov bl, IDEVARS.wPortCtrl
|
---|
[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 | ;--------------------------------------------------------------------
|
---|
| 43 | ALIGN JUMP_ALIGN
|
---|
[160] | 44 | IdeIO_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 | ;--------------------------------------------------------------------
|
---|
| 62 | ALIGN JUMP_ALIGN
|
---|
| 63 | GetPortToDXandTranslateA0andA3ifNecessary:
|
---|
[181] | 64 | xor bh, bh
|
---|
[160] | 65 | xor dh, dh ; DX now has IDE register offset
|
---|
| 66 | add bl, [di+DPT.bIdevarsOffset] ; CS:BX now points port address
|
---|
| 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
|
---|