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

Last change on this file since 569 was 567, checked in by krille_n_@…, 10 years ago

Changes:

  • Renamed MODULE_FEATURE_SETS to MODULE_POWER_MANAGEMENT.
  • Renamed MODULE_VERY_LATE_INITIALIZATION to MODULE_VERY_LATE_INIT and removed it from the official builds.
  • Removed the code that skips detection of slave drives on XT-CF controllers since slave drives can be used with Lo-tech ISA CompactFlash boards.
  • Added autodetection of the SVC ADP50L controller to XTIDECFG.
  • The autodetection of XT-CF controllers now requires MODULE_8BIT_IDE_ADVANCED in the loaded BIOS.
  • Fixed a bug in XTIDECFG from r502 where the "Base (cmd block) address" menu option would be displayed when a serial device was selected as the IDE controller.
  • XTIDECFG would display the "Enable interrupt" menu option for the XTIDE r1 but not for the XTIDE r2. It's now displayed for both controller types.
  • Disabled the "Internal Write Cache" menu option in the Master/Slave Drive menus for serial device type drives.
  • Optimizations and other fixes.
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
31
[473]32%ifdef MODULE_8BIT_IDE
33
34;--------------------------------------------------------------------
35; IdePioBlock_ReadFromXtideRev1
36; Parameters:
37; CX: Block size in 512 byte sectors
38; DX: IDE Data port address
39; ES:DI: Normalized ptr to buffer to receive data
40; Returns:
41; Nothing
42; Corrupts registers:
43; AX, BX, CX
44;--------------------------------------------------------------------
45ALIGN JUMP_ALIGN
46IdePioBlock_ReadFromXtideRev1:
47 UNROLL_SECTORS_IN_CX_TO_OWORDS
48 mov bl, 8 ; Bit mask for toggling data low/high reg
49ALIGN JUMP_ALIGN
50.InswLoop:
51 %rep 8 ; WORDs
52 XTIDE_INSW
53 %endrep
54 loop .InswLoop
55 ret
56
57
58;--------------------------------------------------------------------
[545]59; IdePioBlock_ReadFrom8bitDataPort
60;
61; 8-bit PIO from a single data port.
62;
[473]63; Parameters:
[558]64; CX: Block size in 512 byte sectors
65; DX: IDE Data port address
[473]66; ES:DI: Normalized ptr to buffer to receive data
67; Returns:
68; Nothing
69; Corrupts registers:
70; AX, BX, CX
71;--------------------------------------------------------------------
72ALIGN JUMP_ALIGN
[545]73IdePioBlock_ReadFrom8bitDataPort:
74%ifdef USE_186
75 shl cx, 9 ; Sectors to BYTEs
76 rep insb
77 ret
78%else ; If 8088/8086
[473]79 UNROLL_SECTORS_IN_CX_TO_OWORDS
80ALIGN JUMP_ALIGN
81.ReadNextOword:
[545]82 %rep 16 ; BYTEs
83 in al, dx ; Read BYTE
84 stosb ; Store BYTE to [ES:DI]
[473]85 %endrep
[545]86 loop .ReadNextOword
87 ret
[473]88%endif
89
[545]90%endif ; MODULE_8BIT_IDE
[473]91
[545]92
[473]93;--------------------------------------------------------------------
[545]94; IdePioBlock_ReadFrom16bitDataPort
95;
96; 16-bit PIO from a single data port.
97;
[473]98; Parameters:
[558]99; CX: Block size in 512 byte sectors
100; DX: IDE Data port address
[473]101; ES:DI: Normalized ptr to buffer to receive data
102; Returns:
103; Nothing
104; Corrupts registers:
105; AX, BX, CX
106;--------------------------------------------------------------------
107ALIGN JUMP_ALIGN
[545]108IdePioBlock_ReadFrom16bitDataPort:
[473]109%ifdef USE_186
[558]110 xchg cl, ch ; Sectors to WORDs
[545]111 rep insw
[473]112 ret
113
114%else ; If 8088/8086
115 UNROLL_SECTORS_IN_CX_TO_OWORDS
116ALIGN JUMP_ALIGN
117.ReadNextOword:
[545]118 %rep 8 ; WORDs
[558]119 in ax, dx ; Read WORD
120 stosw ; Store WORD to [ES:DI]
[473]121 %endrep
122 loop .ReadNextOword
123 ret
124%endif
125
126
127;--------------------------------------------------------------------
[545]128ALIGN JUMP_ALIGN
129IdePioBlock_ReadFrom32bitDataPort:
130 db 0C1h ; SHL
131 db 0E1h ; CX
132 db 7 ; 7 (Sectors to DWORDs)
133 rep
134 db 66h ; Override operand size to 32-bit
135 db 6Dh ; INSW/INSD
136 ret
137
138
139
140; --------------------------------------------------------------------------------------------------
141;
142; WRITE routines follow
143;
144; --------------------------------------------------------------------------------------------------
145
146%ifdef MODULE_8BIT_IDE
147
148;--------------------------------------------------------------------
[473]149; IdePioBlock_WriteToXtideRev1
150; Parameters:
[558]151; CX: Block size in 512-byte sectors
152; DX: IDE Data port address
[473]153; ES:SI: Normalized ptr to buffer containing data
154; Returns:
155; Nothing
156; Corrupts registers:
157; AX, BX, CX, DX
158;--------------------------------------------------------------------
159ALIGN JUMP_ALIGN
160IdePioBlock_WriteToXtideRev1:
161 push ds
162 UNROLL_SECTORS_IN_CX_TO_QWORDS
163 mov bl, 8 ; Bit mask for toggling data low/high reg
164 push es ; Copy ES...
165 pop ds ; ...to DS
166ALIGN JUMP_ALIGN
167.OutswLoop:
168 %rep 4 ; WORDs
169 XTIDE_OUTSW
170 %endrep
171 loop .OutswLoop
172 pop ds
173 ret
174
175
176;--------------------------------------------------------------------
177; IdePioBlock_WriteToXtideRev2 or rev 1 with swapped A0 and A3 (chuck-mod)
178; Parameters:
[558]179; CX: Block size in 512-byte sectors
180; DX: IDE Data port address
[473]181; ES:SI: Normalized ptr to buffer containing data
182; Returns:
183; Nothing
184; Corrupts registers:
185; AX, BX, CX, DX
186;--------------------------------------------------------------------
187ALIGN JUMP_ALIGN
188IdePioBlock_WriteToXtideRev2:
189 UNROLL_SECTORS_IN_CX_TO_QWORDS
[558]190 push ds
191 push es ; Copy ES...
192 pop ds ; ...to DS
[473]193ALIGN JUMP_ALIGN
194.WriteNextQword:
195 %rep 4 ; WORDs
[545]196 XTIDE_MOD_OUTSW ; special macro
[473]197 %endrep
198 loop .WriteNextQword
199 pop ds
200 ret
201
202
203;--------------------------------------------------------------------
[545]204; IdePioBlock_WriteTo8bitDataPort
[473]205; Parameters:
[558]206; CX: Block size in 512-byte sectors
207; DX: IDE Data port address
[473]208; ES:SI: Normalized ptr to buffer containing data
209; Returns:
210; Nothing
211; Corrupts registers:
212; AX, BX, CX, DX
213;--------------------------------------------------------------------
214ALIGN JUMP_ALIGN
215IdePioBlock_WriteTo8bitDataPort:
216%ifdef USE_186
217 shl cx, 9 ; Sectors to BYTEs
218 es ; Source is ES segment
219 rep outsb
220 ret
221
222%else ; If 8088/8086
[545]223 UNROLL_SECTORS_IN_CX_TO_QWORDS
[558]224 push ds
225 ;mov ax, es
226 ;mov ds, ax ; move es to ds via ax (does this run faster on 8088?)
227 push es
228 pop ds
[473]229ALIGN JUMP_ALIGN
[545]230.WriteNextQword:
231 %rep 8 ; BYTEs
232 lodsb ; Load BYTE from [DS:SI]
233 out dx, al ; Write BYTE
[473]234 %endrep
[545]235 loop .WriteNextQword
[473]236 pop ds
237 ret
238%endif
239
240%endif ; MODULE_8BIT_IDE
241
242
243;--------------------------------------------------------------------
[545]244; IdePioBlock_WriteTo16bitDataPort Normal 16-bit IDE, XT-CFv3 in BIU Mode
[473]245; IdePioBlock_WriteTo32bitDataPort VLB/PCI 32-bit IDE
246; Parameters:
[558]247; CX: Block size in 512-byte sectors
248; DX: IDE Data port address
[473]249; ES:SI: Normalized ptr to buffer containing data
250; Returns:
251; Nothing
252; Corrupts registers:
253; AX, BX, CX, DX
254;--------------------------------------------------------------------
255ALIGN JUMP_ALIGN
256IdePioBlock_WriteTo16bitDataPort:
[545]257%ifdef USE_186
[473]258 xchg cl, ch ; Sectors to WORDs
259 es ; Source is ES segment
[545]260 rep outsw
[473]261 ret
262
[545]263%else ; If 8088/8086
264 UNROLL_SECTORS_IN_CX_TO_QWORDS
265 push ds
266 ;mov ax, es
267 ;mov ds, ax ; move es to ds via ax (does this run faster on 8088?)
268 push es
269 pop ds
270ALIGN JUMP_ALIGN
271.WriteNextQword:
272 %rep 4 ; WORDs
[558]273 lodsw ; Load WORD from [DS:SI]
274 out dx, ax ; Write WORD
[545]275 %endrep
276 loop .WriteNextQword
277 pop ds
278 ret
279%endif ; if/else USE_186
280
[473]281;--------------------------------------------------------------------
282ALIGN JUMP_ALIGN
283IdePioBlock_WriteTo32bitDataPort:
[480]284 db 0C1h ; SHL
285 db 0E1h ; CX
286 db 7 ; 7 (Sectors to DWORDs)
[473]287 es ; Source is ES segment
288 rep
289 db 66h ; Override operand size to 32-bit
290 db 6Fh ; OUTSW/OUTSD
291 ret
Note: See TracBrowser for help on using the repository browser.