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

Go to the source code of this file.

Macros

#define VAR_POLICY_FLAG_STATS_STR   L"-s"
 
#define VAR_POLICY_FLAG_POLICY_STR   L"-p"
 
#define VAR_POLICY_FLAG_VERBOSE_STR   L"-v"
 
#define VAR_POLICY_CMD_MIN_ATTR_STR_LEN   64
 

Functions

EFI_STATUS GetAttributesString (IN UINT32 Attributes, IN UINTN AttributesStrSize, OUT CHAR16 *AttributesStr)
 
VOID PrintStats (IN UINTN TotalVariables, IN UINTN TotalVariablesSize)
 
CONST VAR_POLICY_CMD_VAR_NAMESPACEGetNameSpaceInfo (IN EFI_GUID *VariableGuid)
 
EFI_STATUS PrintNonVerboseVarInfo (IN CHAR16 *VariableName, IN EFI_GUID *VariableGuid, IN UINTN VariableSize, IN UINT32 VariableAttributes)
 
EFI_STATUS PrintVerboseVarInfo (IN VOID *Data, IN UINTN DataSize)
 
BOOLEAN PrintVariablePolicyInfo (IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid)
 
EFI_STATUS GetNextVariableNameWithDynamicReallocation (IN OUT UINTN *VariableNameBufferSize, IN OUT CHAR16 **VariableName, IN OUT EFI_GUID *VariableGuid)
 
EFI_STATUS DumpVars (IN BOOLEAN Verbose, IN BOOLEAN Stats, IN BOOLEAN PolicyCheck)
 
SHELL_STATUS EFIAPI RunVarPolicy (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
EFI_HII_HANDLE InitializeHiiPackage (IN EFI_HANDLE ImageHandle)
 

Variables

EFI_HII_HANDLE mVarPolicyShellCommandHiiHandle = NULL
 
STATIC CONST SHELL_PARAM_ITEM ParamList []
 
STATIC CONST VAR_POLICY_CMD_VAR_NAMESPACE mVarNamespaces []
 

Detailed Description

Main file for the "varpolicy" dynamic UEFI shell command and application.

This feature can provide detailed UEFI variable policy configuration information in the UEFI shell.

Copyright (c) Microsoft Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file VariablePolicy.c.

Macro Definition Documentation

◆ VAR_POLICY_CMD_MIN_ATTR_STR_LEN

#define VAR_POLICY_CMD_MIN_ATTR_STR_LEN   64

Definition at line 32 of file VariablePolicy.c.

◆ VAR_POLICY_FLAG_POLICY_STR

#define VAR_POLICY_FLAG_POLICY_STR   L"-p"

Definition at line 29 of file VariablePolicy.c.

◆ VAR_POLICY_FLAG_STATS_STR

#define VAR_POLICY_FLAG_STATS_STR   L"-s"

Definition at line 28 of file VariablePolicy.c.

◆ VAR_POLICY_FLAG_VERBOSE_STR

#define VAR_POLICY_FLAG_VERBOSE_STR   L"-v"

Definition at line 30 of file VariablePolicy.c.

Function Documentation

◆ DumpVars()

EFI_STATUS DumpVars ( IN BOOLEAN  Verbose,
IN BOOLEAN  Stats,
IN BOOLEAN  PolicyCheck 
)

Dumps UEFI variable information.

This is the main function that enumerates UEFI variables and prints the information selected by the user.

Parameters
[in]VerboseWhether to print verbose information.
[in]StatsWhether to print statistical information.
[in]PolicyCheckWhether to print variable policy related information.
Return values
EFI_SUCCESSThe UEFI variable information was dumped successfully.
EFI_DEVICE_ERRORAn error occurred attempting to get UEFI variable information.
EFI_OUT_OF_RESOURCESInsufficient memory resources to allocate a required buffer.

Definition at line 621 of file VariablePolicy.c.

◆ GetAttributesString()

EFI_STATUS GetAttributesString ( IN UINT32  Attributes,
IN UINTN  AttributesStrSize,
OUT CHAR16 *  AttributesStr 
)

Returns UEFI variable attribute information in a string.

AttributesStrSize must at least be VAR_POLICY_CMD_MIN_ATTR_STR_LEN in length or EFI_INVALID_PARAMETER will be returned.

Parameters
[in]AttributesThe UEFI variable attributes.
[in]AttributesStrSizeThe size, in bytes, of AttributesStr.
[out]AttributesStrThe Unicode string for the given attributes.
Return values
EFI_SUCCESSThe attributes were converted to a string successfully.
EFI_INVALID_PARAMETERThe AttributesStr pointer is NULL.

Definition at line 101 of file VariablePolicy.c.

◆ GetNameSpaceInfo()

CONST VAR_POLICY_CMD_VAR_NAMESPACE * GetNameSpaceInfo ( IN EFI_GUID VariableGuid)

Returns information for the given variable namespace if available.

Parameters
[in]VariableGuidThe UEFI variable vendor (namespace) GUID.
Returns
Pointer to a namespace info structure on a GUID match.
NULL on lack of a GUID match.

Definition at line 194 of file VariablePolicy.c.

◆ GetNextVariableNameWithDynamicReallocation()

EFI_STATUS GetNextVariableNameWithDynamicReallocation ( IN OUT UINTN VariableNameBufferSize,
IN OUT CHAR16 **  VariableName,
IN OUT EFI_GUID VariableGuid 
)

Gets the next UEFI variable name.

This buffer manages the UEFI variable name buffer, performing memory reallocations as necessary.

Note: The first time this function is called, VariableNameBufferSize must be 0 and the VariableName buffer pointer must point to NULL.

Parameters
[in,out]VariableNameBufferSizeOn input, a pointer to a buffer that holds the current size of the VariableName buffer in bytes. On output, a pointer to a buffer that holds the updated size of the VariableName buffer in bytes.
[in,out]VariableNameOn input, a pointer to a pointer to a buffer that holds the current UEFI variable name. On output, a pointer to a pointer to a buffer that holds the next UEFI variable name.
[in,out]VariableGuidOn input, a pointer to a buffer that holds the current UEFI variable GUID. On output, a pointer to a buffer that holds the next UEFI variable GUID.
Return values
EFI_SUCCESSThe next UEFI variable name was found successfully.
EFI_INVALID_PARAMETERA pointer argument is NULL or initial input values are invalid.
EFI_OUT_OF_RESOURCESInsufficient memory resources to allocate a required buffer.
OthersReturn status codes from the UEFI spec define GetNextVariableName() interface.

Definition at line 543 of file VariablePolicy.c.

◆ InitializeHiiPackage()

EFI_HII_HANDLE InitializeHiiPackage ( IN EFI_HANDLE  ImageHandle)

Retrieve HII package list from ImageHandle and publish to HII database.

Parameters
[in]ImageHandleThe image handle of the process.
Returns
HII handle.

Definition at line 858 of file VariablePolicy.c.

◆ PrintNonVerboseVarInfo()

EFI_STATUS PrintNonVerboseVarInfo ( IN CHAR16 *  VariableName,
IN EFI_GUID VariableGuid,
IN UINTN  VariableSize,
IN UINT32  VariableAttributes 
)

Print non-verbose information about the variable.

Parameters
[in]VariableNameA pointer the Unicode variable name.
[in]VariableGuidA pointer to the variable vendor GUID.
[in]VariableSizeThe size of the UEFI variable in bytes.
[in]VariableAttributesThe UEFI variable attributes.
Return values
EFI_SUCCESSThe non-verbose variable information was printed successfully.
EFI_INVALID_PARAMETERA pointer argument passed to the function was NULL.
EFI_OUT_OF_RESOURCESInsufficient memory resources to print the attributes.

Definition at line 228 of file VariablePolicy.c.

◆ PrintStats()

VOID PrintStats ( IN UINTN  TotalVariables,
IN UINTN  TotalVariablesSize 
)

Prints UEFI variable statistics information.

Parameters
[in]TotalVariablesTotal number of UEFI variables discovered.
[in]TotalVariablesSizeTotal size of UEFI variables discovered.

Definition at line 171 of file VariablePolicy.c.

◆ PrintVariablePolicyInfo()

BOOLEAN PrintVariablePolicyInfo ( IN CHAR16 *  VariableName,
IN EFI_GUID VendorGuid 
)

Prints variable policy information for the given variable.

Parameters
[in]VariableNameA pointer to the Unicode string of the UEFI variable name.
[in]VendorGuidA pointer to the UEFI variable vendor GUID.
Returns
TRUE if a variable policy was found and printed for the variable.
FALSE if an error occurred and/or a variable policy was not found and printed for the variable.

Definition at line 336 of file VariablePolicy.c.

◆ PrintVerboseVarInfo()

EFI_STATUS PrintVerboseVarInfo ( IN VOID *  Data,
IN UINTN  DataSize 
)

Print verbose information about the variable.

Parameters
[in]DataA pointer to the variable data buffer.
[in]DataSizeThe size of data, in bytes, in the variable data buffer.
Return values
EFI_SUCCESSThe verbose variable information was printed successfully.
EFI_INVALID_PARAMETERA pointer argument passed to the function was NULL.

Definition at line 310 of file VariablePolicy.c.

◆ RunVarPolicy()

SHELL_STATUS EFIAPI RunVarPolicy ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Main entry function for the "varpolicy" command/app.

Parameters
[in]ImageHandleHandle to the Image (NULL if Internal).
[in]SystemTablePointer to the System Table (NULL if Internal).
Return values
SHELL_SUCCESSThe "varpolicy" shell command executed successfully.
SHELL_ABORTEDFailed to initialize the shell library.
SHELL_INVALID_PARAMETERAn argument passed to the shell command is invalid.
OthersA different error occurred.

Definition at line 790 of file VariablePolicy.c.

Variable Documentation

◆ mVarNamespaces

Definition at line 43 of file VariablePolicy.c.

◆ mVarPolicyShellCommandHiiHandle

EFI_HII_HANDLE mVarPolicyShellCommandHiiHandle = NULL

Definition at line 34 of file VariablePolicy.c.

◆ ParamList

Initial value:
= {
{ VAR_POLICY_FLAG_POLICY_STR, TypeFlag },
{ VAR_POLICY_FLAG_STATS_STR, TypeFlag },
{ VAR_POLICY_FLAG_VERBOSE_STR, TypeFlag },
{ NULL, TypeMax }
}
#define NULL
Definition: Base.h:319
@ TypeFlag
A flag that is present or not present only (IE "-a").
Definition: ShellLib.h:699

Definition at line 36 of file VariablePolicy.c.