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