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