source: xtideuniversalbios/trunk/XTIDE_Universal_BIOS/Src/Device/IDE/IdePioBlock.asm@ 493

Last change on this file since 493 was 489, checked in by gregli@…, 12 years ago

Added version string to initial title banner, for cases where there is not a boot menu (just hotkeys, or no hotkeys). Also ifdef'd out some unused code.

File size: 7.1 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : IDE Read/Write functions for transferring
3; block using PIO modes.
4; These functions should only be called from IdeTransfer.asm.
5
6;
7; XTIDE Universal BIOS and Associated Tools
8; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2012 by XTIDE Universal BIOS Team.
9;
10; This program is free software; you can redistribute it and/or modify
11; it under the terms of the GNU General Public License as published by
12; the Free Software Foundation; either version 2 of the License, or
13; (at your option) any later version.
14;
15; This program is distributed in the hope that it will be useful,
16; but WITHOUT ANY WARRANTY; without even the implied warranty of
17; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18; GNU General Public License for more details.
19; Visit http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20;
21
22; Section containing code
23SECTION .text
24
25%ifdef MODULE_8BIT_IDE
26
27;--------------------------------------------------------------------
28; IdePioBlock_ReadFromXtideRev1
29; Parameters:
30; CX: Block size in 512 byte sectors
31; DX: IDE Data port address
32; ES:DI: Normalized ptr to buffer to receive data
33; Returns:
34; Nothing
35; Corrupts registers:
36; AX, BX, CX
37;--------------------------------------------------------------------
38ALIGN JUMP_ALIGN
39IdePioBlock_ReadFromXtideRev1:
40 UNROLL_SECTORS_IN_CX_TO_OWORDS
41 mov bl, 8 ; Bit mask for toggling data low/high reg
42ALIGN JUMP_ALIGN
43.InswLoop:
44 %rep 8 ; WORDs
45 XTIDE_INSW
46 %endrep
47 loop .InswLoop
48 ret
49
50
51;--------------------------------------------------------------------
52; IdePioBlock_ReadFromXtideRev2 or rev 1 with swapped A0 and A3 (chuck-mod)
53; Parameters:
54; CX: Block size in 512 byte sectors
55; DX: IDE Data port address
56; ES:DI: Normalized ptr to buffer to receive data
57; Returns:
58; Nothing
59; Corrupts registers:
60; AX, BX, CX
61;--------------------------------------------------------------------
62%ifndef USE_186 ; 8086/8088 compatible WORD read
63
64ALIGN JUMP_ALIGN
65IdePioBlock_ReadFromXtideRev2:
66 UNROLL_SECTORS_IN_CX_TO_OWORDS
67ALIGN JUMP_ALIGN
68.ReadNextOword:
69 %rep 8 ; WORDs
70 in ax, dx ; Read WORD
71 stosw ; Store WORD to [ES:DI]
72 %endrep
73 loop .ReadNextOword
74 ret
75
76%endif
77
78
79;--------------------------------------------------------------------
80; IdePioBlock_ReadFrom8bitDataPort CF-XT when using 8-bit PIO
81; Parameters:
82; CX: Block size in 512 byte sectors
83; DX: IDE Data port address
84; ES:DI: Normalized ptr to buffer to receive data
85; Returns:
86; Nothing
87; Corrupts registers:
88; AX, BX, CX
89;--------------------------------------------------------------------
90ALIGN JUMP_ALIGN
91IdePioBlock_ReadFrom8bitDataPort:
92%ifdef USE_186
93 shl cx, 9 ; Sectors to BYTEs
94 rep insb
95 ret
96
97%else ; If 8088/8086
98 UNROLL_SECTORS_IN_CX_TO_OWORDS
99ALIGN JUMP_ALIGN
100.ReadNextOword:
101 %rep 16 ; BYTEs
102 in al, dx ; Read BYTE
103 stosb ; Store BYTE to [ES:DI]
104 %endrep
105 loop .ReadNextOword
106 ret
107%endif
108
109
110;--------------------------------------------------------------------
111; IdePioBlock_WriteToXtideRev1
112; Parameters:
113; CX: Block size in 512-byte sectors
114; DX: IDE Data port address
115; ES:SI: Normalized ptr to buffer containing data
116; Returns:
117; Nothing
118; Corrupts registers:
119; AX, BX, CX, DX
120;--------------------------------------------------------------------
121ALIGN JUMP_ALIGN
122IdePioBlock_WriteToXtideRev1:
123 push ds
124 UNROLL_SECTORS_IN_CX_TO_QWORDS
125 mov bl, 8 ; Bit mask for toggling data low/high reg
126 push es ; Copy ES...
127 pop ds ; ...to DS
128ALIGN JUMP_ALIGN
129.OutswLoop:
130 %rep 4 ; WORDs
131 XTIDE_OUTSW
132 %endrep
133 loop .OutswLoop
134 pop ds
135 ret
136
137
138;--------------------------------------------------------------------
139; IdePioBlock_WriteToXtideRev2 or rev 1 with swapped A0 and A3 (chuck-mod)
140; Parameters:
141; CX: Block size in 512-byte sectors
142; DX: IDE Data port address
143; ES:SI: Normalized ptr to buffer containing data
144; Returns:
145; Nothing
146; Corrupts registers:
147; AX, BX, CX, DX
148;--------------------------------------------------------------------
149ALIGN JUMP_ALIGN
150IdePioBlock_WriteToXtideRev2:
151 UNROLL_SECTORS_IN_CX_TO_QWORDS
152 push ds
153 push es ; Copy ES...
154 pop ds ; ...to DS
155ALIGN JUMP_ALIGN
156.WriteNextQword:
157 %rep 4 ; WORDs
158 XTIDE_MOD_OUTSW
159 %endrep
160 loop .WriteNextQword
161 pop ds
162 ret
163
164
165;--------------------------------------------------------------------
166; IdePioBlock_WriteTo8bitDataPort XT-CF when using 8-bit PIO
167; Parameters:
168; CX: Block size in 512-byte sectors
169; DX: IDE Data port address
170; ES:SI: Normalized ptr to buffer containing data
171; Returns:
172; Nothing
173; Corrupts registers:
174; AX, BX, CX, DX
175;--------------------------------------------------------------------
176ALIGN JUMP_ALIGN
177IdePioBlock_WriteTo8bitDataPort:
178
179%ifdef USE_186
180 shl cx, 9 ; Sectors to BYTEs
181 es ; Source is ES segment
182 rep outsb
183 ret
184
185%else ; If 8088/8086
186 UNROLL_SECTORS_IN_CX_TO_DWORDS
187 push ds
188 push es
189 pop ds
190ALIGN JUMP_ALIGN
191.WriteNextDword:
192 %rep 4 ; BYTEs
193 lodsb ; Load BYTE from [DS:SI]
194 out dx, al ; Write BYTE
195 %endrep
196 loop .WriteNextDword
197 pop ds
198 ret
199%endif
200
201%endif ; MODULE_8BIT_IDE
202
203
204;--------------------------------------------------------------------
205; IdePioBlock_ReadFromXtideRev2 (when 80186/80188 instructions are available)
206; IdePioBlock_ReadFrom16bitDataPort Normal 16-bit IDE
207; IdePioBlock_ReadFrom32bitDataPort VLB/PCI 32-bit IDE
208; Parameters:
209; CX: Block size in 512 byte sectors
210; DX: IDE Data port address
211; ES:DI: Normalized ptr to buffer to receive data
212; Returns:
213; Nothing
214; Corrupts registers:
215; AX, BX, CX
216;--------------------------------------------------------------------
217ALIGN JUMP_ALIGN
218%ifdef USE_186
219%ifdef MODULE_8BIT_IDE
220IdePioBlock_ReadFromXtideRev2:
221%endif
222%endif
223IdePioBlock_ReadFrom16bitDataPort:
224 xchg cl, ch ; Sectors to WORDs
225 rep
226 db 6Dh ; INSW
227 ret
228
229;--------------------------------------------------------------------
230ALIGN JUMP_ALIGN
231IdePioBlock_ReadFrom32bitDataPort:
232 db 0C1h ; SHL
233 db 0E1h ; CX
234 db 7 ; 7 (Sectors to DWORDs)
235 rep
236 db 66h ; Override operand size to 32-bit
237 db 6Dh ; INSW/INSD
238 ret
239
240
241;--------------------------------------------------------------------
242; IdePioBlock_WriteTo16bitDataPort Normal 16-bit IDE
243; IdePioBlock_WriteTo32bitDataPort VLB/PCI 32-bit IDE
244; Parameters:
245; CX: Block size in 512-byte sectors
246; DX: IDE Data port address
247; ES:SI: Normalized ptr to buffer containing data
248; Returns:
249; Nothing
250; Corrupts registers:
251; AX, BX, CX, DX
252;--------------------------------------------------------------------
253ALIGN JUMP_ALIGN
254IdePioBlock_WriteTo16bitDataPort:
255 xchg cl, ch ; Sectors to WORDs
256 es ; Source is ES segment
257 rep
258 db 6Fh ; OUTSW
259 ret
260
261;--------------------------------------------------------------------
262ALIGN JUMP_ALIGN
263IdePioBlock_WriteTo32bitDataPort:
264 db 0C1h ; SHL
265 db 0E1h ; CX
266 db 7 ; 7 (Sectors to DWORDs)
267 es ; Source is ES segment
268 rep
269 db 66h ; Override operand size to 32-bit
270 db 6Fh ; OUTSW/OUTSD
271 ret
Note: See TracBrowser for help on using the repository browser.