TianoCore EDK2 master
Loading...
Searching...
No Matches
UefiCapsule.c File Reference
#include "Capsule.h"

Go to the source code of this file.

Macros

#define DEFAULT_SG_LIST_HEADS   (20)
 

Functions

VOID SortMemoryResourceDescriptor (IN OUT MEMORY_RESOURCE_DESCRIPTOR *MemoryResource)
 
VOID MergeMemoryResourceDescriptor (IN OUT MEMORY_RESOURCE_DESCRIPTOR *MemoryResource)
 
MEMORY_RESOURCE_DESCRIPTORBuildMemoryResourceDescriptor (VOID)
 
BOOLEAN AreCapsulesStaged (VOID)
 
EFI_STATUS GetScatterGatherHeadEntries (OUT UINTN *ListLength, OUT EFI_PHYSICAL_ADDRESS **HeadList)
 
EFI_STATUS EFIAPI CapsuleCoalesce (IN EFI_PEI_SERVICES **PeiServices, IN OUT VOID **MemoryBase, IN OUT UINTN *MemorySize)
 
EFI_STATUS EFIAPI CheckCapsuleUpdate (IN EFI_PEI_SERVICES **PeiServices)
 
BOOLEAN CapsuleTestPattern (IN EFI_PEI_SERVICES **PeiServices, IN VOID *CapsuleBase)
 
EFI_STATUS EFIAPI CreateState (IN EFI_PEI_SERVICES **PeiServices, IN VOID *CapsuleBase, IN UINTN CapsuleSize)
 
EFI_STATUS EFIAPI CapsuleMain (IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
 

Variables

CONST EFI_PEI_CAPSULE_PPI mCapsulePpi
 
CONST EFI_PEI_PPI_DESCRIPTOR mUefiPpiListCapsule
 

Detailed Description

Capsule update PEIM for UEFI2.0

Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
Copyright (c) 2017, AMD Incorporated. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file UefiCapsule.c.

Macro Definition Documentation

◆ DEFAULT_SG_LIST_HEADS

#define DEFAULT_SG_LIST_HEADS   (20)

Definition at line 13 of file UefiCapsule.c.

Function Documentation

◆ AreCapsulesStaged()

BOOLEAN AreCapsulesStaged ( VOID  )

Check if the capsules are staged.

Return values
TRUEThe capsules are staged.
FALSEThe capsules are not staged.

Definition at line 838 of file UefiCapsule.c.

◆ BuildMemoryResourceDescriptor()

MEMORY_RESOURCE_DESCRIPTOR * BuildMemoryResourceDescriptor ( VOID  )

Build memory resource descriptor from resource descriptor in HOB list.

Returns
Pointer to the buffer of memory resource descriptor. NULL if no memory resource descriptor reported in HOB list before capsule Coalesce.

Definition at line 731 of file UefiCapsule.c.

◆ CapsuleCoalesce()

EFI_STATUS EFIAPI CapsuleCoalesce ( IN EFI_PEI_SERVICES **  PeiServices,
IN OUT VOID **  MemoryBase,
IN OUT UINTN MemorySize 
)

Capsule PPI service to coalesce a fragmented capsule in memory.

Parameters
PeiServicesGeneral purpose services available to every PEIM.
MemoryBasePointer to the base of a block of memory that we can walk all over while trying to coalesce our buffers. On output, this variable will hold the base address of a coalesced capsule.
MemorySizeSize of the memory region pointed to by MemoryBase. On output, this variable will contain the size of the coalesced capsule.
Return values
EFI_NOT_FOUNDif we can't determine the boot mode if the boot mode is not flash-update if we could not find the capsule descriptors
EFI_BUFFER_TOO_SMALLif we could not coalesce the capsule in the memory region provided to us
EFI_SUCCESSif there's no capsule, or if we processed the capsule successfully.

Definition at line 1066 of file UefiCapsule.c.

◆ CapsuleMain()

EFI_STATUS EFIAPI CapsuleMain ( IN EFI_PEI_FILE_HANDLE  FileHandle,
IN CONST EFI_PEI_SERVICES **  PeiServices 
)

Entry point function for the PEIM

Parameters
FileHandleHandle of the file being invoked.
PeiServicesDescribes the list of possible PEI Services.
Returns
EFI_SUCCESS If we installed our PPI

Definition at line 1370 of file UefiCapsule.c.

◆ CapsuleTestPattern()

BOOLEAN CapsuleTestPattern ( IN EFI_PEI_SERVICES **  PeiServices,
IN VOID *  CapsuleBase 
)

This function will look at a capsule and determine if it's a test pattern. If it is, then it will verify it and emit an error message if corruption is detected.

Parameters
PeiServicesStandard pei services pointer
CapsuleBaseBase address of coalesced capsule, which is preceeded by private data. Very implementation specific.
Return values
TRUECapsule image is the test image
FALSECapsule image is not the test image.

Definition at line 1204 of file UefiCapsule.c.

◆ CheckCapsuleUpdate()

EFI_STATUS EFIAPI CheckCapsuleUpdate ( IN EFI_PEI_SERVICES **  PeiServices)

Determine if we're in capsule update boot mode.

Parameters
PeiServicesPEI services table
Return values
EFI_SUCCESSif we have a capsule available
EFI_NOT_FOUNDno capsule detected

Definition at line 1180 of file UefiCapsule.c.

◆ CreateState()

EFI_STATUS EFIAPI CreateState ( IN EFI_PEI_SERVICES **  PeiServices,
IN VOID *  CapsuleBase,
IN UINTN  CapsuleSize 
)

Capsule PPI service that gets called after memory is available. The capsule coalesce function, which must be called first, returns a base address and size, which can be anything actually. Once the memory init PEIM has discovered memory, then it should call this function and pass in the base address and size returned by the coalesce function. Then this function can create a capsule HOB and return.

Parameters
PeiServicesstandard pei services pointer
CapsuleBaseaddress returned by the capsule coalesce function. Most likely this will actually be a pointer to private data.
CapsuleSizevalue returned by the capsule coalesce function.
Return values
EFI_VOLUME_CORRUPTEDCapsuleBase does not appear to point to a coalesced capsule
EFI_SUCCESSif all goes well.

Definition at line 1269 of file UefiCapsule.c.

◆ GetScatterGatherHeadEntries()

EFI_STATUS GetScatterGatherHeadEntries ( OUT UINTN ListLength,
OUT EFI_PHYSICAL_ADDRESS **  HeadList 
)

Check all the variables for SG list heads and get the count and addresses.

Parameters
ListLengthA pointer would return the SG list length.
HeadListA ponter to the capsule SG list.
Return values
EFI_SUCCESSa valid capsule is present
EFI_NOT_FOUNDif a valid capsule is not present
EFI_INVALID_PARAMETERthe input parameter is invalid
EFI_OUT_OF_RESOURCESfail to allocate memory

Definition at line 894 of file UefiCapsule.c.

◆ MergeMemoryResourceDescriptor()

VOID MergeMemoryResourceDescriptor ( IN OUT MEMORY_RESOURCE_DESCRIPTOR MemoryResource)

Merge continous memory resource entries.

Parameters
[in,out]MemoryResourceA pointer to the memory resource entry buffer.

Definition at line 685 of file UefiCapsule.c.

◆ SortMemoryResourceDescriptor()

VOID SortMemoryResourceDescriptor ( IN OUT MEMORY_RESOURCE_DESCRIPTOR MemoryResource)

Sort memory resource entries based upon PhysicalStart, from low to high.

Parameters
[in,out]MemoryResourceA pointer to the memory resource entry buffer.

Definition at line 652 of file UefiCapsule.c.

Variable Documentation

◆ mCapsulePpi

Initial value:
= {
}
EFI_STATUS EFIAPI CapsuleCoalesce(IN EFI_PEI_SERVICES **PeiServices, IN OUT VOID **MemoryBase, IN OUT UINTN *MemorySize)
Definition: UefiCapsule.c:1066
EFI_STATUS EFIAPI CreateState(IN EFI_PEI_SERVICES **PeiServices, IN VOID *CapsuleBase, IN UINTN CapsuleSize)
Definition: UefiCapsule.c:1269
EFI_STATUS EFIAPI CheckCapsuleUpdate(IN EFI_PEI_SERVICES **PeiServices)
Definition: UefiCapsule.c:1180

Definition at line 1347 of file UefiCapsule.c.

◆ mUefiPpiListCapsule

CONST EFI_PEI_PPI_DESCRIPTOR mUefiPpiListCapsule
Initial value:
= {
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gEfiPeiCapsulePpiGuid,
(EFI_PEI_CAPSULE_PPI *)&mCapsulePpi
}

Definition at line 1353 of file UefiCapsule.c.