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

Last change on this file since 589 was 589, checked in by krille_n_, 8 years ago

Changes:

  • BIOS: Fixed a purely cosmetic bug from r542 where, in builds containing MODULE_EBIOS, the boot menu would display an incorrect drive size (0.4 kB with MODULE_STRINGS_COMPRESSED or 0.5 kB without) for old drives with no support for LBA.
  • Fixed a bug from r392 where Vision_DetectAndReturnIDinAXandPortInDXifControllerPresent would return the ID in AL instead of AH (if DANGEROUS_DETECTION had been defined).
  • Fixed a bug from r587 in AdvAtaInit.asm that would prevent detection of QDI Vision controllers.
  • Also changed how the QDI Vision IDs are defined (removed the need for shifting) to avoid confusion. This fixed a potential bug from r587 in AdvAtaInit.asm where some IDs were not being shifted.
  • Fixed a bug in PDC20x30.asm from r587 where GetPdcIDtoAX would not return with the IDE base port in DX so DisablePdcProgrammingMode would fail.
  • Made some changes to ModuleDependency.inc and other files so that MODULE_ADVANCED_ATA now requires USE_386. Consequently it is no longer included in the regular AT-builds, only in the 386_8k-build.
  • Moved the UNROLL_SECTORS_IN_CX_TO_xWORDS macros from IDE_8bit.inc to IdeIO.inc which means it's now possible to build a BIOS without MODULE_8BIT_IDE.
  • XTIDECFG: Added a minimum DOS version check (since it needs DOS version 2+) to allow the program to quit gracefully in the unlikely scenario where someone tries to run it under DOS version 1.
  • Made some changes to Drive.asm to improve drive enumeration. The old method using GET_DOS_DRIVE_PARAMETER_BLOCK_FOR_SPECIFIC_DRIVE worked well in Windows XP but not in Windows 98 SE (in Windows or in DOS mode). The two problems were; 1) The function call would access the drives which on single floppy drive systems would cause Windows to swap between A: and B: (throwing a blue screen asking the user to insert a disk etc). 2) Only floppy drives and FAT16 drives would be available in the list of drives, no FAT32/optical/network drives.
  • Improved code in IdeControllerMenu.asm so that the default port addresses for all IDE interfaces are now restored when (re-)selecting the (same) type of IDE device.
  • Also made it impossible to select a device type unless the required module is included in the loaded BIOS.
  • The version check done when loading a BIOS now uses the FLASH_SIGNATURE definition from Version.inc. Any changes affecting RomVars now only requires updating that definition. This means that changes to RomVars must be implemented in both the BIOS and XTIDECFG before being committed to the repository.
  • Added a compatibility fix for 3Com 3C503 cards to the ROM checksumming code in Buffers.asm (Buffers_GenerateChecksum).
  • SerDrive: Made some minor changes to file names and paths to improve compatibility with case sensitive environments.
  • BIOSDRVS: Made a minor size optimization which as a side effect also makes it compatible with all DOS versions including DOS version 1.
  • Library: Renamed the WAIT_RETRACE_IF_NECESSARY_THEN macro to CALL_WAIT_FOR_RETRACE_IF_NECESSARY_THEN and made a tail-call-optimized version of it (JMP_WAIT_FOR_RETRACE_IF_NECESSARY_THEN).
  • A speed optimization to the eRCL_IM macro for 386 and higher. This change breaks emulation in the sense that the macro will fail when given a memory operand as the first parameter.
  • Other minor optimizations and fixes.
File size: 6.7 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%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:
49    %rep 8  ; WORDs
50        XTIDE_INSW
51    %endrep
52    loop    .InswLoop
53    ret
54
55
56;--------------------------------------------------------------------
57; 8-bit PIO from a single data port.
58;
59; IdePioBlock_ReadFrom8bitDataPort
60;   Parameters:
61;       CX:     Block size in 512 byte sectors
62;       DX:     IDE Data port address
63;       ES:DI:  Normalized ptr to buffer to receive data
64;   Returns:
65;       Nothing
66;   Corrupts registers:
67;       AX, CX
68;--------------------------------------------------------------------
69ALIGN JUMP_ALIGN
70IdePioBlock_ReadFrom8bitDataPort:
71%ifdef USE_186
72    shl     cx, 9       ; Sectors to BYTEs
73    rep insb
74    ret
75%else ; 808x
76    UNROLL_SECTORS_IN_CX_TO_OWORDS
77ALIGN JUMP_ALIGN
78.ReadNextOword:
79    %rep 16 ; BYTEs
80        in      al, dx  ; Read BYTE
81        stosb           ; Store BYTE to [ES:DI]
82    %endrep
83    loop    .ReadNextOword
84    ret
85%endif
86%endif ; MODULE_8BIT_IDE
87
88
89;--------------------------------------------------------------------
90; 16-bit and 32-bit PIO from a single data port.
91;
92; IdePioBlock_ReadFrom16bitDataPort
93; IdePioBlock_ReadFrom32bitDataPort
94;   Parameters:
95;       CX:     Block size in 512 byte sectors
96;       DX:     IDE Data port address
97;       ES:DI:  Normalized ptr to buffer to receive data
98;   Returns:
99;       Nothing
100;   Corrupts registers:
101;       AX, CX
102;--------------------------------------------------------------------
103ALIGN JUMP_ALIGN
104IdePioBlock_ReadFrom16bitDataPort:
105%ifdef USE_186
106    xchg    cl, ch      ; Sectors to WORDs
107    rep insw
108    ret
109
110%else ; 808x
111    UNROLL_SECTORS_IN_CX_TO_OWORDS
112ALIGN JUMP_ALIGN
113.ReadNextOword:
114    %rep 8  ; WORDs
115        in      ax, dx  ; Read WORD
116        stosw           ; Store WORD to [ES:DI]
117    %endrep
118    loop    .ReadNextOword
119    ret
120%endif
121
122
123;--------------------------------------------------------------------
124%ifdef MODULE_ADVANCED_ATA
125ALIGN JUMP_ALIGN
126IdePioBlock_ReadFrom32bitDataPort:
127    shl     cx, 7       ; Sectors to DWORDs
128    rep insd
129    ret
130%endif ; MODULE_ADVANCED_ATA
131
132
133; --------------------------------------------------------------------------------------------------
134;
135; WRITE routines follow
136;
137; --------------------------------------------------------------------------------------------------
138
139%ifdef MODULE_8BIT_IDE
140;--------------------------------------------------------------------
141; IdePioBlock_WriteToXtideRev1
142;   Parameters:
143;       CX:     Block size in 512-byte sectors
144;       DX:     IDE Data port address
145;       DS:SI:  Normalized ptr to buffer containing data
146;   Returns:
147;       Nothing
148;   Corrupts registers:
149;       AX, BX, CX
150;--------------------------------------------------------------------
151ALIGN JUMP_ALIGN
152IdePioBlock_WriteToXtideRev1:
153    UNROLL_SECTORS_IN_CX_TO_QWORDS
154    mov     bl, 8       ; Bit mask for toggling data low/high reg
155ALIGN JUMP_ALIGN
156.OutswLoop:
157    %rep 4  ; WORDs
158        XTIDE_OUTSW
159    %endrep
160    loop    .OutswLoop
161    ret
162
163
164;--------------------------------------------------------------------
165; IdePioBlock_WriteToXtideRev2  or rev 1 with swapped A0 and A3 (chuck-mod)
166;   Parameters:
167;       CX:     Block size in 512-byte sectors
168;       DX:     IDE Data port address
169;       DS:SI:  Normalized ptr to buffer containing data
170;   Returns:
171;       Nothing
172;   Corrupts registers:
173;       AX, CX
174;--------------------------------------------------------------------
175ALIGN JUMP_ALIGN
176IdePioBlock_WriteToXtideRev2:
177    UNROLL_SECTORS_IN_CX_TO_QWORDS
178ALIGN JUMP_ALIGN
179.WriteNextQword:
180    %rep 4  ; WORDs
181        XTIDE_MOD_OUTSW
182    %endrep
183    loop    .WriteNextQword
184    ret
185
186
187;--------------------------------------------------------------------
188; IdePioBlock_WriteTo8bitDataPort
189;   Parameters:
190;       CX:     Block size in 512-byte sectors
191;       DX:     IDE Data port address
192;       DS:SI:  Normalized ptr to buffer containing data
193;   Returns:
194;       Nothing
195;   Corrupts registers:
196;       AX, CX
197;--------------------------------------------------------------------
198ALIGN JUMP_ALIGN
199IdePioBlock_WriteTo8bitDataPort:
200%ifdef USE_186
201    shl     cx, 9       ; Sectors to BYTEs
202    rep outsb
203    ret
204
205%else ; 808x
206    UNROLL_SECTORS_IN_CX_TO_QWORDS
207ALIGN JUMP_ALIGN
208.WriteNextQword:
209    %rep 8  ; BYTEs
210        lodsb           ; Load BYTE from [DS:SI]
211        out     dx, al  ; Write BYTE
212    %endrep
213    loop    .WriteNextQword
214    ret
215%endif
216%endif ; MODULE_8BIT_IDE
217
218
219;--------------------------------------------------------------------
220; IdePioBlock_WriteTo16bitDataPort      Normal 16-bit IDE, XT-CFv3 in BIU Mode
221; IdePioBlock_WriteTo32bitDataPort      VLB/PCI 32-bit IDE
222;   Parameters:
223;       CX:     Block size in 512-byte sectors
224;       DX:     IDE Data port address
225;       DS:SI:  Normalized ptr to buffer containing data
226;   Returns:
227;       Nothing
228;   Corrupts registers:
229;       AX, CX
230;--------------------------------------------------------------------
231ALIGN JUMP_ALIGN
232IdePioBlock_WriteTo16bitDataPort:
233%ifdef USE_186
234    xchg    cl, ch      ; Sectors to WORDs
235    rep outsw
236    ret
237
238%else ; 808x
239    UNROLL_SECTORS_IN_CX_TO_QWORDS
240ALIGN JUMP_ALIGN
241.WriteNextQword:
242    %rep 4  ; WORDs
243        lodsw           ; Load WORD from [DS:SI]
244        out     dx, ax  ; Write WORD
245    %endrep
246    loop    .WriteNextQword
247    ret
248%endif
249
250;--------------------------------------------------------------------
251%ifdef MODULE_ADVANCED_ATA
252ALIGN JUMP_ALIGN
253IdePioBlock_WriteTo32bitDataPort:
254    shl     cx, 7       ; Sectors to DWORDs
255    rep outsd
256    ret
257%endif ; MODULE_ADVANCED_ATA
Note: See TracBrowser for help on using the repository browser.