1 | ; Project name : XTIDE Universal BIOS
|
---|
2 | ; Description : Macros for accessing data port(s) on 8-bit
|
---|
3 | ; IDE controllers.
|
---|
4 | %ifndef IDE_8BIT_INC
|
---|
5 | %define IDE_8BIT_INC
|
---|
6 |
|
---|
7 | ;--------------------------------------------------------------------
|
---|
8 | ; Emulates INSW for XTIDE dual (8-bit) data port.
|
---|
9 | ;
|
---|
10 | ; eDUAL_BYTE_PORT_INSW
|
---|
11 | ; Parameters:
|
---|
12 | ; BX: Bit mask for toggling XTIDE data low/high reg
|
---|
13 | ; DX: Port address (must be IDE Data Register)
|
---|
14 | ; ES:DI: Ptr to destination buffer
|
---|
15 | ; Returns:
|
---|
16 | ; ES:DI: Incremented/decremented for next word
|
---|
17 | ; Corrupts registers:
|
---|
18 | ; AL, FLAGS
|
---|
19 | ;--------------------------------------------------------------------
|
---|
20 | %macro eDUAL_BYTE_PORT_INSW 0
|
---|
21 | %ifdef USE_186 ; INS instruction available
|
---|
22 | insb ; Load low byte from port DX to [ES:DI]
|
---|
23 | xor dx, bx ; IDE Data Reg to XTIDE Data High Reg
|
---|
24 | insb ; Load high byte from port DX to [ES:DI]
|
---|
25 | xor dx, bx ; Restore to IDE Data Register
|
---|
26 | %else ; If 8088/8086
|
---|
27 | in al, dx ; Load low byte from port
|
---|
28 | xor dx, bx ; IDE Data Reg to XTIDE Data High Reg
|
---|
29 | stosb ; Store byte to [ES:DI]
|
---|
30 | in al, dx ; Load high byte from port
|
---|
31 | xor dx, bx ; Restore to IDE Data Register
|
---|
32 | stosb ; Store byte to [ES:DI]
|
---|
33 | %endif
|
---|
34 | %endmacro
|
---|
35 |
|
---|
36 |
|
---|
37 | ;--------------------------------------------------------------------
|
---|
38 | ; Emulates OUTSW for XTIDE dual (8-bit) data port.
|
---|
39 | ;
|
---|
40 | ; eDUAL_BYTE_PORT_OUTSW
|
---|
41 | ; Parameters:
|
---|
42 | ; BX: Bit mask for toggling XTIDE data low/high reg
|
---|
43 | ; DX: Port address (must be IDE Data Register)
|
---|
44 | ; DS:SI: Ptr to source buffer
|
---|
45 | ; Returns:
|
---|
46 | ; SI: Incremented/decremented for next word
|
---|
47 | ; Corrupts registers:
|
---|
48 | ; AX, FLAGS
|
---|
49 | ;--------------------------------------------------------------------
|
---|
50 | %macro eDUAL_BYTE_PORT_OUTSW 0
|
---|
51 | %ifdef USE_186 ; OUTS instruction available
|
---|
52 | lodsb ; Load low byte from [DS:SI] to AL
|
---|
53 | xor dx, bx ; IDE Data Reg to XTIDE Data High Reg
|
---|
54 | outsb ; Output high byte from [DS:SI]
|
---|
55 | xor dx, bx ; IDE Data Reg to XTIDE Data Low Reg
|
---|
56 | out dx, al ; Output low byte from AL
|
---|
57 | %else ; If 8088/8086
|
---|
58 | lodsw ; Load word from [DS:SI]
|
---|
59 | xor dx, bx ; IDE Data Reg to XTIDE Data High Reg
|
---|
60 | xchg al, ah ; => AL=high byte, AH=low byte
|
---|
61 | out dx, al ; Output high byte
|
---|
62 | xor dx, bx ; XTIDE Data High Reg to IDE Data Reg
|
---|
63 | mov al, ah ; Copy low byte to AL
|
---|
64 | out dx, al ; Output low byte
|
---|
65 | %endif
|
---|
66 | %endmacro
|
---|
67 |
|
---|
68 |
|
---|
69 | %endif ; IDE_8BIT_INC
|
---|