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

Last change on this file since 565 was 558, checked in by krille_n_@…, 11 years ago

Changes:

  • Building the BIOS Drive Information Tool now works again.
  • Moved all XT-CF related code to MODULE_8BIT_IDE_ADVANCED. I don't see how an XT-CF card could work without *_ADVANCED anyway but if I'm wrong, feel free to undo this. Note! The autodetection code in XTIDECFG has NOT been changed to reflect this (still relies on MODULE_8BIT_IDE).
  • Optimizations and fixes in general.
File size: 7.4 KB
RevLine 
[473]1; Project name : XTIDE Universal BIOS
[558]2; Description : IDE Read/Write functions for transferring block using PIO modes.
[473]3; These functions should only be called from IdeTransfer.asm.
4
5;
6; XTIDE Universal BIOS and Associated Tools
[526]7; Copyright (C) 2009-2010 by Tomi Tilli, 2011-2013 by XTIDE Universal BIOS Team.
[473]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
[545]21; Modified by JJP for XT-CFv3 support, Mar-13
22
[473]23; Section containing code
24SECTION .text
25
[545]26
27; --------------------------------------------------------------------------------------------------
28;
29; READ routines follow
30;
31; --------------------------------------------------------------------------------------------------
32
33
[473]34%ifdef MODULE_8BIT_IDE
35
36;--------------------------------------------------------------------
37; IdePioBlock_ReadFromXtideRev1
38; Parameters:
39; CX: Block size in 512 byte sectors
40; DX: IDE Data port address
41; ES:DI: Normalized ptr to buffer to receive data
42; Returns:
43; Nothing
44; Corrupts registers:
45; AX, BX, CX
46;--------------------------------------------------------------------
47ALIGN JUMP_ALIGN
48IdePioBlock_ReadFromXtideRev1:
49 UNROLL_SECTORS_IN_CX_TO_OWORDS
50 mov bl, 8 ; Bit mask for toggling data low/high reg
51ALIGN JUMP_ALIGN
52.InswLoop:
53 %rep 8 ; WORDs
54 XTIDE_INSW
55 %endrep
56 loop .InswLoop
57 ret
58
59
60;--------------------------------------------------------------------
[545]61; IdePioBlock_ReadFrom8bitDataPort
62;
63; 8-bit PIO from a single data port.
64;
[473]65; Parameters:
[558]66; CX: Block size in 512 byte sectors
67; DX: IDE Data port address
[473]68; ES:DI: Normalized ptr to buffer to receive data
69; Returns:
70; Nothing
71; Corrupts registers:
72; AX, BX, CX
73;--------------------------------------------------------------------
74ALIGN JUMP_ALIGN
[545]75IdePioBlock_ReadFrom8bitDataPort:
76%ifdef USE_186
77 shl cx, 9 ; Sectors to BYTEs
78 rep insb
79 ret
80%else ; If 8088/8086
[473]81 UNROLL_SECTORS_IN_CX_TO_OWORDS
82ALIGN JUMP_ALIGN
83.ReadNextOword:
[545]84 %rep 16 ; BYTEs
85 in al, dx ; Read BYTE
86 stosb ; Store BYTE to [ES:DI]
[473]87 %endrep
[545]88 loop .ReadNextOword
89 ret
[473]90%endif
91
[545]92%endif ; MODULE_8BIT_IDE
[473]93
[545]94
[473]95;--------------------------------------------------------------------
[545]96; IdePioBlock_ReadFrom16bitDataPort
97;
98; 16-bit PIO from a single data port.
99;
[473]100; Parameters:
[558]101; CX: Block size in 512 byte sectors
102; DX: IDE Data port address
[473]103; ES:DI: Normalized ptr to buffer to receive data
104; Returns:
105; Nothing
106; Corrupts registers:
107; AX, BX, CX
108;--------------------------------------------------------------------
109ALIGN JUMP_ALIGN
[545]110IdePioBlock_ReadFrom16bitDataPort:
[473]111%ifdef USE_186
[558]112 xchg cl, ch ; Sectors to WORDs
[545]113 rep insw
[473]114 ret
115
116%else ; If 8088/8086
117 UNROLL_SECTORS_IN_CX_TO_OWORDS
118ALIGN JUMP_ALIGN
119.ReadNextOword:
[545]120 %rep 8 ; WORDs
[558]121 in ax, dx ; Read WORD
122 stosw ; Store WORD to [ES:DI]
[473]123 %endrep
124 loop .ReadNextOword
125 ret
126%endif
127
128
129;--------------------------------------------------------------------
[545]130ALIGN JUMP_ALIGN
131IdePioBlock_ReadFrom32bitDataPort:
132 db 0C1h ; SHL
133 db 0E1h ; CX
134 db 7 ; 7 (Sectors to DWORDs)
135 rep
136 db 66h ; Override operand size to 32-bit
137 db 6Dh ; INSW/INSD
138 ret
139
140
141
142; --------------------------------------------------------------------------------------------------
143;
144; WRITE routines follow
145;
146; --------------------------------------------------------------------------------------------------
147
148%ifdef MODULE_8BIT_IDE
149
150;--------------------------------------------------------------------
[473]151; IdePioBlock_WriteToXtideRev1
152; Parameters:
[558]153; CX: Block size in 512-byte sectors
154; DX: IDE Data port address
[473]155; ES:SI: Normalized ptr to buffer containing data
156; Returns:
157; Nothing
158; Corrupts registers:
159; AX, BX, CX, DX
160;--------------------------------------------------------------------
161ALIGN JUMP_ALIGN
162IdePioBlock_WriteToXtideRev1:
163 push ds
164 UNROLL_SECTORS_IN_CX_TO_QWORDS
165 mov bl, 8 ; Bit mask for toggling data low/high reg
166 push es ; Copy ES...
167 pop ds ; ...to DS
168ALIGN JUMP_ALIGN
169.OutswLoop:
170 %rep 4 ; WORDs
171 XTIDE_OUTSW
172 %endrep
173 loop .OutswLoop
174 pop ds
175 ret
176
177
178;--------------------------------------------------------------------
179; IdePioBlock_WriteToXtideRev2 or rev 1 with swapped A0 and A3 (chuck-mod)
180; Parameters:
[558]181; CX: Block size in 512-byte sectors
182; DX: IDE Data port address
[473]183; ES:SI: Normalized ptr to buffer containing data
184; Returns:
185; Nothing
186; Corrupts registers:
187; AX, BX, CX, DX
188;--------------------------------------------------------------------
189ALIGN JUMP_ALIGN
190IdePioBlock_WriteToXtideRev2:
191 UNROLL_SECTORS_IN_CX_TO_QWORDS
[558]192 push ds
193 push es ; Copy ES...
194 pop ds ; ...to DS
[473]195ALIGN JUMP_ALIGN
196.WriteNextQword:
197 %rep 4 ; WORDs
[545]198 XTIDE_MOD_OUTSW ; special macro
[473]199 %endrep
200 loop .WriteNextQword
201 pop ds
202 ret
203
204
205;--------------------------------------------------------------------
[545]206; IdePioBlock_WriteTo8bitDataPort
[473]207; Parameters:
[558]208; CX: Block size in 512-byte sectors
209; DX: IDE Data port address
[473]210; ES:SI: Normalized ptr to buffer containing data
211; Returns:
212; Nothing
213; Corrupts registers:
214; AX, BX, CX, DX
215;--------------------------------------------------------------------
216ALIGN JUMP_ALIGN
217IdePioBlock_WriteTo8bitDataPort:
218%ifdef USE_186
219 shl cx, 9 ; Sectors to BYTEs
220 es ; Source is ES segment
221 rep outsb
222 ret
223
224%else ; If 8088/8086
[545]225 UNROLL_SECTORS_IN_CX_TO_QWORDS
[558]226 push ds
227 ;mov ax, es
228 ;mov ds, ax ; move es to ds via ax (does this run faster on 8088?)
229 push es
230 pop ds
[473]231ALIGN JUMP_ALIGN
[545]232.WriteNextQword:
233 %rep 8 ; BYTEs
234 lodsb ; Load BYTE from [DS:SI]
235 out dx, al ; Write BYTE
[473]236 %endrep
[545]237 loop .WriteNextQword
[473]238 pop ds
239 ret
240%endif
241
242%endif ; MODULE_8BIT_IDE
243
244
245;--------------------------------------------------------------------
[545]246; IdePioBlock_WriteTo16bitDataPort Normal 16-bit IDE, XT-CFv3 in BIU Mode
[473]247; IdePioBlock_WriteTo32bitDataPort VLB/PCI 32-bit IDE
248; Parameters:
[558]249; CX: Block size in 512-byte sectors
250; DX: IDE Data port address
[473]251; ES:SI: Normalized ptr to buffer containing data
252; Returns:
253; Nothing
254; Corrupts registers:
255; AX, BX, CX, DX
256;--------------------------------------------------------------------
257ALIGN JUMP_ALIGN
258IdePioBlock_WriteTo16bitDataPort:
[545]259%ifdef USE_186
[473]260 xchg cl, ch ; Sectors to WORDs
261 es ; Source is ES segment
[545]262 rep outsw
[473]263 ret
264
[545]265%else ; If 8088/8086
266 UNROLL_SECTORS_IN_CX_TO_QWORDS
267 push ds
268 ;mov ax, es
269 ;mov ds, ax ; move es to ds via ax (does this run faster on 8088?)
270 push es
271 pop ds
272ALIGN JUMP_ALIGN
273.WriteNextQword:
274 %rep 4 ; WORDs
[558]275 lodsw ; Load WORD from [DS:SI]
276 out dx, ax ; Write WORD
[545]277 %endrep
278 loop .WriteNextQword
279 pop ds
280 ret
281%endif ; if/else USE_186
282
[473]283;--------------------------------------------------------------------
284ALIGN JUMP_ALIGN
285IdePioBlock_WriteTo32bitDataPort:
[480]286 db 0C1h ; SHL
287 db 0E1h ; CX
288 db 7 ; 7 (Sectors to DWORDs)
[473]289 es ; Source is ES segment
290 rep
291 db 66h ; Override operand size to 32-bit
292 db 6Fh ; OUTSW/OUTSD
293 ret
Note: See TracBrowser for help on using the repository browser.