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