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