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