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