pstree.c revision 199767f8919635c4928607450d9e0abb932109ce
/******************************************************************************
*
* Module Name: pstree - Parser op tree manipulation/traversal/search
*
*****************************************************************************/
/*
* Copyright (C) 2000 - 2015, Intel Corp.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* NO WARRANTY
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGES.
*/
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME ("pstree")
/* Local prototypes */
#ifdef ACPI_OBSOLETE_FUNCTIONS
#endif
/*******************************************************************************
*
* FUNCTION: AcpiPsGetArg
*
* PARAMETERS: Op - Get an argument for this op
* Argn - Nth argument to get
*
* RETURN: The argument (as an Op object). NULL if argument does not exist
*
* DESCRIPTION: Get the specified op's argument.
*
******************************************************************************/
{
const ACPI_OPCODE_INFO *OpInfo;
/*
if (Op->Common.AmlOpcode == AML_INT_CONNECTION_OP)
{
return (Op->Common.Value.Arg);
}
*/
/* Get the info structure for this opcode */
{
/* Invalid opcode or ASCII character */
return (NULL);
}
/* Check if this opcode requires argument sub-objects */
{
/* Has no linked argument objects */
return (NULL);
}
/* Get the requested argument object */
{
Argn--;
}
return (Arg);
}
/*******************************************************************************
*
* FUNCTION: AcpiPsAppendArg
*
* PARAMETERS: Op - Append an argument to this Op.
* Arg - Argument Op to append
*
* RETURN: None.
*
* DESCRIPTION: Append an argument to an op's argument list (a NULL arg is OK)
*
******************************************************************************/
void
{
const ACPI_OPCODE_INFO *OpInfo;
if (!Op)
{
return;
}
/* Get the info structure for this opcode */
{
/* Invalid opcode */
return;
}
/* Check if this opcode requires argument sub-objects */
{
/* Has no linked argument objects */
return;
}
/* Append the argument to the linked argument list */
{
/* Append to existing argument list */
{
}
}
else
{
/* No argument list, this will be the first argument */
}
/* Set the parent in this arg and any args linked after it */
while (Arg)
{
}
}
/*******************************************************************************
*
* FUNCTION: AcpiPsGetDepthNext
*
* PARAMETERS: Origin - Root of subtree to search
* Op - Last (previous) Op that was found
*
* RETURN: Next Op found in the search.
*
* DESCRIPTION: Get next op in tree (walking the tree in depth-first order)
* Return NULL when reaching "origin" or when walking up from root
*
******************************************************************************/
{
if (!Op)
{
return (NULL);
}
/* Look for an argument or child */
if (Next)
{
return (Next);
}
/* Look for a sibling */
if (Next)
{
return (Next);
}
/* Look for a sibling of parent */
while (Parent)
{
{
}
{
/* Reached parent of origin, end search */
return (NULL);
}
{
/* Found sibling of parent */
}
}
return (Next);
}
#ifdef ACPI_OBSOLETE_FUNCTIONS
/*******************************************************************************
*
* FUNCTION: AcpiPsGetChild
*
* PARAMETERS: Op - Get the child of this Op
*
* RETURN: Child Op, Null if none is found.
*
* DESCRIPTION: Get op's children or NULL if none
*
******************************************************************************/
{
{
case AML_SCOPE_OP:
case AML_ELSE_OP:
case AML_DEVICE_OP:
case AML_THERMAL_ZONE_OP:
case AML_INT_METHODCALL_OP:
break;
case AML_BUFFER_OP:
case AML_PACKAGE_OP:
case AML_METHOD_OP:
case AML_IF_OP:
case AML_WHILE_OP:
case AML_FIELD_OP:
break;
case AML_POWER_RES_OP:
case AML_INDEX_FIELD_OP:
break;
case AML_PROCESSOR_OP:
case AML_BANK_FIELD_OP:
break;
default:
/* All others have no children */
break;
}
return (Child);
}
#endif