]>
Commit | Line | Data |
---|---|---|
3eb9473e | 1 | /*++\r |
2 | \r | |
bdabfae7 | 3 | Copyright (c) 2005 - 2008, Intel Corporation \r |
3eb9473e | 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 | RuntimeLib.c\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | Light weight lib to support Tiano drivers.\r | |
19 | \r | |
20 | --*/\r | |
21 | \r | |
22 | #include "Tiano.h"\r | |
23 | #include "EfiRuntimeLib.h"\r | |
24 | #include EFI_PROTOCOL_DEFINITION (CpuIo)\r | |
25 | #include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)\r | |
26 | #include EFI_GUID_DEFINITION (StatusCodeCallerId)\r | |
27 | #include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)\r | |
28 | \r | |
29 | //\r | |
30 | // Driver Lib Module Globals\r | |
31 | //\r | |
32 | static EFI_RUNTIME_SERVICES *mRT;\r | |
33 | static EFI_EVENT mRuntimeNotifyEvent = NULL;\r | |
34 | static EFI_EVENT mEfiVirtualNotifyEvent = NULL;\r | |
35 | static BOOLEAN mRuntimeLibInitialized = FALSE;\r | |
36 | static BOOLEAN mEfiGoneVirtual = FALSE;\r | |
37 | \r | |
38 | //\r | |
39 | // Runtime Global, but you should use the Lib functions\r | |
40 | //\r | |
41 | EFI_CPU_IO_PROTOCOL *gCpuIo;\r | |
42 | BOOLEAN mEfiAtRuntime = FALSE;\r | |
43 | FVB_ENTRY *mFvbEntry;\r | |
44 | \r | |
3eb9473e | 45 | static EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL;\r |
3eb9473e | 46 | \r |
47 | EFI_STATUS\r | |
48 | EfiConvertPointer (\r | |
49 | IN UINTN DebugDisposition,\r | |
50 | IN OUT VOID *Address\r | |
51 | )\r | |
52 | /*++\r | |
53 | \r | |
54 | Routine Description:\r | |
55 | \r | |
56 | Determines the new virtual address that is to be used on subsequent memory accesses.\r | |
57 | \r | |
58 | Arguments:\r | |
59 | \r | |
60 | DebugDisposition - Supplies type information for the pointer being converted.\r | |
61 | Address - A pointer to a pointer that is to be fixed to be the value needed\r | |
62 | for the new virtual address mappings being applied.\r | |
63 | \r | |
64 | Returns:\r | |
65 | \r | |
66 | Status code\r | |
67 | \r | |
68 | --*/\r | |
69 | {\r | |
70 | return mRT->ConvertPointer (DebugDisposition, Address);\r | |
71 | }\r | |
72 | \r | |
73 | EFI_STATUS\r | |
74 | EfiConvertInternalPointer (\r | |
75 | IN OUT VOID *Address\r | |
76 | )\r | |
77 | /*++\r | |
78 | \r | |
79 | Routine Description:\r | |
80 | \r | |
81 | Call EfiConvertPointer() to convert internal pointer.\r | |
82 | \r | |
83 | Arguments:\r | |
84 | \r | |
85 | Address - A pointer to a pointer that is to be fixed to be the value needed\r | |
86 | for the new virtual address mappings being applied.\r | |
87 | \r | |
88 | Returns:\r | |
89 | \r | |
90 | Status code\r | |
91 | \r | |
92 | --*/\r | |
93 | {\r | |
94 | return EfiConvertPointer (EFI_INTERNAL_POINTER, Address);\r | |
95 | }\r | |
96 | \r | |
97 | VOID\r | |
98 | EFIAPI\r | |
99 | EfiRuntimeLibFvbVirtualNotifyEvent (\r | |
100 | IN EFI_EVENT Event,\r | |
101 | IN VOID *Context\r | |
102 | )\r | |
103 | /*++\r | |
104 | \r | |
105 | Routine Description:\r | |
106 | \r | |
107 | Convert all pointers in mFvbEntry after ExitBootServices.\r | |
108 | \r | |
109 | Arguments:\r | |
110 | \r | |
111 | Event - The Event that is being processed\r | |
112 | \r | |
113 | Context - Event Context\r | |
114 | \r | |
115 | Returns:\r | |
116 | \r | |
117 | None\r | |
118 | \r | |
119 | --*/\r | |
120 | {\r | |
121 | UINTN Index;\r | |
122 | if (mFvbEntry != NULL) {\r | |
123 | for (Index = 0; Index < MAX_FVB_COUNT; Index++) {\r | |
124 | if (NULL != mFvbEntry[Index].Fvb) {\r | |
125 | EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetBlockSize);\r | |
126 | EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetPhysicalAddress);\r | |
127 | EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetVolumeAttributes);\r | |
128 | EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->SetVolumeAttributes);\r | |
129 | EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->Read);\r | |
130 | EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->Write);\r | |
131 | EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->EraseBlocks);\r | |
132 | EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb);\r | |
133 | }\r | |
134 | \r | |
135 | if (NULL != mFvbEntry[Index].FvbExtension) {\r | |
136 | EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].FvbExtension->EraseFvbCustomBlock);\r | |
137 | EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].FvbExtension);\r | |
138 | }\r | |
139 | }\r | |
140 | \r | |
141 | EfiConvertInternalPointer ((VOID **) &mFvbEntry);\r | |
142 | }\r | |
143 | }\r | |
144 | \r | |
145 | VOID\r | |
146 | EFIAPI\r | |
147 | RuntimeDriverExitBootServices (\r | |
148 | IN EFI_EVENT Event,\r | |
149 | IN VOID *Context\r | |
150 | )\r | |
151 | /*++\r | |
152 | \r | |
153 | Routine Description:\r | |
154 | \r | |
155 | Set AtRuntime flag as TRUE after ExitBootServices\r | |
156 | \r | |
157 | Arguments:\r | |
158 | \r | |
159 | Event - The Event that is being processed\r | |
160 | \r | |
161 | Context - Event Context\r | |
162 | \r | |
163 | Returns: \r | |
164 | \r | |
165 | None\r | |
166 | \r | |
167 | --*/\r | |
168 | {\r | |
169 | mEfiAtRuntime = TRUE;\r | |
170 | }\r | |
171 | \r | |
172 | extern BOOLEAN gEfiFvbInitialized;\r | |
173 | \r | |
174 | VOID\r | |
175 | EFIAPI\r | |
176 | EfiRuntimeLibVirtualNotifyEvent (\r | |
177 | IN EFI_EVENT Event,\r | |
178 | IN VOID *Context\r | |
179 | )\r | |
180 | /*++\r | |
181 | \r | |
182 | Routine Description:\r | |
183 | \r | |
184 | Fixup internal data so that EFI can be call in virtual mode.\r | |
185 | Call the passed in Child Notify event and convert any pointers in \r | |
186 | lib to virtual mode.\r | |
187 | \r | |
188 | Arguments:\r | |
189 | \r | |
190 | Event - The Event that is being processed\r | |
191 | \r | |
192 | Context - Event Context\r | |
193 | \r | |
194 | Returns: \r | |
195 | \r | |
196 | None\r | |
197 | \r | |
198 | --*/\r | |
199 | {\r | |
200 | EFI_EVENT_NOTIFY ChildNotifyEventHandler;\r | |
201 | \r | |
202 | if (Context != NULL) {\r | |
203 | ChildNotifyEventHandler = (EFI_EVENT_NOTIFY) (UINTN) Context;\r | |
204 | ChildNotifyEventHandler (Event, NULL);\r | |
205 | }\r | |
206 | \r | |
207 | if (gEfiFvbInitialized) {\r | |
208 | EfiRuntimeLibFvbVirtualNotifyEvent (Event, Context);\r | |
209 | }\r | |
210 | //\r | |
211 | // Update global for Runtime Services Table and IO\r | |
212 | //\r | |
213 | EfiConvertInternalPointer ((VOID **) &gCpuIo);\r | |
3eb9473e | 214 | if (gStatusCode != NULL) {\r |
215 | EfiConvertInternalPointer ((VOID **) &gStatusCode->ReportStatusCode);\r | |
216 | EfiConvertInternalPointer ((VOID **) &gStatusCode);\r | |
217 | }\r | |
3eb9473e | 218 | EfiConvertInternalPointer ((VOID **) &mRT);\r |
219 | \r | |
220 | //\r | |
221 | // Clear out BootService globals\r | |
222 | //\r | |
223 | gBS = NULL;\r | |
224 | gST = NULL;\r | |
225 | mEfiGoneVirtual = TRUE;\r | |
226 | }\r | |
227 | \r | |
228 | EFI_STATUS\r | |
229 | EfiInitializeRuntimeDriverLib (\r | |
230 | IN EFI_HANDLE ImageHandle,\r | |
231 | IN EFI_SYSTEM_TABLE *SystemTable,\r | |
232 | IN EFI_EVENT_NOTIFY GoVirtualChildEvent\r | |
233 | )\r | |
234 | /*++\r | |
235 | \r | |
236 | Routine Description:\r | |
237 | \r | |
238 | Intialize runtime Driver Lib if it has not yet been initialized. \r | |
239 | \r | |
240 | Arguments:\r | |
241 | \r | |
242 | ImageHandle - The firmware allocated handle for the EFI image.\r | |
243 | \r | |
244 | SystemTable - A pointer to the EFI System Table.\r | |
245 | \r | |
246 | GoVirtualChildEvent - Caller can register a virtual notification event.\r | |
247 | \r | |
248 | Returns: \r | |
249 | \r | |
250 | EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.\r | |
251 | \r | |
252 | --*/\r | |
253 | {\r | |
254 | EFI_STATUS Status;\r | |
255 | \r | |
256 | if (mRuntimeLibInitialized) {\r | |
257 | return EFI_ALREADY_STARTED;\r | |
258 | }\r | |
259 | \r | |
260 | mRuntimeLibInitialized = TRUE;\r | |
261 | \r | |
262 | gST = SystemTable;\r | |
263 | ASSERT (gST != NULL);\r | |
264 | \r | |
265 | gBS = SystemTable->BootServices;\r | |
266 | ASSERT (gBS != NULL);\r | |
267 | mRT = SystemTable->RuntimeServices;\r | |
268 | ASSERT (mRT != NULL);\r | |
269 | \r | |
270 | Status = EfiLibGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);\r | |
271 | ASSERT_EFI_ERROR (Status);\r | |
272 | \r | |
3eb9473e | 273 | Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);\r |
274 | if (EFI_ERROR (Status)) {\r | |
275 | gStatusCode = NULL;\r | |
276 | }\r | |
3eb9473e | 277 | \r |
4b79797e | 278 | Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);\r |
3eb9473e | 279 | if (EFI_ERROR (Status)) {\r |
280 | gCpuIo = NULL;\r | |
281 | }\r | |
282 | \r | |
283 | //\r | |
284 | // Register our ExitBootServices () notify function\r | |
285 | //\r | |
286 | Status = gBS->CreateEvent (\r | |
287 | EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES,\r | |
288 | EFI_TPL_NOTIFY,\r | |
289 | RuntimeDriverExitBootServices,\r | |
290 | NULL,\r | |
291 | &mRuntimeNotifyEvent\r | |
292 | );\r | |
293 | ASSERT_EFI_ERROR (Status);\r | |
294 | \r | |
295 | //\r | |
296 | // Register SetVirtualAddressMap () notify function\r | |
297 | //\r | |
298 | Status = gBS->CreateEvent (\r | |
299 | EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,\r | |
300 | EFI_TPL_NOTIFY,\r | |
301 | EfiRuntimeLibVirtualNotifyEvent,\r | |
302 | (VOID *) (UINTN) GoVirtualChildEvent,\r | |
303 | &mEfiVirtualNotifyEvent\r | |
304 | );\r | |
305 | ASSERT_EFI_ERROR (Status);\r | |
306 | \r | |
307 | return EFI_SUCCESS;\r | |
308 | }\r | |
309 | \r | |
310 | EFI_STATUS\r | |
311 | EfiShutdownRuntimeDriverLib (\r | |
312 | VOID\r | |
313 | )\r | |
314 | /*++\r | |
315 | \r | |
316 | Routine Description:\r | |
317 | \r | |
318 | This routine will free some resources which have been allocated in\r | |
319 | EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error, \r | |
320 | it must call this routine to free the allocated resource before the exiting.\r | |
321 | \r | |
322 | Arguments:\r | |
323 | \r | |
324 | None\r | |
325 | \r | |
326 | Returns: \r | |
327 | \r | |
328 | EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully\r | |
329 | EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all\r | |
330 | \r | |
331 | --*/\r | |
332 | {\r | |
333 | EFI_STATUS Status;\r | |
334 | \r | |
335 | if (!mRuntimeLibInitialized) {\r | |
336 | //\r | |
337 | // You must call EfiInitializeRuntimeDriverLib() first\r | |
338 | //\r | |
339 | return EFI_UNSUPPORTED;\r | |
340 | }\r | |
341 | \r | |
342 | mRuntimeLibInitialized = FALSE;\r | |
343 | \r | |
344 | //\r | |
345 | // Close our ExitBootServices () notify function\r | |
346 | //\r | |
347 | if (mRuntimeNotifyEvent != NULL) {\r | |
348 | Status = gBS->CloseEvent (mRuntimeNotifyEvent);\r | |
349 | ASSERT_EFI_ERROR (Status);\r | |
350 | }\r | |
351 | \r | |
352 | //\r | |
353 | // Close SetVirtualAddressMap () notify function\r | |
354 | //\r | |
355 | if (mEfiVirtualNotifyEvent != NULL) {\r | |
356 | Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);\r | |
357 | ASSERT_EFI_ERROR (Status);\r | |
358 | }\r | |
359 | \r | |
360 | return EFI_SUCCESS;\r | |
361 | }\r | |
362 | \r | |
363 | EFI_STATUS\r | |
364 | EfiInitializeSmmDriverLib (\r | |
365 | IN EFI_HANDLE ImageHandle,\r | |
366 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
367 | )\r | |
368 | /*++\r | |
369 | \r | |
370 | Routine Description:\r | |
371 | \r | |
372 | Intialize runtime Driver Lib if it has not yet been initialized. \r | |
373 | \r | |
374 | Arguments:\r | |
375 | \r | |
376 | ImageHandle - The firmware allocated handle for the EFI image.\r | |
377 | \r | |
378 | SystemTable - A pointer to the EFI System Table.\r | |
379 | \r | |
380 | Returns: \r | |
381 | \r | |
382 | EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.\r | |
383 | \r | |
384 | --*/\r | |
385 | {\r | |
386 | EFI_STATUS Status;\r | |
387 | \r | |
388 | if (mRuntimeLibInitialized) {\r | |
389 | return EFI_ALREADY_STARTED;\r | |
390 | }\r | |
391 | \r | |
392 | mRuntimeLibInitialized = TRUE;\r | |
393 | \r | |
394 | gST = SystemTable;\r | |
395 | ASSERT (gST != NULL);\r | |
396 | \r | |
397 | gBS = SystemTable->BootServices;\r | |
398 | ASSERT (gBS != NULL);\r | |
399 | mRT = SystemTable->RuntimeServices;\r | |
400 | ASSERT (mRT != NULL);\r | |
401 | \r | |
3eb9473e | 402 | Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);\r |
403 | if (EFI_ERROR (Status)) {\r | |
404 | gStatusCode = NULL;\r | |
405 | }\r | |
3eb9473e | 406 | \r |
4b79797e | 407 | Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);\r |
3eb9473e | 408 | if (EFI_ERROR (Status)) {\r |
409 | gCpuIo = NULL;\r | |
410 | }\r | |
411 | \r | |
412 | return EFI_SUCCESS;\r | |
413 | }\r | |
414 | \r | |
415 | BOOLEAN\r | |
416 | EfiAtRuntime (\r | |
417 | VOID\r | |
418 | )\r | |
419 | /*++\r | |
420 | \r | |
421 | Routine Description:\r | |
422 | Return TRUE if ExitBootServices () has been called\r | |
423 | \r | |
424 | Arguments:\r | |
425 | NONE\r | |
426 | \r | |
427 | Returns: \r | |
428 | TRUE - If ExitBootServices () has been called\r | |
429 | \r | |
430 | --*/\r | |
431 | {\r | |
432 | return mEfiAtRuntime;\r | |
433 | }\r | |
434 | \r | |
435 | BOOLEAN\r | |
436 | EfiGoneVirtual (\r | |
437 | VOID\r | |
438 | )\r | |
439 | /*++\r | |
440 | \r | |
441 | Routine Description:\r | |
442 | Return TRUE if SetVirtualAddressMap () has been called\r | |
443 | \r | |
444 | Arguments:\r | |
445 | NONE\r | |
446 | \r | |
447 | Returns: \r | |
448 | TRUE - If SetVirtualAddressMap () has been called\r | |
449 | \r | |
450 | --*/\r | |
451 | {\r | |
452 | return mEfiGoneVirtual;\r | |
453 | }\r | |
454 | //\r | |
455 | // The following functions hide the mRT local global from the call to\r | |
456 | // runtime service in the EFI system table.\r | |
457 | //\r | |
458 | EFI_STATUS\r | |
459 | EfiGetTime (\r | |
460 | OUT EFI_TIME *Time,\r | |
461 | OUT EFI_TIME_CAPABILITIES *Capabilities\r | |
462 | )\r | |
463 | /*++\r | |
464 | \r | |
465 | Routine Description:\r | |
466 | \r | |
467 | Returns the current time and date information, and the time-keeping \r | |
468 | capabilities of the hardware platform.\r | |
469 | \r | |
470 | Arguments:\r | |
471 | \r | |
472 | Time - A pointer to storage to receive a snapshot of the current time.\r | |
fd0d281b | 473 | Capabilities - An optional pointer to a buffer to receive the real time clock device's\r |
3eb9473e | 474 | capabilities.\r |
475 | \r | |
476 | Returns:\r | |
477 | \r | |
478 | Status code\r | |
479 | \r | |
480 | --*/\r | |
481 | {\r | |
482 | return mRT->GetTime (Time, Capabilities);\r | |
483 | }\r | |
484 | \r | |
485 | EFI_STATUS\r | |
486 | EfiSetTime (\r | |
487 | IN EFI_TIME *Time\r | |
488 | )\r | |
489 | /*++\r | |
490 | \r | |
491 | Routine Description:\r | |
492 | \r | |
493 | Sets the current local time and date information.\r | |
494 | \r | |
495 | Arguments:\r | |
496 | \r | |
497 | Time - A pointer to the current time.\r | |
498 | \r | |
499 | Returns:\r | |
500 | \r | |
501 | Status code\r | |
502 | \r | |
503 | --*/\r | |
504 | {\r | |
505 | return mRT->SetTime (Time);\r | |
506 | }\r | |
507 | \r | |
508 | EFI_STATUS\r | |
509 | EfiGetWakeupTime (\r | |
510 | OUT BOOLEAN *Enabled,\r | |
511 | OUT BOOLEAN *Pending,\r | |
512 | OUT EFI_TIME *Time\r | |
513 | )\r | |
514 | /*++\r | |
515 | \r | |
516 | Routine Description:\r | |
517 | \r | |
518 | Returns the current wakeup alarm clock setting.\r | |
519 | \r | |
520 | Arguments:\r | |
521 | \r | |
522 | Enabled - Indicates if the alarm is currently enabled or disabled.\r | |
523 | Pending - Indicates if the alarm signal is pending and requires acknowledgement.\r | |
524 | Time - The current alarm setting.\r | |
525 | \r | |
526 | Returns:\r | |
527 | \r | |
528 | Status code\r | |
529 | \r | |
530 | --*/\r | |
531 | {\r | |
532 | return mRT->GetWakeupTime (Enabled, Pending, Time);\r | |
533 | }\r | |
534 | \r | |
535 | EFI_STATUS\r | |
536 | EfiSetWakeupTime (\r | |
537 | IN BOOLEAN Enable,\r | |
538 | IN EFI_TIME *Time\r | |
539 | )\r | |
540 | /*++\r | |
541 | \r | |
542 | Routine Description:\r | |
543 | \r | |
544 | Sets the system wakeup alarm clock time.\r | |
545 | \r | |
546 | Arguments:\r | |
547 | \r | |
548 | Enable - Enable or disable the wakeup alarm.\r | |
549 | Time - If Enable is TRUE, the time to set the wakeup alarm for.\r | |
550 | If Enable is FALSE, then this parameter is optional, and may be NULL.\r | |
551 | \r | |
552 | Returns:\r | |
553 | \r | |
554 | Status code\r | |
555 | \r | |
556 | --*/\r | |
557 | {\r | |
558 | return mRT->SetWakeupTime (Enable, Time);\r | |
559 | }\r | |
560 | \r | |
561 | EFI_STATUS\r | |
562 | EfiGetVariable (\r | |
563 | IN CHAR16 *VariableName,\r | |
564 | IN EFI_GUID * VendorGuid,\r | |
565 | OUT UINT32 *Attributes OPTIONAL,\r | |
566 | IN OUT UINTN *DataSize,\r | |
567 | OUT VOID *Data\r | |
568 | )\r | |
569 | /*++\r | |
570 | \r | |
571 | Routine Description:\r | |
572 | \r | |
573 | Returns the value of a variable.\r | |
574 | \r | |
575 | Arguments:\r | |
576 | \r | |
577 | VariableName - A Null-terminated Unicode string that is the name of the\r | |
fd0d281b | 578 | vendor's variable.\r |
3eb9473e | 579 | VendorGuid - A unique identifier for the vendor.\r |
580 | Attributes - If not NULL, a pointer to the memory location to return the\r | |
581 | attributes bitmask for the variable.\r | |
582 | DataSize - On input, the size in bytes of the return Data buffer.\r | |
583 | On output the size of data returned in Data.\r | |
584 | Data - The buffer to return the contents of the variable.\r | |
585 | \r | |
586 | Returns:\r | |
587 | \r | |
588 | Status code\r | |
589 | \r | |
590 | --*/\r | |
591 | {\r | |
592 | return mRT->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);\r | |
593 | }\r | |
594 | \r | |
595 | EFI_STATUS\r | |
596 | EfiGetNextVariableName (\r | |
597 | IN OUT UINTN *VariableNameSize,\r | |
598 | IN OUT CHAR16 *VariableName,\r | |
599 | IN OUT EFI_GUID *VendorGuid\r | |
600 | )\r | |
601 | /*++\r | |
602 | \r | |
603 | Routine Description:\r | |
604 | \r | |
605 | Enumerates the current variable names.\r | |
606 | \r | |
607 | Arguments:\r | |
608 | \r | |
609 | VariableNameSize - The size of the VariableName buffer.\r | |
610 | VariableName - On input, supplies the last VariableName that was returned\r | |
611 | by GetNextVariableName(). \r | |
612 | On output, returns the Nullterminated Unicode string of the\r | |
613 | current variable.\r | |
614 | VendorGuid - On input, supplies the last VendorGuid that was returned by\r | |
615 | GetNextVariableName(). \r | |
616 | On output, returns the VendorGuid of the current variable.\r | |
617 | \r | |
618 | Returns:\r | |
619 | \r | |
620 | Status code\r | |
621 | \r | |
622 | --*/\r | |
623 | {\r | |
624 | return mRT->GetNextVariableName (VariableNameSize, VariableName, VendorGuid);\r | |
625 | }\r | |
626 | \r | |
627 | EFI_STATUS\r | |
628 | EfiSetVariable (\r | |
629 | IN CHAR16 *VariableName,\r | |
630 | IN EFI_GUID *VendorGuid,\r | |
631 | IN UINT32 Attributes,\r | |
632 | IN UINTN DataSize,\r | |
633 | IN VOID *Data\r | |
634 | )\r | |
635 | /*++\r | |
636 | \r | |
637 | Routine Description:\r | |
638 | \r | |
639 | Sets the value of a variable.\r | |
640 | \r | |
641 | Arguments:\r | |
642 | \r | |
643 | VariableName - A Null-terminated Unicode string that is the name of the\r | |
fd0d281b | 644 | vendor's variable.\r |
3eb9473e | 645 | VendorGuid - A unique identifier for the vendor.\r |
646 | Attributes - Attributes bitmask to set for the variable.\r | |
647 | DataSize - The size in bytes of the Data buffer.\r | |
648 | Data - The contents for the variable.\r | |
649 | \r | |
650 | Returns:\r | |
651 | \r | |
652 | Status code\r | |
653 | \r | |
654 | --*/\r | |
655 | {\r | |
656 | return mRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);\r | |
657 | }\r | |
658 | \r | |
3eb9473e | 659 | #if (EFI_SPECIFICATION_VERSION >= 0x00020000)\r |
660 | \r | |
661 | EFI_STATUS\r | |
662 | EfiQueryVariableInfo (\r | |
663 | IN UINT32 Attributes,\r | |
664 | OUT UINT64 *MaximumVariableStorageSize,\r | |
665 | OUT UINT64 *RemainingVariableStorageSize,\r | |
666 | OUT UINT64 *MaximumVariableSize\r | |
667 | )\r | |
668 | \r | |
669 | /*++\r | |
670 | \r | |
671 | Routine Description:\r | |
672 | \r | |
673 | This code returns information about the EFI variables.\r | |
674 | \r | |
675 | Arguments:\r | |
676 | \r | |
677 | Attributes Attributes bitmask to specify the type of variables \r | |
678 | on which to return information.\r | |
679 | MaximumVariableStorageSize Pointer to the maximum size of the storage space available\r | |
680 | for the EFI variables associated with the attributes specified.\r | |
681 | RemainingVariableStorageSize Pointer to the remaining size of the storage space available \r | |
682 | for the EFI variables associated with the attributes specified.\r | |
683 | MaximumVariableSize Pointer to the maximum size of the individual EFI variables\r | |
684 | associated with the attributes specified.\r | |
685 | \r | |
686 | Returns:\r | |
687 | \r | |
688 | Status code\r | |
689 | \r | |
690 | --*/\r | |
691 | {\r | |
692 | return mRT->QueryVariableInfo (Attributes, MaximumVariableStorageSize, RemainingVariableStorageSize, MaximumVariableSize);\r | |
693 | }\r | |
694 | \r | |
695 | #endif\r | |
696 | \r | |
bdabfae7 | 697 | \r |
3eb9473e | 698 | EFI_STATUS\r |
699 | EfiGetNextHighMonotonicCount (\r | |
700 | OUT UINT32 *HighCount\r | |
701 | )\r | |
702 | /*++\r | |
703 | \r | |
704 | Routine Description:\r | |
705 | \r | |
fd0d281b | 706 | Returns the next high 32 bits of the platform's monotonic counter.\r |
3eb9473e | 707 | \r |
708 | Arguments:\r | |
709 | \r | |
710 | HighCount - Pointer to returned value.\r | |
711 | \r | |
712 | Returns:\r | |
713 | \r | |
714 | Status code\r | |
715 | \r | |
716 | --*/\r | |
717 | {\r | |
718 | return mRT->GetNextHighMonotonicCount (HighCount);\r | |
719 | }\r | |
720 | \r | |
721 | VOID\r | |
722 | EfiResetSystem (\r | |
723 | IN EFI_RESET_TYPE ResetType,\r | |
724 | IN EFI_STATUS ResetStatus,\r | |
725 | IN UINTN DataSize,\r | |
726 | IN CHAR16 *ResetData\r | |
727 | )\r | |
728 | /*++\r | |
729 | \r | |
730 | Routine Description:\r | |
731 | \r | |
732 | Resets the entire platform.\r | |
733 | \r | |
734 | Arguments:\r | |
735 | \r | |
736 | ResetType - The type of reset to perform.\r | |
737 | ResetStatus - The status code for the reset.\r | |
738 | DataSize - The size, in bytes, of ResetData.\r | |
739 | ResetData - A data buffer that includes a Null-terminated Unicode string, optionally\r | |
740 | followed by additional binary data.\r | |
741 | \r | |
742 | Returns:\r | |
743 | \r | |
744 | None\r | |
745 | \r | |
746 | --*/\r | |
747 | {\r | |
748 | mRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);\r | |
749 | }\r | |
750 | \r | |
751 | EFI_STATUS\r | |
752 | EfiReportStatusCode (\r | |
753 | IN EFI_STATUS_CODE_TYPE CodeType,\r | |
754 | IN EFI_STATUS_CODE_VALUE Value,\r | |
755 | IN UINT32 Instance,\r | |
756 | IN EFI_GUID * CallerId,\r | |
757 | IN EFI_STATUS_CODE_DATA * Data OPTIONAL\r | |
758 | )\r | |
759 | /*++\r | |
760 | \r | |
761 | Routine Description:\r | |
762 | \r | |
763 | Status Code reporter\r | |
764 | \r | |
765 | Arguments:\r | |
766 | \r | |
767 | CodeType - Type of Status Code.\r | |
768 | \r | |
769 | Value - Value to output for Status Code.\r | |
770 | \r | |
771 | Instance - Instance Number of this status code.\r | |
772 | \r | |
773 | CallerId - ID of the caller of this status code.\r | |
774 | \r | |
775 | Data - Optional data associated with this status code.\r | |
776 | \r | |
777 | Returns:\r | |
778 | \r | |
779 | Status code\r | |
780 | \r | |
781 | --*/\r | |
782 | {\r | |
783 | EFI_STATUS Status;\r | |
bdabfae7 | 784 | \r |
3eb9473e | 785 | Status = EFI_UNSUPPORTED;\r |
bdabfae7 LG |
786 | \r |
787 | if (mRT->Hdr.Revision >= 0x00020000) {\r | |
788 | if (gStatusCode == NULL) {\r | |
789 | if (EfiAtRuntime ()) {\r | |
790 | return EFI_UNSUPPORTED;\r | |
791 | }\r | |
792 | Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);\r | |
793 | if (EFI_ERROR (Status) || gStatusCode == NULL) {\r | |
794 | return EFI_UNSUPPORTED;\r | |
795 | }\r | |
796 | }\r | |
797 | Status = gStatusCode->ReportStatusCode (CodeType, Value, Instance, CallerId, Data);\r | |
798 | } else {\r | |
799 | if (mRT == NULL) {\r | |
800 | return EFI_UNSUPPORTED;\r | |
801 | }\r | |
802 | //\r | |
803 | // Check whether EFI_RUNTIME_SERVICES has Tiano Extension\r | |
804 | //\r | |
805 | Status = EFI_UNSUPPORTED;\r | |
806 | #if (EFI_SPECIFICATION_VERSION < 0x00020000)\r | |
807 | if (mRT->Hdr.Revision == EFI_SPECIFICATION_VERSION &&\r | |
808 | mRT->Hdr.HeaderSize == sizeof (EFI_RUNTIME_SERVICES) &&\r | |
809 | mRT->ReportStatusCode != NULL) {\r | |
3eb9473e | 810 | Status = mRT->ReportStatusCode (CodeType, Value, Instance, CallerId, Data);\r |
3eb9473e | 811 | #endif\r |
bdabfae7 LG |
812 | }\r |
813 | }\r | |
3eb9473e | 814 | return Status;\r |
815 | }\r |