FreeBSD/sys/contrib/dev/acpica/common/adwalk.c
/*******************************************************************************
 *
 * FUNCTION:    AcpiDmLoadDescendingOp
 *
 * PARAMETERS:  ASL_WALK_CALLBACK
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Descending handler for namespace control method object load
 *
 ******************************************************************************/


Status

Descending handler for namespace control method object load
Status Descending handler for namespace control method object load
static ACPI_STATUS
AcpiDmLoadDescendingOp (
    ACPI_PARSE_OBJECT       *Op,
    UINT32                  Level,
    void                    *Context)
{
    ACPI_OP_WALK_INFO       *Info = Context;
    const ACPI_OPCODE_INFO  *OpInfo;
    ACPI_WALK_STATE         *WalkState;
    ACPI_OBJECT_TYPE        ObjectType;
    ACPI_STATUS             Status;
    char                    *Path = NULL;
    ACPI_PARSE_OBJECT       *NextOp;
    ACPI_NAMESPACE_NODE     *Node;
    char                    FieldPath[5];
    BOOLEAN                 PreDefined = FALSE;
    UINT8                   PreDefineIndex = 0;
    WalkState = Info->WalkState;
    OpInfo = AcpiPsGetOpcodeInfo (Op->Common.AmlOpcode);
    ObjectType = OpInfo->ObjectType;
    ObjectType = AslMapNamedOpcodeToDataType (Op->Asl.AmlOpcode);
    if (!(OpInfo->Flags & AML_NAMED) &&
        !(OpInfo->Flags & AML_CREATE))
    {
        goto Exit;
    }
    if (OpInfo->Flags & AML_NAMED)
    {
        Path = (char *) Op->Named.Path;
        if (!Path && Op->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
        {
            *ACPI_CAST_PTR (UINT32, &FieldPath[0]) = Op->Named.Name;
            FieldPath[4] = 0;
            Path = FieldPath;
        }
    }
    else if (OpInfo->Flags & AML_CREATE)
    {
        NextOp = Op->Common.Value.Arg;
        while (NextOp->Common.Next)
        {
            NextOp = NextOp->Common.Next;
        }
        Path = NextOp->Common.Value.String;
    }
    if (!Path)
    {
        goto Exit;
    }
    Status = AcpiNsLookup (WalkState->ScopeInfo, Path, ObjectType,
        ACPI_IMODE_LOAD_PASS2, ACPI_NS_DONT_OPEN_SCOPE,
        WalkState, &Node);
    Op->Common.Node = Node;
    if (ACPI_SUCCESS (Status))
    {
        while (AcpiGbl_PreDefinedNames[PreDefineIndex].Name)
        {
            if (ACPI_COMPARE_NAME (Node->Name.Ascii,
                AcpiGbl_PreDefinedNames[PreDefineIndex].Name))
            {
                PreDefined = TRUE;
                break;
            }
            PreDefineIndex++;
        }
        if (!PreDefined && Node != AcpiGbl_RootNode &&
            Op->Common.AmlOpcode != AML_SCOPE_OP)
        {
            Node->OwnerId = WalkState->OwnerId;
        }
    }
Exit:
    if (AcpiNsOpensScope (ObjectType))
    {
        if (Op->Common.Node)
        {
            Status = AcpiDsScopeStackPush (Op->Common.Node, ObjectType,
                WalkState);
            if (ACPI_FAILURE (Status))
            {
                return (Status);
            }
        }
    }
    return (AE_OK);
}
static ACPI_STATUS AcpiDmLoadDescendingOp ( ACPI_PARSE_OBJECT * Op , UINT32 Level , void * Context ) { ACPI_OP_WALK_INFO * Info = Context ; const ACPI_OPCODE_INFO * OpInfo ; ACPI_WALK_STATE * WalkState ; ACPI_OBJECT_TYPE ObjectType ; ACPI_STATUS Status ; char * Path = NULL ; ACPI_PARSE_OBJECT * NextOp ; ACPI_NAMESPACE_NODE * Node ; char FieldPath [ 5 ] ; BOOLEAN PreDefined = FALSE ; UINT8 PreDefineIndex = 0 ; WalkState = Info -> WalkState ; OpInfo = AcpiPsGetOpcodeInfo ( Op -> Common . AmlOpcode ) ; ObjectType = OpInfo -> ObjectType ; ObjectType = AslMapNamedOpcodeToDataType ( Op -> Asl . AmlOpcode ) ; if ( ! ( OpInfo -> Flags & AML_NAMED ) && ! ( OpInfo -> Flags & AML_CREATE ) ) { goto Exit ; } if ( OpInfo -> Flags & AML_NAMED ) { Path = ( char * ) Op -> Named . Path ; if ( ! Path && Op -> Common . AmlOpcode == AML_INT_NAMEDFIELD_OP ) { * ACPI_CAST_PTR ( UINT32 , & FieldPath [ 0 ] ) = Op -> Named . Name ; FieldPath [ 4 ] = 0 ; Path = FieldPath ; } } else if ( OpInfo -> Flags & AML_CREATE ) { NextOp = Op -> Common . Value . Arg ; while ( NextOp -> Common . Next ) { NextOp = NextOp -> Common . Next ; } Path = NextOp -> Common . Value . String ; } if ( ! Path ) { goto Exit ; } Status = AcpiNsLookup ( WalkState -> ScopeInfo , Path , ObjectType , ACPI_IMODE_LOAD_PASS2 , ACPI_NS_DONT_OPEN_SCOPE , WalkState , & Node ) ; Op -> Common . Node = Node ; if ( ACPI_SUCCESS ( Status ) ) { while ( AcpiGbl_PreDefinedNames [ PreDefineIndex ] . Name ) { if ( ACPI_COMPARE_NAME ( Node -> Name . Ascii , AcpiGbl_PreDefinedNames [ PreDefineIndex ] . Name ) ) { PreDefined = TRUE ; break ; } PreDefineIndex ++ ; } if ( ! PreDefined && Node != AcpiGbl_RootNode && Op -> Common . AmlOpcode != AML_SCOPE_OP ) { Node -> OwnerId = WalkState -> OwnerId ; } } Exit : if ( AcpiNsOpensScope ( ObjectType ) ) { if ( Op -> Common . Node ) { Status = AcpiDsScopeStackPush ( Op -> Common . Node , ObjectType , WalkState ) ; if ( ACPI_FAILURE ( Status ) ) { return ( Status ) ; } } } return ( AE_OK ) ; }
FUNCTION:    AcpiDmLoadDescendingOp
 PARAMETERS:  ASL_WALK_CALLBACK
FUNCTION : AcpiDmLoadDescendingOp PARAMETERS : ASL_WALK_CALLBACK
/* Only interested in operators that create new names */ /* Get the NamePath from the appropriate place */ /* For all named operators, get the new name */ /* New name is the last child */ /* Insert the name into the namespace */ /* Check if it's a predefined node */ /*
         * Set node owner id if it satisfies all the following conditions:
         * 1) Not a predefined node, _SB_ etc
         * 2) Not the root node
         * 3) Not a node created by Scope
         */