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