ACPI_GPE_EVENT_INFO * AcpiEvGetGpeEventInfo ( ACPI_HANDLE GpeDevice, UINT32 GpeNumber) { ACPI_OPERAND_OBJECT *ObjDesc; ACPI_GPE_EVENT_INFO *GpeInfo; UINT32 i; ACPI_FUNCTION_ENTRY (); /* A NULL GpeDevice means use the FADT-defined GPE block(s) */ if (!GpeDevice) { /* Examine GPE Block 0 and 1 (These blocks are permanent) */ for (i = 0; i < ACPI_MAX_GPE_BLOCKS; i++) { GpeInfo = AcpiEvLowGetGpeInfo (GpeNumber, AcpiGbl_GpeFadtBlocks[i]); if (GpeInfo) { return (GpeInfo); } } /* The GpeNumber was not in the range of either FADT GPE block */ return (NULL); } /* A Non-NULL GpeDevice means this is a GPE Block Device */ ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) GpeDevice); if (!ObjDesc || !ObjDesc->Device.GpeBlock) { return (NULL); } return (AcpiEvLowGetGpeInfo (GpeNumber, ObjDesc->Device.GpeBlock)); }
ACPI_STATUS AcpiEvMatchGpeMethod ( ACPI_HANDLE ObjHandle, UINT32 Level, void *Context, void **ReturnValue) { ACPI_NAMESPACE_NODE *MethodNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); ACPI_GPE_WALK_INFO *WalkInfo = ACPI_CAST_PTR (ACPI_GPE_WALK_INFO, Context); ACPI_GPE_EVENT_INFO *GpeEventInfo; UINT32 GpeNumber; char Name[ACPI_NAME_SIZE + 1]; UINT8 Type; ACPI_FUNCTION_TRACE (EvMatchGpeMethod); /* Check if requested OwnerId matches this OwnerId */ if ((WalkInfo->ExecuteByOwnerId) && (MethodNode->OwnerId != WalkInfo->OwnerId)) { return_ACPI_STATUS (AE_OK); } /* * Match and decode the _Lxx and _Exx GPE method names * * 1) Extract the method name and null terminate it */ ACPI_MOVE_32_TO_32 (Name, &MethodNode->Name.Integer); Name[ACPI_NAME_SIZE] = 0; /* 2) Name must begin with an underscore */ if (Name[0] != '_') { return_ACPI_STATUS (AE_OK); /* Ignore this method */ } /* * 3) Edge/Level determination is based on the 2nd character * of the method name */ switch (Name[1]) { case 'L': Type = ACPI_GPE_LEVEL_TRIGGERED; break; case 'E': Type = ACPI_GPE_EDGE_TRIGGERED; break; default: /* Unknown method type, just ignore it */ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Ignoring unknown GPE method type: %s " "(name not of form _Lxx or _Exx)", Name)); return_ACPI_STATUS (AE_OK); } /* 4) The last two characters of the name are the hex GPE Number */ GpeNumber = ACPI_STRTOUL (&Name[2], NULL, 16); if (GpeNumber == ACPI_UINT32_MAX) { /* Conversion failed; invalid method, just ignore it */ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Could not extract GPE number from name: %s " "(name is not of form _Lxx or _Exx)", Name)); return_ACPI_STATUS (AE_OK); } /* Ensure that we have a valid GPE number for this GPE block */ GpeEventInfo = AcpiEvLowGetGpeInfo (GpeNumber, WalkInfo->GpeBlock); if (!GpeEventInfo) { /* * This GpeNumber is not valid for this GPE block, just ignore it. * However, it may be valid for a different GPE block, since GPE0 * and GPE1 methods both appear under \_GPE. */ return_ACPI_STATUS (AE_OK); } if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) { /* If there is already a handler, ignore this GPE method */ return_ACPI_STATUS (AE_OK); } if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_METHOD) { /* * If there is already a method, ignore this method. But check * for a type mismatch (if both the _Lxx AND _Exx exist) */ if (Type != (GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK)) { ACPI_ERROR ((AE_INFO, "For GPE 0x%.2X, found both _L%2.2X and _E%2.2X methods", GpeNumber, GpeNumber, GpeNumber)); } return_ACPI_STATUS (AE_OK); } /* * Add the GPE information from above to the GpeEventInfo block for * use during dispatch of this GPE. */ GpeEventInfo->Flags &= ~(ACPI_GPE_DISPATCH_MASK); GpeEventInfo->Flags |= (UINT8) (Type | ACPI_GPE_DISPATCH_METHOD); GpeEventInfo->Dispatch.MethodNode = MethodNode; ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Registered GPE method %s as GPE number 0x%.2X\n", Name, GpeNumber)); return_ACPI_STATUS (AE_OK); }
ACPI_STATUS AcpiEvMatchPrwAndGpe ( ACPI_HANDLE ObjHandle, UINT32 Level, void *Context, void **ReturnValue) { ACPI_GPE_WALK_INFO *WalkInfo = ACPI_CAST_PTR (ACPI_GPE_WALK_INFO, Context); ACPI_NAMESPACE_NODE *GpeDevice; ACPI_GPE_BLOCK_INFO *GpeBlock; ACPI_NAMESPACE_NODE *TargetGpeDevice; ACPI_NAMESPACE_NODE *PrwNode; ACPI_GPE_EVENT_INFO *GpeEventInfo; ACPI_OPERAND_OBJECT *PkgDesc; ACPI_OPERAND_OBJECT *ObjDesc; UINT32 GpeNumber; ACPI_STATUS Status; ACPI_FUNCTION_TRACE (EvMatchPrwAndGpe); /* Check for a _PRW method under this device */ Status = AcpiNsGetNode (ObjHandle, METHOD_NAME__PRW, ACPI_NS_NO_UPSEARCH, &PrwNode); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (AE_OK); } /* Check if requested OwnerId matches this OwnerId */ if ((WalkInfo->ExecuteByOwnerId) && (PrwNode->OwnerId != WalkInfo->OwnerId)) { return_ACPI_STATUS (AE_OK); } /* Execute the _PRW */ Status = AcpiUtEvaluateObject (PrwNode, NULL, ACPI_BTYPE_PACKAGE, &PkgDesc); if (ACPI_FAILURE (Status)) { return_ACPI_STATUS (AE_OK); } /* The returned _PRW package must have at least two elements */ if (PkgDesc->Package.Count < 2) { goto Cleanup; } /* Extract pointers from the input context */ GpeDevice = WalkInfo->GpeDevice; GpeBlock = WalkInfo->GpeBlock; /* * The _PRW object must return a package, we are only interested * in the first element */ ObjDesc = PkgDesc->Package.Elements[0]; if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER) { /* Use FADT-defined GPE device (from definition of _PRW) */ TargetGpeDevice = NULL; if (GpeDevice) { TargetGpeDevice = AcpiGbl_FadtGpeDevice; } /* Integer is the GPE number in the FADT described GPE blocks */ GpeNumber = (UINT32) ObjDesc->Integer.Value; } else if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE) { /* Package contains a GPE reference and GPE number within a GPE block */ if ((ObjDesc->Package.Count < 2) || ((ObjDesc->Package.Elements[0])->Common.Type != ACPI_TYPE_LOCAL_REFERENCE) || ((ObjDesc->Package.Elements[1])->Common.Type != ACPI_TYPE_INTEGER)) { goto Cleanup; } /* Get GPE block reference and decode */ TargetGpeDevice = ObjDesc->Package.Elements[0]->Reference.Node; GpeNumber = (UINT32) ObjDesc->Package.Elements[1]->Integer.Value; } else { /* Unknown type, just ignore it */ goto Cleanup; } /* Get the GpeEventInfo for this GPE */ if (GpeDevice) { /* * Is this GPE within this block? * * TRUE if and only if these conditions are true: * 1) The GPE devices match. * 2) The GPE index(number) is within the range of the Gpe Block * associated with the GPE device. */ if (GpeDevice != TargetGpeDevice) { goto Cleanup; } GpeEventInfo = AcpiEvLowGetGpeInfo (GpeNumber, GpeBlock); } else { /* GpeDevice is NULL, just match the TargetDevice and GpeNumber */ GpeEventInfo = AcpiEvGetGpeEventInfo (TargetGpeDevice, GpeNumber); } if (GpeEventInfo) { if (!(GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE)) { /* This GPE can wake the system */ GpeEventInfo->Flags |= ACPI_GPE_CAN_WAKE; WalkInfo->Count++; } } Cleanup: AcpiUtRemoveReference (PkgDesc); return_ACPI_STATUS (AE_OK); }
ACPI_STATUS AcpiEvMatchGpeMethod ( ACPI_HANDLE ObjHandle, UINT32 Level, void *Context, void **ReturnValue) { ACPI_NAMESPACE_NODE *MethodNode = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle); ACPI_GPE_WALK_INFO *WalkInfo = ACPI_CAST_PTR (ACPI_GPE_WALK_INFO, Context); ACPI_GPE_EVENT_INFO *GpeEventInfo; ACPI_NAMESPACE_NODE *GpeDevice; ACPI_STATUS Status; UINT32 GpeNumber; char Name[ACPI_NAME_SIZE + 1]; UINT8 Type; ACPI_FUNCTION_TRACE (EvMatchGpeMethod); /* Check if requested OwnerId matches this OwnerId */ if ((WalkInfo->ExecuteByOwnerId) && (MethodNode->OwnerId != WalkInfo->OwnerId)) { return_ACPI_STATUS (AE_OK); } /* * Match and decode the _Lxx and _Exx GPE method names * * 1) Extract the method name and null terminate it */ ACPI_MOVE_32_TO_32 (Name, &MethodNode->Name.Integer); Name[ACPI_NAME_SIZE] = 0; /* 2) Name must begin with an underscore */ if (Name[0] != '_') { return_ACPI_STATUS (AE_OK); /* Ignore this method */ } /* * 3) Edge/Level determination is based on the 2nd character * of the method name * * NOTE: Default GPE type is RUNTIME only. Later, if a _PRW object is * found that points to this GPE, the ACPI_GPE_CAN_WAKE flag is set. */ switch (Name[1]) { case 'L': Type = ACPI_GPE_LEVEL_TRIGGERED; break; case 'E': Type = ACPI_GPE_EDGE_TRIGGERED; break; default: /* Unknown method type, just ignore it */ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Ignoring unknown GPE method type: %s " "(name not of form _Lxx or _Exx)", Name)); return_ACPI_STATUS (AE_OK); } /* 4) The last two characters of the name are the hex GPE Number */ GpeNumber = ACPI_STRTOUL (&Name[2], NULL, 16); if (GpeNumber == ACPI_UINT32_MAX) { /* Conversion failed; invalid method, just ignore it */ ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Could not extract GPE number from name: %s " "(name is not of form _Lxx or _Exx)", Name)); return_ACPI_STATUS (AE_OK); } /* Ensure that we have a valid GPE number for this GPE block */ GpeEventInfo = AcpiEvLowGetGpeInfo (GpeNumber, WalkInfo->GpeBlock); if (!GpeEventInfo) { /* * This GpeNumber is not valid for this GPE block, just ignore it. * However, it may be valid for a different GPE block, since GPE0 * and GPE1 methods both appear under \_GPE. */ return_ACPI_STATUS (AE_OK); } if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_HANDLER) { /* If there is already a handler, ignore this GPE method */ return_ACPI_STATUS (AE_OK); } if ((GpeEventInfo->Flags & ACPI_GPE_DISPATCH_MASK) == ACPI_GPE_DISPATCH_METHOD) { /* * If there is already a method, ignore this method. But check * for a type mismatch (if both the _Lxx AND _Exx exist) */ if (Type != (GpeEventInfo->Flags & ACPI_GPE_XRUPT_TYPE_MASK)) { ACPI_ERROR ((AE_INFO, "For GPE 0x%.2X, found both _L%2.2X and _E%2.2X methods", GpeNumber, GpeNumber, GpeNumber)); } return_ACPI_STATUS (AE_OK); } /* * Add the GPE information from above to the GpeEventInfo block for * use during dispatch of this GPE. */ GpeEventInfo->Flags |= (UINT8) (Type | ACPI_GPE_DISPATCH_METHOD); GpeEventInfo->Dispatch.MethodNode = MethodNode; /* * Enable this GPE if requested. This only happens when during the * execution of a Load or LoadTable operator. We have found a new * GPE method and want to immediately enable the GPE if it is a * runtime GPE. */ if (WalkInfo->EnableThisGpe) { /* Ignore GPEs that can wake the system */ if (!(GpeEventInfo->Flags & ACPI_GPE_CAN_WAKE) || !AcpiGbl_LeaveWakeGpesDisabled) { WalkInfo->Count++; GpeDevice = WalkInfo->GpeDevice; if (GpeDevice == AcpiGbl_FadtGpeDevice) { GpeDevice = NULL; } Status = AcpiEnableGpe (GpeDevice, GpeNumber); if (ACPI_FAILURE (Status)) { ACPI_EXCEPTION ((AE_INFO, Status, "Could not enable GPE 0x%02X", GpeNumber)); } } } ACPI_DEBUG_PRINT ((ACPI_DB_LOAD, "Registered GPE method %s as GPE number 0x%.2X\n", Name, GpeNumber)); return_ACPI_STATUS (AE_OK); }