2 The AhciPei driver is used to manage ATA hard disk device working under AHCI
5 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions
9 of the BSD License which accompanies this distribution. The
10 full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
23 #include <IndustryStandard/Atapi.h>
25 #include <Ppi/AtaAhciController.h>
26 #include <Ppi/IoMmu.h>
27 #include <Ppi/EndOfPeiPhase.h>
28 #include <Ppi/AtaPassThru.h>
29 #include <Ppi/BlockIo2.h>
30 #include <Ppi/StorageSecurityCommand.h>
32 #include <Library/DebugLib.h>
33 #include <Library/PeiServicesLib.h>
34 #include <Library/MemoryAllocationLib.h>
35 #include <Library/BaseMemoryLib.h>
36 #include <Library/IoLib.h>
37 #include <Library/TimerLib.h>
40 // Structure forward declarations
42 typedef struct _PEI_AHCI_CONTROLLER_PRIVATE_DATA PEI_AHCI_CONTROLLER_PRIVATE_DATA
;
44 #include "AhciPeiPassThru.h"
45 #include "AhciPeiStorageSecurity.h"
48 // ATA AHCI driver implementation related definitions
51 // Refer SATA1.0a spec section 5.2, the Phy detection time should be less than 10ms.
52 // The value is in millisecond units. Add a bit of margin for robustness.
54 #define AHCI_BUS_PHY_DETECT_TIMEOUT 15
56 // Refer SATA1.0a spec, the bus reset time should be less than 1s.
57 // The value is in 100ns units.
59 #define AHCI_PEI_RESET_TIMEOUT 10000000
61 // Time out Value for ATA pass through protocol, in 100ns units.
63 #define ATA_TIMEOUT 30000000
65 // Maximal number of Physical Region Descriptor Table entries supported.
67 #define AHCI_MAX_PRDT_NUMBER 8
69 #define AHCI_CAPABILITY_OFFSET 0x0000
70 #define AHCI_CAP_SAM BIT18
71 #define AHCI_CAP_SSS BIT27
73 #define AHCI_GHC_OFFSET 0x0004
74 #define AHCI_GHC_RESET BIT0
75 #define AHCI_GHC_ENABLE BIT31
77 #define AHCI_IS_OFFSET 0x0008
78 #define AHCI_PI_OFFSET 0x000C
80 #define AHCI_MAX_PORTS 32
92 #define AHCI_ATAPI_SIG_MASK 0xFFFF0000
93 #define AHCI_ATA_DEVICE_SIG 0x00000000
96 // Each PRDT entry can point to a memory block up to 4M byte
98 #define AHCI_MAX_DATA_PER_PRDT 0x400000
100 #define AHCI_FIS_REGISTER_H2D 0x27 //Register FIS - Host to Device
101 #define AHCI_FIS_REGISTER_H2D_LENGTH 20
102 #define AHCI_FIS_REGISTER_D2H 0x34 //Register FIS - Device to Host
103 #define AHCI_FIS_PIO_SETUP 0x5F //PIO Setup FIS - Device to Host
105 #define AHCI_D2H_FIS_OFFSET 0x40
106 #define AHCI_PIO_FIS_OFFSET 0x20
107 #define AHCI_FIS_TYPE_MASK 0xFF
112 #define AHCI_PORT_START 0x0100
113 #define AHCI_PORT_REG_WIDTH 0x0080
114 #define AHCI_PORT_CLB 0x0000
115 #define AHCI_PORT_CLBU 0x0004
116 #define AHCI_PORT_FB 0x0008
117 #define AHCI_PORT_FBU 0x000C
118 #define AHCI_PORT_IS 0x0010
119 #define AHCI_PORT_IE 0x0014
120 #define AHCI_PORT_CMD 0x0018
121 #define AHCI_PORT_CMD_ST BIT0
122 #define AHCI_PORT_CMD_SUD BIT1
123 #define AHCI_PORT_CMD_POD BIT2
124 #define AHCI_PORT_CMD_CLO BIT3
125 #define AHCI_PORT_CMD_FRE BIT4
126 #define AHCI_PORT_CMD_FR BIT14
127 #define AHCI_PORT_CMD_CR BIT15
128 #define AHCI_PORT_CMD_CPD BIT20
129 #define AHCI_PORT_CMD_ATAPI BIT24
130 #define AHCI_PORT_CMD_DLAE BIT25
131 #define AHCI_PORT_CMD_ALPE BIT26
132 #define AHCI_PORT_CMD_ACTIVE (1 << 28)
133 #define AHCI_PORT_CMD_ICC_MASK (BIT28 | BIT29 | BIT30 | BIT31)
135 #define AHCI_PORT_TFD 0x0020
136 #define AHCI_PORT_TFD_ERR BIT0
137 #define AHCI_PORT_TFD_DRQ BIT3
138 #define AHCI_PORT_TFD_BSY BIT7
139 #define AHCI_PORT_TFD_MASK (BIT7 | BIT3 | BIT0)
141 #define AHCI_PORT_SIG 0x0024
142 #define AHCI_PORT_SSTS 0x0028
143 #define AHCI_PORT_SSTS_DET_MASK 0x000F
144 #define AHCI_PORT_SSTS_DET 0x0001
145 #define AHCI_PORT_SSTS_DET_PCE 0x0003
147 #define AHCI_PORT_SCTL 0x002C
148 #define AHCI_PORT_SCTL_IPM_INIT 0x0300
150 #define AHCI_PORT_SERR 0x0030
151 #define AHCI_PORT_CI 0x0038
153 #define IS_ALIGNED(addr, size) (((UINTN) (addr) & (size - 1)) == 0)
154 #define TIMER_PERIOD_SECONDS(Seconds) MultU64x32((UINT64)(Seconds), 10000000)
159 // Received FIS structure
162 UINT8 AhciDmaSetupFis
[0x1C]; // Dma Setup Fis: offset 0x00
163 UINT8 AhciDmaSetupFisRsvd
[0x04];
164 UINT8 AhciPioSetupFis
[0x14]; // Pio Setup Fis: offset 0x20
165 UINT8 AhciPioSetupFisRsvd
[0x0C];
166 UINT8 AhciD2HRegisterFis
[0x14]; // D2H Register Fis: offset 0x40
167 UINT8 AhciD2HRegisterFisRsvd
[0x04];
168 UINT64 AhciSetDeviceBitsFis
; // Set Device Bits Fix: offset 0x58
169 UINT8 AhciUnknownFis
[0x40]; // Unkonwn Fis: offset 0x60
170 UINT8 AhciUnknownFisRsvd
[0x60];
171 } EFI_AHCI_RECEIVED_FIS
;
174 // Command List structure includes total 32 entries.
175 // The entry Data structure is listed at the following.
178 UINT32 AhciCmdCfl
:5; //Command FIS Length
179 UINT32 AhciCmdA
:1; //ATAPI
180 UINT32 AhciCmdW
:1; //Write
181 UINT32 AhciCmdP
:1; //Prefetchable
182 UINT32 AhciCmdR
:1; //Reset
183 UINT32 AhciCmdB
:1; //BIST
184 UINT32 AhciCmdC
:1; //Clear Busy upon R_OK
185 UINT32 AhciCmdRsvd
:1;
186 UINT32 AhciCmdPmp
:4; //Port Multiplier Port
187 UINT32 AhciCmdPrdtl
:16; //Physical Region Descriptor Table Length
188 UINT32 AhciCmdPrdbc
; //Physical Region Descriptor Byte Count
189 UINT32 AhciCmdCtba
; //Command Table Descriptor Base Address
190 UINT32 AhciCmdCtbau
; //Command Table Descriptor Base Address Upper 32-BITs
191 UINT32 AhciCmdRsvd1
[4];
192 } EFI_AHCI_COMMAND_LIST
;
195 // This is a software constructed FIS.
196 // For Data transfer operations, this is the H2D Register FIS format as
197 // specified in the Serial ATA Revision 2.6 specification.
201 UINT8 AhciCFisPmNum
:4;
202 UINT8 AhciCFisRsvd
:1;
203 UINT8 AhciCFisRsvd1
:1;
204 UINT8 AhciCFisRsvd2
:1;
205 UINT8 AhciCFisCmdInd
:1;
207 UINT8 AhciCFisFeature
;
208 UINT8 AhciCFisSecNum
;
209 UINT8 AhciCFisClyLow
;
210 UINT8 AhciCFisClyHigh
;
211 UINT8 AhciCFisDevHead
;
212 UINT8 AhciCFisSecNumExp
;
213 UINT8 AhciCFisClyLowExp
;
214 UINT8 AhciCFisClyHighExp
;
215 UINT8 AhciCFisFeatureExp
;
216 UINT8 AhciCFisSecCount
;
217 UINT8 AhciCFisSecCountExp
;
219 UINT8 AhciCFisControl
;
220 UINT8 AhciCFisRsvd4
[4];
221 UINT8 AhciCFisRsvd5
[44];
222 } EFI_AHCI_COMMAND_FIS
;
225 // ACMD: ATAPI command (12 or 16 bytes)
228 UINT8 AtapiCmd
[0x10];
229 } EFI_AHCI_ATAPI_COMMAND
;
232 // Physical Region Descriptor Table includes up to 65535 entries
233 // The entry data structure is listed at the following.
234 // the actual entry number comes from the PRDTL field in the command
235 // list entry for this command slot.
238 UINT32 AhciPrdtDba
; //Data Base Address
239 UINT32 AhciPrdtDbau
; //Data Base Address Upper 32-BITs
241 UINT32 AhciPrdtDbc
:22; //Data Byte Count
242 UINT32 AhciPrdtRsvd1
:9;
243 UINT32 AhciPrdtIoc
:1; //Interrupt on Completion
244 } EFI_AHCI_COMMAND_PRDT
;
247 // Command table Data strucute which is pointed to by the entry in the command list
250 EFI_AHCI_COMMAND_FIS CommandFis
; // A software constructed FIS.
251 EFI_AHCI_ATAPI_COMMAND AtapiCmd
; // 12 or 16 bytes ATAPI cmd.
252 UINT8 Reserved
[0x30];
254 // The scatter/gather list for Data transfer.
256 EFI_AHCI_COMMAND_PRDT PrdtTable
[AHCI_MAX_PRDT_NUMBER
];
257 } EFI_AHCI_COMMAND_TABLE
;
262 EFI_AHCI_RECEIVED_FIS
*AhciRFis
;
263 EFI_AHCI_COMMAND_LIST
*AhciCmdList
;
264 EFI_AHCI_COMMAND_TABLE
*AhciCmdTable
;
266 UINTN MaxCmdListSize
;
267 UINTN MaxCmdTableSize
;
269 VOID
*AhciCmdListMap
;
270 VOID
*AhciCmdTableMap
;
271 } EFI_AHCI_REGISTERS
;
274 // Unique signature for AHCI ATA device information structure.
276 #define AHCI_PEI_ATA_DEVICE_DATA_SIGNATURE SIGNATURE_32 ('A', 'P', 'A', 'D')
279 // AHCI mode device information structure.
286 UINT16 PortMultiplier
;
289 ATA_IDENTIFY_DATA
*IdentifyData
;
292 BOOLEAN TrustComputing
;
293 UINTN TrustComputingDeviceIndex
;
294 EFI_PEI_BLOCK_IO2_MEDIA Media
;
296 PEI_AHCI_CONTROLLER_PRIVATE_DATA
*Private
;
297 } PEI_AHCI_ATA_DEVICE_DATA
;
299 #define AHCI_PEI_ATA_DEVICE_INFO_FROM_THIS(a) \
301 PEI_AHCI_ATA_DEVICE_DATA, \
303 AHCI_PEI_ATA_DEVICE_DATA_SIGNATURE \
307 // Unique signature for private data structure.
309 #define AHCI_PEI_CONTROLLER_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('A','P','C','P')
312 // ATA AHCI controller private data structure.
314 struct _PEI_AHCI_CONTROLLER_PRIVATE_DATA
{
317 UINTN DevicePathLength
;
318 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
320 EFI_ATA_PASS_THRU_MODE AtaPassThruMode
;
321 EDKII_PEI_ATA_PASS_THRU_PPI AtaPassThruPpi
;
322 EDKII_PEI_STORAGE_SECURITY_CMD_PPI StorageSecurityPpi
;
323 EFI_PEI_PPI_DESCRIPTOR AtaPassThruPpiList
;
324 EFI_PEI_PPI_DESCRIPTOR BlkIoPpiList
;
325 EFI_PEI_PPI_DESCRIPTOR BlkIo2PpiList
;
326 EFI_PEI_PPI_DESCRIPTOR StorageSecurityPpiList
;
327 EFI_PEI_NOTIFY_DESCRIPTOR EndOfPeiNotifyList
;
329 EFI_AHCI_REGISTERS AhciRegisters
;
332 UINT32 ActiveDevices
;
333 UINT32 TrustComputingDevices
;
334 LIST_ENTRY DeviceList
;
337 UINT16 PreviousPortMultiplier
;
340 #define GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_PASS_THRU(a) \
341 CR (a, PEI_AHCI_CONTROLLER_PRIVATE_DATA, AtaPassThruPpi, AHCI_PEI_CONTROLLER_PRIVATE_DATA_SIGNATURE)
342 #define GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_BLKIO(a) \
343 CR (a, PEI_AHCI_CONTROLLER_PRIVATE_DATA, BlkIoPpi, AHCI_PEI_CONTROLLER_PRIVATE_DATA_SIGNATURE)
344 #define GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_BLKIO2(a) \
345 CR (a, PEI_AHCI_CONTROLLER_PRIVATE_DATA, BlkIo2Ppi, AHCI_PEI_CONTROLLER_PRIVATE_DATA_SIGNATURE)
346 #define GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_STROAGE_SECURITY(a) \
347 CR (a, PEI_AHCI_CONTROLLER_PRIVATE_DATA, StorageSecurityPpi, AHCI_PEI_CONTROLLER_PRIVATE_DATA_SIGNATURE)
348 #define GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_NOTIFY(a) \
349 CR (a, PEI_AHCI_CONTROLLER_PRIVATE_DATA, EndOfPeiNotifyList, AHCI_PEI_CONTROLLER_PRIVATE_DATA_SIGNATURE)
354 extern UINT32 mMaxTransferBlockNumber
[2];
357 // Internal functions
361 Allocates pages that are suitable for an OperationBusMasterCommonBuffer or
362 OperationBusMasterCommonBuffer64 mapping.
364 @param Pages The number of pages to allocate.
365 @param HostAddress A pointer to store the base system memory address of the
367 @param DeviceAddress The resulting map address for the bus master PCI controller to use to
368 access the hosts HostAddress.
369 @param Mapping A resulting value to pass to Unmap().
371 @retval EFI_SUCCESS The requested memory pages were allocated.
372 @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are
373 MEMORY_WRITE_COMBINE and MEMORY_CACHED.
374 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
375 @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
379 IoMmuAllocateBuffer (
381 OUT VOID
**HostAddress
,
382 OUT EFI_PHYSICAL_ADDRESS
*DeviceAddress
,
387 Frees memory that was allocated with AllocateBuffer().
389 @param Pages The number of pages to free.
390 @param HostAddress The base system memory address of the allocated range.
391 @param Mapping The mapping value returned from Map().
393 @retval EFI_SUCCESS The requested memory pages were freed.
394 @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and Pages
395 was not allocated with AllocateBuffer().
401 IN VOID
*HostAddress
,
406 Provides the controller-specific addresses required to access system memory from a
409 @param Operation Indicates if the bus master is going to read or write to system memory.
410 @param HostAddress The system memory address to map to the PCI controller.
411 @param NumberOfBytes On input the number of bytes to map. On output the number of bytes
413 @param DeviceAddress The resulting map address for the bus master PCI controller to use to
414 access the hosts HostAddress.
415 @param Mapping A resulting value to pass to Unmap().
417 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
418 @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer.
419 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
420 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
421 @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
426 IN EDKII_IOMMU_OPERATION Operation
,
427 IN VOID
*HostAddress
,
428 IN OUT UINTN
*NumberOfBytes
,
429 OUT EFI_PHYSICAL_ADDRESS
*DeviceAddress
,
434 Completes the Map() operation and releases any corresponding resources.
436 @param Mapping The mapping value returned from Map().
438 @retval EFI_SUCCESS The range was unmapped.
439 @retval EFI_INVALID_PARAMETER Mapping is not a value that was returned by Map().
440 @retval EFI_DEVICE_ERROR The data was not committed to the target system memory.
448 One notified function to cleanup the allocated DMA buffers at EndOfPei.
450 @param[in] PeiServices Pointer to PEI Services Table.
451 @param[in] NotifyDescriptor Pointer to the descriptor for the Notification
452 event that caused this function to execute.
453 @param[in] Ppi Pointer to the PPI data associated with this function.
455 @retval EFI_SUCCESS The function completes successfully
461 IN EFI_PEI_SERVICES
**PeiServices
,
462 IN EFI_PEI_NOTIFY_DESCRIPTOR
*NotifyDescriptor
,
467 Collect the number of bits set within a port bitmap.
469 @param[in] PortBitMap A 32-bit wide bit map of ATA AHCI ports.
471 @retval The number of bits set in the bitmap.
475 AhciGetNumberOfPortsFromMap (
480 Start a PIO Data transfer on specific port.
482 @param[in] Private The pointer to the PEI_AHCI_CONTROLLER_PRIVATE_DATA.
483 @param[in] Port The number of port.
484 @param[in] PortMultiplier The number of port multiplier.
485 @param[in] FisIndex The offset index of the FIS base address.
486 @param[in] Read The transfer direction.
487 @param[in] AtaCommandBlock The EFI_ATA_COMMAND_BLOCK data.
488 @param[in,out] AtaStatusBlock The EFI_ATA_STATUS_BLOCK data.
489 @param[in,out] MemoryAddr The pointer to the data buffer.
490 @param[in] DataCount The data count to be transferred.
491 @param[in] Timeout The timeout value of PIO data transfer, uses
494 @retval EFI_DEVICE_ERROR The PIO data transfer abort with error occurs.
495 @retval EFI_TIMEOUT The operation is time out.
496 @retval EFI_UNSUPPORTED The device is not ready for transfer.
497 @retval EFI_OUT_OF_RESOURCES The operation fails due to lack of resources.
498 @retval EFI_SUCCESS The PIO data transfer executes successfully.
503 IN PEI_AHCI_CONTROLLER_PRIVATE_DATA
*Private
,
505 IN UINT8 PortMultiplier
,
508 IN EFI_ATA_COMMAND_BLOCK
*AtaCommandBlock
,
509 IN OUT EFI_ATA_STATUS_BLOCK
*AtaStatusBlock
,
510 IN OUT VOID
*MemoryAddr
,
516 Start a non data transfer on specific port.
518 @param[in] Private The pointer to the PEI_AHCI_CONTROLLER_PRIVATE_DATA.
519 @param[in] Port The number of port.
520 @param[in] PortMultiplier The number of port multiplier.
521 @param[in] FisIndex The offset index of the FIS base address.
522 @param[in] AtaCommandBlock The EFI_ATA_COMMAND_BLOCK data.
523 @param[in,out] AtaStatusBlock The EFI_ATA_STATUS_BLOCK data.
524 @param[in] Timeout The timeout value of non data transfer, uses
527 @retval EFI_DEVICE_ERROR The non data transfer abort with error occurs.
528 @retval EFI_TIMEOUT The operation is time out.
529 @retval EFI_UNSUPPORTED The device is not ready for transfer.
530 @retval EFI_SUCCESS The non data transfer executes successfully.
534 AhciNonDataTransfer (
535 IN PEI_AHCI_CONTROLLER_PRIVATE_DATA
*Private
,
537 IN UINT8 PortMultiplier
,
539 IN EFI_ATA_COMMAND_BLOCK
*AtaCommandBlock
,
540 IN OUT EFI_ATA_STATUS_BLOCK
*AtaStatusBlock
,
545 Initialize ATA host controller at AHCI mode.
547 The function is designed to initialize ATA host controller.
549 @param[in,out] Private A pointer to the PEI_AHCI_CONTROLLER_PRIVATE_DATA instance.
551 @retval EFI_SUCCESS The ATA AHCI controller is initialized successfully.
552 @retval EFI_OUT_OF_RESOURCES Not enough resource to complete while initializing
554 @retval Others A device error occurred while initializing the
559 AhciModeInitialization (
560 IN OUT PEI_AHCI_CONTROLLER_PRIVATE_DATA
*Private
564 Trust transfer data from/to ATA device.
566 This function performs one ATA pass through transaction to do a trust transfer
567 from/to ATA device. It chooses the appropriate ATA command and protocol to invoke
568 PassThru interface of ATA pass through.
570 @param[in] DeviceData Pointer to PEI_AHCI_ATA_DEVICE_DATA structure.
571 @param[in,out] Buffer The pointer to the current transaction buffer.
572 @param[in] SecurityProtocolId
573 The value of the "Security Protocol" parameter
574 of the security protocol command to be sent.
575 @param[in] SecurityProtocolSpecificData
576 The value of the "Security Protocol Specific"
577 parameter of the security protocol command to
579 @param[in] TransferLength The block number or sector count of the transfer.
580 @param[in] IsTrustSend Indicates whether it is a trust send operation
582 @param[in] Timeout The timeout, in 100ns units, to use for the execution
583 of the security protocol command. A Timeout value
584 of 0 means that this function will wait indefinitely
585 for the security protocol command to execute. If
586 Timeout is greater than zero, then this function
587 will return EFI_TIMEOUT if the time required to
588 execute the receive data command is greater than
590 @param[out] TransferLengthOut
591 A pointer to a buffer to store the size in bytes
592 of the data written to the buffer. Ignore it when
595 @retval EFI_SUCCESS The data transfer is complete successfully.
596 @return others Some error occurs when transferring data.
600 TrustTransferAtaDevice (
601 IN PEI_AHCI_ATA_DEVICE_DATA
*DeviceData
,
603 IN UINT8 SecurityProtocolId
,
604 IN UINT16 SecurityProtocolSpecificData
,
605 IN UINTN TransferLength
,
606 IN BOOLEAN IsTrustSend
,
608 OUT UINTN
*TransferLengthOut
612 Returns a pointer to the next node in a device path.
614 If Node is NULL, then ASSERT().
616 @param Node A pointer to a device path node data structure.
618 @return a pointer to the device path node that follows the device path node
622 EFI_DEVICE_PATH_PROTOCOL
*
628 Get the size of the current device path instance.
630 @param[in] DevicePath A pointer to the EFI_DEVICE_PATH_PROTOCOL
632 @param[out] InstanceSize The size of the current device path instance.
633 @param[out] EntireDevicePathEnd Indicate whether the instance is the last
634 one in the device path strucure.
636 @retval EFI_SUCCESS The size of the current device path instance is fetched.
637 @retval Others Fails to get the size of the current device path instance.
641 GetDevicePathInstanceSize (
642 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
643 OUT UINTN
*InstanceSize
,
644 OUT BOOLEAN
*EntireDevicePathEnd
648 Check the validity of the device path of a ATA AHCI host controller.
650 @param[in] DevicePath A pointer to the EFI_DEVICE_PATH_PROTOCOL
652 @param[in] DevicePathLength The length of the device path.
654 @retval EFI_SUCCESS The device path is valid.
655 @retval EFI_INVALID_PARAMETER The device path is invalid.
659 AhciIsHcDevicePathValid (
660 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
661 IN UINTN DevicePathLength
665 Build the device path for an ATA device with given port and port multiplier number.
667 @param[in] Private A pointer to the PEI_AHCI_CONTROLLER_PRIVATE_DATA
669 @param[in] Port The given port number.
670 @param[in] PortMultiplierPort The given port multiplier number.
671 @param[out] DevicePathLength The length of the device path in bytes specified
673 @param[out] DevicePath The device path of ATA device.
675 @retval EFI_SUCCESS The operation succeeds.
676 @retval EFI_INVALID_PARAMETER The parameters are invalid.
677 @retval EFI_OUT_OF_RESOURCES The operation fails due to lack of resources.
681 AhciBuildDevicePath (
682 IN PEI_AHCI_CONTROLLER_PRIVATE_DATA
*Private
,
684 IN UINT16 PortMultiplierPort
,
685 OUT UINTN
*DevicePathLength
,
686 OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
690 Collect the ports that need to be enumerated on a controller for S3 phase.
692 @param[in] HcDevicePath Device path of the controller.
693 @param[in] HcDevicePathLength Length of the device path specified by
695 @param[out] PortBitMap Bitmap that indicates the ports that need
696 to be enumerated on the controller.
698 @retval The number of ports that need to be enumerated.
702 AhciS3GetEumeratePorts (
703 IN EFI_DEVICE_PATH_PROTOCOL
*HcDevicePath
,
704 IN UINTN HcDevicePathLength
,
705 OUT UINT32
*PortBitMap