FreeBSD/sys/contrib/dev/acpica/compiler/aslopt.c
/*******************************************************************************
 *
 * FUNCTION:    OptSearchToRoot
 *
 * PARAMETERS:  Op                  - Current parser op
 *              WalkState           - Current state
 *              CurrentNode         - Where we are in the namespace
 *              TargetNode          - Node to which we are referring
 *              TargetPath          - External full path to the target node
 *              NewPath             - Where the optimized path is returned
 *
 * RETURN:      Status
 *
 * DESCRIPTION: Attempt to optimize a reference to a single 4-character ACPI
 *              name utilizing the search-to-root name resolution algorithm
 *              that is used by AML interpreters.
 *
 ******************************************************************************/


Status

Attempt to optimize a reference to a single 4-character ACPI
name utilizing the search-to-root name resolution algorithm
that is used by AML interpreters.
Status Attempt to optimize a reference to a single 4 - character ACPI name utilizing the search - to - root name resolution algorithm that is used by AML interpreters .
static ACPI_STATUS
OptSearchToRoot (
    ACPI_PARSE_OBJECT       *Op,
    ACPI_WALK_STATE         *WalkState,
    ACPI_NAMESPACE_NODE     *CurrentNode,
    ACPI_NAMESPACE_NODE     *TargetNode,
    ACPI_BUFFER             *TargetPath,
    char                    **NewPath)
{
    ACPI_NAMESPACE_NODE     *Node;
    ACPI_GENERIC_STATE      ScopeInfo;
    ACPI_STATUS             Status;
    char                    *Path;
    ACPI_FUNCTION_NAME (OptSearchToRoot);
    Path = &(((char *) TargetPath->Pointer)[
        TargetPath->Length - ACPI_NAME_SIZE]),
    ScopeInfo.Scope.Node = CurrentNode;
    Status = AcpiNsLookup (&ScopeInfo, Path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
        ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
        WalkState, &(Node));
    if (ACPI_FAILURE (Status))
    {
        return (Status);
    }
    if (Node != TargetNode)
    {
        return (AE_NOT_FOUND);
    }
    ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
        "NAMESEG:   %-24s", Path));
    *NewPath = UtStringCacheCalloc (ACPI_NAME_SIZE + 1);
    strcpy (*NewPath, Path);
    if (strncmp (*NewPath, "_T_", 3))
    {
        AslError (ASL_OPTIMIZATION, ASL_MSG_SINGLE_NAME_OPTIMIZATION,
            Op, *NewPath);
    }
    return (AE_OK);
}
static ACPI_STATUS OptSearchToRoot ( ACPI_PARSE_OBJECT * Op , ACPI_WALK_STATE * WalkState , ACPI_NAMESPACE_NODE * CurrentNode , ACPI_NAMESPACE_NODE * TargetNode , ACPI_BUFFER * TargetPath , char * * NewPath ) { ACPI_NAMESPACE_NODE * Node ; ACPI_GENERIC_STATE ScopeInfo ; ACPI_STATUS Status ; char * Path ; ACPI_FUNCTION_NAME ( OptSearchToRoot ) ; Path = & ( ( ( char * ) TargetPath -> Pointer ) [ TargetPath -> Length - ACPI_NAME_SIZE ] ) , ScopeInfo . Scope . Node = CurrentNode ; Status = AcpiNsLookup ( & ScopeInfo , Path , ACPI_TYPE_ANY , ACPI_IMODE_EXECUTE , ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE , WalkState , & ( Node ) ) ; if ( ACPI_FAILURE ( Status ) ) { return ( Status ) ; } if ( Node != TargetNode ) { return ( AE_NOT_FOUND ) ; } ACPI_DEBUG_PRINT_RAW ( ( ACPI_DB_OPTIMIZATIONS , " " , Path ) ) ; * NewPath = UtStringCacheCalloc ( ACPI_NAME_SIZE + 1 ) ; strcpy ( * NewPath , Path ) ; if ( strncmp ( * NewPath , " " , 3 ) ) { AslError ( ASL_OPTIMIZATION , ASL_MSG_SINGLE_NAME_OPTIMIZATION , Op , * NewPath ) ; } return ( AE_OK ) ; }
FUNCTION:    OptSearchToRoot
 PARAMETERS:  Op                  - Current parser op
              WalkState           - Current state
              CurrentNode         - Where we are in the namespace
              TargetNode          - Node to which we are referring
              TargetPath          - External full path to the target node
              NewPath             - Where the optimized path is returned
FUNCTION : OptSearchToRoot PARAMETERS : Op - Current parser op WalkState - Current state CurrentNode - Where we are in the namespace TargetNode - Node to which we are referring TargetPath - External full path to the target node NewPath - Where the optimized path is returned
/*
     * Check if search-to-root can be utilized. Use the last NameSeg of
     * the NamePath and 1) See if can be found and 2) If found, make
     * sure that it is the same node that we want. If there is another
     * name in the search path before the one we want, the nodes will
     * not match, and we cannot use this optimization.
     */ /* Lookup the NameSeg using SEARCH_PARENT (search-to-root) */ /*
     * We found the name, but we must check to make sure that the node
     * matches. Otherwise, there is another identical name in the search
     * path that precludes the use of this optimization.
     */ /*
         * This means that another object with the same name was found first,
         * and we cannot use this optimization.
         */ /* Found the node, we can use this optimization */ /* We must allocate a new string for the name (TargetPath gets deleted) */