]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Variable/EmuRuntimeDxe/InitVariable.c
Add comments and DoxyGen format for these files.
[mirror_edk2.git] / MdeModulePkg / Universal / Variable / EmuRuntimeDxe / InitVariable.c
1 /** @file
2
3 Implment all four UEFI runtime variable services and
4 install variable architeture protocol.
5
6 Copyright (c) 2006 - 2008, Intel Corporation
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 #include "Variable.h"
18
19 //
20 // Don't use module globals after the SetVirtualAddress map is signaled
21 //
22 extern ESAL_VARIABLE_GLOBAL *mVariableModuleGlobal;
23
24 EFI_STATUS
25 EFIAPI
26 RuntimeServiceGetVariable (
27 IN CHAR16 *VariableName,
28 IN EFI_GUID * VendorGuid,
29 OUT UINT32 *Attributes OPTIONAL,
30 IN OUT UINTN *DataSize,
31 OUT VOID *Data
32 )
33 /*++
34
35 Routine Description:
36
37 Arguments:
38
39 Returns:
40
41 --*/
42 {
43 return GetVariable (
44 VariableName,
45 VendorGuid,
46 Attributes OPTIONAL,
47 DataSize,
48 Data,
49 &mVariableModuleGlobal->VariableGlobal[Physical],
50 mVariableModuleGlobal->FvbInstance
51 );
52 }
53
54 EFI_STATUS
55 EFIAPI
56 RuntimeServiceGetNextVariableName (
57 IN OUT UINTN *VariableNameSize,
58 IN OUT CHAR16 *VariableName,
59 IN OUT EFI_GUID *VendorGuid
60 )
61 /*++
62
63 Routine Description:
64
65 Arguments:
66
67 Returns:
68
69 --*/
70 {
71 return GetNextVariableName (
72 VariableNameSize,
73 VariableName,
74 VendorGuid,
75 &mVariableModuleGlobal->VariableGlobal[Physical],
76 mVariableModuleGlobal->FvbInstance
77 );
78 }
79
80 EFI_STATUS
81 EFIAPI
82 RuntimeServiceSetVariable (
83 IN CHAR16 *VariableName,
84 IN EFI_GUID *VendorGuid,
85 IN UINT32 Attributes,
86 IN UINTN DataSize,
87 IN VOID *Data
88 )
89 /*++
90
91 Routine Description:
92
93 Arguments:
94
95 Returns:
96
97 --*/
98 {
99 return SetVariable (
100 VariableName,
101 VendorGuid,
102 Attributes,
103 DataSize,
104 Data,
105 &mVariableModuleGlobal->VariableGlobal[Physical],
106 &mVariableModuleGlobal->VolatileLastVariableOffset,
107 &mVariableModuleGlobal->NonVolatileLastVariableOffset,
108 mVariableModuleGlobal->FvbInstance
109 );
110 }
111
112 EFI_STATUS
113 EFIAPI
114 RuntimeServiceQueryVariableInfo (
115 IN UINT32 Attributes,
116 OUT UINT64 *MaximumVariableStorageSize,
117 OUT UINT64 *RemainingVariableStorageSize,
118 OUT UINT64 *MaximumVariableSize
119 )
120 /*++
121
122 Routine Description:
123
124 Arguments:
125
126 Returns:
127
128 --*/
129 {
130 return QueryVariableInfo (
131 Attributes,
132 MaximumVariableStorageSize,
133 RemainingVariableStorageSize,
134 MaximumVariableSize,
135 &mVariableModuleGlobal->VariableGlobal[Physical],
136 mVariableModuleGlobal->FvbInstance
137 );
138 }
139
140 VOID
141 EFIAPI
142 VariableClassAddressChangeEvent (
143 IN EFI_EVENT Event,
144 IN VOID *Context
145 )
146 /*++
147
148 Routine Description:
149
150 Arguments:
151
152 Returns:
153
154 --*/
155 {
156 EfiConvertPointer (
157 0x0,
158 (VOID **) &mVariableModuleGlobal->VariableGlobal[Physical].NonVolatileVariableBase
159 );
160 EfiConvertPointer (
161 0x0,
162 (VOID **) &mVariableModuleGlobal->VariableGlobal[Physical].VolatileVariableBase
163 );
164 EfiConvertPointer (0x0, (VOID **) &mVariableModuleGlobal);
165 }
166
167 EFI_STATUS
168 EFIAPI
169 VariableServiceInitialize (
170 IN EFI_HANDLE ImageHandle,
171 IN EFI_SYSTEM_TABLE *SystemTable
172 )
173 /*++
174
175 Routine Description:
176
177 Arguments:
178
179 Returns:
180
181 --*/
182 {
183 EFI_HANDLE NewHandle;
184 EFI_STATUS Status;
185
186 Status = VariableCommonInitialize (ImageHandle, SystemTable);
187 ASSERT_EFI_ERROR (Status);
188
189 SystemTable->RuntimeServices->GetVariable = RuntimeServiceGetVariable;
190 SystemTable->RuntimeServices->GetNextVariableName = RuntimeServiceGetNextVariableName;
191 SystemTable->RuntimeServices->SetVariable = RuntimeServiceSetVariable;
192 SystemTable->RuntimeServices->QueryVariableInfo = RuntimeServiceQueryVariableInfo;
193
194 //
195 // Now install the Variable Runtime Architectural Protocol on a new handle
196 //
197 NewHandle = NULL;
198 Status = gBS->InstallMultipleProtocolInterfaces (
199 &NewHandle,
200 &gEfiVariableArchProtocolGuid,
201 NULL,
202 &gEfiVariableWriteArchProtocolGuid,
203 NULL,
204 NULL
205 );
206 ASSERT_EFI_ERROR (Status);
207
208 return EFI_SUCCESS;
209 }