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