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