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