]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/UefiRuntimeLib/RuntimeService.c
Fixed comments to follow coding standard.
[mirror_edk2.git] / MdePkg / Library / UefiRuntimeLib / RuntimeService.c
1 /** @file
2 UEFI Runtime Library implementation for non IPF processor types.
3
4 This library hides the global variable for the EFI Runtime Services so the
5 caller does not need to deal with the possiblitly of being called from an
6 OS virtual address space. All pointer values are different for a virtual
7 mapping than from the normal physical mapping at boot services time.
8
9 Copyright (c) 2006 - 2007, Intel Corporation.<BR>
10 All rights reserved. This program and the accompanying materials
11 are licensed and made available under the terms and conditions of the BSD License
12 which accompanies this distribution. The full text of the license may be found at
13 http://opensource.org/licenses/bsd-license.php
14
15 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
16 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17
18 **/
19
20 #include <PiDxe.h>
21
22 #include <RuntimeLibInternal.h>
23
24
25 /**
26 Resets the entire platform.
27
28 @param ResetType The type of reset to perform.
29 @param ResetStatus The status code for reset.
30 @param DataSize The size in bytes of reset data.
31 @param ResetData Pointer to data buffer that includes
32 Null-Terminated Unicode string.
33
34 **/
35 VOID
36 EFIAPI
37 EfiResetSystem (
38 IN EFI_RESET_TYPE ResetType,
39 IN EFI_STATUS ResetStatus,
40 IN UINTN DataSize,
41 IN CHAR16 *ResetData
42 )
43 {
44 mRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);
45 }
46
47
48 /**
49 Return current time and date information, and time-keeping
50 capabilities of hardware platform.
51
52 @param Time A pointer to storage to receive a snapshot of the current time.
53 @param Capabilities An optional pointer to a buffer to receive the real time clock device's
54 capabilities.
55
56 @retval EFI_SUCCESS Success to execute the function.
57 @retval !EFI_SUCCESS Failed to e3xecute the function.
58
59 **/
60 EFI_STATUS
61 EFIAPI
62 EfiGetTime (
63 OUT EFI_TIME *Time,
64 OUT EFI_TIME_CAPABILITIES *Capabilities
65 )
66 {
67 return mRT->GetTime (Time, Capabilities);
68 }
69
70
71 /**
72 Set current time and date information.
73
74 @param Time A pointer to cache of time setting.
75
76 @retval EFI_SUCCESS Success to execute the function.
77 @retval !EFI_SUCCESS Failed to execute the function.
78
79 **/
80 EFI_STATUS
81 EFIAPI
82 EfiSetTime (
83 IN EFI_TIME *Time
84 )
85 {
86 return mRT->SetTime (Time);
87 }
88
89
90 /**
91 Return current wakeup alarm clock setting.
92
93 @param Enabled Indicate if the alarm clock is enabled or disabled.
94 @param Pending Indicate if the alarm signal is pending and requires acknowledgement.
95 @param Time Current alarm clock setting.
96
97 @retval EFI_SUCCESS Success to execute the function.
98 @retval !EFI_SUCCESS Failed to e3xecute the function.
99
100 **/
101 EFI_STATUS
102 EFIAPI
103 EfiGetWakeupTime (
104 OUT BOOLEAN *Enabled,
105 OUT BOOLEAN *Pending,
106 OUT EFI_TIME *Time
107 )
108 {
109 return mRT->GetWakeupTime (Enabled, Pending, Time);
110 }
111
112
113
114 /**
115 Set current wakeup alarm clock.
116
117 @param Enable Enable or disable current alarm clock..
118 @param Time Point to alarm clock setting.
119
120 @retval EFI_SUCCESS Success to execute the function.
121 @retval !EFI_SUCCESS Failed to e3xecute the function.
122
123 **/
124 EFI_STATUS
125 EFIAPI
126 EfiSetWakeupTime (
127 IN BOOLEAN Enable,
128 IN EFI_TIME *Time
129 )
130 {
131 return mRT->SetWakeupTime (Enable, Time);
132 }
133
134
135 /**
136 Return value of variable.
137
138 @param VariableName the name of the vendor's variable, it's a
139 Null-Terminated Unicode String
140 @param VendorGuid Unify identifier for vendor.
141 @param Attributes Point to memory location to return the attributes of variable. If the point
142 is NULL, the parameter would be ignored.
143 @param DataSize As input, point to the maxinum size of return Data-Buffer.
144 As output, point to the actual size of the returned Data-Buffer.
145 @param Data Point to return Data-Buffer.
146
147 @retval EFI_SUCCESS Success to execute the function.
148 @retval !EFI_SUCCESS Failed to e3xecute the function.
149
150 **/
151 EFI_STATUS
152 EFIAPI
153 EfiGetVariable (
154 IN CHAR16 *VariableName,
155 IN EFI_GUID * VendorGuid,
156 OUT UINT32 *Attributes OPTIONAL,
157 IN OUT UINTN *DataSize,
158 OUT VOID *Data
159 )
160 {
161 return mRT->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);
162 }
163
164
165 /**
166 Enumerates variable's name.
167
168 @param VariableNameSize As input, point to maxinum size of variable name.
169 As output, point to actual size of varaible name.
170 @param VariableName As input, supplies the last VariableName that was returned by
171 GetNextVariableName().
172 As output, returns the name of variable. The name
173 string is Null-Terminated Unicode string.
174 @param VendorGuid As input, supplies the last VendorGuid that was returned by
175 GetNextVriableName().
176 As output, returns the VendorGuid of the current variable.
177
178 @retval EFI_SUCCESS Success to execute the function.
179 @retval !EFI_SUCCESS Failed to e3xecute the function.
180
181 **/
182 EFI_STATUS
183 EFIAPI
184 EfiGetNextVariableName (
185 IN OUT UINTN *VariableNameSize,
186 IN OUT CHAR16 *VariableName,
187 IN OUT EFI_GUID *VendorGuid
188 )
189 {
190 return mRT->GetNextVariableName (VariableNameSize, VariableName, VendorGuid);
191 }
192
193
194 /**
195 Sets value of variable.
196
197 @param VariableName the name of the vendor's variable, it's a
198 Null-Terminated Unicode String
199 @param VendorGuid Unify identifier for vendor.
200 @param Attributes Point to memory location to return the attributes of variable. If the point
201 is NULL, the parameter would be ignored.
202 @param DataSize The size in bytes of Data-Buffer.
203 @param Data Point to the content of the variable.
204
205 @retval EFI_SUCCESS Success to execute the function.
206 @retval !EFI_SUCCESS Failed to e3xecute the function.
207
208 **/
209 EFI_STATUS
210 EFIAPI
211 EfiSetVariable (
212 IN CHAR16 *VariableName,
213 IN EFI_GUID *VendorGuid,
214 IN UINT32 Attributes,
215 IN UINTN DataSize,
216 IN VOID *Data
217 )
218 {
219 return mRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);
220 }
221
222
223 /**
224 Returns the next high 32 bits of platform's monotonic counter.
225
226 @param HighCount Pointer to returned value.
227
228 @retval EFI_SUCCESS Success to execute the function.
229 @retval !EFI_SUCCESS Failed to e3xecute the function.
230
231 **/
232 EFI_STATUS
233 EFIAPI
234 EfiGetNextHighMonotonicCount (
235 OUT UINT32 *HighCount
236 )
237 {
238 return mRT->GetNextHighMonotonicCount (HighCount);
239 }
240
241
242 /**
243 Determines the new virtual address that is to be used on subsequent memory accesses.
244
245 @param DebugDisposition Supplies type information for the pointer being converted.
246 @param Address The pointer to a pointer that is to be fixed to be the
247 value needed for the new virtual address mapping being
248 applied.
249
250 @retval EFI_SUCCESS Success to execute the function.
251 @retval !EFI_SUCCESS Failed to e3xecute the function.
252
253 **/
254 EFI_STATUS
255 EFIAPI
256 EfiConvertPointer (
257 IN UINTN DebugDisposition,
258 IN OUT VOID **Address
259 )
260 {
261 return mRT->ConvertPointer (DebugDisposition, Address);
262 }
263
264
265 /**
266 Conver the standard Lib double linked list to a virtual mapping.
267
268 @param DebugDisposition Supplies type information for the pointer being converted.
269 @param ListHead Head of linked list to convert.
270
271 @retval EFI_SUCCESS Success to execute the function.
272 @retval !EFI_SUCCESS Failed to e3xecute the function.
273
274 **/
275 EFI_STATUS
276 EFIAPI
277 EfiConvertList (
278 IN UINTN DebugDisposition,
279 IN OUT LIST_ENTRY *ListHead
280 )
281 {
282 LIST_ENTRY *Link;
283 LIST_ENTRY *NextLink;
284
285 //
286 // Convert all the ForwardLink & BackLink pointers in the list
287 //
288 Link = ListHead;
289 do {
290 NextLink = Link->ForwardLink;
291
292 EfiConvertPointer (
293 Link->ForwardLink == ListHead ? DebugDisposition : 0,
294 (VOID **) &Link->ForwardLink
295 );
296
297 EfiConvertPointer (
298 Link->BackLink == ListHead ? DebugDisposition : 0,
299 (VOID **) &Link->BackLink
300 );
301
302 Link = NextLink;
303 } while (Link != ListHead);
304 return EFI_SUCCESS;
305 }
306
307
308 /**
309 Change the runtime addressing mode of EFI firmware from physical to virtual.
310
311 @param MemoryMapSize The size in bytes of VirtualMap.
312 @param DescriptorSize The size in bytes of an entry in the VirtualMap.
313 @param DescriptorVersion The version of the structure entries in VirtualMap.
314 @param VirtualMap An array of memory descriptors which contain new virtual
315 address mapping information for all runtime ranges. Type
316 EFI_MEMORY_DESCRIPTOR is defined in the
317 GetMemoryMap() function description.
318
319 @retval EFI_SUCCESS The virtual address map has been applied.
320 @retval EFI_UNSUPPORTED EFI firmware is not at runtime, or the EFI firmware is already in
321 virtual address mapped mode.
322 @retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is
323 invalid.
324 @retval EFI_NO_MAPPING A virtual address was not supplied for a range in the memory
325 map that requires a mapping.
326 @retval EFI_NOT_FOUND A virtual address was supplied for an address that is not found
327 in the memory map.
328 **/
329 EFI_STATUS
330 EFIAPI
331 EfiSetVirtualAddressMap (
332 IN UINTN MemoryMapSize,
333 IN UINTN DescriptorSize,
334 IN UINT32 DescriptorVersion,
335 IN CONST EFI_MEMORY_DESCRIPTOR *VirtualMap
336 )
337 {
338 return mRT->SetVirtualAddressMap (
339 MemoryMapSize,
340 DescriptorSize,
341 DescriptorVersion,
342 (EFI_MEMORY_DESCRIPTOR *) VirtualMap
343 );
344 }
345
346
347 /**
348 Passes capsules to the firmware with both virtual and physical mapping.
349 Depending on the intended consumption, the firmware may
350 process the capsule immediately. If the payload should persist across a
351 system reset, the reset value returned from EFI_QueryCapsuleCapabilities must
352 be passed into ResetSystem() and will cause the capsule to be processed by
353 the firmware as part of the reset process.
354
355 @param CapsuleHeaderArray Virtual pointer to an array of virtual pointers to the capsules
356 being passed into update capsule. Each capsules is assumed to
357 stored in contiguous virtual memory. The capsules in the
358 CapsuleHeaderArray must be the same capsules as the
359 ScatterGatherList. The CapsuleHeaderArray must
360 have the capsules in the same order as the ScatterGatherList.
361 @param CapsuleCount Number of pointers to EFI_CAPSULE_HEADER in
362 CaspuleHeaderArray.
363 @param ScatterGatherList Physical pointer to a set of
364 EFI_CAPSULE_BLOCK_DESCRIPTOR that describes the
365 location in physical memory of a set of capsules. See Related
366 Definitions for an explanation of how more than one capsule is
367 passed via this interface. The capsules in the
368 ScatterGatherList must be in the same order as the
369 CapsuleHeaderArray. This parameter is only referenced if
370 the capsules are defined to persist across system reset.
371
372 @retval EFI_SUCCESS Valid capsule was passed. I Valid capsule was passed. If
373 CAPSULE_FLAGS_PERSIT_ACROSS_RESET is not set, the
374 capsule has been successfully processed by the firmware.
375 @retval EFI_INVALID_PARAMETER CapsuleSize is NULL or ResetTye is NULL.
376 @retval EFI_DEVICE_ERROR The capsule update was started, but failed due to a device error.
377
378 **/
379 EFI_STATUS
380 EFIAPI
381 EfiUpdateCapsule (
382 IN EFI_CAPSULE_HEADER **CapsuleHeaderArray,
383 IN UINTN CapsuleCount,
384 IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL
385 )
386 {
387 return mRT->UpdateCapsule (
388 CapsuleHeaderArray,
389 CapsuleCount,
390 ScatterGatherList
391 );
392 }
393
394
395 /**
396 The QueryCapsuleCapabilities() function allows a caller to test to see if a capsule or
397 capsules can be updated via UpdateCapsule(). The Flags values in the capsule header and
398 size of the entire capsule is checked.
399 If the caller needs to query for generic capsule capability a fake EFI_CAPSULE_HEADER can be
400 constructed where CapsuleImageSize is equal to HeaderSize that is equal to sizeof
401 (EFI_CAPSULE_HEADER). To determine reset requirements,
402 CAPSULE_FLAGS_PERSIST_ACROSS_RESET should be set in the Flags field of the
403 EFI_CAPSULE_HEADER.
404 The firmware must support any capsule that has the
405 CAPSULE_FLAGS_PERSIST_ACROSS_RESET flag set in EFI_CAPSULE_HEADER. The
406 firmware sets the policy for what capsules are supported that do not have the
407 CAPSULE_FLAGS_PERSIST_ACROSS_RESET flag set.
408
409 @param CapsuleHeaderArray Virtual pointer to an array of virtual pointers to the capsules
410 being passed into update capsule. The capsules are assumed to
411 stored in contiguous virtual memory.
412 @param CapsuleCount Number of pointers to EFI_CAPSULE_HEADER in
413 CaspuleHeaderArray.
414 @param MaxiumCapsuleSize On output the maximum size that UpdateCapsule() can
415 support as an argument to UpdateCapsule() via
416 CapsuleHeaderArray and ScatterGatherList.
417 Undefined on input.
418 @param ResetType Returns the type of reset required for the capsule update.
419
420 @retval EFI_SUCCESS Valid answer returned..
421 @retval EFI_INVALID_PARAMETER MaximumCapsuleSize is NULL.
422 @retval EFI_UNSUPPORTED The capsule type is not supported on this platform, and
423 MaximumCapsuleSize and ResetType are undefined.
424
425 **/
426 EFI_STATUS
427 EFIAPI
428 EfiQueryCapsuleCapabilities (
429 IN EFI_CAPSULE_HEADER **CapsuleHeaderArray,
430 IN UINTN CapsuleCount,
431 OUT UINT64 *MaximumCapsuleSize,
432 OUT EFI_RESET_TYPE *ResetType
433 )
434 {
435 return mRT->QueryCapsuleCapabilities (
436 CapsuleHeaderArray,
437 CapsuleCount,
438 MaximumCapsuleSize,
439 ResetType
440 );
441 }
442
443
444 /**
445 The QueryVariableInfo() function allows a caller to obtain the information about the
446 maximum size of the storage space available for the EFI variables, the remaining size of the storage
447 space available for the EFI variables and the maximum size of each individual EFI variable,
448 associated with the attributes specified.
449 The returned MaximumVariableStorageSize, RemainingVariableStorageSize,
450 MaximumVariableSize information may change immediately after the call based on other
451 runtime activities including asynchronous error events. Also, these values associated with different
452 attributes are not additive in nature.
453
454 @param Attributes Attributes bitmask to specify the type of variables on
455 which to return information. Refer to the
456 GetVariable() function description.
457 @param MaximumVariableStorageSize
458 On output the maximum size of the storage space
459 available for the EFI variables associated with the
460 attributes specified.
461 @param RemainingVariableStorageSize
462 Returns the remaining size of the storage space
463 available for the EFI variables associated with the
464 attributes specified..
465 @param MaximumVariableSize Returns the maximum size of the individual EFI
466 variables associated with the attributes specified.
467
468 @retval EFI_SUCCESS Valid answer returned.
469 @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied.
470 @retval EFI_UNSUPPORTED EFI_UNSUPPORTED The attribute is not supported on this platform, and the
471 MaximumVariableStorageSize,
472 RemainingVariableStorageSize, MaximumVariableSize
473 are undefined.
474 **/
475 EFI_STATUS
476 EFIAPI
477 EfiQueryVariableInfo (
478 IN UINT32 Attributes,
479 OUT UINT64 *MaximumVariableStorageSize,
480 OUT UINT64 *RemainingVariableStorageSize,
481 OUT UINT64 *MaximumVariableSize
482 )
483 {
484 return mRT->QueryVariableInfo (
485 Attributes,
486 MaximumVariableStorageSize,
487 RemainingVariableStorageSize,
488 MaximumVariableSize
489 );
490 }