2 function definitions for shell environment functions.
4 the following includes are required:
5 //#include <Guid/ShellVariableGuid.h>
6 //#include <Library/UefiRuntimeServicesTableLib.h>
9 Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
10 This program and the accompanying materials
11 are licensed and made available under the terms and conditions of the BSD License
12 which accompanies this distribution. The full text of the license may be found at
13 http://opensource.org/licenses/bsd-license.php
15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
16 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
20 #ifndef _SHELL_ENVIRONMENT_VARIABLE_HEADER_
21 #define _SHELL_ENVIRONMENT_VARIABLE_HEADER_
31 // The list is used to cache the environment variables.
33 extern ENV_VAR_LIST gShellEnvVarList
;
37 Reports whether an environment variable is Volatile or Non-Volatile
39 This will use the Runtime Services call GetVariable to to search for the variable.
41 @param EnvVarName The name of the environment variable in question
43 @retval TRUE This environment variable is Volatile
44 @retval FALSE This environment variable is NON-Volatile
49 IN CONST CHAR16
*EnvVarName
53 Delete a Non-Violatile environment variable.
55 This will use the Runtime Services call SetVariable to remove a non-violatile variable.
57 @param EnvVarName The name of the environment variable in question
59 @retval EFI_SUCCESS The variable was deleted sucessfully
60 @retval other An error ocurred
63 #define SHELL_DELETE_ENVIRONMENT_VARIABLE(EnvVarName) \
64 (gRT->SetVariable((CHAR16*)EnvVarName, \
65 &gShellVariableGuid, \
71 Set a Non-Violatile environment variable.
73 This will use the Runtime Services call SetVariable to set a non-violatile variable.
75 @param EnvVarName The name of the environment variable in question
76 @param BufferSize UINTN size of Buffer
77 @param Buffer Pointer to value to set variable to
79 @retval EFI_SUCCESS The variable was changed sucessfully
80 @retval other An error ocurred
83 #define SHELL_SET_ENVIRONMENT_VARIABLE_NV(EnvVarName,BufferSize,Buffer) \
84 (gRT->SetVariable((CHAR16*)EnvVarName, \
85 &gShellVariableGuid, \
86 EFI_VARIABLE_NON_VOLATILE|EFI_VARIABLE_BOOTSERVICE_ACCESS, \
91 Get an environment variable.
93 This will use the Runtime Services call GetVariable to get a variable.
95 @param EnvVarName The name of the environment variable in question
96 @param BufferSize Pointer to the UINTN size of Buffer
97 @param Buffer Pointer buffer to get variable value into
99 @retval EFI_SUCCESS The variable's value was retrieved sucessfully
100 @retval other An error ocurred
103 #define SHELL_GET_ENVIRONMENT_VARIABLE(EnvVarName,BufferSize,Buffer) \
104 (gRT->GetVariable((CHAR16*)EnvVarName, \
105 &gShellVariableGuid, \
111 Get an environment variable.
113 This will use the Runtime Services call GetVariable to get a variable.
115 @param EnvVarName The name of the environment variable in question
116 @param Atts Pointer to the UINT32 for attributes (or NULL)
117 @param BufferSize Pointer to the UINTN size of Buffer
118 @param Buffer Pointer buffer to get variable value into
120 @retval EFI_SUCCESS The variable's value was retrieved sucessfully
121 @retval other An error ocurred
124 #define SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(EnvVarName,Atts,BufferSize,Buffer) \
125 (gRT->GetVariable((CHAR16*)EnvVarName, \
126 &gShellVariableGuid, \
132 Set a Violatile environment variable.
134 This will use the Runtime Services call SetVariable to set a violatile variable.
136 @param EnvVarName The name of the environment variable in question
137 @param BufferSize UINTN size of Buffer
138 @param Buffer Pointer to value to set variable to
140 @retval EFI_SUCCESS The variable was changed sucessfully
141 @retval other An error ocurred
144 #define SHELL_SET_ENVIRONMENT_VARIABLE_V(EnvVarName,BufferSize,Buffer) \
145 (gRT->SetVariable((CHAR16*)EnvVarName, \
146 &gShellVariableGuid, \
147 EFI_VARIABLE_BOOTSERVICE_ACCESS, \
152 Creates a list of all Shell-Guid-based environment variables.
154 @param[in, out] List The pointer to pointer to LIST_ENTRY object for
157 @retval EFI_SUCCESS the list was created sucessfully.
161 GetEnvironmentVariableList(
162 IN OUT LIST_ENTRY
*List
166 Sets a list of all Shell-Guid-based environment variables. this will
167 also eliminate all pre-existing shell environment variables (even if they
168 are not on the list).
170 This function will also deallocate the memory from List.
172 @param[in] List The pointer to LIST_ENTRY from
173 GetShellEnvVarList().
175 @retval EFI_SUCCESS The list was Set sucessfully.
179 SetEnvironmentVariableList(
184 sets all Shell-Guid-based environment variables. this will
185 also eliminate all pre-existing shell environment variables (even if they
186 are not on the list).
188 @param[in] Environment Points to a NULL-terminated array of environment
189 variables with the format 'x=y', where x is the
190 environment variable name and y is the value.
192 @retval EFI_SUCCESS The command executed successfully.
193 @retval EFI_INVALID_PARAMETER The parameter is invalid.
194 @retval EFI_OUT_OF_RESOURCES Out of resources.
196 @sa SetEnvironmentVariableList
200 SetEnvironmentVariables(
201 IN CONST CHAR16
**Environment
205 free function for ENV_VAR_LIST objects.
207 @param[in] List The pointer to pointer to list.
211 FreeEnvironmentVariableList(
216 Find an environment variable in the gShellEnvVarList.
218 @param Key The name of the environment variable.
219 @param Value The value of the environment variable, the buffer
220 shoule be freed by the caller.
221 @param ValueSize The size in bytes of the environment variable
222 including the tailing CHAR_NULL.
223 @param Atts The attributes of the variable.
225 @retval EFI_SUCCESS The command executed successfully.
226 @retval EFI_NOT_FOUND The environment variable is not found in
231 ShellFindEnvVarInList (
232 IN CONST CHAR16
*Key
,
234 OUT UINTN
*ValueSize
,
235 OUT UINT32
*Atts OPTIONAL
239 Add an environment variable into gShellEnvVarList.
241 @param Key The name of the environment variable.
242 @param Value The value of environment variable.
243 @param ValueSize The size in bytes of the environment variable
244 including the tailing CHAR_NELL
245 @param Atts The attributes of the variable.
249 ShellAddEnvVarToList (
250 IN CONST CHAR16
*Key
,
251 IN CONST CHAR16
*Value
,
257 Remove a specified environment variable in gShellEnvVarList.
259 @param Key The name of the environment variable.
261 @retval EFI_SUCCESS The command executed successfully.
262 @retval EFI_NOT_FOUND The environment variable is not found in
266 ShellRemvoeEnvVarFromList (
271 Initialize the gShellEnvVarList and cache all Shell-Guid-based environment
276 ShellInitEnvVarList (
281 Destructe the gShellEnvVarList.
285 ShellFreeEnvVarList (
289 #endif //_SHELL_ENVIRONMENT_VARIABLE_HEADER_