TianoCore EDK2 master
Loading...
Searching...
No Matches
PlatVarCleanupLib.c File Reference
#include "PlatVarCleanup.h"

Go to the source code of this file.

Functions

VAR_ERROR_FLAG InternalGetVarErrorFlag (VOID)
 
BOOLEAN IsUserVariable (IN CHAR16 *Name, IN EFI_GUID *Guid)
 
USER_VARIABLE_NODEFindUserVariableNodeByGuid (IN EFI_GUID *Guid)
 
VOID CreateUserVariableNode (VOID)
 
VOID DestroyUserVariableNode (VOID)
 
EFI_STATUS CreateTimeBasedPayload (IN OUT UINTN *DataSize, IN OUT UINT8 **Data)
 
EFI_STATUS CreateCounterBasedPayload (IN OUT UINTN *DataSize, IN OUT UINT8 **Data)
 
VOID DeleteUserVariable (IN BOOLEAN DeleteAll, IN VARIABLE_CLEANUP_DATA *VariableCleanupData OPTIONAL)
 
EFI_STATUS EFIAPI VariableCleanupHiiExtractConfig (IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results)
 
VOID UpdateUserVariableForm (IN VARIABLE_CLEANUP_HII_PRIVATE_DATA *Private)
 
EFI_STATUS EFIAPI VariableCleanupHiiRouteConfig (IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Configuration, OUT EFI_STRING *Progress)
 
EFI_STATUS EFIAPI VariableCleanupHiiCallback (IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN EFI_BROWSER_ACTION Action, IN EFI_QUESTION_ID QuestionId, IN UINT8 Type, IN EFI_IFR_TYPE_VALUE *Value, OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest)
 
EFI_STATUS EFIAPI PlatformVarCleanup (IN VAR_ERROR_FLAG Flag, IN VAR_CLEANUP_TYPE Type)
 
VAR_ERROR_FLAG EFIAPI GetLastBootVarErrorFlag (VOID)
 
VOID EFIAPI PlatformVarCleanupEndOfDxeEvent (IN EFI_EVENT Event, IN VOID *Context)
 
EFI_STATUS EFIAPI PlatformVarCleanupLibConstructor (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
EFI_STATUS EFIAPI PlatformVarCleanupLibDestructor (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

VAR_ERROR_FLAG mLastVarErrorFlag = VAR_ERROR_FLAG_NO_ERROR
 
EDKII_VAR_CHECK_PROTOCOLmVarCheck = NULL
 
BOOLEAN mEndOfDxe = FALSE
 
EFI_EVENT mPlatVarCleanupLibEndOfDxeEvent = NULL
 
LIST_ENTRY mUserVariableList = INITIALIZE_LIST_HEAD_VARIABLE (mUserVariableList)
 
UINT16 mUserVariableCount = 0
 
UINT16 mMarkedUserVariableCount = 0
 
EFI_GUID mVariableCleanupHiiGuid = VARIABLE_CLEANUP_HII_GUID
 
CHAR16 mVarStoreName [] = L"VariableCleanup"
 
HII_VENDOR_DEVICE_PATH mVarCleanupHiiVendorDevicePath
 

Detailed Description

Sample platform variable cleanup library implementation.

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

Definition in file PlatVarCleanupLib.c.

Function Documentation

◆ CreateCounterBasedPayload()

EFI_STATUS CreateCounterBasedPayload ( IN OUT UINTN DataSize,
IN OUT UINT8 **  Data 
)

Create a counter based data payload by concatenating the EFI_VARIABLE_AUTHENTICATION descriptor with the input data. NO authentication is required in this function.

Parameters
[in,out]DataSizeOn input, the size of Data buffer in bytes. On output, the size of data returned in Data buffer in bytes.
[in,out]DataOn input, Pointer to data buffer to be wrapped or pointer to NULL to wrap an empty payload. On output, Pointer to the new payload date buffer allocated from pool, it's caller's responsibility to free the memory after using it.
Return values
EFI_SUCCESSCreate counter based payload successfully.
EFI_OUT_OF_RESOURCESThere are not enough memory resourses to create time based payload.
EFI_INVALID_PARAMETERThe parameter is invalid.
OthersUnexpected error happens.

Definition at line 430 of file PlatVarCleanupLib.c.

◆ CreateTimeBasedPayload()

EFI_STATUS CreateTimeBasedPayload ( IN OUT UINTN DataSize,
IN OUT UINT8 **  Data 
)

Create a time based data payload by concatenating the EFI_VARIABLE_AUTHENTICATION_2 descriptor with the input data. NO authentication is required in this function.

Parameters
[in,out]DataSizeOn input, the size of Data buffer in bytes. On output, the size of data returned in Data buffer in bytes.
[in,out]DataOn input, Pointer to data buffer to be wrapped or pointer to NULL to wrap an empty payload. On output, Pointer to the new payload date buffer allocated from pool, it's caller's responsibility to free the memory after using it.
Return values
EFI_SUCCESSCreate time based payload successfully.
EFI_OUT_OF_RESOURCESThere are not enough memory resourses to create time based payload.
EFI_INVALID_PARAMETERThe parameter is invalid.
OthersUnexpected error happens.

Definition at line 345 of file PlatVarCleanupLib.c.

◆ CreateUserVariableNode()

VOID CreateUserVariableNode ( VOID  )

Create user variable node.

Definition at line 187 of file PlatVarCleanupLib.c.

◆ DeleteUserVariable()

VOID DeleteUserVariable ( IN BOOLEAN  DeleteAll,
IN VARIABLE_CLEANUP_DATA *VariableCleanupData  OPTIONAL 
)

Delete user variable.

Parameters
[in]DeleteAllDelete all user variables.
[in]VariableCleanupDataPointer to variable cleanup data.

Definition at line 500 of file PlatVarCleanupLib.c.

◆ DestroyUserVariableNode()

VOID DestroyUserVariableNode ( VOID  )

Destroy user variable nodes.

Definition at line 294 of file PlatVarCleanupLib.c.

◆ FindUserVariableNodeByGuid()

USER_VARIABLE_NODE * FindUserVariableNodeByGuid ( IN EFI_GUID Guid)

Find user variable node by variable GUID.

Parameters
[in]GuidPointer to vendor guid.
Returns
Pointer to user variable node.

Definition at line 143 of file PlatVarCleanupLib.c.

◆ GetLastBootVarErrorFlag()

VAR_ERROR_FLAG EFIAPI GetLastBootVarErrorFlag ( VOID  )

Get last boot variable error flag.

Returns
Last boot variable error flag.

Definition at line 1203 of file PlatVarCleanupLib.c.

◆ InternalGetVarErrorFlag()

VAR_ERROR_FLAG InternalGetVarErrorFlag ( VOID  )

Internal get variable error flag.

Returns
Variable error flag.

Definition at line 57 of file PlatVarCleanupLib.c.

◆ IsUserVariable()

BOOLEAN IsUserVariable ( IN CHAR16 *  Name,
IN EFI_GUID Guid 
)

Is user variable?

Parameters
[in]NamePointer to variable name.
[in]GuidPointer to vendor guid.
Return values
TRUEUser variable.
FALSESystem variable.

Definition at line 92 of file PlatVarCleanupLib.c.

◆ PlatformVarCleanup()

EFI_STATUS EFIAPI PlatformVarCleanup ( IN VAR_ERROR_FLAG  Flag,
IN VAR_CLEANUP_TYPE  Type 
)

Platform variable cleanup.

Parameters
[in]FlagVariable error flag.
[in]TypeVariable cleanup type. If it is VarCleanupManually, the interface must be called after console connected.
Return values
EFI_SUCCESSNo error or error processed.
EFI_UNSUPPORTEDThe specified Flag or Type is not supported. For example, system error may be not supported to process and Platform should have mechanism to reset system to manufacture mode. Another, if system and user variables are wanted to be distinguished to process, the interface must be called after EndOfDxe.
EFI_OUT_OF_RESOURCESNot enough resource to process the error.
EFI_INVALID_PARAMETERThe specified Flag or Type is an invalid value.
OthersOther failure occurs.

Definition at line 1039 of file PlatVarCleanupLib.c.

◆ PlatformVarCleanupEndOfDxeEvent()

VOID EFIAPI PlatformVarCleanupEndOfDxeEvent ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Notification function of END_OF_DXE.

This is a notification function registered on END_OF_DXE event.

Parameters
[in]EventEvent whose notification function is being invoked.
[in]ContextPointer to the notification function's context.

Definition at line 1221 of file PlatVarCleanupLib.c.

◆ PlatformVarCleanupLibConstructor()

EFI_STATUS EFIAPI PlatformVarCleanupLibConstructor ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

The constructor function caches the pointer to VarCheck protocol and last boot variable error flag.

The constructor function locates VarCheck protocol from protocol database. It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.

Parameters
ImageHandleThe firmware allocated handle for the EFI image.
SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSThe constructor always returns EFI_SUCCESS.

Definition at line 1243 of file PlatVarCleanupLib.c.

◆ PlatformVarCleanupLibDestructor()

EFI_STATUS EFIAPI PlatformVarCleanupLibDestructor ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

The destructor function closes the End of DXE event.

Parameters
ImageHandleThe firmware allocated handle for the EFI image.
SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSThe destructor completed successfully.

Definition at line 1280 of file PlatVarCleanupLib.c.

◆ UpdateUserVariableForm()

VOID UpdateUserVariableForm ( IN VARIABLE_CLEANUP_HII_PRIVATE_DATA Private)

Update user variable form.

Parameters
[in]PrivatePoints to the VARIABLE_CLEANUP_HII_PRIVATE_DATA.

Definition at line 671 of file PlatVarCleanupLib.c.

◆ VariableCleanupHiiCallback()

EFI_STATUS EFIAPI VariableCleanupHiiCallback ( IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL This,
IN EFI_BROWSER_ACTION  Action,
IN EFI_QUESTION_ID  QuestionId,
IN UINT8  Type,
IN EFI_IFR_TYPE_VALUE Value,
OUT EFI_BROWSER_ACTION_REQUEST *  ActionRequest 
)

This function is called to provide results data to the driver. This data consists of a unique key that is used to identify which data is either being passed back or being asked for.

Parameters
[in]ThisPoints to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
[in]ActionSpecifies the type of action taken by the browser.
[in]QuestionIdA unique value which is sent to the original exporting driver so that it can identify the type of data to expect. The format of the data tends to vary based on the opcode that generated the callback.
[in]TypeThe type of value for the question.
[in]ValueA pointer to the data being sent to the original exporting driver.
[out]ActionRequestOn return, points to the action requested by the callback function.
Return values
EFI_SUCCESSThe callback successfully handled the action.
EFI_OUT_OF_RESOURCESNot enough storage is available to hold the variable and its data.
EFI_DEVICE_ERRORThe variable could not be saved.
EFI_UNSUPPORTEDThe specified Action is not supported by the callback.

Definition at line 920 of file PlatVarCleanupLib.c.

◆ VariableCleanupHiiExtractConfig()

EFI_STATUS EFIAPI VariableCleanupHiiExtractConfig ( IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL This,
IN CONST EFI_STRING  Request,
OUT EFI_STRING *  Progress,
OUT EFI_STRING *  Results 
)

This function allows a caller to extract the current configuration for one or more named elements from the target driver.

Parameters
[in]ThisPoints to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
[in]RequestA null-terminated Unicode string in <ConfigRequest> format.
[out]ProgressOn return, points to a character in the Request string. Points to the string's null terminator if request was successful. Points to the most recent '&' before the first failing name/value pair (or the beginning of the string if the failure is in the first name/value pair) if the request was not successful.
[out]ResultsA null-terminated Unicode string in <ConfigAltResp> format which has all values filled in for the names in the Request string. String to be allocated by the called function.
Return values
EFI_SUCCESSThe Results is filled with the requested values.
EFI_OUT_OF_RESOURCESNot enough memory to store the results.
EFI_INVALID_PARAMETERRequest is illegal syntax, or unknown name.
EFI_NOT_FOUNDRouting data doesn't match any storage in this driver.

Definition at line 580 of file PlatVarCleanupLib.c.

◆ VariableCleanupHiiRouteConfig()

EFI_STATUS EFIAPI VariableCleanupHiiRouteConfig ( IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL This,
IN CONST EFI_STRING  Configuration,
OUT EFI_STRING *  Progress 
)

This function applies changes in a driver's configuration. Input is a Configuration, which has the routing data for this driver followed by name / value configuration pairs. The driver must apply those pairs to its configurable storage. If the driver's configuration is stored in a linear block of data and the driver's name / value pairs are in <BlockConfig> format, it may use the ConfigToBlock helper function (above) to simplify the job. Currently not implemented.

Parameters
[in]ThisPoints to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
[in]ConfigurationA null-terminated Unicode string in <ConfigString> format.
[out]ProgressA pointer to a string filled in with the offset of the most recent '&' before the first failing name / value pair (or the beginn ing of the string if the failure is in the first name / value pair) or the terminating NULL if all was successful.
Return values
EFI_SUCCESSThe results have been distributed or are awaiting distribution.
EFI_OUT_OF_RESOURCESNot enough memory to store the parts of the results that must be stored awaiting possible future protocols.
EFI_INVALID_PARAMETERSPassing in a NULL for the Results parameter would result in this type of error.
EFI_NOT_FOUNDTarget for the specified routing data was not found.

Definition at line 840 of file PlatVarCleanupLib.c.

Variable Documentation

◆ mEndOfDxe

BOOLEAN mEndOfDxe = FALSE

The flag to indicate whether the platform has left the DXE phase of execution.

Definition at line 17 of file PlatVarCleanupLib.c.

◆ mLastVarErrorFlag

VAR_ERROR_FLAG mLastVarErrorFlag = VAR_ERROR_FLAG_NO_ERROR

Definition at line 11 of file PlatVarCleanupLib.c.

◆ mMarkedUserVariableCount

UINT16 mMarkedUserVariableCount = 0

Definition at line 23 of file PlatVarCleanupLib.c.

◆ mPlatVarCleanupLibEndOfDxeEvent

EFI_EVENT mPlatVarCleanupLibEndOfDxeEvent = NULL

Definition at line 19 of file PlatVarCleanupLib.c.

◆ mUserVariableCount

UINT16 mUserVariableCount = 0

Definition at line 22 of file PlatVarCleanupLib.c.

◆ mUserVariableList

LIST_ENTRY mUserVariableList = INITIALIZE_LIST_HEAD_VARIABLE (mUserVariableList)

Definition at line 21 of file PlatVarCleanupLib.c.

◆ mVarCheck

Definition at line 12 of file PlatVarCleanupLib.c.

◆ mVarCleanupHiiVendorDevicePath

HII_VENDOR_DEVICE_PATH mVarCleanupHiiVendorDevicePath
Initial value:
= {
{
{
{
(UINT8)(sizeof (VENDOR_DEVICE_PATH)),
(UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
}
},
VARIABLE_CLEANUP_HII_GUID
},
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
(UINT8)(sizeof (EFI_DEVICE_PATH_PROTOCOL)),
(UINT8)((sizeof (EFI_DEVICE_PATH_PROTOCOL)) >> 8)
}
}
}
#define HARDWARE_DEVICE_PATH
Definition: DevicePath.h:68
#define HW_VENDOR_DP
Definition: DevicePath.h:133

Definition at line 28 of file PlatVarCleanupLib.c.

◆ mVariableCleanupHiiGuid

EFI_GUID mVariableCleanupHiiGuid = VARIABLE_CLEANUP_HII_GUID

Definition at line 25 of file PlatVarCleanupLib.c.

◆ mVarStoreName

CHAR16 mVarStoreName[] = L"VariableCleanup"

Definition at line 26 of file PlatVarCleanupLib.c.