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

Last change on this file since 608 was 601, checked in by Krister Nordvall, 6 years ago

Changes:

  • Building the BIOS now works again.
  • Added a new IDE device type/transfer mode for use only with XT-IDE rev 2+ (or Chuck(G)-modded rev 1) cards installed in any of the following machines: Olivetti M24, AT&T PC6300, Xerox 6060 and Logabax Persona 1600. This new transfer mode is slightly faster than the regular XT-IDE rev 1 device type and requires that the card is configured for High Speed mode (or, in case of the card being a rev 1 card, has the Chuck(G) mod done). The new device type is called "XTIDE rev 2 (Olivetti M24)" in XTIDECFG.
  • Made some minor improvements to the library code that handles 'Drive Not Ready' errors in XTIDECFG.
  • Optimizations.
File size: 7.3 KB
Line 
1; Project name : XTIDE Universal BIOS
2; Description : IDE Read/Write functions for transferring block using PIO modes.
3; These functions should only be called from IdeTransfer.asm.
4
5;
6; XTIDE Universal BIOS and Associated Tools
7; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 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; Section containing code
22SECTION .text
23
24
25; --------------------------------------------------------------------------------------------------
26;
27; READ routines follow
28;
29; --------------------------------------------------------------------------------------------------
30
31%ifdef MODULE_8BIT_IDE
32;--------------------------------------------------------------------
33; IdePioBlock_ReadFromXtideRev1
34; Parameters:
35; CX: Block size in 512 byte sectors
36; DX: IDE Data port address
37; ES:DI: Normalized ptr to buffer to receive data
38; Returns:
39; Nothing
40; Corrupts registers:
41; AX, BX, CX
42;--------------------------------------------------------------------
43ALIGN JUMP_ALIGN
44IdePioBlock_ReadFromXtideRev1:
45 UNROLL_SECTORS_IN_CX_TO_OWORDS
46 mov bl, 8 ; Bit mask for toggling data low/high reg
47ALIGN JUMP_ALIGN
48.InswLoop:
49 %rep 8 ; WORDs
50 XTIDE_INSW
51 %endrep
52 loop .InswLoop
53 ret
54
55
56;--------------------------------------------------------------------
57; IdePioBlock_ReadFromXtideRev2_Olivetti
58; Parameters:
59; CX: Block size in 512 byte sectors
60; DX: IDE Data port address
61; ES:DI: Normalized ptr to buffer to receive data
62; Returns:
63; Nothing
64; Corrupts registers:
65; AX, CX
66;--------------------------------------------------------------------
67ALIGN JUMP_ALIGN
68IdePioBlock_ReadFromXtideRev2_Olivetti:
69 UNROLL_SECTORS_IN_CX_TO_OWORDS
70ALIGN JUMP_ALIGN
71.InswLoop:
72 %rep 8 ; WORDs
73 XTIDE_MOD_OLIVETTI_INSW
74 %endrep
75 loop .InswLoop
76 ret
77
78
79;--------------------------------------------------------------------
80; 8-bit PIO from a single data port.
81;
82; IdePioBlock_ReadFrom8bitDataPort
83; Parameters:
84; CX: Block size in 512 byte sectors
85; DX: IDE Data port address
86; ES:DI: Normalized ptr to buffer to receive data
87; Returns:
88; Nothing
89; Corrupts registers:
90; AX, CX
91;--------------------------------------------------------------------
92ALIGN JUMP_ALIGN
93IdePioBlock_ReadFrom8bitDataPort:
94%ifdef USE_186
95 shl cx, 9 ; Sectors to BYTEs
96 rep insb
97 ret
98%else ; 808x
99 UNROLL_SECTORS_IN_CX_TO_OWORDS
100ALIGN JUMP_ALIGN
101.ReadNextOword:
102 %rep 16 ; BYTEs
103 in al, dx ; Read BYTE
104 stosb ; Store BYTE to [ES:DI]
105 %endrep
106 loop .ReadNextOword
107 ret
108%endif
109%endif ; MODULE_8BIT_IDE
110
111
112;--------------------------------------------------------------------
113; 16-bit and 32-bit PIO from a single data port.
114;
115; IdePioBlock_ReadFrom16bitDataPort
116; IdePioBlock_ReadFrom32bitDataPort
117; Parameters:
118; CX: Block size in 512 byte sectors
119; DX: IDE Data port address
120; ES:DI: Normalized ptr to buffer to receive data
121; Returns:
122; Nothing
123; Corrupts registers:
124; AX, CX
125;--------------------------------------------------------------------
126ALIGN JUMP_ALIGN
127IdePioBlock_ReadFrom16bitDataPort:
128%ifdef USE_186
129 xchg cl, ch ; Sectors to WORDs
130 rep insw
131 ret
132
133%else ; 808x
134 UNROLL_SECTORS_IN_CX_TO_OWORDS
135ALIGN JUMP_ALIGN
136.ReadNextOword:
137 %rep 8 ; WORDs
138 in ax, dx ; Read WORD
139 stosw ; Store WORD to [ES:DI]
140 %endrep
141 loop .ReadNextOword
142 ret
143%endif
144
145
146;--------------------------------------------------------------------
147%ifdef MODULE_ADVANCED_ATA
148ALIGN JUMP_ALIGN
149IdePioBlock_ReadFrom32bitDataPort:
150 shl cx, 7 ; Sectors to DWORDs
151 rep insd
152 ret
153%endif ; MODULE_ADVANCED_ATA
154
155
156; --------------------------------------------------------------------------------------------------
157;
158; WRITE routines follow
159;
160; --------------------------------------------------------------------------------------------------
161
162%ifdef MODULE_8BIT_IDE
163;--------------------------------------------------------------------
164; IdePioBlock_WriteToXtideRev1
165; Parameters:
166; CX: Block size in 512-byte sectors
167; DX: IDE Data port address
168; DS:SI: Normalized ptr to buffer containing data
169; Returns:
170; Nothing
171; Corrupts registers:
172; AX, BX, CX
173;--------------------------------------------------------------------
174ALIGN JUMP_ALIGN
175IdePioBlock_WriteToXtideRev1:
176 UNROLL_SECTORS_IN_CX_TO_QWORDS
177 mov bl, 8 ; Bit mask for toggling data low/high reg
178ALIGN JUMP_ALIGN
179.OutswLoop:
180 %rep 4 ; WORDs
181 XTIDE_OUTSW
182 %endrep
183 loop .OutswLoop
184 ret
185
186
187;--------------------------------------------------------------------
188; IdePioBlock_WriteToXtideRev2 or rev 1 with swapped A0 and A3 (chuck-mod)
189; Parameters:
190; CX: Block size in 512-byte sectors
191; DX: IDE Data port address
192; DS:SI: Normalized ptr to buffer containing data
193; Returns:
194; Nothing
195; Corrupts registers:
196; AX, CX
197;--------------------------------------------------------------------
198ALIGN JUMP_ALIGN
199IdePioBlock_WriteToXtideRev2:
200 UNROLL_SECTORS_IN_CX_TO_QWORDS
201ALIGN JUMP_ALIGN
202.WriteNextQword:
203 %rep 4 ; WORDs
204 XTIDE_MOD_OUTSW
205 %endrep
206 loop .WriteNextQword
207 ret
208
209
210;--------------------------------------------------------------------
211; IdePioBlock_WriteTo8bitDataPort
212; Parameters:
213; CX: Block size in 512-byte sectors
214; DX: IDE Data port address
215; DS:SI: Normalized ptr to buffer containing data
216; Returns:
217; Nothing
218; Corrupts registers:
219; AX, CX
220;--------------------------------------------------------------------
221ALIGN JUMP_ALIGN
222IdePioBlock_WriteTo8bitDataPort:
223%ifdef USE_186
224 shl cx, 9 ; Sectors to BYTEs
225 rep outsb
226 ret
227
228%else ; 808x
229 UNROLL_SECTORS_IN_CX_TO_QWORDS
230ALIGN JUMP_ALIGN
231.WriteNextQword:
232 %rep 8 ; BYTEs
233 lodsb ; Load BYTE from [DS:SI]
234 out dx, al ; Write BYTE
235 %endrep
236 loop .WriteNextQword
237 ret
238%endif
239%endif ; MODULE_8BIT_IDE
240
241
242;--------------------------------------------------------------------
243; IdePioBlock_WriteTo16bitDataPort Normal 16-bit IDE, XT-CFv3 in BIU Mode
244; IdePioBlock_WriteTo32bitDataPort VLB/PCI 32-bit IDE
245; Parameters:
246; CX: Block size in 512-byte sectors
247; DX: IDE Data port address
248; DS:SI: Normalized ptr to buffer containing data
249; Returns:
250; Nothing
251; Corrupts registers:
252; AX, CX
253;--------------------------------------------------------------------
254ALIGN JUMP_ALIGN
255IdePioBlock_WriteTo16bitDataPort:
256%ifdef USE_186
257 xchg cl, ch ; Sectors to WORDs
258 rep outsw
259 ret
260
261%else ; 808x
262 UNROLL_SECTORS_IN_CX_TO_QWORDS
263ALIGN JUMP_ALIGN
264.WriteNextQword:
265 %rep 4 ; WORDs
266 lodsw ; Load WORD from [DS:SI]
267 out dx, ax ; Write WORD
268 %endrep
269 loop .WriteNextQword
270 ret
271%endif
272
273;--------------------------------------------------------------------
274%ifdef MODULE_ADVANCED_ATA
275ALIGN JUMP_ALIGN
276IdePioBlock_WriteTo32bitDataPort:
277 shl cx, 7 ; Sectors to DWORDs
278 rep outsd
279 ret
280%endif ; MODULE_ADVANCED_ATA
Note: See TracBrowser for help on using the repository browser.