2 The NvmExpressPei driver is used to manage non-volatile memory subsystem
3 which follows NVM Express specification at PEI phase.
5 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
7 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include "NvmExpressPei.h"
13 #include <Guid/S3StorageDeviceInitList.h>
15 #include <Library/LockBoxLib.h>
18 Determine if a specific NVM Express controller can be skipped for S3 phase.
20 @param[in] HcDevicePath Device path of the controller.
21 @param[in] HcDevicePathLength Length of the device path specified by
24 @retval The number of ports that need to be enumerated.
28 NvmeS3SkipThisController (
29 IN EFI_DEVICE_PATH_PROTOCOL
*HcDevicePath
,
30 IN UINTN HcDevicePathLength
35 UINTN S3InitDevicesLength
;
36 EFI_DEVICE_PATH_PROTOCOL
*S3InitDevices
;
37 EFI_DEVICE_PATH_PROTOCOL
*DevicePathInst
;
38 UINTN DevicePathInstLength
;
43 // From the LockBox, get the list of device paths for devices need to be
47 S3InitDevicesLength
= sizeof (DummyData
);
50 Status
= RestoreLockBox (&gS3StorageDeviceInitListGuid
, &DummyData
, &S3InitDevicesLength
);
51 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
54 S3InitDevices
= AllocatePool (S3InitDevicesLength
);
55 if (S3InitDevices
== NULL
) {
59 Status
= RestoreLockBox (&gS3StorageDeviceInitListGuid
, S3InitDevices
, &S3InitDevicesLength
);
60 if (EFI_ERROR (Status
)) {
65 if (S3InitDevices
== NULL
) {
70 // Only need to initialize the controllers that exist in the device list.
74 // Fetch the size of current device path instance.
76 Status
= GetDevicePathInstanceSize (
78 &DevicePathInstLength
,
81 if (EFI_ERROR (Status
)) {
85 DevicePathInst
= S3InitDevices
;
86 S3InitDevices
= (EFI_DEVICE_PATH_PROTOCOL
*)((UINTN
) S3InitDevices
+ DevicePathInstLength
);
88 if (HcDevicePathLength
>= DevicePathInstLength
) {
93 // Compare the device paths to determine if the device is managed by this
99 HcDevicePathLength
- sizeof (EFI_DEVICE_PATH_PROTOCOL
)
104 } while (!EntireEnd
);