]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.h
IntelFrameworkModulePkg IdeBusDxe: Remove redundant functions
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Pci / IdeBusDxe / Ide.h
CommitLineData
ead42efc 1/** @file\r
2 Header file for IDE Bus Driver, containing the helper functions'\r
630d580d 3 prototype.\r
ead42efc 4\r
0a6f4824 5 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
180a5a35 6 This program and the accompanying materials\r
ead42efc 7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14 @par Revision Reference:\r
15 2002-6: Add Atapi6 enhancement, support >120GB hard disk, including\r
16 Add - IDEBlkIoReadBlocksExt() func definition\r
17 Add - IDEBlkIoWriteBlocksExt() func definition\r
18\r
19**/\r
20\r
eeefcb9d 21#ifndef _IDE_H_\r
22#define _IDE_H_\r
ead42efc 23\r
24//\r
25// Helper functions Prototype\r
26//\r
27/**\r
cd57e888 28 read a one-byte data from a IDE port.\r
ead42efc 29\r
630d580d 30 @param PciIo The PCI IO protocol instance\r
0a6f4824 31 @param Port the IDE Port number\r
ead42efc 32\r
630d580d 33 return the one-byte data read from IDE port\r
ead42efc 34**/\r
35UINT8\r
36IDEReadPortB (\r
37 IN EFI_PCI_IO_PROTOCOL *PciIo,\r
38 IN UINT16 Port\r
ed66e1bc 39 );\r
ead42efc 40\r
41/**\r
630d580d 42 Reads multiple words of data from the IDE data port.\r
43 Call the IO abstraction once to do the complete read,\r
cd57e888 44 not one word at a time.\r
ead42efc 45\r
630d580d 46 @param PciIo Pointer to the EFI_PCI_IO instance\r
47 @param Port IO port to read\r
48 @param Count No. of UINT16's to read\r
49 @param Buffer Pointer to the data buffer for read\r
ead42efc 50\r
51**/\r
52VOID\r
53IDEReadPortWMultiple (\r
54 IN EFI_PCI_IO_PROTOCOL *PciIo,\r
55 IN UINT16 Port,\r
56 IN UINTN Count,\r
57 OUT VOID *Buffer\r
ed66e1bc 58 );\r
ead42efc 59\r
60/**\r
cd57e888 61 write a 1-byte data to a specific IDE port.\r
ead42efc 62\r
630d580d 63 @param PciIo PCI IO protocol instance\r
64 @param Port The IDE port to be writen\r
65 @param Data The data to write to the port\r
ead42efc 66**/\r
67VOID\r
68IDEWritePortB (\r
69 IN EFI_PCI_IO_PROTOCOL *PciIo,\r
70 IN UINT16 Port,\r
71 IN UINT8 Data\r
ed66e1bc 72 );\r
ead42efc 73\r
74/**\r
cd57e888 75 write a 1-word data to a specific IDE port.\r
ead42efc 76\r
630d580d 77 @param PciIo PCI IO protocol instance\r
78 @param Port The IDE port to be writen\r
79 @param Data The data to write to the port\r
ead42efc 80**/\r
81VOID\r
82IDEWritePortW (\r
83 IN EFI_PCI_IO_PROTOCOL *PciIo,\r
84 IN UINT16 Port,\r
85 IN UINT16 Data\r
ed66e1bc 86 );\r
ead42efc 87\r
88/**\r
630d580d 89 Write multiple words of data to the IDE data port.\r
90 Call the IO abstraction once to do the complete read,\r
cd57e888 91 not one word at a time.\r
ead42efc 92\r
630d580d 93 @param PciIo Pointer to the EFI_PCI_IO instance\r
94 @param Port IO port to read\r
95 @param Count No. of UINT16's to read\r
96 @param Buffer Pointer to the data buffer for read\r
ead42efc 97\r
98**/\r
99VOID\r
100IDEWritePortWMultiple (\r
101 IN EFI_PCI_IO_PROTOCOL *PciIo,\r
102 IN UINT16 Port,\r
103 IN UINTN Count,\r
104 IN VOID *Buffer\r
ed66e1bc 105 );\r
ead42efc 106\r
107/**\r
630d580d 108 Get IDE IO port registers' base addresses by mode. In 'Compatibility' mode,\r
109 use fixed addresses. In Native-PCI mode, get base addresses from BARs in\r
110 the PCI IDE controller's Configuration Space.\r
ead42efc 111\r
630d580d 112 The steps to get IDE IO port registers' base addresses for each channel\r
113 as follows:\r
ead42efc 114\r
630d580d 115 1. Examine the Programming Interface byte of the Class Code fields in PCI IDE\r
116 controller's Configuration Space to determine the operating mode.\r
117\r
118 2. a) In 'Compatibility' mode, use fixed addresses shown in the Table 1 below.\r
119 <pre>\r
120 ___________________________________________\r
121 | | Command Block | Control Block |\r
122 | Channel | Registers | Registers |\r
123 |___________|_______________|_______________|\r
124 | Primary | 1F0h - 1F7h | 3F6h - 3F7h |\r
125 |___________|_______________|_______________|\r
126 | Secondary | 170h - 177h | 376h - 377h |\r
127 |___________|_______________|_______________|\r
128\r
129 Table 1. Compatibility resource mappings\r
130 </pre>\r
131\r
132 b) In Native-PCI mode, IDE registers are mapped into IO space using the BARs\r
133 in IDE controller's PCI Configuration Space, shown in the Table 2 below.\r
134 <pre>\r
135 ___________________________________________________\r
136 | | Command Block | Control Block |\r
137 | Channel | Registers | Registers |\r
138 |___________|___________________|___________________|\r
139 | Primary | BAR at offset 0x10| BAR at offset 0x14|\r
140 |___________|___________________|___________________|\r
141 | Secondary | BAR at offset 0x18| BAR at offset 0x1C|\r
142 |___________|___________________|___________________|\r
143\r
144 Table 2. BARs for Register Mapping\r
145 </pre>\r
146 @note Refer to Intel ICH4 datasheet, Control Block Offset: 03F4h for\r
147 primary, 0374h for secondary. So 2 bytes extra offset should be\r
148 added to the base addresses read from BARs.\r
149\r
150 For more details, please refer to PCI IDE Controller Specification and Intel\r
151 ICH4 Datasheet.\r
152\r
153 @param PciIo Pointer to the EFI_PCI_IO_PROTOCOL instance\r
154 @param IdeRegsBaseAddr Pointer to IDE_REGISTERS_BASE_ADDR to\r
cd57e888 155 receive IDE IO port registers' base addresses\r
0a6f4824 156\r
cd57e888 157 @retval EFI_UNSUPPORTED return this value when the BARs is not IO type\r
158 @retval EFI_SUCCESS Get the Base address successfully\r
159 @retval other read the pci configureation data error\r
ead42efc 160\r
161**/\r
162EFI_STATUS\r
163GetIdeRegistersBaseAddr (\r
164 IN EFI_PCI_IO_PROTOCOL *PciIo,\r
165 OUT IDE_REGISTERS_BASE_ADDR *IdeRegsBaseAddr\r
ed66e1bc 166 );\r
ead42efc 167\r
168/**\r
630d580d 169 This function is used to requery IDE resources. The IDE controller will\r
170 probably switch between native and legacy modes during the EFI->CSM->OS\r
171 transfer. We do this everytime before an BlkIo operation to ensure its\r
172 succeess.\r
ead42efc 173\r
630d580d 174 @param IdeDev The BLK_IO private data which specifies the IDE device\r
ead42efc 175\r
cd57e888 176 @retval EFI_INVALID_PARAMETER return this value when the channel is invalid\r
177 @retval EFI_SUCCESS reassign the IDE IO resource successfully\r
178 @retval other get the IDE current base address effor\r
179\r
ead42efc 180**/\r
181EFI_STATUS\r
182ReassignIdeResources (\r
183 IN IDE_BLK_IO_DEV *IdeDev\r
ed66e1bc 184 );\r
ead42efc 185\r
186/**\r
cd57e888 187 Detect if there is disk attached to this port.\r
ead42efc 188\r
630d580d 189 @param IdeDev The BLK_IO private data which specifies the IDE device.\r
0a6f4824 190\r
cd57e888 191 @retval EFI_NOT_FOUND The device or channel is not found\r
192 @retval EFI_SUCCESS The device is found\r
ead42efc 193\r
194**/\r
195EFI_STATUS\r
196DiscoverIdeDevice (\r
197 IN IDE_BLK_IO_DEV *IdeDev\r
ed66e1bc 198 );\r
ead42efc 199\r
200/**\r
201 This interface is used to initialize all state data related to the\r
202 detection of one channel.\r
203\r
ead42efc 204**/\r
563c9c8a 205VOID\r
ead42efc 206InitializeIDEChannelData (\r
207 VOID\r
ed66e1bc 208 );\r
ead42efc 209\r
210/**\r
630d580d 211 This function is used to poll for the DRQ bit clear in the Status\r
212 Register. DRQ is cleared when the device is finished transferring data.\r
213 So this function is called after data transfer is finished.\r
ead42efc 214\r
0a6f4824 215 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used\r
630d580d 216 to record all the information of the IDE device.\r
217 @param TimeoutInMilliSeconds used to designate the timeout for the DRQ clear.\r
ead42efc 218\r
630d580d 219 @retval EFI_SUCCESS DRQ bit clear within the time out.\r
ead42efc 220\r
630d580d 221 @retval EFI_TIMEOUT DRQ bit not clear within the time out.\r
ead42efc 222\r
630d580d 223 @note\r
224 Read Status Register will clear interrupt status.\r
ead42efc 225\r
226**/\r
227EFI_STATUS\r
228DRQClear (\r
229 IN IDE_BLK_IO_DEV *IdeDev,\r
230 IN UINTN TimeoutInMilliSeconds\r
ed66e1bc 231 );\r
ead42efc 232\r
233/**\r
630d580d 234 This function is used to poll for the DRQ bit clear in the Alternate\r
235 Status Register. DRQ is cleared when the device is finished\r
236 transferring data. So this function is called after data transfer\r
237 is finished.\r
ead42efc 238\r
0a6f4824 239 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used\r
630d580d 240 to record all the information of the IDE device.\r
ead42efc 241\r
630d580d 242 @param TimeoutInMilliSeconds used to designate the timeout for the DRQ clear.\r
243\r
244 @retval EFI_SUCCESS DRQ bit clear within the time out.\r
245\r
246 @retval EFI_TIMEOUT DRQ bit not clear within the time out.\r
247 @note\r
248 Read Alternate Status Register will not clear interrupt status.\r
ead42efc 249\r
250**/\r
251EFI_STATUS\r
252DRQClear2 (\r
253 IN IDE_BLK_IO_DEV *IdeDev,\r
254 IN UINTN TimeoutInMilliSeconds\r
ed66e1bc 255 );\r
ead42efc 256\r
257/**\r
630d580d 258 This function is used to poll for the DRQ bit set in the\r
259 Status Register.\r
260 DRQ is set when the device is ready to transfer data. So this function\r
261 is called after the command is sent to the device and before required\r
262 data is transferred.\r
263\r
264 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to\r
265 record all the information of the IDE device.\r
266 @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.\r
ead42efc 267\r
630d580d 268 @retval EFI_SUCCESS DRQ bit set within the time out.\r
269 @retval EFI_TIMEOUT DRQ bit not set within the time out.\r
270 @retval EFI_ABORTED DRQ bit not set caused by the command abort.\r
ead42efc 271\r
630d580d 272 @note Read Status Register will clear interrupt status.\r
ead42efc 273\r
274**/\r
275EFI_STATUS\r
276DRQReady (\r
277 IN IDE_BLK_IO_DEV *IdeDev,\r
278 IN UINTN TimeoutInMilliSeconds\r
ed66e1bc 279 );\r
ead42efc 280\r
281/**\r
630d580d 282 This function is used to poll for the DRQ bit set in the Alternate Status Register.\r
0a6f4824 283 DRQ is set when the device is ready to transfer data. So this function is called after\r
630d580d 284 the command is sent to the device and before required data is transferred.\r
ead42efc 285\r
0a6f4824 286 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to\r
630d580d 287 record all the information of the IDE device.\r
ead42efc 288\r
630d580d 289 @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.\r
290\r
291 @retval EFI_SUCCESS DRQ bit set within the time out.\r
292 @retval EFI_TIMEOUT DRQ bit not set within the time out.\r
293 @retval EFI_ABORTED DRQ bit not set caused by the command abort.\r
294 @note Read Alternate Status Register will not clear interrupt status.\r
ead42efc 295\r
296**/\r
297EFI_STATUS\r
298DRQReady2 (\r
299 IN IDE_BLK_IO_DEV *IdeDev,\r
300 IN UINTN TimeoutInMilliSeconds\r
ed66e1bc 301 );\r
ead42efc 302\r
303/**\r
630d580d 304 This function is used to poll for the BSY bit clear in the Status Register. BSY\r
305 is clear when the device is not busy. Every command must be sent after device is not busy.\r
ead42efc 306\r
0a6f4824 307 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used\r
630d580d 308 to record all the information of the IDE device.\r
309 @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.\r
ead42efc 310\r
630d580d 311 @retval EFI_SUCCESS BSY bit clear within the time out.\r
312 @retval EFI_TIMEOUT BSY bit not clear within the time out.\r
ead42efc 313\r
630d580d 314 @note Read Status Register will clear interrupt status.\r
ead42efc 315**/\r
316EFI_STATUS\r
317WaitForBSYClear (\r
318 IN IDE_BLK_IO_DEV *IdeDev,\r
319 IN UINTN TimeoutInMilliSeconds\r
ed66e1bc 320 );\r
ead42efc 321\r
322/**\r
0a6f4824
LG
323 This function is used to poll for the BSY bit clear in the Alternate Status Register.\r
324 BSY is clear when the device is not busy. Every command must be sent after device is\r
630d580d 325 not busy.\r
ead42efc 326\r
0a6f4824 327 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
630d580d 328 all the information of the IDE device.\r
cd57e888 329 @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.\r
ead42efc 330\r
630d580d 331 @retval EFI_SUCCESS BSY bit clear within the time out.\r
332 @retval EFI_TIMEOUT BSY bit not clear within the time out.\r
333 @note Read Alternate Status Register will not clear interrupt status.\r
ead42efc 334\r
335**/\r
336EFI_STATUS\r
337WaitForBSYClear2 (\r
338 IN IDE_BLK_IO_DEV *IdeDev,\r
339 IN UINTN TimeoutInMilliSeconds\r
ed66e1bc 340 );\r
ead42efc 341\r
342/**\r
630d580d 343 This function is used to poll for the DRDY bit set in the Status Register. DRDY\r
0a6f4824 344 bit is set when the device is ready to accept command. Most ATA commands must be\r
630d580d 345 sent after DRDY set except the ATAPI Packet Command.\r
ead42efc 346\r
630d580d 347 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used\r
348 to record all the information of the IDE device.\r
349 @param DelayInMilliSeconds used to designate the timeout for the DRQ ready.\r
ead42efc 350\r
630d580d 351 @retval EFI_SUCCESS DRDY bit set within the time out.\r
352 @retval EFI_TIMEOUT DRDY bit not set within the time out.\r
ead42efc 353\r
630d580d 354 @note Read Status Register will clear interrupt status.\r
ead42efc 355**/\r
356EFI_STATUS\r
357DRDYReady (\r
358 IN IDE_BLK_IO_DEV *IdeDev,\r
359 IN UINTN DelayInMilliSeconds\r
ed66e1bc 360 );\r
ead42efc 361\r
362/**\r
0a6f4824
LG
363 This function is used to poll for the DRDY bit set in the Alternate Status Register.\r
364 DRDY bit is set when the device is ready to accept command. Most ATA commands must\r
630d580d 365 be sent after DRDY set except the ATAPI Packet Command.\r
366\r
367 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used\r
368 to record all the information of the IDE device.\r
369 @param DelayInMilliSeconds used to designate the timeout for the DRQ ready.\r
ead42efc 370\r
630d580d 371 @retval EFI_SUCCESS DRDY bit set within the time out.\r
372 @retval EFI_TIMEOUT DRDY bit not set within the time out.\r
ead42efc 373\r
630d580d 374 @note Read Alternate Status Register will clear interrupt status.\r
ead42efc 375\r
376**/\r
377EFI_STATUS\r
378DRDYReady2 (\r
379 IN IDE_BLK_IO_DEV *IdeDev,\r
380 IN UINTN DelayInMilliSeconds\r
ed66e1bc 381 );\r
ead42efc 382\r
ead42efc 383//\r
384// ATA device functions' prototype\r
385//\r
386/**\r
630d580d 387 Sends out an ATA Identify Command to the specified device.\r
388\r
389 This function is called by DiscoverIdeDevice() during its device\r
390 identification. It sends out the ATA Identify Command to the\r
391 specified device. Only ATA device responses to this command. If\r
392 the command succeeds, it returns the Identify data structure which\r
393 contains information about the device. This function extracts the\r
394 information it needs to fill the IDE_BLK_IO_DEV data structure,\r
395 including device type, media block size, media capacity, and etc.\r
ead42efc 396\r
0a6f4824 397 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to record\r
630d580d 398 all the information of the IDE device.\r
ead42efc 399\r
630d580d 400 @retval EFI_SUCCESS Identify ATA device successfully.\r
401 @retval EFI_DEVICE_ERROR ATA Identify Device Command failed or device is not ATA device.\r
402 @note parameter IdeDev will be updated in this function.\r
ead42efc 403\r
404**/\r
405EFI_STATUS\r
406ATAIdentify (\r
407 IN IDE_BLK_IO_DEV *IdeDev\r
ed66e1bc 408 );\r
ead42efc 409\r
410/**\r
630d580d 411 This function is called by ATAIdentify() or ATAPIIdentify() to print device's module name.\r
ead42efc 412\r
630d580d 413 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
414 all the information of the IDE device.\r
ead42efc 415**/\r
416VOID\r
417PrintAtaModuleName (\r
418 IN IDE_BLK_IO_DEV *IdeDev\r
ed66e1bc 419 );\r
ead42efc 420/**\r
630d580d 421 This function is used to send out ATA commands conforms to the PIO Data In Protocol.\r
ead42efc 422\r
0a6f4824 423 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
630d580d 424 all the information of the IDE device.\r
425 @param Buffer buffer contained data transferred from device to host.\r
426 @param ByteCount data size in byte unit of the buffer.\r
427 @param AtaCommand value of the Command Register\r
428 @param Head value of the Head/Device Register\r
429 @param SectorCount value of the Sector Count Register\r
430 @param SectorNumber value of the Sector Number Register\r
431 @param CylinderLsb value of the low byte of the Cylinder Register\r
432 @param CylinderMsb value of the high byte of the Cylinder Register\r
0a6f4824 433\r
630d580d 434 @retval EFI_SUCCESS send out the ATA command and device send required data successfully.\r
435 @retval EFI_DEVICE_ERROR command sent failed.\r
ead42efc 436\r
437**/\r
438EFI_STATUS\r
439AtaPioDataIn (\r
440 IN IDE_BLK_IO_DEV *IdeDev,\r
441 IN VOID *Buffer,\r
442 IN UINT32 ByteCount,\r
443 IN UINT8 AtaCommand,\r
444 IN UINT8 Head,\r
445 IN UINT8 SectorCount,\r
446 IN UINT8 SectorNumber,\r
447 IN UINT8 CylinderLsb,\r
448 IN UINT8 CylinderMsb\r
ed66e1bc 449 );\r
ead42efc 450\r
451/**\r
630d580d 452 This function is used to send out ATA commands conforms to the\r
453 PIO Data Out Protocol.\r
ead42efc 454\r
630d580d 455 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used\r
456 to record all the information of the IDE device.\r
457 @param *Buffer buffer contained data transferred from host to device.\r
458 @param ByteCount data size in byte unit of the buffer.\r
459 @param AtaCommand value of the Command Register\r
460 @param Head value of the Head/Device Register\r
461 @param SectorCount value of the Sector Count Register\r
462 @param SectorNumber value of the Sector Number Register\r
463 @param CylinderLsb value of the low byte of the Cylinder Register\r
464 @param CylinderMsb value of the high byte of the Cylinder Register\r
ead42efc 465\r
630d580d 466 @retval EFI_SUCCESS send out the ATA command and device received required\r
467 data successfully.\r
468 @retval EFI_DEVICE_ERROR command sent failed.\r
ead42efc 469\r
470**/\r
471EFI_STATUS\r
472AtaPioDataOut (\r
473 IN IDE_BLK_IO_DEV *IdeDev,\r
474 IN VOID *Buffer,\r
475 IN UINT32 ByteCount,\r
476 IN UINT8 AtaCommand,\r
477 IN UINT8 Head,\r
478 IN UINT8 SectorCount,\r
479 IN UINT8 SectorNumber,\r
480 IN UINT8 CylinderLsb,\r
481 IN UINT8 CylinderMsb\r
ed66e1bc 482 );\r
ead42efc 483\r
484/**\r
630d580d 485 This function is used to analyze the Status Register and print out\r
486 some debug information and if there is ERR bit set in the Status\r
487 Register, the Error Register's value is also be parsed and print out.\r
ead42efc 488\r
0a6f4824 489 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to\r
630d580d 490 record all the information of the IDE device.\r
ead42efc 491\r
630d580d 492 @retval EFI_SUCCESS No err information in the Status Register.\r
493 @retval EFI_DEVICE_ERROR Any err information in the Status Register.\r
ead42efc 494\r
495**/\r
496EFI_STATUS\r
497CheckErrorStatus (\r
498 IN IDE_BLK_IO_DEV *IdeDev\r
ed66e1bc 499 );\r
ead42efc 500\r
501/**\r
630d580d 502 This function is used to implement the Soft Reset on the specified device. But,\r
0a6f4824 503 the ATA Soft Reset mechanism is so strong a reset method that it will force\r
630d580d 504 resetting on both devices connected to the same cable.\r
ead42efc 505\r
630d580d 506 It is called by IdeBlkIoReset(), a interface function of Block\r
507 I/O protocol.\r
ead42efc 508\r
630d580d 509 This function can also be used by the ATAPI device to perform reset when\r
510 ATAPI Reset command is failed.\r
ead42efc 511\r
630d580d 512 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
513 all the information of the IDE device.\r
514 @retval EFI_SUCCESS Soft reset completes successfully.\r
515 @retval EFI_DEVICE_ERROR Any step during the reset process is failed.\r
ead42efc 516\r
630d580d 517 @note The registers initial values after ATA soft reset are different\r
518 to the ATA device and ATAPI device.\r
ead42efc 519**/\r
520EFI_STATUS\r
521AtaSoftReset (\r
522 IN IDE_BLK_IO_DEV *IdeDev\r
ed66e1bc 523 );\r
ead42efc 524\r
525/**\r
630d580d 526 This function is the ATA implementation for ReadBlocks in the\r
527 Block I/O Protocol interface.\r
528\r
529 @param IdeBlkIoDevice Indicates the calling context.\r
530 @param MediaId The media id that the read request is for.\r
cd57e888 531 @param Lba The starting logical block address to read from on the device.\r
630d580d 532 @param BufferSize The size of the Buffer in bytes. This must be a multiple\r
533 of the intrinsic block size of the device.\r
ead42efc 534\r
630d580d 535 @param Buffer A pointer to the destination buffer for the data. The caller\r
536 is responsible for either having implicit or explicit ownership\r
537 of the memory that data is read into.\r
ead42efc 538\r
630d580d 539 @retval EFI_SUCCESS Read Blocks successfully.\r
540 @retval EFI_DEVICE_ERROR Read Blocks failed.\r
541 @retval EFI_NO_MEDIA There is no media in the device.\r
542 @retval EFI_MEDIA_CHANGE The MediaId is not for the current media.\r
543 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the\r
544 intrinsic block size of the device.\r
545 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
546 or the data buffer is not valid.\r
547\r
548 @note If Read Block error because of device error, this function will call\r
549 AtaSoftReset() function to reset device.\r
ead42efc 550\r
551**/\r
552EFI_STATUS\r
553AtaBlkIoReadBlocks (\r
554 IN IDE_BLK_IO_DEV *IdeBlkIoDevice,\r
555 IN UINT32 MediaId,\r
e72ca438 556 IN EFI_LBA Lba,\r
ead42efc 557 IN UINTN BufferSize,\r
558 OUT VOID *Buffer\r
ed66e1bc 559 );\r
ead42efc 560\r
561/**\r
630d580d 562 This function is the ATA implementation for WriteBlocks in the\r
563 Block I/O Protocol interface.\r
564\r
565 @param IdeBlkIoDevice Indicates the calling context.\r
566 @param MediaId The media id that the write request is for.\r
cd57e888 567 @param Lba The starting logical block address to write onto the device.\r
630d580d 568 @param BufferSize The size of the Buffer in bytes. This must be a multiple\r
569 of the intrinsic block size of the device.\r
570 @param Buffer A pointer to the source buffer for the data.The caller\r
0a6f4824 571 is responsible for either having implicit or explicit\r
630d580d 572 ownership of the memory that data is written from.\r
ead42efc 573\r
630d580d 574 @retval EFI_SUCCESS Write Blocks successfully.\r
575 @retval EFI_DEVICE_ERROR Write Blocks failed.\r
576 @retval EFI_NO_MEDIA There is no media in the device.\r
577 @retval EFI_MEDIA_CHANGE The MediaId is not for the current media.\r
ead42efc 578\r
630d580d 579 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the\r
580 intrinsic block size of the device.\r
581 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
582 or the data buffer is not valid.\r
ead42efc 583\r
630d580d 584 @note If Write Block error because of device error, this function will call\r
585 AtaSoftReset() function to reset device.\r
ead42efc 586**/\r
587EFI_STATUS\r
588AtaBlkIoWriteBlocks (\r
589 IN IDE_BLK_IO_DEV *IdeBlkIoDevice,\r
590 IN UINT32 MediaId,\r
e72ca438 591 IN EFI_LBA Lba,\r
ead42efc 592 IN UINTN BufferSize,\r
593 OUT VOID *Buffer\r
ed66e1bc 594 );\r
ead42efc 595\r
ead42efc 596/**\r
630d580d 597 This function is called by DiscoverIdeDevice() during its device\r
598 identification.\r
599 Its main purpose is to get enough information for the device media\r
600 to fill in the Media data structure of the Block I/O Protocol interface.\r
601\r
602 There are 5 steps to reach such objective:\r
0a6f4824 603 1. Sends out the ATAPI Identify Command to the specified device.\r
630d580d 604 Only ATAPI device responses to this command. If the command succeeds,\r
0a6f4824
LG
605 it returns the Identify data structure which filled with information\r
606 about the device. Since the ATAPI device contains removable media,\r
630d580d 607 the only meaningful information is the device module name.\r
608 2. Sends out ATAPI Inquiry Packet Command to the specified device.\r
609 This command will return inquiry data of the device, which contains\r
610 the device type information.\r
611 3. Allocate sense data space for future use. We don't detect the media\r
0a6f4824 612 presence here to improvement boot performance, especially when CD\r
630d580d 613 media is present. The media detection will be performed just before\r
614 each BLK_IO read/write\r
0a6f4824 615\r
630d580d 616 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used\r
617 to record all the information of the IDE device.\r
ead42efc 618\r
630d580d 619 @retval EFI_SUCCESS Identify ATAPI device successfully.\r
620 @retval EFI_DEVICE_ERROR ATAPI Identify Device Command failed or device type\r
621 is not supported by this IDE driver.\r
0a6f4824 622 @retval EFI_OUT_OF_RESOURCES Allocate memory for sense data failed\r
ead42efc 623\r
630d580d 624 @note Parameter "IdeDev" will be updated in this function.\r
ead42efc 625**/\r
626EFI_STATUS\r
627ATAPIIdentify (\r
628 IN IDE_BLK_IO_DEV *IdeDev\r
ed66e1bc 629 );\r
ead42efc 630\r
631/**\r
630d580d 632 This function is used to implement the Soft Reset on the specified\r
633 ATAPI device. Different from the AtaSoftReset(), here reset is a ATA\r
634 Soft Reset Command special for ATAPI device, and it only take effects\r
635 on the specified ATAPI device, not on the whole IDE bus.\r
636 Since the ATAPI soft reset is needed when device is in exceptional\r
637 condition (such as BSY bit is always set ), I think the Soft Reset\r
638 command should be sent without waiting for the BSY clear and DRDY\r
639 set.\r
0a6f4824 640 This function is called by IdeBlkIoReset(),\r
630d580d 641 a interface function of Block I/O protocol.\r
ead42efc 642\r
630d580d 643 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used\r
644 to record all the information of the IDE device.\r
ead42efc 645\r
630d580d 646 @retval EFI_SUCCESS Soft reset completes successfully.\r
647 @retval EFI_DEVICE_ERROR Any step during the reset process is failed.\r
ead42efc 648\r
649**/\r
650EFI_STATUS\r
651AtapiSoftReset (\r
652 IN IDE_BLK_IO_DEV *IdeDev\r
ed66e1bc 653 );\r
ead42efc 654\r
655/**\r
630d580d 656 This function is the ATAPI implementation for ReadBlocks in the\r
657 Block I/O Protocol interface.\r
ead42efc 658\r
630d580d 659 @param IdeBlkIoDevice Indicates the calling context.\r
660 @param MediaId The media id that the read request is for.\r
cd57e888 661 @param Lba The starting logical block address to read from on the device.\r
630d580d 662 @param BufferSize The size of the Buffer in bytes. This must be a multiple\r
663 of the intrinsic block size of the device.\r
664 @param Buffer A pointer to the destination buffer for the data. The caller\r
0a6f4824 665 is responsible for either having implicit or explicit\r
630d580d 666 ownership of the memory that data is read into.\r
0a6f4824 667\r
630d580d 668 @retval EFI_SUCCESS Read Blocks successfully.\r
669 @retval EFI_DEVICE_ERROR Read Blocks failed.\r
670 @retval EFI_NO_MEDIA There is no media in the device.\r
671 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
672 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the\r
673 intrinsic block size of the device.\r
674 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
675 or the data buffer is not valid.\r
ead42efc 676**/\r
677EFI_STATUS\r
678AtapiBlkIoReadBlocks (\r
679 IN IDE_BLK_IO_DEV *IdeBlkIoDevice,\r
680 IN UINT32 MediaId,\r
e72ca438 681 IN EFI_LBA Lba,\r
ead42efc 682 IN UINTN BufferSize,\r
683 OUT VOID *Buffer\r
ed66e1bc 684 );\r
ead42efc 685\r
686/**\r
630d580d 687 This function is the ATAPI implementation for WriteBlocks in the\r
688 Block I/O Protocol interface.\r
ead42efc 689\r
630d580d 690 @param IdeBlkIoDevice Indicates the calling context.\r
691 @param MediaId The media id that the write request is for.\r
cd57e888 692 @param Lba The starting logical block address to write onto the device.\r
630d580d 693 @param BufferSize The size of the Buffer in bytes. This must be a multiple\r
694 of the intrinsic block size of the device.\r
695 @param Buffer A pointer to the source buffer for the data. The caller\r
696 is responsible for either having implicit or explicit ownership\r
697 of the memory that data is written from.\r
ead42efc 698\r
630d580d 699 @retval EFI_SUCCESS Write Blocks successfully.\r
700 @retval EFI_DEVICE_ERROR Write Blocks failed.\r
701 @retval EFI_NO_MEDIA There is no media in the device.\r
702 @retval EFI_MEDIA_CHANGE The MediaId is not for the current media.\r
703 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the\r
0a6f4824
LG
704 intrinsic block size of the device.\r
705 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
630d580d 706 or the data buffer is not valid.\r
ead42efc 707\r
630d580d 708 @retval EFI_WRITE_PROTECTED The write protected is enabled or the media does not support write\r
ead42efc 709**/\r
710EFI_STATUS\r
711AtapiBlkIoWriteBlocks (\r
712 IN IDE_BLK_IO_DEV *IdeBlkIoDevice,\r
713 IN UINT32 MediaId,\r
e72ca438 714 IN EFI_LBA Lba,\r
ead42efc 715 IN UINTN BufferSize,\r
716 OUT VOID *Buffer\r
ed66e1bc 717 );\r
ead42efc 718\r
719/**\r
630d580d 720 Release resources of an IDE device before stopping it.\r
ead42efc 721\r
630d580d 722 @param IdeBlkIoDevice Standard IDE device private data structure\r
ead42efc 723\r
724**/\r
725VOID\r
726ReleaseIdeResources (\r
727 IN IDE_BLK_IO_DEV *IdeBlkIoDevice\r
ed66e1bc 728 );\r
ead42efc 729\r
730/**\r
630d580d 731 Set the calculated Best transfer mode to a detected device\r
ead42efc 732\r
630d580d 733 @param IdeDev Standard IDE device private data structure\r
734 @param TransferMode The device transfer mode to be set\r
735 @return Set transfer mode Command execute status.\r
ead42efc 736**/\r
737EFI_STATUS\r
738SetDeviceTransferMode (\r
739 IN IDE_BLK_IO_DEV *IdeDev,\r
740 IN ATA_TRANSFER_MODE *TransferMode\r
ed66e1bc 741 );\r
ead42efc 742/**\r
cd57e888 743 Send ATA command into device with NON_DATA protocol.\r
ead42efc 744\r
630d580d 745 @param IdeDev Standard IDE device private data structure\r
746 @param AtaCommand The ATA command to be sent\r
747 @param Device The value in Device register\r
748 @param Feature The value in Feature register\r
749 @param SectorCount The value in SectorCount register\r
750 @param LbaLow The value in LBA_LOW register\r
751 @param LbaMiddle The value in LBA_MIDDLE register\r
752 @param LbaHigh The value in LBA_HIGH register\r
ead42efc 753\r
630d580d 754 @retval EFI_SUCCESS Reading succeed\r
755 @retval EFI_ABORTED Command failed\r
756 @retval EFI_DEVICE_ERROR Device status error.\r
ead42efc 757\r
758**/\r
759EFI_STATUS\r
760AtaNonDataCommandIn (\r
761 IN IDE_BLK_IO_DEV *IdeDev,\r
762 IN UINT8 AtaCommand,\r
763 IN UINT8 Device,\r
764 IN UINT8 Feature,\r
765 IN UINT8 SectorCount,\r
766 IN UINT8 LbaLow,\r
767 IN UINT8 LbaMiddle,\r
768 IN UINT8 LbaHigh\r
ed66e1bc 769 );\r
ead42efc 770\r
75eccf9d 771/**\r
772 Enable Long Physical Sector Feature for ATA device.\r
773\r
774 @param IdeDev The IDE device data\r
775\r
776 @retval EFI_SUCCESS The ATA device supports Long Physical Sector feature\r
777 and corresponding fields in BlockIo structure is updated.\r
778 @retval EFI_UNSUPPORTED The device is not ATA device or Long Physical Sector\r
779 feature is not supported.\r
780**/\r
781EFI_STATUS\r
782AtaEnableLongPhysicalSector (\r
783 IN IDE_BLK_IO_DEV *IdeDev\r
784 );\r
785\r
ead42efc 786/**\r
cd57e888 787 Set drive parameters for devices not support PACKETS command.\r
ead42efc 788\r
630d580d 789 @param IdeDev Standard IDE device private data structure\r
790 @param DriveParameters The device parameters to be set into the disk\r
791 @return SetParameters Command execute status.\r
ead42efc 792\r
793**/\r
794EFI_STATUS\r
795SetDriveParameters (\r
796 IN IDE_BLK_IO_DEV *IdeDev,\r
797 IN ATA_DRIVE_PARMS *DriveParameters\r
ed66e1bc 798 );\r
ead42efc 799\r
800/**\r
7dd94873 801 Enable Interrupt on IDE controller.\r
ead42efc 802\r
630d580d 803 @param IdeDev Standard IDE device private data structure\r
ead42efc 804\r
630d580d 805 @retval EFI_SUCCESS Enable Interrupt successfully\r
ead42efc 806**/\r
807EFI_STATUS\r
808EnableInterrupt (\r
809 IN IDE_BLK_IO_DEV *IdeDev\r
ed66e1bc 810 );\r
ead42efc 811#endif\r