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