]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Variable/RuntimeDxe/Variable.h
Move VariablePei/VariableDxe/EmuVarible to /Variable folder of MdeModulePkg.
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / 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 #include <PiDxe.h>
24 #include <Protocol/VariableWrite.h>
25 #include <Protocol/FaultTolerantWriteLite.h>
26 #include <Protocol/FirmwareVolumeBlock.h>
27 #include <Protocol/Variable.h>
28 #include <Library/PcdLib.h>
29 #include <Library/UefiDriverEntryPoint.h>
30 #include <Library/DxeServicesTableLib.h>
31 #include <Library/UefiRuntimeLib.h>
32 #include <Library/DebugLib.h>
33 #include <Library/BaseMemoryLib.h>
34 #include <Library/FvbServiceLib.h>
35 #include <Library/UefiBootServicesTableLib.h>
36 #include <Library/UefiLib.h>
37 #include <Library/BaseLib.h>
38 #include <Library/MemoryAllocationLib.h>
39 #include <Library/HobLib.h>
40 #include <Common/FlashMap.h>
41 #include <Guid/FlashMapHob.h>
42
43 //
44 // BugBug: We need relcate the head file.
45 //
46 #include <Common/Variable.h>
47
48 #define VARIABLE_RECLAIM_THRESHOLD (1024)
49
50 #define VARIABLE_STORE_SIZE (64 * 1024)
51 #define SCRATCH_SIZE (4 * 1024)
52
53 //
54 // Define GET_PAD_SIZE to optimize compiler
55 //
56 #if ((ALIGNMENT == 0) || (ALIGNMENT == 1))
57 #define GET_PAD_SIZE(a) (0)
58 #else
59 #define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))
60 #endif
61
62 #define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))
63
64 typedef enum {
65 Physical,
66 Virtual
67 } VARIABLE_POINTER_TYPE;
68
69 typedef struct {
70 VARIABLE_HEADER *CurrPtr;
71 VARIABLE_HEADER *EndPtr;
72 VARIABLE_HEADER *StartPtr;
73 BOOLEAN Volatile;
74 } VARIABLE_POINTER_TRACK;
75
76 typedef struct {
77 EFI_PHYSICAL_ADDRESS VolatileVariableBase;
78 EFI_PHYSICAL_ADDRESS NonVolatileVariableBase;
79 EFI_LOCK VariableServicesLock;
80 } VARIABLE_GLOBAL;
81
82 typedef struct {
83 VARIABLE_GLOBAL VariableGlobal[2];
84 UINTN VolatileLastVariableOffset;
85 UINTN NonVolatileLastVariableOffset;
86 UINT32 FvbInstance;
87 } ESAL_VARIABLE_GLOBAL;
88
89 extern ESAL_VARIABLE_GLOBAL *mVariableModuleGlobal;
90
91 //
92 // Functions
93 //
94 EFI_STATUS
95 EFIAPI
96 VariableCommonInitialize (
97 IN EFI_HANDLE ImageHandle,
98 IN EFI_SYSTEM_TABLE *SystemTable
99 );
100
101 EFI_STATUS
102 EFIAPI
103 VariableServiceInitialize (
104 IN EFI_HANDLE ImageHandle,
105 IN EFI_SYSTEM_TABLE *SystemTable
106 );
107
108 VOID
109 EFIAPI
110 VariableClassAddressChangeEvent (
111 IN EFI_EVENT Event,
112 IN VOID *Context
113 );
114
115 EFI_STATUS
116 EFIAPI
117 GetVariable (
118 IN CHAR16 *VariableName,
119 IN EFI_GUID * VendorGuid,
120 OUT UINT32 *Attributes OPTIONAL,
121 IN OUT UINTN *DataSize,
122 OUT VOID *Data,
123 IN VARIABLE_GLOBAL * Global,
124 IN UINT32 Instance
125 );
126
127 EFI_STATUS
128 EFIAPI
129 GetNextVariableName (
130 IN OUT UINTN *VariableNameSize,
131 IN OUT CHAR16 *VariableName,
132 IN OUT EFI_GUID *VendorGuid,
133 IN VARIABLE_GLOBAL *Global,
134 IN UINT32 Instance
135 );
136
137 EFI_STATUS
138 EFIAPI
139 SetVariable (
140 IN CHAR16 *VariableName,
141 IN EFI_GUID *VendorGuid,
142 IN UINT32 Attributes,
143 IN UINTN DataSize,
144 IN VOID *Data,
145 IN VARIABLE_GLOBAL *Global,
146 IN UINTN *VolatileOffset,
147 IN UINTN *NonVolatileOffset,
148 IN UINT32 Instance
149 );
150
151 EFI_STATUS
152 EFIAPI
153 QueryVariableInfo (
154 IN UINT32 Attributes,
155 OUT UINT64 *MaximumVariableStorageSize,
156 OUT UINT64 *RemainingVariableStorageSize,
157 OUT UINT64 *MaximumVariableSize,
158 IN VARIABLE_GLOBAL *Global,
159 IN UINT32 Instance
160 );
161
162 EFI_STATUS
163 GetFvbHandleByAddress (
164 IN EFI_PHYSICAL_ADDRESS VariableStoreBase,
165 OUT EFI_HANDLE *FvbHandle
166 );
167
168 EFI_STATUS
169 FtwVariableSpace (
170 IN EFI_PHYSICAL_ADDRESS VariableBaseAddress,
171 IN UINT8 *Buffer,
172 IN UINTN BufferSize
173 );
174
175 #endif