Add in EmuVariableRuntimeDxe
[mirror_edk2.git] / MdeModulePkg / Universal / EmuVariableRuntimeDxe / Variable.h
1 /*++
2
3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 Variable.h
15
16 Abstract:
17
18 --*/
19
20 #ifndef _VARIABLE_H
21 #define _VARIABLE_H
22
23 //
24 // Statements that include other header files
25 //
26 //
27 // The package level header files this module uses
28 //
29 #include <PiDxe.h>
30 //
31 // The protocols, PPI and GUID defintions for this module
32 //
33 #include <Protocol/VariableWrite.h>
34 #include <Protocol/Variable.h>
35 //
36 // The Library classes this module consumes
37 //
38 #include <Library/BaseMemoryLib.h>
39 #include <Library/MemoryAllocationLib.h>
40 #include <Library/DebugLib.h>
41 #include <Library/UefiRuntimeLib.h>
42 #include <Library/UefiDriverEntryPoint.h>
43 #include <Library/UefiBootServicesTableLib.h>
44 #include <Library/UefiLib.h>
45 #include <Library/BaseLib.h>
46
47 //
48 // BugBug: We need relcate the head file.
49 //
50 #include <Common/Variable.h>
51
52 #define VARIABLE_STORE_SIZE (64 * 1024)
53 #define SCRATCH_SIZE (4 * 1024)
54
55 //
56 // Define GET_PAD_SIZE to optimize compiler
57 //
58 #if ((ALIGNMENT == 0) || (ALIGNMENT == 1))
59 #define GET_PAD_SIZE(a) (0)
60 #else
61 #define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))
62 #endif
63
64 #define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))
65
66 typedef enum {
67 Physical,
68 Virtual
69 } VARIABLE_POINTER_TYPE;
70
71 typedef struct {
72 VARIABLE_HEADER *CurrPtr;
73 VARIABLE_HEADER *EndPtr;
74 VARIABLE_HEADER *StartPtr;
75 BOOLEAN Volatile;
76 } VARIABLE_POINTER_TRACK;
77
78 typedef struct {
79 EFI_PHYSICAL_ADDRESS VolatileVariableBase;
80 EFI_PHYSICAL_ADDRESS NonVolatileVariableBase;
81 EFI_LOCK VariableServicesLock;
82 } VARIABLE_GLOBAL;
83
84 typedef struct {
85 VARIABLE_GLOBAL VariableGlobal[2];
86 UINTN VolatileLastVariableOffset;
87 UINTN NonVolatileLastVariableOffset;
88 UINT32 FvbInstance;
89 } ESAL_VARIABLE_GLOBAL;
90
91 extern ESAL_VARIABLE_GLOBAL *mVariableModuleGlobal;
92
93 //
94 // Functions
95 //
96 EFI_STATUS
97 EFIAPI
98 VariableCommonInitialize (
99 IN EFI_HANDLE ImageHandle,
100 IN EFI_SYSTEM_TABLE *SystemTable
101 )
102 ;
103
104 EFI_STATUS
105 EFIAPI
106 VariableServiceInitialize (
107 IN EFI_HANDLE ImageHandle,
108 IN EFI_SYSTEM_TABLE *SystemTable
109 )
110 ;
111
112 VOID
113 EFIAPI
114 VariableClassAddressChangeEvent (
115 IN EFI_EVENT Event,
116 IN VOID *Context
117 )
118 ;
119
120 EFI_STATUS
121 EFIAPI
122 GetVariable (
123 IN CHAR16 *VariableName,
124 IN EFI_GUID * VendorGuid,
125 OUT UINT32 *Attributes OPTIONAL,
126 IN OUT UINTN *DataSize,
127 OUT VOID *Data,
128 IN VARIABLE_GLOBAL * Global,
129 IN UINT32 Instance
130 )
131 ;
132
133 EFI_STATUS
134 EFIAPI
135 GetNextVariableName (
136 IN OUT UINTN *VariableNameSize,
137 IN OUT CHAR16 *VariableName,
138 IN OUT EFI_GUID *VendorGuid,
139 IN VARIABLE_GLOBAL *Global,
140 IN UINT32 Instance
141 )
142 ;
143
144 EFI_STATUS
145 EFIAPI
146 SetVariable (
147 IN CHAR16 *VariableName,
148 IN EFI_GUID *VendorGuid,
149 IN UINT32 Attributes,
150 IN UINTN DataSize,
151 IN VOID *Data,
152 IN VARIABLE_GLOBAL *Global,
153 IN UINTN *VolatileOffset,
154 IN UINTN *NonVolatileOffset,
155 IN UINT32 Instance
156 )
157 ;
158
159 EFI_STATUS
160 EFIAPI
161 QueryVariableInfo (
162 IN UINT32 Attributes,
163 OUT UINT64 *MaximumVariableStorageSize,
164 OUT UINT64 *RemainingVariableStorageSize,
165 OUT UINT64 *MaximumVariableSize,
166 IN VARIABLE_GLOBAL *Global,
167 IN UINT32 Instance
168 )
169 ;
170
171 #endif