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

Last change on this file since 599 was 589, checked in by Krister Nordvall, 9 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
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;--------------------------------------------------------------------
[545]57; 8-bit PIO from a single data port.
58;
[589]59; IdePioBlock_ReadFrom8bitDataPort
[473]60; Parameters:
[558]61; CX: Block size in 512 byte sectors
62; DX: IDE Data port address
[473]63; ES:DI: Normalized ptr to buffer to receive data
64; Returns:
65; Nothing
66; Corrupts registers:
[589]67; AX, CX
[473]68;--------------------------------------------------------------------
69ALIGN JUMP_ALIGN
[545]70IdePioBlock_ReadFrom8bitDataPort:
71%ifdef USE_186
72 shl cx, 9 ; Sectors to BYTEs
73 rep insb
74 ret
[580]75%else ; 808x
[473]76 UNROLL_SECTORS_IN_CX_TO_OWORDS
77ALIGN JUMP_ALIGN
78.ReadNextOword:
[545]79 %rep 16 ; BYTEs
80 in al, dx ; Read BYTE
81 stosb ; Store BYTE to [ES:DI]
[473]82 %endrep
[545]83 loop .ReadNextOword
84 ret
[473]85%endif
[589]86%endif ; MODULE_8BIT_IDE
[473]87
88
89;--------------------------------------------------------------------
[589]90; 16-bit and 32-bit PIO from a single data port.
91;
[545]92; IdePioBlock_ReadFrom16bitDataPort
[589]93; IdePioBlock_ReadFrom32bitDataPort
[473]94; Parameters:
[558]95; CX: Block size in 512 byte sectors
96; DX: IDE Data port address
[473]97; ES:DI: Normalized ptr to buffer to receive data
98; Returns:
99; Nothing
100; Corrupts registers:
[589]101; AX, CX
[473]102;--------------------------------------------------------------------
103ALIGN JUMP_ALIGN
[545]104IdePioBlock_ReadFrom16bitDataPort:
[473]105%ifdef USE_186
[589]106 xchg cl, ch ; Sectors to WORDs
[545]107 rep insw
[473]108 ret
109
[580]110%else ; 808x
[473]111 UNROLL_SECTORS_IN_CX_TO_OWORDS
112ALIGN JUMP_ALIGN
113.ReadNextOword:
[545]114 %rep 8 ; WORDs
[558]115 in ax, dx ; Read WORD
116 stosw ; Store WORD to [ES:DI]
[473]117 %endrep
118 loop .ReadNextOword
119 ret
120%endif
121
122
123;--------------------------------------------------------------------
[589]124%ifdef MODULE_ADVANCED_ATA
[545]125ALIGN JUMP_ALIGN
126IdePioBlock_ReadFrom32bitDataPort:
[589]127 shl cx, 7 ; Sectors to DWORDs
128 rep insd
[545]129 ret
[589]130%endif ; MODULE_ADVANCED_ATA
[545]131
132
133; --------------------------------------------------------------------------------------------------
134;
135; WRITE routines follow
136;
137; --------------------------------------------------------------------------------------------------
138
139%ifdef MODULE_8BIT_IDE
140;--------------------------------------------------------------------
[473]141; IdePioBlock_WriteToXtideRev1
142; Parameters:
[558]143; CX: Block size in 512-byte sectors
144; DX: IDE Data port address
[589]145; DS:SI: Normalized ptr to buffer containing data
[473]146; Returns:
147; Nothing
148; Corrupts registers:
[580]149; AX, BX, CX
[473]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:
[558]167; CX: Block size in 512-byte sectors
168; DX: IDE Data port address
[589]169; DS:SI: Normalized ptr to buffer containing data
[473]170; Returns:
171; Nothing
172; Corrupts registers:
[589]173; AX, CX
[473]174;--------------------------------------------------------------------
175ALIGN JUMP_ALIGN
176IdePioBlock_WriteToXtideRev2:
177 UNROLL_SECTORS_IN_CX_TO_QWORDS
178ALIGN JUMP_ALIGN
179.WriteNextQword:
180 %rep 4 ; WORDs
[580]181 XTIDE_MOD_OUTSW
[473]182 %endrep
183 loop .WriteNextQword
184 ret
185
186
187;--------------------------------------------------------------------
[545]188; IdePioBlock_WriteTo8bitDataPort
[473]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_WriteTo8bitDataPort:
200%ifdef USE_186
201 shl cx, 9 ; Sectors to BYTEs
202 rep outsb
203 ret
204
[580]205%else ; 808x
[545]206 UNROLL_SECTORS_IN_CX_TO_QWORDS
[473]207ALIGN JUMP_ALIGN
[545]208.WriteNextQword:
209 %rep 8 ; BYTEs
210 lodsb ; Load BYTE from [DS:SI]
[580]211 out dx, al ; Write BYTE
[473]212 %endrep
[545]213 loop .WriteNextQword
[473]214 ret
215%endif
216%endif ; MODULE_8BIT_IDE
217
218
219;--------------------------------------------------------------------
[545]220; IdePioBlock_WriteTo16bitDataPort Normal 16-bit IDE, XT-CFv3 in BIU Mode
[473]221; IdePioBlock_WriteTo32bitDataPort VLB/PCI 32-bit IDE
222; Parameters:
[558]223; CX: Block size in 512-byte sectors
224; DX: IDE Data port address
[589]225; DS:SI: Normalized ptr to buffer containing data
[473]226; Returns:
227; Nothing
228; Corrupts registers:
[589]229; AX, CX
[473]230;--------------------------------------------------------------------
231ALIGN JUMP_ALIGN
232IdePioBlock_WriteTo16bitDataPort:
[545]233%ifdef USE_186
[473]234 xchg cl, ch ; Sectors to WORDs
[545]235 rep outsw
[473]236 ret
237
[580]238%else ; 808x
[545]239 UNROLL_SECTORS_IN_CX_TO_QWORDS
240ALIGN JUMP_ALIGN
241.WriteNextQword:
242 %rep 4 ; WORDs
[558]243 lodsw ; Load WORD from [DS:SI]
[580]244 out dx, ax ; Write WORD
[545]245 %endrep
246 loop .WriteNextQword
247 ret
[580]248%endif
[545]249
[473]250;--------------------------------------------------------------------
[589]251%ifdef MODULE_ADVANCED_ATA
[473]252ALIGN JUMP_ALIGN
253IdePioBlock_WriteTo32bitDataPort:
[589]254 shl cx, 7 ; Sectors to DWORDs
255 rep outsd
[473]256 ret
[589]257%endif ; MODULE_ADVANCED_ATA
Note: See TracBrowser for help on using the repository browser.