diff options
22 files changed, 838 insertions, 694 deletions
diff --git a/FmpDevicePkg/CapsuleUpdatePolicyDxe/CapsuleUpdatePolicyDxe.c b/FmpDevicePkg/CapsuleUpdatePolicyDxe/CapsuleUpdatePolicyDxe.c index 1035fd67dd..9d6fc6789d 100644 --- a/FmpDevicePkg/CapsuleUpdatePolicyDxe/CapsuleUpdatePolicyDxe.c +++ b/FmpDevicePkg/CapsuleUpdatePolicyDxe/CapsuleUpdatePolicyDxe.c @@ -50,7 +50,6 @@ CapsuleUpdatePolicyCheckSystemPower ( return CheckSystemPower (Good);
}
-
/**
Determines if the system thermal state supports a capsule update.
@@ -159,12 +158,13 @@ CapsuleUpdatePolicyInitialize ( IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEdkiiCapsuleUpdatePolicyProtocolGuid);
Status = gBS->InstallMultipleProtocolInterfaces (
&mHandle,
- &gEdkiiCapsuleUpdatePolicyProtocolGuid, &mCapsuleUpdatePolicy,
+ &gEdkiiCapsuleUpdatePolicyProtocolGuid,
+ &mCapsuleUpdatePolicy,
NULL
);
ASSERT_EFI_ERROR (Status);
diff --git a/FmpDevicePkg/FmpDxe/DetectTestKey.c b/FmpDevicePkg/FmpDxe/DetectTestKey.c index 0e10d5ee17..75dfce16bb 100644 --- a/FmpDevicePkg/FmpDxe/DetectTestKey.c +++ b/FmpDevicePkg/FmpDxe/DetectTestKey.c @@ -54,7 +54,7 @@ DetectTestKey ( //
PublicKeyDataXdr = PcdGetPtr (PcdFmpDevicePkcs7CertBufferXdr);
PublicKeyDataXdrEnd = PublicKeyDataXdr + PcdGetSize (PcdFmpDevicePkcs7CertBufferXdr);
- if (PublicKeyDataXdr == NULL || PublicKeyDataXdr == PublicKeyDataXdrEnd) {
+ if ((PublicKeyDataXdr == NULL) || (PublicKeyDataXdr == PublicKeyDataXdrEnd)) {
return;
}
@@ -76,6 +76,7 @@ DetectTestKey ( //
break;
}
+
//
// Read key length stored in big endian format
//
@@ -100,10 +101,12 @@ DetectTestKey ( TestKeyUsed = TRUE;
break;
}
+
if (!Sha256Update (HashContext, PublicKeyDataXdr, PublicKeyDataLength)) {
TestKeyUsed = TRUE;
break;
}
+
if (!Sha256Final (HashContext, Digest)) {
TestKeyUsed = TRUE;
break;
@@ -121,7 +124,7 @@ DetectTestKey ( // Point to start of next key
//
PublicKeyDataXdr += PublicKeyDataLength;
- PublicKeyDataXdr = (UINT8 *)ALIGN_POINTER (PublicKeyDataXdr, sizeof (UINT32));
+ PublicKeyDataXdr = (UINT8 *)ALIGN_POINTER (PublicKeyDataXdr, sizeof (UINT32));
}
//
diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c index 6b0675ea38..197df28c8d 100644 --- a/FmpDevicePkg/FmpDxe/FmpDxe.c +++ b/FmpDevicePkg/FmpDxe/FmpDxe.c @@ -40,8 +40,8 @@ EDKII_FIRMWARE_MANAGEMENT_PROGRESS_PROTOCOL mFmpProgress; // Protocol instance
//
const FIRMWARE_MANAGEMENT_PRIVATE_DATA mFirmwareManagementPrivateDataTemplate = {
- FIRMWARE_MANAGEMENT_PRIVATE_DATA_SIGNATURE, // Signature
- NULL, // Handle
+ FIRMWARE_MANAGEMENT_PRIVATE_DATA_SIGNATURE, // Signature
+ NULL, // Handle
{ // Fmp
GetTheImageInfo,
GetTheImage,
@@ -50,13 +50,14 @@ const FIRMWARE_MANAGEMENT_PRIVATE_DATA mFirmwareManagementPrivateDataTemplate = GetPackageInfo,
SetPackageInfo
},
- FALSE, // DescriptorPopulated
- { // Desc
- 1, // ImageIndex
+ FALSE, // DescriptorPopulated
+ { // Desc
+ 1, // ImageIndex
//
// ImageTypeId
//
- { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} },
+ { 0x00000000, 0x0000,0x0000, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
+ },
1, // ImageId
NULL, // ImageIdName
0, // Version
@@ -70,18 +71,18 @@ const FIRMWARE_MANAGEMENT_PRIVATE_DATA mFirmwareManagementPrivateDataTemplate = 0, // LastAttemptStatus
0 // HardwareInstance
},
- NULL, // ImageIdName
- NULL, // VersionName
- TRUE, // RuntimeVersionSupported
- NULL, // FmpDeviceLockEvent
- FALSE, // FmpDeviceLocked
- NULL, // FmpDeviceContext
- NULL, // VersionVariableName
- NULL, // LsvVariableName
- NULL, // LastAttemptStatusVariableName
- NULL, // LastAttemptVersionVariableName
- NULL, // FmpStateVariableName
- TRUE // DependenciesSatisfied
+ NULL, // ImageIdName
+ NULL, // VersionName
+ TRUE, // RuntimeVersionSupported
+ NULL, // FmpDeviceLockEvent
+ FALSE, // FmpDeviceLocked
+ NULL, // FmpDeviceContext
+ NULL, // VersionVariableName
+ NULL, // LsvVariableName
+ NULL, // LastAttemptStatusVariableName
+ NULL, // LastAttemptVersionVariableName
+ NULL, // FmpStateVariableName
+ TRUE // DependenciesSatisfied
};
///
@@ -125,7 +126,7 @@ FmpDxeProgress ( IN UINTN Completion
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
Status = EFI_UNSUPPORTED;
@@ -165,7 +166,7 @@ GetImageTypeIdGuid ( UINTN ImageTypeIdGuidSize;
FmpDeviceLibGuid = NULL;
- Status = FmpDeviceGetImageTypeIdGuidPtr (&FmpDeviceLibGuid);
+ Status = FmpDeviceGetImageTypeIdGuidPtr (&FmpDeviceLibGuid);
if (EFI_ERROR (Status)) {
if (Status != EFI_UNSUPPORTED) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): FmpDeviceLib GetImageTypeIdGuidPtr() returned invalid error %r\n", mImageIdName, Status));
@@ -174,6 +175,7 @@ GetImageTypeIdGuid ( DEBUG ((DEBUG_ERROR, "FmpDxe(%s): FmpDeviceLib GetImageTypeIdGuidPtr() returned invalid GUID\n", mImageIdName));
Status = EFI_NOT_FOUND;
}
+
if (EFI_ERROR (Status)) {
ImageTypeIdGuidSize = PcdGetSize (PcdFmpDeviceImageTypeIdGuid);
if (ImageTypeIdGuidSize == sizeof (EFI_GUID)) {
@@ -183,6 +185,7 @@ GetImageTypeIdGuid ( FmpDeviceLibGuid = &gEfiCallerIdGuid;
}
}
+
return FmpDeviceLibGuid;
}
@@ -239,7 +242,7 @@ GetLowestSupportedVersion ( // Check the FmpDeviceLib
//
DeviceLibLowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION;
- Status = FmpDeviceGetLowestSupportedVersion (&DeviceLibLowestSupportedVersion);
+ Status = FmpDeviceGetLowestSupportedVersion (&DeviceLibLowestSupportedVersion);
if (EFI_ERROR (Status)) {
DeviceLibLowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION;
}
@@ -288,9 +291,9 @@ PopulateDescriptor ( }
Private->Descriptor.ImageIndex = 1;
- CopyGuid (&Private->Descriptor.ImageTypeId, GetImageTypeIdGuid());
+ CopyGuid (&Private->Descriptor.ImageTypeId, GetImageTypeIdGuid ());
Private->Descriptor.ImageId = Private->Descriptor.ImageIndex;
- Private->Descriptor.ImageIdName = GetImageTypeNameString();
+ Private->Descriptor.ImageIdName = GetImageTypeNameString ();
//
// Get the hardware instance from FmpDeviceLib
@@ -314,12 +317,12 @@ PopulateDescriptor ( Status = FmpDeviceGetVersion (&Private->Descriptor.Version);
if (Status == EFI_UNSUPPORTED) {
Private->RuntimeVersionSupported = FALSE;
- Private->Descriptor.Version = GetVersionFromVariable (Private);
+ Private->Descriptor.Version = GetVersionFromVariable (Private);
} else if (EFI_ERROR (Status)) {
//
// Unexpected error. Use default version.
//
- DEBUG ((DEBUG_ERROR, "FmpDxe(%s): GetVersion() from FmpDeviceLib (%s) returned %r\n", mImageIdName, GetImageTypeNameString(), Status));
+ DEBUG ((DEBUG_ERROR, "FmpDxe(%s): GetVersion() from FmpDeviceLib (%s) returned %r\n", mImageIdName, GetImageTypeNameString (), Status));
Private->Descriptor.Version = DEFAULT_VERSION;
}
@@ -491,8 +494,9 @@ GetTheImageInfo ( //
// Confirm that buffer isn't null
//
- if ( (ImageInfo == NULL) || (DescriptorVersion == NULL) || (DescriptorCount == NULL) || (DescriptorSize == NULL)
- || (PackageVersion == NULL)) {
+ if ( (ImageInfo == NULL) || (DescriptorVersion == NULL) || (DescriptorCount == NULL) || (DescriptorSize == NULL)
+ || (PackageVersion == NULL))
+ {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): GetImageInfo() - Pointer Parameter is NULL.\n", mImageIdName));
Status = EFI_INVALID_PARAMETER;
goto cleanup;
@@ -514,8 +518,8 @@ GetTheImageInfo ( CopyMem (ImageInfo, &Private->Descriptor, sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR));
*DescriptorVersion = EFI_FIRMWARE_IMAGE_DESCRIPTOR_VERSION;
- *DescriptorCount = 1;
- *DescriptorSize = sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR);
+ *DescriptorCount = 1;
+ *DescriptorSize = sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR);
//
// means unsupported
//
@@ -606,6 +610,7 @@ GetTheImage ( if (EFI_ERROR (Status)) {
Size = 0;
}
+
if (*ImageSize < Size) {
*ImageSize = Size;
DEBUG ((DEBUG_VERBOSE, "FmpDxe(%s): GetImage() - ImageSize is to small.\n", mImageIdName));
@@ -650,8 +655,9 @@ GetFmpHeader ( //
// Check to make sure that operation can be safely performed.
//
- if (((UINTN)Image + sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength) + AdditionalHeaderSize < (UINTN)Image || \
- ((UINTN)Image + sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength) + AdditionalHeaderSize >= (UINTN)Image + ImageSize) {
+ if ((((UINTN)Image + sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength) + AdditionalHeaderSize < (UINTN)Image) || \
+ (((UINTN)Image + sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength) + AdditionalHeaderSize >= (UINTN)Image + ImageSize))
+ {
//
// Pointer overflow. Invalid image.
//
@@ -696,9 +702,10 @@ GetAllHeaderSize ( //
// Check to make sure that operation can be safely performed.
//
- if (CalculatedSize < sizeof (Image->MonotonicCount) ||
- CalculatedSize < AdditionalHeaderSize ||
- CalculatedSize < Image->AuthInfo.Hdr.dwLength ) {
+ if ((CalculatedSize < sizeof (Image->MonotonicCount)) ||
+ (CalculatedSize < AdditionalHeaderSize) ||
+ (CalculatedSize < Image->AuthInfo.Hdr.dwLength))
+ {
//
// Integer overflow. Invalid image.
//
@@ -774,16 +781,16 @@ CheckTheImageInternal ( EFI_FIRMWARE_IMAGE_DEP *Dependencies;
UINT32 DependenciesSize;
- Status = EFI_SUCCESS;
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
- RawSize = 0;
- FmpPayloadHeader = NULL;
- FmpPayloadSize = 0;
- Version = 0;
- FmpHeaderSize = 0;
- AllHeaderSize = 0;
- Dependencies = NULL;
- DependenciesSize = 0;
+ Status = EFI_SUCCESS;
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
+ RawSize = 0;
+ FmpPayloadHeader = NULL;
+ FmpPayloadSize = 0;
+ Version = 0;
+ FmpHeaderSize = 0;
+ AllHeaderSize = 0;
+ Dependencies = NULL;
+ DependenciesSize = 0;
if (!FeaturePcdGet (PcdFmpDeviceStorageAccessEnable)) {
return EFI_UNSUPPORTED;
@@ -803,7 +810,7 @@ CheckTheImageInternal ( if (This == NULL) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckImage() - This is NULL.\n", mImageIdName));
- Status = EFI_INVALID_PARAMETER;
+ Status = EFI_INVALID_PARAMETER;
*LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_PROTOCOL_ARG_MISSING;
goto cleanup;
}
@@ -821,13 +828,13 @@ CheckTheImageInternal ( if (ImageUpdatable == NULL) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckImage() - ImageUpdatable Pointer Parameter is NULL.\n", mImageIdName));
- Status = EFI_INVALID_PARAMETER;
+ Status = EFI_INVALID_PARAMETER;
*LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_IMAGE_NOT_UPDATABLE;
goto cleanup;
}
//
- //Set to valid and then if any tests fail it will update this flag.
+ // Set to valid and then if any tests fail it will update this flag.
//
*ImageUpdatable = IMAGE_UPDATABLE_VALID;
@@ -841,7 +848,7 @@ CheckTheImageInternal ( //
// not sure if this is needed
//
- *ImageUpdatable = IMAGE_UPDATABLE_INVALID;
+ *ImageUpdatable = IMAGE_UPDATABLE_INVALID;
*LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_IMAGE_NOT_PROVIDED;
return EFI_INVALID_PARAMETER;
}
@@ -849,9 +856,9 @@ CheckTheImageInternal ( PublicKeyDataXdr = PcdGetPtr (PcdFmpDevicePkcs7CertBufferXdr);
PublicKeyDataXdrEnd = PublicKeyDataXdr + PcdGetSize (PcdFmpDevicePkcs7CertBufferXdr);
- if (PublicKeyDataXdr == NULL || (PublicKeyDataXdr == PublicKeyDataXdrEnd)) {
+ if ((PublicKeyDataXdr == NULL) || (PublicKeyDataXdr == PublicKeyDataXdrEnd)) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Invalid certificate, skipping it.\n", mImageIdName));
- Status = EFI_ABORTED;
+ Status = EFI_ABORTED;
LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_INVALID_CERTIFICATE;
} else {
//
@@ -861,11 +868,11 @@ CheckTheImageInternal ( Index++;
DEBUG (
(DEBUG_INFO,
- "FmpDxe(%s): Certificate #%d [%p..%p].\n",
- mImageIdName,
- Index,
- PublicKeyDataXdr,
- PublicKeyDataXdrEnd
+ "FmpDxe(%s): Certificate #%d [%p..%p].\n",
+ mImageIdName,
+ Index,
+ PublicKeyDataXdr,
+ PublicKeyDataXdrEnd
)
);
@@ -874,10 +881,11 @@ CheckTheImageInternal ( // Key data extends beyond end of PCD
//
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Certificate size extends beyond end of PCD, skipping it.\n", mImageIdName));
- Status = EFI_ABORTED;
+ Status = EFI_ABORTED;
LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_INVALID_KEY_LENGTH_VALUE;
break;
}
+
//
// Read key length stored in big-endian format
//
@@ -891,22 +899,24 @@ CheckTheImageInternal ( // Key data extends beyond end of PCD
//
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Certificate extends beyond end of PCD, skipping it.\n", mImageIdName));
- Status = EFI_ABORTED;
+ Status = EFI_ABORTED;
LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_INVALID_KEY_LENGTH;
break;
}
+
PublicKeyData = PublicKeyDataXdr;
- Status = AuthenticateFmpImage (
- (EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image,
- ImageSize,
- PublicKeyData,
- PublicKeyDataLength
- );
+ Status = AuthenticateFmpImage (
+ (EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image,
+ ImageSize,
+ PublicKeyData,
+ PublicKeyDataLength
+ );
if (!EFI_ERROR (Status)) {
break;
}
+
PublicKeyDataXdr += PublicKeyDataLength;
- PublicKeyDataXdr = (UINT8 *)ALIGN_POINTER (PublicKeyDataXdr, sizeof (UINT32));
+ PublicKeyDataXdr = (UINT8 *)ALIGN_POINTER (PublicKeyDataXdr, sizeof (UINT32));
}
}
@@ -917,6 +927,7 @@ CheckTheImageInternal ( } else {
*LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_IMAGE_AUTH_FAILURE;
}
+
goto cleanup;
}
@@ -925,8 +936,8 @@ CheckTheImageInternal ( //
if (ImageIndex != 1) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckImage() - Image Index Invalid.\n", mImageIdName));
- *ImageUpdatable = IMAGE_UPDATABLE_INVALID_TYPE;
- Status = EFI_INVALID_PARAMETER;
+ *ImageUpdatable = IMAGE_UPDATABLE_INVALID_TYPE;
+ Status = EFI_INVALID_PARAMETER;
*LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_INVALID_IMAGE_INDEX;
goto cleanup;
}
@@ -935,7 +946,7 @@ CheckTheImageInternal ( // Get the dependency from Image.
//
Dependencies = GetImageDependency (
- (EFI_FIRMWARE_IMAGE_AUTHENTICATION *) Image,
+ (EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image,
ImageSize,
&DependenciesSize,
LastAttemptStatus
@@ -948,18 +959,19 @@ CheckTheImageInternal ( //
// Check the FmpPayloadHeader
//
- FmpPayloadHeader = GetFmpHeader ( (EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, ImageSize, DependenciesSize, &FmpPayloadSize );
+ FmpPayloadHeader = GetFmpHeader ((EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, ImageSize, DependenciesSize, &FmpPayloadSize);
if (FmpPayloadHeader == NULL) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - GetFmpHeader failed.\n", mImageIdName));
- Status = EFI_ABORTED;
+ Status = EFI_ABORTED;
*LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_FMP_HEADER;
goto cleanup;
}
+
Status = GetFmpPayloadHeaderVersion (FmpPayloadHeader, FmpPayloadSize, &Version);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - GetFmpPayloadHeaderVersion failed %r.\n", mImageIdName, Status));
- *ImageUpdatable = IMAGE_UPDATABLE_INVALID;
- Status = EFI_SUCCESS;
+ *ImageUpdatable = IMAGE_UPDATABLE_INVALID;
+ Status = EFI_SUCCESS;
*LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_FMP_HEADER_VERSION;
goto cleanup;
}
@@ -970,11 +982,11 @@ CheckTheImageInternal ( if (Version < Private->Descriptor.LowestSupportedImageVersion) {
DEBUG (
(DEBUG_ERROR,
- "FmpDxe(%s): CheckTheImage() - Version Lower than lowest supported version. 0x%08X < 0x%08X\n",
- mImageIdName, Version, Private->Descriptor.LowestSupportedImageVersion)
+ "FmpDxe(%s): CheckTheImage() - Version Lower than lowest supported version. 0x%08X < 0x%08X\n",
+ mImageIdName, Version, Private->Descriptor.LowestSupportedImageVersion)
);
- *ImageUpdatable = IMAGE_UPDATABLE_INVALID_OLD;
- Status = EFI_SUCCESS;
+ *ImageUpdatable = IMAGE_UPDATABLE_INVALID_OLD;
+ Status = EFI_SUCCESS;
*LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_VERSION_TOO_LOW;
goto cleanup;
}
@@ -991,8 +1003,8 @@ CheckTheImageInternal ( );
if (!Private->DependenciesSatisfied) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - Dependency check failed.\n", mImageIdName));
- *ImageUpdatable = IMAGE_UPDATABLE_INVALID;
- Status = EFI_SUCCESS;
+ *ImageUpdatable = IMAGE_UPDATABLE_INVALID;
+ Status = EFI_SUCCESS;
*LastAttemptStatus = LocalLastAttemptStatus;
goto cleanup;
}
@@ -1003,8 +1015,8 @@ CheckTheImageInternal ( Status = GetFmpPayloadHeaderSize (FmpPayloadHeader, FmpPayloadSize, &FmpHeaderSize);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "FmpDxe: CheckTheImage() - GetFmpPayloadHeaderSize failed %r.\n", Status));
- *ImageUpdatable = IMAGE_UPDATABLE_INVALID;
- Status = EFI_SUCCESS;
+ *ImageUpdatable = IMAGE_UPDATABLE_INVALID;
+ Status = EFI_SUCCESS;
*LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_FMP_HEADER_SIZE;
goto cleanup;
}
@@ -1013,19 +1025,20 @@ CheckTheImageInternal ( // Call FmpDevice Lib Check Image on the
// Raw payload. So all headers need stripped off
//
- AllHeaderSize = GetAllHeaderSize ( (EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, FmpHeaderSize + DependenciesSize);
+ AllHeaderSize = GetAllHeaderSize ((EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, FmpHeaderSize + DependenciesSize);
if (AllHeaderSize == 0) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - GetAllHeaderSize failed.\n", mImageIdName));
- Status = EFI_ABORTED;
+ Status = EFI_ABORTED;
*LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_ALL_HEADER_SIZE;
goto cleanup;
}
+
RawSize = ImageSize - AllHeaderSize;
//
// FmpDeviceLib CheckImage function to do any specific checks
//
- Status = FmpDeviceCheckImageWithStatus ((((UINT8 *) Image) + AllHeaderSize), RawSize, ImageUpdatable, LastAttemptStatus);
+ Status = FmpDeviceCheckImageWithStatus ((((UINT8 *)Image) + AllHeaderSize), RawSize, ImageUpdatable, LastAttemptStatus);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - FmpDeviceLib CheckImage failed. Status = %r\n", mImageIdName, Status));
@@ -1034,12 +1047,13 @@ CheckTheImageInternal ( // [LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE, LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE]
//
if ((*LastAttemptStatus < LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE) ||
- (*LastAttemptStatus > LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE)) {
+ (*LastAttemptStatus > LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE))
+ {
DEBUG (
(DEBUG_ERROR,
- "FmpDxe(%s): CheckTheImage() - LastAttemptStatus %d from FmpDeviceCheckImageWithStatus() is invalid.\n",
- mImageIdName,
- *LastAttemptStatus)
+ "FmpDxe(%s): CheckTheImage() - LastAttemptStatus %d from FmpDeviceCheckImageWithStatus() is invalid.\n",
+ mImageIdName,
+ *LastAttemptStatus)
);
*LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
}
@@ -1158,18 +1172,18 @@ SetTheImage ( EFI_FIRMWARE_IMAGE_DEP *Dependencies;
UINT32 DependenciesSize;
- Status = EFI_SUCCESS;
- Private = NULL;
- Updateable = 0;
- BooleanValue = FALSE;
- FmpHeaderSize = 0;
- FmpHeader = NULL;
- FmpPayloadSize = 0;
- AllHeaderSize = 0;
- IncomingFwVersion = 0;
- LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
- Dependencies = NULL;
- DependenciesSize = 0;
+ Status = EFI_SUCCESS;
+ Private = NULL;
+ Updateable = 0;
+ BooleanValue = FALSE;
+ FmpHeaderSize = 0;
+ FmpHeader = NULL;
+ FmpPayloadSize = 0;
+ AllHeaderSize = 0;
+ IncomingFwVersion = 0;
+ LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
+ Dependencies = NULL;
+ DependenciesSize = 0;
if (!FeaturePcdGet (PcdFmpDeviceStorageAccessEnable)) {
return EFI_UNSUPPORTED;
@@ -1177,7 +1191,7 @@ SetTheImage ( if (This == NULL) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - This is NULL.\n", mImageIdName));
- Status = EFI_INVALID_PARAMETER;
+ Status = EFI_INVALID_PARAMETER;
LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_PROTOCOL_ARG_MISSING;
goto cleanup;
}
@@ -1205,7 +1219,7 @@ SetTheImage ( if (Private->FmpDeviceLocked) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - Device is already locked. Can't update.\n", mImageIdName));
LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_DEVICE_LOCKED;
- Status = EFI_UNSUPPORTED;
+ Status = EFI_UNSUPPORTED;
goto cleanup;
}
@@ -1227,13 +1241,14 @@ SetTheImage ( // No functional error in CheckTheImage. Attempt to get the Version to
// support better error reporting.
//
- FmpHeader = GetFmpHeader ( (EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, ImageSize, DependenciesSize, &FmpPayloadSize );
+ FmpHeader = GetFmpHeader ((EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, ImageSize, DependenciesSize, &FmpPayloadSize);
if (FmpHeader == NULL) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - GetFmpHeader failed.\n", mImageIdName));
LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_FMP_HEADER;
- Status = EFI_ABORTED;
+ Status = EFI_ABORTED;
goto cleanup;
}
+
Status = GetFmpPayloadHeaderVersion (FmpHeader, FmpPayloadSize, &IncomingFwVersion);
if (!EFI_ERROR (Status)) {
//
@@ -1242,16 +1257,16 @@ SetTheImage ( SetLastAttemptVersionInVariable (Private, IncomingFwVersion);
}
-
if (Updateable != IMAGE_UPDATABLE_VALID) {
DEBUG (
(DEBUG_ERROR,
- "FmpDxe(%s): SetTheImage() - Check The Image returned that the Image was not valid for update. Updatable value = 0x%X.\n",
- mImageIdName, Updateable)
+ "FmpDxe(%s): SetTheImage() - Check The Image returned that the Image was not valid for update. Updatable value = 0x%X.\n",
+ mImageIdName, Updateable)
);
if (Private->DependenciesSatisfied == FALSE) {
LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSATISFIED_DEPENDENCIES;
}
+
Status = EFI_ABORTED;
goto cleanup;
}
@@ -1259,7 +1274,7 @@ SetTheImage ( if (Progress == NULL) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - Invalid progress callback\n", mImageIdName));
LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_PROGRESS_CALLBACK_ERROR;
- Status = EFI_INVALID_PARAMETER;
+ Status = EFI_INVALID_PARAMETER;
goto cleanup;
}
@@ -1274,7 +1289,7 @@ SetTheImage ( }
//
- //Check System Power
+ // Check System Power
//
Status = CheckSystemPower (&BooleanValue);
if (EFI_ERROR (Status)) {
@@ -1282,11 +1297,12 @@ SetTheImage ( LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_CHECK_POWER_API;
goto cleanup;
}
+
if (!BooleanValue) {
Status = EFI_ABORTED;
DEBUG (
(DEBUG_ERROR,
- "FmpDxe(%s): SetTheImage() - CheckSystemPower - returned False. Update not allowed due to System Power.\n", mImageIdName)
+ "FmpDxe(%s): SetTheImage() - CheckSystemPower - returned False. Update not allowed due to System Power.\n", mImageIdName)
);
LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_PWR_EVT_BATT;
goto cleanup;
@@ -1295,7 +1311,7 @@ SetTheImage ( Progress (2);
//
- //Check System Thermal
+ // Check System Thermal
//
Status = CheckSystemThermal (&BooleanValue);
if (EFI_ERROR (Status)) {
@@ -1303,12 +1319,13 @@ SetTheImage ( LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_CHECK_SYS_THERMAL_API;
goto cleanup;
}
+
if (!BooleanValue) {
- Status = EFI_ABORTED;
+ Status = EFI_ABORTED;
LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_THERMAL;
DEBUG (
(DEBUG_ERROR,
- "FmpDxe(%s): SetTheImage() - CheckSystemThermal - returned False. Update not allowed due to System Thermal.\n", mImageIdName)
+ "FmpDxe(%s): SetTheImage() - CheckSystemThermal - returned False. Update not allowed due to System Thermal.\n", mImageIdName)
);
goto cleanup;
}
@@ -1316,7 +1333,7 @@ SetTheImage ( Progress (3);
//
- //Check System Environment
+ // Check System Environment
//
Status = CheckSystemEnvironment (&BooleanValue);
if (EFI_ERROR (Status)) {
@@ -1324,12 +1341,13 @@ SetTheImage ( LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_CHECK_SYS_ENV_API;
goto cleanup;
}
+
if (!BooleanValue) {
- Status = EFI_ABORTED;
+ Status = EFI_ABORTED;
LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_SYSTEM_ENV;
DEBUG (
(DEBUG_ERROR,
- "FmpDxe(%s): SetTheImage() - CheckSystemEnvironment - returned False. Update not allowed due to System Environment.\n", mImageIdName)
+ "FmpDxe(%s): SetTheImage() - CheckSystemEnvironment - returned False. Update not allowed due to System Environment.\n", mImageIdName)
);
goto cleanup;
}
@@ -1356,7 +1374,7 @@ SetTheImage ( if (AllHeaderSize == 0) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - GetAllHeaderSize failed.\n", mImageIdName));
LastAttemptStatus = LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_ALL_HEADER_SIZE;
- Status = EFI_ABORTED;
+ Status = EFI_ABORTED;
goto cleanup;
}
@@ -1366,10 +1384,10 @@ SetTheImage ( Progress (5);
//
- //Copy the requested image to the firmware using the FmpDeviceLib
+ // Copy the requested image to the firmware using the FmpDeviceLib
//
Status = FmpDeviceSetImageWithStatus (
- (((UINT8 *) Image) + AllHeaderSize),
+ (((UINT8 *)Image) + AllHeaderSize),
ImageSize - AllHeaderSize,
VendorCode,
FmpDxeProgress,
@@ -1385,12 +1403,13 @@ SetTheImage ( // [LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE, LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE]
//
if ((LastAttemptStatus < LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE) ||
- (LastAttemptStatus > LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE)) {
+ (LastAttemptStatus > LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE))
+ {
DEBUG (
(DEBUG_ERROR,
- "FmpDxe(%s): SetTheImage() - LastAttemptStatus %d from FmpDeviceSetImageWithStatus() is invalid.\n",
- mImageIdName,
- LastAttemptStatus)
+ "FmpDxe(%s): SetTheImage() - LastAttemptStatus %d from FmpDeviceSetImageWithStatus() is invalid.\n",
+ mImageIdName,
+ LastAttemptStatus)
);
LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL;
}
@@ -1406,6 +1425,7 @@ SetTheImage ( if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() SaveFmpDependency from FmpDependencyCheckLib failed. (%r)\n", mImageIdName, Status));
}
+
Status = EFI_SUCCESS;
}
@@ -1580,7 +1600,7 @@ FmpDxeLockEventNotify ( // Lock the firmware device
//
FmpDeviceSetContext (Private->Handle, &Private->FmpDeviceContext);
- Status = FmpDeviceLock();
+ Status = FmpDeviceLock ();
if (EFI_ERROR (Status)) {
if (Status != EFI_UNSUPPORTED) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): FmpDeviceLock() returned error. Status = %r\n", mImageIdName, Status));
@@ -1588,6 +1608,7 @@ FmpDxeLockEventNotify ( DEBUG ((DEBUG_WARN, "FmpDxe(%s): FmpDeviceLock() returned error. Status = %r\n", mImageIdName, Status));
}
}
+
Private->FmpDeviceLocked = TRUE;
}
}
@@ -1643,9 +1664,9 @@ InstallFmpInstance ( //
// Initialize private context data structure
//
- Private->Handle = Handle;
+ Private->Handle = Handle;
Private->FmpDeviceContext = NULL;
- Status = FmpDeviceSetContext (Private->Handle, &Private->FmpDeviceContext);
+ Status = FmpDeviceSetContext (Private->Handle, &Private->FmpDeviceContext);
if (Status == EFI_UNSUPPORTED) {
Private->FmpDeviceContext = NULL;
} else if (EFI_ERROR (Status)) {
@@ -1682,6 +1703,7 @@ InstallFmpInstance ( if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to register notification. Status = %r\n", mImageIdName, Status));
}
+
ASSERT_EFI_ERROR (Status);
} else {
DEBUG ((DEBUG_VERBOSE, "FmpDxe(%s): Not registering notification to call FmpDeviceLock() because mfg mode\n", mImageIdName));
@@ -1692,8 +1714,10 @@ InstallFmpInstance ( //
Status = gBS->InstallMultipleProtocolInterfaces (
&Private->Handle,
- &gEfiFirmwareManagementProtocolGuid, &Private->Fmp,
- &gEdkiiFirmwareManagementProgressProtocolGuid, &mFmpProgress,
+ &gEfiFirmwareManagementProtocolGuid,
+ &Private->Fmp,
+ &gEdkiiFirmwareManagementProgressProtocolGuid,
+ &mFmpProgress,
NULL
);
if (EFI_ERROR (Status)) {
@@ -1708,27 +1732,35 @@ cleanup: if (Private->FmpDeviceLockEvent != NULL) {
gBS->CloseEvent (Private->FmpDeviceLockEvent);
}
+
if (Private->Descriptor.VersionName != NULL) {
FreePool (Private->Descriptor.VersionName);
}
+
if (Private->FmpDeviceContext != NULL) {
FmpDeviceSetContext (NULL, &Private->FmpDeviceContext);
}
+
if (Private->VersionVariableName != NULL) {
FreePool (Private->VersionVariableName);
}
+
if (Private->LsvVariableName != NULL) {
FreePool (Private->LsvVariableName);
}
+
if (Private->LastAttemptStatusVariableName != NULL) {
FreePool (Private->LastAttemptStatusVariableName);
}
+
if (Private->LastAttemptVersionVariableName != NULL) {
FreePool (Private->LastAttemptVersionVariableName);
}
+
if (Private->FmpStateVariableName != NULL) {
FreePool (Private->FmpStateVariableName);
}
+
FreePool (Private);
}
}
@@ -1778,8 +1810,10 @@ UninstallFmpInstance ( Status = gBS->UninstallMultipleProtocolInterfaces (
Private->Handle,
- &gEfiFirmwareManagementProtocolGuid, &Private->Fmp,
- &gEdkiiFirmwareManagementProgressProtocolGuid, &mFmpProgress,
+ &gEfiFirmwareManagementProtocolGuid,
+ &Private->Fmp,
+ &gEdkiiFirmwareManagementProgressProtocolGuid,
+ &mFmpProgress,
NULL
);
if (EFI_ERROR (Status)) {
@@ -1790,24 +1824,31 @@ UninstallFmpInstance ( if (Private->Descriptor.VersionName != NULL) {
FreePool (Private->Descriptor.VersionName);
}
+
if (Private->FmpDeviceContext != NULL) {
FmpDeviceSetContext (NULL, &Private->FmpDeviceContext);
}
+
if (Private->VersionVariableName != NULL) {
FreePool (Private->VersionVariableName);
}
+
if (Private->LsvVariableName != NULL) {
FreePool (Private->LsvVariableName);
}
+
if (Private->LastAttemptStatusVariableName != NULL) {
FreePool (Private->LastAttemptStatusVariableName);
}
+
if (Private->LastAttemptVersionVariableName != NULL) {
FreePool (Private->LastAttemptVersionVariableName);
}
+
if (Private->FmpStateVariableName != NULL) {
FreePool (Private->FmpStateVariableName);
}
+
FreePool (Private);
return EFI_SUCCESS;
@@ -1832,6 +1873,7 @@ FmpDxeLibDestructor ( if (mFmpSingleInstance) {
return UninstallFmpInstance (ImageHandle);
}
+
return EFI_SUCCESS;
}
@@ -1865,8 +1907,8 @@ FmpDxeEntryPoint ( //
// Get the ImageIdName value for the EFI_FIRMWARE_IMAGE_DESCRIPTOR from a PCD.
//
- mImageIdName = (CHAR16 *) PcdGetPtr (PcdFmpDeviceImageIdName);
- if (PcdGetSize (PcdFmpDeviceImageIdName) <= 2 || mImageIdName[0] == 0) {
+ mImageIdName = (CHAR16 *)PcdGetPtr (PcdFmpDeviceImageIdName);
+ if ((PcdGetSize (PcdFmpDeviceImageIdName) <= 2) || (mImageIdName[0] == 0)) {
//
// PcdFmpDeviceImageIdName must be set to a non-empty Unicode string
//
@@ -1895,6 +1937,7 @@ FmpDxeEntryPoint ( if (PcdGetSize (PcdFmpDeviceLockEventGuid) == sizeof (EFI_GUID)) {
mLockGuid = (EFI_GUID *)PcdGetPtr (PcdFmpDeviceLockEventGuid);
}
+
DEBUG ((DEBUG_INFO, "FmpDxe(%s): Lock GUID: %g\n", mImageIdName, mLockGuid));
//
diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.h b/FmpDevicePkg/FmpDxe/FmpDxe.h index 4d94a925b6..7baf730e69 100644 --- a/FmpDevicePkg/FmpDxe/FmpDxe.h +++ b/FmpDevicePkg/FmpDxe/FmpDxe.h @@ -45,18 +45,18 @@ ///
///
///
-#define FIRMWARE_MANAGEMENT_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('f','m','p','p')
+#define FIRMWARE_MANAGEMENT_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('f','m','p','p')
typedef struct {
- UINTN Signature;
- EFI_HANDLE Handle;
- EFI_FIRMWARE_MANAGEMENT_PROTOCOL Fmp;
- BOOLEAN DescriptorPopulated;
- EFI_FIRMWARE_IMAGE_DESCRIPTOR Descriptor;
- CHAR16 *ImageIdName;
- CHAR16 *VersionName;
- BOOLEAN RuntimeVersionSupported;
- EFI_EVENT FmpDeviceLockEvent;
+ UINTN Signature;
+ EFI_HANDLE Handle;
+ EFI_FIRMWARE_MANAGEMENT_PROTOCOL Fmp;
+ BOOLEAN DescriptorPopulated;
+ EFI_FIRMWARE_IMAGE_DESCRIPTOR Descriptor;
+ CHAR16 *ImageIdName;
+ CHAR16 *VersionName;
+ BOOLEAN RuntimeVersionSupported;
+ EFI_EVENT FmpDeviceLockEvent;
//
// Indicates if an attempt has been made to lock a
// FLASH storage device by calling FmpDeviceLock().
@@ -64,14 +64,14 @@ typedef struct { // so this variable is set to TRUE even if FmpDeviceLock()
// returns an error.
//
- BOOLEAN FmpDeviceLocked;
- VOID *FmpDeviceContext;
- CHAR16 *VersionVariableName;
- CHAR16 *LsvVariableName;
- CHAR16 *LastAttemptStatusVariableName;
- CHAR16 *LastAttemptVersionVariableName;
- CHAR16 *FmpStateVariableName;
- BOOLEAN DependenciesSatisfied;
+ BOOLEAN FmpDeviceLocked;
+ VOID *FmpDeviceContext;
+ CHAR16 *VersionVariableName;
+ CHAR16 *LsvVariableName;
+ CHAR16 *LastAttemptStatusVariableName;
+ CHAR16 *LastAttemptVersionVariableName;
+ CHAR16 *FmpStateVariableName;
+ BOOLEAN DependenciesSatisfied;
} FIRMWARE_MANAGEMENT_PRIVATE_DATA;
///
@@ -183,7 +183,6 @@ GetTheImage ( IN OUT UINTN *ImageSize
);
-
/**
Checks if the firmware image is valid for the device.
diff --git a/FmpDevicePkg/FmpDxe/VariableSupport.c b/FmpDevicePkg/FmpDxe/VariableSupport.c index c4b72a2ff9..541e5e0f5f 100644 --- a/FmpDevicePkg/FmpDxe/VariableSupport.c +++ b/FmpDevicePkg/FmpDxe/VariableSupport.c @@ -45,10 +45,11 @@ GetFmpVariable ( (VOID **)&Buffer,
&Size
);
- if (!EFI_ERROR (Status) && Size == sizeof (*Value) && Buffer != NULL) {
+ if (!EFI_ERROR (Status) && (Size == sizeof (*Value)) && (Buffer != NULL)) {
*Valid = TRUE;
*Value = *Buffer;
}
+
if (Buffer != NULL) {
FreePool (Buffer);
}
@@ -105,23 +106,26 @@ GetFmpControllerState ( FmpControllerState = NULL;
Size = 0;
- Status = GetVariable2 (
- Private->FmpStateVariableName,
- &gEfiCallerIdGuid,
- (VOID **)&FmpControllerState,
- &Size
- );
- if (EFI_ERROR (Status) || FmpControllerState == NULL) {
+ Status = GetVariable2 (
+ Private->FmpStateVariableName,
+ &gEfiCallerIdGuid,
+ (VOID **)&FmpControllerState,
+ &Size
+ );
+ if (EFI_ERROR (Status) || (FmpControllerState == NULL)) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to get the controller state. Status = %r\n", mImageIdName, Status));
} else {
if (Size == sizeof (*FmpControllerState)) {
return FmpControllerState;
}
+
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Getting controller state returned a size different than expected. Size = 0x%x\n", mImageIdName, Size));
}
+
if (FmpControllerState != NULL) {
FreePool (FmpControllerState);
}
+
return NULL;
}
@@ -154,17 +158,19 @@ GenerateFmpVariableName ( // Allocate Unicode string with room for BaseVariableName and a 16 digit
// hexadecimal value for the HardwareInstance value.
//
- Size = StrSize (BaseVariableName) + 16 * sizeof (CHAR16);
+ Size = StrSize (BaseVariableName) + 16 * sizeof (CHAR16);
VariableName = AllocateCopyPool (Size, BaseVariableName);
if (VariableName == NULL) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to generate variable name %s.\n", mImageIdName, BaseVariableName));
return VariableName;
}
+
if (HardwareInstance == 0) {
return VariableName;
}
+
UnicodeValueToStringS (
- &VariableName[StrLen(BaseVariableName)],
+ &VariableName[StrLen (BaseVariableName)],
Size,
PREFIX_ZERO | RADIX_HEX,
HardwareInstance,
@@ -202,22 +208,26 @@ GenerateFmpVariableNames ( IN OUT FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private
)
{
- EFI_STATUS Status;
- VOID *Buffer;
+ EFI_STATUS Status;
+ VOID *Buffer;
FMP_CONTROLLER_STATE FmpControllerState;
if (Private->VersionVariableName != NULL) {
FreePool (Private->VersionVariableName);
}
+
if (Private->LsvVariableName != NULL) {
FreePool (Private->LsvVariableName);
}
+
if (Private->LastAttemptStatusVariableName != NULL) {
FreePool (Private->LastAttemptStatusVariableName);
}
+
if (Private->LastAttemptVersionVariableName != NULL) {
FreePool (Private->LastAttemptVersionVariableName);
}
+
if (Private->FmpStateVariableName != NULL) {
FreePool (Private->FmpStateVariableName);
}
@@ -331,20 +341,24 @@ GetVersionFromVariable ( FMP_CONTROLLER_STATE *FmpControllerState;
UINT32 Value;
- Value = DEFAULT_VERSION;
+ Value = DEFAULT_VERSION;
FmpControllerState = GetFmpControllerState (Private);
if (FmpControllerState != NULL) {
if (FmpControllerState->VersionValid) {
Value = FmpControllerState->Version;
- DEBUG ((DEBUG_INFO, "FmpDxe(%s): Get variable %g %s Version %08x\n",
+ DEBUG ((
+ DEBUG_INFO,
+ "FmpDxe(%s): Get variable %g %s Version %08x\n",
mImageIdName,
&gEfiCallerIdGuid,
Private->FmpStateVariableName,
Value
));
}
+
FreePool (FmpControllerState);
}
+
return Value;
}
@@ -370,20 +384,24 @@ GetLowestSupportedVersionFromVariable ( FMP_CONTROLLER_STATE *FmpControllerState;
UINT32 Value;
- Value = DEFAULT_LOWESTSUPPORTEDVERSION;
+ Value = DEFAULT_LOWESTSUPPORTEDVERSION;
FmpControllerState = GetFmpControllerState (Private);
if (FmpControllerState != NULL) {
if (FmpControllerState->LsvValid) {
Value = FmpControllerState->Lsv;
- DEBUG ((DEBUG_INFO, "FmpDxe(%s): Get variable %g %s LowestSupportedVersion %08x\n",
+ DEBUG ((
+ DEBUG_INFO,
+ "FmpDxe(%s): Get variable %g %s LowestSupportedVersion %08x\n",
mImageIdName,
&gEfiCallerIdGuid,
Private->FmpStateVariableName,
Value
));
}
+
FreePool (FmpControllerState);
}
+
return Value;
}
@@ -408,20 +426,24 @@ GetLastAttemptStatusFromVariable ( FMP_CONTROLLER_STATE *FmpControllerState;
UINT32 Value;
- Value = DEFAULT_LASTATTEMPTSTATUS;
+ Value = DEFAULT_LASTATTEMPTSTATUS;
FmpControllerState = GetFmpControllerState (Private);
if (FmpControllerState != NULL) {
if (FmpControllerState->LastAttemptStatusValid) {
Value = FmpControllerState->LastAttemptStatus;
- DEBUG ((DEBUG_INFO, "FmpDxe(%s): Get variable %g %s LastAttemptStatus %08x\n",
+ DEBUG ((
+ DEBUG_INFO,
+ "FmpDxe(%s): Get variable %g %s LastAttemptStatus %08x\n",
mImageIdName,
&gEfiCallerIdGuid,
Private->FmpStateVariableName,
Value
));
}
+
FreePool (FmpControllerState);
}
+
return Value;
}
@@ -446,20 +468,24 @@ GetLastAttemptVersionFromVariable ( FMP_CONTROLLER_STATE *FmpControllerState;
UINT32 Value;
- Value = DEFAULT_LASTATTEMPTVERSION;
+ Value = DEFAULT_LASTATTEMPTVERSION;
FmpControllerState = GetFmpControllerState (Private);
if (FmpControllerState != NULL) {
if (FmpControllerState->LastAttemptVersionValid) {
Value = FmpControllerState->LastAttemptVersion;
- DEBUG ((DEBUG_INFO, "FmpDxe(%s): Get variable %g %s LastAttemptVersion %08x\n",
+ DEBUG ((
+ DEBUG_INFO,
+ "FmpDxe(%s): Get variable %g %s LastAttemptVersion %08x\n",
mImageIdName,
&gEfiCallerIdGuid,
Private->FmpStateVariableName,
Value
));
}
+
FreePool (FmpControllerState);
}
+
return Value;
}
@@ -495,25 +521,29 @@ SetVersionInVariable ( if (!FmpControllerState->VersionValid) {
Update = TRUE;
}
+
if (FmpControllerState->Version != Version) {
Update = TRUE;
}
+
if (!Update) {
DEBUG ((DEBUG_INFO, "FmpDxe(%s): No need to update controller state. Same value as before.\n", mImageIdName));
} else {
FmpControllerState->VersionValid = TRUE;
FmpControllerState->Version = Version;
- Status = gRT->SetVariable (
- Private->FmpStateVariableName,
- &gEfiCallerIdGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
- sizeof (*FmpControllerState),
- FmpControllerState
- );
+ Status = gRT->SetVariable (
+ Private->FmpStateVariableName,
+ &gEfiCallerIdGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (*FmpControllerState),
+ FmpControllerState
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to update controller state. Status = %r\n", mImageIdName, Status));
} else {
- DEBUG ((DEBUG_INFO, "FmpDxe(%s): Set variable %g %s Version %08x\n",
+ DEBUG ((
+ DEBUG_INFO,
+ "FmpDxe(%s): Set variable %g %s Version %08x\n",
mImageIdName,
&gEfiCallerIdGuid,
Private->FmpStateVariableName,
@@ -521,6 +551,7 @@ SetVersionInVariable ( ));
}
}
+
FreePool (FmpControllerState);
}
@@ -558,25 +589,29 @@ SetLowestSupportedVersionInVariable ( if (!FmpControllerState->LsvValid) {
Update = TRUE;
}
+
if (FmpControllerState->Lsv < LowestSupportedVersion) {
Update = TRUE;
}
+
if (!Update) {
DEBUG ((DEBUG_INFO, "FmpDxe(%s): No need to update controller state. Same value as before.\n", mImageIdName));
} else {
FmpControllerState->LsvValid = TRUE;
FmpControllerState->Lsv = LowestSupportedVersion;
- Status = gRT->SetVariable (
- Private->FmpStateVariableName,
- &gEfiCallerIdGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
- sizeof (*FmpControllerState),
- FmpControllerState
- );
+ Status = gRT->SetVariable (
+ Private->FmpStateVariableName,
+ &gEfiCallerIdGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (*FmpControllerState),
+ FmpControllerState
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to update controller state. Status = %r\n", mImageIdName, Status));
} else {
- DEBUG ((DEBUG_INFO, "FmpDxe(%s): Set variable %g %s LowestSupportedVersion %08x\n",
+ DEBUG ((
+ DEBUG_INFO,
+ "FmpDxe(%s): Set variable %g %s LowestSupportedVersion %08x\n",
mImageIdName,
&gEfiCallerIdGuid,
Private->FmpStateVariableName,
@@ -584,6 +619,7 @@ SetLowestSupportedVersionInVariable ( ));
}
}
+
FreePool (FmpControllerState);
}
@@ -621,25 +657,29 @@ SetLastAttemptStatusInVariable ( if (!FmpControllerState->LastAttemptStatusValid) {
Update = TRUE;
}
+
if (FmpControllerState->LastAttemptStatus != LastAttemptStatus) {
Update = TRUE;
}
+
if (!Update) {
DEBUG ((DEBUG_INFO, "FmpDxe(%s): No need to update controller state. Same value as before.\n", mImageIdName));
} else {
FmpControllerState->LastAttemptStatusValid = TRUE;
FmpControllerState->LastAttemptStatus = LastAttemptStatus;
- Status = gRT->SetVariable (
- Private->FmpStateVariableName,
- &gEfiCallerIdGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
- sizeof (*FmpControllerState),
- FmpControllerState
- );
+ Status = gRT->SetVariable (
+ Private->FmpStateVariableName,
+ &gEfiCallerIdGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (*FmpControllerState),
+ FmpControllerState
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to update controller state. Status = %r\n", mImageIdName, Status));
} else {
- DEBUG ((DEBUG_INFO, "FmpDxe(%s): Set variable %g %s LastAttemptStatus %08x\n",
+ DEBUG ((
+ DEBUG_INFO,
+ "FmpDxe(%s): Set variable %g %s LastAttemptStatus %08x\n",
mImageIdName,
&gEfiCallerIdGuid,
Private->FmpStateVariableName,
@@ -647,6 +687,7 @@ SetLastAttemptStatusInVariable ( ));
}
}
+
FreePool (FmpControllerState);
}
@@ -684,25 +725,29 @@ SetLastAttemptVersionInVariable ( if (!FmpControllerState->LastAttemptVersionValid) {
Update = TRUE;
}
+
if (FmpControllerState->LastAttemptVersion != LastAttemptVersion) {
Update = TRUE;
}
+
if (!Update) {
DEBUG ((DEBUG_INFO, "FmpDxe(%s): No need to update controller state. Same value as before.\n", mImageIdName));
} else {
FmpControllerState->LastAttemptVersionValid = TRUE;
FmpControllerState->LastAttemptVersion = LastAttemptVersion;
- Status = gRT->SetVariable (
- Private->FmpStateVariableName,
- &gEfiCallerIdGuid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
- sizeof (*FmpControllerState),
- FmpControllerState
- );
+ Status = gRT->SetVariable (
+ Private->FmpStateVariableName,
+ &gEfiCallerIdGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof (*FmpControllerState),
+ FmpControllerState
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to update controller state. Status = %r\n", mImageIdName, Status));
} else {
- DEBUG ((DEBUG_INFO, "FmpDxe(%s): Set variable %g %s LastAttemptVersion %08x\n",
+ DEBUG ((
+ DEBUG_INFO,
+ "FmpDxe(%s): Set variable %g %s LastAttemptVersion %08x\n",
mImageIdName,
&gEfiCallerIdGuid,
Private->FmpStateVariableName,
@@ -710,6 +755,7 @@ SetLastAttemptVersionInVariable ( ));
}
}
+
FreePool (FmpControllerState);
}
@@ -737,25 +783,31 @@ LockFmpVariable ( EFI_STATUS Status;
// If success, go ahead and set the policies to protect the target variables.
- Status = RegisterBasicVariablePolicy (VariablePolicy,
- &gEfiCallerIdGuid,
- VariableName,
- VARIABLE_POLICY_NO_MIN_SIZE,
- VARIABLE_POLICY_NO_MAX_SIZE,
- VARIABLE_POLICY_NO_MUST_ATTR,
- VARIABLE_POLICY_NO_CANT_ATTR,
- VARIABLE_POLICY_TYPE_LOCK_NOW);
+ Status = RegisterBasicVariablePolicy (
+ VariablePolicy,
+ &gEfiCallerIdGuid,
+ VariableName,
+ VARIABLE_POLICY_NO_MIN_SIZE,
+ VARIABLE_POLICY_NO_MAX_SIZE,
+ VARIABLE_POLICY_NO_MUST_ATTR,
+ VARIABLE_POLICY_NO_CANT_ATTR,
+ VARIABLE_POLICY_TYPE_LOCK_NOW
+ );
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to lock variable %g %s. Status = %r\n",
- mImageIdName,
- &gEfiCallerIdGuid,
- VariableName,
- Status
- ));
+ DEBUG ((
+ DEBUG_ERROR,
+ "FmpDxe(%s): Failed to lock variable %g %s. Status = %r\n",
+ mImageIdName,
+ &gEfiCallerIdGuid,
+ VariableName,
+ Status
+ ));
}
+
if (EFI_ERROR (PreviousStatus)) {
return PreviousStatus;
}
+
return Status;
}
@@ -774,11 +826,11 @@ LockAllFmpVariables ( FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private
)
{
- EFI_STATUS Status;
- EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy;
+ EFI_STATUS Status;
+ EDKII_VARIABLE_POLICY_PROTOCOL *VariablePolicy;
// Locate the VariablePolicy protocol.
- Status = gBS->LocateProtocol (&gEdkiiVariablePolicyProtocolGuid, NULL, (VOID**)&VariablePolicy );
+ Status = gBS->LocateProtocol (&gEdkiiVariablePolicyProtocolGuid, NULL, (VOID **)&VariablePolicy);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "FmpDxe %a - Could not locate VariablePolicy protocol! %r\n", __FUNCTION__, Status));
return Status;
diff --git a/FmpDevicePkg/FmpDxe/VariableSupport.h b/FmpDevicePkg/FmpDxe/VariableSupport.h index 23f24f2a13..f23ab11d69 100644 --- a/FmpDevicePkg/FmpDxe/VariableSupport.h +++ b/FmpDevicePkg/FmpDxe/VariableSupport.h @@ -24,10 +24,10 @@ /// Base UEFI Variable names for FMP Controller State information stored in
/// separate variables.
///
-#define VARNAME_VERSION L"FmpVersion"
-#define VARNAME_LSV L"FmpLsv"
-#define VARNAME_LASTATTEMPTSTATUS L"LastAttemptStatus"
-#define VARNAME_LASTATTEMPTVERSION L"LastAttemptVersion"
+#define VARNAME_VERSION L"FmpVersion"
+#define VARNAME_LSV L"FmpLsv"
+#define VARNAME_LASTATTEMPTSTATUS L"LastAttemptStatus"
+#define VARNAME_LASTATTEMPTVERSION L"LastAttemptVersion"
///
/// Base UEFI Variable name for FMP Controller State information stored in a
@@ -35,21 +35,21 @@ /// then they are merged into a single variable and the separate variables are
/// deleted.
///
-#define VARNAME_FMPSTATE L"FmpState"
+#define VARNAME_FMPSTATE L"FmpState"
///
/// FMP Controller State structure that is used to store the state of
/// a controller in one combined UEFI Variable.
///
typedef struct {
- BOOLEAN VersionValid;
- BOOLEAN LsvValid;
- BOOLEAN LastAttemptStatusValid;
- BOOLEAN LastAttemptVersionValid;
- UINT32 Version;
- UINT32 Lsv;
- UINT32 LastAttemptStatus;
- UINT32 LastAttemptVersion;
+ BOOLEAN VersionValid;
+ BOOLEAN LsvValid;
+ BOOLEAN LastAttemptStatusValid;
+ BOOLEAN LastAttemptVersionValid;
+ UINT32 Version;
+ UINT32 Lsv;
+ UINT32 LastAttemptStatus;
+ UINT32 LastAttemptVersion;
} FMP_CONTROLLER_STATE;
/**
diff --git a/FmpDevicePkg/Include/LastAttemptStatus.h b/FmpDevicePkg/Include/LastAttemptStatus.h index 0dcd1ef716..4a81d2737b 100644 --- a/FmpDevicePkg/Include/LastAttemptStatus.h +++ b/FmpDevicePkg/Include/LastAttemptStatus.h @@ -31,51 +31,51 @@ ///
/// The minimum value of the FMP reserved range.
///
-#define LAST_ATTEMPT_STATUS_FMP_RESERVED_MIN_ERROR_CODE_VALUE 0x1000
+#define LAST_ATTEMPT_STATUS_FMP_RESERVED_MIN_ERROR_CODE_VALUE 0x1000
///
/// The maximum value of the FMP reserved range.
///
-#define LAST_ATTEMPT_STATUS_FMP_RESERVED_MAX_ERROR_CODE_VALUE 0x1FFF
+#define LAST_ATTEMPT_STATUS_FMP_RESERVED_MAX_ERROR_CODE_VALUE 0x1FFF
///
/// The minimum value allowed for FmpDxe driver-specific errors.
///
-#define LAST_ATTEMPT_STATUS_DRIVER_MIN_ERROR_CODE_VALUE 0x1000
+#define LAST_ATTEMPT_STATUS_DRIVER_MIN_ERROR_CODE_VALUE 0x1000
///
/// The maximum value allowed for FmpDxe driver-specific errors.
///
-#define LAST_ATTEMPT_STATUS_DRIVER_MAX_ERROR_CODE_VALUE 0x107F
+#define LAST_ATTEMPT_STATUS_DRIVER_MAX_ERROR_CODE_VALUE 0x107F
///
/// The minimum value allowed for FmpDependencyLib related errors.
///
-#define LAST_ATTEMPT_STATUS_FMP_DEPENDENCY_LIB_MIN_ERROR_CODE_VALUE 0x1080
+#define LAST_ATTEMPT_STATUS_FMP_DEPENDENCY_LIB_MIN_ERROR_CODE_VALUE 0x1080
///
/// The maximum value allowed for FmpDependencyLib related errors.
///
-#define LAST_ATTEMPT_STATUS_FMP_DEPENDENCY_LIB_MAX_ERROR_CODE_VALUE 0x109F
+#define LAST_ATTEMPT_STATUS_FMP_DEPENDENCY_LIB_MAX_ERROR_CODE_VALUE 0x109F
///
/// The minimum value allowed for FmpDependencyCheckLib related errors.
///
-#define LAST_ATTEMPT_STATUS_FMP_DEPENDENCY_CHECK_LIB_MIN_ERROR_CODE_VALUE 0x10A0
+#define LAST_ATTEMPT_STATUS_FMP_DEPENDENCY_CHECK_LIB_MIN_ERROR_CODE_VALUE 0x10A0
///
/// The maximum value allowed for FmpDependencyCheckLib related errors.
///
-#define LAST_ATTEMPT_STATUS_FMP_DEPENDENCY_CHECK_LIB_MAX_ERROR_CODE_VALUE 0x10BF
+#define LAST_ATTEMPT_STATUS_FMP_DEPENDENCY_CHECK_LIB_MAX_ERROR_CODE_VALUE 0x10BF
///
/// The minimum value allowed for FMP device library errors.
///
-#define LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE 0x1800
+#define LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MIN_ERROR_CODE_VALUE 0x1800
///
/// The maximum value allowed for FMP device library errors.
///
-#define LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE 0x1FFF
+#define LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_MAX_ERROR_CODE_VALUE 0x1FFF
#endif
diff --git a/FmpDevicePkg/Include/Library/CapsuleUpdatePolicyLib.h b/FmpDevicePkg/Include/Library/CapsuleUpdatePolicyLib.h index 5ec4d487e3..fa0406029c 100644 --- a/FmpDevicePkg/Include/Library/CapsuleUpdatePolicyLib.h +++ b/FmpDevicePkg/Include/Library/CapsuleUpdatePolicyLib.h @@ -46,7 +46,7 @@ CheckSystemPower ( EFI_STATUS
EFIAPI
CheckSystemThermal (
- OUT BOOLEAN *Good
+ OUT BOOLEAN *Good
);
/**
@@ -65,7 +65,7 @@ CheckSystemThermal ( EFI_STATUS
EFIAPI
CheckSystemEnvironment (
- OUT BOOLEAN *Good
+ OUT BOOLEAN *Good
);
/**
diff --git a/FmpDevicePkg/Include/Library/FmpDependencyDeviceLib.h b/FmpDevicePkg/Include/Library/FmpDependencyDeviceLib.h index 4351173b7e..173e415b6f 100644 --- a/FmpDevicePkg/Include/Library/FmpDependencyDeviceLib.h +++ b/FmpDevicePkg/Include/Library/FmpDependencyDeviceLib.h @@ -42,7 +42,7 @@ SaveFmpDependency ( @retval NULL
**/
-EFI_FIRMWARE_IMAGE_DEP*
+EFI_FIRMWARE_IMAGE_DEP *
EFIAPI
GetFmpDependency (
OUT UINT32 *DepexSize
diff --git a/FmpDevicePkg/Include/Library/FmpDependencyLib.h b/FmpDevicePkg/Include/Library/FmpDependencyLib.h index f4013484a2..a1f577272b 100644 --- a/FmpDevicePkg/Include/Library/FmpDependencyLib.h +++ b/FmpDevicePkg/Include/Library/FmpDependencyLib.h @@ -19,8 +19,8 @@ // Data struct to store FMP ImageType and version for dependency check.
//
typedef struct {
- EFI_GUID ImageTypeId;
- UINT32 Version;
+ EFI_GUID ImageTypeId;
+ UINT32 Version;
} FMP_DEPEX_CHECK_VERSION_DATA;
/**
@@ -61,13 +61,13 @@ ValidateDependency ( @retval Null
**/
-EFI_FIRMWARE_IMAGE_DEP*
+EFI_FIRMWARE_IMAGE_DEP *
EFIAPI
GetImageDependency (
- IN EFI_FIRMWARE_IMAGE_AUTHENTICATION *Image,
- IN UINTN ImageSize,
- OUT UINT32 *DepexSize,
- OUT UINT32 *LastAttemptStatus OPTIONAL
+ IN EFI_FIRMWARE_IMAGE_AUTHENTICATION *Image,
+ IN UINTN ImageSize,
+ OUT UINT32 *DepexSize,
+ OUT UINT32 *LastAttemptStatus OPTIONAL
);
/**
diff --git a/FmpDevicePkg/Include/Library/FmpDeviceLib.h b/FmpDevicePkg/Include/Library/FmpDeviceLib.h index a93c3b8e94..a14406abe8 100644 --- a/FmpDevicePkg/Include/Library/FmpDeviceLib.h +++ b/FmpDevicePkg/Include/Library/FmpDeviceLib.h @@ -206,8 +206,8 @@ FmpDeviceGetImageTypeIdGuidPtr ( EFI_STATUS
EFIAPI
FmpDeviceGetAttributes (
- OUT UINT64 *Supported,
- OUT UINT64 *Setting
+ OUT UINT64 *Supported,
+ OUT UINT64 *Setting
);
/**
diff --git a/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.c b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.c index 0cb1d775c3..b3a41a4af3 100644 --- a/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.c +++ b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibNull/CapsuleUpdatePolicyLibNull.c @@ -50,7 +50,7 @@ CheckSystemPower ( EFI_STATUS
EFIAPI
CheckSystemThermal (
- OUT BOOLEAN *Good
+ OUT BOOLEAN *Good
)
{
*Good = TRUE;
@@ -73,7 +73,7 @@ CheckSystemThermal ( EFI_STATUS
EFIAPI
CheckSystemEnvironment (
- OUT BOOLEAN *Good
+ OUT BOOLEAN *Good
)
{
*Good = TRUE;
diff --git a/FmpDevicePkg/Library/CapsuleUpdatePolicyLibOnProtocol/CapsuleUpdatePolicyLibOnProtocol.c b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibOnProtocol/CapsuleUpdatePolicyLibOnProtocol.c index 6f916888c7..34433ec7ef 100644 --- a/FmpDevicePkg/Library/CapsuleUpdatePolicyLibOnProtocol/CapsuleUpdatePolicyLibOnProtocol.c +++ b/FmpDevicePkg/Library/CapsuleUpdatePolicyLibOnProtocol/CapsuleUpdatePolicyLibOnProtocol.c @@ -36,6 +36,7 @@ LookupCapsuleUpdatePolicyProtocol ( if (mCapsuleUpdatePolicy != NULL) {
return TRUE;
}
+
Status = gBS->LocateProtocol (
&gEdkiiCapsuleUpdatePolicyProtocolGuid,
NULL,
@@ -45,6 +46,7 @@ LookupCapsuleUpdatePolicyProtocol ( mCapsuleUpdatePolicy = NULL;
return FALSE;
}
+
return TRUE;
}
@@ -70,6 +72,7 @@ CheckSystemPower ( if (LookupCapsuleUpdatePolicyProtocol ()) {
return mCapsuleUpdatePolicy->CheckSystemPower (mCapsuleUpdatePolicy, Good);
}
+
*Good = TRUE;
return EFI_SUCCESS;
}
@@ -90,12 +93,13 @@ CheckSystemPower ( EFI_STATUS
EFIAPI
CheckSystemThermal (
- OUT BOOLEAN *Good
+ OUT BOOLEAN *Good
)
{
if (LookupCapsuleUpdatePolicyProtocol ()) {
return mCapsuleUpdatePolicy->CheckSystemThermal (mCapsuleUpdatePolicy, Good);
}
+
*Good = TRUE;
return EFI_SUCCESS;
}
@@ -116,12 +120,13 @@ CheckSystemThermal ( EFI_STATUS
EFIAPI
CheckSystemEnvironment (
- OUT BOOLEAN *Good
+ OUT BOOLEAN *Good
)
{
if (LookupCapsuleUpdatePolicyProtocol ()) {
return mCapsuleUpdatePolicy->CheckSystemEnvironment (mCapsuleUpdatePolicy, Good);
}
+
*Good = TRUE;
return EFI_SUCCESS;
}
@@ -145,6 +150,7 @@ IsLowestSupportedVersionCheckRequired ( if (LookupCapsuleUpdatePolicyProtocol ()) {
return mCapsuleUpdatePolicy->IsLowestSupportedVersionCheckRequired (mCapsuleUpdatePolicy);
}
+
return TRUE;
}
@@ -167,5 +173,6 @@ IsLockFmpDeviceAtLockEventGuidRequired ( if (LookupCapsuleUpdatePolicyProtocol ()) {
return mCapsuleUpdatePolicy->IsLockFmpDeviceAtLockEventGuidRequired (mCapsuleUpdatePolicy);
}
+
return TRUE;
}
diff --git a/FmpDevicePkg/Library/FmpDependencyCheckLib/FmpDependencyCheckLib.c b/FmpDevicePkg/Library/FmpDependencyCheckLib/FmpDependencyCheckLib.c index 31a801657f..f007ef03d2 100644 --- a/FmpDevicePkg/Library/FmpDependencyCheckLib/FmpDependencyCheckLib.c +++ b/FmpDevicePkg/Library/FmpDependencyCheckLib/FmpDependencyCheckLib.c @@ -64,82 +64,82 @@ CheckFmpDependency ( UINTN FmpVersionsCount;
BOOLEAN IsSatisfied;
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
- FmpImageInfoBuf = NULL;
- DescriptorVer = NULL;
- DescriptorSize = NULL;
- NumberOfFmpInstance = 0;
- FmpVersions = NULL;
- FmpVersionsCount = 0;
- IsSatisfied = TRUE;
- PackageVersionName = NULL;
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
+ FmpImageInfoBuf = NULL;
+ DescriptorVer = NULL;
+ DescriptorSize = NULL;
+ NumberOfFmpInstance = 0;
+ FmpVersions = NULL;
+ FmpVersionsCount = 0;
+ IsSatisfied = TRUE;
+ PackageVersionName = NULL;
//
// Get ImageDescriptors of all FMP instances, and archive them for dependency evaluation.
//
Status = gBS->LocateHandleBuffer (
- ByProtocol,
- &gEfiFirmwareManagementProtocolGuid,
- NULL,
- &NumberOfFmpInstance,
- &HandleBuffer
- );
+ ByProtocol,
+ &gEfiFirmwareManagementProtocolGuid,
+ NULL,
+ &NumberOfFmpInstance,
+ &HandleBuffer
+ );
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "CheckFmpDependency: Get Firmware Management Protocol failed. (%r)", Status));
- IsSatisfied = FALSE;
+ IsSatisfied = FALSE;
LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_FMP_PROTOCOL_NOT_FOUND;
goto cleanup;
}
- FmpImageInfoBuf = AllocateZeroPool (sizeof(EFI_FIRMWARE_IMAGE_DESCRIPTOR *) * NumberOfFmpInstance);
+ FmpImageInfoBuf = AllocateZeroPool (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR *) * NumberOfFmpInstance);
if (FmpImageInfoBuf == NULL) {
- IsSatisfied = FALSE;
+ IsSatisfied = FALSE;
LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_MEM_ALLOC_FMP_INFO_BUFFER_FAILED;
goto cleanup;
}
- DescriptorVer = AllocateZeroPool (sizeof(UINT32) * NumberOfFmpInstance);
+ DescriptorVer = AllocateZeroPool (sizeof (UINT32) * NumberOfFmpInstance);
if (DescriptorVer == NULL ) {
- IsSatisfied = FALSE;
+ IsSatisfied = FALSE;
LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_MEM_ALLOC_DESC_VER_BUFFER_FAILED;
goto cleanup;
}
- DescriptorSize = AllocateZeroPool (sizeof(UINTN) * NumberOfFmpInstance);
+ DescriptorSize = AllocateZeroPool (sizeof (UINTN) * NumberOfFmpInstance);
if (DescriptorSize == NULL ) {
- IsSatisfied = FALSE;
+ IsSatisfied = FALSE;
LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_MEM_ALLOC_DESC_SIZE_BUFFER_FAILED;
goto cleanup;
}
- FmpVersions = AllocateZeroPool (sizeof(FMP_DEPEX_CHECK_VERSION_DATA) * NumberOfFmpInstance);
+ FmpVersions = AllocateZeroPool (sizeof (FMP_DEPEX_CHECK_VERSION_DATA) * NumberOfFmpInstance);
if (FmpVersions == NULL) {
- IsSatisfied = FALSE;
+ IsSatisfied = FALSE;
LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_MEM_ALLOC_FMP_VER_BUFFER_FAILED;
goto cleanup;
}
- for (Index = 0; Index < NumberOfFmpInstance; Index ++) {
+ for (Index = 0; Index < NumberOfFmpInstance; Index++) {
Status = gBS->HandleProtocol (
HandleBuffer[Index],
&gEfiFirmwareManagementProtocolGuid,
- (VOID **) &Fmp
+ (VOID **)&Fmp
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
continue;
}
ImageInfoSize = 0;
- Status = Fmp->GetImageInfo (
- Fmp,
- &ImageInfoSize,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL
- );
+ Status = Fmp->GetImageInfo (
+ Fmp,
+ &ImageInfoSize,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ );
if (Status != EFI_BUFFER_TOO_SMALL) {
continue;
}
@@ -159,7 +159,7 @@ CheckFmpDependency ( &PackageVersion, // PackageVersion
&PackageVersionName // PackageVersionName
);
- if (EFI_ERROR(Status)) {
+ if (EFI_ERROR (Status)) {
FreePool (FmpImageInfoBuf[Index]);
FmpImageInfoBuf[Index] = NULL;
continue;
@@ -172,7 +172,7 @@ CheckFmpDependency ( CopyGuid (&FmpVersions[FmpVersionsCount].ImageTypeId, &FmpImageInfoBuf[Index]->ImageTypeId);
FmpVersions[FmpVersionsCount].Version = FmpImageInfoBuf[Index]->Version;
- FmpVersionsCount ++;
+ FmpVersionsCount++;
}
//
@@ -189,11 +189,12 @@ CheckFmpDependency ( cleanup:
if (FmpImageInfoBuf != NULL) {
- for (Index = 0; Index < NumberOfFmpInstance; Index ++) {
+ for (Index = 0; Index < NumberOfFmpInstance; Index++) {
if (FmpImageInfoBuf[Index] != NULL) {
FreePool (FmpImageInfoBuf[Index]);
}
}
+
FreePool (FmpImageInfoBuf);
}
diff --git a/FmpDevicePkg/Library/FmpDependencyDeviceLibNull/FmpDependencyDeviceLib.c b/FmpDevicePkg/Library/FmpDependencyDeviceLibNull/FmpDependencyDeviceLib.c index 0839681430..8f924cdd4e 100644 --- a/FmpDevicePkg/Library/FmpDependencyDeviceLibNull/FmpDependencyDeviceLib.c +++ b/FmpDevicePkg/Library/FmpDependencyDeviceLibNull/FmpDependencyDeviceLib.c @@ -40,7 +40,7 @@ SaveFmpDependency ( @retval NULL
**/
-EFI_FIRMWARE_IMAGE_DEP*
+EFI_FIRMWARE_IMAGE_DEP *
EFIAPI
GetFmpDependency (
OUT UINT32 *DepexSize
diff --git a/FmpDevicePkg/Library/FmpDependencyLib/FmpDependencyLib.c b/FmpDevicePkg/Library/FmpDependencyLib/FmpDependencyLib.c index ad0fa6532e..76a1ee3f40 100644 --- a/FmpDevicePkg/Library/FmpDependencyLib/FmpDependencyLib.c +++ b/FmpDevicePkg/Library/FmpDependencyLib/FmpDependencyLib.c @@ -34,16 +34,16 @@ typedef enum { // Value of stack element
//
typedef union {
- BOOLEAN Boolean;
- UINT32 Version;
+ BOOLEAN Boolean;
+ UINT32 Version;
} ELEMENT_VALUE;
//
// Stack element used to evaluate dependency expressions
//
typedef struct {
- ELEMENT_VALUE Value;
- ELEMENT_TYPE Type;
+ ELEMENT_VALUE Value;
+ ELEMENT_TYPE Type;
} DEPEX_ELEMENT;
//
@@ -118,17 +118,17 @@ GrowDepexStack ( **/
EFI_STATUS
Push (
- IN UINT32 Value,
- IN UINTN Type
+ IN UINT32 Value,
+ IN UINTN Type
)
{
- EFI_STATUS Status;
- DEPEX_ELEMENT Element;
+ EFI_STATUS Status;
+ DEPEX_ELEMENT Element;
//
// Check Type
//
- if (Type != BooleanType && Type != VersionType) {
+ if ((Type != BooleanType) && (Type != VersionType)) {
return EFI_INVALID_PARAMETER;
}
@@ -146,7 +146,7 @@ Push ( }
Element.Value.Version = Value;
- Element.Type = Type;
+ Element.Type = Type;
//
// Push the item onto the stack
@@ -191,6 +191,7 @@ Pop ( DEBUG ((DEBUG_ERROR, "EvaluateDependency: Popped element type is mismatched!\n"));
return EFI_INVALID_PARAMETER;
}
+
return EFI_SUCCESS;
}
@@ -225,25 +226,25 @@ EvaluateDependency ( OUT UINT32 *LastAttemptStatus OPTIONAL
)
{
- EFI_STATUS Status;
- UINT8 *Iterator;
- UINT8 Index;
- DEPEX_ELEMENT Element1;
- DEPEX_ELEMENT Element2;
- GUID ImageTypeId;
- UINT32 Version;
- UINT32 LocalLastAttemptStatus;
+ EFI_STATUS Status;
+ UINT8 *Iterator;
+ UINT8 Index;
+ DEPEX_ELEMENT Element1;
+ DEPEX_ELEMENT Element2;
+ GUID ImageTypeId;
+ UINT32 Version;
+ UINT32 LocalLastAttemptStatus;
LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_SUCCESS;
//
// Check if parameter is valid.
//
- if (Dependencies == NULL || DependenciesSize == 0) {
+ if ((Dependencies == NULL) || (DependenciesSize == 0)) {
return FALSE;
}
- if (FmpVersions == NULL && FmpVersionsCount > 0) {
+ if ((FmpVersions == NULL) && (FmpVersionsCount > 0)) {
return FALSE;
}
@@ -253,216 +254,247 @@ EvaluateDependency ( //
mDepexEvaluationStackPointer = mDepexEvaluationStack;
- Iterator = (UINT8 *) Dependencies->Dependencies;
- while (Iterator < (UINT8 *) Dependencies->Dependencies + DependenciesSize) {
- switch (*Iterator)
- {
- case EFI_FMP_DEP_PUSH_GUID:
- if (Iterator + sizeof (EFI_GUID) >= (UINT8 *) Dependencies->Dependencies + DependenciesSize) {
- DEBUG ((DEBUG_ERROR, "EvaluateDependency: GUID extends beyond end of dependency expression!\n"));
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_GUID_BEYOND_DEPEX;
- goto Error;
- }
+ Iterator = (UINT8 *)Dependencies->Dependencies;
+ while (Iterator < (UINT8 *)Dependencies->Dependencies + DependenciesSize) {
+ switch (*Iterator) {
+ case EFI_FMP_DEP_PUSH_GUID:
+ if (Iterator + sizeof (EFI_GUID) >= (UINT8 *)Dependencies->Dependencies + DependenciesSize) {
+ DEBUG ((DEBUG_ERROR, "EvaluateDependency: GUID extends beyond end of dependency expression!\n"));
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_GUID_BEYOND_DEPEX;
+ goto Error;
+ }
+
+ CopyGuid (&ImageTypeId, (EFI_GUID *)(Iterator + 1));
+ Iterator = Iterator + sizeof (EFI_GUID);
- CopyGuid (&ImageTypeId, (EFI_GUID *) (Iterator + 1));
- Iterator = Iterator + sizeof (EFI_GUID);
+ for (Index = 0; Index < FmpVersionsCount; Index++) {
+ if (CompareGuid (&FmpVersions[Index].ImageTypeId, &ImageTypeId)) {
+ Status = Push (FmpVersions[Index].Version, VersionType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
+ goto Error;
+ }
- for (Index = 0; Index < FmpVersionsCount; Index ++) {
- if(CompareGuid (&FmpVersions[Index].ImageTypeId, &ImageTypeId)){
- Status = Push (FmpVersions[Index].Version, VersionType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
- goto Error;
+ break;
}
- break;
}
- }
- if (Index == FmpVersionsCount) {
- DEBUG ((DEBUG_ERROR, "EvaluateDependency: %g is not found!\n", &ImageTypeId));
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_FMP_NOT_FOUND;
- goto Error;
- }
- break;
- case EFI_FMP_DEP_PUSH_VERSION:
- if (Iterator + sizeof (UINT32) >= (UINT8 *) Dependencies->Dependencies + DependenciesSize ) {
- DEBUG ((DEBUG_ERROR, "EvaluateDependency: VERSION extends beyond end of dependency expression!\n"));
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_VERSION_BEYOND_DEPEX;
- goto Error;
- }
- Version = *(UINT32 *) (Iterator + 1);
- Status = Push (Version, VersionType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
- goto Error;
- }
- Iterator = Iterator + sizeof (UINT32);
- break;
- case EFI_FMP_DEP_VERSION_STR:
- Iterator += AsciiStrnLenS ((CHAR8 *) Iterator, DependenciesSize - (Iterator - Dependencies->Dependencies));
- if (Iterator == (UINT8 *) Dependencies->Dependencies + DependenciesSize) {
- DEBUG ((DEBUG_ERROR, "EvaluateDependency: STRING extends beyond end of dependency expression!\n"));
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_VERSION_STR_BEYOND_DEPEX;
- goto Error;
- }
- break;
- case EFI_FMP_DEP_AND:
- Status = Pop (&Element1, BooleanType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
- goto Error;
- }
- Status = Pop (&Element2, BooleanType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
- goto Error;
- }
- Status = Push (Element1.Value.Boolean & Element2.Value.Boolean, BooleanType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
- goto Error;
- }
- break;
- case EFI_FMP_DEP_OR:
- Status = Pop (&Element1, BooleanType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
- goto Error;
- }
- Status = Pop(&Element2, BooleanType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
- goto Error;
- }
- Status = Push (Element1.Value.Boolean | Element2.Value.Boolean, BooleanType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
- goto Error;
- }
- break;
- case EFI_FMP_DEP_NOT:
- Status = Pop (&Element1, BooleanType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
- goto Error;
- }
- Status = Push (!(Element1.Value.Boolean), BooleanType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
- goto Error;
- }
- break;
- case EFI_FMP_DEP_TRUE:
- Status = Push (TRUE, BooleanType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
- goto Error;
- }
- break;
- case EFI_FMP_DEP_FALSE:
- Status = Push (FALSE, BooleanType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
- goto Error;
- }
- break;
- case EFI_FMP_DEP_EQ:
- Status = Pop (&Element1, VersionType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
- goto Error;
- }
- Status = Pop (&Element2, VersionType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
- goto Error;
- }
- Status = (Element1.Value.Version == Element2.Value.Version) ? Push (TRUE, BooleanType) : Push (FALSE, BooleanType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
- goto Error;
- }
- break;
- case EFI_FMP_DEP_GT:
- Status = Pop (&Element1, VersionType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
- goto Error;
- }
- Status = Pop (&Element2, VersionType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
- goto Error;
- }
- Status = (Element1.Value.Version > Element2.Value.Version) ? Push (TRUE, BooleanType) : Push (FALSE, BooleanType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
- goto Error;
- }
- break;
- case EFI_FMP_DEP_GTE:
- Status = Pop (&Element1, VersionType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
- goto Error;
- }
- Status = Pop (&Element2, VersionType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
- goto Error;
- }
- Status = (Element1.Value.Version >= Element2.Value.Version) ? Push (TRUE, BooleanType) : Push (FALSE, BooleanType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
- goto Error;
- }
- break;
- case EFI_FMP_DEP_LT:
- Status = Pop (&Element1, VersionType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
- goto Error;
- }
- Status = Pop (&Element2, VersionType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus= LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
- goto Error;
- }
- Status = (Element1.Value.Version < Element2.Value.Version) ? Push (TRUE, BooleanType) : Push (FALSE, BooleanType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
- goto Error;
- }
- break;
- case EFI_FMP_DEP_LTE:
- Status = Pop (&Element1, VersionType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
- goto Error;
- }
- Status = Pop (&Element2, VersionType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
- goto Error;
- }
- Status = (Element1.Value.Version <= Element2.Value.Version) ? Push (TRUE, BooleanType) : Push (FALSE, BooleanType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
- goto Error;
- }
- break;
- case EFI_FMP_DEP_END:
- Status = Pop (&Element1, BooleanType);
- if (EFI_ERROR (Status)) {
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
+ if (Index == FmpVersionsCount) {
+ DEBUG ((DEBUG_ERROR, "EvaluateDependency: %g is not found!\n", &ImageTypeId));
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_FMP_NOT_FOUND;
+ goto Error;
+ }
+
+ break;
+ case EFI_FMP_DEP_PUSH_VERSION:
+ if (Iterator + sizeof (UINT32) >= (UINT8 *)Dependencies->Dependencies + DependenciesSize ) {
+ DEBUG ((DEBUG_ERROR, "EvaluateDependency: VERSION extends beyond end of dependency expression!\n"));
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_VERSION_BEYOND_DEPEX;
+ goto Error;
+ }
+
+ Version = *(UINT32 *)(Iterator + 1);
+ Status = Push (Version, VersionType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
+ goto Error;
+ }
+
+ Iterator = Iterator + sizeof (UINT32);
+ break;
+ case EFI_FMP_DEP_VERSION_STR:
+ Iterator += AsciiStrnLenS ((CHAR8 *)Iterator, DependenciesSize - (Iterator - Dependencies->Dependencies));
+ if (Iterator == (UINT8 *)Dependencies->Dependencies + DependenciesSize) {
+ DEBUG ((DEBUG_ERROR, "EvaluateDependency: STRING extends beyond end of dependency expression!\n"));
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_VERSION_STR_BEYOND_DEPEX;
+ goto Error;
+ }
+
+ break;
+ case EFI_FMP_DEP_AND:
+ Status = Pop (&Element1, BooleanType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
+ goto Error;
+ }
+
+ Status = Pop (&Element2, BooleanType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
+ goto Error;
+ }
+
+ Status = Push (Element1.Value.Boolean & Element2.Value.Boolean, BooleanType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
+ goto Error;
+ }
+
+ break;
+ case EFI_FMP_DEP_OR:
+ Status = Pop (&Element1, BooleanType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
+ goto Error;
+ }
+
+ Status = Pop (&Element2, BooleanType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
+ goto Error;
+ }
+
+ Status = Push (Element1.Value.Boolean | Element2.Value.Boolean, BooleanType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
+ goto Error;
+ }
+
+ break;
+ case EFI_FMP_DEP_NOT:
+ Status = Pop (&Element1, BooleanType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
+ goto Error;
+ }
+
+ Status = Push (!(Element1.Value.Boolean), BooleanType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
+ goto Error;
+ }
+
+ break;
+ case EFI_FMP_DEP_TRUE:
+ Status = Push (TRUE, BooleanType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
+ goto Error;
+ }
+
+ break;
+ case EFI_FMP_DEP_FALSE:
+ Status = Push (FALSE, BooleanType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
+ goto Error;
+ }
+
+ break;
+ case EFI_FMP_DEP_EQ:
+ Status = Pop (&Element1, VersionType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
+ goto Error;
+ }
+
+ Status = Pop (&Element2, VersionType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
+ goto Error;
+ }
+
+ Status = (Element1.Value.Version == Element2.Value.Version) ? Push (TRUE, BooleanType) : Push (FALSE, BooleanType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
+ goto Error;
+ }
+
+ break;
+ case EFI_FMP_DEP_GT:
+ Status = Pop (&Element1, VersionType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
+ goto Error;
+ }
+
+ Status = Pop (&Element2, VersionType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
+ goto Error;
+ }
+
+ Status = (Element1.Value.Version > Element2.Value.Version) ? Push (TRUE, BooleanType) : Push (FALSE, BooleanType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
+ goto Error;
+ }
+
+ break;
+ case EFI_FMP_DEP_GTE:
+ Status = Pop (&Element1, VersionType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
+ goto Error;
+ }
+
+ Status = Pop (&Element2, VersionType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
+ goto Error;
+ }
+
+ Status = (Element1.Value.Version >= Element2.Value.Version) ? Push (TRUE, BooleanType) : Push (FALSE, BooleanType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
+ goto Error;
+ }
+
+ break;
+ case EFI_FMP_DEP_LT:
+ Status = Pop (&Element1, VersionType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
+ goto Error;
+ }
+
+ Status = Pop (&Element2, VersionType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
+ goto Error;
+ }
+
+ Status = (Element1.Value.Version < Element2.Value.Version) ? Push (TRUE, BooleanType) : Push (FALSE, BooleanType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
+ goto Error;
+ }
+
+ break;
+ case EFI_FMP_DEP_LTE:
+ Status = Pop (&Element1, VersionType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
+ goto Error;
+ }
+
+ Status = Pop (&Element2, VersionType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
+ goto Error;
+ }
+
+ Status = (Element1.Value.Version <= Element2.Value.Version) ? Push (TRUE, BooleanType) : Push (FALSE, BooleanType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE;
+ goto Error;
+ }
+
+ break;
+ case EFI_FMP_DEP_END:
+ Status = Pop (&Element1, BooleanType);
+ if (EFI_ERROR (Status)) {
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE;
+ goto Error;
+ }
+
+ return Element1.Value.Boolean;
+ default:
+ DEBUG ((DEBUG_ERROR, "EvaluateDependency: Unknown Opcode - %02x!\n", *Iterator));
+ LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_UNKNOWN_OPCODE;
goto Error;
- }
- return Element1.Value.Boolean;
- default:
- DEBUG ((DEBUG_ERROR, "EvaluateDependency: Unknown Opcode - %02x!\n", *Iterator));
- LocalLastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_UNKNOWN_OPCODE;
- goto Error;
}
+
Iterator++;
}
@@ -504,7 +536,7 @@ ValidateDependency ( UINT8 *Depex;
if (DepexSize != NULL) {
- *DepexSize = 0;
+ *DepexSize = 0;
}
if (Dependencies == NULL) {
@@ -513,37 +545,37 @@ ValidateDependency ( Depex = Dependencies->Dependencies;
while (Depex < Dependencies->Dependencies + MaxDepexSize) {
- switch (*Depex)
- {
- case EFI_FMP_DEP_PUSH_GUID:
- Depex += sizeof (EFI_GUID) + 1;
- break;
- case EFI_FMP_DEP_PUSH_VERSION:
- Depex += sizeof (UINT32) + 1;
- break;
- case EFI_FMP_DEP_VERSION_STR:
- Depex += AsciiStrnLenS ((CHAR8 *) Depex, Dependencies->Dependencies + MaxDepexSize - Depex) + 1;
- break;
- case EFI_FMP_DEP_AND:
- case EFI_FMP_DEP_OR:
- case EFI_FMP_DEP_NOT:
- case EFI_FMP_DEP_TRUE:
- case EFI_FMP_DEP_FALSE:
- case EFI_FMP_DEP_EQ:
- case EFI_FMP_DEP_GT:
- case EFI_FMP_DEP_GTE:
- case EFI_FMP_DEP_LT:
- case EFI_FMP_DEP_LTE:
- Depex += 1;
- break;
- case EFI_FMP_DEP_END:
- Depex += 1;
- if (DepexSize != NULL) {
- *DepexSize = (UINT32)(Depex - Dependencies->Dependencies);
- }
- return TRUE;
- default:
- return FALSE;
+ switch (*Depex) {
+ case EFI_FMP_DEP_PUSH_GUID:
+ Depex += sizeof (EFI_GUID) + 1;
+ break;
+ case EFI_FMP_DEP_PUSH_VERSION:
+ Depex += sizeof (UINT32) + 1;
+ break;
+ case EFI_FMP_DEP_VERSION_STR:
+ Depex += AsciiStrnLenS ((CHAR8 *)Depex, Dependencies->Dependencies + MaxDepexSize - Depex) + 1;
+ break;
+ case EFI_FMP_DEP_AND:
+ case EFI_FMP_DEP_OR:
+ case EFI_FMP_DEP_NOT:
+ case EFI_FMP_DEP_TRUE:
+ case EFI_FMP_DEP_FALSE:
+ case EFI_FMP_DEP_EQ:
+ case EFI_FMP_DEP_GT:
+ case EFI_FMP_DEP_GTE:
+ case EFI_FMP_DEP_LT:
+ case EFI_FMP_DEP_LTE:
+ Depex += 1;
+ break;
+ case EFI_FMP_DEP_END:
+ Depex += 1;
+ if (DepexSize != NULL) {
+ *DepexSize = (UINT32)(Depex - Dependencies->Dependencies);
+ }
+
+ return TRUE;
+ default:
+ return FALSE;
}
}
@@ -568,17 +600,17 @@ ValidateDependency ( @retval Null
**/
-EFI_FIRMWARE_IMAGE_DEP*
+EFI_FIRMWARE_IMAGE_DEP *
EFIAPI
GetImageDependency (
- IN EFI_FIRMWARE_IMAGE_AUTHENTICATION *Image,
- IN UINTN ImageSize,
- OUT UINT32 *DepexSize,
- OUT UINT32 *LastAttemptStatus OPTIONAL
+ IN EFI_FIRMWARE_IMAGE_AUTHENTICATION *Image,
+ IN UINTN ImageSize,
+ OUT UINT32 *DepexSize,
+ OUT UINT32 *LastAttemptStatus OPTIONAL
)
{
- EFI_FIRMWARE_IMAGE_DEP *Depex;
- UINTN MaxDepexSize;
+ EFI_FIRMWARE_IMAGE_DEP *Depex;
+ UINTN MaxDepexSize;
if (Image == NULL) {
return NULL;
@@ -587,18 +619,20 @@ GetImageDependency ( //
// Check to make sure that operation can be safely performed.
//
- if (((UINTN)Image + sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength) < (UINTN)Image || \
- ((UINTN)Image + sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength) >= (UINTN)Image + ImageSize) {
+ if ((((UINTN)Image + sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength) < (UINTN)Image) || \
+ (((UINTN)Image + sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength) >= (UINTN)Image + ImageSize))
+ {
//
// Pointer overflow. Invalid image.
//
if (LastAttemptStatus != NULL) {
*LastAttemptStatus = LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_GET_DEPEX_FAILURE;
}
+
return NULL;
}
- Depex = (EFI_FIRMWARE_IMAGE_DEP*)((UINT8 *)Image + sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength);
+ Depex = (EFI_FIRMWARE_IMAGE_DEP *)((UINT8 *)Image + sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength);
MaxDepexSize = ImageSize - (sizeof (Image->MonotonicCount) + Image->AuthInfo.Hdr.dwLength);
//
diff --git a/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c b/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c index 92f202112f..2e5c17b2b0 100644 --- a/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c +++ b/FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c @@ -131,6 +131,7 @@ FmpDeviceGetSize ( if (Size == NULL) {
return EFI_INVALID_PARAMETER;
}
+
*Size = 0;
return EFI_SUCCESS;
}
@@ -184,13 +185,14 @@ FmpDeviceGetImageTypeIdGuidPtr ( EFI_STATUS
EFIAPI
FmpDeviceGetAttributes (
- OUT UINT64 *Supported,
- OUT UINT64 *Setting
+ OUT UINT64 *Supported,
+ OUT UINT64 *Setting
)
{
- if (Supported == NULL || Setting == NULL) {
+ if ((Supported == NULL) || (Setting == NULL)) {
return EFI_INVALID_PARAMETER;
}
+
*Supported = 0;
*Setting = 0;
return EFI_SUCCESS;
@@ -268,6 +270,7 @@ FmpDeviceGetVersionString ( if (VersionString == NULL) {
return EFI_INVALID_PARAMETER;
}
+
*VersionString = NULL;
return EFI_UNSUPPORTED;
}
@@ -527,15 +530,15 @@ FmpDeviceSetImage ( {
UINT32 LastAttemptStatus;
- return FmpDeviceSetImageWithStatus (
- Image,
- ImageSize,
- VendorCode,
- Progress,
- CapsuleFwVersion,
- AbortReason,
- &LastAttemptStatus
- );
+ return FmpDeviceSetImageWithStatus (
+ Image,
+ ImageSize,
+ VendorCode,
+ Progress,
+ CapsuleFwVersion,
+ AbortReason,
+ &LastAttemptStatus
+ );
}
/**
diff --git a/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c b/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c index 119679cd9c..766647f075 100644 --- a/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c +++ b/FmpDevicePkg/Library/FmpPayloadHeaderLibV1/FmpPayloadHeaderLib.c @@ -22,10 +22,10 @@ #pragma pack(1)
typedef struct {
- UINT32 Signature;
- UINT32 HeaderSize;
- UINT32 FwVersion;
- UINT32 LowestSupportedVersion;
+ UINT32 Signature;
+ UINT32 HeaderSize;
+ UINT32 FwVersion;
+ UINT32 LowestSupportedVersion;
} FMP_PAYLOAD_HEADER;
#pragma pack()
@@ -34,7 +34,7 @@ typedef struct { /// Identifier is used to make sure the data in the header is for this structure
/// and version. If the structure changes update the last digit.
///
-#define FMP_PAYLOAD_HEADER_SIGNATURE SIGNATURE_32 ('M', 'S', 'S', '1')
+#define FMP_PAYLOAD_HEADER_SIGNATURE SIGNATURE_32 ('M', 'S', 'S', '1')
/**
Returns the FMP Payload Header size in bytes.
@@ -61,14 +61,15 @@ GetFmpPayloadHeaderSize ( FmpPayloadHeader = NULL;
- if (Header == NULL || Size == NULL) {
+ if ((Header == NULL) || (Size == NULL)) {
return EFI_INVALID_PARAMETER;
}
FmpPayloadHeader = (FMP_PAYLOAD_HEADER *)Header;
- if ((UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) < (UINTN)FmpPayloadHeader ||
- (UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) >= (UINTN)FmpPayloadHeader + FmpPayloadSize ||
- FmpPayloadHeader->HeaderSize < sizeof (FMP_PAYLOAD_HEADER)) {
+ if (((UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) < (UINTN)FmpPayloadHeader) ||
+ ((UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) >= (UINTN)FmpPayloadHeader + FmpPayloadSize) ||
+ (FmpPayloadHeader->HeaderSize < sizeof (FMP_PAYLOAD_HEADER)))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -106,14 +107,15 @@ GetFmpPayloadHeaderVersion ( FmpPayloadHeader = NULL;
- if (Header == NULL || Version == NULL) {
+ if ((Header == NULL) || (Version == NULL)) {
return EFI_INVALID_PARAMETER;
}
FmpPayloadHeader = (FMP_PAYLOAD_HEADER *)Header;
- if ((UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) < (UINTN)FmpPayloadHeader ||
- (UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) >= (UINTN)FmpPayloadHeader + FmpPayloadSize ||
- FmpPayloadHeader->HeaderSize < sizeof (FMP_PAYLOAD_HEADER)) {
+ if (((UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) < (UINTN)FmpPayloadHeader) ||
+ ((UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) >= (UINTN)FmpPayloadHeader + FmpPayloadSize) ||
+ (FmpPayloadHeader->HeaderSize < sizeof (FMP_PAYLOAD_HEADER)))
+ {
return EFI_INVALID_PARAMETER;
}
@@ -142,23 +144,24 @@ GetFmpPayloadHeaderVersion ( EFI_STATUS
EFIAPI
GetFmpPayloadHeaderLowestSupportedVersion (
- IN CONST VOID *Header,
- IN CONST UINTN FmpPayloadSize,
- OUT UINT32 *LowestSupportedVersion
+ IN CONST VOID *Header,
+ IN CONST UINTN FmpPayloadSize,
+ OUT UINT32 *LowestSupportedVersion
)
{
FMP_PAYLOAD_HEADER *FmpPayloadHeader;
FmpPayloadHeader = NULL;
- if (Header == NULL || LowestSupportedVersion == NULL) {
+ if ((Header == NULL) || (LowestSupportedVersion == NULL)) {
return EFI_INVALID_PARAMETER;
}
FmpPayloadHeader = (FMP_PAYLOAD_HEADER *)Header;
- if ((UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) < (UINTN)FmpPayloadHeader ||
- (UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) >= (UINTN)FmpPayloadHeader + FmpPayloadSize ||
- FmpPayloadHeader->HeaderSize < sizeof (FMP_PAYLOAD_HEADER)) {
+ if (((UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) < (UINTN)FmpPayloadHeader) ||
+ ((UINTN)FmpPayloadHeader + sizeof (FMP_PAYLOAD_HEADER) >= (UINTN)FmpPayloadHeader + FmpPayloadSize) ||
+ (FmpPayloadHeader->HeaderSize < sizeof (FMP_PAYLOAD_HEADER)))
+ {
return EFI_INVALID_PARAMETER;
}
diff --git a/FmpDevicePkg/PrivateInclude/FmpLastAttemptStatus.h b/FmpDevicePkg/PrivateInclude/FmpLastAttemptStatus.h index de865a2e3d..39a55dd2c6 100644 --- a/FmpDevicePkg/PrivateInclude/FmpLastAttemptStatus.h +++ b/FmpDevicePkg/PrivateInclude/FmpLastAttemptStatus.h @@ -29,52 +29,51 @@ /// The value of pre-existing last attempt status codes should never be modified to ensure the values remain
/// consistent over time.
///
-enum LAST_ATTEMPT_STATUS_EXPANDED_ERROR_LIST
-{
+enum LAST_ATTEMPT_STATUS_EXPANDED_ERROR_LIST {
///
/// Last attempt status codes used in FmpDxe
///
- LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_FMP_HEADER = LAST_ATTEMPT_STATUS_DRIVER_MIN_ERROR_CODE_VALUE,
- LAST_ATTEMPT_STATUS_DRIVER_ERROR_PROGRESS_CALLBACK_ERROR ,
- LAST_ATTEMPT_STATUS_DRIVER_ERROR_CHECK_POWER_API ,
- LAST_ATTEMPT_STATUS_DRIVER_ERROR_CHECK_SYS_THERMAL_API ,
- LAST_ATTEMPT_STATUS_DRIVER_ERROR_THERMAL ,
- LAST_ATTEMPT_STATUS_DRIVER_ERROR_CHECK_SYS_ENV_API ,
- LAST_ATTEMPT_STATUS_DRIVER_ERROR_SYSTEM_ENV ,
- LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_FMP_HEADER_SIZE ,
- LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_ALL_HEADER_SIZE ,
- LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_FMP_HEADER_VERSION ,
- LAST_ATTEMPT_STATUS_DRIVER_ERROR_IMAGE_NOT_PROVIDED ,
- LAST_ATTEMPT_STATUS_DRIVER_ERROR_IMAGE_NOT_UPDATABLE ,
- LAST_ATTEMPT_STATUS_DRIVER_ERROR_INVALID_CERTIFICATE ,
- LAST_ATTEMPT_STATUS_DRIVER_ERROR_INVALID_IMAGE_INDEX ,
- LAST_ATTEMPT_STATUS_DRIVER_ERROR_INVALID_KEY_LENGTH ,
- LAST_ATTEMPT_STATUS_DRIVER_ERROR_INVALID_KEY_LENGTH_VALUE ,
- LAST_ATTEMPT_STATUS_DRIVER_ERROR_VERSION_TOO_LOW ,
- LAST_ATTEMPT_STATUS_DRIVER_ERROR_DEVICE_LOCKED ,
- LAST_ATTEMPT_STATUS_DRIVER_ERROR_IMAGE_AUTH_FAILURE ,
- LAST_ATTEMPT_STATUS_DRIVER_ERROR_PROTOCOL_ARG_MISSING ,
+ LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_FMP_HEADER = LAST_ATTEMPT_STATUS_DRIVER_MIN_ERROR_CODE_VALUE,
+ LAST_ATTEMPT_STATUS_DRIVER_ERROR_PROGRESS_CALLBACK_ERROR,
+ LAST_ATTEMPT_STATUS_DRIVER_ERROR_CHECK_POWER_API,
+ LAST_ATTEMPT_STATUS_DRIVER_ERROR_CHECK_SYS_THERMAL_API,
+ LAST_ATTEMPT_STATUS_DRIVER_ERROR_THERMAL,
+ LAST_ATTEMPT_STATUS_DRIVER_ERROR_CHECK_SYS_ENV_API,
+ LAST_ATTEMPT_STATUS_DRIVER_ERROR_SYSTEM_ENV,
+ LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_FMP_HEADER_SIZE,
+ LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_ALL_HEADER_SIZE,
+ LAST_ATTEMPT_STATUS_DRIVER_ERROR_GET_FMP_HEADER_VERSION,
+ LAST_ATTEMPT_STATUS_DRIVER_ERROR_IMAGE_NOT_PROVIDED,
+ LAST_ATTEMPT_STATUS_DRIVER_ERROR_IMAGE_NOT_UPDATABLE,
+ LAST_ATTEMPT_STATUS_DRIVER_ERROR_INVALID_CERTIFICATE,
+ LAST_ATTEMPT_STATUS_DRIVER_ERROR_INVALID_IMAGE_INDEX,
+ LAST_ATTEMPT_STATUS_DRIVER_ERROR_INVALID_KEY_LENGTH,
+ LAST_ATTEMPT_STATUS_DRIVER_ERROR_INVALID_KEY_LENGTH_VALUE,
+ LAST_ATTEMPT_STATUS_DRIVER_ERROR_VERSION_TOO_LOW,
+ LAST_ATTEMPT_STATUS_DRIVER_ERROR_DEVICE_LOCKED,
+ LAST_ATTEMPT_STATUS_DRIVER_ERROR_IMAGE_AUTH_FAILURE,
+ LAST_ATTEMPT_STATUS_DRIVER_ERROR_PROTOCOL_ARG_MISSING,
///
/// Last attempt status codes used in FmpDependencyLib
///
- LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_GET_DEPEX_FAILURE = LAST_ATTEMPT_STATUS_FMP_DEPENDENCY_LIB_MIN_ERROR_CODE_VALUE,
- LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_NO_END_OPCODE ,
- LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_UNKNOWN_OPCODE ,
- LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_GUID_BEYOND_DEPEX ,
- LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_VERSION_BEYOND_DEPEX ,
- LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_VERSION_STR_BEYOND_DEPEX ,
- LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_FMP_NOT_FOUND ,
- LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE ,
- LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE ,
+ LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_GET_DEPEX_FAILURE = LAST_ATTEMPT_STATUS_FMP_DEPENDENCY_LIB_MIN_ERROR_CODE_VALUE,
+ LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_NO_END_OPCODE,
+ LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_UNKNOWN_OPCODE,
+ LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_GUID_BEYOND_DEPEX,
+ LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_VERSION_BEYOND_DEPEX,
+ LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_VERSION_STR_BEYOND_DEPEX,
+ LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_FMP_NOT_FOUND,
+ LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_PUSH_FAILURE,
+ LAST_ATTEMPT_STATUS_DEPENDENCY_LIB_ERROR_POP_FAILURE,
///
/// Last attempt status codes used in FmpDependencyCheckLib
///
- LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_FMP_PROTOCOL_NOT_FOUND = LAST_ATTEMPT_STATUS_FMP_DEPENDENCY_CHECK_LIB_MIN_ERROR_CODE_VALUE,
- LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_MEM_ALLOC_FMP_INFO_BUFFER_FAILED ,
- LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_MEM_ALLOC_DESC_VER_BUFFER_FAILED ,
- LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_MEM_ALLOC_DESC_SIZE_BUFFER_FAILED ,
+ LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_FMP_PROTOCOL_NOT_FOUND = LAST_ATTEMPT_STATUS_FMP_DEPENDENCY_CHECK_LIB_MIN_ERROR_CODE_VALUE,
+ LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_MEM_ALLOC_FMP_INFO_BUFFER_FAILED,
+ LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_MEM_ALLOC_DESC_VER_BUFFER_FAILED,
+ LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_MEM_ALLOC_DESC_SIZE_BUFFER_FAILED,
LAST_ATTEMPT_STATUS_DEPENDENCY_CHECK_LIB_ERROR_MEM_ALLOC_FMP_VER_BUFFER_FAILED
};
diff --git a/FmpDevicePkg/PrivateInclude/Library/FmpPayloadHeaderLib.h b/FmpDevicePkg/PrivateInclude/Library/FmpPayloadHeaderLib.h index 24afd5e299..a527c82460 100644 --- a/FmpDevicePkg/PrivateInclude/Library/FmpPayloadHeaderLib.h +++ b/FmpDevicePkg/PrivateInclude/Library/FmpPayloadHeaderLib.h @@ -75,9 +75,9 @@ GetFmpPayloadHeaderVersion ( EFI_STATUS
EFIAPI
GetFmpPayloadHeaderLowestSupportedVersion (
- IN CONST VOID *Header,
- IN CONST UINTN FmpPayloadSize,
- OUT UINT32 *LowestSupportedVersion
+ IN CONST VOID *Header,
+ IN CONST UINTN FmpPayloadSize,
+ OUT UINT32 *LowestSupportedVersion
);
#endif
diff --git a/FmpDevicePkg/PrivateInclude/Protocol/CapsuleUpdatePolicy.h b/FmpDevicePkg/PrivateInclude/Protocol/CapsuleUpdatePolicy.h index 4f7d917295..7292f8e31b 100644 --- a/FmpDevicePkg/PrivateInclude/Protocol/CapsuleUpdatePolicy.h +++ b/FmpDevicePkg/PrivateInclude/Protocol/CapsuleUpdatePolicy.h @@ -15,7 +15,7 @@ 0x487784c5, 0x6299, 0x4ba6, { 0xb0, 0x96, 0x5c, 0xc5, 0x27, 0x7c, 0xf7, 0x57 } \
}
-typedef struct _EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL;
+typedef struct _EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL;
/**
Determine if the system power state supports a capsule update.
@@ -33,7 +33,7 @@ typedef struct _EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL EDKII_CAPSULE_UPDATE_POLIC **/
typedef
EFI_STATUS
-(EFIAPI * EDKII_CAPSULE_UPDATE_POLICY_CHECK_SYSTEM_POWER) (
+(EFIAPI *EDKII_CAPSULE_UPDATE_POLICY_CHECK_SYSTEM_POWER)(
IN EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL *This,
OUT BOOLEAN *Good
);
@@ -54,7 +54,7 @@ EFI_STATUS **/
typedef
EFI_STATUS
-(EFIAPI * EDKII_CAPSULE_UPDATE_POLICY_CHECK_SYSTEM_THERMAL) (
+(EFIAPI *EDKII_CAPSULE_UPDATE_POLICY_CHECK_SYSTEM_THERMAL)(
IN EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL *This,
OUT BOOLEAN *Good
);
@@ -75,7 +75,7 @@ EFI_STATUS **/
typedef
EFI_STATUS
-(EFIAPI * EDKII_CAPSULE_UPDATE_POLICY_CHECK_SYSTEM_ENVIRONMENT) (
+(EFIAPI *EDKII_CAPSULE_UPDATE_POLICY_CHECK_SYSTEM_ENVIRONMENT)(
IN EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL *This,
OUT BOOLEAN *Good
);
@@ -94,7 +94,7 @@ EFI_STATUS **/
typedef
BOOLEAN
-(EFIAPI * EDKII_CAPSULE_UPDATE_POLICY_IS_LOWEST_SUPPORTED_VERSION_CHECK_REQUIRED) (
+(EFIAPI *EDKII_CAPSULE_UPDATE_POLICY_IS_LOWEST_SUPPORTED_VERSION_CHECK_REQUIRED)(
IN EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL *This
);
@@ -112,7 +112,7 @@ BOOLEAN **/
typedef
BOOLEAN
-(EFIAPI * EDKII_CAPSULE_UPDATE_POLICY_IS_FMP_DEVICE_AT_LOCK_EVENT_REQUIRED) (
+(EFIAPI *EDKII_CAPSULE_UPDATE_POLICY_IS_FMP_DEVICE_AT_LOCK_EVENT_REQUIRED)(
IN EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL *This
);
@@ -120,13 +120,13 @@ BOOLEAN /// This protocol provides platform policy services used during a capsule update.
///
struct _EDKII_CAPSULE_UPDATE_POLICY_PROTOCOL {
- EDKII_CAPSULE_UPDATE_POLICY_CHECK_SYSTEM_POWER CheckSystemPower;
- EDKII_CAPSULE_UPDATE_POLICY_CHECK_SYSTEM_THERMAL CheckSystemThermal;
- EDKII_CAPSULE_UPDATE_POLICY_CHECK_SYSTEM_ENVIRONMENT CheckSystemEnvironment;
- EDKII_CAPSULE_UPDATE_POLICY_IS_LOWEST_SUPPORTED_VERSION_CHECK_REQUIRED IsLowestSupportedVersionCheckRequired;
- EDKII_CAPSULE_UPDATE_POLICY_IS_FMP_DEVICE_AT_LOCK_EVENT_REQUIRED IsLockFmpDeviceAtLockEventGuidRequired;
+ EDKII_CAPSULE_UPDATE_POLICY_CHECK_SYSTEM_POWER CheckSystemPower;
+ EDKII_CAPSULE_UPDATE_POLICY_CHECK_SYSTEM_THERMAL CheckSystemThermal;
+ EDKII_CAPSULE_UPDATE_POLICY_CHECK_SYSTEM_ENVIRONMENT CheckSystemEnvironment;
+ EDKII_CAPSULE_UPDATE_POLICY_IS_LOWEST_SUPPORTED_VERSION_CHECK_REQUIRED IsLowestSupportedVersionCheckRequired;
+ EDKII_CAPSULE_UPDATE_POLICY_IS_FMP_DEVICE_AT_LOCK_EVENT_REQUIRED IsLockFmpDeviceAtLockEventGuidRequired;
};
-extern EFI_GUID gEdkiiCapsuleUpdatePolicyProtocolGuid;
+extern EFI_GUID gEdkiiCapsuleUpdatePolicyProtocolGuid;
#endif
diff --git a/FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/EvaluateDependencyUnitTest.c b/FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/EvaluateDependencyUnitTest.c index 01ac19a7d5..0edb7f6730 100644 --- a/FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/EvaluateDependencyUnitTest.c +++ b/FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/EvaluateDependencyUnitTest.c @@ -19,65 +19,65 @@ #define UNIT_TEST_APP_VERSION "1.0"
typedef struct {
- UINT8 *Dependencies;
- UINTN DependenciesSize;
- BOOLEAN ExpectedResult;
+ UINT8 *Dependencies;
+ UINTN DependenciesSize;
+ BOOLEAN ExpectedResult;
} BASIC_TEST_CONTEXT;
//
// Image Type ID of FMP device A
//
-#define IMAGE_TYPE_ID_1 { 0x97144DFA, 0xEB8E, 0xD14D, {0x8B, 0x4D, 0x39, 0x88, 0x24, 0x96, 0x56, 0x42}}
+#define IMAGE_TYPE_ID_1 { 0x97144DFA, 0xEB8E, 0xD14D, {0x8B, 0x4D, 0x39, 0x88, 0x24, 0x96, 0x56, 0x42}}
//
// Image Type ID of FMP device B
//
-#define IMAGE_TYPE_ID_2 { 0xA42A7370, 0x433A, 0x684D, {0x9A, 0xA1, 0xDE, 0x62, 0x23, 0x30, 0x6C, 0xF3}}
+#define IMAGE_TYPE_ID_2 { 0xA42A7370, 0x433A, 0x684D, {0x9A, 0xA1, 0xDE, 0x62, 0x23, 0x30, 0x6C, 0xF3}}
//
// Device A's version is 0x00000002
// Device B's version is 0x00000003
//
-static FMP_DEPEX_CHECK_VERSION_DATA mFmpVersions[] = {
- {IMAGE_TYPE_ID_1, 0x00000002},
- {IMAGE_TYPE_ID_2, 0x00000003}
+static FMP_DEPEX_CHECK_VERSION_DATA mFmpVersions[] = {
+ { IMAGE_TYPE_ID_1, 0x00000002 },
+ { IMAGE_TYPE_ID_2, 0x00000003 }
};
// Valid Dependency Expression 1: (Version(A) > 0x00000001) && (Version(B) >= 0x00000003)
-static UINT8 mExpression1[] = {
+static UINT8 mExpression1[] = {
EFI_FMP_DEP_PUSH_VERSION, 0x01, 0x00, 0x00, 0x00,
- EFI_FMP_DEP_PUSH_GUID, 0xFA, 0x4D, 0x14, 0x97, 0x8E, 0xEB, 0x4D, 0xD1, 0x8B, 0x4D, 0x39, 0x88, 0x24, 0x96, 0x56, 0x42,
+ EFI_FMP_DEP_PUSH_GUID, 0xFA, 0x4D, 0x14, 0x97,0x8E, 0xEB, 0x4D, 0xD1, 0x8B, 0x4D, 0x39, 0x88, 0x24, 0x96, 0x56, 0x42,
EFI_FMP_DEP_GT,
EFI_FMP_DEP_PUSH_VERSION, 0x03, 0x00, 0x00, 0x00,
- EFI_FMP_DEP_PUSH_GUID, 0x70, 0x73, 0x2A, 0xA4, 0x3A, 0x43, 0x4D, 0x68, 0x9A, 0xA1, 0xDE, 0x62, 0x23, 0x30, 0x6C, 0xF3,
+ EFI_FMP_DEP_PUSH_GUID, 0x70, 0x73, 0x2A, 0xA4,0x3A, 0x43, 0x4D, 0x68, 0x9A, 0xA1, 0xDE, 0x62, 0x23, 0x30, 0x6C, 0xF3,
EFI_FMP_DEP_GTE,
EFI_FMP_DEP_AND,
EFI_FMP_DEP_END
};
// Valid Dependency Expression 2: (Version(A) < 0x00000002) || (Version(B) <= 0x00000003)
-static UINT8 mExpression2[] = {
+static UINT8 mExpression2[] = {
EFI_FMP_DEP_PUSH_VERSION, 0x02, 0x00, 0x00, 0x00,
- EFI_FMP_DEP_PUSH_GUID, 0xFA, 0x4D, 0x14, 0x97, 0x8E, 0xEB, 0x4D, 0xD1, 0x8B, 0x4D, 0x39, 0x88, 0x24, 0x96, 0x56, 0x42,
+ EFI_FMP_DEP_PUSH_GUID, 0xFA, 0x4D, 0x14, 0x97,0x8E, 0xEB, 0x4D, 0xD1, 0x8B, 0x4D, 0x39, 0x88, 0x24, 0x96, 0x56, 0x42,
EFI_FMP_DEP_LT,
EFI_FMP_DEP_PUSH_VERSION, 0x03, 0x00, 0x00, 0x00,
- EFI_FMP_DEP_PUSH_GUID, 0x70, 0x73, 0x2A, 0xA4, 0x3A, 0x43, 0x4D, 0x68, 0x9A, 0xA1, 0xDE, 0x62, 0x23, 0x30, 0x6C, 0xF3,
+ EFI_FMP_DEP_PUSH_GUID, 0x70, 0x73, 0x2A, 0xA4,0x3A, 0x43, 0x4D, 0x68, 0x9A, 0xA1, 0xDE, 0x62, 0x23, 0x30, 0x6C, 0xF3,
EFI_FMP_DEP_LTE,
EFI_FMP_DEP_OR,
EFI_FMP_DEP_END
};
// Valid Dependency Expression 3: !(Version(A) == 0x0000002)
-static UINT8 mExpression3[] = {
+static UINT8 mExpression3[] = {
EFI_FMP_DEP_PUSH_VERSION, 0x02, 0x00, 0x00, 0x00,
- EFI_FMP_DEP_PUSH_GUID, 0xFA, 0x4D, 0x14, 0x97, 0x8E, 0xEB, 0x4D, 0xD1, 0x8B, 0x4D, 0x39, 0x88, 0x24, 0x96, 0x56, 0x42,
+ EFI_FMP_DEP_PUSH_GUID, 0xFA, 0x4D, 0x14, 0x97,0x8E,0xEB, 0x4D, 0xD1, 0x8B, 0x4D, 0x39, 0x88, 0x24, 0x96, 0x56, 0x42,
EFI_FMP_DEP_EQ,
EFI_FMP_DEP_NOT,
EFI_FMP_DEP_END
};
// Valid Dependency Expression 4: "Test" TRUE && FALSE
-static UINT8 mExpression4[] = {
+static UINT8 mExpression4[] = {
EFI_FMP_DEP_VERSION_STR, 'T', 'e', 's', 't', '\0',
EFI_FMP_DEP_TRUE,
EFI_FMP_DEP_FALSE,
@@ -86,58 +86,58 @@ static UINT8 mExpression4[] = { };
// Invalid Dependency Expression 1: Invalid Op-code
-static UINT8 mExpression5[] = {EFI_FMP_DEP_TRUE, 0xAA, EFI_FMP_DEP_END};
+static UINT8 mExpression5[] = { EFI_FMP_DEP_TRUE, 0xAA, EFI_FMP_DEP_END };
// Invalid Dependency Expression 2: String doesn't end with '\0'
-static UINT8 mExpression6[] = {EFI_FMP_DEP_VERSION_STR, 'T', 'e', 's', 't', EFI_FMP_DEP_TRUE, EFI_FMP_DEP_END};
+static UINT8 mExpression6[] = { EFI_FMP_DEP_VERSION_STR, 'T', 'e', 's', 't', EFI_FMP_DEP_TRUE, EFI_FMP_DEP_END };
// Invalid Dependency Expression 3: GUID is in invalid size
-static UINT8 mExpression7[] = {
+static UINT8 mExpression7[] = {
EFI_FMP_DEP_PUSH_VERSION, 0x02, 0x00, 0x00, 0x00,
- EFI_FMP_DEP_PUSH_GUID, 0xAA, 0xBB, 0xCC, 0xDD,
+ EFI_FMP_DEP_PUSH_GUID, 0xAA, 0xBB, 0xCC, 0xDD,
EFI_FMP_DEP_GTE,
EFI_FMP_DEP_END
};
// Invalid Dependency Expression 4: Version is in invalid size
-static UINT8 mExpression8[] = {
+static UINT8 mExpression8[] = {
EFI_FMP_DEP_PUSH_VERSION, 0x02, 0x00,
- EFI_FMP_DEP_PUSH_GUID, 0xDA, 0xCB, 0x25, 0xAC, 0x9E, 0xCD, 0x5E, 0xE2, 0x9C, 0x5E, 0x4A, 0x99, 0x35, 0xA7, 0x67, 0x53,
+ EFI_FMP_DEP_PUSH_GUID, 0xDA, 0xCB,0x25,0xAC, 0x9E, 0xCD, 0x5E, 0xE2, 0x9C, 0x5E, 0x4A, 0x99, 0x35, 0xA7, 0x67, 0x53,
EFI_FMP_DEP_GTE,
EFI_FMP_DEP_END
};
// Invalid Dependency Expression 5: Operand and operator mismatch
-static UINT8 mExpression9[] = {EFI_FMP_DEP_TRUE, EFI_FMP_DEP_FALSE, EFI_FMP_DEP_GTE, EFI_FMP_DEP_END};
+static UINT8 mExpression9[] = { EFI_FMP_DEP_TRUE, EFI_FMP_DEP_FALSE, EFI_FMP_DEP_GTE, EFI_FMP_DEP_END };
// Invalid Dependency Expression 6: GUID is NOT FOUND
-static UINT8 mExpression10[] = {
+static UINT8 mExpression10[] = {
EFI_FMP_DEP_PUSH_VERSION, 0x02, 0x00, 0x00, 0x00,
- EFI_FMP_DEP_PUSH_GUID, 0xDA, 0xCB, 0x25, 0xAC, 0x9E, 0xCD, 0x5E, 0xE2, 0x9C, 0x5E, 0x4A, 0x99, 0x35, 0xA7, 0x67, 0x53,
+ EFI_FMP_DEP_PUSH_GUID, 0xDA, 0xCB, 0x25, 0xAC,0x9E,0xCD, 0x5E, 0xE2, 0x9C, 0x5E, 0x4A, 0x99, 0x35, 0xA7, 0x67, 0x53,
EFI_FMP_DEP_GT,
EFI_FMP_DEP_END
};
// Invalid Dependency Expression 7: Stack underflow
-static UINT8 mExpression11[] = {
+static UINT8 mExpression11[] = {
EFI_FMP_DEP_PUSH_VERSION, 0x02, 0x00, 0x00, 0x00,
EFI_FMP_DEP_GT,
EFI_FMP_DEP_END
};
// ------------------------------------------------Test Depex------Depex Size----------------Expected Result
-static BASIC_TEST_CONTEXT mBasicTestTrue1 = {mExpression1, sizeof(mExpression1), TRUE};
-static BASIC_TEST_CONTEXT mBasicTestTrue2 = {mExpression2, sizeof(mExpression2), TRUE};
-static BASIC_TEST_CONTEXT mBasicTestFalse1 = {mExpression3, sizeof(mExpression3), FALSE};
-static BASIC_TEST_CONTEXT mBasicTestFalse2 = {mExpression4, sizeof(mExpression4), FALSE};
-static BASIC_TEST_CONTEXT mBasicTestInvalid1 = {mExpression1, sizeof(mExpression1) - 1, FALSE};
-static BASIC_TEST_CONTEXT mBasicTestInvalid2 = {mExpression5, sizeof(mExpression5), FALSE};
-static BASIC_TEST_CONTEXT mBasicTestInvalid3 = {mExpression6, sizeof(mExpression6), FALSE};
-static BASIC_TEST_CONTEXT mBasicTestInvalid4 = {mExpression7, sizeof(mExpression7), FALSE};
-static BASIC_TEST_CONTEXT mBasicTestInvalid5 = {mExpression8, sizeof(mExpression8), FALSE};
-static BASIC_TEST_CONTEXT mBasicTestInvalid6 = {mExpression9, sizeof(mExpression9), FALSE};
-static BASIC_TEST_CONTEXT mBasicTestInvalid7 = {mExpression10, sizeof(mExpression10), FALSE};
-static BASIC_TEST_CONTEXT mBasicTestInvalid8 = {mExpression11, sizeof(mExpression11), FALSE};
+static BASIC_TEST_CONTEXT mBasicTestTrue1 = { mExpression1, sizeof (mExpression1), TRUE };
+static BASIC_TEST_CONTEXT mBasicTestTrue2 = { mExpression2, sizeof (mExpression2), TRUE };
+static BASIC_TEST_CONTEXT mBasicTestFalse1 = { mExpression3, sizeof (mExpression3), FALSE };
+static BASIC_TEST_CONTEXT mBasicTestFalse2 = { mExpression4, sizeof (mExpression4), FALSE };
+static BASIC_TEST_CONTEXT mBasicTestInvalid1 = { mExpression1, sizeof (mExpression1) - 1, FALSE };
+static BASIC_TEST_CONTEXT mBasicTestInvalid2 = { mExpression5, sizeof (mExpression5), FALSE };
+static BASIC_TEST_CONTEXT mBasicTestInvalid3 = { mExpression6, sizeof (mExpression6), FALSE };
+static BASIC_TEST_CONTEXT mBasicTestInvalid4 = { mExpression7, sizeof (mExpression7), FALSE };
+static BASIC_TEST_CONTEXT mBasicTestInvalid5 = { mExpression8, sizeof (mExpression8), FALSE };
+static BASIC_TEST_CONTEXT mBasicTestInvalid6 = { mExpression9, sizeof (mExpression9), FALSE };
+static BASIC_TEST_CONTEXT mBasicTestInvalid7 = { mExpression10, sizeof (mExpression10), FALSE };
+static BASIC_TEST_CONTEXT mBasicTestInvalid8 = { mExpression11, sizeof (mExpression11), FALSE };
/**
Unit test for EvaluateDependency() API of the FmpDependencyLib.
@@ -171,7 +171,7 @@ EvaluateDependencyTest ( (EFI_FIRMWARE_IMAGE_DEP *)TestContext->Dependencies,
TestContext->DependenciesSize,
mFmpVersions,
- sizeof(mFmpVersions)/sizeof(FMP_DEPEX_CHECK_VERSION_DATA),
+ sizeof (mFmpVersions)/sizeof (FMP_DEPEX_CHECK_VERSION_DATA),
&LastAttemptStatus
);
@@ -208,8 +208,8 @@ UnitTestingEntry ( //
Status = InitUnitTestFramework (&Fw, UNIT_TEST_APP_NAME, gEfiCallerBaseName, UNIT_TEST_APP_VERSION);
if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status = %r\n", Status));
- goto EXIT;
+ DEBUG ((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status = %r\n", Status));
+ goto EXIT;
}
//
@@ -265,8 +265,8 @@ FmpDependencyLibUnitTestAppEntry ( **/
int
main (
- int argc,
- char *argv[]
+ int argc,
+ char *argv[]
)
{
return UnitTestingEntry ();
|