//#include <Library/UefiRuntimeServicesTableLib.h>\r
\r
\r
- Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
- This program and the accompanying materials\r
- are licensed and made available under the terms and conditions of the BSD License\r
- which accompanies this distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+ Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
UINT32 Atts;\r
} ENV_VAR_LIST;\r
\r
-/**\r
- Reports whether an environment variable is Volatile or Non-Volatile\r
+//\r
+// The list is used to cache the environment variables.\r
+//\r
+extern ENV_VAR_LIST gShellEnvVarList;\r
+\r
\r
- This will use the Runtime Services call GetVariable to to search for the variable.\r
+/**\r
+ Reports whether an environment variable is Volatile or Non-Volatile.\r
\r
@param EnvVarName The name of the environment variable in question\r
+ @param Volatile Return TRUE if the environment variable is volatile\r
\r
- @retval TRUE This environment variable is Volatile\r
- @retval FALSE This environment variable is NON-Volatile\r
+ @retval EFI_SUCCESS The volatile attribute is returned successfully\r
+ @retval others Some errors happened.\r
**/\r
-BOOLEAN\r
-EFIAPI\r
+EFI_STATUS\r
IsVolatileEnv (\r
- IN CONST CHAR16 *EnvVarName\r
+ IN CONST CHAR16 *EnvVarName,\r
+ OUT BOOLEAN *Volatile\r
);\r
\r
/**\r
- Delete a Non-Violatile environment variable.\r
+ Delete a Non-Volatile environment variable.\r
\r
- This will use the Runtime Services call SetVariable to remove a non-violatile variable.\r
+ This will use the Runtime Services call SetVariable to remove a non-volatile variable.\r
\r
@param EnvVarName The name of the environment variable in question\r
\r
- @retval EFI_SUCCESS The variable was deleted sucessfully\r
- @retval other An error ocurred\r
+ @retval EFI_SUCCESS The variable was deleted successfully\r
+ @retval other An error occurred\r
@sa SetVariable\r
**/\r
#define SHELL_DELETE_ENVIRONMENT_VARIABLE(EnvVarName) \\r
NULL))\r
\r
/**\r
- Set a Non-Violatile environment variable.\r
+ Set a Non-Volatile environment variable.\r
\r
- This will use the Runtime Services call SetVariable to set a non-violatile variable.\r
+ This will use the Runtime Services call SetVariable to set a non-volatile variable.\r
\r
@param EnvVarName The name of the environment variable in question\r
@param BufferSize UINTN size of Buffer\r
@param Buffer Pointer to value to set variable to\r
\r
- @retval EFI_SUCCESS The variable was changed sucessfully\r
- @retval other An error ocurred\r
+ @retval EFI_SUCCESS The variable was changed successfully\r
+ @retval other An error occurred\r
@sa SetVariable\r
**/\r
#define SHELL_SET_ENVIRONMENT_VARIABLE_NV(EnvVarName,BufferSize,Buffer) \\r
@param BufferSize Pointer to the UINTN size of Buffer\r
@param Buffer Pointer buffer to get variable value into\r
\r
- @retval EFI_SUCCESS The variable's value was retrieved sucessfully\r
- @retval other An error ocurred\r
+ @retval EFI_SUCCESS The variable's value was retrieved successfully\r
+ @retval other An error occurred\r
@sa SetVariable\r
**/\r
#define SHELL_GET_ENVIRONMENT_VARIABLE(EnvVarName,BufferSize,Buffer) \\r
@param BufferSize Pointer to the UINTN size of Buffer\r
@param Buffer Pointer buffer to get variable value into\r
\r
- @retval EFI_SUCCESS The variable's value was retrieved sucessfully\r
- @retval other An error ocurred\r
+ @retval EFI_SUCCESS The variable's value was retrieved successfully\r
+ @retval other An error occurred\r
@sa SetVariable\r
**/\r
#define SHELL_GET_ENVIRONMENT_VARIABLE_AND_ATTRIBUTES(EnvVarName,Atts,BufferSize,Buffer) \\r
Buffer))\r
\r
/**\r
- Set a Violatile environment variable.\r
+ Set a Volatile environment variable.\r
\r
- This will use the Runtime Services call SetVariable to set a violatile variable.\r
+ This will use the Runtime Services call SetVariable to set a volatile variable.\r
\r
@param EnvVarName The name of the environment variable in question\r
@param BufferSize UINTN size of Buffer\r
@param Buffer Pointer to value to set variable to\r
\r
- @retval EFI_SUCCESS The variable was changed sucessfully\r
- @retval other An error ocurred\r
+ @retval EFI_SUCCESS The variable was changed successfully\r
+ @retval other An error occurred\r
@sa SetVariable\r
**/\r
#define SHELL_SET_ENVIRONMENT_VARIABLE_V(EnvVarName,BufferSize,Buffer) \\r
/**\r
Creates a list of all Shell-Guid-based environment variables.\r
\r
- @param[in,out] List The pointer to pointer to LIST_ENTRY object for\r
- storing this list.\r
+ @param[in, out] List The pointer to pointer to LIST_ENTRY object for\r
+ storing this list.\r
\r
- @retval EFI_SUCCESS the list was created sucessfully.\r
+ @retval EFI_SUCCESS the list was created successfully.\r
**/\r
EFI_STATUS\r
-EFIAPI\r
GetEnvironmentVariableList(\r
IN OUT LIST_ENTRY *List\r
);\r
@param[in] List The pointer to LIST_ENTRY from\r
GetShellEnvVarList().\r
\r
- @retval EFI_SUCCESS The list was Set sucessfully.\r
+ @retval EFI_SUCCESS The list was Set successfully.\r
**/\r
EFI_STATUS\r
-EFIAPI\r
SetEnvironmentVariableList(\r
IN LIST_ENTRY *List\r
);\r
@sa SetEnvironmentVariableList\r
**/\r
EFI_STATUS\r
-EFIAPI\r
SetEnvironmentVariables(\r
IN CONST CHAR16 **Environment\r
);\r
@param[in] List The pointer to pointer to list.\r
**/\r
VOID\r
-EFIAPI\r
FreeEnvironmentVariableList(\r
IN LIST_ENTRY *List\r
);\r
\r
+/**\r
+ Find an environment variable in the gShellEnvVarList.\r
+\r
+ @param Key The name of the environment variable.\r
+ @param Value The value of the environment variable, the buffer\r
+ shoule be freed by the caller.\r
+ @param ValueSize The size in bytes of the environment variable\r
+ including the tailing CHAR_NULL.\r
+ @param Atts The attributes of the variable.\r
+\r
+ @retval EFI_SUCCESS The command executed successfully.\r
+ @retval EFI_NOT_FOUND The environment variable is not found in\r
+ gShellEnvVarList.\r
+\r
+**/\r
+EFI_STATUS\r
+ShellFindEnvVarInList (\r
+ IN CONST CHAR16 *Key,\r
+ OUT CHAR16 **Value,\r
+ OUT UINTN *ValueSize,\r
+ OUT UINT32 *Atts OPTIONAL\r
+ );\r
+\r
+/**\r
+ Add an environment variable into gShellEnvVarList.\r
+\r
+ @param Key The name of the environment variable.\r
+ @param Value The value of environment variable.\r
+ @param ValueSize The size in bytes of the environment variable\r
+ including the tailing CHAR_NULL\r
+ @param Atts The attributes of the variable.\r
+\r
+ @retval EFI_SUCCESS The environment variable was added to list successfully.\r
+ @retval others Some errors happened.\r
+\r
+**/\r
+EFI_STATUS\r
+ShellAddEnvVarToList (\r
+ IN CONST CHAR16 *Key,\r
+ IN CONST CHAR16 *Value,\r
+ IN UINTN ValueSize,\r
+ IN UINT32 Atts\r
+ );\r
+\r
+/**\r
+ Remove a specified environment variable in gShellEnvVarList.\r
+\r
+ @param Key The name of the environment variable.\r
+\r
+ @retval EFI_SUCCESS The command executed successfully.\r
+ @retval EFI_NOT_FOUND The environment variable is not found in\r
+ gShellEnvVarList.\r
+**/\r
+EFI_STATUS\r
+ShellRemvoeEnvVarFromList (\r
+ IN CONST CHAR16 *Key\r
+ );\r
+\r
+/**\r
+ Initialize the gShellEnvVarList and cache all Shell-Guid-based environment\r
+ variables.\r
+\r
+**/\r
+EFI_STATUS\r
+ShellInitEnvVarList (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Destructe the gShellEnvVarList.\r
+\r
+**/\r
+VOID\r
+ShellFreeEnvVarList (\r
+ VOID\r
+ );\r
+\r
#endif //_SHELL_ENVIRONMENT_VARIABLE_HEADER_\r
\r