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