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