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