| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
#define EXPORT_ACPI_INTERFACES |
| 45 |
|
| 46 |
#include "acpi.h" |
| 47 |
#include "accommon.h" |
| 48 |
#include "actables.h" |
| 49 |
|
| 50 |
#define _COMPONENT ACPI_EVENTS |
| 51 |
ACPI_MODULE_NAME ("evxfevnt") |
| 52 |
|
| 53 |
|
| 54 |
#if (!ACPI_REDUCED_HARDWARE) |
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
ACPI_STATUS |
| 68 |
AcpiEnable ( |
| 69 |
void) |
| 70 |
{ |
| 71 |
ACPI_STATUS Status = AE_OK; |
| 72 |
|
| 73 |
|
| 74 |
ACPI_FUNCTION_TRACE (AcpiEnable); |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
if (AcpiGbl_FadtIndex == ACPI_INVALID_TABLE_INDEX) |
| 80 |
{ |
| 81 |
return_ACPI_STATUS (AE_NO_ACPI_TABLES); |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
if (AcpiGbl_ReducedHardware) |
| 87 |
{ |
| 88 |
return_ACPI_STATUS (AE_OK); |
| 89 |
} |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
if (AcpiHwGetMode() == ACPI_SYS_MODE_ACPI) |
| 94 |
{ |
| 95 |
ACPI_DEBUG_PRINT ((ACPI_DB_INIT, |
| 96 |
"System is already in ACPI mode\n")); |
| 97 |
} |
| 98 |
else |
| 99 |
{ |
| 100 |
|
| 101 |
|
| 102 |
Status = AcpiHwSetMode (ACPI_SYS_MODE_ACPI); |
| 103 |
if (ACPI_FAILURE (Status)) |
| 104 |
{ |
| 105 |
ACPI_ERROR ((AE_INFO, "Could not transition to ACPI mode")); |
| 106 |
return_ACPI_STATUS (Status); |
| 107 |
} |
| 108 |
|
| 109 |
ACPI_DEBUG_PRINT ((ACPI_DB_INIT, |
| 110 |
"Transition to ACPI mode successful\n")); |
| 111 |
} |
| 112 |
|
| 113 |
return_ACPI_STATUS (Status); |
| 114 |
} |
| 115 |
|
| 116 |
ACPI_EXPORT_SYMBOL (AcpiEnable) |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
ACPI_STATUS |
| 132 |
AcpiDisable ( |
| 133 |
void) |
| 134 |
{ |
| 135 |
ACPI_STATUS Status = AE_OK; |
| 136 |
|
| 137 |
|
| 138 |
ACPI_FUNCTION_TRACE (AcpiDisable); |
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
if (AcpiGbl_ReducedHardware) |
| 144 |
{ |
| 145 |
return_ACPI_STATUS (AE_OK); |
| 146 |
} |
| 147 |
|
| 148 |
if (AcpiHwGetMode() == ACPI_SYS_MODE_LEGACY) |
| 149 |
{ |
| 150 |
ACPI_DEBUG_PRINT ((ACPI_DB_INIT, |
| 151 |
"System is already in legacy (non-ACPI) mode\n")); |
| 152 |
} |
| 153 |
else |
| 154 |
{ |
| 155 |
|
| 156 |
|
| 157 |
Status = AcpiHwSetMode (ACPI_SYS_MODE_LEGACY); |
| 158 |
|
| 159 |
if (ACPI_FAILURE (Status)) |
| 160 |
{ |
| 161 |
ACPI_ERROR ((AE_INFO, |
| 162 |
"Could not exit ACPI mode to legacy mode")); |
| 163 |
return_ACPI_STATUS (Status); |
| 164 |
} |
| 165 |
|
| 166 |
ACPI_DEBUG_PRINT ((ACPI_DB_INIT, |
| 167 |
"ACPI mode disabled\n")); |
| 168 |
} |
| 169 |
|
| 170 |
return_ACPI_STATUS (Status); |
| 171 |
} |
| 172 |
|
| 173 |
ACPI_EXPORT_SYMBOL (AcpiDisable) |
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
ACPI_STATUS |
| 190 |
AcpiEnableEvent ( |
| 191 |
UINT32 Event, |
| 192 |
UINT32 Flags) |
| 193 |
{ |
| 194 |
ACPI_STATUS Status = AE_OK; |
| 195 |
UINT32 Value; |
| 196 |
|
| 197 |
|
| 198 |
ACPI_FUNCTION_TRACE (AcpiEnableEvent); |
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
if (AcpiGbl_ReducedHardware) |
| 204 |
{ |
| 205 |
return_ACPI_STATUS (AE_OK); |
| 206 |
} |
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
if (Event > ACPI_EVENT_MAX) |
| 211 |
{ |
| 212 |
return_ACPI_STATUS (AE_BAD_PARAMETER); |
| 213 |
} |
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
Status = AcpiWriteBitRegister ( |
| 220 |
AcpiGbl_FixedEventInfo[Event].EnableRegisterId, |
| 221 |
ACPI_ENABLE_EVENT); |
| 222 |
if (ACPI_FAILURE (Status)) |
| 223 |
{ |
| 224 |
return_ACPI_STATUS (Status); |
| 225 |
} |
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
Status = AcpiReadBitRegister ( |
| 230 |
AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value); |
| 231 |
if (ACPI_FAILURE (Status)) |
| 232 |
{ |
| 233 |
return_ACPI_STATUS (Status); |
| 234 |
} |
| 235 |
|
| 236 |
if (Value != 1) |
| 237 |
{ |
| 238 |
ACPI_ERROR ((AE_INFO, |
| 239 |
"Could not enable %s event", AcpiUtGetEventName (Event))); |
| 240 |
return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); |
| 241 |
} |
| 242 |
|
| 243 |
return_ACPI_STATUS (Status); |
| 244 |
} |
| 245 |
|
| 246 |
ACPI_EXPORT_SYMBOL (AcpiEnableEvent) |
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
ACPI_STATUS |
| 263 |
AcpiDisableEvent ( |
| 264 |
UINT32 Event, |
| 265 |
UINT32 Flags) |
| 266 |
{ |
| 267 |
ACPI_STATUS Status = AE_OK; |
| 268 |
UINT32 Value; |
| 269 |
|
| 270 |
|
| 271 |
ACPI_FUNCTION_TRACE (AcpiDisableEvent); |
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
if (AcpiGbl_ReducedHardware) |
| 277 |
{ |
| 278 |
return_ACPI_STATUS (AE_OK); |
| 279 |
} |
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
if (Event > ACPI_EVENT_MAX) |
| 284 |
{ |
| 285 |
return_ACPI_STATUS (AE_BAD_PARAMETER); |
| 286 |
} |
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
Status = AcpiWriteBitRegister ( |
| 293 |
AcpiGbl_FixedEventInfo[Event].EnableRegisterId, |
| 294 |
ACPI_DISABLE_EVENT); |
| 295 |
if (ACPI_FAILURE (Status)) |
| 296 |
{ |
| 297 |
return_ACPI_STATUS (Status); |
| 298 |
} |
| 299 |
|
| 300 |
Status = AcpiReadBitRegister ( |
| 301 |
AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &Value); |
| 302 |
if (ACPI_FAILURE (Status)) |
| 303 |
{ |
| 304 |
return_ACPI_STATUS (Status); |
| 305 |
} |
| 306 |
|
| 307 |
if (Value != 0) |
| 308 |
{ |
| 309 |
ACPI_ERROR ((AE_INFO, |
| 310 |
"Could not disable %s events", AcpiUtGetEventName (Event))); |
| 311 |
return_ACPI_STATUS (AE_NO_HARDWARE_RESPONSE); |
| 312 |
} |
| 313 |
|
| 314 |
return_ACPI_STATUS (Status); |
| 315 |
} |
| 316 |
|
| 317 |
ACPI_EXPORT_SYMBOL (AcpiDisableEvent) |
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
ACPI_STATUS |
| 333 |
AcpiClearEvent ( |
| 334 |
UINT32 Event) |
| 335 |
{ |
| 336 |
ACPI_STATUS Status = AE_OK; |
| 337 |
|
| 338 |
|
| 339 |
ACPI_FUNCTION_TRACE (AcpiClearEvent); |
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
if (AcpiGbl_ReducedHardware) |
| 345 |
{ |
| 346 |
return_ACPI_STATUS (AE_OK); |
| 347 |
} |
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
if (Event > ACPI_EVENT_MAX) |
| 352 |
{ |
| 353 |
return_ACPI_STATUS (AE_BAD_PARAMETER); |
| 354 |
} |
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
Status = AcpiWriteBitRegister ( |
| 361 |
AcpiGbl_FixedEventInfo[Event].StatusRegisterId, |
| 362 |
ACPI_CLEAR_STATUS); |
| 363 |
|
| 364 |
return_ACPI_STATUS (Status); |
| 365 |
} |
| 366 |
|
| 367 |
ACPI_EXPORT_SYMBOL (AcpiClearEvent) |
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
ACPI_STATUS |
| 385 |
AcpiGetEventStatus ( |
| 386 |
UINT32 Event, |
| 387 |
ACPI_EVENT_STATUS *EventStatus) |
| 388 |
{ |
| 389 |
ACPI_STATUS Status; |
| 390 |
ACPI_EVENT_STATUS LocalEventStatus = 0; |
| 391 |
UINT32 InByte; |
| 392 |
|
| 393 |
|
| 394 |
ACPI_FUNCTION_TRACE (AcpiGetEventStatus); |
| 395 |
|
| 396 |
|
| 397 |
if (!EventStatus) |
| 398 |
{ |
| 399 |
return_ACPI_STATUS (AE_BAD_PARAMETER); |
| 400 |
} |
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
if (Event > ACPI_EVENT_MAX) |
| 405 |
{ |
| 406 |
return_ACPI_STATUS (AE_BAD_PARAMETER); |
| 407 |
} |
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
if (AcpiGbl_FixedEventHandlers[Event].Handler) |
| 412 |
{ |
| 413 |
LocalEventStatus |= ACPI_EVENT_FLAG_HAS_HANDLER; |
| 414 |
} |
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
Status = AcpiReadBitRegister ( |
| 419 |
AcpiGbl_FixedEventInfo[Event].EnableRegisterId, &InByte); |
| 420 |
if (ACPI_FAILURE (Status)) |
| 421 |
{ |
| 422 |
return_ACPI_STATUS (Status); |
| 423 |
} |
| 424 |
|
| 425 |
if (InByte) |
| 426 |
{ |
| 427 |
LocalEventStatus |= |
| 428 |
(ACPI_EVENT_FLAG_ENABLED | ACPI_EVENT_FLAG_ENABLE_SET); |
| 429 |
} |
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
Status = AcpiReadBitRegister ( |
| 434 |
AcpiGbl_FixedEventInfo[Event].StatusRegisterId, &InByte); |
| 435 |
if (ACPI_FAILURE (Status)) |
| 436 |
{ |
| 437 |
return_ACPI_STATUS (Status); |
| 438 |
} |
| 439 |
|
| 440 |
if (InByte) |
| 441 |
{ |
| 442 |
LocalEventStatus |= ACPI_EVENT_FLAG_STATUS_SET; |
| 443 |
} |
| 444 |
|
| 445 |
(*EventStatus) = LocalEventStatus; |
| 446 |
return_ACPI_STATUS (AE_OK); |
| 447 |
} |
| 448 |
|
| 449 |
ACPI_EXPORT_SYMBOL (AcpiGetEventStatus) |
| 450 |
|
| 451 |
#endif |