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

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

Changes:

  • XTIDECFG: Fixed a bug from r459 where the menu option for selection of default boot drive would be missing if the BIOS had been built without MODULE_HOTKEYS. The menu option is now visible if either or both of MODULE_HOTKEYS and MODULE_BOOT_MENU is available.
  • BIOS: Disabled ATA-ID validation by adding a new define (NO_ATAID_VALIDATION) and making it the default for all builds since at least two WD Caviar drive models are incompatible with it.
  • Fixed the "No Fixed Disk Present in FDISK"-bug introduced in r551 which means the Tiny build now works without including MODULE_DRIVEXLATE.
  • Fixed a bug from r528 where pressing hotkey F6 would not initiate detection of serial drives.
  • Fixed a bug from r186 in DisplayFormatCompressed.asm where the boot menu would print the IRQ in hexadecimal format when it should be in decimal format.
  • Optimizations and fixes.
File size: 7.0 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
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;--------------------------------------------------------------------
59; IdePioBlock_ReadFrom8bitDataPort
60;
61; 8-bit PIO from a single data port.
62;
63; Parameters:
64; CX: Block size in 512 byte sectors
65; DX: IDE Data port address
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
73IdePioBlock_ReadFrom8bitDataPort:
74%ifdef USE_186
75 shl cx, 9 ; Sectors to BYTEs
76 rep insb
77 ret
78%else ; 808x
79 UNROLL_SECTORS_IN_CX_TO_OWORDS
80ALIGN JUMP_ALIGN
81.ReadNextOword:
82 %rep 16 ; BYTEs
83 in al, dx ; Read BYTE
84 stosb ; Store BYTE to [ES:DI]
85 %endrep
86 loop .ReadNextOword
87 ret
88%endif
89
90%endif ; MODULE_8BIT_IDE
91
92
93;--------------------------------------------------------------------
94; IdePioBlock_ReadFrom16bitDataPort
95;
96; 16-bit PIO from a single data port.
97;
98; Parameters:
99; CX: Block size in 512 byte sectors
100; DX: IDE Data port address
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
108IdePioBlock_ReadFrom16bitDataPort:
109%ifdef USE_186
110 xchg cl, ch ; Sectors to WORDs
111 rep insw
112 ret
113
114%else ; 808x
115 UNROLL_SECTORS_IN_CX_TO_OWORDS
116ALIGN JUMP_ALIGN
117.ReadNextOword:
118 %rep 8 ; WORDs
119 in ax, dx ; Read WORD
120 stosw ; Store WORD to [ES:DI]
121 %endrep
122 loop .ReadNextOword
123 ret
124%endif
125
126
127;--------------------------------------------------------------------
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;--------------------------------------------------------------------
149; IdePioBlock_WriteToXtideRev1
150; Parameters:
151; CX: Block size in 512-byte sectors
152; DX: IDE Data port address
153; ES:SI: Normalized ptr to buffer containing data
154; Returns:
155; Nothing
156; Corrupts registers:
157; AX, BX, CX
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
165 pop 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:
179; CX: Block size in 512-byte sectors
180; DX: IDE Data port address
181; ES:SI: Normalized ptr to buffer containing data
182; Returns:
183; Nothing
184; Corrupts registers:
185; AX, BX, CX
186;--------------------------------------------------------------------
187ALIGN JUMP_ALIGN
188IdePioBlock_WriteToXtideRev2:
189 UNROLL_SECTORS_IN_CX_TO_QWORDS
190 push ds
191 push es
192 pop ds
193ALIGN JUMP_ALIGN
194.WriteNextQword:
195 %rep 4 ; WORDs
196 XTIDE_MOD_OUTSW
197 %endrep
198 loop .WriteNextQword
199 pop ds
200 ret
201
202
203;--------------------------------------------------------------------
204; IdePioBlock_WriteTo8bitDataPort
205; Parameters:
206; CX: Block size in 512-byte sectors
207; DX: IDE Data port address
208; ES:SI: Normalized ptr to buffer containing data
209; Returns:
210; Nothing
211; Corrupts registers:
212; AX, BX, CX
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 ; 808x
223 UNROLL_SECTORS_IN_CX_TO_QWORDS
224 push ds
225 push es
226 pop ds
227ALIGN JUMP_ALIGN
228.WriteNextQword:
229 %rep 8 ; BYTEs
230 lodsb ; Load BYTE from [DS:SI]
231 out dx, al ; Write BYTE
232 %endrep
233 loop .WriteNextQword
234 pop ds
235 ret
236%endif
237
238%endif ; MODULE_8BIT_IDE
239
240
241;--------------------------------------------------------------------
242; IdePioBlock_WriteTo16bitDataPort Normal 16-bit IDE, XT-CFv3 in BIU Mode
243; IdePioBlock_WriteTo32bitDataPort VLB/PCI 32-bit IDE
244; Parameters:
245; CX: Block size in 512-byte sectors
246; DX: IDE Data port address
247; ES:SI: Normalized ptr to buffer containing data
248; Returns:
249; Nothing
250; Corrupts registers:
251; AX, BX, CX
252;--------------------------------------------------------------------
253ALIGN JUMP_ALIGN
254IdePioBlock_WriteTo16bitDataPort:
255%ifdef USE_186
256 xchg cl, ch ; Sectors to WORDs
257 es ; Source is ES segment
258 rep outsw
259 ret
260
261%else ; 808x
262 UNROLL_SECTORS_IN_CX_TO_QWORDS
263 push ds
264 push es
265 pop ds
266ALIGN JUMP_ALIGN
267.WriteNextQword:
268 %rep 4 ; WORDs
269 lodsw ; Load WORD from [DS:SI]
270 out dx, ax ; Write WORD
271 %endrep
272 loop .WriteNextQword
273 pop ds
274 ret
275%endif
276
277;--------------------------------------------------------------------
278ALIGN JUMP_ALIGN
279IdePioBlock_WriteTo32bitDataPort:
280 db 0C1h ; SHL
281 db 0E1h ; CX
282 db 7 ; 7 (Sectors to DWORDs)
283 es ; Source is ES segment
284 rep
285 db 66h ; Override operand size to 32-bit
286 db 6Fh ; OUTSW/OUTSD
287 ret
Note: See TracBrowser for help on using the repository browser.