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

Last change on this file since 621 was 601, checked in by Krister Nordvall, 5 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
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
21; Section containing code
22SECTION .text
23
[545]24
25; --------------------------------------------------------------------------------------------------
26;
27; READ routines follow
28;
29; --------------------------------------------------------------------------------------------------
30
[473]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:
[580]49 %rep 8 ; WORDs
[473]50 XTIDE_INSW
51 %endrep
52 loop .InswLoop
53 ret
54
55
56;--------------------------------------------------------------------
[601]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;--------------------------------------------------------------------
[545]80; 8-bit PIO from a single data port.
81;
[589]82; IdePioBlock_ReadFrom8bitDataPort
[473]83; Parameters:
[558]84; CX: Block size in 512 byte sectors
85; DX: IDE Data port address
[473]86; ES:DI: Normalized ptr to buffer to receive data
87; Returns:
88; Nothing
89; Corrupts registers:
[589]90; AX, CX
[473]91;--------------------------------------------------------------------
92ALIGN JUMP_ALIGN
[545]93IdePioBlock_ReadFrom8bitDataPort:
94%ifdef USE_186
95 shl cx, 9 ; Sectors to BYTEs
96 rep insb
97 ret
[580]98%else ; 808x
[473]99 UNROLL_SECTORS_IN_CX_TO_OWORDS
100ALIGN JUMP_ALIGN
101.ReadNextOword:
[545]102 %rep 16 ; BYTEs
103 in al, dx ; Read BYTE
104 stosb ; Store BYTE to [ES:DI]
[473]105 %endrep
[545]106 loop .ReadNextOword
107 ret
[473]108%endif
[589]109%endif ; MODULE_8BIT_IDE
[473]110
111
112;--------------------------------------------------------------------
[589]113; 16-bit and 32-bit PIO from a single data port.
114;
[545]115; IdePioBlock_ReadFrom16bitDataPort
[589]116; IdePioBlock_ReadFrom32bitDataPort
[473]117; Parameters:
[558]118; CX: Block size in 512 byte sectors
119; DX: IDE Data port address
[473]120; ES:DI: Normalized ptr to buffer to receive data
121; Returns:
122; Nothing
123; Corrupts registers:
[589]124; AX, CX
[473]125;--------------------------------------------------------------------
126ALIGN JUMP_ALIGN
[545]127IdePioBlock_ReadFrom16bitDataPort:
[473]128%ifdef USE_186
[589]129 xchg cl, ch ; Sectors to WORDs
[545]130 rep insw
[473]131 ret
132
[580]133%else ; 808x
[473]134 UNROLL_SECTORS_IN_CX_TO_OWORDS
135ALIGN JUMP_ALIGN
136.ReadNextOword:
[545]137 %rep 8 ; WORDs
[558]138 in ax, dx ; Read WORD
139 stosw ; Store WORD to [ES:DI]
[473]140 %endrep
141 loop .ReadNextOword
142 ret
143%endif
144
145
146;--------------------------------------------------------------------
[589]147%ifdef MODULE_ADVANCED_ATA
[545]148ALIGN JUMP_ALIGN
149IdePioBlock_ReadFrom32bitDataPort:
[589]150 shl cx, 7 ; Sectors to DWORDs
151 rep insd
[545]152 ret
[589]153%endif ; MODULE_ADVANCED_ATA
[545]154
155
156; --------------------------------------------------------------------------------------------------
157;
158; WRITE routines follow
159;
160; --------------------------------------------------------------------------------------------------
161
162%ifdef MODULE_8BIT_IDE
163;--------------------------------------------------------------------
[473]164; IdePioBlock_WriteToXtideRev1
165; Parameters:
[558]166; CX: Block size in 512-byte sectors
167; DX: IDE Data port address
[589]168; DS:SI: Normalized ptr to buffer containing data
[473]169; Returns:
170; Nothing
171; Corrupts registers:
[580]172; AX, BX, CX
[473]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:
[558]190; CX: Block size in 512-byte sectors
191; DX: IDE Data port address
[589]192; DS:SI: Normalized ptr to buffer containing data
[473]193; Returns:
194; Nothing
195; Corrupts registers:
[589]196; AX, CX
[473]197;--------------------------------------------------------------------
198ALIGN JUMP_ALIGN
199IdePioBlock_WriteToXtideRev2:
200 UNROLL_SECTORS_IN_CX_TO_QWORDS
201ALIGN JUMP_ALIGN
202.WriteNextQword:
203 %rep 4 ; WORDs
[580]204 XTIDE_MOD_OUTSW
[473]205 %endrep
206 loop .WriteNextQword
207 ret
208
209
210;--------------------------------------------------------------------
[545]211; IdePioBlock_WriteTo8bitDataPort
[473]212; Parameters:
[558]213; CX: Block size in 512-byte sectors
214; DX: IDE Data port address
[589]215; DS:SI: Normalized ptr to buffer containing data
[473]216; Returns:
217; Nothing
218; Corrupts registers:
[589]219; AX, CX
[473]220;--------------------------------------------------------------------
221ALIGN JUMP_ALIGN
222IdePioBlock_WriteTo8bitDataPort:
223%ifdef USE_186
224 shl cx, 9 ; Sectors to BYTEs
225 rep outsb
226 ret
227
[580]228%else ; 808x
[545]229 UNROLL_SECTORS_IN_CX_TO_QWORDS
[473]230ALIGN JUMP_ALIGN
[545]231.WriteNextQword:
232 %rep 8 ; BYTEs
233 lodsb ; Load BYTE from [DS:SI]
[580]234 out dx, al ; Write BYTE
[473]235 %endrep
[545]236 loop .WriteNextQword
[473]237 ret
238%endif
239%endif ; MODULE_8BIT_IDE
240
241
242;--------------------------------------------------------------------
[545]243; IdePioBlock_WriteTo16bitDataPort Normal 16-bit IDE, XT-CFv3 in BIU Mode
[473]244; IdePioBlock_WriteTo32bitDataPort VLB/PCI 32-bit IDE
245; Parameters:
[558]246; CX: Block size in 512-byte sectors
247; DX: IDE Data port address
[589]248; DS:SI: Normalized ptr to buffer containing data
[473]249; Returns:
250; Nothing
251; Corrupts registers:
[589]252; AX, CX
[473]253;--------------------------------------------------------------------
254ALIGN JUMP_ALIGN
255IdePioBlock_WriteTo16bitDataPort:
[545]256%ifdef USE_186
[473]257 xchg cl, ch ; Sectors to WORDs
[545]258 rep outsw
[473]259 ret
260
[580]261%else ; 808x
[545]262 UNROLL_SECTORS_IN_CX_TO_QWORDS
263ALIGN JUMP_ALIGN
264.WriteNextQword:
265 %rep 4 ; WORDs
[558]266 lodsw ; Load WORD from [DS:SI]
[580]267 out dx, ax ; Write WORD
[545]268 %endrep
269 loop .WriteNextQword
270 ret
[580]271%endif
[545]272
[473]273;--------------------------------------------------------------------
[589]274%ifdef MODULE_ADVANCED_ATA
[473]275ALIGN JUMP_ALIGN
276IdePioBlock_WriteTo32bitDataPort:
[589]277 shl cx, 7 ; Sectors to DWORDs
278 rep outsd
[473]279 ret
[589]280%endif ; MODULE_ADVANCED_ATA
Note: See TracBrowser for help on using the repository browser.