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