TianoCore EDK2 master
Loading...
Searching...
No Matches
SystemFirmwareCommonDxe.c
Go to the documentation of this file.
1
9#include "SystemFirmwareDxe.h"
10
11EFI_GUID gSystemFmpLastAttemptVariableGuid = SYSTEM_FMP_LAST_ATTEMPT_VARIABLE_GUID;
12EFI_GUID gSystemFmpProtocolGuid = SYSTEM_FMP_PROTOCOL_GUID;
13
14EFI_FIRMWARE_MANAGEMENT_PROTOCOL mFirmwareManagementProtocol = {
21};
22
62EFIAPI
65 IN OUT UINTN *ImageInfoSize,
67 OUT UINT32 *DescriptorVersion,
68 OUT UINT8 *DescriptorCount,
69 OUT UINTN *DescriptorSize,
70 OUT UINT32 *PackageVersion,
71 OUT CHAR16 **PackageVersionName
72 )
73{
74 SYSTEM_FMP_PRIVATE_DATA *SystemFmpPrivate;
76
77 SystemFmpPrivate = SYSTEM_FMP_PRIVATE_DATA_FROM_FMP (This);
78
79 if (ImageInfoSize == NULL) {
80 return EFI_INVALID_PARAMETER;
81 }
82
83 if (*ImageInfoSize < sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR) * SystemFmpPrivate->DescriptorCount) {
84 *ImageInfoSize = sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR) * SystemFmpPrivate->DescriptorCount;
85 return EFI_BUFFER_TOO_SMALL;
86 }
87
88 if ((ImageInfo == NULL) ||
89 (DescriptorVersion == NULL) ||
90 (DescriptorCount == NULL) ||
91 (DescriptorSize == NULL) ||
92 (PackageVersion == NULL) ||
93 (PackageVersionName == NULL))
94 {
95 return EFI_INVALID_PARAMETER;
96 }
97
98 *ImageInfoSize = sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR) * SystemFmpPrivate->DescriptorCount;
99 *DescriptorSize = sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR);
100 *DescriptorCount = SystemFmpPrivate->DescriptorCount;
101 *DescriptorVersion = EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION;
102
103 //
104 // supports 1 ImageInfo descriptor
105 //
106 ImageDescriptor = SystemFmpPrivate->ImageDescriptor;
107 ImageInfo->ImageIndex = ImageDescriptor->ImageIndex;
108 CopyGuid (&ImageInfo->ImageTypeId, &ImageDescriptor->ImageTypeId);
109 ImageInfo->ImageId = ImageDescriptor->ImageId;
110 if (ImageDescriptor->ImageIdNameStringOffset != 0) {
111 ImageInfo->ImageIdName = (CHAR16 *)((UINTN)ImageDescriptor + ImageDescriptor->ImageIdNameStringOffset);
112 } else {
113 ImageInfo->ImageIdName = NULL;
114 }
115
116 ImageInfo->Version = ImageDescriptor->Version;
117 if (ImageDescriptor->VersionNameStringOffset != 0) {
118 ImageInfo->VersionName = (CHAR16 *)((UINTN)ImageDescriptor + ImageDescriptor->VersionNameStringOffset);
119 } else {
120 ImageInfo->VersionName = NULL;
121 }
122
123 ImageInfo->Size = (UINTN)ImageDescriptor->Size;
124 ImageInfo->AttributesSupported = ImageDescriptor->AttributesSupported;
125 ImageInfo->AttributesSetting = ImageDescriptor->AttributesSetting;
126 ImageInfo->Compatibilities = ImageDescriptor->Compatibilities;
127 ImageInfo->LowestSupportedImageVersion = ImageDescriptor->LowestSupportedImageVersion;
128 ImageInfo->LastAttemptVersion = SystemFmpPrivate->LastAttempt.LastAttemptVersion;
129 ImageInfo->LastAttemptStatus = SystemFmpPrivate->LastAttempt.LastAttemptStatus;
130 ImageInfo->HardwareInstance = ImageDescriptor->HardwareInstance;
131
132 //
133 // package version
134 //
135 *PackageVersion = ImageDescriptor->PackageVersion;
136 if (ImageDescriptor->PackageVersionNameStringOffset != 0) {
137 *PackageVersionName = (VOID *)((UINTN)ImageDescriptor + ImageDescriptor->PackageVersionNameStringOffset);
138 *PackageVersionName = AllocateCopyPool (StrSize (*PackageVersionName), *PackageVersionName);
139 } else {
140 *PackageVersionName = NULL;
141 }
142
143 return EFI_SUCCESS;
144}
145
170EFIAPI
173 IN UINT8 ImageIndex,
174 IN OUT VOID *Image,
175 IN OUT UINTN *ImageSize
176 )
177{
178 return EFI_UNSUPPORTED;
179}
180
202EFIAPI
205 IN UINT8 ImageIndex,
206 IN CONST VOID *Image,
207 IN UINTN ImageSize,
208 OUT UINT32 *ImageUpdatable
209 )
210{
211 return EFI_UNSUPPORTED;
212}
213
247EFIAPI
250 OUT UINT32 *PackageVersion,
251 OUT CHAR16 **PackageVersionName,
252 OUT UINT32 *PackageVersionNameMaxLen,
253 OUT UINT64 *AttributesSupported,
254 OUT UINT64 *AttributesSetting
255 )
256{
257 return EFI_UNSUPPORTED;
258}
259
292EFIAPI
295 IN CONST VOID *Image,
296 IN UINTN ImageSize,
297 IN CONST VOID *VendorCode,
298 IN UINT32 PackageVersion,
299 IN CONST CHAR16 *PackageVersionName
300 )
301{
302 return EFI_UNSUPPORTED;
303}
304
314 IN SYSTEM_FMP_PRIVATE_DATA *SystemFmpPrivate
315 )
316{
317 EFI_STATUS VarStatus;
318 UINTN VarSize;
319
320 SystemFmpPrivate->Signature = SYSTEM_FMP_PRIVATE_DATA_SIGNATURE;
321 SystemFmpPrivate->Handle = NULL;
322 SystemFmpPrivate->DescriptorCount = 1;
323 CopyMem (&SystemFmpPrivate->Fmp, &mFirmwareManagementProtocol, sizeof (EFI_FIRMWARE_MANAGEMENT_PROTOCOL));
324
325 SystemFmpPrivate->ImageDescriptor = PcdGetPtr (PcdEdkiiSystemFirmwareImageDescriptor);
326
327 SystemFmpPrivate->LastAttempt.LastAttemptVersion = 0x0;
328 SystemFmpPrivate->LastAttempt.LastAttemptStatus = 0x0;
329 VarSize = sizeof (SystemFmpPrivate->LastAttempt);
330 VarStatus = gRT->GetVariable (
331 SYSTEM_FMP_LAST_ATTEMPT_VARIABLE_NAME,
332 &gSystemFmpLastAttemptVariableGuid,
333 NULL,
334 &VarSize,
335 &SystemFmpPrivate->LastAttempt
336 );
337 DEBUG ((DEBUG_INFO, "GetLastAttempt - %r\n", VarStatus));
338 DEBUG ((DEBUG_INFO, "GetLastAttempt Version - 0x%x, State - 0x%x\n", SystemFmpPrivate->LastAttempt.LastAttemptVersion, SystemFmpPrivate->LastAttempt.LastAttemptStatus));
339
340 return EFI_SUCCESS;
341}
UINT64 UINTN
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
Definition: String.c:72
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
Definition: MemLibGuid.c:39
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
#define EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION
EFI_RUNTIME_SERVICES * gRT
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define DEBUG(Expression)
Definition: DebugLib.h:434
#define PcdGetPtr(TokenName)
Definition: PcdLib.h:388
EFI_STATUS EFIAPI FmpGetImageInfo(IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, IN OUT UINTN *ImageInfoSize, IN OUT EFI_FIRMWARE_IMAGE_DESCRIPTOR *ImageInfo, OUT UINT32 *DescriptorVersion, OUT UINT8 *DescriptorCount, OUT UINTN *DescriptorSize, OUT UINT32 *PackageVersion, OUT CHAR16 **PackageVersionName)
EFI_STATUS EFIAPI FmpCheckImage(IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, IN UINT8 ImageIndex, IN CONST VOID *Image, IN UINTN ImageSize, OUT UINT32 *ImageUpdatable)
EFI_STATUS EFIAPI FmpGetImage(IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, IN UINT8 ImageIndex, IN OUT VOID *Image, IN OUT UINTN *ImageSize)
EFI_STATUS InitializePrivateData(IN SYSTEM_FMP_PRIVATE_DATA *SystemFmpPrivate)
EFI_STATUS EFIAPI FmpGetPackageInfo(IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, OUT UINT32 *PackageVersion, OUT CHAR16 **PackageVersionName, OUT UINT32 *PackageVersionNameMaxLen, OUT UINT64 *AttributesSupported, OUT UINT64 *AttributesSetting)
EFI_STATUS EFIAPI FmpSetPackageInfo(IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, IN CONST VOID *Image, IN UINTN ImageSize, IN CONST VOID *VendorCode, IN UINT32 PackageVersion, IN CONST CHAR16 *PackageVersionName)
#define SYSTEM_FMP_PRIVATE_DATA_FROM_FMP(a)
EFI_STATUS EFIAPI FmpSetImage(IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, IN UINT8 ImageIndex, IN CONST VOID *Image, IN UINTN ImageSize, IN CONST VOID *VendorCode, IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress, OUT CHAR16 **AbortReason)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
Definition: Base.h:213