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