]>
Commit | Line | Data |
---|---|---|
bf231ea6 A |
1 | /** @file\r |
2 | UEFI Runtime Library implementation for non IPF processor types.\r | |
ebcc8fb7 | 3 | \r |
bf231ea6 A |
4 | This library hides the global variable for the EFI Runtime Services so the\r |
5 | caller does not need to deal with the possiblitly of being called from an\r | |
6 | OS virtual address space. All pointer values are different for a virtual \r | |
7 | mapping than from the normal physical mapping at boot services time.\r | |
ebcc8fb7 | 8 | \r |
60c93673 | 9 | Copyright (c) 2006 - 2008, Intel Corporation.<BR>\r |
bf231ea6 A |
10 | All rights reserved. This program and the accompanying materials \r |
11 | are licensed and made available under the terms and conditions of the BSD License \r | |
12 | which accompanies this distribution. The full text of the license may be found at \r | |
13 | http://opensource.org/licenses/bsd-license.php \r | |
ebcc8fb7 | 14 | \r |
bf231ea6 A |
15 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r |
16 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
17 | \r | |
18 | **/\r | |
ebcc8fb7 | 19 | \r |
60c93673 | 20 | #include "RuntimeLibInternal.h"\r |
ebcc8fb7 | 21 | \r |
bf231ea6 A |
22 | \r |
23 | /**\r | |
cf8ae2f6 | 24 | This service is a wrapper for the UEFI Runtime Service ResetSystem().\r |
25 | \r | |
26 | The ResetSystem()function resets the entire platform, including all processors and devices,and reboots the system.\r | |
27 | Calling this interface with ResetType of EfiResetCold causes a system-wide reset. This sets all circuitry within\r | |
28 | the system to its initial state. This type of reset is asynchronous to system operation and operates without regard\r | |
29 | to cycle boundaries. EfiResetCold is tantamount to a system power cycle.\r | |
30 | Calling this interface with ResetType of EfiResetWarm causes a system-wide initialization. The processors are set to\r | |
31 | their initial state, and pending cycles are not corrupted. If the system does not support this reset type, then an\r | |
32 | EfiResetCold must be performed.\r | |
33 | Calling this interface with ResetType of EfiResetShutdown causes the system to enter a power state equivalent to the\r | |
34 | ACPI G2/S5 or G3 states. If the system does not support this reset type, then when the system is rebooted, it should\r | |
35 | exhibit the EfiResetCold attributes.\r | |
36 | The platform may optionally log the parmeters from any non-normal reset that occurs.\r | |
37 | The ResetSystem() function does not return.\r | |
bf231ea6 A |
38 | \r |
39 | @param ResetType The type of reset to perform.\r | |
cf8ae2f6 | 40 | @param ResetStatus The status code for the reset. If the system reset is part of a normal operation, the status code\r |
41 | would be EFI_SUCCESS. If the system reset is due to some type of failure the most appropriate EFI\r | |
42 | Status code would be used.\r | |
1d37ab9f | 43 | @param DataSizeThe size, in bytes, of ResetData.\r |
cf8ae2f6 | 44 | @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or EfiResetShutdown the data buffer starts with a\r |
45 | Null-terminated Unicode string, optionally followed by additional binary data. The string is a\r | |
46 | description that the caller may use to further indicate the reason for the system reset. ResetData\r | |
47 | is only valid if ResetStatus is something other then EFI_SUCCESS. This pointer must be a physical\r | |
48 | address. For a ResetType of EfiRestUpdate the data buffer also starts with a Null-terminated string\r | |
49 | that is followed by a physical VOID * to an EFI_CAPSULE_HEADER.\r | |
bf231ea6 A |
50 | \r |
51 | **/\r | |
ebcc8fb7 | 52 | VOID\r |
53 | EFIAPI\r | |
54 | EfiResetSystem (\r | |
55 | IN EFI_RESET_TYPE ResetType,\r | |
56 | IN EFI_STATUS ResetStatus,\r | |
57 | IN UINTN DataSize,\r | |
008dfe31 | 58 | IN VOID *ResetData OPTIONAL\r |
ebcc8fb7 | 59 | )\r |
bf231ea6 A |
60 | {\r |
61 | mRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);\r | |
62 | }\r | |
ebcc8fb7 | 63 | \r |
ebcc8fb7 | 64 | \r |
bf231ea6 | 65 | /**\r |
1d37ab9f | 66 | This service is a wrapper for the UEFI Runtime Service GetTime().\r |
67 | \r | |
68 | The GetTime() function returns a time that was valid sometime during the call to the function.\r | |
69 | While the returned EFI_TIME structure contains TimeZone and Daylight savings time information,\r | |
70 | the actual clock does not maintain these values. The current time zone and daylight saving time\r | |
71 | information returned by GetTime() are the values that were last set via SetTime().\r | |
72 | The GetTime() function should take approximately the same amount of time to read the time each\r | |
73 | time it is called. All reported device capabilities are to be rounded up.\r | |
74 | During runtime, if a PC-AT CMOS device is present in the platform the caller must synchronize\r | |
75 | access to the device before calling GetTime().\r | |
ebcc8fb7 | 76 | \r |
bf231ea6 A |
77 | @param Time A pointer to storage to receive a snapshot of the current time.\r |
78 | @param Capabilities An optional pointer to a buffer to receive the real time clock device's\r | |
79 | capabilities.\r | |
ebcc8fb7 | 80 | \r |
1d37ab9f | 81 | @retval EFI_SUCCESS The operation completed successfully.\r |
82 | @retval EFI_INVALID_PARAMETER Time is NULL.\r | |
83 | @retval EFI_DEVICE_ERROR The time could not be retrieved due to a hardware error.\r | |
ebcc8fb7 | 84 | \r |
bf231ea6 | 85 | **/\r |
ebcc8fb7 | 86 | EFI_STATUS\r |
87 | EFIAPI\r | |
88 | EfiGetTime (\r | |
89 | OUT EFI_TIME *Time,\r | |
91fd9c9b | 90 | OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL\r |
ebcc8fb7 | 91 | )\r |
bf231ea6 A |
92 | {\r |
93 | return mRT->GetTime (Time, Capabilities);\r | |
94 | }\r | |
ebcc8fb7 | 95 | \r |
ebcc8fb7 | 96 | \r |
bf231ea6 | 97 | /**\r |
1d37ab9f | 98 | This service is a wrapper for the UEFI Runtime Service SetTime().\r |
99 | \r | |
100 | The SetTime() function sets the real time clock device to the supplied time, and records the\r | |
101 | current time zone and daylight savings time information. The SetTime() function is not allowed\r | |
102 | to loop based on the current time. For example, if the device does not support a hardware reset\r | |
103 | for the sub-resolution time, the code is not to implement the feature by waiting for the time to\r | |
104 | wrap.\r | |
105 | During runtime, if a PC-AT CMOS device is present in the platform the caller must synchronize\r | |
106 | access to the device before calling SetTime().\r | |
107 | \r | |
108 | @param Time A pointer to the current time. Type EFI_TIME is defined in the GetTime()\r | |
109 | function description. Full error checking is performed on the different\r | |
110 | fields of the EFI_TIME structure (refer to the EFI_TIME definition in the\r | |
111 | GetTime() function description for full details), and EFI_INVALID_PARAMETER\r | |
112 | is returned if any field is out of range.\r | |
113 | \r | |
114 | @retval EFI_SUCCESS The operation completed successfully.\r | |
115 | @retval EFI_INVALID_PARAMETER A time field is out of range.\r | |
116 | @retval EFI_DEVICE_ERROR The time could not be set due to a hardware error.\r | |
ebcc8fb7 | 117 | \r |
bf231ea6 | 118 | **/\r |
ebcc8fb7 | 119 | EFI_STATUS\r |
120 | EFIAPI\r | |
121 | EfiSetTime (\r | |
122 | IN EFI_TIME *Time\r | |
123 | )\r | |
bf231ea6 A |
124 | {\r |
125 | return mRT->SetTime (Time);\r | |
126 | }\r | |
ebcc8fb7 | 127 | \r |
ebcc8fb7 | 128 | \r |
bf231ea6 | 129 | /**\r |
cf8ae2f6 | 130 | This service is a wrapper for the UEFI Runtime Service GetWakeupTime().\r |
ebcc8fb7 | 131 | \r |
1d37ab9f | 132 | The alarm clock time may be rounded from the set alarm clock time to be within the resolution\r |
133 | of the alarm clock device. The resolution of the alarm clock device is defined to be one second.\r | |
134 | During runtime, if a PC-AT CMOS device is present in the platform the caller must synchronize\r | |
135 | access to the device before calling GetWakeupTime().\r | |
ebcc8fb7 | 136 | \r |
1d37ab9f | 137 | @param Enabled Indicates if the alarm is currently enabled or disabled.\r |
138 | @param Pending Indicates if the alarm signal is pending and requires acknowledgement.\r | |
139 | @param Time The current alarm setting. Type EFI_TIME is defined in the GetTime()\r | |
140 | function description.\r | |
141 | \r | |
142 | @retval EFI_SUCCESS The alarm settings were returned.\r | |
143 | @retval EFI_INVALID_PARAMETER Enabled is NULL.\r | |
144 | @retval EFI_INVALID_PARAMETER Pending is NULL.\r | |
145 | @retval EFI_INVALID_PARAMETER Time is NULL.\r | |
146 | @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error.\r | |
147 | @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.\r | |
ebcc8fb7 | 148 | \r |
bf231ea6 | 149 | **/\r |
ebcc8fb7 | 150 | EFI_STATUS\r |
151 | EFIAPI\r | |
152 | EfiGetWakeupTime (\r | |
153 | OUT BOOLEAN *Enabled,\r | |
154 | OUT BOOLEAN *Pending,\r | |
155 | OUT EFI_TIME *Time\r | |
156 | )\r | |
bf231ea6 A |
157 | {\r |
158 | return mRT->GetWakeupTime (Enabled, Pending, Time);\r | |
159 | }\r | |
ebcc8fb7 | 160 | \r |
ebcc8fb7 | 161 | \r |
ebcc8fb7 | 162 | \r |
bf231ea6 | 163 | /**\r |
cf8ae2f6 | 164 | This service is a wrapper for the UEFI Runtime Service SetWakeupTime()\r |
165 | \r | |
166 | Setting a system wakeup alarm causes the system to wake up or power on at the set time.\r | |
167 | When the alarm fires, the alarm signal is latched until it is acknowledged by calling SetWakeupTime()\r | |
168 | to disable the alarm. If the alarm fires before the system is put into a sleeping or off state,\r | |
169 | since the alarm signal is latched the system will immediately wake up. If the alarm fires while\r | |
170 | the system is off and there is insufficient power to power on the system, the system is powered\r | |
171 | on when power is restored.\r | |
ebcc8fb7 | 172 | \r |
1d37ab9f | 173 | @param Enable Enable or disable the wakeup alarm.\r |
174 | @param Time If Enable is TRUE, the time to set the wakeup alarm for. Type EFI_TIME\r | |
175 | is defined in the GetTime() function description. If Enable is FALSE,\r | |
176 | then this parameter is optional, and may be NULL.\r | |
ebcc8fb7 | 177 | \r |
1d37ab9f | 178 | @retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was enabled.\r |
179 | If Enable is FALSE, then the wakeup alarm was disabled.\r | |
180 | @retval EFI_INVALID_PARAMETER A time field is out of range.\r | |
181 | @retval EFI_DEVICE_ERROR The wakeup time could not be set due to a hardware error.\r | |
182 | @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.\r | |
ebcc8fb7 | 183 | \r |
bf231ea6 | 184 | **/\r |
ebcc8fb7 | 185 | EFI_STATUS\r |
186 | EFIAPI\r | |
187 | EfiSetWakeupTime (\r | |
188 | IN BOOLEAN Enable,\r | |
91fd9c9b | 189 | IN EFI_TIME *Time OPTIONAL\r |
ebcc8fb7 | 190 | )\r |
ebcc8fb7 | 191 | {\r |
192 | return mRT->SetWakeupTime (Enable, Time);\r | |
193 | }\r | |
194 | \r | |
195 | \r | |
bf231ea6 | 196 | /**\r |
cf8ae2f6 | 197 | This service is a wrapper for the UEFI Runtime Service GetVariable().\r |
bf231ea6 | 198 | \r |
cf8ae2f6 | 199 | Each vendor may create and manage its own variables without the risk of name conflicts by\r |
200 | using a unique VendorGuid. When a variable is set its Attributes are supplied to indicate\r | |
201 | how the data variable should be stored and maintained by the system. The attributes affect\r | |
202 | when the variable may be accessed and volatility of the data. Any attempts to access a variable\r | |
203 | that does not have the attribute set for runtime access will yield the EFI_NOT_FOUND error.\r | |
204 | If the Data buffer is too small to hold the contents of the variable, the error EFI_BUFFER_TOO_SMALL\r | |
205 | is returned and DataSize is set to the required buffer size to obtain the data.\r | |
206 | \r | |
207 | @param VariableName the name of the vendor's variable, it's a Null-Terminated Unicode String\r | |
bf231ea6 A |
208 | @param VendorGuid Unify identifier for vendor.\r |
209 | @param Attributes Point to memory location to return the attributes of variable. If the point\r | |
210 | is NULL, the parameter would be ignored.\r | |
211 | @param DataSize As input, point to the maxinum size of return Data-Buffer.\r | |
212 | As output, point to the actual size of the returned Data-Buffer.\r | |
213 | @param Data Point to return Data-Buffer.\r | |
ebcc8fb7 | 214 | \r |
1d37ab9f | 215 | @retval EFI_SUCCESS The function completed successfully.\r |
216 | @retval EFI_NOT_FOUND The variable was not found.\r | |
217 | @retval EFI_BUFFER_TOO_SMALL The DataSize is too small for the result. DataSize has\r | |
218 | been updated with the size needed to complete the request.\r | |
219 | @retval EFI_INVALID_PARAMETER VariableName is NULL.\r | |
220 | @retval EFI_INVALID_PARAMETER VendorGuid is NULL.\r | |
221 | @retval EFI_INVALID_PARAMETER DataSize is NULL.\r | |
222 | @retval EFI_INVALID_PARAMETER The DataSize is not too small and Data is NULL.\r | |
223 | @retval EFI_DEVICE_ERROR The variable could not be retrieved due to a hardware error.\r | |
224 | @retval EFI_SECURITY_VIOLATION The variable could not be retrieved due to an authentication failure.\r | |
bf231ea6 | 225 | **/\r |
ebcc8fb7 | 226 | EFI_STATUS\r |
227 | EFIAPI\r | |
228 | EfiGetVariable (\r | |
229 | IN CHAR16 *VariableName,\r | |
230 | IN EFI_GUID * VendorGuid,\r | |
231 | OUT UINT32 *Attributes OPTIONAL,\r | |
232 | IN OUT UINTN *DataSize,\r | |
233 | OUT VOID *Data\r | |
234 | )\r | |
bf231ea6 A |
235 | {\r |
236 | return mRT->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);\r | |
237 | }\r | |
ebcc8fb7 | 238 | \r |
ebcc8fb7 | 239 | \r |
bf231ea6 | 240 | /**\r |
cf8ae2f6 | 241 | This service is a wrapper for the UEFI Runtime Service GetNextVariableName().\r |
242 | \r | |
243 | GetNextVariableName() is called multiple times to retrieve the VariableName and VendorGuid of\r | |
244 | all variables currently available in the system. On each call to GetNextVariableName() the\r | |
245 | previous results are passed into the interface, and on output the interface returns the next\r | |
246 | variable name data. When the entire variable list has been returned, the error EFI_NOT_FOUND\r | |
247 | is returned.\r | |
ebcc8fb7 | 248 | \r |
bf231ea6 A |
249 | @param VariableNameSize As input, point to maxinum size of variable name.\r |
250 | As output, point to actual size of varaible name.\r | |
251 | @param VariableName As input, supplies the last VariableName that was returned by\r | |
252 | GetNextVariableName().\r | |
253 | As output, returns the name of variable. The name\r | |
254 | string is Null-Terminated Unicode string.\r | |
255 | @param VendorGuid As input, supplies the last VendorGuid that was returned by\r | |
256 | GetNextVriableName().\r | |
257 | As output, returns the VendorGuid of the current variable.\r | |
ebcc8fb7 | 258 | \r |
1d37ab9f | 259 | @retval EFI_SUCCESS The function completed successfully.\r |
260 | @retval EFI_NOT_FOUND The next variable was not found.\r | |
261 | @retval EFI_BUFFER_TOO_SMALL The VariableNameSize is too small for the result.\r | |
262 | VariableNameSize has been updated with the size needed\r | |
263 | to complete the request.\r | |
264 | @retval EFI_INVALID_PARAMETER VariableNameSize is NULL.\r | |
265 | @retval EFI_INVALID_PARAMETER VariableName is NULL.\r | |
266 | @retval EFI_INVALID_PARAMETER VendorGuid is NULL.\r | |
267 | @retval EFI_DEVICE_ERROR The variable name could not be retrieved due to a hardware error.\r | |
ebcc8fb7 | 268 | \r |
bf231ea6 | 269 | **/\r |
ebcc8fb7 | 270 | EFI_STATUS\r |
271 | EFIAPI\r | |
272 | EfiGetNextVariableName (\r | |
273 | IN OUT UINTN *VariableNameSize,\r | |
274 | IN OUT CHAR16 *VariableName,\r | |
275 | IN OUT EFI_GUID *VendorGuid\r | |
276 | )\r | |
bf231ea6 A |
277 | {\r |
278 | return mRT->GetNextVariableName (VariableNameSize, VariableName, VendorGuid);\r | |
279 | }\r | |
ebcc8fb7 | 280 | \r |
ebcc8fb7 | 281 | \r |
bf231ea6 | 282 | /**\r |
cf8ae2f6 | 283 | This service is a wrapper for the UEFI Runtime Service GetNextVariableName()\r |
284 | \r | |
285 | Variables are stored by the firmware and may maintain their values across power cycles. Each vendor\r | |
286 | may create and manage its own variables without the risk of name conflicts by using a unique VendorGuid.\r | |
ebcc8fb7 | 287 | \r |
bf231ea6 A |
288 | @param VariableName the name of the vendor's variable, it's a\r |
289 | Null-Terminated Unicode String\r | |
290 | @param VendorGuid Unify identifier for vendor.\r | |
291 | @param Attributes Point to memory location to return the attributes of variable. If the point\r | |
292 | is NULL, the parameter would be ignored.\r | |
293 | @param DataSize The size in bytes of Data-Buffer.\r | |
294 | @param Data Point to the content of the variable.\r | |
ebcc8fb7 | 295 | \r |
1d37ab9f | 296 | @retval EFI_SUCCESS The firmware has successfully stored the variable and its data as\r |
297 | defined by the Attributes.\r | |
298 | @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied, or the\r | |
299 | DataSize exceeds the maximum allowed.\r | |
300 | @retval EFI_INVALID_PARAMETER VariableName is an empty Unicode string.\r | |
301 | @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the variable and its data.\r | |
302 | @retval EFI_DEVICE_ERROR The variable could not be saved due to a hardware failure.\r | |
303 | @retval EFI_WRITE_PROTECTED The variable in question is read-only.\r | |
304 | @retval EFI_WRITE_PROTECTED The variable in question cannot be deleted.\r | |
305 | @retval EFI_SECURITY_VIOLATION The variable could not be written due to EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS\r | |
306 | set but the AuthInfo does NOT pass the validation check carried\r | |
307 | out by the firmware.\r | |
308 | @retval EFI_NOT_FOUND The variable trying to be updated or deleted was not found.\r | |
ebcc8fb7 | 309 | \r |
bf231ea6 | 310 | **/\r |
ebcc8fb7 | 311 | EFI_STATUS\r |
312 | EFIAPI\r | |
313 | EfiSetVariable (\r | |
314 | IN CHAR16 *VariableName,\r | |
315 | IN EFI_GUID *VendorGuid,\r | |
316 | IN UINT32 Attributes,\r | |
317 | IN UINTN DataSize,\r | |
318 | IN VOID *Data\r | |
319 | )\r | |
bf231ea6 A |
320 | {\r |
321 | return mRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);\r | |
322 | }\r | |
ebcc8fb7 | 323 | \r |
ebcc8fb7 | 324 | \r |
bf231ea6 | 325 | /**\r |
cf8ae2f6 | 326 | This service is a wrapper for the UEFI Runtime Service GetNextHighMonotonicCount().\r |
327 | \r | |
328 |