2 Serialize & Deserialize UEFI Variables
4 Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef __SERIALIZE_VARIABLES_LIB__
10 #define __SERIALIZE_VARIABLES_LIB__
13 Callback function for each variable
15 @param[in] Context - Context as sent to the iteration function
16 @param[in] VariableName - Refer to RuntimeServices GetNextVariableName
17 @param[in] VendorGuid - Refer to RuntimeServices GetNextVariableName
18 @param[in] Attributes - Refer to RuntimeServices GetVariable
19 @param[in] DataSize - Refer to RuntimeServices GetVariable
20 @param[in] Data - Refer to RuntimeServices GetVariable
22 @retval RETURN_SUCCESS Continue iterating through the variables
23 @return Any RETURN_ERROR Stop iterating through the variables
28 (EFIAPI
*VARIABLE_SERIALIZATION_ITERATION_CALLBACK
)(
30 IN CHAR16
*VariableName
,
31 IN EFI_GUID
*VendorGuid
,
38 Creates a new variable serialization instance
40 @param[out] Handle - Handle for a variable serialization instance
42 @retval RETURN_SUCCESS - The variable serialization instance was
44 @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to
45 create the variable serialization instance.
50 SerializeVariablesNewInstance (
51 OUT EFI_HANDLE
*Handle
55 Free memory associated with a variable serialization instance
57 @param[in] Handle - Handle for a variable serialization instance
59 @retval RETURN_SUCCESS - The variable serialization instance was
61 @retval RETURN_INVALID_PARAMETER - Handle was not a valid
62 variable serialization instance.
67 SerializeVariablesFreeInstance (
72 Creates a new variable serialization instance using the given
73 binary representation of the variables to fill the new instance
75 @param[out] Handle - Handle for a variable serialization instance
76 @param[in] Buffer - A buffer with the serialized representation
77 of the variables. Must be the same format as produced
78 by SerializeVariablesToBuffer.
79 @param[in] Size - This is the size of the binary representation
82 @retval RETURN_SUCCESS - The binary representation was successfully
83 imported into a new variable serialization instance
84 @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to
85 create the new variable serialization instance
90 SerializeVariablesNewInstanceFromBuffer (
91 OUT EFI_HANDLE
*Handle
,
97 Iterates all variables found with RuntimeServices GetNextVariableName
99 @param[in] CallbackFunction - Function called for each variable instance
100 @param[in] Context - Passed to each call of CallbackFunction
102 @retval RETURN_SUCCESS - All variables were iterated without the
103 CallbackFunction returning an error
104 @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to
105 iterate through the variables
106 @return Any of RETURN_ERROR indicates an error reading the variable
107 or an error was returned from CallbackFunction
112 SerializeVariablesIterateSystemVariables (
113 IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction
,
118 Iterates all variables found in the variable serialization instance
120 @param[in] Handle - Handle for a variable serialization instance
121 @param[in] CallbackFunction - Function called for each variable instance
122 @param[in] Context - Passed to each call of CallbackFunction
124 @retval RETURN_SUCCESS - All variables were iterated without the
125 CallbackFunction returning an error
126 @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to
127 iterate through the variables
128 @return Any of RETURN_ERROR indicates an error reading the variable
129 or an error was returned from CallbackFunction
134 SerializeVariablesIterateInstanceVariables (
135 IN EFI_HANDLE Handle
,
136 IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction
,
141 Sets all variables found in the variable serialization instance
143 @param[in] Handle - Handle for a variable serialization instance
145 @retval RETURN_SUCCESS - All variables were set successfully
146 @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to
147 set all the variables
148 @return Any of RETURN_ERROR indicates an error reading the variables
149 or in attempting to set a variable
154 SerializeVariablesSetSerializedVariables (
159 Adds a variable to the variable serialization instance
161 @param[in] Handle - Handle for a variable serialization instance
162 @param[in] VariableName - Refer to RuntimeServices GetVariable
163 @param[in] VendorGuid - Refer to RuntimeServices GetVariable
164 @param[in] Attributes - Refer to RuntimeServices GetVariable
165 @param[in] DataSize - Refer to RuntimeServices GetVariable
166 @param[in] Data - Refer to RuntimeServices GetVariable
168 @retval RETURN_SUCCESS - All variables were set successfully
169 @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to
175 SerializeVariablesAddVariable (
176 IN EFI_HANDLE Handle
,
177 IN CHAR16
*VariableName
,
178 IN EFI_GUID
*VendorGuid
,
179 IN UINT32 Attributes
,
185 Serializes the variables known to this instance into the
188 @param[in] Handle - Handle for a variable serialization instance
189 @param[out] Buffer - A buffer to store the binary representation
191 @param[in,out] Size - On input this is the size of the buffer.
192 On output this is the size of the binary representation
195 @retval RETURN_SUCCESS - The binary representation was successfully
196 completed and returned in the buffer.
197 @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to
198 save the variables to the buffer.
199 @retval RETURN_INVALID_PARAMETER - Handle was not a valid
200 variable serialization instance or
201 Size or Buffer were NULL.
206 SerializeVariablesToBuffer (
207 IN EFI_HANDLE Handle
,