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

Last change on this file since 484 was 480, checked in by aitotat@…, 12 years ago

Changes to XTIDE Universal BIOS:

  • XT-CF DMA transfers should now work.
File size: 7.0 KB
RevLine 
[473]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
[480]218%ifdef USE_186
[473]219IdePioBlock_ReadFromXtideRev2:
[480]220%endif
[473]221IdePioBlock_ReadFrom16bitDataPort:
222 xchg cl, ch ; Sectors to WORDs
[480]223 rep
224 db 6Dh ; INSW
[473]225 ret
226
227;--------------------------------------------------------------------
228ALIGN JUMP_ALIGN
229IdePioBlock_ReadFrom32bitDataPort:
[480]230 db 0C1h ; SHL
231 db 0E1h ; CX
232 db 7 ; 7 (Sectors to DWORDs)
[473]233 rep
234 db 66h ; Override operand size to 32-bit
235 db 6Dh ; INSW/INSD
236 ret
237
238
239;--------------------------------------------------------------------
240; IdePioBlock_WriteTo16bitDataPort Normal 16-bit IDE
241; IdePioBlock_WriteTo32bitDataPort VLB/PCI 32-bit IDE
242; Parameters:
243; CX: Block size in 512-byte sectors
244; DX: IDE Data port address
245; ES:SI: Normalized ptr to buffer containing data
246; Returns:
247; Nothing
248; Corrupts registers:
249; AX, BX, CX, DX
250;--------------------------------------------------------------------
251ALIGN JUMP_ALIGN
252IdePioBlock_WriteTo16bitDataPort:
253 xchg cl, ch ; Sectors to WORDs
254 es ; Source is ES segment
[480]255 rep
256 db 6Fh ; OUTSW
[473]257 ret
258
259;--------------------------------------------------------------------
260ALIGN JUMP_ALIGN
261IdePioBlock_WriteTo32bitDataPort:
[480]262 db 0C1h ; SHL
263 db 0E1h ; CX
264 db 7 ; 7 (Sectors to DWORDs)
[473]265 es ; Source is ES segment
266 rep
267 db 66h ; Override operand size to 32-bit
268 db 6Fh ; OUTSW/OUTSD
269 ret
Note: See TracBrowser for help on using the repository browser.