FreeBSD/sys/contrib/dev/acpica/common/adwalk.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiDmFindOrphanDescending
 *
 * PARAMETERS:  ASL_WALK_CALLBACK
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Check namepath Ops for orphaned method invocations
 *
 * Note: Parts of this are experimental, under possible further development.
 *
 ******************************************************************************/


Status

Check namepath Ops for orphaned method invocations

Parts of this are experimental, under possible further development.
Status Check namepath Ops for orphaned method invocations Parts of this are experimental under possible further development .
static ACPI_STATUS
AcpiDmFindOrphanDescending (
    ACPI_PARSE_OBJECT       *Op,
    UINT32                  Level,
    void                    *Context)
{
    const ACPI_OPCODE_INFO  *OpInfo;
    ACPI_PARSE_OBJECT       *ChildOp;
    ACPI_PARSE_OBJECT       *NextOp;
    ACPI_PARSE_OBJECT       *ParentOp;
    UINT32                  ArgCount;
    if (!Op)
    {
        return (AE_OK);
    }
    OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
    switch (Op->Common.AmlOpcode)
    {
#ifdef ACPI_UNDER_DEVELOPMENT
    case AML_ADD_OP:
        ChildOp = Op->Common.Value.Arg;
        if ((ChildOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
            !ChildOp->Common.Node)
        {
            AcpiNsExternalizeName (ACPI_UINT32_MAX, ChildOp->Common.Value.String,
                NULL, &Path);
            AcpiOsPrintf ("/* %-16s A-NAMEPATH: %s  */\n",
                Op->Common.AmlOpName, Path);
            ACPI_FREE (Path);
            NextOp = Op->Common.Next;
            if (!NextOp)
            {
                AcpiDmAddOpToExternalList (ChildOp,
                    ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0);
                return (AE_OK);
            }
            ArgCount = AcpiDmInspectPossibleArgs (3, 1, NextOp);
            AcpiOsPrintf ("/* A-CHILDREN: %u Actual %u */\n",
                ArgCount, AcpiDmCountChildren (Op));
            if (ArgCount < 1)
            {
                AcpiDmAddOpToExternalList (ChildOp,
                    ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0);
                return (AE_OK);
            }
            AcpiDmAddOpToExternalList (ChildOp,
                ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount, 0);
        }
        break;
#endif
    case AML_STORE_OP:
        ChildOp = Op->Common.Value.Arg;
        if ((ChildOp->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
            !ChildOp->Common.Node)
        {
            NextOp = Op->Common.Next;
            if (!NextOp)
            {
                AcpiDmAddOpToExternalList (ChildOp,
                    ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0);
                return (AE_OK);
            }
            ArgCount = AcpiDmInspectPossibleArgs (2, 1, NextOp);
            if (ArgCount <= 1)
            {
                AcpiDmAddOpToExternalList (ChildOp,
                    ChildOp->Common.Value.String, ACPI_TYPE_INTEGER, ArgCount, 0);
                return (AE_OK);
            }
            AcpiDmAddOpToExternalList (ChildOp,
                ChildOp->Common.Value.String, ACPI_TYPE_METHOD, ArgCount, 0);
        }
        break;
    case AML_INT_NAMEPATH_OP:
        ParentOp = Op->Common.Parent;
        OpInfo = AcpiPsGetOpcodeInfo (ParentOp->Common.AmlOpcode);
        if ((OpInfo->Class != AML_CLASS_EXECUTE) &&
            (OpInfo->Class != AML_CLASS_CREATE) &&
            (OpInfo->ObjectType != ACPI_TYPE_LOCAL_ALIAS) &&
            (ParentOp->Common.AmlOpcode != AML_INT_METHODCALL_OP) &&
            !Op->Common.Node)
        {
            ArgCount = AcpiDmInspectPossibleArgs (0, 0, Op);
            if (ArgCount == 0)
            {
                if (((ParentOp->Common.AmlOpcode == AML_IF_OP) ||
                     (ParentOp->Common.AmlOpcode == AML_WHILE_OP) ||
                     (ParentOp->Common.AmlOpcode == AML_RETURN_OP)) &&
                     (ParentOp->Common.Value.Arg == Op))
                {
                    AcpiDmAddOpToExternalList (Op,
                        Op->Common.Value.String, ACPI_TYPE_INTEGER, 0, 0);
                    break;
                }
            }
            AcpiDmAddOpToExternalList (Op,
                Op->Common.Value.String, ACPI_TYPE_METHOD, ArgCount, 0);
        }
        break;
    default:
        break;
    }
    return (AE_OK);
}
static ACPI_STATUS AcpiDmFindOrphanDescending ( ACPI_PARSE_OBJECT * Op , UINT32 Level , void * Context ) { const ACPI_OPCODE_INFO * OpInfo ; ACPI_PARSE_OBJECT * ChildOp ; ACPI_PARSE_OBJECT * NextOp ; ACPI_PARSE_OBJECT * ParentOp ; UINT32 ArgCount ; if ( ! Op ) { return ( AE_OK ) ; } OpInfo = AcpiPsGetOpcodeInfo ( Op -> Common . AmlOpcode ) ; switch ( Op -> Common . AmlOpcode ) { #ifdef ACPI_UNDER_DEVELOPMENT case AML_ADD_OP : ChildOp = Op -> Common . Value . Arg ; if ( ( ChildOp -> Common . AmlOpcode == AML_INT_NAMEPATH_OP ) && ! ChildOp -> Common . Node ) { AcpiNsExternalizeName ( ACPI_UINT32_MAX , ChildOp -> Common . Value . String , NULL , & Path ) ; AcpiOsPrintf ( " \n " , Op -> Common . AmlOpName , Path ) ; ACPI_FREE ( Path ) ; NextOp = Op -> Common . Next ; if ( ! NextOp ) { AcpiDmAddOpToExternalList ( ChildOp , ChildOp -> Common . Value . String , ACPI_TYPE_INTEGER , 0 , 0 ) ; return ( AE_OK ) ; } ArgCount = AcpiDmInspectPossibleArgs ( 3 , 1 , NextOp ) ; AcpiOsPrintf ( " \n " , ArgCount , AcpiDmCountChildren ( Op ) ) ; if ( ArgCount < 1 ) { AcpiDmAddOpToExternalList ( ChildOp , ChildOp -> Common . Value . String , ACPI_TYPE_INTEGER , 0 , 0 ) ; return ( AE_OK ) ; } AcpiDmAddOpToExternalList ( ChildOp , ChildOp -> Common . Value . String , ACPI_TYPE_METHOD , ArgCount , 0 ) ; } break ; #endif case AML_STORE_OP : ChildOp = Op -> Common . Value . Arg ; if ( ( ChildOp -> Common . AmlOpcode == AML_INT_NAMEPATH_OP ) && ! ChildOp -> Common . Node ) { NextOp = Op -> Common . Next ; if ( ! NextOp ) { AcpiDmAddOpToExternalList ( ChildOp , ChildOp -> Common . Value . String , ACPI_TYPE_INTEGER , 0 , 0 ) ; return ( AE_OK ) ; } ArgCount = AcpiDmInspectPossibleArgs ( 2 , 1 , NextOp ) ; if ( ArgCount <= 1 ) { AcpiDmAddOpToExternalList ( ChildOp , ChildOp -> Common . Value . String , ACPI_TYPE_INTEGER , ArgCount , 0 ) ; return ( AE_OK ) ; } AcpiDmAddOpToExternalList ( ChildOp , ChildOp -> Common . Value . String , ACPI_TYPE_METHOD , ArgCount , 0 ) ; } break ; case AML_INT_NAMEPATH_OP : ParentOp = Op -> Common . Parent ; OpInfo = AcpiPsGetOpcodeInfo ( ParentOp -> Common . AmlOpcode ) ; if ( ( OpInfo -> Class != AML_CLASS_EXECUTE ) && ( OpInfo -> Class != AML_CLASS_CREATE ) && ( OpInfo -> ObjectType != ACPI_TYPE_LOCAL_ALIAS ) && ( ParentOp -> Common . AmlOpcode != AML_INT_METHODCALL_OP ) && ! Op -> Common . Node ) { ArgCount = AcpiDmInspectPossibleArgs ( 0 , 0 , Op ) ; if ( ArgCount == 0 ) { if ( ( ( ParentOp -> Common . AmlOpcode == AML_IF_OP ) || ( ParentOp -> Common . AmlOpcode == AML_WHILE_OP ) || ( ParentOp -> Common . AmlOpcode == AML_RETURN_OP ) ) && ( ParentOp -> Common . Value . Arg == Op ) ) { AcpiDmAddOpToExternalList ( Op , Op -> Common . Value . String , ACPI_TYPE_INTEGER , 0 , 0 ) ; break ; } } AcpiDmAddOpToExternalList ( Op , Op -> Common . Value . String , ACPI_TYPE_METHOD , ArgCount , 0 ) ; } break ; default : break ; } return ( AE_OK ) ; }
FUNCTION:    AcpiDmFindOrphanDescending
 PARAMETERS:  ASL_WALK_CALLBACK
FUNCTION : AcpiDmFindOrphanDescending PARAMETERS : ASL_WALK_CALLBACK
/* This NamePath has no args, assume it is an integer */ /* One Arg means this is just a Store(Name,Target) */ /* This NamePath has no args, assume it is an integer */ /* One Arg means this is just a Store(Name,Target) */ /* Must examine parent to see if this namepath is an argument */ /*
             * Check if namepath is a predicate for if/while or lone parameter to
             * a return.
             */ /* And namepath is the first argument */ /*
             * This is a standalone namestring (not a parameter to another
             * operator) - it *must* be a method invocation, nothing else is
             * grammatically possible.
             */