]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.h
Code scrub for IdeBusDxe driver
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Pci / IdeBusDxe / Ide.h
... / ...
CommitLineData
1/** @file\r
2 Header file for IDE Bus Driver, containing the helper functions'\r
3 prototype.\r
4\r
5 Copyright (c) 2006 - 2007 Intel Corporation. <BR>\r
6 All rights reserved. This program and the accompanying materials\r
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
21#ifndef _IDE_H_\r
22#define _IDE_H_\r
23\r
24//\r
25// Helper functions Prototype\r
26//\r
27/**\r
28 read a one-byte data from a IDE port.\r
29\r
30 @param PciIo The PCI IO protocol instance\r
31 @param Port the IDE Port number \r
32\r
33 return the one-byte data read from IDE port\r
34**/\r
35UINT8\r
36IDEReadPortB (\r
37 IN EFI_PCI_IO_PROTOCOL *PciIo,\r
38 IN UINT16 Port\r
39 );\r
40\r
41/**\r
42 Reads multiple words of data from the IDE data port.\r
43 Call the IO abstraction once to do the complete read,\r
44 not one word at a time.\r
45\r
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
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
58 );\r
59\r
60/**\r
61 write a 1-byte data to a specific IDE port.\r
62\r
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
66**/\r
67VOID\r
68IDEWritePortB (\r
69 IN EFI_PCI_IO_PROTOCOL *PciIo,\r
70 IN UINT16 Port,\r
71 IN UINT8 Data\r
72 );\r
73\r
74/**\r
75 write a 1-word data to a specific IDE port.\r
76\r
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
80**/\r
81VOID\r
82IDEWritePortW (\r
83 IN EFI_PCI_IO_PROTOCOL *PciIo,\r
84 IN UINT16 Port,\r
85 IN UINT16 Data\r
86 );\r
87\r
88/**\r
89 Write multiple words of data to the IDE data port.\r
90 Call the IO abstraction once to do the complete read,\r
91 not one word at a time.\r
92\r
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
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
105 );\r
106\r
107/**\r
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
111\r
112 The steps to get IDE IO port registers' base addresses for each channel\r
113 as follows:\r
114\r
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
155 receive IDE IO port registers' base addresses\r
156 \r
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
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
166 );\r
167\r
168/**\r
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
173\r
174 @param IdeDev The BLK_IO private data which specifies the IDE device\r
175\r
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
180**/\r
181EFI_STATUS\r
182ReassignIdeResources (\r
183 IN IDE_BLK_IO_DEV *IdeDev\r
184 );\r
185\r
186/**\r
187 Detect if there is disk attached to this port.\r
188\r
189 @param IdeDev The BLK_IO private data which specifies the IDE device.\r
190 \r
191 @retval EFI_NOT_FOUND The device or channel is not found\r
192 @retval EFI_SUCCESS The device is found\r
193\r
194**/\r
195EFI_STATUS\r
196DiscoverIdeDevice (\r
197 IN IDE_BLK_IO_DEV *IdeDev\r
198 );\r
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
204 @retval EFI_SUCCESS Completed successfully.\r
205\r
206**/\r
207EFI_STATUS\r
208InitializeIDEChannelData (\r
209 VOID\r
210 );\r
211\r
212/**\r
213 This function is used to poll for the DRQ bit clear in the Status\r
214 Register. DRQ is cleared when the device is finished transferring data.\r
215 So this function is called after data transfer is finished.\r
216\r
217 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used \r
218 to record all the information of the IDE device.\r
219 @param TimeoutInMilliSeconds used to designate the timeout for the DRQ clear.\r
220\r
221 @retval EFI_SUCCESS DRQ bit clear within the time out.\r
222\r
223 @retval EFI_TIMEOUT DRQ bit not clear within the time out.\r
224\r
225 @note\r
226 Read Status Register will clear interrupt status.\r
227\r
228**/\r
229EFI_STATUS\r
230DRQClear (\r
231 IN IDE_BLK_IO_DEV *IdeDev,\r
232 IN UINTN TimeoutInMilliSeconds\r
233 );\r
234\r
235/**\r
236 This function is used to poll for the DRQ bit clear in the Alternate\r
237 Status Register. DRQ is cleared when the device is finished\r
238 transferring data. So this function is called after data transfer\r
239 is finished.\r
240\r
241 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used \r
242 to record all the information of the IDE device.\r
243\r
244 @param TimeoutInMilliSeconds used to designate the timeout for the DRQ clear.\r
245\r
246 @retval EFI_SUCCESS DRQ bit clear within the time out.\r
247\r
248 @retval EFI_TIMEOUT DRQ bit not clear within the time out.\r
249 @note\r
250 Read Alternate Status Register will not clear interrupt status.\r
251\r
252**/\r
253EFI_STATUS\r
254DRQClear2 (\r
255 IN IDE_BLK_IO_DEV *IdeDev,\r
256 IN UINTN TimeoutInMilliSeconds\r
257 );\r
258\r
259/**\r
260 This function is used to poll for the DRQ bit set in the\r
261 Status Register.\r
262 DRQ is set when the device is ready to transfer data. So this function\r
263 is called after the command is sent to the device and before required\r
264 data is transferred.\r
265\r
266 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to\r
267 record all the information of the IDE device.\r
268 @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.\r
269\r
270 @retval EFI_SUCCESS DRQ bit set within the time out.\r
271 @retval EFI_TIMEOUT DRQ bit not set within the time out.\r
272 @retval EFI_ABORTED DRQ bit not set caused by the command abort.\r
273\r
274 @note Read Status Register will clear interrupt status.\r
275\r
276**/\r
277EFI_STATUS\r
278DRQReady (\r
279 IN IDE_BLK_IO_DEV *IdeDev,\r
280 IN UINTN TimeoutInMilliSeconds\r
281 );\r
282\r
283/**\r
284 This function is used to poll for the DRQ bit set in the Alternate Status Register.\r
285 DRQ is set when the device is ready to transfer data. So this function is called after \r
286 the command is sent to the device and before required data is transferred.\r
287\r
288 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to \r
289 record all the information of the IDE device.\r
290\r
291 @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.\r
292\r
293 @retval EFI_SUCCESS DRQ bit set within the time out.\r
294 @retval EFI_TIMEOUT DRQ bit not set within the time out.\r
295 @retval EFI_ABORTED DRQ bit not set caused by the command abort.\r
296 @note Read Alternate Status Register will not clear interrupt status.\r
297\r
298**/\r
299EFI_STATUS\r
300DRQReady2 (\r
301 IN IDE_BLK_IO_DEV *IdeDev,\r
302 IN UINTN TimeoutInMilliSeconds\r
303 );\r
304\r
305/**\r
306 This function is used to poll for the BSY bit clear in the Status Register. BSY\r
307 is clear when the device is not busy. Every command must be sent after device is not busy.\r
308\r
309 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used \r
310 to record all the information of the IDE device.\r
311 @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.\r
312\r
313 @retval EFI_SUCCESS BSY bit clear within the time out.\r
314 @retval EFI_TIMEOUT BSY bit not clear within the time out.\r
315\r
316 @note Read Status Register will clear interrupt status.\r
317**/\r
318EFI_STATUS\r
319WaitForBSYClear (\r
320 IN IDE_BLK_IO_DEV *IdeDev,\r
321 IN UINTN TimeoutInMilliSeconds\r
322 );\r
323\r
324/**\r
325 This function is used to poll for the BSY bit clear in the Alternate Status Register. \r
326 BSY is clear when the device is not busy. Every command must be sent after device is \r
327 not busy.\r
328\r
329 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record \r
330 all the information of the IDE device.\r
331 @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.\r
332\r
333 @retval EFI_SUCCESS BSY bit clear within the time out.\r
334 @retval EFI_TIMEOUT BSY bit not clear within the time out.\r
335 @note Read Alternate Status Register will not clear interrupt status.\r
336\r
337**/\r
338EFI_STATUS\r
339WaitForBSYClear2 (\r
340 IN IDE_BLK_IO_DEV *IdeDev,\r
341 IN UINTN TimeoutInMilliSeconds\r
342 );\r
343\r
344/**\r
345 This function is used to poll for the DRDY bit set in the Status Register. DRDY\r
346 bit is set when the device is ready to accept command. Most ATA commands must be \r
347 sent after DRDY set except the ATAPI Packet Command.\r
348\r
349 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used\r
350 to record all the information of the IDE device.\r
351 @param DelayInMilliSeconds used to designate the timeout for the DRQ ready.\r
352\r
353 @retval EFI_SUCCESS DRDY bit set within the time out.\r
354 @retval EFI_TIMEOUT DRDY bit not set within the time out.\r
355\r
356 @note Read Status Register will clear interrupt status.\r
357**/\r
358EFI_STATUS\r
359DRDYReady (\r
360 IN IDE_BLK_IO_DEV *IdeDev,\r
361 IN UINTN DelayInMilliSeconds\r
362 );\r
363\r
364/**\r
365 This function is used to poll for the DRDY bit set in the Alternate Status Register. \r
366 DRDY bit is set when the device is ready to accept command. Most ATA commands must \r
367 be sent after DRDY set except the ATAPI Packet Command.\r
368\r
369 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used\r
370 to record all the information of the IDE device.\r
371 @param DelayInMilliSeconds used to designate the timeout for the DRQ ready.\r
372\r
373 @retval EFI_SUCCESS DRDY bit set within the time out.\r
374 @retval EFI_TIMEOUT DRDY bit not set within the time out.\r
375\r
376 @note Read Alternate Status Register will clear interrupt status.\r
377\r
378**/\r
379EFI_STATUS\r
380DRDYReady2 (\r
381 IN IDE_BLK_IO_DEV *IdeDev,\r
382 IN UINTN DelayInMilliSeconds\r
383 );\r
384\r
385//\r
386// ATA device functions' prototype\r
387//\r
388/**\r
389 Sends out an ATA Identify Command to the specified device.\r
390\r
391 This function is called by DiscoverIdeDevice() during its device\r
392 identification. It sends out the ATA Identify Command to the\r
393 specified device. Only ATA device responses to this command. If\r
394 the command succeeds, it returns the Identify data structure which\r
395 contains information about the device. This function extracts the\r
396 information it needs to fill the IDE_BLK_IO_DEV data structure,\r
397 including device type, media block size, media capacity, and etc.\r
398\r
399 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to record \r
400 all the information of the IDE device.\r
401\r
402 @retval EFI_SUCCESS Identify ATA device successfully.\r
403 @retval EFI_DEVICE_ERROR ATA Identify Device Command failed or device is not ATA device.\r
404 @note parameter IdeDev will be updated in this function.\r
405\r
406**/\r
407EFI_STATUS\r
408ATAIdentify (\r
409 IN IDE_BLK_IO_DEV *IdeDev\r
410 );\r
411\r
412/**\r
413 This function is called by ATAIdentify() or ATAPIIdentify() to print device's module name.\r
414\r
415 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
416 all the information of the IDE device.\r
417**/\r
418VOID\r
419PrintAtaModuleName (\r
420 IN IDE_BLK_IO_DEV *IdeDev\r
421 );\r
422/**\r
423 This function is used to send out ATA commands conforms to the PIO Data In Protocol.\r
424\r
425 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record \r
426 all the information of the IDE device.\r
427 @param Buffer buffer contained data transferred from device to host.\r
428 @param ByteCount data size in byte unit of the buffer.\r
429 @param AtaCommand value of the Command Register\r
430 @param Head value of the Head/Device Register\r
431 @param SectorCount value of the Sector Count Register\r
432 @param SectorNumber value of the Sector Number Register\r
433 @param CylinderLsb value of the low byte of the Cylinder Register\r
434 @param CylinderMsb value of the high byte of the Cylinder Register\r
435 \r
436 @retval EFI_SUCCESS send out the ATA command and device send required data successfully.\r
437 @retval EFI_DEVICE_ERROR command sent failed.\r
438\r
439**/\r
440EFI_STATUS\r
441AtaPioDataIn (\r
442 IN IDE_BLK_IO_DEV *IdeDev,\r
443 IN VOID *Buffer,\r
444 IN UINT32 ByteCount,\r
445 IN UINT8 AtaCommand,\r
446 IN UINT8 Head,\r
447 IN UINT8 SectorCount,\r
448 IN UINT8 SectorNumber,\r
449 IN UINT8 CylinderLsb,\r
450 IN UINT8 CylinderMsb\r
451 );\r
452\r
453/**\r
454 This function is used to send out ATA commands conforms to the\r
455 PIO Data Out Protocol.\r
456\r
457 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used\r
458 to record all the information of the IDE device.\r
459 @param *Buffer buffer contained data transferred from host to device.\r
460 @param ByteCount data size in byte unit of the buffer.\r
461 @param AtaCommand value of the Command Register\r
462 @param Head value of the Head/Device Register\r
463 @param SectorCount value of the Sector Count Register\r
464 @param SectorNumber value of the Sector Number Register\r
465 @param CylinderLsb value of the low byte of the Cylinder Register\r
466 @param CylinderMsb value of the high byte of the Cylinder Register\r
467\r
468 @retval EFI_SUCCESS send out the ATA command and device received required\r
469 data successfully.\r
470 @retval EFI_DEVICE_ERROR command sent failed.\r
471\r
472**/\r
473EFI_STATUS\r
474AtaPioDataOut (\r
475 IN IDE_BLK_IO_DEV *IdeDev,\r
476 IN VOID *Buffer,\r
477 IN UINT32 ByteCount,\r
478 IN UINT8 AtaCommand,\r
479 IN UINT8 Head,\r
480 IN UINT8 SectorCount,\r
481 IN UINT8 SectorNumber,\r
482 IN UINT8 CylinderLsb,\r
483 IN UINT8 CylinderMsb\r
484 );\r
485\r
486/**\r
487 This function is used to analyze the Status Register and print out\r
488 some debug information and if there is ERR bit set in the Status\r
489 Register, the Error Register's value is also be parsed and print out.\r
490\r
491 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to \r
492 record all the information of the IDE device.\r
493\r
494 @retval EFI_SUCCESS No err information in the Status Register.\r
495 @retval EFI_DEVICE_ERROR Any err information in the Status Register.\r
496\r
497**/\r
498EFI_STATUS\r
499CheckErrorStatus (\r
500 IN IDE_BLK_IO_DEV *IdeDev\r
501 );\r
502\r
503/**\r
504 This function is used to implement the Soft Reset on the specified device. But,\r
505 the ATA Soft Reset mechanism is so strong a reset method that it will force \r
506 resetting on both devices connected to the same cable.\r
507\r
508 It is called by IdeBlkIoReset(), a interface function of Block\r
509 I/O protocol.\r
510\r
511 This function can also be used by the ATAPI device to perform reset when\r
512 ATAPI Reset command is failed.\r
513\r
514 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
515 all the information of the IDE device.\r
516 @retval EFI_SUCCESS Soft reset completes successfully.\r
517 @retval EFI_DEVICE_ERROR Any step during the reset process is failed.\r
518\r
519 @note The registers initial values after ATA soft reset are different\r
520 to the ATA device and ATAPI device.\r
521**/\r
522EFI_STATUS\r
523AtaSoftReset (\r
524 IN IDE_BLK_IO_DEV *IdeDev\r
525 );\r
526\r
527/**\r
528 This function is the ATA implementation for ReadBlocks in the\r
529 Block I/O Protocol interface.\r
530\r
531 @param IdeBlkIoDevice Indicates the calling context.\r
532 @param MediaId The media id that the read request is for.\r
533 @param Lba The starting logical block address to read from on the device.\r
534 @param BufferSize The size of the Buffer in bytes. This must be a multiple\r
535 of the intrinsic block size of the device.\r
536\r
537 @param Buffer A pointer to the destination buffer for the data. The caller\r
538 is responsible for either having implicit or explicit ownership\r
539 of the memory that data is read into.\r
540\r
541 @retval EFI_SUCCESS Read Blocks successfully.\r
542 @retval EFI_DEVICE_ERROR Read Blocks failed.\r
543 @retval EFI_NO_MEDIA There is no media in the device.\r
544 @retval EFI_MEDIA_CHANGE The MediaId is not for the current media.\r
545 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the\r
546 intrinsic block size of the device.\r
547 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
548 or the data buffer is not valid.\r
549\r
550 @note If Read Block error because of device error, this function will call\r
551 AtaSoftReset() function to reset device.\r
552\r
553**/\r
554EFI_STATUS\r
555AtaBlkIoReadBlocks (\r
556 IN IDE_BLK_IO_DEV *IdeBlkIoDevice,\r
557 IN UINT32 MediaId,\r
558 IN EFI_LBA Lba,\r
559 IN UINTN BufferSize,\r
560 OUT VOID *Buffer\r
561 );\r
562\r
563/**\r
564 This function is the ATA implementation for WriteBlocks in the\r
565 Block I/O Protocol interface.\r
566\r
567 @param IdeBlkIoDevice Indicates the calling context.\r
568 @param MediaId The media id that the write request is for.\r
569 @param Lba The starting logical block address to write onto the device.\r
570 @param BufferSize The size of the Buffer in bytes. This must be a multiple\r
571 of the intrinsic block size of the device.\r
572 @param Buffer A pointer to the source buffer for the data.The caller\r
573 is responsible for either having implicit or explicit \r
574 ownership of the memory that data is written from.\r
575\r
576 @retval EFI_SUCCESS Write Blocks successfully.\r
577 @retval EFI_DEVICE_ERROR Write Blocks failed.\r
578 @retval EFI_NO_MEDIA There is no media in the device.\r
579 @retval EFI_MEDIA_CHANGE The MediaId is not for the current media.\r
580\r
581 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the\r
582 intrinsic block size of the device.\r
583 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
584 or the data buffer is not valid.\r
585\r
586 @note If Write Block error because of device error, this function will call\r
587 AtaSoftReset() function to reset device.\r
588**/\r
589EFI_STATUS\r
590AtaBlkIoWriteBlocks (\r
591 IN IDE_BLK_IO_DEV *IdeBlkIoDevice,\r
592 IN UINT32 MediaId,\r
593 IN EFI_LBA Lba,\r
594 IN UINTN BufferSize,\r
595 OUT VOID *Buffer\r
596 );\r
597\r
598/**\r
599 This function is called by DiscoverIdeDevice() during its device\r
600 identification.\r
601 Its main purpose is to get enough information for the device media\r
602 to fill in the Media data structure of the Block I/O Protocol interface.\r
603\r
604 There are 5 steps to reach such objective:\r
605 1. Sends out the ATAPI Identify Command to the specified device. \r
606 Only ATAPI device responses to this command. If the command succeeds,\r
607 it returns the Identify data structure which filled with information \r
608 about the device. Since the ATAPI device contains removable media, \r
609 the only meaningful information is the device module name.\r
610 2. Sends out ATAPI Inquiry Packet Command to the specified device.\r
611 This command will return inquiry data of the device, which contains\r
612 the device type information.\r
613 3. Allocate sense data space for future use. We don't detect the media\r
614 presence here to improvement boot performance, especially when CD \r
615 media is present. The media detection will be performed just before\r
616 each BLK_IO read/write\r
617 \r
618 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used\r
619 to record all the information of the IDE device.\r
620\r
621 @retval EFI_SUCCESS Identify ATAPI device successfully.\r
622 @retval EFI_DEVICE_ERROR ATAPI Identify Device Command failed or device type\r
623 is not supported by this IDE driver.\r
624 @retval EFI_OUT_OF_RESOURCES Allocate memory for sense data failed \r
625\r
626 @note Parameter "IdeDev" will be updated in this function.\r
627**/\r
628EFI_STATUS\r
629ATAPIIdentify (\r
630 IN IDE_BLK_IO_DEV *IdeDev\r
631 );\r
632\r
633/**\r
634 This function is used to implement the Soft Reset on the specified\r
635 ATAPI device. Different from the AtaSoftReset(), here reset is a ATA\r
636 Soft Reset Command special for ATAPI device, and it only take effects\r
637 on the specified ATAPI device, not on the whole IDE bus.\r
638 Since the ATAPI soft reset is needed when device is in exceptional\r
639 condition (such as BSY bit is always set ), I think the Soft Reset\r
640 command should be sent without waiting for the BSY clear and DRDY\r
641 set.\r
642 This function is called by IdeBlkIoReset(), \r
643 a interface function of Block I/O protocol.\r
644\r
645 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used\r
646 to record all the information of the IDE device.\r
647\r
648 @retval EFI_SUCCESS Soft reset completes successfully.\r
649 @retval EFI_DEVICE_ERROR Any step during the reset process is failed.\r
650\r
651**/\r
652EFI_STATUS\r
653AtapiSoftReset (\r
654 IN IDE_BLK_IO_DEV *IdeDev\r
655 );\r
656\r
657/**\r
658 This function is the ATAPI implementation for ReadBlocks in the\r
659 Block I/O Protocol interface.\r
660\r
661 @param IdeBlkIoDevice Indicates the calling context.\r
662 @param MediaId The media id that the read request is for.\r
663 @param Lba The starting logical block address to read from on the device.\r
664 @param BufferSize The size of the Buffer in bytes. This must be a multiple\r
665 of the intrinsic block size of the device.\r
666 @param Buffer A pointer to the destination buffer for the data. The caller\r
667 is responsible for either having implicit or explicit \r
668 ownership of the memory that data is read into.\r
669 \r
670 @retval EFI_SUCCESS Read Blocks successfully.\r
671 @retval EFI_DEVICE_ERROR Read Blocks failed.\r
672 @retval EFI_NO_MEDIA There is no media in the device.\r
673 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
674 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the\r
675 intrinsic block size of the device.\r
676 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,\r
677 or the data buffer is not valid.\r
678**/\r
679EFI_STATUS\r
680AtapiBlkIoReadBlocks (\r
681 IN IDE_BLK_IO_DEV *IdeBlkIoDevice,\r
682 IN UINT32 MediaId,\r
683 IN EFI_LBA Lba,\r
684 IN UINTN BufferSize,\r
685 OUT VOID *Buffer\r
686 );\r
687\r
688/**\r
689 This function is the ATAPI implementation for WriteBlocks in the\r
690 Block I/O Protocol interface.\r
691\r
692 @param IdeBlkIoDevice Indicates the calling context.\r
693 @param MediaId The media id that the write request is for.\r
694 @param Lba The starting logical block address to write onto the device.\r
695 @param BufferSize The size of the Buffer in bytes. This must be a multiple\r
696 of the intrinsic block size of the device.\r
697 @param Buffer A pointer to the source buffer for the data. The caller\r
698 is responsible for either having implicit or explicit ownership\r
699 of the memory that data is written from.\r
700\r
701 @retval EFI_SUCCESS Write Blocks successfully.\r
702 @retval EFI_DEVICE_ERROR Write Blocks failed.\r
703 @retval EFI_NO_MEDIA There is no media in the device.\r
704 @retval EFI_MEDIA_CHANGE The MediaId is not for the current media.\r
705 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the\r
706 intrinsic block size of the device. \r
707 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid, \r
708 or the data buffer is not valid.\r
709\r
710 @retval EFI_WRITE_PROTECTED The write protected is enabled or the media does not support write\r
711**/\r
712EFI_STATUS\r
713AtapiBlkIoWriteBlocks (\r
714 IN IDE_BLK_IO_DEV *IdeBlkIoDevice,\r
715 IN UINT32 MediaId,\r
716 IN EFI_LBA Lba,\r
717 IN UINTN BufferSize,\r
718 OUT VOID *Buffer\r
719 );\r
720\r
721/**\r
722 Release resources of an IDE device before stopping it.\r
723\r
724 @param IdeBlkIoDevice Standard IDE device private data structure\r
725\r
726**/\r
727VOID\r
728ReleaseIdeResources (\r
729 IN IDE_BLK_IO_DEV *IdeBlkIoDevice\r
730 );\r
731\r
732/**\r
733 Set the calculated Best transfer mode to a detected device\r
734\r
735 @param IdeDev Standard IDE device private data structure\r
736 @param TransferMode The device transfer mode to be set\r
737 @return Set transfer mode Command execute status.\r
738**/\r
739EFI_STATUS\r
740SetDeviceTransferMode (\r
741 IN IDE_BLK_IO_DEV *IdeDev,\r
742 IN ATA_TRANSFER_MODE *TransferMode\r
743 );\r
744/**\r
745 Send ATA command into device with NON_DATA protocol.\r
746\r
747 @param IdeDev Standard IDE device private data structure\r
748 @param AtaCommand The ATA command to be sent\r
749 @param Device The value in Device register\r
750 @param Feature The value in Feature register\r
751 @param SectorCount The value in SectorCount register\r
752 @param LbaLow The value in LBA_LOW register\r
753 @param LbaMiddle The value in LBA_MIDDLE register\r
754 @param LbaHigh The value in LBA_HIGH register\r
755\r
756 @retval EFI_SUCCESS Reading succeed\r
757 @retval EFI_ABORTED Command failed\r
758 @retval EFI_DEVICE_ERROR Device status error.\r
759\r
760**/\r
761EFI_STATUS\r
762AtaNonDataCommandIn (\r
763 IN IDE_BLK_IO_DEV *IdeDev,\r
764 IN UINT8 AtaCommand,\r
765 IN UINT8 Device,\r
766 IN UINT8 Feature,\r
767 IN UINT8 SectorCount,\r
768 IN UINT8 LbaLow,\r
769 IN UINT8 LbaMiddle,\r
770 IN UINT8 LbaHigh\r
771 );\r
772\r
773/**\r
774 Send ATA Ext command into device with NON_DATA protocol.\r
775\r
776 @param IdeDev Standard IDE device private data structure\r
777 @param AtaCommand The ATA command to be sent\r
778 @param Device The value in Device register\r
779 @param Feature The value in Feature register\r
780 @param SectorCount The value in SectorCount register\r
781 @param LbaAddress The Lba address in 48-bit mode\r
782\r
783 @retval EFI_SUCCESS Reading succeed\r
784 @retval EFI_ABORTED Command failed\r
785 @retval EFI_DEVICE_ERROR Device status error.\r
786\r
787**/\r
788EFI_STATUS\r
789AtaNonDataCommandInExt (\r
790 IN IDE_BLK_IO_DEV *IdeDev,\r
791 IN UINT8 AtaCommand,\r
792 IN UINT8 Device,\r
793 IN UINT16 Feature,\r
794 IN UINT16 SectorCount,\r
795 IN EFI_LBA LbaAddress\r
796 );\r
797/**\r
798 Enable Long Physical Sector Feature for ATA device.\r
799\r
800 @param IdeDev The IDE device data\r
801\r
802 @retval EFI_SUCCESS The ATA device supports Long Physical Sector feature\r
803 and corresponding fields in BlockIo structure is updated.\r
804 @retval EFI_UNSUPPORTED The device is not ATA device or Long Physical Sector\r
805 feature is not supported.\r
806**/\r
807EFI_STATUS\r
808AtaEnableLongPhysicalSector (\r
809 IN IDE_BLK_IO_DEV *IdeDev\r
810 );\r
811\r
812/**\r
813 Set drive parameters for devices not support PACKETS command.\r
814\r
815 @param IdeDev Standard IDE device private data structure\r
816 @param DriveParameters The device parameters to be set into the disk\r
817 @return SetParameters Command execute status.\r
818\r
819**/\r
820EFI_STATUS\r
821SetDriveParameters (\r
822 IN IDE_BLK_IO_DEV *IdeDev,\r
823 IN ATA_DRIVE_PARMS *DriveParameters\r
824 );\r
825\r
826/**\r
827 Enable Interrupt on IDE controller\r
828\r
829 @param IdeDev Standard IDE device private data structure\r
830\r
831 @retval EFI_SUCCESS Enable Interrupt successfully\r
832**/\r
833EFI_STATUS\r
834EnableInterrupt (\r
835 IN IDE_BLK_IO_DEV *IdeDev\r
836 );\r
837#endif\r