X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=FmpDevicePkg%2FFmpDxe%2FFmpDxe.c;h=b25a1511c70cbbe3735593e45db37cd865000b88;hp=f0e8b0da823a342938739628dfce06544ac6a74a;hb=a4c35479b79457f8419f0e83c4d60122269ffc64;hpb=c6c18d879e3ddb833c45b4be49fac3e8970a04d2 diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c index f0e8b0da82..b25a1511c7 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; /** @@ -480,7 +487,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 +504,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 +539,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 +632,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 +881,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 +905,9 @@ SetTheImage ( UINT32 AllHeaderSize; UINT32 IncommingFwVersion; UINT32 LastAttemptStatus; + EFI_STATUS GetAttributesStatus; + UINT64 AttributesSupported; + UINT64 AttributesSetting; Status = EFI_SUCCESS; Updateable = 0; @@ -918,7 +928,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 +1120,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: @@ -1205,7 +1219,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