void AeNotifyHandler ( ACPI_HANDLE Device, UINT32 Value, void *Context) { switch (Value) { #if 0 case 0: printf ("[AcpiExec] Method Error 0x%X: Results not equal\n", Value); if (AcpiGbl_DebugFile) { AcpiOsPrintf ("[AcpiExec] Method Error: Results not equal\n"); } break; case 1: printf ("[AcpiExec] Method Error: Incorrect numeric result\n"); if (AcpiGbl_DebugFile) { AcpiOsPrintf ("[AcpiExec] Method Error: Incorrect numeric result\n"); } break; case 2: printf ("[AcpiExec] Method Error: An operand was overwritten\n"); if (AcpiGbl_DebugFile) { AcpiOsPrintf ("[AcpiExec] Method Error: An operand was overwritten\n"); } break; #endif default: printf ("[AcpiExec] Received a System Notify on [%4.4s] %p Value 0x%2.2X (%s)\n", AcpiUtGetNodeName (Device), Device, Value, AcpiUtGetNotifyName (Value)); if (AcpiGbl_DebugFile) { AcpiOsPrintf ("[AcpiExec] Received a system notify, Value 0x%2.2X\n", Value); } (void) AcpiEvaluateObject (Device, "_NOT", NULL, NULL); break; } }
static void AeDeviceNotifyHandler ( ACPI_HANDLE Device, UINT32 Value, void *Context) { printf ("[AcpiExec] Global: Received a Device Notify on [%4.4s] %p Value 0x%2.2X (%s)\n", AcpiUtGetNodeName (Device), Device, Value, AcpiUtGetNotifyName (Value, ACPI_TYPE_ANY)); if (AcpiGbl_DebugFile) { AcpiOsPrintf ("[AcpiExec] Global: Received a Device Notify, Value 0x%2.2X\n", Value); } (void) AcpiEvaluateObject (Device, "_NOT", NULL, NULL); }
static void AeCommonNotifyHandler ( ACPI_HANDLE Device, UINT32 Value, UINT32 HandlerId) { char *Type; Type = "Device"; if (Value <= ACPI_MAX_SYS_NOTIFY) { Type = "System"; } switch (Value) { #if 0 case 0: printf ("[AcpiExec] Method Error 0x%X: Results not equal\n", Value); if (AcpiGbl_DebugFile) { AcpiOsPrintf ("[AcpiExec] Method Error: Results not equal\n"); } break; case 1: printf ("[AcpiExec] Method Error: Incorrect numeric result\n"); if (AcpiGbl_DebugFile) { AcpiOsPrintf ("[AcpiExec] Method Error: Incorrect numeric result\n"); } break; case 2: printf ("[AcpiExec] Method Error: An operand was overwritten\n"); if (AcpiGbl_DebugFile) { AcpiOsPrintf ("[AcpiExec] Method Error: An operand was overwritten\n"); } break; #endif default: printf ("[AcpiExec] Handler %u: Received a %s Notify on [%4.4s] %p Value 0x%2.2X (%s)\n", HandlerId, Type, AcpiUtGetNodeName (Device), Device, Value, AcpiUtGetNotifyName (Value, ACPI_TYPE_ANY)); if (AcpiGbl_DebugFile) { AcpiOsPrintf ("[AcpiExec] Handler %u: Received a %s notify, Value 0x%2.2X\n", HandlerId, Type, Value); } (void) AcpiEvaluateObject (Device, "_NOT", NULL, NULL); break; } }
ACPI_STATUS AcpiEvQueueNotifyRequest ( ACPI_NAMESPACE_NODE *Node, UINT32 NotifyValue) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_OPERAND_OBJECT *HandlerListHead = NULL; ACPI_GENERIC_STATE *Info; UINT8 HandlerListId = 0; ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_NAME (EvQueueNotifyRequest); /* Are Notifies allowed on this object? */ if (!AcpiEvIsNotifyObject (Node)) { return (AE_TYPE); } /* Get the correct notify list type (System or Device) */ if (NotifyValue <= ACPI_MAX_SYS_NOTIFY) { HandlerListId = ACPI_SYSTEM_HANDLER_LIST; } else { HandlerListId = ACPI_DEVICE_HANDLER_LIST; } /* Get the notify object attached to the namespace Node */ ObjDesc = AcpiNsGetAttachedObject (Node); if (ObjDesc) { /* We have an attached object, Get the correct handler list */ HandlerListHead = ObjDesc->CommonNotify.NotifyList[HandlerListId]; } /* * If there is no notify handler (Global or Local) * for this object, just ignore the notify */ if (!AcpiGbl_GlobalNotify[HandlerListId].Handler && !HandlerListHead) { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "No notify handler for Notify, ignoring (%4.4s, %X) node %p\n", AcpiUtGetNodeName (Node), NotifyValue, Node)); return (AE_OK); } /* Setup notify info and schedule the notify dispatcher */ Info = AcpiUtCreateGenericState (); if (!Info) { return (AE_NO_MEMORY); } Info->Common.DescriptorType = ACPI_DESC_TYPE_STATE_NOTIFY; Info->Notify.Node = Node; Info->Notify.Value = (UINT16) NotifyValue; Info->Notify.HandlerListId = HandlerListId; Info->Notify.HandlerListHead = HandlerListHead; Info->Notify.Global = &AcpiGbl_GlobalNotify[HandlerListId]; ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Dispatching Notify on [%4.4s] (%s) Value 0x%2.2X (%s) Node %p\n", AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type), NotifyValue, AcpiUtGetNotifyName (NotifyValue, ACPI_TYPE_ANY), Node)); Status = AcpiOsExecute (OSL_NOTIFY_HANDLER, AcpiEvNotifyDispatch, Info); if (ACPI_FAILURE (Status)) { AcpiUtDeleteGenericState (Info); } return (Status); }
ACPI_STATUS AcpiEvQueueNotifyRequest ( ACPI_NAMESPACE_NODE *Node, UINT32 NotifyValue) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_OPERAND_OBJECT *HandlerObj = NULL; ACPI_GENERIC_STATE *NotifyInfo; ACPI_STATUS Status = AE_OK; ACPI_FUNCTION_NAME (EvQueueNotifyRequest); /* * For value 3 (Ejection Request), some device method may need to be run. * For value 2 (Device Wake) if _PRW exists, the _PS0 method may need * to be run. * For value 0x80 (Status Change) on the power button or sleep button, * initiate soft-off or sleep operation? */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Dispatching Notify on [%4.4s] Node %p Value 0x%2.2X (%s)\n", AcpiUtGetNodeName (Node), Node, NotifyValue, AcpiUtGetNotifyName (NotifyValue))); /* Get the notify object attached to the NS Node */ ObjDesc = AcpiNsGetAttachedObject (Node); if (ObjDesc) { /* We have the notify object, Get the right handler */ switch (Node->Type) { /* Notify allowed only on these types */ case ACPI_TYPE_DEVICE: case ACPI_TYPE_THERMAL: case ACPI_TYPE_PROCESSOR: if (NotifyValue <= ACPI_MAX_SYS_NOTIFY) { HandlerObj = ObjDesc->CommonNotify.SystemNotify; } else { HandlerObj = ObjDesc->CommonNotify.DeviceNotify; } break; default: /* All other types are not supported */ return (AE_TYPE); } } /* * If there is any handler to run, schedule the dispatcher. * Check for: * 1) Global system notify handler * 2) Global device notify handler * 3) Per-device notify handler */ if ((AcpiGbl_SystemNotify.Handler && (NotifyValue <= ACPI_MAX_SYS_NOTIFY)) || (AcpiGbl_DeviceNotify.Handler && (NotifyValue > ACPI_MAX_SYS_NOTIFY)) || HandlerObj) { NotifyInfo = AcpiUtCreateGenericState (); if (!NotifyInfo) { return (AE_NO_MEMORY); } if (!HandlerObj) { ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Executing system notify handler for Notify (%4.4s, %X) " "node %p\n", AcpiUtGetNodeName (Node), NotifyValue, Node)); } NotifyInfo->Common.DescriptorType = ACPI_DESC_TYPE_STATE_NOTIFY; NotifyInfo->Notify.Node = Node; NotifyInfo->Notify.Value = (UINT16) NotifyValue; NotifyInfo->Notify.HandlerObj = HandlerObj; Status = AcpiOsExecute ( OSL_NOTIFY_HANDLER, AcpiEvNotifyDispatch, NotifyInfo); if (ACPI_FAILURE (Status)) { AcpiUtDeleteGenericState (NotifyInfo); } } else { /* There is no notify handler (per-device or system) for this device */ ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "No notify handler for Notify (%4.4s, %X) node %p\n", AcpiUtGetNodeName (Node), NotifyValue, Node)); } return (Status); }