TianoCore EDK2 master
Loading...
Searching...
No Matches
EdkiiSystemCapsuleLib.c File Reference

Go to the source code of this file.

Functions

BOOLEAN IsBufferErased (IN UINT8 ErasePolarity, IN VOID *InBuffer, IN UINTN BufferSize)
 
BOOLEAN GetSectionByType (IN VOID *SectionBuffer, IN UINT32 SectionBufferSize, IN EFI_SECTION_TYPE SectionType, IN UINTN SectionInstance, OUT VOID **OutSectionBuffer, OUT UINTN *OutSectionSize)
 
BOOLEAN GetFfsByName (IN VOID *FdStart, IN UINTN FdSize, IN EFI_GUID *FileName, IN EFI_FV_FILETYPE Type, OUT VOID **OutFfsBuffer, OUT UINTN *OutFfsBufferSize)
 
BOOLEAN EFIAPI ExtractDriverFvImage (IN VOID *AuthenticatedImage, IN UINTN AuthenticatedImageSize, OUT VOID **DriverFvImage, OUT UINTN *DriverFvImageSize)
 
BOOLEAN EFIAPI ExtractConfigImage (IN VOID *AuthenticatedImage, IN UINTN AuthenticatedImageSize, OUT VOID **ConfigImage, OUT UINTN *ConfigImageSize)
 
BOOLEAN EFIAPI ExtractAuthenticatedImage (IN VOID *Image, IN UINTN ImageSize, OUT UINT32 *LastAttemptStatus, OUT VOID **AuthenticatedImage, OUT UINTN *AuthenticatedImageSize)
 
BOOLEAN EFIAPI ExtractSystemFirmwareImageFmpInfo (IN VOID *SystemFirmwareImage, IN UINTN SystemFirmwareImageSize, OUT EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR **ImageFmpInfo, OUT UINTN *ImageFmpInfoSize)
 
BOOLEAN EFIAPI ExtractSystemFirmwareImage (IN VOID *AuthenticatedImage, IN UINTN AuthenticatedImageSize, OUT VOID **SystemFirmwareImage, OUT UINTN *SystemFirmwareImageSize)
 
EFI_STATUS EFIAPI CapsuleAuthenticateSystemFirmware (IN VOID *Image, IN UINTN ImageSize, IN BOOLEAN ForceVersionMatch, OUT UINT32 *LastAttemptVersion, OUT UINT32 *LastAttemptStatus, OUT VOID **AuthenticatedImage, OUT UINTN *AuthenticatedImageSize)
 
VOID EFIAPI EdkiiSystemCapsuleLibPcdCallBack (IN CONST GUID *CallBackGuid OPTIONAL, IN UINTN CallBackToken, IN OUT VOID *TokenData, IN UINTN TokenDataSize)
 
EFI_STATUS EFIAPI EdkiiSystemCapsuleLibConstructor (VOID)
 

Variables

EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTORmImageFmpInfo
 
UINTN mImageFmpInfoSize
 
EFI_GUID mEdkiiSystemFirmwareFileGuid
 

Detailed Description

EDKII System Capsule library.

EDKII System Capsule library instance.

CapsuleAuthenticateSystemFirmware(), ExtractAuthenticatedImage() will receive untrusted input and do basic validation.

Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file EdkiiSystemCapsuleLib.c.

Function Documentation

◆ CapsuleAuthenticateSystemFirmware()

EFI_STATUS EFIAPI CapsuleAuthenticateSystemFirmware ( IN VOID *  Image,
IN UINTN  ImageSize,
IN BOOLEAN  ForceVersionMatch,
OUT UINT32 *  LastAttemptVersion,
OUT UINT32 *  LastAttemptStatus,
OUT VOID **  AuthenticatedImage,
OUT UINTN AuthenticatedImageSize 
)

Authenticated system firmware FMP capsule image.

Caution: This function may receive untrusted input.

Parameters
[in]ImageThe FMP capsule image, including EFI_FIRMWARE_IMAGE_AUTHENTICATION.
[in]ImageSizeThe size of FMP capsule image in bytes.
[in]ForceVersionMatchTRUE: The version of capsule must be as same as the version of current image. FALSE: The version of capsule must be as same as greater than the lowest supported version of current image.
[out]LastAttemptVersionThe last attempt version, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.
[out]LastAttemptStatusThe last attempt status, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.
[out]AuthenticatedImageThe authenticated capsule image, excluding EFI_FIRMWARE_IMAGE_AUTHENTICATION.
[out]AuthenticatedImageSizeThe size of the authenticated capsule image in bytes.
Return values
TRUEAuthentication passes and the authenticated image is extracted.
FALSEAuthentication fails and the authenticated image is not extracted.

Definition at line 593 of file EdkiiSystemCapsuleLib.c.

◆ EdkiiSystemCapsuleLibConstructor()

EFI_STATUS EFIAPI EdkiiSystemCapsuleLibConstructor ( VOID  )

The constructor function.

Return values
EFI_SUCCESSThe constructor successfully .

Definition at line 732 of file EdkiiSystemCapsuleLib.c.

◆ EdkiiSystemCapsuleLibPcdCallBack()

VOID EFIAPI EdkiiSystemCapsuleLibPcdCallBack ( IN CONST GUID *CallBackGuid  OPTIONAL,
IN UINTN  CallBackToken,
IN OUT VOID *  TokenData,
IN UINTN  TokenDataSize 
)

PcdCallBack gets the real set PCD value

Parameters
[in]CallBackGuidThe PCD token GUID being set.
[in]CallBackTokenThe PCD token number being set.
[in,out]TokenDataA pointer to the token data being set.
[in]TokenDataSizeThe size, in bytes, of the data being set.

Definition at line 687 of file EdkiiSystemCapsuleLib.c.

◆ ExtractAuthenticatedImage()

BOOLEAN EFIAPI ExtractAuthenticatedImage ( IN VOID *  Image,
IN UINTN  ImageSize,
OUT UINT32 *  LastAttemptStatus,
OUT VOID **  AuthenticatedImage,
OUT UINTN AuthenticatedImageSize 
)

Extract the authenticated image from an FMP capsule image.

Caution: This function may receive untrusted input.

Parameters
[in]ImageThe FMP capsule image, including EFI_FIRMWARE_IMAGE_AUTHENTICATION.
[in]ImageSizeThe size of FMP capsule image in bytes.
[out]LastAttemptStatusThe last attempt status, which will be recorded in ESRT and FMP EFI_FIRMWARE_IMAGE_DESCRIPTOR.
[out]AuthenticatedImageThe authenticated capsule image, excluding EFI_FIRMWARE_IMAGE_AUTHENTICATION.
[out]AuthenticatedImageSizeThe size of the authenticated capsule image in bytes.
Return values
TRUEThe authenticated image is extracted.
FALSEThe authenticated image is not extracted.

Definition at line 358 of file EdkiiSystemCapsuleLib.c.

◆ ExtractConfigImage()

BOOLEAN EFIAPI ExtractConfigImage ( IN VOID *  AuthenticatedImage,
IN UINTN  AuthenticatedImageSize,
OUT VOID **  ConfigImage,
OUT UINTN ConfigImageSize 
)

Extract the config image from an authenticated image.

Parameters
[in]AuthenticatedImageThe authenticated capsule image.
[in]AuthenticatedImageSizeThe size of the authenticated capsule image in bytes.
[out]ConfigImageThe config image.
[out]ConfigImageSizeThe size of the config image in bytes.
Return values
TRUEThe config image is extracted.
FALSEThe config image is not extracted.

Definition at line 312 of file EdkiiSystemCapsuleLib.c.

◆ ExtractDriverFvImage()

BOOLEAN EFIAPI ExtractDriverFvImage ( IN VOID *  AuthenticatedImage,
IN UINTN  AuthenticatedImageSize,
OUT VOID **  DriverFvImage,
OUT UINTN DriverFvImageSize 
)

Extract the driver FV from an authenticated image.

Parameters
[in]AuthenticatedImageThe authenticated capsule image.
[in]AuthenticatedImageSizeThe size of the authenticated capsule image in bytes.
[out]DriverFvImageThe driver FV image.
[out]DriverFvImageSizeThe size of the driver FV image in bytes.
Return values
TRUEThe driver Fv is extracted.
FALSEThe driver Fv is not extracted.

Definition at line 269 of file EdkiiSystemCapsuleLib.c.

◆ ExtractSystemFirmwareImage()

BOOLEAN EFIAPI ExtractSystemFirmwareImage ( IN VOID *  AuthenticatedImage,
IN UINTN  AuthenticatedImageSize,
OUT VOID **  SystemFirmwareImage,
OUT UINTN SystemFirmwareImageSize 
)

Extract the System Firmware image from an authenticated image.

Parameters
[in]AuthenticatedImageThe authenticated capsule image.
[in]AuthenticatedImageSizeThe size of the authenticated capsule image in bytes.
[out]SystemFirmwareImageThe System Firmware image.
[out]SystemFirmwareImageSizeThe size of the System Firmware image in bytes.
Return values
TRUEThe System Firmware image is extracted.
FALSEThe System Firmware image is not extracted.

Definition at line 539 of file EdkiiSystemCapsuleLib.c.

◆ ExtractSystemFirmwareImageFmpInfo()

BOOLEAN EFIAPI ExtractSystemFirmwareImageFmpInfo ( IN VOID *  SystemFirmwareImage,
IN UINTN  SystemFirmwareImageSize,
OUT EDKII_SYSTEM_FIRMWARE_IMAGE_DESCRIPTOR **  ImageFmpInfo,
OUT UINTN ImageFmpInfoSize 
)

Extract ImageFmpInfo from system firmware.

Parameters
[in]SystemFirmwareImageThe System Firmware image.
[in]SystemFirmwareImageSizeThe size of the System Firmware image in bytes.
[out]ImageFmpInfoThe ImageFmpInfo.
[out]ImageFmpInfoSizeThe size of the ImageFmpInfo in bytes.
Return values
TRUEThe ImageFmpInfo is extracted.
FALSEThe ImageFmpInfo is not extracted.

Definition at line 481 of file EdkiiSystemCapsuleLib.c.

◆ GetFfsByName()

BOOLEAN GetFfsByName ( IN VOID *  FdStart,
IN UINTN  FdSize,
IN EFI_GUID FileName,
IN EFI_FV_FILETYPE  Type,
OUT VOID **  OutFfsBuffer,
OUT UINTN OutFfsBufferSize 
)

Get FFS buffer pointer by FileName GUID and FileType.

Parameters
[in]FdStartThe System Firmware FD image
[in]FdSizeThe size of System Firmware FD image
[in]FileNameThe FileName GUID of FFS to be found
[in]TypeThe FileType of FFS to be found
[out]OutFfsBufferThe FFS buffer found, including FFS_FILE_HEADER
[out]OutFfsBufferSizeThe size of FFS buffer found, including FFS_FILE_HEADER
Return values
TRUEThe FFS buffer is found.
FALSEThe FFS buffer is not found.

Definition at line 157 of file EdkiiSystemCapsuleLib.c.

◆ GetSectionByType()

BOOLEAN GetSectionByType ( IN VOID *  SectionBuffer,
IN UINT32  SectionBufferSize,
IN EFI_SECTION_TYPE  SectionType,
IN UINTN  SectionInstance,
OUT VOID **  OutSectionBuffer,
OUT UINTN OutSectionSize 
)

Get Section buffer pointer by SectionType and SectionInstance.

Parameters
[in]SectionBufferThe buffer of section
[in]SectionBufferSizeThe size of SectionBuffer in bytes
[in]SectionTypeThe SectionType of Section to be found
[in]SectionInstanceThe Instance of Section to be found
[out]OutSectionBufferThe section found, including SECTION_HEADER
[out]OutSectionSizeThe size of section found, including SECTION_HEADER
Return values
TRUEThe FFS buffer is found.
FALSEThe FFS buffer is not found.

Definition at line 88 of file EdkiiSystemCapsuleLib.c.

◆ IsBufferErased()

BOOLEAN IsBufferErased ( IN UINT8  ErasePolarity,
IN VOID *  InBuffer,
IN UINTN  BufferSize 
)

Check if a block of buffer is erased.

Parameters
[in]ErasePolarityErase polarity attribute of the firmware volume
[in]InBufferThe buffer to be checked
[in]BufferSizeSize of the buffer in bytes
Return values
TRUEThe block of buffer is erased
FALSEThe block of buffer is not erased

Definition at line 48 of file EdkiiSystemCapsuleLib.c.

Variable Documentation

◆ mEdkiiSystemFirmwareFileGuid

EFI_GUID mEdkiiSystemFirmwareFileGuid

Definition at line 35 of file EdkiiSystemCapsuleLib.c.

◆ mImageFmpInfo

Definition at line 33 of file EdkiiSystemCapsuleLib.c.

◆ mImageFmpInfoSize

UINTN mImageFmpInfoSize

Definition at line 34 of file EdkiiSystemCapsuleLib.c.