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 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.
18 #include "NvmExpressPei.h"
20 #include <Guid/S3StorageDeviceInitList.h>
22 #include <Library/LockBoxLib.h>
25 Determine if a specific NVM Express controller can be skipped for S3 phase.
27 @param[in] HcDevicePath Device path of the controller.
28 @param[in] HcDevicePathLength Length of the device path specified by
31 @retval The number of ports that need to be enumerated.
35 NvmeS3SkipThisController (
36 IN EFI_DEVICE_PATH_PROTOCOL
*HcDevicePath
,
37 IN UINTN HcDevicePathLength
42 UINTN S3InitDevicesLength
;
43 EFI_DEVICE_PATH_PROTOCOL
*S3InitDevices
;
44 EFI_DEVICE_PATH_PROTOCOL
*DevicePathInst
;
45 UINTN DevicePathInstLength
;
50 // From the LockBox, get the list of device paths for devices need to be
54 S3InitDevicesLength
= sizeof (DummyData
);
57 Status
= RestoreLockBox (&gS3StorageDeviceInitListGuid
, &DummyData
, &S3InitDevicesLength
);
58 if (Status
!= EFI_BUFFER_TOO_SMALL
) {
61 S3InitDevices
= AllocatePool (S3InitDevicesLength
);
62 if (S3InitDevices
== NULL
) {
66 Status
= RestoreLockBox (&gS3StorageDeviceInitListGuid
, S3InitDevices
, &S3InitDevicesLength
);
67 if (EFI_ERROR (Status
)) {
72 if (S3InitDevices
== NULL
) {
77 // Only need to initialize the controllers that exist in the device list.
81 // Fetch the size of current device path instance.
83 Status
= GetDevicePathInstanceSize (
85 &DevicePathInstLength
,
88 if (EFI_ERROR (Status
)) {
92 DevicePathInst
= S3InitDevices
;
93 S3InitDevices
= (EFI_DEVICE_PATH_PROTOCOL
*)((UINTN
) S3InitDevices
+ DevicePathInstLength
);
95 if (HcDevicePathLength
>= DevicePathInstLength
) {
100 // Compare the device paths to determine if the device is managed by this
106 HcDevicePathLength
- sizeof (EFI_DEVICE_PATH_PROTOCOL
)
111 } while (!EntireEnd
);