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