67c284f8a00a1e722b987eda4e1e6ca046788ee3
[mirror_edk2.git] / EdkModulePkg / Universal / EmuVariable / RuntimeDxe / 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 //
28 // BugBug: We need relcate the head file.
29 //
30 #include <Common/Variable.h>
31
32 #if defined (MDE_CPU_IPF)
33 #define ALIGNMENT 8
34 #else
35 #define ALIGNMENT 1
36 #endif
37
38
39 #define VARIABLE_STORE_SIZE (64 * 1024)
40 #define SCRATCH_SIZE (4 * 1024)
41
42 //
43 // Define GET_PAD_SIZE to optimize compiler
44 //
45 #if ((ALIGNMENT == 0) || (ALIGNMENT == 1))
46 #define GET_PAD_SIZE(a) (0)
47 #else
48 #define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))
49 #endif
50
51 #define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))
52
53 typedef enum {
54 Physical,
55 Virtual
56 } VARIABLE_POINTER_TYPE;
57
58 typedef struct {
59 VARIABLE_HEADER *CurrPtr;
60 VARIABLE_HEADER *EndPtr;
61 VARIABLE_HEADER *StartPtr;
62 BOOLEAN Volatile;
63 } VARIABLE_POINTER_TRACK;
64
65 typedef struct {
66 EFI_PHYSICAL_ADDRESS VolatileVariableBase;
67 EFI_PHYSICAL_ADDRESS NonVolatileVariableBase;
68 EFI_LOCK VariableServicesLock;
69 } VARIABLE_GLOBAL;
70
71 typedef struct {
72 VARIABLE_GLOBAL VariableGlobal[2];
73 UINTN VolatileLastVariableOffset;
74 UINTN NonVolatileLastVariableOffset;
75 UINT32 FvbInstance;
76 } ESAL_VARIABLE_GLOBAL;
77
78 extern ESAL_VARIABLE_GLOBAL *mVariableModuleGlobal;
79
80 //
81 // Functions
82 //
83 EFI_STATUS
84 EFIAPI
85 VariableCommonInitialize (
86 IN EFI_HANDLE ImageHandle,
87 IN EFI_SYSTEM_TABLE *SystemTable
88 )
89 ;
90
91 EFI_STATUS
92 EFIAPI
93 VariableServiceInitialize (
94 IN EFI_HANDLE ImageHandle,
95 IN EFI_SYSTEM_TABLE *SystemTable
96 )
97 ;
98
99 VOID
100 EFIAPI
101 VariableClassAddressChangeEvent (
102 IN EFI_EVENT Event,
103 IN VOID *Context
104 )
105 ;
106
107 EFI_STATUS
108 EFIAPI
109 GetVariable (
110 IN CHAR16 *VariableName,
111 IN EFI_GUID * VendorGuid,
112 OUT UINT32 *Attributes OPTIONAL,
113 IN OUT UINTN *DataSize,
114 OUT VOID *Data,
115 IN VARIABLE_GLOBAL * Global,
116 IN UINT32 Instance
117 )
118 ;
119
120 EFI_STATUS
121 EFIAPI
122 GetNextVariableName (
123 IN OUT UINTN *VariableNameSize,
124 IN OUT CHAR16 *VariableName,
125 IN OUT EFI_GUID *VendorGuid,
126 IN VARIABLE_GLOBAL *Global,
127 IN UINT32 Instance
128 )
129 ;
130
131 EFI_STATUS
132 EFIAPI
133 SetVariable (
134 IN CHAR16 *VariableName,
135 IN EFI_GUID *VendorGuid,
136 IN UINT32 Attributes,
137 IN UINTN DataSize,
138 IN VOID *Data,
139 IN VARIABLE_GLOBAL *Global,
140 IN UINTN *VolatileOffset,
141 IN UINTN *NonVolatileOffset,
142 IN UINT32 Instance
143 )
144 ;
145
146 EFI_STATUS
147 EFIAPI
148 QueryVariableInfo (
149 IN UINT32 Attributes,
150 OUT UINT64 *MaximumVariableStorageSize,
151 OUT UINT64 *RemainingVariableStorageSize,
152 OUT UINT64 *MaximumVariableSize,
153 IN VARIABLE_GLOBAL *Global,
154 IN UINT32 Instance
155 )
156 ;
157
158 #endif