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

Last change on this file since 582 was 580, checked in by krille_n_@…, 9 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
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:
[580]51 %rep 8 ; WORDs
[473]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
[580]78%else ; 808x
[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
[580]114%else ; 808x
[473]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
[580]132 db 7 ; 7 (Sectors to DWORDs)
[545]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:
[580]157; AX, BX, CX
[473]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
[580]164 push es
165 pop ds
[473]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:
[580]185; AX, BX, CX
[473]186;--------------------------------------------------------------------
187ALIGN JUMP_ALIGN
188IdePioBlock_WriteToXtideRev2:
189 UNROLL_SECTORS_IN_CX_TO_QWORDS
[558]190 push ds
[580]191 push es
192 pop ds
[473]193ALIGN JUMP_ALIGN
194.WriteNextQword:
195 %rep 4 ; WORDs
[580]196 XTIDE_MOD_OUTSW
[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:
[580]212; AX, BX, CX
[473]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
[580]222%else ; 808x
[545]223 UNROLL_SECTORS_IN_CX_TO_QWORDS
[558]224 push ds
225 push es
226 pop ds
[473]227ALIGN JUMP_ALIGN
[545]228.WriteNextQword:
229 %rep 8 ; BYTEs
230 lodsb ; Load BYTE from [DS:SI]
[580]231 out dx, al ; Write BYTE
[473]232 %endrep
[545]233 loop .WriteNextQword
[473]234 pop ds
235 ret
236%endif
237
238%endif ; MODULE_8BIT_IDE
239
240
241;--------------------------------------------------------------------
[545]242; IdePioBlock_WriteTo16bitDataPort Normal 16-bit IDE, XT-CFv3 in BIU Mode
[473]243; IdePioBlock_WriteTo32bitDataPort VLB/PCI 32-bit IDE
244; Parameters:
[558]245; CX: Block size in 512-byte sectors
246; DX: IDE Data port address
[473]247; ES:SI: Normalized ptr to buffer containing data
248; Returns:
249; Nothing
250; Corrupts registers:
[580]251; AX, BX, CX
[473]252;--------------------------------------------------------------------
253ALIGN JUMP_ALIGN
254IdePioBlock_WriteTo16bitDataPort:
[545]255%ifdef USE_186
[473]256 xchg cl, ch ; Sectors to WORDs
257 es ; Source is ES segment
[545]258 rep outsw
[473]259 ret
260
[580]261%else ; 808x
[545]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
[558]269 lodsw ; Load WORD from [DS:SI]
[580]270 out dx, ax ; Write WORD
[545]271 %endrep
272 loop .WriteNextQword
273 pop ds
274 ret
[580]275%endif
[545]276
[473]277;--------------------------------------------------------------------
278ALIGN JUMP_ALIGN
279IdePioBlock_WriteTo32bitDataPort:
[480]280 db 0C1h ; SHL
281 db 0E1h ; CX
[580]282 db 7 ; 7 (Sectors to DWORDs)
[473]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.