/*******************************************************************************
*
* Module Name: utmisc - common utility procedures
*
******************************************************************************/
/*
* Copyright (C) 2000 - 2016, 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.
*/
#include "acpi.h"
#include "accommon.h"
#include "acnamesp.h"
ACPI_MODULE_NAME ("utmisc")
/*******************************************************************************
*
* FUNCTION: AcpiUtIsPciRootBridge
*
*
* RETURN: TRUE if the Id is a match for a PCI/PCI-Express Root Bridge
*
* DESCRIPTION: Determine if the input ID is a PCI Root Bridge ID.
*
******************************************************************************/
char *Id)
{
/*
* Check if this is a PCI root bridge.
* ACPI 3.0+: check for a PCI Express root also.
*/
PCI_ROOT_HID_STRING)) ||
{
return (TRUE);
}
return (FALSE);
}
/*******************************************************************************
*
* FUNCTION: AcpiUtIsAmlTable
*
* PARAMETERS: Table - An ACPI table
*
* RETURN: TRUE if table contains executable AML; FALSE otherwise
*
* DESCRIPTION: Check ACPI Signature for a table that contains AML code.
* Currently, these are DSDT,SSDT,PSDT. All other table types are
* data tables that do not contain AML code.
*
******************************************************************************/
{
/* These are the only tables that contain executable AML */
{
return (TRUE);
}
return (FALSE);
}
#endif
/*******************************************************************************
*
* FUNCTION: AcpiUtDwordByteSwap
*
* PARAMETERS: Value - Value to be converted
*
* RETURN: UINT32 integer with bytes swapped
*
* DESCRIPTION: Convert a 32-bit value to big-endian (swap the bytes)
*
******************************************************************************/
{
union
{
} Out;
union
{
} In;
}
/*******************************************************************************
*
* FUNCTION: AcpiUtSetIntegerWidth
*
* PARAMETERS: Revision From DSDT header
*
* RETURN: None
*
* DESCRIPTION: Set the global integer bit width based upon the revision
* of the DSDT. For Revision 1 and 0, Integers are 32 bits.
* For Revision 2 and above, Integers are 64 bits. Yes, this
* makes a difference.
*
******************************************************************************/
void
{
if (Revision < 2)
{
/* 32-bit case */
AcpiGbl_IntegerBitWidth = 32;
}
else
{
/* 64-bit case (ACPI 2.0+) */
AcpiGbl_IntegerBitWidth = 64;
}
}
/*******************************************************************************
*
* FUNCTION: AcpiUtCreateUpdateStateAndPush
*
* PARAMETERS: Object - Object to be added to the new state
* StateList - List the state will be added to
*
* RETURN: Status
*
* DESCRIPTION: Create a new state and push it
*
******************************************************************************/
{
/* Ignore null objects; these are expected */
if (!Object)
{
return (AE_OK);
}
if (!State)
{
return (AE_NO_MEMORY);
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiUtWalkPackageTree
*
* PARAMETERS: SourceObject - The package to walk
* TargetObject - Target object (if package is being copied)
* WalkCallback - Called once for each package element
* Context - Passed to the callback function
*
* RETURN: Status
*
* DESCRIPTION: Walk through a package
*
******************************************************************************/
void *TargetObject,
void *Context)
{
if (!State)
{
}
while (State)
{
/* Get one element of the package */
/*
* Check for:
* 1) An uninitialized package element. It is completely
* legal to declare a package and leave it uninitialized
* 2) Not an internal object - can be a namespace node instead
* 3) Any type other than a package. Packages are handled in else
* case below.
*/
if ((!ThisSourceObj) ||
{
if (ACPI_FAILURE (Status))
{
}
{
/*
* We've handled all of the objects at this level, This means
* that we have just completed a package. That package may
* have contained one or more packages itself.
*
* Delete this state and pop the previous state (package).
*/
/* Finished when there are no more states */
if (!State)
{
/*
* We have handled all of the objects in the top level
* package just add the length of the package objects
* and exit
*/
}
/*
* Go back up a level and move the index past the just
* completed package object.
*/
}
}
else
{
/* This is a subobject of type package */
Status = WalkCallback (
if (ACPI_FAILURE (Status))
{
}
/*
* Push the current state and create a new one
* The callback above returned a new target package object.
*/
if (!State)
{
/* Free any stacked Update State objects */
while (StateList)
{
}
}
}
}
/* We should never get here */
}
#ifdef ACPI_DEBUG_OUTPUT
/*******************************************************************************
*
* FUNCTION: AcpiUtDisplayInitPathname
*
* PARAMETERS: Type - Object type of the node
* ObjHandle - Handle whose pathname will be displayed
* Path - Additional path string to be appended.
* (NULL if no extra path)
*
* RETURN: ACPI_STATUS
*
* DESCRIPTION: Display full pathname of an object, DEBUG ONLY
*
******************************************************************************/
void
const char *Path)
{
/* Only print the path if the appropriate debug level is enabled */
if (!(AcpiDbgLevel & ACPI_LV_INIT_NAMES))
{
return;
}
/* Get the full pathname to the node */
if (ACPI_FAILURE (Status))
{
return;
}
/* Print what we're doing */
switch (Type)
{
case ACPI_TYPE_METHOD:
AcpiOsPrintf ("Executing ");
break;
default:
AcpiOsPrintf ("Initializing ");
break;
}
/* Print the object type and pathname */
AcpiOsPrintf ("%-12s %s",
/* Extra path is used to append names like _STA, _INI, etc. */
if (Path)
{
}
AcpiOsPrintf ("\n");
}
#endif