source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Inc/IdeIO.inc@ 630

Last change on this file since 630 was 630, checked in by Krister Nordvall, 8 days ago

Changes:

  • Changed the g_szPCFlashSuccessful string in XTIDECFG to reflect the reality - it turns out ANY key was limited to just ENTER or ESC.
  • Removed the NEC V-specific optimization I added in r602 because NEC's documentation completely fails to mention that the ROL4 instruction also changes the high nibble of AL. Huge thanks to vcfed-member dreNorteR for discovering this and also for suggesting an optimization to the physical address conversion code in IdeTransfer.asm.
  • Made some changes to the OUTPUT_AL_TO_IDE_REGISTER and OUTPUT_AL_TO_IDE_CONTROL_BLOCK_REGISTER macros as an optimization. This saves 15+12 bytes in builds without MODULE_8BIT_IDE (e.g. the PS/2 builds).
  • Other minor optimizations and cleanups.
File size: 4.9 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : Macros for normal I/O mapped ATA controllers.
3
4;
5; XTIDE Universal BIOS and Associated Tools
6; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2024 by XTIDE Universal BIOS Team.
7;
8; This program is free software; you can redistribute it and/or modify
9; it under the terms of the GNU General Public License as published by
10; the Free Software Foundation; either version 2 of the License, or
11; (at your option) any later version.
12;
13; This program is distributed in the hope that it will be useful,
14; but WITHOUT ANY WARRANTY; without even the implied warranty of
15; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16; GNU General Public License for more details.
17; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
18;
19
20%ifndef IDE_IO_INC
21%define IDE_IO_INC
22
23;--------------------------------------------------------------------
24; OUTPUT_AL_TO_IDE_REGISTER
25; OUTPUT_AL_TO_IDE_CONTROL_BLOCK_REGISTER
26; Parameters:
27; AL: Byte to output
28; %1: IDE Register (OUTPUT_AL_TO_IDE_REGISTER)
29; IDE Control Block Register (OUTPUT_AL_TO_IDE_CONTROL_BLOCK_REGISTER)
30; DS:DI: Ptr to DPT (in RAMVARS segment)
31; Returns:
32; Nothing
33; Corrupts registers:
34; BX, DX
35;--------------------------------------------------------------------
36%macro OUTPUT_AL_TO_IDE_REGISTER 1
37%ifndef MODULE_8BIT_IDE ; Standard IDE controllers only
38
39 %ifdef IO_SEQUENCE
40 %ifndef previous_parameter
41 %ifnidni %1, dx
42 mov dx, %1
43 %endif
44 add dx, [di+DPT.wBasePort]
45 %elif previous_parameter + 1 = %1
46 inc dx
47 %elif previous_parameter - 1 = %1
48 dec dx
49 %elif previous_parameter = %1
50 %else
51 %ifnidni %1, dx
52 mov dx, %1
53 %endif
54 add dx, [di+DPT.wBasePort]
55 %endif
56 %define previous_parameter %1
57
58 %else ; ~IO_SEQUENCE
59 %undef previous_parameter
60 %ifnidni %1, dx
61 mov dx, %1
62 %endif
63 add dx, [di+DPT.wBasePort]
64 %endif
65 out dx, al
66
67%else ; Register translations required
68
69 %ifnidni %1, dl
70 mov dl, %1
71 %endif
72 call IdeIO_OutputALtoIdeRegisterInDL
73
74%endif
75%endmacro
76
77
78%macro OUTPUT_AL_TO_IDE_CONTROL_BLOCK_REGISTER 1
79%ifndef MODULE_8BIT_IDE ; Standard IDE controllers only
80
81 %ifdef IO_SEQUENCE
82 %ifndef previous_parameter
83 eMOVZX bx, [di+DPT.bIdevarsOffset]
84 %ifnidni %1, dx
85 mov dx, %1
86 %endif
87 add dx, [cs:bx+IDEVARS.wControlBlockPort]
88 %elif previous_parameter + 1 = %1
89 inc dx
90 %elif previous_parameter - 1 = %1
91 dec dx
92 %elif previous_parameter = %1
93 %else
94 eMOVZX bx, [di+DPT.bIdevarsOffset]
95 %ifnidni %1, dx
96 mov dx, %1
97 %endif
98 add dx, [cs:bx+IDEVARS.wControlBlockPort]
99 %endif
100 %define previous_parameter %1
101
102 %else ; ~IO_SEQUENCE
103 %undef previous_parameter
104 eMOVZX bx, [di+DPT.bIdevarsOffset]
105 %ifnidni %1, dx
106 mov dx, %1
107 %endif
108 add dx, [cs:bx+IDEVARS.wControlBlockPort]
109 %endif
110 out dx, al
111
112%else ; Register translations required
113
114 %ifnidni %1, dl
115 mov dl, %1
116 %endif
117 call IdeIO_OutputALtoIdeControlBlockRegisterInDL
118
119%endif
120%endmacro
121
122
123;--------------------------------------------------------------------
124; INPUT_TO_AL_FROM_IDE_REGISTER
125; Parameters:
126; %1: IDE Register
127; DS:DI: Ptr to DPT (in RAMVARS segment)
128; Returns:
129; AL: Inputted byte
130; Corrupts registers:
131; BX, DX
132;--------------------------------------------------------------------
133%macro INPUT_TO_AL_FROM_IDE_REGISTER 1
134%ifndef MODULE_8BIT_IDE ; Standard IDE controllers only
135
136 %ifnidni %1, dx
137 mov dx, %1
138 %endif
139 add dx, [di+DPT.wBasePort]
140 in al, dx
141
142%else ; Register translations required
143
144 %ifnidni %1, dl
145 mov dl, %1
146 %endif
147 call IdeIO_InputToALfromIdeRegisterInDL
148
149%endif
150%endmacro
151
152
153;--------------------------------------------------------------------
154; UNROLL_SECTORS_IN_CX_TO_DWORDS
155; UNROLL_SECTORS_IN_CX_TO_QWORDS
156; UNROLL_SECTORS_IN_CX_TO_OWORDS
157; Parameters:
158; CX: Number of sectors in block
159; Returns:
160; CX: Number of DWORDs, QWORDs or OWORDs in block
161; Corrupts registers:
162; Nothing
163;--------------------------------------------------------------------
164%macro UNROLL_SECTORS_IN_CX_TO_DWORDS 0
165%ifdef USE_186
166 shl cx, 7
167%else
168 xchg cl, ch ; Sectors to WORDs (SHL CX, 8)
169 shr cx, 1
170%endif
171%endmacro
172
173%macro UNROLL_SECTORS_IN_CX_TO_QWORDS 0
174%ifdef USE_186
175 shl cx, 6
176%else
177 UNROLL_SECTORS_IN_CX_TO_DWORDS
178 shr cx, 1
179%endif
180%endmacro
181
182%macro UNROLL_SECTORS_IN_CX_TO_OWORDS 0
183%ifdef USE_186
184 shl cx, 5
185%else
186; UNROLL_SECTORS_IN_CX_TO_QWORDS
187; shr cx, 1
188 mov ch, cl ; 2 bytes shorter but possibly slower
189 mov cl, 3
190 shr cx, cl
191%endif
192%endmacro
193
194%macro UNROLL_SECTORS_IN_CX_TO_16WORDS 0
195%ifdef USE_186
196 shl cx, 4
197%else
198 mov ch, cl
199 mov cl, 4
200 shr cx, cl
201%endif
202%endmacro
203
204%macro UNROLL_SECTORS_IN_CX_TO_32WORDS 0
205%ifdef USE_186
206 shl cx, 3
207%else
208 shl cx, 1
209 shl cx, 1
210 shl cx, 1
211%endif
212%endmacro
213
214
215%endif ; IDE_IO_INC
Note: See TracBrowser for help on using the repository browser.