VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/VBoxPkg/VBoxVariable/Variable.h@ 54985

Last change on this file since 54985 was 48674, checked in by vboxsync, 11 years ago

EFI: Export newly imported tinaocore UEFI sources to OSE.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette