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