⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aslanalyze.c

📁 acpi tools for linux include acpiexec and acpixtract
💻 C
📖 第 1 页 / 共 5 页
字号:
/******************************************************************************* * * FUNCTION:    AnFormatBtype * * PARAMETERS:  Btype               - Bitfield of ACPI types *              Buffer              - Where to put the ascii string * * RETURN:      None. * * DESCRIPTION: Convert a Btype to a string of ACPI types * ******************************************************************************/static voidAnFormatBtype (    char                    *Buffer,    UINT32                  Btype){    UINT32                  Type;    BOOLEAN                 First = TRUE;    *Buffer = 0;    if (Btype == 0)    {        strcat (Buffer, "NoReturnValue");        return;    }    for (Type = 1; Type <= ACPI_TYPE_EXTERNAL_MAX; Type++)    {        if (Btype & 0x00000001)        {            if (!First)            {                strcat (Buffer, "|");            }            First = FALSE;            strcat (Buffer, AcpiUtGetTypeName (Type));        }        Btype >>= 1;    }    if (Btype & 0x00000001)    {        if (!First)        {            strcat (Buffer, "|");        }        First = FALSE;        strcat (Buffer, "Reference");    }    Btype >>= 1;    if (Btype & 0x00000001)    {        if (!First)        {            strcat (Buffer, "|");        }        First = FALSE;        strcat (Buffer, "Resource");    }}/******************************************************************************* * * FUNCTION:    AnGetBtype * * PARAMETERS:  Op          - Parse node whose type will be returned. * * RETURN:      The Btype associated with the Op. * * DESCRIPTION: Get the (bitfield) ACPI type associated with the parse node. *              Handles the case where the node is a name or method call and *              the actual type must be obtained from the namespace node. * ******************************************************************************/static UINT32AnGetBtype (    ACPI_PARSE_OBJECT       *Op){    ACPI_NAMESPACE_NODE     *Node;    ACPI_PARSE_OBJECT       *ReferencedNode;    UINT32                  ThisNodeBtype = 0;    if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG)     ||        (Op->Asl.ParseOpcode == PARSEOP_NAMESTRING)  ||        (Op->Asl.ParseOpcode == PARSEOP_METHODCALL))    {        Node = Op->Asl.Node;        if (!Node)        {            DbgPrint (ASL_DEBUG_OUTPUT,                "No attached Nsnode: [%s] at line %d name [%s], ignoring typecheck\n",                Op->Asl.ParseOpName, Op->Asl.LineNumber,                Op->Asl.ExternalName);            return ACPI_UINT32_MAX;        }        ThisNodeBtype = AnMapEtypeToBtype (Node->Type);        if (!ThisNodeBtype)        {            AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op,                "could not map type");        }        /*         * Since it was a named reference, enable the         * reference bit also         */        ThisNodeBtype |= ACPI_BTYPE_REFERENCE;        if (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)        {            ReferencedNode = Node->Op;            if (!ReferencedNode)            {                /* Check for an internal method */                if (AnIsInternalMethod (Op))                {                    return (AnGetInternalMethodReturnType (Op));                }                AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op,                    "null Op pointer");                return ACPI_UINT32_MAX;            }            if (ReferencedNode->Asl.CompileFlags & NODE_METHOD_TYPED)            {                ThisNodeBtype = ReferencedNode->Asl.AcpiBtype;            }            else            {                return (ACPI_UINT32_MAX -1);            }        }    }    else    {        ThisNodeBtype = Op->Asl.AcpiBtype;    }    return (ThisNodeBtype);}/******************************************************************************* * * FUNCTION:    AnCheckForReservedName * * PARAMETERS:  Op              - A parse node *              Name            - NameSeg to check * * RETURN:      None * * DESCRIPTION: Check a NameSeg against the reserved list. * ******************************************************************************/static UINT32AnCheckForReservedName (    ACPI_PARSE_OBJECT       *Op,    char                    *Name){    UINT32                  i;    if (Name[0] == 0)    {        AcpiOsPrintf ("Found a null name, external = %s\n",            Op->Asl.ExternalName);    }    /* All reserved names are prefixed with a single underscore */    if (Name[0] != '_')    {        return (ACPI_NOT_RESERVED_NAME);    }    /* Check for a standard reserved method name */    for (i = 0; ReservedMethods[i].Name; i++)    {        if (ACPI_COMPARE_NAME (Name, ReservedMethods[i].Name))        {            if (ReservedMethods[i].Flags & ASL_RSVD_SCOPE)            {                AslError (ASL_ERROR, ASL_MSG_RESERVED_WORD, Op,                    Op->Asl.ExternalName);                return (ACPI_PREDEFINED_NAME);            }            else if (ReservedMethods[i].Flags & ASL_RSVD_RESOURCE_NAME)            {                AslError (ASL_ERROR, ASL_MSG_RESERVED_WORD, Op,                    Op->Asl.ExternalName);                return (ACPI_PREDEFINED_NAME);            }            /* Return index into reserved array */            return i;        }    }    /*     * Now check for the "special" reserved names --     * GPE:  _Lxx     * GPE:  _Exx     * EC:   _Qxx     */    if ((Name[1] == 'L') ||        (Name[1] == 'E') ||        (Name[1] == 'Q'))    {        /* The next two characters must be hex digits */        if ((isxdigit (Name[2])) &&            (isxdigit (Name[3])))        {            return (ACPI_EVENT_RESERVED_NAME);        }    }    /* Check for the names reserved for the compiler itself: _T_x */    else if ((Op->Asl.ExternalName[1] == 'T') &&             (Op->Asl.ExternalName[2] == '_'))    {        /* Ignore if actually emitted by the compiler */        if (Op->Asl.CompileFlags & NODE_COMPILER_EMITTED)        {            return (ACPI_NOT_RESERVED_NAME);        }        AslError (ASL_ERROR, ASL_MSG_RESERVED_WORD, Op, Op->Asl.ExternalName);        return (ACPI_COMPILER_RESERVED_NAME);    }    /*     * The name didn't match any of the known reserved names. Flag it as a     * warning, since the entire namespace starting with an underscore is     * reserved by the ACPI spec.     */    AslError (ASL_WARNING, ASL_MSG_UNKNOWN_RESERVED_NAME, Op,        Op->Asl.ExternalName);    return (ACPI_NOT_RESERVED_NAME);}/******************************************************************************* * * FUNCTION:    AnCheckForReservedMethod * * PARAMETERS:  Op              - A parse node of type "METHOD". *              MethodInfo      - Saved info about this method * * RETURN:      None * * DESCRIPTION: If method is a reserved name, check that the number of arguments *              and the return type (returns a value or not) is correct. * ******************************************************************************/static voidAnCheckForReservedMethod (    ACPI_PARSE_OBJECT       *Op,    ASL_METHOD_INFO         *MethodInfo){    UINT32                  Index;    /* Check for a match against the reserved name list */    Index = AnCheckForReservedName (Op, Op->Asl.NameSeg);    switch (Index)    {    case ACPI_NOT_RESERVED_NAME:    case ACPI_PREDEFINED_NAME:    case ACPI_COMPILER_RESERVED_NAME:        /* Just return, nothing to do */        break;    case ACPI_EVENT_RESERVED_NAME:        Gbl_ReservedMethods++;        /* NumArguments must be zero for all _Lxx, _Exx, and _Qxx methods */        if (MethodInfo->NumArguments != 0)        {            sprintf (MsgBuffer, "%s requires %d",                        Op->Asl.ExternalName, 0);            AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op, MsgBuffer);        }        break;    default:        Gbl_ReservedMethods++;        /* Matched a reserved method name */        if (MethodInfo->NumArguments != ReservedMethods[Index].NumArguments)        {            sprintf (MsgBuffer, "%s requires %d",                        ReservedMethods[Index].Name,                        ReservedMethods[Index].NumArguments);            if (MethodInfo->NumArguments > ReservedMethods[Index].NumArguments)            {                AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op,                    MsgBuffer);            }            else            {                AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_LO, Op,                    MsgBuffer);            }        }        if (MethodInfo->NumReturnNoValue &&            ReservedMethods[Index].Flags & ASL_RSVD_RETURN_VALUE)        {            sprintf (MsgBuffer, "%s", ReservedMethods[Index].Name);            AslError (ASL_WARNING, ASL_MSG_RESERVED_RETURN_VALUE, Op, MsgBuffer);        }        break;    }}/******************************************************************************* * * FUNCTION:    AnMapObjTypeToBtype * * PARAMETERS:  Op              - A parse node * * RETURN:      A Btype * * DESCRIPTION: Map object to the associated "Btype" * ******************************************************************************/static UINT32AnMapObjTypeToBtype (    ACPI_PARSE_OBJECT       *Op){    switch (Op->Asl.ParseOpcode)    {    case PARSEOP_OBJECTTYPE_BFF:        /* "BuffFieldObj" */        return (ACPI_BTYPE_BUFFER_FIELD);    case PARSEOP_OBJECTTYPE_BUF:        /* "BuffObj" */        return (ACPI_BTYPE_BUFFER);    case PARSEOP_OBJECTTYPE_DDB:        /* "DDBHandleObj" */        return (ACPI_BTYPE_DDB_HANDLE);    case PARSEOP_OBJECTTYPE_DEV:        /* "DeviceObj" */        return (ACPI_BTYPE_DEVICE);    case PARSEOP_OBJECTTYPE_EVT:        /* "EventObj" */        return (ACPI_BTYPE_EVENT);    case PARSEOP_OBJECTTYPE_FLD:        /* "FieldUnitObj" */        return (ACPI_BTYPE_FIELD_UNIT);    case PARSEOP_OBJECTTYPE_INT:        /* "IntObj" */        return (ACPI_BTYPE_INTEGER);    case PARSEOP_OBJECTTYPE_MTH:        /* "MethodObj" */        return (ACPI_BTYPE_METHOD);    case PARSEOP_OBJECTTYPE_MTX:        /* "MutexObj" */        return (ACPI_BTYPE_MUTEX);    case PARSEOP_OBJECTTYPE_OPR:        /* "OpRegionObj" */        return (ACPI_BTYPE_REGION);    case PARSEOP_OBJECTTYPE_PKG:        /* "PkgObj" */        return (ACPI_BTYPE_PACKAGE);    case PARSEOP_OBJECTTYPE_POW:        /* "PowerResObj" */        return (ACPI_BTYPE_POWER);    case PARSEOP_OBJECTTYPE_STR:        /* "StrObj" */        return (ACPI_BTYPE_STRING);    case PARSEOP_OBJECTTYPE_THZ:        /* "ThermalZoneObj" */        return (ACPI_BTYPE_THERMAL);    case PARSEOP_OBJECTTYPE_UNK:        /* "UnknownObj" */        return (ACPI_BTYPE_OBJECTS_AND_REFS);    default:        return (0);    }}/******************************************************************************* * * FUNCTION:    AnMethodAnalysisWalkBegin * * PARAMETERS:  ASL_WALK_CALLBACK * * RETURN:      Status * * DESCRIPTION: Descending callback for the analysis walk. Check methods for: *              1) Initialized local variables *              2) Valid arguments *              3) Return types * ******************************************************************************/ACPI_STATUSAnMethodAnalysisWalkBegin (    ACPI_PARSE_OBJECT       *Op,    UINT32                  Level,    void                    *Context){    ASL_ANALYSIS_WALK_INFO  *WalkInfo = (ASL_ANALYSIS_WALK_INFO *) Context;    ASL_METHOD_INFO         *MethodInfo = WalkInfo->MethodStack;    ACPI_PARSE_OBJECT       *Next;    UINT32                  RegisterNumber;    UINT32                  i;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -