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