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