TianoCore EDK2 master
Loading...
Searching...
No Matches
ShellEnvVar.h File Reference

Go to the source code of this file.

Data Structures

struct  ENV_VAR_LIST
 

Macros

#define SHELL_DELETE_ENVIRONMENT_VARIABLE(EnvVarName)
 
#define SHELL_SET_ENVIRONMENT_VARIABLE_NV(EnvVarName, BufferSize, Buffer)
 
#define SHELL_GET_ENVIRONMENT_VARIABLE(EnvVarName, BufferSize, Buffer)
 
#define SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(EnvVarName, Atts, BufferSize, Buffer)
 
#define SHELL_SET_ENVIRONMENT_VARIABLE_V(EnvVarName, BufferSize, Buffer)
 

Functions

EFI_STATUS IsVolatileEnv (IN CONST CHAR16 *EnvVarName, OUT BOOLEAN *Volatile)
 
EFI_STATUS GetEnvironmentVariableList (IN OUT LIST_ENTRY *List)
 
EFI_STATUS SetEnvironmentVariableList (IN LIST_ENTRY *List)
 
EFI_STATUS SetEnvironmentVariables (IN CONST CHAR16 **Environment)
 
VOID FreeEnvironmentVariableList (IN LIST_ENTRY *List)
 
EFI_STATUS ShellFindEnvVarInList (IN CONST CHAR16 *Key, OUT CHAR16 **Value, OUT UINTN *ValueSize, OUT UINT32 *Atts OPTIONAL)
 
EFI_STATUS ShellAddEnvVarToList (IN CONST CHAR16 *Key, IN CONST CHAR16 *Value, IN UINTN ValueSize, IN UINT32 Atts)
 
EFI_STATUS ShellRemvoeEnvVarFromList (IN CONST CHAR16 *Key)
 
EFI_STATUS ShellInitEnvVarList (VOID)
 
VOID ShellFreeEnvVarList (VOID)
 

Variables

ENV_VAR_LIST gShellEnvVarList
 

Detailed Description

function definitions for shell environment functions.

the following includes are required: #include <Guid/ShellVariableGuid.h> #include <Library/UefiRuntimeServicesTableLib.h>

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

Definition in file ShellEnvVar.h.

Macro Definition Documentation

◆ SHELL_DELETE_ENVIRONMENT_VARIABLE

#define SHELL_DELETE_ENVIRONMENT_VARIABLE (   EnvVarName)
Value:
(gRT->SetVariable((CHAR16*)EnvVarName, \
&gShellVariableGuid, \
0, \
0, \
NULL))
EFI_RUNTIME_SERVICES * gRT
#define NULL
Definition: Base.h:319

Delete a Non-Volatile environment variable.

This will use the Runtime Services call SetVariable to remove a non-volatile variable.

Parameters
EnvVarNameThe name of the environment variable in question
Return values
EFI_SUCCESSThe variable was deleted successfully
otherAn error occurred
See also
SetVariable

Definition at line 55 of file ShellEnvVar.h.

◆ SHELL_GET_ENVIRONMENT_VARIABLE

#define SHELL_GET_ENVIRONMENT_VARIABLE (   EnvVarName,
  BufferSize,
  Buffer 
)
Value:
(gRT->GetVariable((CHAR16*)EnvVarName, \
&gShellVariableGuid, \
0, \
BufferSize, \
Buffer))

Get an environment variable.

This will use the Runtime Services call GetVariable to get a variable.

Parameters
EnvVarNameThe name of the environment variable in question
BufferSizePointer to the UINTN size of Buffer
BufferPointer buffer to get variable value into
Return values
EFI_SUCCESSThe variable's value was retrieved successfully
otherAn error occurred
See also
SetVariable

Definition at line 95 of file ShellEnvVar.h.

◆ SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES

#define SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES (   EnvVarName,
  Atts,
  BufferSize,
  Buffer 
)
Value:
(gRT->GetVariable((CHAR16*)EnvVarName, \
&gShellVariableGuid, \
Atts, \
BufferSize, \
Buffer))

Get an environment variable.

This will use the Runtime Services call GetVariable to get a variable.

Parameters
EnvVarNameThe name of the environment variable in question
AttsPointer to the UINT32 for attributes (or NULL)
BufferSizePointer to the UINTN size of Buffer
BufferPointer buffer to get variable value into
Return values
EFI_SUCCESSThe variable's value was retrieved successfully
otherAn error occurred
See also
SetVariable

Definition at line 116 of file ShellEnvVar.h.

◆ SHELL_SET_ENVIRONMENT_VARIABLE_NV

#define SHELL_SET_ENVIRONMENT_VARIABLE_NV (   EnvVarName,
  BufferSize,
  Buffer 
)
Value:
(gRT->SetVariable((CHAR16*)EnvVarName, \
&gShellVariableGuid, \
EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS, \
BufferSize, \
(VOID*)Buffer))
#define EFI_VARIABLE_NON_VOLATILE

Set a Non-Volatile environment variable.

This will use the Runtime Services call SetVariable to set a non-volatile variable.

Parameters
EnvVarNameThe name of the environment variable in question
BufferSizeUINTN size of Buffer
BufferPointer to value to set variable to
Return values
EFI_SUCCESSThe variable was changed successfully
otherAn error occurred
See also
SetVariable

Definition at line 75 of file ShellEnvVar.h.

◆ SHELL_SET_ENVIRONMENT_VARIABLE_V

#define SHELL_SET_ENVIRONMENT_VARIABLE_V (   EnvVarName,
  BufferSize,
  Buffer 
)
Value:
(gRT->SetVariable((CHAR16*)EnvVarName, \
&gShellVariableGuid, \
EFI_VARIABLE_BOOTSERVICE_ACCESS, \
BufferSize, \
(VOID*)Buffer))

Set a Volatile environment variable.

This will use the Runtime Services call SetVariable to set a volatile variable.

Parameters
EnvVarNameThe name of the environment variable in question
BufferSizeUINTN size of Buffer
BufferPointer to value to set variable to
Return values
EFI_SUCCESSThe variable was changed successfully
otherAn error occurred
See also
SetVariable

Definition at line 136 of file ShellEnvVar.h.

Function Documentation

◆ FreeEnvironmentVariableList()

VOID FreeEnvironmentVariableList ( IN LIST_ENTRY List)

free function for ENV_VAR_LIST objects.

Parameters
[in]ListThe pointer to pointer to list.

Definition at line 95 of file ShellEnvVar.c.

◆ GetEnvironmentVariableList()

EFI_STATUS GetEnvironmentVariableList ( IN OUT LIST_ENTRY ListHead)

Creates a list of all Shell-Guid-based environment variables.

Parameters
[in,out]ListThe pointer to pointer to LIST_ENTRY object for storing this list.
Return values
EFI_SUCCESSthe list was created successfully.

Creates a list of all Shell-Guid-based environment variables.

Parameters
[in,out]ListHeadThe pointer to pointer to LIST ENTRY object for storing this list.
Return values
EFI_SUCCESSthe list was created successfully.

Definition at line 134 of file ShellEnvVar.c.

◆ IsVolatileEnv()

EFI_STATUS IsVolatileEnv ( IN CONST CHAR16 *  EnvVarName,
OUT BOOLEAN *  Volatile 
)

Reports whether an environment variable is Volatile or Non-Volatile.

Parameters
EnvVarNameThe name of the environment variable in question
VolatileReturn TRUE if the environment variable is volatile
Return values
EFI_SUCCESSThe volatile attribute is returned successfully
othersSome errors happened.

Definition at line 29 of file ShellEnvVar.c.

◆ SetEnvironmentVariableList()

EFI_STATUS SetEnvironmentVariableList ( IN LIST_ENTRY ListHead)

Sets a list of all Shell-Guid-based environment variables. this will also eliminate all pre-existing shell environment variables (even if they are not on the list).

This function will also deallocate the memory from List.

Parameters
[in]ListThe pointer to LIST_ENTRY from GetShellEnvVarList().
Return values
EFI_SUCCESSThe list was Set successfully.

Sets a list of all Shell-Guid-based environment variables. this will also eliminate all existing shell environment variables (even if they are not on the list).

This function will also deallocate the memory from List.

Parameters
[in]ListHeadThe pointer to LIST_ENTRY from GetShellEnvVarList().
Return values
EFI_SUCCESSthe list was Set successfully.

Definition at line 254 of file ShellEnvVar.c.

◆ SetEnvironmentVariables()

EFI_STATUS SetEnvironmentVariables ( IN CONST CHAR16 **  Environment)

sets all Shell-Guid-based environment variables. this will also eliminate all pre-existing shell environment variables (even if they are not on the list).

Parameters
[in]EnvironmentPoints to a NULL-terminated array of environment variables with the format 'x=y', where x is the environment variable name and y is the value.
Return values
EFI_SUCCESSThe command executed successfully.
EFI_INVALID_PARAMETERThe parameter is invalid.
EFI_OUT_OF_RESOURCESOut of resources.
See also
SetEnvironmentVariableList

sets a list of all Shell-Guid-based environment variables.

Parameters
EnvironmentPoints to a NULL-terminated array of environment variables with the format 'x=y', where x is the environment variable name and y is the value.
Return values
EFI_SUCCESSThe command executed successfully.
EFI_INVALID_PARAMETERThe parameter is invalid.
EFI_OUT_OF_RESOURCESOut of resources.
See also
SetEnvironmentVariableList

Definition at line 322 of file ShellEnvVar.c.

◆ ShellAddEnvVarToList()

EFI_STATUS ShellAddEnvVarToList ( IN CONST CHAR16 *  Key,
IN CONST CHAR16 *  Value,
IN UINTN  ValueSize,
IN UINT32  Atts 
)

Add an environment variable into gShellEnvVarList.

Parameters
KeyThe name of the environment variable.
ValueThe value of environment variable.
ValueSizeThe size in bytes of the environment variable including the tailing CHAR_NULL
AttsThe attributes of the variable.
Return values
EFI_SUCCESSThe environment variable was added to list successfully.
othersSome errors happened.

Definition at line 472 of file ShellEnvVar.c.

◆ ShellFindEnvVarInList()

EFI_STATUS ShellFindEnvVarInList ( IN CONST CHAR16 *  Key,
OUT CHAR16 **  Value,
OUT UINTN ValueSize,
OUT UINT32 *Atts  OPTIONAL 
)

Find an environment variable in the gShellEnvVarList.

Parameters
KeyThe name of the environment variable.
ValueThe value of the environment variable, the buffer shoule be freed by the caller.
ValueSizeThe size in bytes of the environment variable including the tailing CHAR_NULL.
AttsThe attributes of the variable.
Return values
EFI_SUCCESSThe command executed successfully.
EFI_NOT_FOUNDThe environment variable is not found in gShellEnvVarList.

Find an environment variable in the gShellEnvVarList.

Parameters
KeyThe name of the environment variable.
ValueThe value of the environment variable, the buffer shoule be freed by the caller.
ValueSizeThe size in bytes of the environment variable including the tailing CHAR_NELL.
AttsThe attributes of the variable.
Return values
EFI_SUCCESSThe command executed successfully.
EFI_NOT_FOUNDThe environment variable is not found in gShellEnvVarList.

Definition at line 426 of file ShellEnvVar.c.

◆ ShellFreeEnvVarList()

VOID ShellFreeEnvVarList ( VOID  )

Destructe the gShellEnvVarList.

Definition at line 593 of file ShellEnvVar.c.

◆ ShellInitEnvVarList()

EFI_STATUS ShellInitEnvVarList ( VOID  )

Initialize the gShellEnvVarList and cache all Shell-Guid-based environment variables.

Definition at line 576 of file ShellEnvVar.c.

◆ ShellRemvoeEnvVarFromList()

EFI_STATUS ShellRemvoeEnvVarFromList ( IN CONST CHAR16 *  Key)

Remove a specified environment variable in gShellEnvVarList.

Parameters
KeyThe name of the environment variable.
Return values
EFI_SUCCESSThe command executed successfully.
EFI_NOT_FOUNDThe environment variable is not found in gShellEnvVarList.

Definition at line 543 of file ShellEnvVar.c.

Variable Documentation

◆ gShellEnvVarList

ENV_VAR_LIST gShellEnvVarList
extern

Definition at line 17 of file ShellEnvVar.c.