68 if (Table->FwResourceCount == 0) {
69 DEBUG ((DEBUG_ERROR,
"EsrtFmpDxe: Can't install ESRT table because it has zero Entries. \n"));
70 Status = EFI_UNSUPPORTED;
75 Status =
gBS->InstallConfigurationTable (&gEfiSystemResourceTableGuid, Table);
76 if (EFI_ERROR (Status)) {
77 DEBUG ((DEBUG_ERROR,
"EsrtFmpDxe: Can't install ESRT table. Status: %r. \n", Status));
79 DEBUG ((DEBUG_INFO,
"EsrtFmpDxe: Installed ESRT table. \n"));
103 Guid =
PcdGetPtr (PcdSystemFmpCapsuleImageTypeIdGuid);
104 Count =
PcdGetSize (PcdSystemFmpCapsuleImageTypeIdGuid) /
sizeof (
GUID);
106 for (Index = 0; Index < Count; Index++, Guid++) {
107 if (
CompareGuid (&FmpImageInfo->ImageTypeId, Guid)) {
140 IN OUT UINT32 *NumberOfDescriptors,
147 UINT64 FmpHardwareInstance;
149 FmpHardwareInstance = 0;
150 if (FmpVersion >= 3) {
151 FmpHardwareInstance = FmpImageInfoBuf->HardwareInstance;
159 if (FmpHardwareInstance != 0) {
160 for (Index = 0; Index < *NumberOfDescriptors; Index++) {
161 if (
CompareGuid (&HardwareInstances[Index].ImageTypeGuid, &FmpImageInfoBuf->ImageTypeId)) {
162 if (HardwareInstances[Index].HardwareInstance == FmpHardwareInstance) {
163 DEBUG ((DEBUG_ERROR,
"EsrtFmpDxe: Duplicate firmware image descriptor with GUID %g HardwareInstance:0x%x\n", &FmpImageInfoBuf->ImageTypeId, FmpHardwareInstance));
165 !
CompareGuid (&HardwareInstances[Index].ImageTypeGuid, &FmpImageInfoBuf->ImageTypeId) ||
166 HardwareInstances[Index].HardwareInstance != FmpHardwareInstance
168 return EFI_UNSUPPORTED;
177 CopyGuid (&HardwareInstances[*NumberOfDescriptors].ImageTypeGuid, &FmpImageInfoBuf->ImageTypeId);
178 HardwareInstances[*NumberOfDescriptors].HardwareInstance = FmpHardwareInstance;
179 *NumberOfDescriptors = *NumberOfDescriptors + 1;
181 DEBUG ((DEBUG_INFO,
"EsrtFmpDxe: Add new image descriptor with GUID %g HardwareInstance:0x%x\n", &FmpImageInfoBuf->ImageTypeId, FmpHardwareInstance));
187 for (Index = 0; Index < Table->FwResourceCount; Index++, Entry++) {
188 if (!
CompareGuid (&Entry->FwClass, &FmpImageInfoBuf->ImageTypeId)) {
192 DEBUG ((DEBUG_INFO,
"EsrtFmpDxe: ESRT Entry already exists for FMP Instance with GUID %g\n", &Entry->FwClass));
197 Entry->FwVersion =
MIN (FmpImageInfoBuf->Version, Entry->FwVersion);
202 if (FmpVersion >= 2) {
206 Entry->LowestSupportedFwVersion =
208 FmpImageInfoBuf->LowestSupportedImageVersion,
209 Entry->LowestSupportedFwVersion
216 if (FmpVersion >= 3) {
225 Entry->LastAttemptStatus = FmpImageInfoBuf->LastAttemptStatus;
226 Entry->LastAttemptVersion = FmpImageInfoBuf->LastAttemptVersion;
228 Entry->LastAttemptVersion =
230 FmpImageInfoBuf->LastAttemptVersion,
231 Entry->LastAttemptVersion
245 CopyGuid (&Entry->FwClass, &FmpImageInfoBuf->ImageTypeId);
248 DEBUG ((DEBUG_INFO,
"EsrtFmpDxe: Found an ESRT entry for a System Device.\n"));
249 Entry->FwType = (UINT32)(ESRT_FW_TYPE_SYSTEMFIRMWARE);
251 Entry->FwType = (UINT32)(ESRT_FW_TYPE_DEVICEFIRMWARE);
254 Entry->FwVersion = FmpImageInfoBuf->Version;
255 Entry->LowestSupportedFwVersion = 0;
256 Entry->CapsuleFlags = 0;
257 Entry->LastAttemptVersion = 0;
258 Entry->LastAttemptStatus = 0;
263 if (FmpVersion >= 2) {
264 Entry->LowestSupportedFwVersion = FmpImageInfoBuf->LowestSupportedImageVersion;
270 if (FmpVersion >= 3) {
271 Entry->LastAttemptVersion = FmpImageInfoBuf->LastAttemptVersion;
272 Entry->LastAttemptStatus = FmpImageInfoBuf->LastAttemptStatus;
278 Table->FwResourceCount++;
303 OUT UINT32 *FmpImageInfoDescriptorVer,
304 OUT UINT8 *FmpImageInfoCount,
310 UINT32 PackageVersion;
311 CHAR16 *PackageVersionName;
315 Status = Fmp->GetImageInfo (
319 FmpImageInfoDescriptorVer,
325 if (Status != EFI_BUFFER_TOO_SMALL) {
326 DEBUG ((DEBUG_ERROR,
"EsrtFmpDxe: Unexpected Failure in GetImageInfo. Status = %r\n", Status));
331 if (FmpImageInfoBuf ==
NULL) {
332 DEBUG ((DEBUG_ERROR,
"EsrtFmpDxe: Failed to get memory for FMP descriptor.\n"));
336 PackageVersionName =
NULL;
337 Status = Fmp->GetImageInfo (
341 FmpImageInfoDescriptorVer,
347 if (PackageVersionName !=
NULL) {
351 if (EFI_ERROR (Status)) {
352 DEBUG ((DEBUG_ERROR,
"EsrtFmpDxe: Failure in GetImageInfo. Status = %r\n", Status));
357 return FmpImageInfoBuf;
377 UINT32 FmpImageInfoDescriptorVer;
378 UINT8 FmpImageInfoCount;
379 UINTN DescriptorSize;
380 UINT32 NumberOfDescriptors;
389 FmpImageInfoBuf =
NULL;
390 OrgFmpImageInfoBuf =
NULL;
392 HardwareInstances =
NULL;
395 &gEfiFirmwareManagementProtocolGuid,
399 if (EFI_ERROR (Status) || (Buffer ==
NULL)) {
406 for (Index = 0, NumberOfDescriptors = 0; Index < NoProtocols; Index++) {
409 &FmpImageInfoDescriptorVer,
413 if (FmpImageInfoBuf !=
NULL) {
414 NumberOfDescriptors += FmpImageInfoCount;
426 DEBUG ((DEBUG_ERROR,
"EsrtFmpDxe: Failed to allocate memory for ESRT.\n"));
432 if (HardwareInstances ==
NULL) {
433 DEBUG ((DEBUG_ERROR,
"EsrtFmpDxe: Failed to allocate memory for HW Instance Table.\n"));
446 NumberOfDescriptors = 0;
447 for (Index = 0; Index < NoProtocols; Index++) {
450 &FmpImageInfoDescriptorVer,
454 if (FmpImageInfoBuf ==
NULL) {
461 OrgFmpImageInfoBuf = FmpImageInfoBuf;
462 while (FmpImageInfoCount > 0) {
470 CreateEsrtEntry (Table, HardwareInstances, &NumberOfDescriptors, FmpImageInfoBuf, FmpImageInfoDescriptorVer);
481 OrgFmpImageInfoBuf =
NULL;
517 if (EFI_ERROR (Status)) {
521 DEBUG ((DEBUG_ERROR,
"EsrtFmpDxe: Can't install ESRT table because it is NULL. \n"));
527 gBS->CloseEvent (Event);
557 &EsrtReadyToBootEvent
561 if (EFI_ERROR (Status)) {
562 DEBUG ((DEBUG_ERROR,
"EsrtFmpDxe: Failed to register for ready to boot\n"));
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI EsrtFmpEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS InstallEfiSystemResourceTableInUefiConfigurationTable(IN EFI_SYSTEM_RESOURCE_TABLE *Table)
EFI_FIRMWARE_IMAGE_DESCRIPTOR * FmpGetFirmwareImageDescriptor(IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *Fmp, OUT UINT32 *FmpImageInfoDescriptorVer, OUT UINT8 *FmpImageInfoCount, OUT UINTN *DescriptorSize)
VOID EFIAPI EsrtReadyToBootEventNotify(IN EFI_EVENT Event, IN VOID *Context)
VOID EFIAPI PrintTable(IN EFI_SYSTEM_RESOURCE_TABLE *Table)
BOOLEAN IsSystemFmp(IN EFI_FIRMWARE_IMAGE_DESCRIPTOR *FmpImageInfo)
EFI_STATUS CreateEsrtEntry(IN OUT EFI_SYSTEM_RESOURCE_TABLE *Table, IN OUT GUID_HARDWAREINSTANCE_PAIR *HardwareInstances, IN OUT UINT32 *NumberOfDescriptors, IN EFI_FIRMWARE_IMAGE_DESCRIPTOR *FmpImageInfoBuf, IN UINT32 FmpVersion)
EFI_SYSTEM_RESOURCE_TABLE * CreateFmpBasedEsrt(VOID)
#define IMAGE_ATTRIBUTE_IN_USE
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG_CODE_BEGIN()
#define DEBUG(Expression)
#define PcdGetSize(TokenName)
#define PcdGetPtr(TokenName)
#define EFI_SYSTEM_RESOURCE_TABLE_FIRMWARE_RESOURCE_VERSION
#define LAST_ATTEMPT_STATUS_SUCCESS
EFI_STATUS EFIAPI EfiCreateEventReadyToBootEx(IN EFI_TPL NotifyTpl, IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL, IN VOID *NotifyContext OPTIONAL, OUT EFI_EVENT *ReadyToBootEvent)
EFI_STATUS EFIAPI EfiLocateProtocolBuffer(IN EFI_GUID *Protocol, OUT UINTN *NoProtocols, OUT VOID ***Buffer)
UINT64 AttributesSupported
UINT32 FwResourceCountMax