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