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