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