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