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 | ; UNROLL_SECTORS_IN_CX_TO_QWORDS
|
---|
9 | ; Parameters:
|
---|
10 | ; CX: Number of sectors in block
|
---|
11 | ; Returns:
|
---|
12 | ; CX: Number of QWORDs in block
|
---|
13 | ; Corrupts registers:
|
---|
14 | ; Nothing
|
---|
15 | ;--------------------------------------------------------------------
|
---|
16 | %macro UNROLL_SECTORS_IN_CX_TO_QWORDS 0
|
---|
17 | %ifdef USE_186
|
---|
18 | shl cx, 6
|
---|
19 | %else
|
---|
20 | xchg cl, ch ; Sectors to WORDs (SHL CX, 8)
|
---|
21 | shr cx, 1
|
---|
22 | shr cx, 1
|
---|
23 | %endif
|
---|
24 | %endmacro
|
---|
25 |
|
---|
26 |
|
---|
27 | ;--------------------------------------------------------------------
|
---|
28 | ; Emulates INSW for XTIDE.
|
---|
29 | ;
|
---|
30 | ; XTIDE_INSW
|
---|
31 | ; Parameters:
|
---|
32 | ; BL: Bit mask for toggling XTIDE data low/high reg
|
---|
33 | ; DX: XTIDE Data Low Register address
|
---|
34 | ; ES:DI: Ptr to destination buffer
|
---|
35 | ; Returns:
|
---|
36 | ; ES:DI: Incremented/decremented for next word
|
---|
37 | ; Corrupts registers:
|
---|
38 | ; AL, FLAGS
|
---|
39 | ;--------------------------------------------------------------------
|
---|
40 | %macro XTIDE_INSW 0
|
---|
41 | %ifdef USE_186 ; INS instruction available
|
---|
42 | insb ; Load low byte from port DX to [ES:DI]
|
---|
43 | xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
|
---|
44 | insb ; Load high byte from port DX to [ES:DI]
|
---|
45 | xor dl, bl ; Restore to IDE Data Register
|
---|
46 | %else ; If 8088/8086
|
---|
47 | in al, dx ; Load low byte from port
|
---|
48 | xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
|
---|
49 | stosb ; Store byte to [ES:DI]
|
---|
50 | in al, dx ; Load high byte from port
|
---|
51 | xor dl, bl ; Restore to IDE Data Register
|
---|
52 | stosb ; Store byte to [ES:DI]
|
---|
53 | %endif
|
---|
54 | %endmacro
|
---|
55 |
|
---|
56 |
|
---|
57 | ;--------------------------------------------------------------------
|
---|
58 | ; Emulates OUTSW for XTIDE.
|
---|
59 | ;
|
---|
60 | ; XTIDE_OUTSW
|
---|
61 | ; Parameters:
|
---|
62 | ; BL: Bit mask for toggling XTIDE data low/high reg
|
---|
63 | ; DX: XTIDE Data Low Register address
|
---|
64 | ; DS:SI: Ptr to source buffer
|
---|
65 | ; Returns:
|
---|
66 | ; SI: Incremented/decremented for next word
|
---|
67 | ; Corrupts registers:
|
---|
68 | ; AX, FLAGS
|
---|
69 | ;--------------------------------------------------------------------
|
---|
70 | %macro XTIDE_OUTSW 0
|
---|
71 | %ifdef USE_186 ; OUTS instruction available
|
---|
72 | lodsb ; Load low byte from [DS:SI] to AL
|
---|
73 | xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
|
---|
74 | outsb ; Output high byte from [DS:SI]
|
---|
75 | xor dl, bl ; XTIDE Data High Reg to Data Low Reg
|
---|
76 | out dx, al ; Output low byte from AL
|
---|
77 | %else ; If 8088/8086
|
---|
78 | lodsw ; Load word from [DS:SI]
|
---|
79 | xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
|
---|
80 | xchg al, ah ; => AL=high byte, AH=low byte
|
---|
81 | out dx, al ; Output high byte
|
---|
82 | xor dl, bl ; XTIDE Data High Reg to Data Low Reg
|
---|
83 | mov al, ah ; Copy low byte to AL
|
---|
84 | out dx, al ; Output low byte
|
---|
85 | %endif
|
---|
86 | %endmacro
|
---|
87 |
|
---|
88 |
|
---|
89 | ;--------------------------------------------------------------------
|
---|
90 | ; Emulates OUTSW for modified XTIDE.
|
---|
91 | ;
|
---|
92 | ; XTIDE_MOD_OUTSW
|
---|
93 | ; Parameters:
|
---|
94 | ; DX: XTIDE Data Low Register address
|
---|
95 | ; DS:SI: Ptr to source buffer
|
---|
96 | ; Returns:
|
---|
97 | ; SI: Incremented/decremented for next word
|
---|
98 | ; Corrupts registers:
|
---|
99 | ; AX, FLAGS
|
---|
100 | ;--------------------------------------------------------------------
|
---|
101 | %macro XTIDE_MOD_OUTSW 0
|
---|
102 | %ifdef USE_186 ; OUTS instruction available
|
---|
103 | lodsb ; Load low byte from [DS:SI] to AL
|
---|
104 | inc dx ; IDE Data Reg to XTIDE MOD Data High Reg
|
---|
105 | outsb ; Output high byte from [DS:SI]
|
---|
106 | dec dx ; XTIDE Data High Reg to Data Low Reg
|
---|
107 | out dx, al ; Output low byte from AL
|
---|
108 | %else ; If 8088/8086
|
---|
109 | lodsw ; Load word from [DS:SI]
|
---|
110 | inc dx ; IDE Data Reg to XTIDE MOD Data High Reg
|
---|
111 | xchg al, ah ; => AL=high byte, AH=low byte
|
---|
112 | out dx, al ; Output high byte
|
---|
113 | dec dx ; XTIDE Data High Reg to Data Low Reg
|
---|
114 | mov al, ah ; Copy low byte to AL
|
---|
115 | out dx, al ; Output low byte
|
---|
116 | %endif
|
---|
117 | %endmacro
|
---|
118 |
|
---|
119 |
|
---|
120 | %endif ; IDE_8BIT_INC
|
---|