| 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 |
#include "acpi.h" |
| 45 |
#include "accommon.h" |
| 46 |
#include "acevents.h" |
| 47 |
#include "acnamesp.h" |
| 48 |
|
| 49 |
#define _COMPONENT ACPI_EVENTS |
| 50 |
ACPI_MODULE_NAME ("evmisc") |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
static void ACPI_SYSTEM_XFACE |
| 56 |
AcpiEvNotifyDispatch ( |
| 57 |
void *Context); |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
BOOLEAN |
| 75 |
AcpiEvIsNotifyObject ( |
| 76 |
ACPI_NAMESPACE_NODE *Node) |
| 77 |
{ |
| 78 |
|
| 79 |
switch (Node->Type) |
| 80 |
{ |
| 81 |
case ACPI_TYPE_DEVICE: |
| 82 |
case ACPI_TYPE_PROCESSOR: |
| 83 |
case ACPI_TYPE_THERMAL: |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
return (TRUE); |
| 88 |
|
| 89 |
default: |
| 90 |
|
| 91 |
return (FALSE); |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
ACPI_STATUS |
| 111 |
AcpiEvQueueNotifyRequest ( |
| 112 |
ACPI_NAMESPACE_NODE *Node, |
| 113 |
UINT32 NotifyValue) |
| 114 |
{ |
| 115 |
ACPI_OPERAND_OBJECT *ObjDesc; |
| 116 |
ACPI_OPERAND_OBJECT *HandlerListHead = NULL; |
| 117 |
ACPI_GENERIC_STATE *Info; |
| 118 |
UINT8 HandlerListId = 0; |
| 119 |
ACPI_STATUS Status = AE_OK; |
| 120 |
|
| 121 |
|
| 122 |
ACPI_FUNCTION_NAME (EvQueueNotifyRequest); |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
if (!AcpiEvIsNotifyObject (Node)) |
| 128 |
{ |
| 129 |
return (AE_TYPE); |
| 130 |
} |
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
if (NotifyValue <= ACPI_MAX_SYS_NOTIFY) |
| 135 |
{ |
| 136 |
HandlerListId = ACPI_SYSTEM_HANDLER_LIST; |
| 137 |
} |
| 138 |
else |
| 139 |
{ |
| 140 |
HandlerListId = ACPI_DEVICE_HANDLER_LIST; |
| 141 |
} |
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
ObjDesc = AcpiNsGetAttachedObject (Node); |
| 146 |
if (ObjDesc) |
| 147 |
{ |
| 148 |
|
| 149 |
|
| 150 |
HandlerListHead = ObjDesc->CommonNotify.NotifyList[HandlerListId]; |
| 151 |
} |
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
if (!AcpiGbl_GlobalNotify[HandlerListId].Handler && !HandlerListHead) |
| 158 |
{ |
| 159 |
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, |
| 160 |
"No notify handler for Notify, ignoring (%4.4s, %X) node %p\n", |
| 161 |
AcpiUtGetNodeName (Node), NotifyValue, Node)); |
| 162 |
|
| 163 |
return (AE_OK); |
| 164 |
} |
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
Info = AcpiUtCreateGenericState (); |
| 169 |
if (!Info) |
| 170 |
{ |
| 171 |
return (AE_NO_MEMORY); |
| 172 |
} |
| 173 |
|
| 174 |
Info->Common.DescriptorType = ACPI_DESC_TYPE_STATE_NOTIFY; |
| 175 |
|
| 176 |
Info->Notify.Node = Node; |
| 177 |
Info->Notify.Value = (UINT16) NotifyValue; |
| 178 |
Info->Notify.HandlerListId = HandlerListId; |
| 179 |
Info->Notify.HandlerListHead = HandlerListHead; |
| 180 |
Info->Notify.Global = &AcpiGbl_GlobalNotify[HandlerListId]; |
| 181 |
|
| 182 |
ACPI_DEBUG_PRINT ((ACPI_DB_INFO, |
| 183 |
"Dispatching Notify on [%4.4s] (%s) Value 0x%2.2X (%s) Node %p\n", |
| 184 |
AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type), |
| 185 |
NotifyValue, AcpiUtGetNotifyName (NotifyValue, ACPI_TYPE_ANY), Node)); |
| 186 |
|
| 187 |
Status = AcpiOsExecute (OSL_NOTIFY_HANDLER, |
| 188 |
AcpiEvNotifyDispatch, Info); |
| 189 |
if (ACPI_FAILURE (Status)) |
| 190 |
{ |
| 191 |
AcpiUtDeleteGenericState (Info); |
| 192 |
} |
| 193 |
|
| 194 |
return (Status); |
| 195 |
} |
| 196 |
|
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
static void ACPI_SYSTEM_XFACE |
| 212 |
AcpiEvNotifyDispatch ( |
| 213 |
void *Context) |
| 214 |
{ |
| 215 |
ACPI_GENERIC_STATE *Info = (ACPI_GENERIC_STATE *) Context; |
| 216 |
ACPI_OPERAND_OBJECT *HandlerObj; |
| 217 |
|
| 218 |
|
| 219 |
ACPI_FUNCTION_ENTRY (); |
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
if (Info->Notify.Global->Handler) |
| 225 |
{ |
| 226 |
Info->Notify.Global->Handler (Info->Notify.Node, |
| 227 |
Info->Notify.Value, |
| 228 |
Info->Notify.Global->Context); |
| 229 |
} |
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
HandlerObj = Info->Notify.HandlerListHead; |
| 234 |
while (HandlerObj) |
| 235 |
{ |
| 236 |
HandlerObj->Notify.Handler (Info->Notify.Node, |
| 237 |
Info->Notify.Value, |
| 238 |
HandlerObj->Notify.Context); |
| 239 |
|
| 240 |
HandlerObj = HandlerObj->Notify.Next[Info->Notify.HandlerListId]; |
| 241 |
} |
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
AcpiUtDeleteGenericState (Info); |
| 246 |
} |
| 247 |
|
| 248 |
|
| 249 |
#if (!ACPI_REDUCED_HARDWARE) |
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
void |
| 263 |
AcpiEvTerminate ( |
| 264 |
void) |
| 265 |
{ |
| 266 |
UINT32 i; |
| 267 |
ACPI_STATUS Status; |
| 268 |
|
| 269 |
|
| 270 |
ACPI_FUNCTION_TRACE (EvTerminate); |
| 271 |
|
| 272 |
|
| 273 |
if (AcpiGbl_EventsInitialized) |
| 274 |
{ |
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
for (i = 0; i < ACPI_NUM_FIXED_EVENTS; i++) |
| 283 |
{ |
| 284 |
Status = AcpiDisableEvent (i, 0); |
| 285 |
if (ACPI_FAILURE (Status)) |
| 286 |
{ |
| 287 |
ACPI_ERROR ((AE_INFO, |
| 288 |
"Could not disable fixed event %u", (UINT32) i)); |
| 289 |
} |
| 290 |
} |
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
Status = AcpiEvWalkGpeList (AcpiHwDisableGpeBlock, NULL); |
| 295 |
if (ACPI_FAILURE (Status)) |
| 296 |
{ |
| 297 |
ACPI_EXCEPTION ((AE_INFO, Status, |
| 298 |
"Could not disable GPEs in GPE block")); |
| 299 |
} |
| 300 |
|
| 301 |
Status = AcpiEvRemoveGlobalLockHandler (); |
| 302 |
if (ACPI_FAILURE (Status)) |
| 303 |
{ |
| 304 |
ACPI_EXCEPTION ((AE_INFO, Status, |
| 305 |
"Could not remove Global Lock handler")); |
| 306 |
} |
| 307 |
|
| 308 |
AcpiGbl_EventsInitialized = FALSE; |
| 309 |
} |
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
Status = AcpiEvRemoveAllSciHandlers (); |
| 314 |
if (ACPI_FAILURE (Status)) |
| 315 |
{ |
| 316 |
ACPI_ERROR ((AE_INFO, |
| 317 |
"Could not remove SCI handler")); |
| 318 |
} |
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
Status = AcpiEvWalkGpeList (AcpiEvDeleteGpeHandlers, NULL); |
| 323 |
if (ACPI_FAILURE (Status)) |
| 324 |
{ |
| 325 |
ACPI_EXCEPTION ((AE_INFO, Status, |
| 326 |
"Could not delete GPE handlers")); |
| 327 |
} |
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
if (AcpiGbl_OriginalMode == ACPI_SYS_MODE_LEGACY) |
| 333 |
{ |
| 334 |
Status = AcpiDisable (); |
| 335 |
if (ACPI_FAILURE (Status)) |
| 336 |
{ |
| 337 |
ACPI_WARNING ((AE_INFO, "AcpiDisable failed")); |
| 338 |
} |
| 339 |
} |
| 340 |
return_VOID; |
| 341 |
} |
| 342 |
|
| 343 |
#endif |