]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Pci/IdeBusPei/AtapiPeim.h
MdeModulePkg: Add IdeBusPei driver
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / IdeBusPei / AtapiPeim.h
CommitLineData
ea060cfa 1/** @file\r
2Private Include file for IdeBus PEIM.\r
3\r
4Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
5\r
6This program and the accompanying materials\r
7are licensed and made available under the terms and conditions\r
8of the BSD License which accompanies this distribution. The\r
9full text of the license may be found at\r
10http://opensource.org/licenses/bsd-license.php\r
11\r
12THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17#ifndef _RECOVERY_ATAPI_H_\r
18#define _RECOVERY_ATAPI_H_\r
19\r
20#include <PiPei.h>\r
21\r
22#include <Ppi/BlockIo.h>\r
23#include <Ppi/AtaController.h>\r
24\r
25#include <Library/DebugLib.h>\r
26#include <Library/TimerLib.h>\r
27#include <Library/PeimEntryPoint.h>\r
28#include <Library/PeiServicesLib.h>\r
29#include <Library/BaseMemoryLib.h>\r
30#include <Library/IoLib.h>\r
31#include <Library/PeiServicesTablePointerLib.h>\r
32#include <Library/MemoryAllocationLib.h>\r
33#include <Library/PcdLib.h>\r
34\r
35\r
36#include <IndustryStandard/Atapi.h>\r
37\r
38#define MAX_SENSE_KEY_COUNT 6\r
39#define MAX_IDE_CHANNELS 4 // Ide and Sata Primary, Secondary Channel.\r
40#define MAX_IDE_DEVICES 8 // Ide, Sata Primary, Secondary and Master, Slave device.\r
41\r
42typedef enum {\r
43 IdePrimary = 0,\r
44 IdeSecondary = 1,\r
45 IdeMaxChannel = 2\r
46} EFI_IDE_CHANNEL;\r
47\r
48typedef enum {\r
49 IdeMaster = 0,\r
50 IdeSlave = 1,\r
51 IdeMaxDevice = 2\r
52} EFI_IDE_DEVICE;\r
53\r
54//\r
55// IDE Registers\r
56//\r
57typedef union {\r
58 UINT16 Command; /* when write */\r
59 UINT16 Status; /* when read */\r
60} IDE_CMD_OR_STATUS;\r
61\r
62typedef union {\r
63 UINT16 Error; /* when read */\r
64 UINT16 Feature; /* when write */\r
65} IDE_ERROR_OR_FEATURE;\r
66\r
67typedef union {\r
68 UINT16 AltStatus; /* when read */\r
69 UINT16 DeviceControl; /* when write */\r
70} IDE_ALTSTATUS_OR_DEVICECONTROL;\r
71\r
72//\r
73// IDE registers set\r
74//\r
75typedef struct {\r
76 UINT16 Data;\r
77 IDE_ERROR_OR_FEATURE Reg1;\r
78 UINT16 SectorCount;\r
79 UINT16 SectorNumber;\r
80 UINT16 CylinderLsb;\r
81 UINT16 CylinderMsb;\r
82 UINT16 Head;\r
83 IDE_CMD_OR_STATUS Reg;\r
84\r
85 IDE_ALTSTATUS_OR_DEVICECONTROL Alt;\r
86 UINT16 DriveAddress;\r
87} IDE_BASE_REGISTERS;\r
88\r
89typedef struct {\r
90\r
91 UINTN DevicePosition;\r
92 EFI_PEI_BLOCK_IO_MEDIA MediaInfo;\r
93\r
94} PEI_ATAPI_DEVICE_INFO;\r
95\r
96#define ATAPI_BLK_IO_DEV_SIGNATURE SIGNATURE_32 ('a', 'b', 'i', 'o')\r
97typedef struct {\r
98 UINTN Signature;\r
99\r
100 EFI_PEI_RECOVERY_BLOCK_IO_PPI AtapiBlkIo;\r
101 EFI_PEI_PPI_DESCRIPTOR PpiDescriptor;\r
102 PEI_ATA_CONTROLLER_PPI *AtaControllerPpi;\r
103\r
104 UINTN DeviceCount;\r
105 PEI_ATAPI_DEVICE_INFO DeviceInfo[MAX_IDE_DEVICES]; //for max 8 device\r
106 IDE_BASE_REGISTERS IdeIoPortReg[MAX_IDE_CHANNELS]; //for max 4 channel.\r
107} ATAPI_BLK_IO_DEV;\r
108\r
109#define PEI_RECOVERY_ATAPI_FROM_BLKIO_THIS(a) CR (a, ATAPI_BLK_IO_DEV, AtapiBlkIo, ATAPI_BLK_IO_DEV_SIGNATURE)\r
110\r
111\r
112#define STALL_1_MILLI_SECOND 1000 // stall 1 ms\r
113#define STALL_1_SECONDS 1000 * STALL_1_MILLI_SECOND\r
114\r
115//\r
116// Time Out Value For IDE Device Polling\r
117//\r
118// ATATIMEOUT is used for waiting time out for ATA device\r
119//\r
120#define ATATIMEOUT 1000 // 1 second\r
121// ATAPITIMEOUT is used for waiting operation\r
122// except read and write time out for ATAPI device\r
123//\r
124#define ATAPITIMEOUT 1000 // 1 second\r
125// ATAPILONGTIMEOUT is used for waiting read and\r
126// write operation timeout for ATAPI device\r
127//\r
128#define CDROMLONGTIMEOUT 2000 // 2 seconds\r
129#define ATAPILONGTIMEOUT 5000 // 5 seconds\r
130\r
131//\r
132// PEI Recovery Block I/O PPI\r
133//\r
134\r
135/**\r
136 Gets the count of block I/O devices that one specific block driver detects.\r
137\r
138 This function is used for getting the count of block I/O devices that one \r
139 specific block driver detects. To the PEI ATAPI driver, it returns the number\r
140 of all the detected ATAPI devices it detects during the enumeration process. \r
141 To the PEI legacy floppy driver, it returns the number of all the legacy \r
142 devices it finds during its enumeration process. If no device is detected, \r
143 then the function will return zero. \r
144 \r
145 @param[in] PeiServices General-purpose services that are available \r
146 to every PEIM.\r
147 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI \r
148 instance.\r
149 @param[out] NumberBlockDevices The number of block I/O devices discovered.\r
150\r
151 @retval EFI_SUCCESS Operation performed successfully.\r
152\r
153**/\r
154EFI_STATUS\r
155EFIAPI\r
156AtapiGetNumberOfBlockDevices (\r
157 IN EFI_PEI_SERVICES **PeiServices,\r
158 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,\r
159 OUT UINTN *NumberBlockDevices\r
160 );\r
161\r
162/**\r
163 Gets a block device's media information.\r
164\r
165 This function will provide the caller with the specified block device's media \r
166 information. If the media changes, calling this function will update the media \r
167 information accordingly.\r
168\r
169 @param[in] PeiServices General-purpose services that are available to every\r
170 PEIM\r
171 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI instance.\r
172 @param[in] DeviceIndex Specifies the block device to which the function wants \r
173 to talk. Because the driver that implements Block I/O \r
174 PPIs will manage multiple block devices, the PPIs that \r
175 want to talk to a single device must specify the \r
176 device index that was assigned during the enumeration\r
177 process. This index is a number from one to \r
178 NumberBlockDevices.\r
179 @param[out] MediaInfo The media information of the specified block media. \r
180 The caller is responsible for the ownership of this \r
181 data structure.\r
182 \r
183 @retval EFI_SUCCESS Media information about the specified block device \r
184 was obtained successfully.\r
185 @retval EFI_DEVICE_ERROR Cannot get the media information due to a hardware \r
186 error.\r
187 @retval Others Other failure occurs.\r
188\r
189**/\r
190EFI_STATUS\r
191EFIAPI\r
192AtapiGetBlockDeviceMediaInfo (\r
193 IN EFI_PEI_SERVICES **PeiServices,\r
194 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,\r
195 IN UINTN DeviceIndex,\r
196 OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo\r
197 );\r
198\r
199/**\r
200 Reads the requested number of blocks from the specified block device.\r
201\r
202 The function reads the requested number of blocks from the device. All the \r
203 blocks are read, or an error is returned. If there is no media in the device,\r
204 the function returns EFI_NO_MEDIA.\r
205\r
206 @param[in] PeiServices General-purpose services that are available to \r
207 every PEIM.\r
208 @param[in] This Indicates the EFI_PEI_RECOVERY_BLOCK_IO_PPI instance.\r
209 @param[in] DeviceIndex Specifies the block device to which the function wants \r
210 to talk. Because the driver that implements Block I/O \r
211 PPIs will manage multiple block devices, the PPIs that \r
212 want to talk to a single device must specify the device \r
213 index that was assigned during the enumeration process. \r
214 This index is a number from one to NumberBlockDevices.\r
215 @param[in] StartLBA The starting logical block address (LBA) to read from\r
216 on the device\r
217 @param[in] BufferSize The size of the Buffer in bytes. This number must be\r
218 a multiple of the intrinsic block size of the device.\r
219 @param[out] Buffer A pointer to the destination buffer for the data.\r
220 The caller is responsible for the ownership of the \r
221 buffer.\r
222 \r
223 @retval EFI_SUCCESS The data was read correctly from the device.\r
224 @retval EFI_DEVICE_ERROR The device reported an error while attempting \r
225 to perform the read operation.\r
226 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not \r
227 valid, or the buffer is not properly aligned.\r
228 @retval EFI_NO_MEDIA There is no media in the device.\r
229 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of\r
230 the intrinsic block size of the device.\r
231\r
232**/\r
233EFI_STATUS\r
234EFIAPI\r
235AtapiReadBlocks (\r
236 IN EFI_PEI_SERVICES **PeiServices,\r
237 IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This,\r
238 IN UINTN DeviceIndex,\r
239 IN EFI_PEI_LBA StartLBA,\r
240 IN UINTN BufferSize,\r
241 OUT VOID *Buffer\r
242 );\r
243\r
244//\r
245// Internal functions\r
246//\r
247\r
248/**\r
249 Enumerate Atapi devices.\r
250\r
251 This function is used to enumerate Atatpi device in Ide channel.\r
252\r
253 @param[in] AtapiBlkIoDev A pointer to atapi block IO device\r
254\r
255**/\r
256VOID\r
257AtapiEnumerateDevices (\r
258 IN ATAPI_BLK_IO_DEV *AtapiBlkIoDev\r
259 );\r
260\r
261/**\r
262 Detect Atapi devices.\r
263 \r
264 @param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
265 @param[in] DevicePosition An integer to signify device position.\r
266 @param[out] MediaInfo The media information of the specified block media.\r
267\r
268 @retval TRUE Atapi device exists in specified position.\r
269 @retval FALSE Atapi device does not exist in specified position.\r
270\r
271**/\r
272BOOLEAN\r
273DiscoverAtapiDevice (\r
274 IN ATAPI_BLK_IO_DEV *AtapiBlkIoDev,\r
275 IN UINTN DevicePosition,\r
276 OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo\r
277 );\r
278\r
279/**\r
280 Detect if an IDE controller exists in specified position.\r
281 \r
282 @param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
283 @param[in] DevicePosition An integer to signify device position.\r
284\r
285 @retval TRUE The Atapi device exists.\r
286 @retval FALSE The Atapi device does not present.\r
287\r
288**/\r
289BOOLEAN\r
290DetectIDEController (\r
291 IN ATAPI_BLK_IO_DEV *AtapiBlkIoDev,\r
292 IN UINTN DevicePosition\r
293 );\r
294\r
295/**\r
296 Wait specified time interval to poll for BSY bit clear in the Status Register.\r
297 \r
298 @param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
299 @param[in] IdeIoRegisters A pointer to IDE IO registers.\r
300 @param[in] TimeoutInMilliSeconds Time specified in milliseconds.\r
301\r
302 @retval EFI_SUCCESS BSY bit is cleared in the specified time interval.\r
303 @retval EFI_TIMEOUT BSY bit is not cleared in the specified time interval.\r
304\r
305**/\r
306EFI_STATUS\r
307WaitForBSYClear (\r
308 IN ATAPI_BLK_IO_DEV *AtapiBlkIoDev,\r
309 IN IDE_BASE_REGISTERS *IdeIoRegisters,\r
310 IN UINTN TimeoutInMilliSeconds\r
311 );\r
312\r
313/**\r
314 Wait specified time interval to poll for DRDY bit set in the Status register.\r
315 \r
316 @param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
317 @param[in] IdeIoRegisters A pointer to IDE IO registers.\r
318 @param[in] TimeoutInMilliSeconds Time specified in milliseconds.\r
319\r
320 @retval EFI_SUCCESS DRDY bit is set in the specified time interval.\r
321 @retval EFI_TIMEOUT DRDY bit is not set in the specified time interval.\r
322\r
323**/\r
324EFI_STATUS\r
325DRDYReady (\r
326 IN ATAPI_BLK_IO_DEV *AtapiBlkIoDev,\r
327 IN IDE_BASE_REGISTERS *IdeIoRegisters,\r
328 IN UINTN TimeoutInMilliSeconds\r
329 );\r
330\r
331/**\r
332 Wait specified time interval to poll for DRQ bit clear in the Status Register.\r
333 \r
334 @param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
335 @param[in] IdeIoRegisters A pointer to IDE IO registers.\r
336 @param[in] TimeoutInMilliSeconds Time specified in milliseconds.\r
337\r
338 @retval EFI_SUCCESS DRQ bit is cleared in the specified time interval.\r
339 @retval EFI_TIMEOUT DRQ bit is not cleared in the specified time interval.\r
340\r
341**/\r
342EFI_STATUS\r
343DRQClear (\r
344 IN ATAPI_BLK_IO_DEV *AtapiBlkIoDev,\r
345 IN IDE_BASE_REGISTERS *IdeIoRegisters,\r
346 IN UINTN TimeoutInMilliSeconds\r
347 );\r
348\r
349/**\r
350 Wait specified time interval to poll for DRQ bit clear in the Alternate Status Register.\r
351 \r
352 @param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
353 @param[in] IdeIoRegisters A pointer to IDE IO registers.\r
354 @param[in] TimeoutInMilliSeconds Time specified in milliseconds.\r
355\r
356 @retval EFI_SUCCESS DRQ bit is cleared in the specified time interval.\r
357 @retval EFI_TIMEOUT DRQ bit is not cleared in the specified time interval.\r
358\r
359**/\r
360EFI_STATUS\r
361DRQClear2 (\r
362 IN ATAPI_BLK_IO_DEV *AtapiBlkIoDev,\r
363 IN IDE_BASE_REGISTERS *IdeIoRegisters,\r
364 IN UINTN TimeoutInMilliSeconds\r
365 );\r
366\r
367/**\r
368 Wait specified time interval to poll for DRQ bit set in the Status Register.\r
369\r
370 @param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
371 @param[in] IdeIoRegisters A pointer to IDE IO registers.\r
372 @param[in] TimeoutInMilliSeconds Time specified in milliseconds.\r
373\r
374 @retval EFI_SUCCESS DRQ bit is set in the specified time interval.\r
375 @retval EFI_TIMEOUT DRQ bit is not set in the specified time interval.\r
376 @retval EFI_ABORTED Operation Aborted.\r
377\r
378**/\r
379EFI_STATUS\r
380DRQReady (\r
381 IN ATAPI_BLK_IO_DEV *AtapiBlkIoDev,\r
382 IN IDE_BASE_REGISTERS *IdeIoRegisters,\r
383 IN UINTN TimeoutInMilliSeconds\r
384 );\r
385\r
386/**\r
387 Wait specified time interval to poll for DRQ bit set in the Alternate Status Register.\r
388\r
389 @param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
390 @param[in] IdeIoRegisters A pointer to IDE IO registers.\r
391 @param[in] TimeoutInMilliSeconds Time specified in milliseconds.\r
392\r
393 @retval EFI_SUCCESS DRQ bit is set in the specified time interval.\r
394 @retval EFI_TIMEOUT DRQ bit is not set in the specified time interval.\r
395 @retval EFI_ABORTED Operation Aborted.\r
396\r
397**/\r
398EFI_STATUS\r
399DRQReady2 (\r
400 IN ATAPI_BLK_IO_DEV *AtapiBlkIoDev,\r
401 IN IDE_BASE_REGISTERS *IdeIoRegisters,\r
402 IN UINTN TimeoutInMilliSeconds\r
403 );\r
404\r
405/**\r
406 Check if there is an error in Status Register.\r
407\r
408 @param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
409 @param[in] StatusReg The address to IDE IO registers.\r
410\r
411 @retval EFI_SUCCESS Operation success.\r
412 @retval EFI_DEVICE_ERROR Device error.\r
413\r
414**/\r
415EFI_STATUS\r
416CheckErrorStatus (\r
417 IN ATAPI_BLK_IO_DEV *AtapiBlkIoDev,\r
418 IN UINT16 StatusReg\r
419 );\r
420\r
421/**\r
422 Idendify Atapi devices.\r
423\r
424 @param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
425 @param[in] DevicePosition An integer to signify device position.\r
426\r
427 @retval EFI_SUCCESS Identify successfully.\r
428 @retval EFI_DEVICE_ERROR Device cannot be identified successfully.\r
429\r
430**/\r
431EFI_STATUS\r
432ATAPIIdentify (\r
433 IN ATAPI_BLK_IO_DEV *AtapiBlkIoDev,\r
434 IN UINTN DevicePosition\r
435 );\r
436\r
437/**\r
438 Sends out ATAPI Test Unit Ready Packet Command to the specified device\r
439 to find out whether device is accessible.\r
440\r
441 @param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
442 @param[in] DevicePosition An integer to signify device position.\r
443\r
444 @retval EFI_SUCCESS TestUnit command executed successfully.\r
445 @retval EFI_DEVICE_ERROR Device cannot be executed TestUnit command successfully.\r
446\r
447**/\r
448EFI_STATUS\r
449TestUnitReady (\r
450 IN ATAPI_BLK_IO_DEV *AtapiBlkIoDev,\r
451 IN UINTN DevicePosition\r
452 ) ;\r
453\r
454/**\r
455 Send out ATAPI commands conforms to the Packet Command with PIO Data In Protocol.\r
456 \r
457 @param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
458 @param[in] DevicePosition An integer to signify device position.\r
459 @param[in] Packet A pointer to ATAPI command packet.\r
460 @param[in] Buffer Buffer to contain requested transfer data from device.\r
461 @param[in] ByteCount Requested transfer data length.\r
462 @param[in] TimeoutInMilliSeconds Time out value, in unit of milliseconds.\r
463\r
464 @retval EFI_SUCCESS Command executed successfully.\r
465 @retval EFI_DEVICE_ERROR Device cannot be executed command successfully.\r
466\r
467**/\r
468EFI_STATUS\r
469AtapiPacketCommandIn (\r
470 IN ATAPI_BLK_IO_DEV *AtapiBlkIoDev,\r
471 IN UINTN DevicePosition,\r
472 IN ATAPI_PACKET_COMMAND *Packet,\r
473 IN UINT16 *Buffer,\r
474 IN UINT32 ByteCount,\r
475 IN UINTN TimeoutInMilliSeconds\r
476 );\r
477\r
478/**\r
479 Sends out ATAPI Inquiry Packet Command to the specified device.\r
480 This command will return INQUIRY data of the device.\r
481\r
482 @param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
483 @param[in] DevicePosition An integer to signify device position.\r
484 @param[out] MediaInfo The media information of the specified block media.\r
485\r
486 @retval EFI_SUCCESS Command executed successfully.\r
487 @retval EFI_DEVICE_ERROR Device cannot be executed command successfully.\r
488 @retval EFI_UNSUPPORTED Unsupported device type.\r
489\r
490**/\r
491EFI_STATUS\r
492Inquiry (\r
493 IN ATAPI_BLK_IO_DEV *AtapiBlkIoDev,\r
494 IN UINTN DevicePosition,\r
495 OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo\r
496 );\r
497\r
498/** \r
499 Used before read/write blocks from/to ATAPI device media. \r
500 Since ATAPI device media is removable, it is necessary to detect\r
501 whether media is present and get current present media's information. \r
502\r
503 @param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
504 @param[in] DevicePosition An integer to signify device position.\r
505 @param[in, out] MediaInfo The media information of the specified block media.\r
506\r
507 @retval EFI_SUCCESS Command executed successfully.\r
508 @retval EFI_DEVICE_ERROR Some device errors happen.\r
509 @retval EFI_OUT_OF_RESOURCES Can not allocate required resources.\r
510\r
511**/\r
512EFI_STATUS\r
513DetectMedia (\r
514 IN ATAPI_BLK_IO_DEV *AtapiBlkIoDev,\r
515 IN UINTN DevicePosition,\r
516 IN OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo\r
517 );\r
518\r
519/** \r
520 Reset specified Atapi device.\r
521\r
522 @param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
523 @param[in] DevicePosition An integer to signify device position.\r
524 @param[in] Extensive If TRUE, use ATA soft reset, otherwise use Atapi soft reset.\r
525\r
526 @retval EFI_SUCCESS Command executed successfully.\r
527 @retval EFI_DEVICE_ERROR Some device errors happen.\r
528\r
529**/\r
530EFI_STATUS\r
531ResetDevice (\r
532 IN ATAPI_BLK_IO_DEV *AtapiBlkIoDev,\r
533 IN UINTN DevicePosition,\r
534 IN BOOLEAN Extensive\r
535 );\r
536\r
537/** \r
538 Sends out ATAPI Request Sense Packet Command to the specified device.\r
539\r
540 @param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
541 @param[in] DevicePosition An integer to signify device position.\r
542 @param[in] SenseBuffers Pointer to sense buffer.\r
543 @param[in, out] SenseCounts Length of sense buffer.\r
544\r
545 @retval EFI_SUCCESS Command executed successfully.\r
546 @retval EFI_DEVICE_ERROR Some device errors happen.\r
547\r
548**/\r
549EFI_STATUS\r
550RequestSense (\r
551 IN ATAPI_BLK_IO_DEV *AtapiBlkIoDev,\r
552 IN UINTN DevicePosition,\r
553 IN ATAPI_REQUEST_SENSE_DATA *SenseBuffers,\r
554 IN OUT UINT8 *SenseCounts\r
555 );\r
556\r
557/** \r
558 Sends out ATAPI Read Capacity Packet Command to the specified device.\r
559 This command will return the information regarding the capacity of the\r
560 media in the device.\r
561\r
562 @param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
563 @param[in] DevicePosition An integer to signify device position.\r
564 @param[in, out] MediaInfo The media information of the specified block media.\r
565\r
566 @retval EFI_SUCCESS Command executed successfully.\r
567 @retval EFI_DEVICE_ERROR Some device errors happen.\r
568\r
569**/\r
570EFI_STATUS\r
571ReadCapacity (\r
572 IN ATAPI_BLK_IO_DEV *AtapiBlkIoDev,\r
573 IN UINTN DevicePosition,\r
574 IN OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo\r
575 );\r
576\r
577/** \r
578 Perform read from disk in block unit.\r
579\r
580 @param[in] AtapiBlkIoDev A pointer to atapi block IO device.\r
581 @param[in] DevicePosition An integer to signify device position.\r
582 @param[in] Buffer Buffer to contain read data.\r
583 @param[in] StartLba Starting LBA address.\r
584 @param[in] NumberOfBlocks Number of blocks to read.\r
585 @param[in] BlockSize Size of each block.\r
586\r
587 @retval EFI_SUCCESS Command executed successfully.\r
588 @retval EFI_DEVICE_ERROR Some device errors happen.\r
589\r
590**/\r
591EFI_STATUS\r
592ReadSectors (\r
593 IN ATAPI_BLK_IO_DEV *AtapiBlkIoDev,\r
594 IN UINTN DevicePosition,\r
595 IN VOID *Buffer,\r
596 IN EFI_PEI_LBA StartLba,\r
597 IN UINTN NumberOfBlocks,\r
598 IN UINTN BlockSize\r
599 );\r
600\r
601/** \r
602 Check if there is media according to sense data.\r
603\r
604 @param[in] SenseData Pointer to sense data.\r
605 @param[in] SenseCounts Count of sense data.\r
606\r
607 @retval TRUE No media\r
608 @retval FALSE Media exists\r
609\r
610**/\r
611BOOLEAN\r
612IsNoMedia (\r
613 IN ATAPI_REQUEST_SENSE_DATA *SenseData,\r
614 IN UINTN SenseCounts\r
615 );\r
616\r
617/** \r
618 Check if device state is unclear according to sense data.\r
619\r
620 @param[in] SenseData Pointer to sense data.\r
621 @param[in] SenseCounts Count of sense data.\r
622\r
623 @retval TRUE Device state is unclear\r
624 @retval FALSE Device state is clear \r
625\r
626**/\r
627BOOLEAN\r
628IsDeviceStateUnclear (\r
629 IN ATAPI_REQUEST_SENSE_DATA *SenseData,\r
630 IN UINTN SenseCounts\r
631 );\r
632\r
633/** \r
634 Check if there is media error according to sense data.\r
635\r
636 @param[in] SenseData Pointer to sense data.\r
637 @param[in] SenseCounts Count of sense data.\r
638\r
639 @retval TRUE Media error\r
640 @retval FALSE No media error\r
641\r
642**/\r
643BOOLEAN\r
644IsMediaError (\r
645 IN ATAPI_REQUEST_SENSE_DATA *SenseData,\r
646 IN UINTN SenseCounts\r
647 );\r
648\r
649/** \r
650 Check if drive is ready according to sense data.\r
651\r
652 @param[in] SenseData Pointer to sense data.\r
653 @param[in] SenseCounts Count of sense data.\r
654 @param[out] NeedRetry Indicate if retry is needed.\r
655\r
656 @retval TRUE Drive ready\r
657 @retval FALSE Drive not ready\r
658\r
659**/\r
660BOOLEAN\r
661IsDriveReady (\r
662 IN ATAPI_REQUEST_SENSE_DATA *SenseData,\r
663 IN UINTN SenseCounts,\r
664 OUT BOOLEAN *NeedRetry\r
665 );\r
666\r
667#endif\r