]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EdkIIGlueLib / Library / EdkDxeRuntimeDriverLib / Common / RuntimeService.c
1 /*++
2
3 Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
4 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
13 Module Name:
14
15 RuntimeService.c
16
17 Abstract:
18
19 Runtime Lib
20
21 --*/
22
23 #include "../RuntimeLibInternal.h"
24
25 VOID
26 EFIAPI
27 EfiResetSystem (
28 IN EFI_RESET_TYPE ResetType,
29 IN EFI_STATUS ResetStatus,
30 IN UINTN DataSize,
31 IN CHAR16 *ResetData
32 )
33 /*++
34
35 Routine Description:
36
37 Resets the entire platform.
38
39 Arguments:
40
41 ResetType - The type of reset to perform.
42 ResetStatus - The status code for the reset.
43 DataSize - The size, in bytes, of ResetData.
44 ResetData - A data buffer that includes a Null-terminated Unicode string, optionally
45 followed by additional binary data.
46
47 Returns:
48
49 None
50
51 --*/
52 {
53 mRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);
54 }
55
56 //
57 // The following functions hide the mRT local global from the call to
58 // runtime service in the EFI system table.
59 //
60 EFI_STATUS
61 EFIAPI
62 EfiGetTime (
63 OUT EFI_TIME *Time,
64 OUT EFI_TIME_CAPABILITIES *Capabilities
65 )
66 /*++
67
68 Routine Description:
69
70 Returns the current time and date information, and the time-keeping
71 capabilities of the hardware platform.
72
73 Arguments:
74
75 Time - A pointer to storage to receive a snapshot of the current time.
76 Capabilities - An optional pointer to a buffer to receive the real time clock device's
77 capabilities.
78
79 Returns:
80
81 Status code
82
83 --*/
84 {
85 return mRT->GetTime (Time, Capabilities);
86 }
87
88 EFI_STATUS
89 EFIAPI
90 EfiSetTime (
91 IN EFI_TIME *Time
92 )
93 /*++
94
95 Routine Description:
96
97 Sets the current local time and date information.
98
99 Arguments:
100
101 Time - A pointer to the current time.
102
103 Returns:
104
105 Status code
106
107 --*/
108 {
109 return mRT->SetTime (Time);
110 }
111
112 EFI_STATUS
113 EFIAPI
114 EfiGetWakeupTime (
115 OUT BOOLEAN *Enabled,
116 OUT BOOLEAN *Pending,
117 OUT EFI_TIME *Time
118 )
119 /*++
120
121 Routine Description:
122
123 Returns the current wakeup alarm clock setting.
124
125 Arguments:
126
127 Enabled - Indicates if the alarm is currently enabled or disabled.
128 Pending - Indicates if the alarm signal is pending and requires acknowledgement.
129 Time - The current alarm setting.
130
131 Returns:
132
133 Status code
134
135 --*/
136 {
137 return mRT->GetWakeupTime (Enabled, Pending, Time);
138 }
139
140 EFI_STATUS
141 EFIAPI
142 EfiSetWakeupTime (
143 IN BOOLEAN Enable,
144 IN EFI_TIME *Time
145 )
146 /*++
147
148 Routine Description:
149
150 Sets the system wakeup alarm clock time.
151
152 Arguments:
153
154 Enable - Enable or disable the wakeup alarm.
155 Time - If Enable is TRUE, the time to set the wakeup alarm for.
156 If Enable is FALSE, then this parameter is optional, and may be NULL.
157
158 Returns:
159
160 Status code
161
162 --*/
163 {
164 return mRT->SetWakeupTime (Enable, Time);
165 }
166
167
168
169
170 EFI_STATUS
171 EFIAPI
172 EfiGetVariable (
173 IN CHAR16 *VariableName,
174 IN EFI_GUID * VendorGuid,
175 OUT UINT32 *Attributes OPTIONAL,
176 IN OUT UINTN *DataSize,
177 OUT VOID *Data
178 )
179 /*++
180
181 Routine Description:
182
183 Returns the value of a variable.
184
185 Arguments:
186
187 VariableName - A Null-terminated Unicode string that is the name of the
188 vendor's variable.
189 VendorGuid - A unique identifier for the vendor.
190 Attributes - If not NULL, a pointer to the memory location to return the
191 attributes bitmask for the variable.
192 DataSize - On input, the size in bytes of the return Data buffer.
193 On output the size of data returned in Data.
194 Data - The buffer to return the contents of the variable.
195
196 Returns:
197
198 Status code
199
200 --*/
201 {
202 return mRT->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);
203 }
204
205 EFI_STATUS
206 EFIAPI
207 EfiGetNextVariableName (
208 IN OUT UINTN *VariableNameSize,
209 IN OUT CHAR16 *VariableName,
210 IN OUT EFI_GUID *VendorGuid
211 )
212 /*++
213
214 Routine Description:
215
216 Enumerates the current variable names.
217
218 Arguments:
219
220 VariableNameSize - The size of the VariableName buffer.
221 VariableName - On input, supplies the last VariableName that was returned
222 by GetNextVariableName().
223 On output, returns the Nullterminated Unicode string of the
224 current variable.
225 VendorGuid - On input, supplies the last VendorGuid that was returned by
226 GetNextVariableName().
227 On output, returns the VendorGuid of the current variable.
228
229 Returns:
230
231 Status code
232
233 --*/
234 {
235 return mRT->GetNextVariableName (VariableNameSize, VariableName, VendorGuid);
236 }
237
238 EFI_STATUS
239 EFIAPI
240 EfiSetVariable (
241 IN CHAR16 *VariableName,
242 IN EFI_GUID *VendorGuid,
243 IN UINT32 Attributes,
244 IN UINTN DataSize,
245 IN VOID *Data
246 )
247 /*++
248
249 Routine Description:
250
251 Sets the value of a variable.
252
253 Arguments:
254
255 VariableName - A Null-terminated Unicode string that is the name of the
256 vendor's variable.
257 VendorGuid - A unique identifier for the vendor.
258 Attributes - Attributes bitmask to set for the variable.
259 DataSize - The size in bytes of the Data buffer.
260 Data - The contents for the variable.
261
262 Returns:
263
264 Status code
265
266 --*/
267 {
268 return mRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);
269 }
270
271 EFI_STATUS
272 EFIAPI
273 EfiGetNextHighMonotonicCount (
274 OUT UINT32 *HighCount
275 )
276 /*++
277
278 Routine Description:
279
280 Returns the next high 32 bits of the platform's monotonic counter.
281
282 Arguments:
283
284 HighCount - Pointer to returned value.
285
286 Returns:
287
288 Status code
289
290 --*/
291 {
292 return mRT->GetNextHighMonotonicCount (HighCount);
293 }
294
295 EFI_STATUS
296 EFIAPI
297 EfiConvertPointer (
298 IN UINTN DebugDisposition,
299 IN OUT VOID **Address
300 )
301 /*++
302
303 Routine Description:
304
305 Determines the new virtual address that is to be used on subsequent memory accesses.
306
307 Arguments:
308
309 DebugDisposition - Supplies type information for the pointer being converted.
310 Address - A pointer to a pointer that is to be fixed to be the value needed
311 for the new virtual address mappings being applied.
312
313 Returns:
314
315 Status code
316
317 --*/
318 {
319 return mRT->ConvertPointer (DebugDisposition, Address);
320 }
321
322 EFI_STATUS
323 EFIAPI
324 EfiConvertList (
325 IN UINTN DebugDisposition,
326 IN OUT LIST_ENTRY *ListHead
327 )
328 /*++
329
330 Routine Description:
331
332 Conver the standard Lib double linked list to a virtual mapping.
333
334 Arguments:
335
336 DebugDisposition - Argument to EfiConvertPointer (EFI 1.0 API)
337
338 ListHead - Head of linked list to convert
339
340 Returns:
341
342 EFI_SUCCESS
343
344 --*/
345 {
346 LIST_ENTRY *Link;
347 LIST_ENTRY *NextLink;
348
349 //
350 // Convert all the ForwardLink & BackLink pointers in the list
351 //
352 Link = ListHead;
353 do {
354 NextLink = Link->ForwardLink;
355
356 EfiConvertPointer (
357 Link->ForwardLink == ListHead ? DebugDisposition : 0,
358 (VOID **) &Link->ForwardLink
359 );
360
361 EfiConvertPointer (
362 Link->BackLink == ListHead ? DebugDisposition : 0,
363 (VOID **) &Link->BackLink
364 );
365
366 Link = NextLink;
367 } while (Link != ListHead);
368 return EFI_SUCCESS;
369 }
370
371
372 /**
373 Change the runtime addressing mode of EFI firmware from physical to virtual.
374
375 @param MemoryMapSize The size in bytes of VirtualMap.
376 @param DescriptorSize The size in bytes of an entry in the VirtualMap.
377 @param DescriptorVersion The version of the structure entries in VirtualMap.
378 @param VirtualMap An array of memory descriptors which contain new virtual
379 address mapping information for all runtime ranges. Type
380 EFI_MEMORY_DESCRIPTOR is defined in the
381 GetMemoryMap() function description.
382
383 @retval EFI_SUCCESS The virtual address map has been applied.
384 @retval EFI_UNSUPPORTED EFI firmware is not at runtime, or the EFI firmware is already in
385 virtual address mapped mode.
386 @retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is
387 invalid.
388 @retval EFI_NO_MAPPING A virtual address was not supplied for a range in the memory
389 map that requires a mapping.
390 @retval EFI_NOT_FOUND A virtual address was supplied for an address that is not found
391 in the memory map.
392 **/
393 EFI_STATUS
394 EFIAPI
395 EfiSetVirtualAddressMap (
396 IN UINTN MemoryMapSize,
397 IN UINTN DescriptorSize,
398 IN UINT32 DescriptorVersion,
399 IN CONST EFI_MEMORY_DESCRIPTOR *VirtualMap
400 )
401 {
402 return mRT->SetVirtualAddressMap (
403 MemoryMapSize,
404 DescriptorSize,
405 DescriptorVersion,
406 (EFI_MEMORY_DESCRIPTOR *) VirtualMap
407 );
408 }
409
410
411 EFI_STATUS
412 EFIAPI
413 EfiUpdateCapsule (
414 IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray,
415 IN UINTN CapsuleCount,
416 IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL
417 )
418 {
419 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
420 return mRT->UpdateCapsule (
421 CapsuleHeaderArray,
422 CapsuleCount,
423 ScatterGatherList
424 );
425 #else
426 return EFI_UNSUPPORTED;
427 #endif
428 }
429
430 EFI_STATUS
431 EFIAPI
432 EfiQueryCapsuleCapabilities (
433 IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray,
434 IN UINTN CapsuleCount,
435 OUT UINT64 *MaximumCapsuleSize,
436 OUT EFI_RESET_TYPE *ResetType
437 )
438 {
439 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
440 return mRT->QueryCapsuleCapabilities (
441 CapsuleHeaderArray,
442 CapsuleCount,
443 MaximumCapsuleSize,
444 ResetType
445 );
446 #else
447 return EFI_UNSUPPORTED;
448 #endif
449 }
450
451
452 EFI_STATUS
453 EFIAPI
454 EfiQueryVariableInfo (
455 IN UINT32 Attributes,
456 OUT UINT64 *MaximumVariableStorageSize,
457 OUT UINT64 *RemainingVariableStorageSize,
458 OUT UINT64 *MaximumVariableSize
459 )
460 {
461 #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
462 return mRT->QueryVariableInfo (
463 Attributes,
464 MaximumVariableStorageSize,
465 RemainingVariableStorageSize,
466 MaximumVariableSize
467 );
468 #else
469 return EFI_UNSUPPORTED;
470 #endif
471 }