]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/VariableRuntimeDxe/InitVariable.c
Removed CommonHeader.h from MdePkg & MdeModulePkg
[mirror_edk2.git] / MdeModulePkg / Universal / VariableRuntimeDxe / InitVariable.c
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 InitVariable.c
15
16 Abstract:
17
18 Revision History
19
20 --*/
21
22 #include "Variable.h"
23
24 //
25 // Event for Exit Boot Services Callback
26 //
27 STATIC EFI_EVENT mExitBootServicesEvent = NULL;
28
29
30 //
31 // Don't use module globals after the SetVirtualAddress map is signaled
32 //
33 extern ESAL_VARIABLE_GLOBAL *mVariableModuleGlobal;
34
35 EFI_STATUS
36 EFIAPI
37 RuntimeServiceGetVariable (
38 IN CHAR16 *VariableName,
39 IN EFI_GUID * VendorGuid,
40 OUT UINT32 *Attributes OPTIONAL,
41 IN OUT UINTN *DataSize,
42 OUT VOID *Data
43 )
44 /*++
45
46 Routine Description:
47
48 Arguments:
49
50 Returns:
51
52 --*/
53 {
54 return GetVariable (
55 VariableName,
56 VendorGuid,
57 Attributes OPTIONAL,
58 DataSize,
59 Data,
60 &mVariableModuleGlobal->VariableGlobal[Physical],
61 mVariableModuleGlobal->FvbInstance
62 );
63 }
64
65 EFI_STATUS
66 EFIAPI
67 RuntimeServiceGetNextVariableName (
68 IN OUT UINTN *VariableNameSize,
69 IN OUT CHAR16 *VariableName,
70 IN OUT EFI_GUID *VendorGuid
71 )
72 /*++
73
74 Routine Description:
75
76 Arguments:
77
78 Returns:
79
80 --*/
81 {
82 return GetNextVariableName (
83 VariableNameSize,
84 VariableName,
85 VendorGuid,
86 &mVariableModuleGlobal->VariableGlobal[Physical],
87 mVariableModuleGlobal->FvbInstance
88 );
89 }
90
91 EFI_STATUS
92 EFIAPI
93 RuntimeServiceSetVariable (
94 IN CHAR16 *VariableName,
95 IN EFI_GUID *VendorGuid,
96 IN UINT32 Attributes,
97 IN UINTN DataSize,
98 IN VOID *Data
99 )
100 /*++
101
102 Routine Description:
103
104 Arguments:
105
106 Returns:
107
108 --*/
109 {
110 return SetVariable (
111 VariableName,
112 VendorGuid,
113 Attributes,
114 DataSize,
115 Data,
116 &mVariableModuleGlobal->VariableGlobal[Physical],
117 &mVariableModuleGlobal->VolatileLastVariableOffset,
118 &mVariableModuleGlobal->NonVolatileLastVariableOffset,
119 mVariableModuleGlobal->FvbInstance
120 );
121 }
122
123 EFI_STATUS
124 EFIAPI
125 RuntimeServiceQueryVariableInfo (
126 IN UINT32 Attributes,
127 OUT UINT64 *MaximumVariableStorageSize,
128 OUT UINT64 *RemainingVariableStorageSize,
129 OUT UINT64 *MaximumVariableSize
130 )
131 /*++
132
133 Routine Description:
134
135 Arguments:
136
137 Returns:
138
139 --*/
140 {
141 return QueryVariableInfo (
142 Attributes,
143 MaximumVariableStorageSize,
144 RemainingVariableStorageSize,
145 MaximumVariableSize,
146 &mVariableModuleGlobal->VariableGlobal[Physical],
147 mVariableModuleGlobal->FvbInstance
148 );
149 }
150
151 VOID
152 EFIAPI
153 VariableClassAddressChangeEvent (
154 IN EFI_EVENT Event,
155 IN VOID *Context
156 )
157 /*++
158
159 Routine Description:
160
161 Arguments:
162
163 Returns:
164
165 --*/
166 {
167 EfiConvertPointer (
168 0x0,
169 (VOID **) &mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase
170 );
171 EfiConvertPointer (
172 0x0,
173 (VOID **) &mVariableModuleGlobal->VariableGlobal[Physical].VolatileVariableBase
174 );
175 EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal);
176 }
177
178 EFI_STATUS
179 EFIAPI
180 VariableServiceInitialize (
181 IN EFI_HANDLE ImageHandle,
182 IN EFI_SYSTEM_TABLE *SystemTable
183 )
184 /*++
185
186 Routine Description:
187
188 Arguments:
189
190 Returns:
191
192 --*/
193 {
194 EFI_HANDLE NewHandle;
195 EFI_STATUS Status;
196
197 Status = VariableCommonInitialize (ImageHandle, SystemTable);
198 ASSERT_EFI_ERROR (Status);
199
200 SystemTable->RuntimeServices->GetVariable = RuntimeServiceGetVariable;
201 SystemTable->RuntimeServices->GetNextVariableName = RuntimeServiceGetNextVariableName;
202 SystemTable->RuntimeServices->SetVariable = RuntimeServiceSetVariable;
203 SystemTable->RuntimeServices->QueryVariableInfo = RuntimeServiceQueryVariableInfo;
204
205 //
206 // Now install the Variable Runtime Architectural Protocol on a new handle
207 //
208 NewHandle = NULL;
209 Status = gBS->InstallMultipleProtocolInterfaces (
210 &NewHandle,
211 &gEfiVariableArchProtocolGuid,
212 NULL,
213 &gEfiVariableWriteArchProtocolGuid,
214 NULL,
215 NULL
216 );
217 ASSERT_EFI_ERROR (Status);
218
219 Status = gBS->CreateEvent (
220 EVT_SIGNAL_EXIT_BOOT_SERVICES,
221 TPL_NOTIFY,
222 VariableClassAddressChangeEvent,
223 NULL,
224 &mExitBootServicesEvent
225 );
226 ASSERT_EFI_ERROR (Status);
227
228 return EFI_SUCCESS;
229 }