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