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