]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Include/Library/SerializeVariablesLib.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[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
b26f0cf9 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
e79f62f0 6\r
7**/\r
8\r
9#ifndef __SERIALIZE_VARIABLES_LIB__\r
10#define __SERIALIZE_VARIABLES_LIB__\r
11\r
e79f62f0 12/**\r
13 Callback function for each variable\r
14\r
15 @param[in] Context - Context as sent to the iteration function\r
16 @param[in] VariableName - Refer to RuntimeServices GetNextVariableName\r
17 @param[in] VendorGuid - Refer to RuntimeServices GetNextVariableName\r
18 @param[in] Attributes - Refer to RuntimeServices GetVariable\r
19 @param[in] DataSize - Refer to RuntimeServices GetVariable\r
20 @param[in] Data - Refer to RuntimeServices GetVariable\r
21\r
22 @retval RETURN_SUCCESS Continue iterating through the variables\r
23 @return Any RETURN_ERROR Stop iterating through the variables\r
24\r
25**/\r
26typedef\r
27RETURN_STATUS\r
28(EFIAPI *VARIABLE_SERIALIZATION_ITERATION_CALLBACK)(\r
29 IN VOID *Context,\r
30 IN CHAR16 *VariableName,\r
31 IN EFI_GUID *VendorGuid,\r
32 IN UINT32 Attributes,\r
33 IN UINTN DataSize,\r
34 IN VOID *Data\r
35 );\r
36\r
e79f62f0 37/**\r
38 Creates a new variable serialization instance\r
39\r
40 @param[out] Handle - Handle for a variable serialization instance\r
41\r
42 @retval RETURN_SUCCESS - The variable serialization instance was\r
43 successfully created.\r
44 @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to\r
45 create the variable serialization instance.\r
46\r
47**/\r
48RETURN_STATUS\r
49EFIAPI\r
50SerializeVariablesNewInstance (\r
ac0a286f 51 OUT EFI_HANDLE *Handle\r
e79f62f0 52 );\r
53\r
e79f62f0 54/**\r
55 Free memory associated with a variable serialization instance\r
56\r
57 @param[in] Handle - Handle for a variable serialization instance\r
58\r
59 @retval RETURN_SUCCESS - The variable serialization instance was\r
60 successfully freed.\r
61 @retval RETURN_INVALID_PARAMETER - Handle was not a valid\r
62 variable serialization instance.\r
63\r
64**/\r
65RETURN_STATUS\r
66EFIAPI\r
67SerializeVariablesFreeInstance (\r
ac0a286f 68 IN EFI_HANDLE Handle\r
e79f62f0 69 );\r
70\r
e79f62f0 71/**\r
72 Creates a new variable serialization instance using the given\r
73 binary representation of the variables to fill the new instance\r
74\r
75 @param[out] Handle - Handle for a variable serialization instance\r
76 @param[in] Buffer - A buffer with the serialized representation\r
77 of the variables. Must be the same format as produced\r
78 by SerializeVariablesToBuffer.\r
79 @param[in] Size - This is the size of the binary representation\r
80 of the variables.\r
81\r
82 @retval RETURN_SUCCESS - The binary representation was successfully\r
83 imported into a new variable serialization instance\r
84 @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to\r
85 create the new variable serialization instance\r
86\r
87**/\r
88RETURN_STATUS\r
89EFIAPI\r
90SerializeVariablesNewInstanceFromBuffer (\r
ac0a286f
MK
91 OUT EFI_HANDLE *Handle,\r
92 IN VOID *Buffer,\r
93 IN UINTN Size\r
e79f62f0 94 );\r
95\r
e79f62f0 96/**\r
97 Iterates all variables found with RuntimeServices GetNextVariableName\r
98\r
99 @param[in] CallbackFunction - Function called for each variable instance\r
100 @param[in] Context - Passed to each call of CallbackFunction\r
101\r
102 @retval RETURN_SUCCESS - All variables were iterated without the\r
103 CallbackFunction returning an error\r
104 @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to\r
105 iterate through the variables\r
106 @return Any of RETURN_ERROR indicates an error reading the variable\r
107 or an error was returned from CallbackFunction\r
108\r
109**/\r
110RETURN_STATUS\r
111EFIAPI\r
112SerializeVariablesIterateSystemVariables (\r
ac0a286f
MK
113 IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,\r
114 IN VOID *Context\r
e79f62f0 115 );\r
116\r
e79f62f0 117/**\r
118 Iterates all variables found in the variable serialization instance\r
119\r
120 @param[in] Handle - Handle for a variable serialization instance\r
121 @param[in] CallbackFunction - Function called for each variable instance\r
122 @param[in] Context - Passed to each call of CallbackFunction\r
123\r
124 @retval RETURN_SUCCESS - All variables were iterated without the\r
125 CallbackFunction returning an error\r
126 @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to\r
127 iterate through the variables\r
128 @return Any of RETURN_ERROR indicates an error reading the variable\r
129 or an error was returned from CallbackFunction\r
130\r
131**/\r
132RETURN_STATUS\r
133EFIAPI\r
134SerializeVariablesIterateInstanceVariables (\r
ac0a286f
MK
135 IN EFI_HANDLE Handle,\r
136 IN VARIABLE_SERIALIZATION_ITERATION_CALLBACK CallbackFunction,\r
137 IN VOID *Context\r
e79f62f0 138 );\r
139\r
e79f62f0 140/**\r
141 Sets all variables found in the variable serialization instance\r
142\r
143 @param[in] Handle - Handle for a variable serialization instance\r
144\r
145 @retval RETURN_SUCCESS - All variables were set successfully\r
146 @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to\r
147 set all the variables\r
148 @return Any of RETURN_ERROR indicates an error reading the variables\r
149 or in attempting to set a variable\r
150\r
151**/\r
152RETURN_STATUS\r
153EFIAPI\r
154SerializeVariablesSetSerializedVariables (\r
ac0a286f 155 IN EFI_HANDLE Handle\r
e79f62f0 156 );\r
157\r
e79f62f0 158/**\r
159 Adds a variable to the variable serialization instance\r
160\r
161 @param[in] Handle - Handle for a variable serialization instance\r
162 @param[in] VariableName - Refer to RuntimeServices GetVariable\r
163 @param[in] VendorGuid - Refer to RuntimeServices GetVariable\r
164 @param[in] Attributes - Refer to RuntimeServices GetVariable\r
165 @param[in] DataSize - Refer to RuntimeServices GetVariable\r
166 @param[in] Data - Refer to RuntimeServices GetVariable\r
167\r
168 @retval RETURN_SUCCESS - All variables were set successfully\r
169 @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to\r
170 add the variable\r
171\r
172**/\r
173RETURN_STATUS\r
174EFIAPI\r
175SerializeVariablesAddVariable (\r
ac0a286f
MK
176 IN EFI_HANDLE Handle,\r
177 IN CHAR16 *VariableName,\r
178 IN EFI_GUID *VendorGuid,\r
179 IN UINT32 Attributes,\r
180 IN UINTN DataSize,\r
181 IN VOID *Data\r
e79f62f0 182 );\r
183\r
e79f62f0 184/**\r
185 Serializes the variables known to this instance into the\r
186 provided buffer.\r
187\r
188 @param[in] Handle - Handle for a variable serialization instance\r
189 @param[out] Buffer - A buffer to store the binary representation\r
190 of the variables.\r
191 @param[in,out] Size - On input this is the size of the buffer.\r
192 On output this is the size of the binary representation\r
193 of the variables.\r
194\r
195 @retval RETURN_SUCCESS - The binary representation was successfully\r
196 completed and returned in the buffer.\r
197 @retval RETURN_OUT_OF_RESOURCES - There we not enough resources to\r
198 save the variables to the buffer.\r
199 @retval RETURN_INVALID_PARAMETER - Handle was not a valid\r
200 variable serialization instance or\r
201 Size or Buffer were NULL.\r
202\r
203**/\r
204RETURN_STATUS\r
205EFIAPI\r
206SerializeVariablesToBuffer (\r
ac0a286f
MK
207 IN EFI_HANDLE Handle,\r
208 OUT VOID *Buffer,\r
209 IN OUT UINTN *Size\r
e79f62f0 210 );\r
211\r
e79f62f0 212#endif\r