24 0x78ef0a56, 0x1cf0, 0x4535, { 0xb5, 0xda, 0xf6, 0xfd, 0x2f, 0x40, 0x5a, 0x11 }
43 FIRMWARE_MANAGEMENT_PRIVATE_DATA_SIGNATURE,
59 { 0x00000000, 0x0000,0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
131 Status = EFI_UNSUPPORTED;
142 if (Status == EFI_UNSUPPORTED) {
166 UINTN ImageTypeIdGuidSize;
168 FmpDeviceLibGuid =
NULL;
170 if (EFI_ERROR (Status)) {
171 if (Status != EFI_UNSUPPORTED) {
172 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): FmpDeviceLib GetImageTypeIdGuidPtr() returned invalid error %r\n",
mImageIdName, Status));
174 }
else if (FmpDeviceLibGuid ==
NULL) {
175 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): FmpDeviceLib GetImageTypeIdGuidPtr() returned invalid GUID\n",
mImageIdName));
176 Status = EFI_NOT_FOUND;
179 if (EFI_ERROR (Status)) {
180 ImageTypeIdGuidSize =
PcdGetSize (PcdFmpDeviceImageTypeIdGuid);
181 if (ImageTypeIdGuidSize ==
sizeof (
EFI_GUID)) {
186 "FmpDxe(%s): Fall back to ImageTypeIdGuid of gEfiCallerIdGuid. FmpDxe error: misconfiguration\n",
190 FmpDeviceLibGuid = &gEfiCallerIdGuid;
194 return FmpDeviceLibGuid;
229 UINT32 DeviceLibLowestSupportedVersion;
230 UINT32 VariableLowestSupportedVersion;
244 ReturnLsv =
PcdGet32 (PcdFmpDeviceBuildTimeLowestSupportedVersion);
249 DeviceLibLowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION;
251 if (EFI_ERROR (Status)) {
252 DeviceLibLowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION;
255 if (DeviceLibLowestSupportedVersion > ReturnLsv) {
256 ReturnLsv = DeviceLibLowestSupportedVersion;
263 if (VariableLowestSupportedVersion > ReturnLsv) {
264 ReturnLsv = VariableLowestSupportedVersion;
287 UINT32 DependenciesSize;
289 if (Private ==
NULL) {
290 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): PopulateDescriptor() - Private is NULL.\n",
mImageIdName));
294 if (Private->DescriptorPopulated) {
307 if (Status == EFI_UNSUPPORTED) {
323 if (Status == EFI_UNSUPPORTED) {
324 Private->RuntimeVersionSupported =
FALSE;
326 }
else if (EFI_ERROR (Status)) {
347 if (Status == EFI_UNSUPPORTED) {
348 DEBUG ((DEBUG_INFO,
"FmpDxe(%s): GetVersionString() unsupported in FmpDeviceLib.\n",
mImageIdName));
350 sizeof (VERSION_STRING_NOT_SUPPORTED),
351 VERSION_STRING_NOT_SUPPORTED
353 }
else if (EFI_ERROR (Status)) {
354 DEBUG ((DEBUG_INFO,
"FmpDxe(%s): GetVersionString() not available in FmpDeviceLib.\n",
mImageIdName));
356 sizeof (VERSION_STRING_NOT_AVAILABLE),
357 VERSION_STRING_NOT_AVAILABLE
389 if (EFI_ERROR (Status)) {
390 Private->Descriptor.
Size = 0;
399 Private->Descriptor.Dependencies =
NULL;
408 Private->DescriptorPopulated =
TRUE;
455 OUT UINT32 *DescriptorVersion,
456 OUT UINT8 *DescriptorCount,
458 OUT UINT32 *PackageVersion,
459 OUT CHAR16 **PackageVersionName
468 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): GetImageInfo() - This is NULL.\n",
mImageIdName));
469 Status = EFI_INVALID_PARAMETER;
476 Private = FIRMWARE_MANAGEMENT_PRIVATE_DATA_FROM_THIS (This);
482 if (ImageInfoSize ==
NULL) {
483 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): GetImageInfo() - ImageInfoSize is NULL.\n",
mImageIdName));
484 Status = EFI_INVALID_PARAMETER;
494 DEBUG ((DEBUG_VERBOSE,
"FmpDxe(%s): GetImageInfo() - ImageInfoSize is to small.\n",
mImageIdName));
495 Status = EFI_BUFFER_TOO_SMALL;
502 if ( (ImageInfo ==
NULL) || (DescriptorVersion ==
NULL) || (DescriptorCount ==
NULL) || (DescriptorSize ==
NULL)
503 || (PackageVersion ==
NULL))
505 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): GetImageInfo() - Pointer Parameter is NULL.\n",
mImageIdName));
506 Status = EFI_INVALID_PARAMETER;
526 *DescriptorCount = 1;
531 *PackageVersion = 0xFFFFFFFF;
579 return EFI_UNSUPPORTED;
586 Status = EFI_INVALID_PARAMETER;
593 Private = FIRMWARE_MANAGEMENT_PRIVATE_DATA_FROM_THIS (This);
599 if (ImageIndex != 1) {
600 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): GetImage() - Image Index Invalid.\n",
mImageIdName));
601 Status = EFI_INVALID_PARAMETER;
605 if (ImageSize ==
NULL) {
606 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): GetImage() - ImageSize Pointer Parameter is NULL.\n",
mImageIdName));
607 Status = EFI_INVALID_PARAMETER;
615 if (EFI_ERROR (Status)) {
619 if (*ImageSize < Size) {
621 DEBUG ((DEBUG_VERBOSE,
"FmpDxe(%s): GetImage() - ImageSize is to small.\n",
mImageIdName));
622 Status = EFI_BUFFER_TOO_SMALL;
627 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): GetImage() - Image Pointer Parameter is NULL.\n",
mImageIdName));
628 Status = EFI_INVALID_PARAMETER;
663 if ((((
UINTN)Image +
sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength) + AdditionalHeaderSize < (
UINTN)Image) || \
664 (((
UINTN)Image + sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength) + AdditionalHeaderSize >= (
UINTN)Image + ImageSize))
672 if (PayloadSize !=
NULL) {
673 *PayloadSize = ImageSize - (
sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength + AdditionalHeaderSize);
676 return (VOID *)((UINT8 *)Image +
sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength + AdditionalHeaderSize);
693 IN UINT32 AdditionalHeaderSize
696 UINT32 CalculatedSize;
699 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): GetAllHeaderSize() - Image is NULL.\n",
mImageIdName));
703 CalculatedSize =
sizeof (Image->MonotonicCount) +
704 AdditionalHeaderSize +
705 Image->AuthInfo.Hdr.dwLength;
710 if ((CalculatedSize <
sizeof (Image->MonotonicCount)) ||
711 (CalculatedSize < AdditionalHeaderSize) ||
712 (CalculatedSize < Image->AuthInfo.Hdr.dwLength))
720 return CalculatedSize;
768 OUT UINT32 *ImageUpdatable,
769 OUT UINT32 *LastAttemptStatus
773 UINT32 LocalLastAttemptStatus;
776 VOID *FmpPayloadHeader;
777 UINTN FmpPayloadSize;
779 UINT32 FmpHeaderSize;
783 UINTN PublicKeyDataLength;
784 UINT8 *PublicKeyDataXdr;
785 UINT8 *PublicKeyDataXdrEnd;
787 UINT32 DependenciesSize;
792 FmpPayloadHeader =
NULL;
798 DependenciesSize = 0;
801 return EFI_UNSUPPORTED;
804 if (LastAttemptStatus ==
NULL) {
805 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): CheckTheImageInternal() - LastAttemptStatus is NULL.\n",
mImageIdName));
806 Status = EFI_INVALID_PARAMETER;
817 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): CheckImage() - This is NULL.\n",
mImageIdName));
818 Status = EFI_INVALID_PARAMETER;
819 *LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_PROTOCOL_ARG_MISSING;
826 Private = FIRMWARE_MANAGEMENT_PRIVATE_DATA_FROM_THIS (This);
834 if (ImageUpdatable ==
NULL) {
835 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): CheckImage() - ImageUpdatable Pointer Parameter is NULL.\n",
mImageIdName));
836 Status = EFI_INVALID_PARAMETER;
837 *LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_IMAGE_NOT_UPDATABLE;
849 Private->DependenciesSatisfied =
TRUE;
852 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): CheckImage() - Image Pointer Parameter is NULL.\n",
mImageIdName));
857 *LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_IMAGE_NOT_PROVIDED;
858 return EFI_INVALID_PARAMETER;
861 PublicKeyDataXdr =
PcdGetPtr (PcdFmpDevicePkcs7CertBufferXdr);
862 PublicKeyDataXdrEnd = PublicKeyDataXdr +
PcdGetSize (PcdFmpDevicePkcs7CertBufferXdr);
864 if ((PublicKeyDataXdr ==
NULL) || (PublicKeyDataXdr == PublicKeyDataXdrEnd)) {
865 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): Invalid certificate, skipping it.\n",
mImageIdName));
866 Status = EFI_ABORTED;
867 LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_INVALID_CERTIFICATE;
872 for (Index = 1; PublicKeyDataXdr < PublicKeyDataXdrEnd; Index++) {
876 "FmpDxe(%s): Certificate #%d [%p..%p].\n",
884 if ((PublicKeyDataXdr +
sizeof (UINT32)) > PublicKeyDataXdrEnd) {
888 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): Certificate size extends beyond end of PCD, skipping it.\n",
mImageIdName));
889 Status = EFI_ABORTED;
890 LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_INVALID_KEY_LENGTH_VALUE;
897 PublicKeyDataLength =
SwapBytes32 (*(UINT32 *)(PublicKeyDataXdr));
901 PublicKeyDataXdr +=
sizeof (UINT32);
902 if (PublicKeyDataXdr + PublicKeyDataLength > PublicKeyDataXdrEnd) {
906 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): Certificate extends beyond end of PCD, skipping it.\n",
mImageIdName));
907 Status = EFI_ABORTED;
908 LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_INVALID_KEY_LENGTH;
912 PublicKeyData = PublicKeyDataXdr;
919 if (!EFI_ERROR (Status)) {
923 PublicKeyDataXdr += PublicKeyDataLength;
924 PublicKeyDataXdr = (UINT8 *)
ALIGN_POINTER (PublicKeyDataXdr,
sizeof (UINT32));
928 if (EFI_ERROR (Status)) {
929 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): CheckTheImage() - Authentication Failed %r.\n",
mImageIdName, Status));
931 *LastAttemptStatus = LocalLastAttemptStatus;
933 *LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_IMAGE_AUTH_FAILURE;
942 if (ImageIndex != 1) {
943 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): CheckImage() - Image Index Invalid.\n",
mImageIdName));
945 Status = EFI_INVALID_PARAMETER;
946 *LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_INVALID_IMAGE_INDEX;
960 Status = EFI_ABORTED;
968 if (FmpPayloadHeader ==
NULL) {
969 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): CheckTheImage() - GetFmpHeader failed.\n",
mImageIdName));
970 Status = EFI_ABORTED;
976 if (EFI_ERROR (Status)) {
977 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): CheckTheImage() - GetFmpPayloadHeaderVersion failed %r.\n",
mImageIdName, Status));
980 *LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_FMP_HEADER_VERSION;
987 if (Version < Private->Descriptor.LowestSupportedImageVersion) {
990 "FmpDxe(%s): CheckTheImage() - Version Lower than lowest supported version. 0x%08X < 0x%08X\n",
995 *LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_VERSION_TOO_LOW;
1007 &LocalLastAttemptStatus
1009 if (!Private->DependenciesSatisfied) {
1010 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): CheckTheImage() - Dependency check failed.\n",
mImageIdName));
1013 *LastAttemptStatus = LocalLastAttemptStatus;
1021 if (EFI_ERROR (Status)) {
1022 DEBUG ((DEBUG_ERROR,
"FmpDxe: CheckTheImage() - GetFmpPayloadHeaderSize failed %r.\n", Status));
1025 *LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_FMP_HEADER_SIZE;
1034 if (AllHeaderSize == 0) {
1035 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): CheckTheImage() - GetAllHeaderSize failed.\n",
mImageIdName));
1036 Status = EFI_ABORTED;
1037 *LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_ALL_HEADER_SIZE;
1041 RawSize = ImageSize - AllHeaderSize;
1047 if (EFI_ERROR (Status)) {
1053 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): CheckTheImage() - FmpDeviceLib CheckImage failed. Status = %r\n",
mImageIdName, Status));
1070 "FmpDxe(%s): CheckTheImage() - LastAttemptStatus %d from FmpDeviceCheckImageWithStatus() is invalid.\n",
1074 *LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
1107 IN UINT8 ImageIndex,
1110 OUT UINT32 *ImageUpdatable
1113 UINT32 LastAttemptStatus;
1115 return CheckTheImageInternal (This, ImageIndex, Image, ImageSize, ImageUpdatable, &LastAttemptStatus);
1168 IN UINT8 ImageIndex,
1173 OUT CHAR16 **AbortReason
1179 BOOLEAN BooleanValue;
1180 UINT32 FmpHeaderSize;
1182 UINTN FmpPayloadSize;
1183 UINT32 AllHeaderSize;
1184 UINT32 IncomingFwVersion;
1185 UINT32 LastAttemptStatus;
1187 UINT32 LowestSupportedVersion;
1189 UINT32 DependenciesSize;
1194 BooleanValue =
FALSE;
1199 IncomingFwVersion = 0;
1200 LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
1201 Dependencies =
NULL;
1202 DependenciesSize = 0;
1205 return EFI_UNSUPPORTED;
1209 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): SetTheImage() - This is NULL.\n",
mImageIdName));
1210 Status = EFI_INVALID_PARAMETER;
1211 LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_PROTOCOL_ARG_MISSING;
1218 Private = FIRMWARE_MANAGEMENT_PRIVATE_DATA_FROM_THIS (This);
1235 if (Private->FmpDeviceLocked) {
1236 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): SetTheImage() - Device is already locked. Can't update.\n",
mImageIdName));
1237 LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_DEVICE_LOCKED;
1238 Status = EFI_UNSUPPORTED;
1245 Status =
CheckTheImageInternal (This, ImageIndex, Image, ImageSize, &Updateable, &LastAttemptStatus);
1246 if (EFI_ERROR (Status)) {
1247 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): SetTheImage() - Check The Image failed with %r.\n",
mImageIdName, Status));
1261 if (FmpHeader ==
NULL) {
1262 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): SetTheImage() - GetFmpHeader failed.\n",
mImageIdName));
1264 Status = EFI_ABORTED;
1269 if (!EFI_ERROR (Status)) {
1279 "FmpDxe(%s): SetTheImage() - Check The Image returned that the Image was not valid for update. Updatable value = 0x%X.\n",
1282 if (Private->DependenciesSatisfied ==
FALSE) {
1283 LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSATISFIED_DEPENDENCIES;
1286 Status = EFI_ABORTED;
1290 if (Progress ==
NULL) {
1291 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): SetTheImage() - Invalid progress callback\n",
mImageIdName));
1292 LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_PROGRESS_CALLBACK_ERROR;
1293 Status = EFI_INVALID_PARAMETER;
1302 Status = Progress (1);
1303 if (EFI_ERROR (Status)) {
1304 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): SetTheImage() - Progress Callback failed with Status %r.\n",
mImageIdName, Status));
1311 if (EFI_ERROR (Status)) {
1312 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): SetTheImage() - CheckSystemPower - API call failed %r.\n",
mImageIdName, Status));
1313 LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_CHECK_POWER_API;
1317 if (!BooleanValue) {
1318 Status = EFI_ABORTED;
1321 "FmpDxe(%s): SetTheImage() - CheckSystemPower - returned False. Update not allowed due to System Power.\n",
mImageIdName)
1323 LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_PWR_EVT_BATT;
1333 if (EFI_ERROR (Status)) {
1334 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): SetTheImage() - CheckSystemThermal - API call failed %r.\n",
mImageIdName, Status));
1335 LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_CHECK_SYS_THERMAL_API;
1339 if (!BooleanValue) {
1340 Status = EFI_ABORTED;
1341 LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_THERMAL;
1344 "FmpDxe(%s): SetTheImage() - CheckSystemThermal - returned False. Update not allowed due to System Thermal.\n",
mImageIdName)
1355 if (EFI_ERROR (Status)) {
1356 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): SetTheImage() - CheckSystemEnvironment - API call failed %r.\n",
mImageIdName, Status));
1357 LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_CHECK_SYS_ENV_API;
1361 if (!BooleanValue) {
1362 Status = EFI_ABORTED;
1363 LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_SYSTEM_ENV;
1366 "FmpDxe(%s): SetTheImage() - CheckSystemEnvironment - returned False. Update not allowed due to System Environment.\n",
mImageIdName)
1383 if (EFI_ERROR (Status)) {
1384 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): SetTheImage() - GetFmpPayloadHeaderSize failed %r.\n",
mImageIdName, Status));
1385 LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_FMP_HEADER_SIZE;
1390 if (AllHeaderSize == 0) {
1391 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): SetTheImage() - GetAllHeaderSize failed.\n",
mImageIdName));
1392 LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_ALL_HEADER_SIZE;
1393 Status = EFI_ABORTED;
1406 (((UINT8 *)Image) + AllHeaderSize),
1407 ImageSize - AllHeaderSize,
1414 if (EFI_ERROR (Status)) {
1415 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): SetTheImage() SetImage from FmpDeviceLib failed. Status = %r.\n",
mImageIdName, Status));
1426 "FmpDxe(%s): SetTheImage() - LastAttemptStatus %d from FmpDeviceSetImageWithStatus() is invalid.\n",
1430 LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
1441 if (EFI_ERROR (Status)) {
1442 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): SetTheImage() SaveFmpDependency from FmpDependencyCheckLib failed. (%r)\n",
mImageIdName, Status));
1457 if (!Private->RuntimeVersionSupported) {
1466 LowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION;
1475 if (Private !=
NULL) {
1476 DEBUG ((DEBUG_INFO,
"FmpDxe(%s): SetTheImage() LastAttemptStatus: %u.\n",
mImageIdName, LastAttemptStatus));
1480 if (Progress !=
NULL) {
1491 if (Private !=
NULL) {
1492 Private->DescriptorPopulated =
FALSE;
1534 OUT UINT32 *PackageVersion,
1535 OUT CHAR16 **PackageVersionName,
1536 OUT UINT32 *PackageVersionNameMaxLen,
1537 OUT UINT64 *AttributesSupported,
1538 OUT UINT64 *AttributesSetting
1541 return EFI_UNSUPPORTED;
1582 IN UINT32 PackageVersion,
1583 IN CONST CHAR16 *PackageVersionName
1586 return EFI_UNSUPPORTED;
1607 if (Context ==
NULL) {
1608 ASSERT (Context !=
NULL);
1614 if (!Private->FmpDeviceLocked) {
1620 if (EFI_ERROR (Status)) {
1621 if (Status != EFI_UNSUPPORTED) {
1622 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): FmpDeviceLock() returned error. Status = %r\n",
mImageIdName, Status));
1624 DEBUG ((DEBUG_WARN,
"FmpDxe(%s): FmpDeviceLock() returned error. Status = %r\n",
mImageIdName, Status));
1628 Private->FmpDeviceLocked =
TRUE;
1655 Status =
gBS->OpenProtocol (
1657 &gEfiFirmwareManagementProtocolGuid,
1661 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1663 if (!EFI_ERROR (Status)) {
1664 return EFI_ALREADY_STARTED;
1671 sizeof (mFirmwareManagementPrivateDataTemplate),
1672 &mFirmwareManagementPrivateDataTemplate
1674 if (Private ==
NULL) {
1675 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): Failed to allocate memory for private structure.\n",
mImageIdName));
1676 Status = EFI_OUT_OF_RESOURCES;
1683 Private->Handle = Handle;
1684 Private->FmpDeviceContext =
NULL;
1686 if (Status == EFI_UNSUPPORTED) {
1687 Private->FmpDeviceContext =
NULL;
1688 }
else if (EFI_ERROR (Status)) {
1702 if (EFI_ERROR (Status)) {
1703 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): Failed to register variables to lock. Status = %r.\n",
mImageIdName, Status));
1705 DEBUG ((DEBUG_INFO,
"FmpDxe(%s): All variables registered to lock\n",
mImageIdName));
1711 Status =
gBS->CreateEventEx (
1717 &Private->FmpDeviceLockEvent
1719 if (EFI_ERROR (Status)) {
1720 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): Failed to register notification. Status = %r\n",
mImageIdName, Status));
1725 DEBUG ((DEBUG_VERBOSE,
"FmpDxe(%s): Not registering notification to call FmpDeviceLock() because mfg mode\n",
mImageIdName));
1731 Status =
gBS->InstallMultipleProtocolInterfaces (
1733 &gEfiFirmwareManagementProtocolGuid,
1739 if (EFI_ERROR (Status)) {
1740 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): Protocol install error. Status = %r.\n",
mImageIdName, Status));
1746 if (EFI_ERROR (Status)) {
1747 if (Private !=
NULL) {
1748 if (Private->FmpDeviceLockEvent !=
NULL) {
1749 gBS->CloseEvent (Private->FmpDeviceLockEvent);
1756 if (Private->FmpDeviceContext !=
NULL) {
1760 if (Private->VersionVariableName !=
NULL) {
1761 FreePool (Private->VersionVariableName);
1764 if (Private->LsvVariableName !=
NULL) {
1765 FreePool (Private->LsvVariableName);
1768 if (Private->LastAttemptStatusVariableName !=
NULL) {
1769 FreePool (Private->LastAttemptStatusVariableName);
1772 if (Private->LastAttemptVersionVariableName !=
NULL) {
1773 FreePool (Private->LastAttemptVersionVariableName);
1776 if (Private->FmpStateVariableName !=
NULL) {
1777 FreePool (Private->FmpStateVariableName);
1807 Status =
gBS->OpenProtocol (
1809 &gEfiFirmwareManagementProtocolGuid,
1813 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1815 if (EFI_ERROR (Status)) {
1816 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): Protocol open error. Status = %r.\n",
mImageIdName, Status));
1820 Private = FIRMWARE_MANAGEMENT_PRIVATE_DATA_FROM_THIS (Fmp);
1823 if (Private->FmpDeviceLockEvent !=
NULL) {
1824 gBS->CloseEvent (Private->FmpDeviceLockEvent);
1827 Status =
gBS->UninstallMultipleProtocolInterfaces (
1829 &gEfiFirmwareManagementProtocolGuid,
1835 if (EFI_ERROR (Status)) {
1836 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): Protocol uninstall error. Status = %r.\n",
mImageIdName, Status));
1844 if (Private->FmpDeviceContext !=
NULL) {
1848 if (Private->VersionVariableName !=
NULL) {
1849 FreePool (Private->VersionVariableName);
1852 if (Private->LsvVariableName !=
NULL) {
1853 FreePool (Private->LsvVariableName);
1856 if (Private->LastAttemptStatusVariableName !=
NULL) {
1857 FreePool (Private->LastAttemptStatusVariableName);
1860 if (Private->LastAttemptVersionVariableName !=
NULL) {
1861 FreePool (Private->LastAttemptVersionVariableName);
1864 if (Private->FmpStateVariableName !=
NULL) {
1865 FreePool (Private->FmpStateVariableName);
1918 DEBUG ((DEBUG_ERROR,
"FmpDxe: Use of default FILE_GUID detected. FILE_GUID must be set to a unique value.\n"));
1920 return EFI_UNSUPPORTED;
1931 DEBUG ((DEBUG_ERROR,
"FmpDxe(%g): PcdFmpDeviceImageIdName is an empty string.\n", &gEfiCallerIdGuid));
1933 return EFI_UNSUPPORTED;
1952 mLockGuid = &gEfiEndOfDxeEventGroupGuid;
1966 if (Status == EFI_UNSUPPORTED) {
1968 DEBUG ((DEBUG_INFO,
"FmpDxe(%s): FmpDeviceLib registration returned EFI_UNSUPPORTED. Installing single FMP instance.\n",
mImageIdName));
1970 if (Status == EFI_UNSUPPORTED) {
1973 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): FmpDeviceLib RegisterFmpInstaller and RegisterFmpUninstaller do not match.\n",
mImageIdName));
1974 Status = EFI_UNSUPPORTED;
1976 }
else if (EFI_ERROR (Status)) {
1977 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): FmpDeviceLib registration returned %r. No FMP installed.\n",
mImageIdName, Status));
1981 "FmpDxe(%s): FmpDeviceLib registration returned EFI_SUCCESS. Expect FMP to be installed during the BDS/Device connection phase.\n",
1985 if (EFI_ERROR (Status)) {
1986 DEBUG ((DEBUG_ERROR,
"FmpDxe(%s): FmpDeviceLib RegisterFmpInstaller and RegisterFmpUninstaller do not match.\n",
mImageIdName));
UINT32 EFIAPI SwapBytes32(IN UINT32 Value)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
EFI_STATUS EFIAPI CheckSystemThermal(OUT BOOLEAN *Good)
BOOLEAN EFIAPI IsLowestSupportedVersionCheckRequired(VOID)
EFI_STATUS EFIAPI CheckSystemPower(OUT BOOLEAN *Good)
BOOLEAN EFIAPI IsLockFmpDeviceAtLockEventGuidRequired(VOID)
EFI_STATUS EFIAPI CheckSystemEnvironment(OUT BOOLEAN *Good)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
#define IMAGE_UPDATABLE_INVALID
#define IMAGE_ATTRIBUTE_AUTHENTICATION_REQUIRED
#define IMAGE_ATTRIBUTE_IMAGE_UPDATABLE
#define EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION
#define IMAGE_UPDATABLE_INVALID_OLD
#define IMAGE_UPDATABLE_INVALID_TYPE
#define IMAGE_ATTRIBUTE_DEPENDENCY
#define IMAGE_UPDATABLE_VALID
EFI_STATUS(EFIAPI * EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS)(IN UINTN Completion)
EFI_GUID gEdkiiFirmwareManagementProgressProtocolGuid
RETURN_STATUS EFIAPI AuthenticateFmpImage(IN EFI_FIRMWARE_IMAGE_AUTHENTICATION *Image, IN UINTN ImageSize, IN CONST UINT8 *PublicKeyData, IN UINTN PublicKeyDataLength)
BOOLEAN EFIAPI CheckFmpDependency(IN EFI_GUID ImageTypeId, IN UINT32 Version, IN EFI_FIRMWARE_IMAGE_DEP *Dependencies OPTIONAL, IN UINT32 DependenciesSize, OUT UINT32 *LastAttemptStatus OPTIONAL)
EFI_FIRMWARE_IMAGE_DEP *EFIAPI GetFmpDependency(OUT UINT32 *DepexSize)
EFI_STATUS EFIAPI SaveFmpDependency(IN EFI_FIRMWARE_IMAGE_DEP *Depex, IN UINT32 DepexSize)
EFI_FIRMWARE_IMAGE_DEP *EFIAPI GetImageDependency(IN EFI_FIRMWARE_IMAGE_AUTHENTICATION *Image, IN UINTN ImageSize, OUT UINT32 *DepexSize, OUT UINT32 *LastAttemptStatus OPTIONAL)
EFI_STATUS EFIAPI FmpDeviceGetImage(OUT VOID *Image, IN OUT UINTN *ImageSize)
EFI_STATUS EFIAPI FmpDeviceSetImageWithStatus(IN CONST VOID *Image, IN UINTN ImageSize, IN CONST VOID *VendorCode OPTIONAL, IN EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS Progress OPTIONAL, IN UINT32 CapsuleFwVersion, OUT CHAR16 **AbortReason, OUT UINT32 *LastAttemptStatus)
EFI_STATUS EFIAPI FmpDeviceGetSize(OUT UINTN *Size)
EFI_STATUS EFIAPI FmpDeviceLock(VOID)
EFI_STATUS EFIAPI FmpDeviceGetVersion(OUT UINT32 *Version)
EFI_STATUS EFIAPI FmpDeviceCheckImageWithStatus(IN CONST VOID *Image, IN UINTN ImageSize, OUT UINT32 *ImageUpdatable, OUT UINT32 *LastAttemptStatus)
EFI_STATUS EFIAPI FmpDeviceGetAttributes(OUT UINT64 *Supported, OUT UINT64 *Setting)
EFI_STATUS EFIAPI RegisterFmpInstaller(IN FMP_DEVICE_LIB_REGISTER_FMP_INSTALLER FmpInstaller)
EFI_STATUS EFIAPI FmpDeviceGetHardwareInstance(OUT UINT64 *HardwareInstance)
EFI_STATUS EFIAPI FmpDeviceSetContext(IN EFI_HANDLE Handle, IN OUT VOID **Context)
EFI_STATUS EFIAPI FmpDeviceGetLowestSupportedVersion(OUT UINT32 *LowestSupportedVersion)
EFI_STATUS EFIAPI FmpDeviceGetVersionString(OUT CHAR16 **VersionString)
EFI_STATUS EFIAPI FmpDeviceGetImageTypeIdGuidPtr(OUT EFI_GUID **Guid)
EFI_STATUS EFIAPI RegisterFmpUninstaller(IN FMP_DEVICE_LIB_REGISTER_FMP_UNINSTALLER FmpUninstaller)
BOOLEAN mFmpSingleInstance
EFI_STATUS EFIAPI SetTheImage(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)
EFI_STATUS EFIAPI FmpDxeLibDestructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI CheckTheImage(IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, IN UINT8 ImageIndex, IN CONST VOID *Image, IN UINTN ImageSize, OUT UINT32 *ImageUpdatable)
EFI_STATUS EFIAPI SetPackageInfo(IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, IN CONST VOID *Image, IN UINTN ImageSize, IN CONST VOID *VendorCode, IN UINT32 PackageVersion, IN CONST CHAR16 *PackageVersionName)
EFI_STATUS EFIAPI GetTheImageInfo(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 UninstallFmpInstance(IN EFI_HANDLE Handle)
EFI_FIRMWARE_MANAGEMENT_UPDATE_IMAGE_PROGRESS mProgressFunc
VOID EFIAPI FmpDxeLockEventNotify(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS EFIAPI GetPackageInfo(IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, OUT UINT32 *PackageVersion, OUT CHAR16 **PackageVersionName, OUT UINT32 *PackageVersionNameMaxLen, OUT UINT64 *AttributesSupported, OUT UINT64 *AttributesSetting)
EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL mFmpProgress
EFI_STATUS EFIAPI FmpDxeEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI InstallFmpInstance(IN EFI_HANDLE Handle)
EFI_STATUS EFIAPI GetTheImage(IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, IN UINT8 ImageIndex, IN OUT VOID *Image, IN OUT UINTN *ImageSize)
const EFI_GUID mDefaultModuleFileGuid
UINT32 GetLowestSupportedVersion(FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private)
EFI_STATUS EFIAPI FmpDxeProgress(IN UINTN Completion)
VOID PopulateDescriptor(FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private)
CHAR16 * GetImageTypeNameString(VOID)
EFI_STATUS EFIAPI CheckTheImageInternal(IN EFI_FIRMWARE_MANAGEMENT_PROTOCOL *This, IN UINT8 ImageIndex, IN CONST VOID *Image, IN UINTN ImageSize, OUT UINT32 *ImageUpdatable, OUT UINT32 *LastAttemptStatus)
UINT32 GetAllHeaderSize(IN CONST EFI_FIRMWARE_IMAGE_AUTHENTICATION *Image, IN UINT32 AdditionalHeaderSize)
EFI_GUID * GetImageTypeIdGuid(VOID)
VOID * GetFmpHeader(IN CONST EFI_FIRMWARE_IMAGE_AUTHENTICATION *Image, IN CONST UINTN ImageSize, IN CONST UINTN AdditionalHeaderSize, OUT UINTN *PayloadSize OPTIONAL)
@ LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_FMP_HEADER
#define LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE
#define LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE
#define ALIGN_POINTER(Pointer, Alignment)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define PcdGetSize(TokenName)
#define PcdGet8(TokenName)
#define PcdGet32(TokenName)
#define PcdGetPtr(TokenName)
#define FeaturePcdGet(TokenName)
#define LAST_ATTEMPT_STATUS_SUCCESS
UINT32 GetLastAttemptStatusFromVariable(IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private)
VOID SetVersionInVariable(IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private, IN UINT32 Version)
UINT32 GetLastAttemptVersionFromVariable(IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private)
UINT32 GetLowestSupportedVersionFromVariable(IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private)
VOID SetLowestSupportedVersionInVariable(IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private, IN UINT32 LowestSupportedVersion)
VOID GenerateFmpVariableNames(IN OUT FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private)
UINT32 GetVersionFromVariable(IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private)
VOID SetLastAttemptStatusInVariable(IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private, IN UINT32 LastAttemptStatus)
EFI_STATUS LockAllFmpVariables(FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private)
VOID SetLastAttemptVersionInVariable(IN FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private, IN UINT32 LastAttemptVersion)
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION ProgressBarForegroundColor
UINT64 AttributesSupported
UINT32 LastAttemptVersion
UINT32 LowestSupportedImageVersion