]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Variable/EmuRuntimeDxe/Variable.h
define the variable related to PCD for supporting big variable (>32K) easily.
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / EmuRuntimeDxe / 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 #include <PiDxe.h>
28
29 #include <Protocol/VariableWrite.h>
30 #include <Protocol/Variable.h>
31
32 #include <Library/BaseMemoryLib.h>
33 #include <Library/MemoryAllocationLib.h>
34 #include <Library/DebugLib.h>
35 #include <Library/UefiRuntimeLib.h>
36 #include <Library/UefiDriverEntryPoint.h>
37 #include <Library/UefiBootServicesTableLib.h>
38 #include <Library/UefiLib.h>
39 #include <Library/BaseLib.h>
40 #include <Library/PcdLib.h>
41 #include <VariableFormat.h>
42
43 #define VARIABLE_STORE_SIZE FixedPcdGet32(PcdVariableStoreSize)
44 #define SCRATCH_SIZE FixedPcdGet32(PcdMaxVariableSize)
45
46 //
47 // Define GET_PAD_SIZE to optimize compiler
48 //
49 #if ((ALIGNMENT == 0) || (ALIGNMENT == 1))
50 #define GET_PAD_SIZE(a) (0)
51 #else
52 #define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))
53 #endif
54
55 #define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))
56
57 typedef enum {
58 Physical,
59 Virtual
60 } VARIABLE_POINTER_TYPE;
61
62 typedef struct {
63 VARIABLE_HEADER *CurrPtr;
64 VARIABLE_HEADER *EndPtr;
65 VARIABLE_HEADER *StartPtr;
66 BOOLEAN Volatile;
67 } VARIABLE_POINTER_TRACK;
68
69 typedef struct {
70 EFI_PHYSICAL_ADDRESS VolatileVariableBase;
71 EFI_PHYSICAL_ADDRESS NonVolatileVariableBase;
72 EFI_LOCK VariableServicesLock;
73 } VARIABLE_GLOBAL;
74
75 typedef struct {
76 VARIABLE_GLOBAL VariableGlobal[2];
77 UINTN VolatileLastVariableOffset;
78 UINTN NonVolatileLastVariableOffset;
79 UINT32 FvbInstance;
80 } ESAL_VARIABLE_GLOBAL;
81
82 extern ESAL_VARIABLE_GLOBAL *mVariableModuleGlobal;
83
84 //
85 // Functions
86 //
87 EFI_STATUS
88 EFIAPI
89 VariableCommonInitialize (
90 IN EFI_HANDLE ImageHandle,
91 IN EFI_SYSTEM_TABLE *SystemTable
92 )
93 ;
94
95 EFI_STATUS
96 EFIAPI
97 VariableServiceInitialize (
98 IN EFI_HANDLE ImageHandle,
99 IN EFI_SYSTEM_TABLE *SystemTable
100 )
101 ;
102
103 VOID
104 EFIAPI
105 VariableClassAddressChangeEvent (
106 IN EFI_EVENT Event,
107 IN VOID *Context
108 )
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
124 EFI_STATUS
125 EFIAPI
126 GetNextVariableName (
127 IN OUT UINTN *VariableNameSize,
128 IN OUT CHAR16 *VariableName,
129 IN OUT EFI_GUID *VendorGuid,
130 IN VARIABLE_GLOBAL *Global,
131 IN UINT32 Instance
132 )
133 ;
134
135 EFI_STATUS
136 EFIAPI
137 SetVariable (
138 IN CHAR16 *VariableName,
139 IN EFI_GUID *VendorGuid,
140 IN UINT32 Attributes,
141 IN UINTN DataSize,
142 IN VOID *Data,
143 IN VARIABLE_GLOBAL *Global,
144 IN UINTN *VolatileOffset,
145 IN UINTN *NonVolatileOffset,
146 IN UINT32 Instance
147 )
148 ;
149
150 EFI_STATUS
151 EFIAPI
152 QueryVariableInfo (
153 IN UINT32 Attributes,
154 OUT UINT64 *MaximumVariableStorageSize,
155 OUT UINT64 *RemainingVariableStorageSize,
156 OUT UINT64 *MaximumVariableSize,
157 IN VARIABLE_GLOBAL *Global,
158 IN UINT32 Instance
159 )
160 ;
161
162 #endif