--- /dev/null
+/** @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