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