1 | ; Project name : XTIDE Universal BIOS
|
---|
2 | ; Description : Macros for accessing data port(s) on 8-bit
|
---|
3 | ; IDE controllers.
|
---|
4 |
|
---|
5 | ;
|
---|
6 | ; XTIDE Universal BIOS and Associated Tools
|
---|
7 | ; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
|
---|
8 | ;
|
---|
9 | ; This program is free software; you can redistribute it and/or modify
|
---|
10 | ; it under the terms of the GNU General Public License as published by
|
---|
11 | ; the Free Software Foundation; either version 2 of the License, or
|
---|
12 | ; (at your option) any later version.
|
---|
13 | ;
|
---|
14 | ; This program is distributed in the hope that it will be useful,
|
---|
15 | ; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
16 | ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
17 | ; GNU General Public License for more details.
|
---|
18 | ; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
---|
19 | ;
|
---|
20 |
|
---|
21 | %ifndef IDE_8BIT_INC
|
---|
22 | %define IDE_8BIT_INC
|
---|
23 |
|
---|
24 | ;--------------------------------------------------------------------
|
---|
25 | ; UNROLL_SECTORS_IN_CX_TO_QWORDS
|
---|
26 | ; Parameters:
|
---|
27 | ; CX: Number of sectors in block
|
---|
28 | ; Returns:
|
---|
29 | ; CX: Number of QWORDs in block
|
---|
30 | ; Corrupts registers:
|
---|
31 | ; Nothing
|
---|
32 | ;--------------------------------------------------------------------
|
---|
33 | %macro UNROLL_SECTORS_IN_CX_TO_QWORDS 0
|
---|
34 | %ifdef USE_186
|
---|
35 | shl cx, 6
|
---|
36 | %else
|
---|
37 | xchg cl, ch ; Sectors to WORDs (SHL CX, 8)
|
---|
38 | shr cx, 1
|
---|
39 | shr cx, 1
|
---|
40 | %endif
|
---|
41 | %endmacro
|
---|
42 |
|
---|
43 |
|
---|
44 | ;--------------------------------------------------------------------
|
---|
45 | ; Emulates INSW for XTIDE.
|
---|
46 | ;
|
---|
47 | ; XTIDE_INSW
|
---|
48 | ; Parameters:
|
---|
49 | ; BL: Bit mask for toggling XTIDE data low/high reg
|
---|
50 | ; DX: XTIDE Data Low Register address
|
---|
51 | ; ES:DI: Ptr to destination buffer
|
---|
52 | ; Returns:
|
---|
53 | ; ES:DI: Incremented/decremented for next word
|
---|
54 | ; Corrupts registers:
|
---|
55 | ; AL, FLAGS
|
---|
56 | ;--------------------------------------------------------------------
|
---|
57 | %macro XTIDE_INSW 0
|
---|
58 | %ifdef USE_186 ; INS instruction available
|
---|
59 | insb ; Load low byte from port DX to [ES:DI]
|
---|
60 | xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
|
---|
61 | insb ; Load high byte from port DX to [ES:DI]
|
---|
62 | xor dl, bl ; Restore to IDE Data Register
|
---|
63 | %else ; If 8088/8086
|
---|
64 | in al, dx ; Load low byte from port
|
---|
65 | xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
|
---|
66 | stosb ; Store byte to [ES:DI]
|
---|
67 | in al, dx ; Load high byte from port
|
---|
68 | xor dl, bl ; Restore to IDE Data Register
|
---|
69 | stosb ; Store byte to [ES:DI]
|
---|
70 | %endif
|
---|
71 | %endmacro
|
---|
72 |
|
---|
73 |
|
---|
74 | ;--------------------------------------------------------------------
|
---|
75 | ; Emulates OUTSW for XTIDE.
|
---|
76 | ;
|
---|
77 | ; XTIDE_OUTSW
|
---|
78 | ; Parameters:
|
---|
79 | ; BL: Bit mask for toggling XTIDE data low/high reg
|
---|
80 | ; DX: XTIDE Data Low Register address
|
---|
81 | ; DS:SI: Ptr to source buffer
|
---|
82 | ; Returns:
|
---|
83 | ; SI: Incremented/decremented for next word
|
---|
84 | ; Corrupts registers:
|
---|
85 | ; AX, FLAGS
|
---|
86 | ;--------------------------------------------------------------------
|
---|
87 | %macro XTIDE_OUTSW 0
|
---|
88 | %ifdef USE_186 ; OUTS instruction available
|
---|
89 | lodsb ; Load low byte from [DS:SI] to AL
|
---|
90 | xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
|
---|
91 | outsb ; Output high byte from [DS:SI]
|
---|
92 | xor dl, bl ; XTIDE Data High Reg to Data Low Reg
|
---|
93 | out dx, al ; Output low byte from AL
|
---|
94 | %else ; If 8088/8086
|
---|
95 | lodsw ; Load word from [DS:SI]
|
---|
96 | xor dl, bl ; IDE Data Reg to XTIDE Data High Reg
|
---|
97 | xchg al, ah ; => AL=high byte, AH=low byte
|
---|
98 | out dx, al ; Output high byte
|
---|
99 | xor dl, bl ; XTIDE Data High Reg to Data Low Reg
|
---|
100 | mov al, ah ; Copy low byte to AL
|
---|
101 | out dx, al ; Output low byte
|
---|
102 | %endif
|
---|
103 | %endmacro
|
---|
104 |
|
---|
105 |
|
---|
106 | ;--------------------------------------------------------------------
|
---|
107 | ; Emulates OUTSW for modified XTIDE.
|
---|
108 | ;
|
---|
109 | ; XTIDE_MOD_OUTSW
|
---|
110 | ; Parameters:
|
---|
111 | ; DX: XTIDE Data Low Register address
|
---|
112 | ; DS:SI: Ptr to source buffer
|
---|
113 | ; Returns:
|
---|
114 | ; SI: Incremented/decremented for next word
|
---|
115 | ; Corrupts registers:
|
---|
116 | ; AX, FLAGS
|
---|
117 | ;--------------------------------------------------------------------
|
---|
118 | %macro XTIDE_MOD_OUTSW 0
|
---|
119 | %ifdef USE_186 ; OUTS instruction available
|
---|
120 | lodsb ; Load low byte from [DS:SI] to AL
|
---|
121 | inc dx ; IDE Data Reg to XTIDE MOD Data High Reg
|
---|
122 | outsb ; Output high byte from [DS:SI]
|
---|
123 | dec dx ; XTIDE Data High Reg to Data Low Reg
|
---|
124 | out dx, al ; Output low byte from AL
|
---|
125 | %else ; If 8088/8086
|
---|
126 | lodsw ; Load word from [DS:SI]
|
---|
127 | inc dx ; IDE Data Reg to XTIDE MOD Data High Reg
|
---|
128 | xchg al, ah ; => AL=high byte, AH=low byte
|
---|
129 | out dx, al ; Output high byte
|
---|
130 | dec dx ; XTIDE Data High Reg to Data Low Reg
|
---|
131 | mov al, ah ; Copy low byte to AL
|
---|
132 | out dx, al ; Output low byte
|
---|
133 | %endif
|
---|
134 | %endmacro
|
---|
135 |
|
---|
136 |
|
---|
137 | %endif ; IDE_8BIT_INC
|
---|