]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg: Add SerializeVariablesLib library class
authorjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 30 Jan 2011 19:49:37 +0000 (19:49 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 30 Jan 2011 19:49:37 +0000 (19:49 +0000)
This library provides an interface for converting the system
variables into a binary and also restoring the system variables
from that binary.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11284 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/Include/Library/SerializeVariablesLib.h [new file with mode: 0644]
OvmfPkg/OvmfPkg.dec

diff --git a/OvmfPkg/Include/Library/SerializeVariablesLib.h b/OvmfPkg/Include/Library/SerializeVariablesLib.h
new file mode 100644 (file)
index 0000000..c9feeb0
--- /dev/null
@@ -0,0 +1,229 @@
+/** @file\r
+  Serialize & Deserialize UEFI Variables\r
+\r
+  Copyright (c) 2011, 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
+\r
+**/\r
+\r
+#ifndef __SERIALIZE_VARIABLES_LIB__\r
+#define __SERIALIZE_VARIABLES_LIB__\r
+\r
+\r
+/**\r
+  Callback function for each variable\r
+\r
+  @param[in] Context - Context as sent to the iteration function\r
+  @param[in] VariableName - Refer to RuntimeServices GetNextVariableName\r
+  @param[in] VendorGuid - Refer to RuntimeServices GetNextVariableName\r
+  @param[in] Attributes - Refer to RuntimeServices GetVariable\r
+  @param[in] DataSize - Refer to RuntimeServices GetVariable\r
+  @param[in] Data - Refer to RuntimeServices GetVariable\r
+\r
+  @retval RETURN_SUCCESS         Continue iterating through the variables\r
+  @return Any RETURN_ERROR       Stop iterating through the variables\r
+\r
+**/\r
+typedef\r
+RETURN_STATUS\r
+(EFIAPI *VARIABLE_SERIALIZATION_ITERATION_CALLBACK)(\r
+  IN  VOID                         *Context,\r
+  IN  CHAR16                       *VariableName,\r
+  IN  EFI_GUID                     *VendorGuid,\r
+  IN  UINT32                       Attributes,\r
+  IN  UINTN                        DataSize,\r
+  IN  VOID                         *Data\r
+  );\r
+\r
+\r
+/**\r
+  Creates a new variable serialization instance\r
+\r
+  @param[out]  Handle - Handle for a variable serialization instance\r
+\r
+  @retval      RETURN_SUCCESS - The variable serialization instance was\r
+                 successfully created.\r
+  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources to\r
+                 create the variable serialization instance.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+SerializeVariablesNewInstance (\r
+  OUT EFI_HANDLE                      *Handle\r
+  );\r
+\r
+\r
+/**\r
+  Free memory associated with a variable serialization instance\r
+\r
+  @param[in]  Handle - Handle for a variable serialization instance\r
+\r
+  @retval      RETURN_SUCCESS - The variable serialization instance was\r
+                 successfully freed.\r
+  @retval      RETURN_INVALID_PARAMETER - Handle was not a valid\r
+                 variable serialization instance.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+SerializeVariablesFreeInstance (\r
+  IN EFI_HANDLE Handle\r
+  );\r
+\r
+\r
+/**\r
+  Creates a new variable serialization instance using the given\r
+  binary representation of the variables to fill the new instance\r
+\r
+  @param[out] Handle - Handle for a variable serialization instance\r
+  @param[in]  Buffer - A buffer with the serialized representation\r
+                of the variables.  Must be the same format as produced\r
+                by SerializeVariablesToBuffer.\r
+  @param[in]  Size - This is the size of the binary representation\r
+                of the variables.\r
+\r
+  @retval      RETURN_SUCCESS - The binary representation was successfully\r
+                 imported into a new variable serialization instance\r
+  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources to\r
+                 create the new variable serialization instance\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+SerializeVariablesNewInstanceFromBuffer (\r
+  OUT EFI_HANDLE                          *Handle,\r
+  IN  VOID                                *Buffer,\r
+  IN  UINTN                               Size\r
+  );\r
+\r
+\r
+/**\r
+  Iterates all variables found with RuntimeServices GetNextVariableName\r
+\r
+  @param[in]   CallbackFunction - Function called for each variable instance\r
+  @param[in]   Context - Passed to each call of CallbackFunction\r
+\r
+  @retval      RETURN_SUCCESS - All variables were iterated without the\r
+                 CallbackFunction returning an error\r
+  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources to\r
+                 iterate through the variables\r
+  @return      Any of RETURN_ERROR indicates an error reading the variable\r
+                 or an error was returned from CallbackFunction\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+SerializeVariablesIterateSystemVariables (\r
+  IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,\r
+  IN VOID                                      *Context\r
+  );\r
+\r
+\r
+/**\r
+  Iterates all variables found in the variable serialization instance\r
+\r
+  @param[in]   Handle - Handle for a variable serialization instance\r
+  @param[in]   CallbackFunction - Function called for each variable instance\r
+  @param[in]   Context - Passed to each call of CallbackFunction\r
+\r
+  @retval      RETURN_SUCCESS - All variables were iterated without the\r
+                 CallbackFunction returning an error\r
+  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources to\r
+                 iterate through the variables\r
+  @return      Any of RETURN_ERROR indicates an error reading the variable\r
+                 or an error was returned from CallbackFunction\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+SerializeVariablesIterateInstanceVariables (\r
+  IN EFI_HANDLE                                Handle,\r
+  IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,\r
+  IN VOID                                      *Context\r
+  );\r
+\r
+\r
+/**\r
+  Sets all variables found in the variable serialization instance\r
+\r
+  @param[in]   Handle - Handle for a variable serialization instance\r
+\r
+  @retval      RETURN_SUCCESS - All variables were set successfully\r
+  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources to\r
+                 set all the variables\r
+  @return      Any of RETURN_ERROR indicates an error reading the variables\r
+                 or in attempting to set a variable\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+SerializeVariablesSetSerializedVariables (\r
+  IN EFI_HANDLE                       Handle\r
+  );\r
+\r
+\r
+/**\r
+  Adds a variable to the variable serialization instance\r
+\r
+  @param[in] Handle - Handle for a variable serialization instance\r
+  @param[in] VariableName - Refer to RuntimeServices GetVariable\r
+  @param[in] VendorGuid - Refer to RuntimeServices GetVariable\r
+  @param[in] Attributes - Refer to RuntimeServices GetVariable\r
+  @param[in] DataSize - Refer to RuntimeServices GetVariable\r
+  @param[in] Data - Refer to RuntimeServices GetVariable\r
+\r
+  @retval      RETURN_SUCCESS - All variables were set successfully\r
+  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources to\r
+                 add the variable\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+SerializeVariablesAddVariable (\r
+  IN EFI_HANDLE                   Handle,\r
+  IN CHAR16                       *VariableName,\r
+  IN EFI_GUID                     *VendorGuid,\r
+  IN UINT32                       Attributes,\r
+  IN UINTN                        DataSize,\r
+  IN VOID                         *Data\r
+  );\r
+\r
+\r
+/**\r
+  Serializes the variables known to this instance into the\r
+  provided buffer.\r
+\r
+  @param[in]     Handle - Handle for a variable serialization instance\r
+  @param[out]    Buffer - A buffer to store the binary representation\r
+                   of the variables.\r
+  @param[in,out] Size - On input this is the size of the buffer.\r
+                   On output this is the size of the binary representation\r
+                   of the variables.\r
+\r
+  @retval      RETURN_SUCCESS - The binary representation was successfully\r
+                 completed and returned in the buffer.\r
+  @retval      RETURN_OUT_OF_RESOURCES - There we not enough resources to\r
+                 save the variables to the buffer.\r
+  @retval      RETURN_INVALID_PARAMETER - Handle was not a valid\r
+                 variable serialization instance or\r
+                 Size or Buffer were NULL.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+SerializeVariablesToBuffer (\r
+  IN     EFI_HANDLE                       Handle,\r
+  OUT    VOID                             *Buffer,\r
+  IN OUT UINTN                            *Size\r
+  );\r
+\r
+\r
+#endif\r
+\r
index 743bd1ed1cb4d39a0a3ac5db7b714ae5185bdc08..a42bd9daeac6a2ddf32b58fb742a043b9f4481e5 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #  EFI/Framework Open Virtual Machine Firmware (OVMF) platform\r
 #\r
-#  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -40,3 +40,7 @@
   #\r
   NvVarsFileLib|Include/Library/NvVarsFileLib.h\r
 \r
+  ##  @libraryclass  Serialize (and deserialize) variables\r
+  #\r
+  SerializeVariablesLib|Include/Library/SerializeVariablesLib.h\r
+\r