]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/Ide.h
IntelFrameworkModulePkg IdeBusDxe: Remove redundant functions
[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 - 2018, Intel Corporation. All rights reserved.<BR>\r
6 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**/\r
205VOID\r
206InitializeIDEChannelData (\r
207 VOID\r
208 );\r
209\r
210/**\r
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
214\r
215 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used\r
216 to record all the information of the IDE device.\r
217 @param TimeoutInMilliSeconds used to designate the timeout for the DRQ clear.\r
218\r
219 @retval EFI_SUCCESS DRQ bit clear within the time out.\r
220\r
221 @retval EFI_TIMEOUT DRQ bit not clear within the time out.\r
222\r
223 @note\r
224 Read Status Register will clear interrupt status.\r
225\r
226**/\r
227EFI_STATUS\r
228DRQClear (\r
229 IN IDE_BLK_IO_DEV *IdeDev,\r
230 IN UINTN TimeoutInMilliSeconds\r
231 );\r
232\r
233/**\r
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
238\r
239 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used\r
240 to record all the information of the IDE device.\r
241\r
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
249\r
250**/\r
251EFI_STATUS\r
252DRQClear2 (\r
253 IN IDE_BLK_IO_DEV *IdeDev,\r
254 IN UINTN TimeoutInMilliSeconds\r
255 );\r
256\r
257/**\r
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
267\r
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
271\r
272 @note Read Status Register will clear interrupt status.\r
273\r
274**/\r
275EFI_STATUS\r
276DRQReady (\r
277 IN IDE_BLK_IO_DEV *IdeDev,\r
278 IN UINTN TimeoutInMilliSeconds\r
279 );\r
280\r
281/**\r
282 This function is used to poll for the DRQ bit set in the Alternate Status Register.\r
283 DRQ is set when the device is ready to transfer data. So this function is called after\r
284 the command is sent to the device and before required data is transferred.\r
285\r
286 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to\r
287 record all the information of the IDE device.\r
288\r
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
295\r
296**/\r
297EFI_STATUS\r
298DRQReady2 (\r
299 IN IDE_BLK_IO_DEV *IdeDev,\r
300 IN UINTN TimeoutInMilliSeconds\r
301 );\r
302\r
303/**\r
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
306\r
307 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used\r
308 to record all the information of the IDE device.\r
309 @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.\r
310\r
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
313\r
314 @note Read Status Register will clear interrupt status.\r
315**/\r
316EFI_STATUS\r
317WaitForBSYClear (\r
318 IN IDE_BLK_IO_DEV *IdeDev,\r
319 IN UINTN TimeoutInMilliSeconds\r
320 );\r
321\r
322/**\r
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
325 not busy.\r
326\r
327 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
328 all the information of the IDE device.\r
329 @param TimeoutInMilliSeconds used to designate the timeout for the DRQ ready.\r
330\r
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
334\r
335**/\r
336EFI_STATUS\r
337WaitForBSYClear2 (\r
338 IN IDE_BLK_IO_DEV *IdeDev,\r
339 IN UINTN TimeoutInMilliSeconds\r
340 );\r
341\r
342/**\r
343 This function is used to poll for the DRDY bit set in the Status Register. DRDY\r
344 bit is set when the device is ready to accept command. Most ATA commands must be\r
345 sent after DRDY set except the ATAPI Packet Command.\r
346\r
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
350\r
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
353\r
354 @note Read Status Register will clear interrupt status.\r
355**/\r
356EFI_STATUS\r
357DRDYReady (\r
358 IN IDE_BLK_IO_DEV *IdeDev,\r
359 IN UINTN DelayInMilliSeconds\r
360 );\r
361\r
362/**\r
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
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
370\r
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
373\r
374 @note Read Alternate Status Register will clear interrupt status.\r
375\r
376**/\r
377EFI_STATUS\r
378DRDYReady2 (\r
379 IN IDE_BLK_IO_DEV *IdeDev,\r
380 IN UINTN DelayInMilliSeconds\r
381 );\r
382\r
383//\r
384// ATA device functions' prototype\r
385//\r
386/**\r
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
396\r
397 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure,used to record\r
398 all the information of the IDE device.\r
399\r
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
403\r
404**/\r
405EFI_STATUS\r
406ATAIdentify (\r
407 IN IDE_BLK_IO_DEV *IdeDev\r
408 );\r
409\r
410/**\r
411 This function is called by ATAIdentify() or ATAPIIdentify() to print device's module name.\r
412\r
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
415**/\r
416VOID\r
417PrintAtaModuleName (\r
418 IN IDE_BLK_IO_DEV *IdeDev\r
419 );\r
420/**\r
421 This function is used to send out ATA commands conforms to the PIO Data In Protocol.\r
422\r
423 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to record\r
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
433\r
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
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
449 );\r
450\r
451/**\r
452 This function is used to send out ATA commands conforms to the\r
453 PIO Data Out Protocol.\r
454\r
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
465\r
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
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
482 );\r
483\r
484/**\r
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
488\r
489 @param IdeDev pointer pointing to IDE_BLK_IO_DEV data structure, used to\r
490 record all the information of the IDE device.\r
491\r
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
494\r
495**/\r
496EFI_STATUS\r
497CheckErrorStatus (\r
498 IN IDE_BLK_IO_DEV *IdeDev\r
499 );\r
500\r
501/**\r
502 This function is used to implement the Soft Reset on the specified device. But,\r
503 the ATA Soft Reset mechanism is so strong a reset method that it will force\r
504 resetting on both devices connected to the same cable.\r
505\r
506 It is called by IdeBlkIoReset(), a interface function of Block\r
507 I/O protocol.\r
508\r
509 This function can also be used by the ATAPI device to perform reset when\r
510 ATAPI Reset command is failed.\r
511\r
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
516\r
517 @note The registers initial values after ATA soft reset are different\r
518 to the ATA device and ATAPI device.\r
519**/\r
520EFI_STATUS\r
521AtaSoftReset (\r
522 IN IDE_BLK_IO_DEV *IdeDev\r
523 );\r
524\r
525/**\r
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
531 @param Lba The starting logical block address to read from on the device.\r
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
534\r
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
538\r
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
550\r
551**/\r
552EFI_STATUS\r
553AtaBlkIoReadBlocks (\r
554 IN IDE_BLK_IO_DEV *IdeBlkIoDevice,\r
555 IN UINT32 MediaId,\r
556 IN EFI_LBA Lba,\r
557 IN UINTN BufferSize,\r
558 OUT VOID *Buffer\r
559 );\r
560\r
561/**\r
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
567 @param Lba The starting logical block address to write onto the device.\r
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
571 is responsible for either having implicit or explicit\r
572 ownership of the memory that data is written from.\r
573\r
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
578\r
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
583\r
584 @note If Write Block error because of device error, this function will call\r
585 AtaSoftReset() function to reset device.\r
586**/\r
587EFI_STATUS\r
588AtaBlkIoWriteBlocks (\r
589 IN IDE_BLK_IO_DEV *IdeBlkIoDevice,\r
590 IN UINT32 MediaId,\r
591 IN EFI_LBA Lba,\r
592 IN UINTN BufferSize,\r
593 OUT VOID *Buffer\r
594 );\r
595\r
596/**\r
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
603 1. Sends out the ATAPI Identify Command to the specified device.\r
604 Only ATAPI device responses to this command. If the command succeeds,\r
605 it returns the Identify data structure which filled with information\r
606 about the device. Since the ATAPI device contains removable media,\r
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
612 presence here to improvement boot performance, especially when CD\r
613 media is present. The media detection will be performed just before\r
614 each BLK_IO read/write\r
615\r
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
618\r
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
622 @retval EFI_OUT_OF_RESOURCES Allocate memory for sense data failed\r
623\r
624 @note Parameter "IdeDev" will be updated in this function.\r
625**/\r
626EFI_STATUS\r
627ATAPIIdentify (\r
628 IN IDE_BLK_IO_DEV *IdeDev\r
629 );\r
630\r
631/**\r
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
640 This function is called by IdeBlkIoReset(),\r
641 a interface function of Block I/O protocol.\r
642\r
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
645\r
646 @retval EFI_SUCCESS Soft reset completes successfully.\r
647 @retval EFI_DEVICE_ERROR Any step during the reset process is failed.\r
648\r
649**/\r
650EFI_STATUS\r
651AtapiSoftReset (\r
652 IN IDE_BLK_IO_DEV *IdeDev\r
653 );\r
654\r
655/**\r
656 This function is the ATAPI implementation for ReadBlocks in the\r
657 Block I/O Protocol interface.\r
658\r
659 @param IdeBlkIoDevice Indicates the calling context.\r
660 @param MediaId The media id that the read request is for.\r
661 @param Lba The starting logical block address to read from on the device.\r
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
665 is responsible for either having implicit or explicit\r
666 ownership of the memory that data is read into.\r
667\r
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
676**/\r
677EFI_STATUS\r
678AtapiBlkIoReadBlocks (\r
679 IN IDE_BLK_IO_DEV *IdeBlkIoDevice,\r
680 IN UINT32 MediaId,\r
681 IN EFI_LBA Lba,\r
682 IN UINTN BufferSize,\r
683 OUT VOID *Buffer\r
684 );\r
685\r
686/**\r
687 This function is the ATAPI implementation for WriteBlocks in the\r
688 Block I/O Protocol interface.\r
689\r
690 @param IdeBlkIoDevice Indicates the calling context.\r
691 @param MediaId The media id that the write request is for.\r
692 @param Lba The starting logical block address to write onto the device.\r
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
698\r
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
704 intrinsic block size of the device.\r
705 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,\r
706 or the data buffer is not valid.\r
707\r
708 @retval EFI_WRITE_PROTECTED The write protected is enabled or the media does not support write\r
709**/\r
710EFI_STATUS\r
711AtapiBlkIoWriteBlocks (\r
712 IN IDE_BLK_IO_DEV *IdeBlkIoDevice,\r
713 IN UINT32 MediaId,\r
714 IN EFI_LBA Lba,\r
715 IN UINTN BufferSize,\r
716 OUT VOID *Buffer\r
717 );\r
718\r
719/**\r
720 Release resources of an IDE device before stopping it.\r
721\r
722 @param IdeBlkIoDevice Standard IDE device private data structure\r
723\r
724**/\r
725VOID\r
726ReleaseIdeResources (\r
727 IN IDE_BLK_IO_DEV *IdeBlkIoDevice\r
728 );\r
729\r
730/**\r
731 Set the calculated Best transfer mode to a detected device\r
732\r
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
736**/\r
737EFI_STATUS\r
738SetDeviceTransferMode (\r
739 IN IDE_BLK_IO_DEV *IdeDev,\r
740 IN ATA_TRANSFER_MODE *TransferMode\r
741 );\r
742/**\r
743 Send ATA command into device with NON_DATA protocol.\r
744\r
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
753\r
754 @retval EFI_SUCCESS Reading succeed\r
755 @retval EFI_ABORTED Command failed\r
756 @retval EFI_DEVICE_ERROR Device status error.\r
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
769 );\r
770\r
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
786/**\r
787 Set drive parameters for devices not support PACKETS command.\r
788\r
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
792\r
793**/\r
794EFI_STATUS\r
795SetDriveParameters (\r
796 IN IDE_BLK_IO_DEV *IdeDev,\r
797 IN ATA_DRIVE_PARMS *DriveParameters\r
798 );\r
799\r
800/**\r
801 Enable Interrupt on IDE controller.\r
802\r
803 @param IdeDev Standard IDE device private data structure\r
804\r
805 @retval EFI_SUCCESS Enable Interrupt successfully\r
806**/\r
807EFI_STATUS\r
808EnableInterrupt (\r
809 IN IDE_BLK_IO_DEV *IdeDev\r
810 );\r
811#endif\r