]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Universal/Variable/RuntimeDxe/Variable.h
Add a lock to protect the critical region in Service APIs for UEFI Runtime Variable...
[mirror_edk2.git] / EdkModulePkg / 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 //
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 #if defined (MDE_CPU_IPF)
33 #define ALIGNMENT 8
34 #else
35 #define ALIGNMENT 1
36 #endif
37
38 #define VARIABLE_RECLAIM_THRESHOLD (1024)
39
40 #define VARIABLE_STORE_SIZE (64 * 1024)
41 #define SCRATCH_SIZE (4 * 1024)
42
43 //
44 // Define GET_PAD_SIZE to optimize compiler
45 //
46 #if ((ALIGNMENT == 0) || (ALIGNMENT == 1))
47 #define GET_PAD_SIZE(a) (0)
48 #else
49 #define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))
50 #endif
51
52 #define GET_VARIABLE_NAME_PTR(a) (CHAR16 *) ((UINTN) (a) + sizeof (VARIABLE_HEADER))
53
54 typedef enum {
55 Physical,
56 Virtual
57 } VARIABLE_POINTER_TYPE;
58
59 typedef struct {
60 VARIABLE_HEADER *CurrPtr;
61 VARIABLE_HEADER *EndPtr;
62 VARIABLE_HEADER *StartPtr;
63 BOOLEAN Volatile;
64 } VARIABLE_POINTER_TRACK;
65
66 typedef struct {
67 EFI_PHYSICAL_ADDRESS VolatileVariableBase;
68 EFI_PHYSICAL_ADDRESS NonVolatileVariableBase;
69 EFI_LOCK VariableServicesLock;
70 } VARIABLE_GLOBAL;
71
72 typedef struct {
73 VARIABLE_GLOBAL VariableGlobal[2];
74 UINTN VolatileLastVariableOffset;
75 UINTN NonVolatileLastVariableOffset;
76 UINT32 FvbInstance;
77 } ESAL_VARIABLE_GLOBAL;
78
79 extern ESAL_VARIABLE_GLOBAL *mVariableModuleGlobal;
80
81 //
82 // Functions
83 //
84 EFI_STATUS
85 EFIAPI
86 VariableCommonInitialize (
87 IN EFI_HANDLE ImageHandle,
88 IN EFI_SYSTEM_TABLE *SystemTable
89 )
90 ;
91
92 EFI_STATUS
93 EFIAPI
94 VariableServiceInitialize (
95 IN EFI_HANDLE ImageHandle,
96 IN EFI_SYSTEM_TABLE *SystemTable
97 )
98 ;
99
100 VOID
101 EFIAPI
102 VariableClassAddressChangeEvent (
103 IN EFI_EVENT Event,
104 IN VOID *Context
105 )
106 ;
107
108 EFI_STATUS
109 EFIAPI
110 GetVariable (
111 IN CHAR16 *VariableName,
112 IN EFI_GUID * VendorGuid,
113 OUT UINT32 *Attributes OPTIONAL,
114 IN OUT UINTN *DataSize,
115 OUT VOID *Data,
116 IN VARIABLE_GLOBAL * Global,
117 IN UINT32 Instance
118 )
119 ;
120
121 EFI_STATUS
122 EFIAPI
123 GetNextVariableName (
124 IN OUT UINTN *VariableNameSize,
125 IN OUT CHAR16 *VariableName,
126 IN OUT EFI_GUID *VendorGuid,
127 IN VARIABLE_GLOBAL *Global,
128 IN UINT32 Instance
129 )
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
147 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
148 EFI_STATUS
149 EFIAPI
150 QueryVariableInfo (
151 IN UINT32 Attributes,
152 OUT UINT64 *MaximumVariableStorageSize,
153 OUT UINT64 *RemainingVariableStorageSize,
154 OUT UINT64 *MaximumVariableSize,
155 IN VARIABLE_GLOBAL *Global,
156 IN UINT32 Instance
157 )
158 ;
159 #endif
160
161 #endif