TianoCore EDK2 master
Loading...
Searching...
No Matches
NvmExpressPeiS3.c
Go to the documentation of this file.
1
11#include "NvmExpressPei.h"
12
14
15#include <Library/LockBoxLib.h>
16
27BOOLEAN
29 IN EFI_DEVICE_PATH_PROTOCOL *HcDevicePath,
30 IN UINTN HcDevicePathLength
31 )
32{
33 EFI_STATUS Status;
34 UINT8 DummyData;
35 UINTN S3InitDevicesLength;
36 EFI_DEVICE_PATH_PROTOCOL *S3InitDevices;
37 EFI_DEVICE_PATH_PROTOCOL *DevicePathInst;
38 UINTN DevicePathInstLength;
39 BOOLEAN EntireEnd;
40 BOOLEAN Skip;
41
42 //
43 // From the LockBox, get the list of device paths for devices need to be
44 // initialized in S3.
45 //
46 S3InitDevices = NULL;
47 S3InitDevicesLength = sizeof (DummyData);
48 EntireEnd = FALSE;
49 Skip = TRUE;
50 Status = RestoreLockBox (&gS3StorageDeviceInitListGuid, &DummyData, &S3InitDevicesLength);
51 if (Status != EFI_BUFFER_TOO_SMALL) {
52 return Skip;
53 } else {
54 S3InitDevices = AllocatePool (S3InitDevicesLength);
55 if (S3InitDevices == NULL) {
56 return Skip;
57 }
58
59 Status = RestoreLockBox (&gS3StorageDeviceInitListGuid, S3InitDevices, &S3InitDevicesLength);
60 if (EFI_ERROR (Status)) {
61 return Skip;
62 }
63 }
64
65 //
66 // Only need to initialize the controllers that exist in the device list.
67 //
68 do {
69 //
70 // Fetch the size of current device path instance.
71 //
73 S3InitDevices,
74 &DevicePathInstLength,
75 &EntireEnd
76 );
77 if (EFI_ERROR (Status)) {
78 break;
79 }
80
81 DevicePathInst = S3InitDevices;
82 S3InitDevices = (EFI_DEVICE_PATH_PROTOCOL *)((UINTN)S3InitDevices + DevicePathInstLength);
83
84 if (HcDevicePathLength >= DevicePathInstLength) {
85 continue;
86 }
87
88 //
89 // Compare the device paths to determine if the device is managed by this
90 // controller.
91 //
92 if (CompareMem (
93 DevicePathInst,
94 HcDevicePath,
95 HcDevicePathLength - sizeof (EFI_DEVICE_PATH_PROTOCOL)
96 ) == 0)
97 {
98 Skip = FALSE;
99 break;
100 }
101 } while (!EntireEnd);
102
103 return Skip;
104}
UINT64 UINTN
EFI_STATUS GetDevicePathInstanceSize(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, OUT UINTN *InstanceSize, OUT BOOLEAN *EntireDevicePathEnd)
Definition: DevicePath.c:55
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
RETURN_STATUS EFIAPI RestoreLockBox(IN GUID *Guid, IN VOID *Buffer OPTIONAL, IN OUT UINTN *Length OPTIONAL)
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
BOOLEAN NvmeS3SkipThisController(IN EFI_DEVICE_PATH_PROTOCOL *HcDevicePath, IN UINTN HcDevicePathLength)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29