X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=FmpDevicePkg%2FFmpDxe%2FFmpDxe.c;h=095cebaa750771af7bab61b71f2486815e9274d1;hp=091f950b95b23a7a2811b3060748ba04395c023f;hb=559b5d5283ac6c0890b35e8684963e35f57f79b9;hpb=1bbb51266482f2b73771cb23a4180f5617bdcecb diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c index 091f950b95..095cebaa75 100644 --- a/FmpDevicePkg/FmpDxe/FmpDxe.c +++ b/FmpDevicePkg/FmpDxe/FmpDxe.c @@ -89,6 +89,13 @@ UINT64 mImageId = 0x1; CHAR16 *mVersionName = NULL; EFI_EVENT mFmpDeviceLockEvent; +// +// Indicates if an attempt has been made to lock a +// FLASH storage device by calling FmpDeviceLock(). +// A FLASH storage device may not support being locked, +// so this variable is set to TRUE even if FmpDeviceLock() +// returns an error. +// BOOLEAN mFmpDeviceLocked = FALSE; /** @@ -222,6 +229,7 @@ GetLowestSupportedVersion ( // // Check the FmpDeviceLib // + DeviceLibLowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION; Status = FmpDeviceGetLowestSupportedVersion (&DeviceLibLowestSupportedVersion); if (EFI_ERROR (Status)) { DeviceLibLowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION; @@ -480,7 +488,7 @@ cleanup: @retval EFI_INVALID_PARAMETER The Image was NULL. @retval EFI_NOT_FOUND The current image is not copied to the buffer. @retval EFI_UNSUPPORTED The operation is not supported. - @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure. + @retval EFI_SECURITY_VIOLATION The operation could not be performed due to an authentication failure. **/ EFI_STATUS @@ -497,6 +505,15 @@ GetTheImage ( Status = EFI_SUCCESS; + // + // Check to make sure index is 1 (only 1 image for this device) + // + if (ImageIndex != 1) { + DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - Image Index Invalid.\n")); + Status = EFI_INVALID_PARAMETER; + goto cleanup; + } + if ((ImageSize == NULL)) { DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - ImageSize Pointer Parameter is NULL.\n")); Status = EFI_INVALID_PARAMETER; @@ -523,16 +540,6 @@ GetTheImage ( goto cleanup; } - // - // Check to make sure index is 1 (only 1 image for this device) - // - if (ImageIndex != 1) { - DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - Image Index Invalid.\n")); - Status = EFI_INVALID_PARAMETER; - goto cleanup; - } - - Status = FmpDeviceGetImage (Image, ImageSize); cleanup: @@ -626,9 +633,10 @@ GetAllHeaderSize ( if available, additional information if the image is invalid. @retval EFI_SUCCESS The image was successfully checked. + @retval EFI_ABORTED The operation is aborted. @retval EFI_INVALID_PARAMETER The Image was NULL. @retval EFI_UNSUPPORTED The operation is not supported. - @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure. + @retval EFI_SECURITY_VIOLATION The operation could not be performed due to an authentication failure. **/ EFI_STATUS @@ -874,7 +882,7 @@ cleanup: @retval EFI_ABORTED The operation is aborted. @retval EFI_INVALID_PARAMETER The Image was NULL. @retval EFI_UNSUPPORTED The operation is not supported. - @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure. + @retval EFI_SECURITY_VIOLATION The operation could not be performed due to an authentication failure. **/ EFI_STATUS @@ -898,6 +906,9 @@ SetTheImage ( UINT32 AllHeaderSize; UINT32 IncommingFwVersion; UINT32 LastAttemptStatus; + EFI_STATUS GetAttributesStatus; + UINT64 AttributesSupported; + UINT64 AttributesSetting; Status = EFI_SUCCESS; Updateable = 0; @@ -918,7 +929,7 @@ SetTheImage ( // if (mFmpDeviceLocked) { DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - Device is already locked. Can't update.\n")); - Status = EFI_ACCESS_DENIED; + Status = EFI_UNSUPPORTED; goto cleanup; } @@ -1110,10 +1121,14 @@ SetTheImage ( // // Set flag so the descriptor is repopulated - // This only applied to devices that do not require system reboot + // This is only applied to devices that do not require reset // - if (!PcdGetBool (PcdFmpDeviceSystemResetRequired)) { - mDescriptorPopulated = FALSE; + GetAttributesStatus = FmpDeviceGetAttributes (&AttributesSupported, &AttributesSetting); + if (!EFI_ERROR (GetAttributesStatus)) { + if (((AttributesSupported & IMAGE_ATTRIBUTE_RESET_REQUIRED) == 0) || + ((AttributesSetting & IMAGE_ATTRIBUTE_RESET_REQUIRED) == 0)) { + mDescriptorPopulated = FALSE; + } } cleanup: @@ -1121,10 +1136,12 @@ cleanup: mProgressSupported = FALSE; SetLastAttemptStatusInVariable (LastAttemptStatus); - // - // Set progress to 100 after everything is done including recording Status. - // - Progress (100); + if (Progress != NULL) { + // + // Set progress to 100 after everything is done including recording Status. + // + Progress (100); + } return Status; } @@ -1203,7 +1220,7 @@ GetPackageInfo ( @retval EFI_INVALID_PARAMETER The PackageVersionName length is longer than the value returned in PackageVersionNameMaxLen. @retval EFI_UNSUPPORTED The operation is not supported. - @retval EFI_SECURITY_VIOLATIO The operation could not be performed due to an authentication failure. + @retval EFI_SECURITY_VIOLATION The operation could not be performed due to an authentication failure. **/ EFI_STATUS