]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Include/Library/SerializeVariablesLib.h
OvmfPkg/MemEncryptSevLib: find pages of initial SMRAM save state map
[mirror_edk2.git] / OvmfPkg / Include / Library / SerializeVariablesLib.h
CommitLineData
e79f62f0 1/** @file\r
2 Serialize & Deserialize UEFI Variables\r
3\r
4 Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef __SERIALIZE_VARIABLES_LIB__\r
16#define __SERIALIZE_VARIABLES_LIB__\r
17\r
18\r
19/**\r
20 Callback function for each variable\r
21\r
22 @param[in] Context - Context as sent to the iteration function\r
23 @param[in] VariableName - Refer to RuntimeServices GetNextVariableName\r
24 @param[in] VendorGuid - Refer to RuntimeServices GetNextVariableName\r
25 @param[in] Attributes - Refer to RuntimeServices GetVariable\r
26 @param[in] DataSize - Refer to RuntimeServices GetVariable\r
27 @param[in] Data - Refer to RuntimeServices GetVariable\r
28\r
29 @retval RETURN_SUCCESS Continue iterating through the variables\r
30 @return Any RETURN_ERROR Stop iterating through the variables\r
31\r
32**/\r
33typedef\r
34RETURN_STATUS\r
35(EFIAPI *VARIABLE_SERIALIZATION_ITERATION_CALLBACK)(\r
36 IN VOID *Context,\r
37 IN CHAR16 *VariableName,\r
38 IN EFI_GUID *VendorGuid,\r
39 IN UINT32 Attributes,\r
40 IN UINTN DataSize,\r
41 IN VOID *Data\r
42 );\r
43\r
44\r
45/**\r
46 Creates a new variable serialization instance\r
47\r
48 @param[out] Handle - Handle for a variable serialization instance\r
49\r
50 @retval RETURN_SUCCESS - The variable serialization instance was\r
51 successfully created.\r
52 @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to\r
53 create the variable serialization instance.\r
54\r
55**/\r
56RETURN_STATUS\r
57EFIAPI\r
58SerializeVariablesNewInstance (\r
59 OUT EFI_HANDLE *Handle\r
60 );\r
61\r
62\r
63/**\r
64 Free memory associated with a variable serialization instance\r
65\r
66 @param[in] Handle - Handle for a variable serialization instance\r
67\r
68 @retval RETURN_SUCCESS - The variable serialization instance was\r
69 successfully freed.\r
70 @retval RETURN_INVALID_PARAMETER - Handle was not a valid\r
71 variable serialization instance.\r
72\r
73**/\r
74RETURN_STATUS\r
75EFIAPI\r
76SerializeVariablesFreeInstance (\r
77 IN EFI_HANDLE Handle\r
78 );\r
79\r
80\r
81/**\r
82 Creates a new variable serialization instance using the given\r
83 binary representation of the variables to fill the new instance\r
84\r
85 @param[out] Handle - Handle for a variable serialization instance\r
86 @param[in] Buffer - A buffer with the serialized representation\r
87 of the variables. Must be the same format as produced\r
88 by SerializeVariablesToBuffer.\r
89 @param[in] Size - This is the size of the binary representation\r
90 of the variables.\r
91\r
92 @retval RETURN_SUCCESS - The binary representation was successfully\r
93 imported into a new variable serialization instance\r
94 @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to\r
95 create the new variable serialization instance\r
96\r
97**/\r
98RETURN_STATUS\r
99EFIAPI\r
100SerializeVariablesNewInstanceFromBuffer (\r
101 OUT EFI_HANDLE *Handle,\r
102 IN VOID *Buffer,\r
103 IN UINTN Size\r
104 );\r
105\r
106\r
107/**\r
108 Iterates all variables found with RuntimeServices GetNextVariableName\r
109\r
110 @param[in] CallbackFunction - Function called for each variable instance\r
111 @param[in] Context - Passed to each call of CallbackFunction\r
112\r
113 @retval RETURN_SUCCESS - All variables were iterated without the\r
114 CallbackFunction returning an error\r
115 @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to\r
116 iterate through the variables\r
117 @return Any of RETURN_ERROR indicates an error reading the variable\r
118 or an error was returned from CallbackFunction\r
119\r
120**/\r
121RETURN_STATUS\r
122EFIAPI\r
123SerializeVariablesIterateSystemVariables (\r
124 IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,\r
125 IN VOID *Context\r
126 );\r
127\r
128\r
129/**\r
130 Iterates all variables found in the variable serialization instance\r
131\r
132 @param[in] Handle - Handle for a variable serialization instance\r
133 @param[in] CallbackFunction - Function called for each variable instance\r
134 @param[in] Context - Passed to each call of CallbackFunction\r
135\r
136 @retval RETURN_SUCCESS - All variables were iterated without the\r
137 CallbackFunction returning an error\r
138 @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to\r
139 iterate through the variables\r
140 @return Any of RETURN_ERROR indicates an error reading the variable\r
141 or an error was returned from CallbackFunction\r
142\r
143**/\r
144RETURN_STATUS\r
145EFIAPI\r
146SerializeVariablesIterateInstanceVariables (\r
147 IN EFI_HANDLE Handle,\r
148 IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,\r
149 IN VOID *Context\r
150 );\r
151\r
152\r
153/**\r
154 Sets all variables found in the variable serialization instance\r
155\r
156 @param[in] Handle - Handle for a variable serialization instance\r
157\r
158 @retval RETURN_SUCCESS - All variables were set successfully\r
159 @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to\r
160 set all the variables\r
161 @return Any of RETURN_ERROR indicates an error reading the variables\r
162 or in attempting to set a variable\r
163\r
164**/\r
165RETURN_STATUS\r
166EFIAPI\r
167SerializeVariablesSetSerializedVariables (\r
168 IN EFI_HANDLE Handle\r
169 );\r
170\r
171\r
172/**\r
173 Adds a variable to the variable serialization instance\r
174\r
175 @param[in] Handle - Handle for a variable serialization instance\r
176 @param[in] VariableName - Refer to RuntimeServices GetVariable\r
177 @param[in] VendorGuid - Refer to RuntimeServices GetVariable\r
178 @param[in] Attributes - Refer to RuntimeServices GetVariable\r
179 @param[in] DataSize - Refer to RuntimeServices GetVariable\r
180 @param[in] Data - Refer to RuntimeServices GetVariable\r
181\r
182 @retval RETURN_SUCCESS - All variables were set successfully\r
183 @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to\r
184 add the variable\r
185\r
186**/\r
187RETURN_STATUS\r
188EFIAPI\r
189SerializeVariablesAddVariable (\r
190 IN EFI_HANDLE Handle,\r
191 IN CHAR16 *VariableName,\r
192 IN EFI_GUID *VendorGuid,\r
193 IN UINT32 Attributes,\r
194 IN UINTN DataSize,\r
195 IN VOID *Data\r
196 );\r
197\r
198\r
199/**\r
200 Serializes the variables known to this instance into the\r
201 provided buffer.\r
202\r
203 @param[in] Handle - Handle for a variable serialization instance\r
204 @param[out] Buffer - A buffer to store the binary representation\r
205 of the variables.\r
206 @param[in,out] Size - On input this is the size of the buffer.\r
207 On output this is the size of the binary representation\r
208 of the variables.\r
209\r
210 @retval RETURN_SUCCESS - The binary representation was successfully\r
211 completed and returned in the buffer.\r
212 @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to\r
213 save the variables to the buffer.\r
214 @retval RETURN_INVALID_PARAMETER - Handle was not a valid\r
215 variable serialization instance or\r
216 Size or Buffer were NULL.\r
217\r
218**/\r
219RETURN_STATUS\r
220EFIAPI\r
221SerializeVariablesToBuffer (\r
222 IN EFI_HANDLE Handle,\r
223 OUT VOID *Buffer,\r
224 IN OUT UINTN *Size\r
225 );\r
226\r
227\r
228#endif\r
229\r