X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=FmpDevicePkg%2FFmpDxe%2FFmpDxe.c;h=095cebaa750771af7bab61b71f2486815e9274d1;hp=b709bc282a6c0d14954db893513cae0662279f4b;hb=559b5d5283ac6c0890b35e8684963e35f57f79b9;hpb=b0bacc003a6890d1881ea269d785d42928a7f340 diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c index b709bc282a..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; /** @@ -210,15 +217,19 @@ GetLowestSupportedVersion ( // Get the LowestSupportedVersion. // - DeviceLibLowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION; - ReturnLsv = PcdGet32 (PcdFmpDeviceBuildTimeLowestSupportedVersion); if (!IsLowestSupportedVersionCheckRequired ()) { - return 1; + // + // Any Version can pass the 0 LowestSupportedVersion check. + // + return 0; } + ReturnLsv = PcdGet32 (PcdFmpDeviceBuildTimeLowestSupportedVersion); + // // Check the FmpDeviceLib // + DeviceLibLowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION; Status = FmpDeviceGetLowestSupportedVersion (&DeviceLibLowestSupportedVersion); if (EFI_ERROR (Status)) { DeviceLibLowestSupportedVersion = DEFAULT_LOWESTSUPPORTEDVERSION; @@ -477,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 @@ -494,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; @@ -520,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: @@ -623,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 @@ -871,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 @@ -895,6 +906,9 @@ SetTheImage ( UINT32 AllHeaderSize; UINT32 IncommingFwVersion; UINT32 LastAttemptStatus; + EFI_STATUS GetAttributesStatus; + UINT64 AttributesSupported; + UINT64 AttributesSetting; Status = EFI_SUCCESS; Updateable = 0; @@ -915,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; } @@ -1107,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: @@ -1118,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; } @@ -1200,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 @@ -1360,7 +1380,7 @@ cleanup: } /** - Main entry for this library. + Main entry for this driver/library. @param[in] ImageHandle Image handle this driver. @param[in] SystemTable Pointer to SystemTable.