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