utcopy.c revision db2bae3047e71d795bde12e3baa621f4b6cc8930
/******************************************************************************
*
* Module Name: utcopy - Internal to external object translation utilities
* $Revision: 1.137 $
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* Code in any form, with the right to sublicense such rights; and
*
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
* license (with the right to sublicense), under only those claims of Intel
* patents that are infringed by the Original Intel Code, to make, use, sell,
* offer to sell, and import the Covered Code and derivative works thereof
* solely to the minimum extent necessary to exercise the above copyright
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************/
#define __UTCOPY_C__
#include "acpi.h"
#include "acnamesp.h"
#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME ("utcopy")
/* Local prototypes */
static ACPI_STATUS
static ACPI_STATUS
void *Context);
static ACPI_STATUS
static ACPI_STATUS
static ACPI_STATUS
static ACPI_STATUS
static ACPI_STATUS
void *Context);
static ACPI_STATUS
/*******************************************************************************
*
* FUNCTION: AcpiUtCopyIsimpleToEsimple
*
* PARAMETERS: InternalObject - Source object to be copied
* ExternalObject - Where to return the copied object
* DataSpace - Where object data is returned (such as
* buffer and string data)
* BufferSpaceUsed - Length of DataSpace that was used
*
* RETURN: Status
*
* DESCRIPTION: This function is called to copy a simple internal object to
* an external object.
*
* The DataSpace buffer is assumed to have sufficient space for
* the object.
*
******************************************************************************/
static ACPI_STATUS
{
*BufferSpaceUsed = 0;
/*
* Check for NULL object case (could be an uninitialized
* package element)
*/
if (!InternalObject)
{
}
/* Always clear the external object */
/*
* In general, the external object will be the same type as
* the internal object
*/
/* However, only a limited number of external types are supported */
switch (ACPI_GET_OBJECT_TYPE (InternalObject))
{
case ACPI_TYPE_STRING:
ACPI_MEMCPY ((void *) DataSpace,
break;
case ACPI_TYPE_BUFFER:
ACPI_MEMCPY ((void *) DataSpace,
break;
case ACPI_TYPE_INTEGER:
break;
/* This is an object reference. */
{
case ACPI_REFCLASS_NAME:
/*
* For namepath, return the object handle ("reference")
* We are referring to the namespace node
*/
break;
default:
/* All other reference types are unsupported */
}
break;
case ACPI_TYPE_PROCESSOR:
break;
case ACPI_TYPE_POWER:
break;
default:
/*
* There is no corresponding external object type
*/
"Unsupported object type, cannot convert to external object: %s",
}
}
/*******************************************************************************
*
* FUNCTION: AcpiUtCopyIelementToEelement
*
* PARAMETERS: ACPI_PKG_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Copy one package element to another package element
*
******************************************************************************/
static ACPI_STATUS
void *Context)
{
TargetObject = (ACPI_OBJECT *)
switch (ObjectType)
{
case ACPI_COPY_TYPE_SIMPLE:
/*
* This is a simple or null object
*/
if (ACPI_FAILURE (Status))
{
return (Status);
}
break;
case ACPI_COPY_TYPE_PACKAGE:
/*
* Build the package object
*/
/*
* Pass the new package object back to the package walk routine
*/
/*
* Save space for the array of objects (Package elements)
* update the buffer length counter
*/
sizeof (ACPI_OBJECT));
break;
default:
return (AE_BAD_PARAMETER);
}
return (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiUtCopyIpackageToEpackage
*
* PARAMETERS: InternalObject - Pointer to the object we are returning
* Buffer - Where the object is returned
* SpaceUsed - Where the object length is returned
*
* RETURN: Status
*
* DESCRIPTION: This function is called to place a package object in a user
* buffer. A package object by definition contains other objects.
*
* The buffer is assumed to have sufficient space for the object.
* The caller must have verified the buffer length needed using the
* AcpiUtGetObjectSize function before calling this function.
*
******************************************************************************/
static ACPI_STATUS
{
/*
* First package at head of the buffer
*/
/*
* Free space begins right after the first package
*/
sizeof (ACPI_OBJECT));
Info.ObjectSpace = 0;
/*
* Leave room for an array of ACPI_OBJECTS in the buffer
* and move the free space past it
*/
ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
}
/*******************************************************************************
*
* FUNCTION: AcpiUtCopyIobjectToEobject
*
* PARAMETERS: InternalObject - The internal object to be converted
* BufferPtr - Where the object is returned
*
* RETURN: Status
*
* DESCRIPTION: This function is called to build an API object to be returned to
* the caller.
*
******************************************************************************/
{
{
/*
* Package object: Copy all subobjects (including
* nested packages)
*/
}
else
{
/*
* Build a simple object (no nested objects)
*/
ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT))),
/*
* build simple does not include the object size in the length
* so we add it in here
*/
}
}
/*******************************************************************************
*
* FUNCTION: AcpiUtCopyEsimpleToIsimple
*
* PARAMETERS: ExternalObject - The external object to be converted
* RetInternalObject - Where the internal object is returned
*
* RETURN: Status
*
* DESCRIPTION: This function copies an external object to an internal one.
* NOTE: Pointers can be copied, we don't need to copy data.
* (The pointers have to be valid in our address space no matter
* what we do with them!)
*
******************************************************************************/
static ACPI_STATUS
{
/*
* Simple types supported are: String, Buffer, Integer
*/
switch (ExternalObject->Type)
{
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
case ACPI_TYPE_INTEGER:
if (!InternalObject)
{
}
break;
case ACPI_TYPE_ANY: /* This is the case for a NULL object */
default:
/* All other types are not supported */
}
/* Must COPY string and buffer contents */
switch (ExternalObject->Type)
{
case ACPI_TYPE_STRING:
{
goto ErrorExit;
}
break;
case ACPI_TYPE_BUFFER:
{
goto ErrorExit;
}
/* Mark buffer data valid */
break;
case ACPI_TYPE_INTEGER:
break;
/* TBD: should validate incoming handle */
break;
default:
/* Other types can't get here */
break;
}
}
/*******************************************************************************
*
* FUNCTION: AcpiUtCopyEpackageToIpackage
*
* PARAMETERS: ExternalObject - The external object to be converted
* InternalObject - Where the internal object is returned
*
* RETURN: Status
*
* DESCRIPTION: Copy an external package object to an internal package.
* Handles nested packages.
*
******************************************************************************/
static ACPI_STATUS
{
UINT32 i;
/* Create the package object */
if (!PackageObject)
{
}
/*
* Recursive implementation. Probably ok, since nested external packages
* as parameters should be very rare.
*/
{
&PackageElements[i]);
if (ACPI_FAILURE (Status))
{
/* Truncate package and delete it */
PackageElements[i] = NULL;
}
}
/* Mark package data valid */
}
/*******************************************************************************
*
* FUNCTION: AcpiUtCopyEobjectToIobject
*
* PARAMETERS: ExternalObject - The external object to be converted
* InternalObject - Where the internal object is returned
*
* RETURN: Status - the status of the call
*
* DESCRIPTION: Converts an external object to an internal object.
*
******************************************************************************/
{
{
}
else
{
/*
* Build a simple object (no nested objects)
*/
}
}
/*******************************************************************************
*
* FUNCTION: AcpiUtCopySimpleObject
*
* PARAMETERS: SourceDesc - The internal object to be copied
* DestDesc - New target object
*
* RETURN: Status
*
* DESCRIPTION: Simple copy of one internal object to another. Reference count
* of the destination object is preserved.
*
******************************************************************************/
static ACPI_STATUS
{
/* Save fields from destination that we don't want to overwrite */
/* Copy the entire source object over the destination object*/
sizeof (ACPI_OPERAND_OBJECT));
/* Restore the saved fields */
/* New object is not static, regardless of source */
/* Handle the objects with extra data */
switch (ACPI_GET_OBJECT_TYPE (DestDesc))
{
case ACPI_TYPE_BUFFER:
/*
* Allocate and copy the actual buffer if and only if:
* 1) There is a valid buffer pointer
* 2) The buffer has a length > 0
*/
{
{
return (AE_NO_MEMORY);
}
/* Copy the actual buffer data */
}
break;
case ACPI_TYPE_STRING:
/*
* Allocate and copy the actual string if and only if:
* 1) There is a valid string pointer
* (Pointer to a NULL string is allowed)
*/
{
{
return (AE_NO_MEMORY);
}
/* Copy the actual string data */
}
break;
/*
* We copied the reference object, so we now must add a reference
* to the object pointed to by the reference
*
* it does not have a Reference.Object, so does not need to
* increase the reference count
*/
{
break;
}
break;
case ACPI_TYPE_REGION:
/*
* We copied the Region Handler, so we now must add a reference
*/
{
}
break;
default:
/* Nothing to do for other simple objects */
break;
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiUtCopyIelementToIelement
*
* PARAMETERS: ACPI_PKG_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Copy one package element to another package element
*
******************************************************************************/
static ACPI_STATUS
void *Context)
{
ThisTargetPtr = (ACPI_OPERAND_OBJECT **)
switch (ObjectType)
{
case ACPI_COPY_TYPE_SIMPLE:
/* A null source object indicates a (legal) null package element */
if (SourceObject)
{
/*
* This is a simple object, just copy it
*/
if (!TargetObject)
{
return (AE_NO_MEMORY);
}
if (ACPI_FAILURE (Status))
{
goto ErrorExit;
}
}
else
{
/* Pass through a null element */
*ThisTargetPtr = NULL;
}
break;
case ACPI_COPY_TYPE_PACKAGE:
/*
* This object is a package - go down another nesting level
* Create and build the package object
*/
if (!TargetObject)
{
return (AE_NO_MEMORY);
}
/* Pass the new package object back to the package walk routine */
/* Store the object pointer in the parent package object */
break;
default:
return (AE_BAD_PARAMETER);
}
return (Status);
return (Status);
}
/*******************************************************************************
*
* FUNCTION: AcpiUtCopyIpackageToIpackage
*
* PARAMETERS: *SourceObj - Pointer to the source package object
* *DestObj - Where the internal object is returned
*
* RETURN: Status - the status of the call
*
* DESCRIPTION: This function is called to copy an internal package object
* into another internal package object.
*
******************************************************************************/
static ACPI_STATUS
{
/*
* Create the object array and walk the source package tree
*/
sizeof (void *));
{
}
/*
* Copy the package element-by-element by walking the package "tree".
* This handles nested packages of arbitrary depth.
*/
if (ACPI_FAILURE (Status))
{
/* On failure, delete the destination package object */
}
}
/*******************************************************************************
*
* FUNCTION: AcpiUtCopyIobjectToIobject
*
* PARAMETERS: WalkState - Current walk state
* SourceDesc - The internal object to be copied
* DestDesc - Where the copied object is returned
*
* RETURN: Status
*
* DESCRIPTION: Copy an internal object to a new internal object
*
******************************************************************************/
{
/* Create the top level object */
if (!*DestDesc)
{
}
/* Copy the object and possible subobjects */
{
}
else
{
}
}