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