]>
Commit | Line | Data |
---|---|---|
504214c4 | 1 | /** @file\r |
8d3a5c82 | 2 | \r |
504214c4 LG |
3 | The internal header file includes the common header files, defines\r |
4 | internal structure and functions used by EmuVariable module.\r | |
5 | \r | |
6 | Copyright (c) 2006 - 2008, Intel Corporation\r | |
8d3a5c82 | 7 | All rights reserved. This program and the accompanying materials\r |
8 | are licensed and made available under the terms and conditions of the BSD License\r | |
9 | which accompanies this distribution. The full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
504214c4 | 15 | **/\r |
8d3a5c82 | 16 | \r |
1794e506 | 17 | #ifndef _VARIABLE_H_\r |
18 | #define _VARIABLE_H_\r | |
ed7748fe | 19 | \r |
60c93673 | 20 | #include <Uefi.h>\r |
ed7748fe | 21 | \r |
8d3a5c82 | 22 | #include <Protocol/VariableWrite.h>\r |
23 | #include <Protocol/Variable.h>\r | |
ed7748fe | 24 | \r |
8d3a5c82 | 25 | #include <Library/BaseMemoryLib.h>\r |
26 | #include <Library/MemoryAllocationLib.h>\r | |
27 | #include <Library/DebugLib.h>\r | |
28 | #include <Library/UefiRuntimeLib.h>\r | |
29 | #include <Library/UefiDriverEntryPoint.h>\r | |
30 | #include <Library/UefiBootServicesTableLib.h>\r | |
31 | #include <Library/UefiLib.h>\r | |
32 | #include <Library/BaseLib.h>\r | |
518d395c | 33 | #include <Library/PcdLib.h>\r |
3cfb790c | 34 | #include <VariableFormat.h>\r |
8d3a5c82 | 35 | \r |
01a5c994 | 36 | #include <Guid/EventGroup.h>\r |
37 | \r | |
8d3a5c82 | 38 | #define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))\r |
39 | \r | |
40 | typedef enum {\r | |
41 | Physical,\r | |
42 | Virtual\r | |
43 | } VARIABLE_POINTER_TYPE;\r | |
44 | \r | |
45 | typedef struct {\r | |
46 | VARIABLE_HEADER *CurrPtr;\r | |
47 | VARIABLE_HEADER *EndPtr;\r | |
48 | VARIABLE_HEADER *StartPtr;\r | |
49 | BOOLEAN Volatile;\r | |
50 | } VARIABLE_POINTER_TRACK;\r | |
51 | \r | |
52 | typedef struct {\r | |
53 | EFI_PHYSICAL_ADDRESS VolatileVariableBase;\r | |
54 | EFI_PHYSICAL_ADDRESS NonVolatileVariableBase;\r | |
55 | EFI_LOCK VariableServicesLock;\r | |
56 | } VARIABLE_GLOBAL;\r | |
57 | \r | |
58 | typedef struct {\r | |
59 | VARIABLE_GLOBAL VariableGlobal[2];\r | |
60 | UINTN VolatileLastVariableOffset;\r | |
61 | UINTN NonVolatileLastVariableOffset;\r | |
62 | UINT32 FvbInstance;\r | |
63 | } ESAL_VARIABLE_GLOBAL;\r | |
64 | \r | |
1794e506 | 65 | ///\r |
66 | /// Don't use module globals after the SetVirtualAddress map is signaled\r | |
67 | ///\r | |
8d3a5c82 | 68 | extern ESAL_VARIABLE_GLOBAL *mVariableModuleGlobal;\r |
69 | \r | |
1794e506 | 70 | /**\r |
71 | Initializes variable store area for non-volatile and volatile variable.\r | |
72 | \r | |
73 | This function allocates and initializes memory space for global context of ESAL\r | |
74 | variable service and variable store area for non-volatile and volatile variable.\r | |
75 | \r | |
76 | @param ImageHandle The Image handle of this driver.\r | |
77 | @param SystemTable The pointer of EFI_SYSTEM_TABLE.\r | |
78 | \r | |
79 | @retval EFI_SUCCESS Function successfully executed.\r | |
80 | @retval EFI_OUT_OF_RESOURCES Fail to allocate enough memory resource.\r | |
81 | \r | |
82 | **/\r | |
8d3a5c82 | 83 | EFI_STATUS\r |
84 | EFIAPI\r | |
85 | VariableCommonInitialize (\r | |
86 | IN EFI_HANDLE ImageHandle,\r | |
87 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
ed66e1bc | 88 | );\r |
8d3a5c82 | 89 | \r |
1794e506 | 90 | /**\r |
91 | Entry point of EmuVariable service module.\r | |
92 | \r | |
93 | This function is the entry point of EmuVariable service module.\r | |
94 | It registers all interfaces of Variable Services, initializes\r | |
95 | variable store for non-volatile and volatile variables, and registers\r | |
96 | notification function for EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.\r | |
97 | \r | |
98 | @param ImageHandle The Image handle of this driver.\r | |
99 | @param SystemTable The pointer of EFI_SYSTEM_TABLE.\r | |
100 | \r | |
101 | @retval EFI_SUCCESS Variable service successfully initialized.\r | |
102 | \r | |
103 | **/\r | |
8d3a5c82 | 104 | EFI_STATUS\r |
105 | EFIAPI\r | |
106 | VariableServiceInitialize (\r | |
107 | IN EFI_HANDLE ImageHandle,\r | |
108 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
ed66e1bc | 109 | );\r |
8d3a5c82 | 110 | \r |
1794e506 | 111 | /**\r |
112 | Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.\r | |
113 | \r | |
114 | This is a notification function registered on EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.\r | |
115 | It convers pointer to new virtual address.\r | |
116 | \r | |
117 | @param Event Event whose notification function is being invoked.\r | |
118 | @param Context Pointer to the notification function's context.\r | |
119 | \r | |
120 | **/\r | |
8d3a5c82 | 121 | VOID\r |
122 | EFIAPI\r | |
123 | VariableClassAddressChangeEvent (\r | |
124 | IN EFI_EVENT Event,\r | |
125 | IN VOID *Context\r | |
ed66e1bc | 126 | );\r |
8d3a5c82 | 127 | \r |
1794e506 | 128 | /**\r |
129 | This code finds variable in storage blocks (Volatile or Non-Volatile).\r | |
130 | \r | |
131 | @param VariableName A Null-terminated Unicode string that is the name of\r | |
132 | the vendor's variable.\r | |
133 | @param VendorGuid A unique identifier for the vendor.\r | |
134 | @param Attributes If not NULL, a pointer to the memory location to return the \r | |
135 | attributes bitmask for the variable.\r | |
136 | @param DataSize Size of Data found. If size is less than the\r | |
137 | data, this value contains the required size.\r | |
138 | @param Data On input, the size in bytes of the return Data buffer. \r | |
139 | On output, the size of data returned in Data.\r | |
140 | @param Global Pointer to VARIABLE_GLOBAL structure\r | |
141 | @param Instance Instance of the Firmware Volume.\r | |
142 | \r | |
143 | @retval EFI_SUCCESS The function completed successfully. \r | |
144 | @retval EFI_NOT_FOUND The variable was not found.\r | |
145 | @retval EFI_BUFFER_TOO_SMALL DataSize is too small for the result. DataSize has \r | |
146 | been updated with the size needed to complete the request.\r | |
147 | @retval EFI_INVALID_PARAMETER VariableName or VendorGuid or DataSize is NULL.\r | |
148 | \r | |
149 | **/\r | |
8d3a5c82 | 150 | EFI_STATUS\r |
151 | EFIAPI\r | |
152 | GetVariable (\r | |
153 | IN CHAR16 *VariableName,\r | |
154 | IN EFI_GUID * VendorGuid,\r | |
155 | OUT UINT32 *Attributes OPTIONAL,\r | |
156 | IN OUT UINTN *DataSize,\r | |
157 | OUT VOID *Data,\r | |
158 | IN VARIABLE_GLOBAL * Global,\r | |
159 | IN UINT32 Instance\r | |
ed66e1bc | 160 | );\r |
8d3a5c82 | 161 | \r |
1794e506 | 162 | /**\r |
163 | \r | |
164 | This code finds the next available variable.\r | |
165 | \r | |
166 | @param VariableNameSize Size of the variable.\r | |
167 | @param VariableName On input, supplies the last VariableName that was returned by GetNextVariableName().\r | |
168 | On output, returns the Null-terminated Unicode string of the current variable.\r | |
169 | @param VendorGuid On input, supplies the last VendorGuid that was returned by GetNextVariableName().\r | |
170 | On output, returns the VendorGuid of the current variable. \r | |
171 | @param Global Pointer to VARIABLE_GLOBAL structure.\r | |
172 | @param Instance Instance of the Firmware Volume.\r | |
173 | \r | |
174 | @retval EFI_SUCCESS The function completed successfully. \r | |
175 | @retval EFI_NOT_FOUND The next variable was not found.\r | |
176 | @retval EFI_BUFFER_TOO_SMALL VariableNameSize is too small for the result. \r | |
177 | VariableNameSize has been updated with the size needed to complete the request.\r | |
178 | @retval EFI_INVALID_PARAMETER VariableNameSize or VariableName or VendorGuid is NULL.\r | |
179 | \r | |
180 | **/\r | |
8d3a5c82 | 181 | EFI_STATUS\r |
182 | EFIAPI\r | |
183 | GetNextVariableName (\r | |
184 | IN OUT UINTN *VariableNameSize,\r | |
185 | IN OUT CHAR16 *VariableName,\r | |
186 | IN OUT EFI_GUID *VendorGuid,\r | |
187 | IN VARIABLE_GLOBAL *Global,\r | |
188 | IN UINT32 Instance\r | |
ed66e1bc | 189 | );\r |
8d3a5c82 | 190 | \r |
1794e506 | 191 | /**\r |
192 | \r | |
193 | This code sets variable in storage blocks (Volatile or Non-Volatile).\r | |
194 | \r | |
195 | @param VariableName A Null-terminated Unicode string that is the name of the vendor's\r | |
196 | variable. Each VariableName is unique for each \r | |
197 | VendorGuid. VariableName must contain 1 or more \r | |
198 | Unicode characters. If VariableName is an empty Unicode \r | |
199 | string, then EFI_INVALID_PARAMETER is returned.\r | |
200 | @param VendorGuid A unique identifier for the vendor\r | |
201 | @param Attributes Attributes bitmask to set for the variable\r | |
202 | @param DataSize The size in bytes of the Data buffer. A size of zero causes the\r | |
203 | variable to be deleted.\r | |
204 | @param Data The contents for the variable\r | |
205 | @param Global Pointer to VARIABLE_GLOBAL structure\r | |
206 | @param VolatileOffset The offset of last volatile variable\r | |
207 | @param NonVolatileOffset The offset of last non-volatile variable\r | |
208 | @param Instance Instance of the Firmware Volume.\r | |
209 | \r | |
210 | @retval EFI_SUCCESS The firmware has successfully stored the variable and its data as \r | |
211 | defined by the Attributes.\r | |
212 | @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied, or the \r | |
213 | DataSize exceeds the maximum allowed, or VariableName is an empty \r | |
214 | Unicode string, or VendorGuid is NULL.\r | |
215 | @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.\r | |
216 | @retval EFI_DEVICE_ERROR The variable could not be saved due to a hardware failure.\r | |
217 | @retval EFI_WRITE_PROTECTED The variable in question is read-only or cannot be deleted.\r | |
218 | @retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found.\r | |
219 | \r | |
220 | **/\r | |
8d3a5c82 | 221 | EFI_STATUS\r |
222 | EFIAPI\r | |
223 | SetVariable (\r | |
224 | IN CHAR16 *VariableName,\r | |
225 | IN EFI_GUID *VendorGuid,\r | |
226 | IN UINT32 Attributes,\r | |
227 | IN UINTN DataSize,\r | |
228 | IN VOID *Data,\r | |
229 | IN VARIABLE_GLOBAL *Global,\r | |
230 | IN UINTN *VolatileOffset,\r | |
231 | IN UINTN *NonVolatileOffset,\r | |
232 | IN UINT32 Instance\r | |
ed66e1bc | 233 | );\r |
8d3a5c82 | 234 | \r |
1794e506 | 235 | /**\r |
236 | \r | |
237 | This code returns information about the EFI variables.\r | |
238 | \r | |
239 | @param Attributes Attributes bitmask to specify the type of variables\r | |
240 | on which to return information.\r | |
241 | @param MaximumVariableStorageSize On output the maximum size of the storage space available for \r | |
242 | the EFI variables associated with the attributes specified. \r | |
243 | @param RemainingVariableStorageSize Returns the remaining size of the storage space available for EFI \r | |
244 | variables associated with the attributes specified.\r | |
245 | @param MaximumVariableSize Returns the maximum size of an individual EFI variable \r | |
246 | associated with the attributes specified.\r | |
247 | @param Global Pointer to VARIABLE_GLOBAL structure.\r | |
248 | @param Instance Instance of the Firmware Volume.\r | |
249 | \r | |
250 | @retval EFI_SUCCESS Valid answer returned.\r | |
251 | @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied\r | |
252 | @retval EFI_UNSUPPORTED The attribute is not supported on this platform, and the \r | |
253 | MaximumVariableStorageSize, RemainingVariableStorageSize, \r | |
254 | MaximumVariableSize are undefined.\r | |
255 | \r | |
256 | **/\r | |
8d3a5c82 | 257 | EFI_STATUS\r |
258 | EFIAPI\r | |
259 | QueryVariableInfo (\r | |
260 | IN UINT32 Attributes,\r | |
261 | OUT UINT64 *MaximumVariableStorageSize,\r | |
262 | OUT UINT64 *RemainingVariableStorageSize,\r | |
263 | OUT UINT64 *MaximumVariableSize,\r | |
264 | IN VARIABLE_GLOBAL *Global,\r | |
265 | IN UINT32 Instance\r | |
ed66e1bc | 266 | );\r |
8d3a5c82 | 267 | \r |
268 | #endif\r |