]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrVariable.c
Retire framework IfrSupportLib and HiiLib, which will be replaced by new designed...
[mirror_edk2.git] / IntelFrameworkPkg / Library / FrameworkIfrSupportLib / IfrVariable.c
diff --git a/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrVariable.c b/IntelFrameworkPkg/Library/FrameworkIfrSupportLib/IfrVariable.c
deleted file mode 100644 (file)
index 44b5357..0000000
+++ /dev/null
@@ -1,428 +0,0 @@
-/** @file\r
-  Variable/Map manipulations routines\r
-  \r
-Copyright (c) 2006, Intel Corporation                                                         \r
-All rights reserved. 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
-\r
-**/\r
-\r
-#include "IfrSupportLibInternal.h"\r
-\r
-/**\r
-  Extracts a variable form a Pack.\r
-\r
-  @param  Pack              List of variables\r
-  @param  Name              Name of the variable/map\r
-  @param  Guid              GUID of the variable/map\r
-  @param  Id                The index of the variable/map to retrieve\r
-  @param  Var               Pointer to the variable/map\r
-  @param  Size              Size of the variable/map in bytes\r
-**/\r
-VOID\r
-EFIAPI\r
-EfiLibHiiVariablePackGetMap (\r
-  IN      EFI_HII_VARIABLE_PACK     *Pack,  \r
-     OUT  CHAR16                    **Name, OPTIONAL\r
-     OUT  EFI_GUID                  **Guid, OPTIONAL\r
-     OUT  UINT16                    *Id,    OPTIONAL\r
-     OUT  VOID                      **Var,  OPTIONAL\r
-     OUT  UINTN                     *Size   OPTIONAL\r
-  )\r
-{\r
-  if (NULL != Name) {\r
-    *Name = (VOID *) (Pack + 1);\r
-  }\r
-    \r
-  if (NULL != Guid) { \r
-    *Guid = (EFI_GUID *)(UINTN)&Pack->VariableGuid;\r
-  }\r
-    \r
-    \r
-  if (NULL != Id) {\r
-    *Id   = Pack->VariableId;\r
-  }\r
-    \r
-  if (NULL != Var) {\r
-    *Var  = (VOID *) ((CHAR8 *) (Pack + 1) + Pack->VariableNameLength);\r
-  }\r
-    \r
-  if (NULL != Size) {\r
-    *Size = Pack->Header.Length - sizeof (*Pack) - Pack->VariableNameLength;\r
-  }\r
-}\r
-\r
-/**\r
-  Finds a count of the variables/maps in the List.\r
-\r
-  @param  List              List of variables\r
-\r
-  @return                   The number of map count.\r
-**/\r
-UINTN\r
-EFIAPI\r
-EfiLibHiiVariablePackListGetMapCnt (\r
-  IN  EFI_HII_VARIABLE_PACK_LIST    *List\r
-  )\r
-{\r
-  UINTN                             Cnt;\r
-  \r
-  Cnt = 0;\r
-  while (NULL != List) {\r
-    Cnt++;\r
-    List = List->NextVariablePack;\r
-  }\r
-  return Cnt;\r
-}\r
-\r
-/**\r
-  Will iterate all variable/maps as appearing \r
-  in List and for each, it will call the Callback.\r
-\r
-  @param  List              List of variables\r
-  @param  Callback          Routine to be called for each iterated variable.\r
-**/\r
-VOID\r
-EFIAPI\r
-EfiLibHiiVariablePackListForEachVar (\r
-  IN  EFI_HII_VARIABLE_PACK_LIST               *List,\r
-  IN  EFI_LIB_HII_VARIABLE_PACK_LIST_CALLBACK  *Callback\r
-  )\r
-{\r
-  CHAR16                            *MapName;\r
-  EFI_GUID                          *MapGuid;\r
-  UINT16                            MapId;\r
-  VOID                              *Map;\r
-  UINTN                             MapSize;\r
-\r
-  while (NULL != List) {\r
-    EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize);\r
-    //\r
-    // call the callback\r
-    //\r
-    Callback (MapName, MapGuid, MapId, Map, MapSize); \r
-    List = List->NextVariablePack;\r
-  }\r
-}\r
-\r
-/**\r
-  Finds a variable form List given \r
-  the order number as appears in the List.\r
-\r
-  @param  Idx            The index of the variable/map to retrieve\r
-  @param  List           List of variables\r
-  @param  Name           Name of the variable/map\r
-  @param  Guid           GUID of the variable/map\r
-  @param  Id             Id of the variable/map\r
-  @param  Var            Pointer to the variable/map\r
-  @param  Size           Size of the variable/map in bytes\r
-\r
-  @return EFI_SUCCESS    Variable is found, OUT parameters are valid\r
-  @return EFI_NOT_FOUND  Variable is not found, OUT parameters are not valid\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EfiLibHiiVariablePackListGetMapByIdx (\r
-  IN      UINTN                      Idx,  \r
-  IN      EFI_HII_VARIABLE_PACK_LIST *List,  \r
-     OUT  CHAR16                     **Name, OPTIONAL\r
-     OUT  EFI_GUID                   **Guid, OPTIONAL\r
-     OUT  UINT16                     *Id,    OPTIONAL\r
-     OUT  VOID                       **Var,\r
-     OUT  UINTN                      *Size\r
-  )\r
-{\r
-  CHAR16                            *MapName;\r
-  EFI_GUID                          *MapGuid;\r
-  UINT16                            MapId;\r
-  VOID                              *Map;\r
-  UINTN                             MapSize;\r
-\r
-  while (NULL != List) {\r
-    EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize);\r
-    if (0 == Idx--) {\r
-      *Var  = Map;\r
-      *Size = MapSize;\r
-\r
-      if (NULL != Name) {\r
-        *Name = MapName;\r
-      }\r
-\r
-      if (NULL != Guid) {\r
-        *Guid = MapGuid;\r
-      }\r
-        \r
-      if (NULL != Id) {\r
-        *Id   = MapId;\r
-      }\r
-      //\r
-      // Map found\r
-      //\r
-      return EFI_SUCCESS;\r
-    }\r
-    List = List->NextVariablePack;\r
-  }\r
-  //\r
-  // If here, the map is not found\r
-  //\r
-  return EFI_NOT_FOUND; \r
-}\r
-\r
-/**\r
-  Finds a variable form List given the \r
-  order number as appears in the List.\r
-\r
-  @param  Id             The ID of the variable/map to retrieve\r
-  @param  List           List of variables\r
-  @param  Name           Name of the variable/map\r
-  @param  Guid           GUID of the variable/map\r
-  @param  Var            Pointer to the variable/map\r
-  @param  Size           Size of the variable/map in bytes\r
-\r
-  @retval EFI_SUCCESS    Variable is found, OUT parameters are valid\r
-  @retval EFI_NOT_FOUND  Variable is not found, OUT parameters are not valid\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EfiLibHiiVariablePackListGetMapById (\r
-  IN      UINT16                     Id,  \r
-  IN      EFI_HII_VARIABLE_PACK_LIST *List,\r
-     OUT  CHAR16                     **Name, OPTIONAL\r
-     OUT  EFI_GUID                   **Guid, OPTIONAL\r
-     OUT  VOID                       **Var,\r
-     OUT  UINTN                      *Size\r
-  )\r
-{ \r
-  CHAR16                            *MapName;\r
-  EFI_GUID                          *MapGuid;\r
-  UINT16                            MapId;\r
-  VOID                              *Map;\r
-  UINTN                             MapSize;\r
-\r
-  while (NULL != List) {\r
-    EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize);\r
-    if (MapId == Id) {\r
-      *Var  = Map;\r
-      *Size = MapSize;\r
-      if (NULL != Name) {\r
-         *Name = MapName;\r
-      }\r
-      if (NULL != Guid) {\r
-        *Guid = MapGuid;\r
-      }\r
-      //\r
-      // Map found\r
-      //\r
-      return EFI_SUCCESS; \r
-    }\r
-    List = List->NextVariablePack;\r
-  }\r
-  //\r
-  // If here, the map is not found\r
-  //\r
-  return EFI_NOT_FOUND; \r
-}\r
-\r
-/**\r
-  Finds a variable form EFI_HII_VARIABLE_PACK_LIST given name and GUID.\r
-\r
-  @param  List           List of variables\r
-  @param  Name           Name of the variable/map to be found\r
-  @param  Guid           GUID of the variable/map to be found\r
-  @param  Id             Id of the variable/map to be found\r
-  @param  Var            Pointer to the variable/map found\r
-  @param  Size           Size of the variable/map in bytes found\r
-\r
-  @retval EFI_SUCCESS    variable is found, OUT parameters are valid\r
-  @retval EFI_NOT_FOUND  variable is not found, OUT parameters are not valid\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EfiLibHiiVariablePackListGetMap (\r
-  IN      EFI_HII_VARIABLE_PACK_LIST *List,\r
-  IN      CHAR16                     *Name,\r
-  IN      EFI_GUID                   *Guid,\r
-     OUT  UINT16                     *Id,\r
-     OUT  VOID                       **Var, \r
-     OUT  UINTN                      *Size\r
-  )\r
-{ \r
-  VOID                              *Map;\r
-  UINTN                             MapSize;\r
-  UINT16                            MapId;\r
-  CHAR16                            *MapName;\r
-  EFI_GUID                          *MapGuid;\r
-\r
-  while (NULL != List) {\r
-    EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize);\r
-    if ((0 == StrCmp (Name, MapName)) && CompareGuid (Guid, MapGuid)) {\r
-      *Id   = MapId;\r
-      *Var  = Map;\r
-      *Size = MapSize;\r
-      return EFI_SUCCESS;\r
-    }\r
-    List = List->NextVariablePack;\r
-  }\r
-  //\r
-  // If here, the map is not found\r
-  //\r
-  return EFI_NOT_FOUND;\r
-}\r
-\r
-/**\r
-  Finds out if a variable of specific Name/Guid/Size exists in NV. \r
-  If it does, it will retrieve it into the Var. \r
-\r
-  @param  Name            Parameters of the variable to retrieve. Must match exactly.\r
-  @param  Guid            Parameters of the variable to retrieve. Must match exactly.\r
-  @param  Size            Parameters of the variable to retrieve. Must match exactly.\r
-  @param  Var             Variable will be retrieved into buffer pointed by this pointer.\r
-                          If pointing to NULL, the buffer will be allocated. \r
-                          Caller is responsible for releasing the buffer.\r
-\r
-  @retval EFI_SUCCESS     The variable of exact Name/Guid/Size parameters was retrieved and written to Var.\r
-  @retval EFI_NOT_FOUND   The variable of this Name/Guid was not found in the NV.\r
-  @retval EFI_LOAD_ERROR  The variable in the NV was of different size, or NV API returned error.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EfiLibHiiVariableRetrieveFromNv (\r
-  IN      CHAR16                    *Name,\r
-  IN      EFI_GUID                  *Guid,\r
-  IN      UINTN                     Size,\r
-     OUT  VOID                      **Var\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  UINTN                             SizeNv;\r
-\r
-  //\r
-  // Test for existence of the variable.\r
-  //\r
-  SizeNv = 0;\r
-  Status = gRT->GetVariable (Name, Guid, NULL, &SizeNv, NULL);\r
-  if (EFI_BUFFER_TOO_SMALL != Status) {\r
-    ASSERT (EFI_SUCCESS != Status);\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  if (SizeNv != Size) {\r
-    //\r
-    // The variable is considered corrupt, as it has different size from expected.\r
-    //\r
-    return EFI_LOAD_ERROR; \r
-  }\r
-\r
-  if (NULL == *Var) {\r
-    *Var = AllocatePool (Size);\r
-    ASSERT (NULL != *Var);\r
-  }\r
-  SizeNv = Size;\r
-  //\r
-  // Final read into the Var\r
-  //\r
-  Status = gRT->GetVariable (Name, Guid, NULL, &SizeNv, *Var); \r
-  //\r
-  // No tolerance for random failures. Such behavior is undetermined and not validated.\r
-  //\r
-  ASSERT_EFI_ERROR (Status); \r
-  ASSERT (SizeNv == Size);\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-/**\r
-  Overrrides the variable with NV data if found.\r
-  But it only does it if the Name ends with specified Suffix.\r
-  For example, if Suffix="MyOverride" and the Name="XyzSetupMyOverride",\r
-  the Suffix matches the end of Name, so the variable will be loaded from NV\r
-  provided the variable exists and the GUID and Size matches.\r
-\r
-  @param  Suffix            Suffix the Name should end with.\r
-  @param  Name              Name of the variable to retrieve.\r
-  @param  Guid              Guid of the variable to retrieve.\r
-  @param  Size              Parameters of the variable to retrieve.\r
-  @param  Var               Variable will be retrieved into this buffer.\r
-                            Caller is responsible for providing storage of exactly Size size in bytes.\r
-\r
-  @retval EFI_SUCCESS           The variable was overriden with NV variable of same Name/Guid/Size.\r
-  @retval EFI_INVALID_PARAMETER The name of the variable does not end with <Suffix>.\r
-  @retval EFI_NOT_FOUND         The variable of this Name/Guid was not found in the NV.\r
-  @retval EFI_LOAD_ERROR        The variable in the NV was of different size, or NV API returned error.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EfiLibHiiVariableOverrideIfSuffix (\r
-  IN      CHAR16                    *Suffix,\r
-  IN      CHAR16                    *Name,\r
-  IN      EFI_GUID                  *Guid,\r
-  IN      UINTN                     Size,\r
-     OUT  VOID                      *Var\r
-  )  \r
-{\r
-  UINTN                             StrLength;\r
-  UINTN                             StrLenSuffix;\r
-\r
-  StrLength       = StrLen (Name);\r
-  StrLenSuffix    = StrLen (Suffix);\r
-  if ((StrLength <= StrLenSuffix) || (0 != StrCmp (Suffix, &Name[StrLength - StrLenSuffix]))) {\r
-    //\r
-    // Not ending with <Suffix>.\r
-    //\r
-    return EFI_INVALID_PARAMETER; \r
-  }\r
-  return EfiLibHiiVariableRetrieveFromNv (Name, Guid, Size, &Var);\r
-}\r
-\r
-/**\r
-  Overrrides the variable with NV data if found.\r
-  But it only does it if the NV contains the same variable with Name is appended with Suffix.  \r
-  For example, if Suffix="MyOverride" and the Name="XyzSetup",\r
-  the Suffix will be appended to the end of Name, and the variable with Name="XyzSetupMyOverride"\r
-  will be loaded from NV provided the variable exists and the GUID and Size matches.\r
-\r
-  @param  Suffix          Suffix the variable will be appended with.\r
-  @param  Name            Parameters of the Name variable to retrieve.\r
-  @param  Guid            Parameters of the Guid variable to retrieve.\r
-  @param  Size            Parameters of the Size variable to retrieve.\r
-  @param  Var             Variable will be retrieved into this buffer.\r
-                          Caller is responsible for providing storage of exactly Size size in bytes.\r
-\r
-  @retval EFI_SUCCESS     The variable was overriden with NV variable of same Name/Guid/Size.\r
-  @retval EFI_NOT_FOUND   The variable of this Name/Guid was not found in the NV.\r
-  @retval EFI_LOAD_ERROR  The variable in the NV was of different size, or NV API returned error.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-EfiLibHiiVariableOverrideBySuffix (\r
-  IN      CHAR16                    *Suffix,\r
-  IN      CHAR16                    *Name,\r
-  IN      EFI_GUID                  *Guid,\r
-  IN      UINTN                     Size,\r
-     OUT  VOID                      *Var\r
-  )\r
-{\r
-  EFI_STATUS                        Status;\r
-  CHAR16                            *NameSuffixed;\r
-  UINTN                             NameLength;\r
-  UINTN                             SuffixLength;\r
-\r
-  //\r
-  // enough to concatenate both strings.\r
-  //\r
-  NameLength   = StrLen (Name);\r
-  SuffixLength = StrLen (Suffix);\r
-  NameSuffixed = AllocateZeroPool ((NameLength + SuffixLength + 1) * sizeof (CHAR16)); \r
-  \r
-  StrCpy (NameSuffixed, Name);\r
-  StrCat (NameSuffixed, Suffix);\r
-  \r
-  Status = EfiLibHiiVariableRetrieveFromNv (NameSuffixed, Guid, Size, &Var);\r
-  FreePool (NameSuffixed);\r
-  \r
-  return Status;\r
-}\r
-\r