13446Smrj /****************************************************************************** 23446Smrj * 33446Smrj * Module Name: utcopy - Internal to external object translation utilities 43446Smrj * 53446Smrj *****************************************************************************/ 63446Smrj 73446Smrj /****************************************************************************** 83446Smrj * 93446Smrj * 1. Copyright Notice 103446Smrj * 11*9980SDana.Myers@Sun.COM * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. 123446Smrj * All rights reserved. 133446Smrj * 143446Smrj * 2. License 153446Smrj * 163446Smrj * 2.1. This is your license from Intel Corp. under its intellectual property 173446Smrj * rights. You may have additional license terms from the party that provided 183446Smrj * you this software, covering your right to use that party's intellectual 193446Smrj * property rights. 203446Smrj * 213446Smrj * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 223446Smrj * copy of the source code appearing in this file ("Covered Code") an 233446Smrj * irrevocable, perpetual, worldwide license under Intel's copyrights in the 243446Smrj * base code distributed originally by Intel ("Original Intel Code") to copy, 253446Smrj * make derivatives, distribute, use and display any portion of the Covered 263446Smrj * Code in any form, with the right to sublicense such rights; and 273446Smrj * 283446Smrj * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 293446Smrj * license (with the right to sublicense), under only those claims of Intel 303446Smrj * patents that are infringed by the Original Intel Code, to make, use, sell, 313446Smrj * offer to sell, and import the Covered Code and derivative works thereof 323446Smrj * solely to the minimum extent necessary to exercise the above copyright 333446Smrj * license, and in no event shall the patent license extend to any additions 343446Smrj * to or modifications of the Original Intel Code. No other license or right 353446Smrj * is granted directly or by implication, estoppel or otherwise; 363446Smrj * 373446Smrj * The above copyright and patent license is granted only if the following 383446Smrj * conditions are met: 393446Smrj * 403446Smrj * 3. Conditions 413446Smrj * 423446Smrj * 3.1. Redistribution of Source with Rights to Further Distribute Source. 433446Smrj * Redistribution of source code of any substantial portion of the Covered 443446Smrj * Code or modification with rights to further distribute source must include 453446Smrj * the above Copyright Notice, the above License, this list of Conditions, 463446Smrj * and the following Disclaimer and Export Compliance provision. In addition, 473446Smrj * Licensee must cause all Covered Code to which Licensee contributes to 483446Smrj * contain a file documenting the changes Licensee made to create that Covered 493446Smrj * Code and the date of any change. Licensee must include in that file the 503446Smrj * documentation of any changes made by any predecessor Licensee. Licensee 513446Smrj * must include a prominent statement that the modification is derived, 523446Smrj * directly or indirectly, from Original Intel Code. 533446Smrj * 543446Smrj * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 553446Smrj * Redistribution of source code of any substantial portion of the Covered 563446Smrj * Code or modification without rights to further distribute source must 573446Smrj * include the following Disclaimer and Export Compliance provision in the 583446Smrj * documentation and/or other materials provided with distribution. In 593446Smrj * addition, Licensee may not authorize further sublicense of source of any 603446Smrj * portion of the Covered Code, and must include terms to the effect that the 613446Smrj * license from Licensee to its licensee is limited to the intellectual 623446Smrj * property embodied in the software Licensee provides to its licensee, and 633446Smrj * not to intellectual property embodied in modifications its licensee may 643446Smrj * make. 653446Smrj * 663446Smrj * 3.3. Redistribution of Executable. Redistribution in executable form of any 673446Smrj * substantial portion of the Covered Code or modification must reproduce the 683446Smrj * above Copyright Notice, and the following Disclaimer and Export Compliance 693446Smrj * provision in the documentation and/or other materials provided with the 703446Smrj * distribution. 713446Smrj * 723446Smrj * 3.4. Intel retains all right, title, and interest in and to the Original 733446Smrj * Intel Code. 743446Smrj * 753446Smrj * 3.5. Neither the name Intel nor any other trademark owned or controlled by 763446Smrj * Intel shall be used in advertising or otherwise to promote the sale, use or 773446Smrj * other dealings in products derived from or relating to the Covered Code 783446Smrj * without prior written authorization from Intel. 793446Smrj * 803446Smrj * 4. Disclaimer and Export Compliance 813446Smrj * 823446Smrj * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 833446Smrj * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 843446Smrj * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 853446Smrj * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 863446Smrj * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 873446Smrj * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 883446Smrj * PARTICULAR PURPOSE. 893446Smrj * 903446Smrj * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 913446Smrj * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 923446Smrj * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 933446Smrj * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 943446Smrj * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 953446Smrj * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 963446Smrj * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 973446Smrj * LIMITED REMEDY. 983446Smrj * 993446Smrj * 4.3. Licensee shall not export, either directly or indirectly, any of this 1003446Smrj * software or system incorporating such software without first obtaining any 1013446Smrj * required license or other approval from the U. S. Department of Commerce or 1023446Smrj * any other agency or department of the United States Government. In the 1033446Smrj * event Licensee exports any such software from the United States or 1043446Smrj * re-exports any such software from a foreign destination, Licensee shall 1053446Smrj * ensure that the distribution and export/re-export of the software is in 1063446Smrj * compliance with all laws, regulations, orders, or other restrictions of the 1073446Smrj * U.S. Export Administration Regulations. Licensee agrees that neither it nor 1083446Smrj * any of its subsidiaries will export/re-export any technical data, process, 1093446Smrj * software, or service, directly or indirectly, to any country for which the 1103446Smrj * United States government or any agency thereof requires an export license, 1113446Smrj * other governmental approval, or letter of assurance, without first obtaining 1123446Smrj * such license, approval or letter. 1133446Smrj * 1143446Smrj *****************************************************************************/ 1153446Smrj 1163446Smrj #define __UTCOPY_C__ 1173446Smrj 1183446Smrj #include "acpi.h" 119*9980SDana.Myers@Sun.COM #include "accommon.h" 1207851SDana.Myers@Sun.COM #include "acnamesp.h" 1213446Smrj 1223446Smrj 1233446Smrj #define _COMPONENT ACPI_UTILITIES 1243446Smrj ACPI_MODULE_NAME ("utcopy") 1253446Smrj 1263446Smrj /* Local prototypes */ 1273446Smrj 1283446Smrj static ACPI_STATUS 1293446Smrj AcpiUtCopyIsimpleToEsimple ( 1303446Smrj ACPI_OPERAND_OBJECT *InternalObject, 1313446Smrj ACPI_OBJECT *ExternalObject, 1323446Smrj UINT8 *DataSpace, 1333446Smrj ACPI_SIZE *BufferSpaceUsed); 1343446Smrj 1353446Smrj static ACPI_STATUS 1363446Smrj AcpiUtCopyIelementToIelement ( 1373446Smrj UINT8 ObjectType, 1383446Smrj ACPI_OPERAND_OBJECT *SourceObject, 1393446Smrj ACPI_GENERIC_STATE *State, 1403446Smrj void *Context); 1413446Smrj 1423446Smrj static ACPI_STATUS 1433446Smrj AcpiUtCopyIpackageToEpackage ( 1443446Smrj ACPI_OPERAND_OBJECT *InternalObject, 1453446Smrj UINT8 *Buffer, 1463446Smrj ACPI_SIZE *SpaceUsed); 1473446Smrj 1483446Smrj static ACPI_STATUS 1493446Smrj AcpiUtCopyEsimpleToIsimple( 1503446Smrj ACPI_OBJECT *UserObj, 1513446Smrj ACPI_OPERAND_OBJECT **ReturnObj); 1523446Smrj 1533446Smrj static ACPI_STATUS 1547851SDana.Myers@Sun.COM AcpiUtCopyEpackageToIpackage ( 1557851SDana.Myers@Sun.COM ACPI_OBJECT *ExternalObject, 1567851SDana.Myers@Sun.COM ACPI_OPERAND_OBJECT **InternalObject); 1577851SDana.Myers@Sun.COM 1587851SDana.Myers@Sun.COM static ACPI_STATUS 1593446Smrj AcpiUtCopySimpleObject ( 1603446Smrj ACPI_OPERAND_OBJECT *SourceDesc, 1613446Smrj ACPI_OPERAND_OBJECT *DestDesc); 1623446Smrj 1633446Smrj static ACPI_STATUS 1643446Smrj AcpiUtCopyIelementToEelement ( 1653446Smrj UINT8 ObjectType, 1663446Smrj ACPI_OPERAND_OBJECT *SourceObject, 1673446Smrj ACPI_GENERIC_STATE *State, 1683446Smrj void *Context); 1693446Smrj 1703446Smrj static ACPI_STATUS 1713446Smrj AcpiUtCopyIpackageToIpackage ( 1723446Smrj ACPI_OPERAND_OBJECT *SourceObj, 1733446Smrj ACPI_OPERAND_OBJECT *DestObj, 1743446Smrj ACPI_WALK_STATE *WalkState); 1753446Smrj 1763446Smrj 1773446Smrj /******************************************************************************* 1783446Smrj * 1793446Smrj * FUNCTION: AcpiUtCopyIsimpleToEsimple 1803446Smrj * 1813446Smrj * PARAMETERS: InternalObject - Source object to be copied 1823446Smrj * ExternalObject - Where to return the copied object 1833446Smrj * DataSpace - Where object data is returned (such as 1843446Smrj * buffer and string data) 1853446Smrj * BufferSpaceUsed - Length of DataSpace that was used 1863446Smrj * 1873446Smrj * RETURN: Status 1883446Smrj * 1893446Smrj * DESCRIPTION: This function is called to copy a simple internal object to 1903446Smrj * an external object. 1913446Smrj * 1923446Smrj * The DataSpace buffer is assumed to have sufficient space for 1933446Smrj * the object. 1943446Smrj * 1953446Smrj ******************************************************************************/ 1963446Smrj 1973446Smrj static ACPI_STATUS 1983446Smrj AcpiUtCopyIsimpleToEsimple ( 1993446Smrj ACPI_OPERAND_OBJECT *InternalObject, 2003446Smrj ACPI_OBJECT *ExternalObject, 2013446Smrj UINT8 *DataSpace, 2023446Smrj ACPI_SIZE *BufferSpaceUsed) 2033446Smrj { 2043446Smrj ACPI_STATUS Status = AE_OK; 2053446Smrj 2063446Smrj 2073446Smrj ACPI_FUNCTION_TRACE (UtCopyIsimpleToEsimple); 2083446Smrj 2093446Smrj 2103446Smrj *BufferSpaceUsed = 0; 2113446Smrj 2123446Smrj /* 2133446Smrj * Check for NULL object case (could be an uninitialized 2143446Smrj * package element) 2153446Smrj */ 2163446Smrj if (!InternalObject) 2173446Smrj { 2183446Smrj return_ACPI_STATUS (AE_OK); 2193446Smrj } 2203446Smrj 2213446Smrj /* Always clear the external object */ 2223446Smrj 2233446Smrj ACPI_MEMSET (ExternalObject, 0, sizeof (ACPI_OBJECT)); 2243446Smrj 2253446Smrj /* 2263446Smrj * In general, the external object will be the same type as 2273446Smrj * the internal object 2283446Smrj */ 229*9980SDana.Myers@Sun.COM ExternalObject->Type = InternalObject->Common.Type; 2303446Smrj 2313446Smrj /* However, only a limited number of external types are supported */ 2323446Smrj 233*9980SDana.Myers@Sun.COM switch (InternalObject->Common.Type) 2343446Smrj { 2353446Smrj case ACPI_TYPE_STRING: 2363446Smrj 2373446Smrj ExternalObject->String.Pointer = (char *) DataSpace; 2383446Smrj ExternalObject->String.Length = InternalObject->String.Length; 2393446Smrj *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD ( 2403446Smrj (ACPI_SIZE) InternalObject->String.Length + 1); 2413446Smrj 2423446Smrj ACPI_MEMCPY ((void *) DataSpace, 2433446Smrj (void *) InternalObject->String.Pointer, 2443446Smrj (ACPI_SIZE) InternalObject->String.Length + 1); 2453446Smrj break; 2463446Smrj 2473446Smrj 2483446Smrj case ACPI_TYPE_BUFFER: 2493446Smrj 2503446Smrj ExternalObject->Buffer.Pointer = DataSpace; 2513446Smrj ExternalObject->Buffer.Length = InternalObject->Buffer.Length; 2523446Smrj *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD ( 2533446Smrj InternalObject->String.Length); 2543446Smrj 2553446Smrj ACPI_MEMCPY ((void *) DataSpace, 2563446Smrj (void *) InternalObject->Buffer.Pointer, 2573446Smrj InternalObject->Buffer.Length); 2583446Smrj break; 2593446Smrj 2603446Smrj 2613446Smrj case ACPI_TYPE_INTEGER: 2623446Smrj 2633446Smrj ExternalObject->Integer.Value = InternalObject->Integer.Value; 2643446Smrj break; 2653446Smrj 2663446Smrj 2673446Smrj case ACPI_TYPE_LOCAL_REFERENCE: 2683446Smrj 2697851SDana.Myers@Sun.COM /* This is an object reference. */ 2707851SDana.Myers@Sun.COM 2717851SDana.Myers@Sun.COM switch (InternalObject->Reference.Class) 2723446Smrj { 2737851SDana.Myers@Sun.COM case ACPI_REFCLASS_NAME: 2743446Smrj 2757851SDana.Myers@Sun.COM /* 2767851SDana.Myers@Sun.COM * For namepath, return the object handle ("reference") 2777851SDana.Myers@Sun.COM * We are referring to the namespace node 2787851SDana.Myers@Sun.COM */ 2797851SDana.Myers@Sun.COM ExternalObject->Reference.Handle = 2807851SDana.Myers@Sun.COM InternalObject->Reference.Node; 2817851SDana.Myers@Sun.COM ExternalObject->Reference.ActualType = 2827851SDana.Myers@Sun.COM AcpiNsGetType (InternalObject->Reference.Node); 2837851SDana.Myers@Sun.COM break; 2843446Smrj 2853446Smrj default: 2867851SDana.Myers@Sun.COM 2877851SDana.Myers@Sun.COM /* All other reference types are unsupported */ 2887851SDana.Myers@Sun.COM 2897851SDana.Myers@Sun.COM return_ACPI_STATUS (AE_TYPE); 2903446Smrj } 2913446Smrj break; 2923446Smrj 2933446Smrj 2943446Smrj case ACPI_TYPE_PROCESSOR: 2953446Smrj 2967851SDana.Myers@Sun.COM ExternalObject->Processor.ProcId = 2977851SDana.Myers@Sun.COM InternalObject->Processor.ProcId; 2987851SDana.Myers@Sun.COM ExternalObject->Processor.PblkAddress = 2997851SDana.Myers@Sun.COM InternalObject->Processor.Address; 3007851SDana.Myers@Sun.COM ExternalObject->Processor.PblkLength = 3017851SDana.Myers@Sun.COM InternalObject->Processor.Length; 3023446Smrj break; 3033446Smrj 3043446Smrj 3053446Smrj case ACPI_TYPE_POWER: 3063446Smrj 3073446Smrj ExternalObject->PowerResource.SystemLevel = 3087851SDana.Myers@Sun.COM InternalObject->PowerResource.SystemLevel; 3093446Smrj 3103446Smrj ExternalObject->PowerResource.ResourceOrder = 3117851SDana.Myers@Sun.COM InternalObject->PowerResource.ResourceOrder; 3123446Smrj break; 3133446Smrj 3143446Smrj 3153446Smrj default: 3163446Smrj /* 3173446Smrj * There is no corresponding external object type 3183446Smrj */ 3197851SDana.Myers@Sun.COM ACPI_ERROR ((AE_INFO, 3207851SDana.Myers@Sun.COM "Unsupported object type, cannot convert to external object: %s", 321*9980SDana.Myers@Sun.COM AcpiUtGetTypeName (InternalObject->Common.Type))); 3227851SDana.Myers@Sun.COM 3233446Smrj return_ACPI_STATUS (AE_SUPPORT); 3243446Smrj } 3253446Smrj 3263446Smrj return_ACPI_STATUS (Status); 3273446Smrj } 3283446Smrj 3293446Smrj 3303446Smrj /******************************************************************************* 3313446Smrj * 3323446Smrj * FUNCTION: AcpiUtCopyIelementToEelement 3333446Smrj * 3343446Smrj * PARAMETERS: ACPI_PKG_CALLBACK 3353446Smrj * 3363446Smrj * RETURN: Status 3373446Smrj * 3383446Smrj * DESCRIPTION: Copy one package element to another package element 3393446Smrj * 3403446Smrj ******************************************************************************/ 3413446Smrj 3423446Smrj static ACPI_STATUS 3433446Smrj AcpiUtCopyIelementToEelement ( 3443446Smrj UINT8 ObjectType, 3453446Smrj ACPI_OPERAND_OBJECT *SourceObject, 3463446Smrj ACPI_GENERIC_STATE *State, 3473446Smrj void *Context) 3483446Smrj { 3493446Smrj ACPI_STATUS Status = AE_OK; 3503446Smrj ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context; 3513446Smrj ACPI_SIZE ObjectSpace; 3523446Smrj UINT32 ThisIndex; 3533446Smrj ACPI_OBJECT *TargetObject; 3543446Smrj 3553446Smrj 3563446Smrj ACPI_FUNCTION_ENTRY (); 3573446Smrj 3583446Smrj 3593446Smrj ThisIndex = State->Pkg.Index; 3603446Smrj TargetObject = (ACPI_OBJECT *) 3613446Smrj &((ACPI_OBJECT *)(State->Pkg.DestObject))->Package.Elements[ThisIndex]; 3623446Smrj 3633446Smrj switch (ObjectType) 3643446Smrj { 3653446Smrj case ACPI_COPY_TYPE_SIMPLE: 3663446Smrj 3673446Smrj /* 3683446Smrj * This is a simple or null object 3693446Smrj */ 3703446Smrj Status = AcpiUtCopyIsimpleToEsimple (SourceObject, 3713446Smrj TargetObject, Info->FreeSpace, &ObjectSpace); 3723446Smrj if (ACPI_FAILURE (Status)) 3733446Smrj { 3743446Smrj return (Status); 3753446Smrj } 3763446Smrj break; 3773446Smrj 3783446Smrj 3793446Smrj case ACPI_COPY_TYPE_PACKAGE: 3803446Smrj 3813446Smrj /* 3823446Smrj * Build the package object 3833446Smrj */ 3843446Smrj TargetObject->Type = ACPI_TYPE_PACKAGE; 3853446Smrj TargetObject->Package.Count = SourceObject->Package.Count; 3863446Smrj TargetObject->Package.Elements = 3873446Smrj ACPI_CAST_PTR (ACPI_OBJECT, Info->FreeSpace); 3883446Smrj 3893446Smrj /* 3903446Smrj * Pass the new package object back to the package walk routine 3913446Smrj */ 3923446Smrj State->Pkg.ThisTargetObj = TargetObject; 3933446Smrj 3943446Smrj /* 3953446Smrj * Save space for the array of objects (Package elements) 3963446Smrj * update the buffer length counter 3973446Smrj */ 3983446Smrj ObjectSpace = ACPI_ROUND_UP_TO_NATIVE_WORD ( 3993446Smrj (ACPI_SIZE) TargetObject->Package.Count * 4003446Smrj sizeof (ACPI_OBJECT)); 4013446Smrj break; 4023446Smrj 4033446Smrj 4043446Smrj default: 4053446Smrj return (AE_BAD_PARAMETER); 4063446Smrj } 4073446Smrj 4083446Smrj Info->FreeSpace += ObjectSpace; 4093446Smrj Info->Length += ObjectSpace; 4103446Smrj return (Status); 4113446Smrj } 4123446Smrj 4133446Smrj 4143446Smrj /******************************************************************************* 4153446Smrj * 4163446Smrj * FUNCTION: AcpiUtCopyIpackageToEpackage 4173446Smrj * 4183446Smrj * PARAMETERS: InternalObject - Pointer to the object we are returning 4193446Smrj * Buffer - Where the object is returned 4203446Smrj * SpaceUsed - Where the object length is returned 4213446Smrj * 4223446Smrj * RETURN: Status 4233446Smrj * 4243446Smrj * DESCRIPTION: This function is called to place a package object in a user 4253446Smrj * buffer. A package object by definition contains other objects. 4263446Smrj * 4273446Smrj * The buffer is assumed to have sufficient space for the object. 4283446Smrj * The caller must have verified the buffer length needed using the 4293446Smrj * AcpiUtGetObjectSize function before calling this function. 4303446Smrj * 4313446Smrj ******************************************************************************/ 4323446Smrj 4333446Smrj static ACPI_STATUS 4343446Smrj AcpiUtCopyIpackageToEpackage ( 4353446Smrj ACPI_OPERAND_OBJECT *InternalObject, 4363446Smrj UINT8 *Buffer, 4373446Smrj ACPI_SIZE *SpaceUsed) 4383446Smrj { 4393446Smrj ACPI_OBJECT *ExternalObject; 4403446Smrj ACPI_STATUS Status; 4413446Smrj ACPI_PKG_INFO Info; 4423446Smrj 4433446Smrj 4443446Smrj ACPI_FUNCTION_TRACE (UtCopyIpackageToEpackage); 4453446Smrj 4463446Smrj 4473446Smrj /* 4483446Smrj * First package at head of the buffer 4493446Smrj */ 4503446Smrj ExternalObject = ACPI_CAST_PTR (ACPI_OBJECT, Buffer); 4513446Smrj 4523446Smrj /* 4533446Smrj * Free space begins right after the first package 4543446Smrj */ 4553446Smrj Info.Length = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); 4563446Smrj Info.FreeSpace = Buffer + ACPI_ROUND_UP_TO_NATIVE_WORD ( 4573446Smrj sizeof (ACPI_OBJECT)); 4583446Smrj Info.ObjectSpace = 0; 4593446Smrj Info.NumPackages = 1; 4603446Smrj 461*9980SDana.Myers@Sun.COM ExternalObject->Type = InternalObject->Common.Type; 4623446Smrj ExternalObject->Package.Count = InternalObject->Package.Count; 4633446Smrj ExternalObject->Package.Elements = ACPI_CAST_PTR (ACPI_OBJECT, 4643446Smrj Info.FreeSpace); 4653446Smrj 4663446Smrj /* 4673446Smrj * Leave room for an array of ACPI_OBJECTS in the buffer 4683446Smrj * and move the free space past it 4693446Smrj */ 4703446Smrj Info.Length += (ACPI_SIZE) ExternalObject->Package.Count * 4713446Smrj ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); 4723446Smrj Info.FreeSpace += ExternalObject->Package.Count * 4733446Smrj ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); 4743446Smrj 4753446Smrj Status = AcpiUtWalkPackageTree (InternalObject, ExternalObject, 4763446Smrj AcpiUtCopyIelementToEelement, &Info); 4773446Smrj 4783446Smrj *SpaceUsed = Info.Length; 4793446Smrj return_ACPI_STATUS (Status); 4803446Smrj } 4813446Smrj 4823446Smrj 4833446Smrj /******************************************************************************* 4843446Smrj * 4853446Smrj * FUNCTION: AcpiUtCopyIobjectToEobject 4863446Smrj * 4873446Smrj * PARAMETERS: InternalObject - The internal object to be converted 4883446Smrj * BufferPtr - Where the object is returned 4893446Smrj * 4903446Smrj * RETURN: Status 4913446Smrj * 4923446Smrj * DESCRIPTION: This function is called to build an API object to be returned to 4933446Smrj * the caller. 4943446Smrj * 4953446Smrj ******************************************************************************/ 4963446Smrj 4973446Smrj ACPI_STATUS 4983446Smrj AcpiUtCopyIobjectToEobject ( 4993446Smrj ACPI_OPERAND_OBJECT *InternalObject, 5003446Smrj ACPI_BUFFER *RetBuffer) 5013446Smrj { 5023446Smrj ACPI_STATUS Status; 5033446Smrj 5043446Smrj 5053446Smrj ACPI_FUNCTION_TRACE (UtCopyIobjectToEobject); 5063446Smrj 5073446Smrj 508*9980SDana.Myers@Sun.COM if (InternalObject->Common.Type == ACPI_TYPE_PACKAGE) 5093446Smrj { 5103446Smrj /* 5113446Smrj * Package object: Copy all subobjects (including 5123446Smrj * nested packages) 5133446Smrj */ 5143446Smrj Status = AcpiUtCopyIpackageToEpackage (InternalObject, 5153446Smrj RetBuffer->Pointer, &RetBuffer->Length); 5163446Smrj } 5173446Smrj else 5183446Smrj { 5193446Smrj /* 5203446Smrj * Build a simple object (no nested objects) 5213446Smrj */ 5223446Smrj Status = AcpiUtCopyIsimpleToEsimple (InternalObject, 5233446Smrj ACPI_CAST_PTR (ACPI_OBJECT, RetBuffer->Pointer), 5243446Smrj ACPI_ADD_PTR (UINT8, RetBuffer->Pointer, 5253446Smrj ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT))), 5263446Smrj &RetBuffer->Length); 5273446Smrj /* 5283446Smrj * build simple does not include the object size in the length 5293446Smrj * so we add it in here 5303446Smrj */ 5313446Smrj RetBuffer->Length += sizeof (ACPI_OBJECT); 5323446Smrj } 5333446Smrj 5343446Smrj return_ACPI_STATUS (Status); 5353446Smrj } 5363446Smrj 5373446Smrj 5383446Smrj /******************************************************************************* 5393446Smrj * 5403446Smrj * FUNCTION: AcpiUtCopyEsimpleToIsimple 5413446Smrj * 5423446Smrj * PARAMETERS: ExternalObject - The external object to be converted 5433446Smrj * RetInternalObject - Where the internal object is returned 5443446Smrj * 5453446Smrj * RETURN: Status 5463446Smrj * 5473446Smrj * DESCRIPTION: This function copies an external object to an internal one. 5483446Smrj * NOTE: Pointers can be copied, we don't need to copy data. 5493446Smrj * (The pointers have to be valid in our address space no matter 5503446Smrj * what we do with them!) 5513446Smrj * 5523446Smrj ******************************************************************************/ 5533446Smrj 5543446Smrj static ACPI_STATUS 5553446Smrj AcpiUtCopyEsimpleToIsimple ( 5563446Smrj ACPI_OBJECT *ExternalObject, 5573446Smrj ACPI_OPERAND_OBJECT **RetInternalObject) 5583446Smrj { 5593446Smrj ACPI_OPERAND_OBJECT *InternalObject; 5603446Smrj 5613446Smrj 5623446Smrj ACPI_FUNCTION_TRACE (UtCopyEsimpleToIsimple); 5633446Smrj 5643446Smrj 5653446Smrj /* 5663446Smrj * Simple types supported are: String, Buffer, Integer 5673446Smrj */ 5683446Smrj switch (ExternalObject->Type) 5693446Smrj { 5703446Smrj case ACPI_TYPE_STRING: 5713446Smrj case ACPI_TYPE_BUFFER: 5723446Smrj case ACPI_TYPE_INTEGER: 5737851SDana.Myers@Sun.COM case ACPI_TYPE_LOCAL_REFERENCE: 5743446Smrj 5753446Smrj InternalObject = AcpiUtCreateInternalObject ( 5763446Smrj (UINT8) ExternalObject->Type); 5773446Smrj if (!InternalObject) 5783446Smrj { 5793446Smrj return_ACPI_STATUS (AE_NO_MEMORY); 5803446Smrj } 5813446Smrj break; 5823446Smrj 5837851SDana.Myers@Sun.COM case ACPI_TYPE_ANY: /* This is the case for a NULL object */ 5847851SDana.Myers@Sun.COM 5857851SDana.Myers@Sun.COM *RetInternalObject = NULL; 5867851SDana.Myers@Sun.COM return_ACPI_STATUS (AE_OK); 5877851SDana.Myers@Sun.COM 5883446Smrj default: 5893446Smrj /* All other types are not supported */ 5903446Smrj 591*9980SDana.Myers@Sun.COM ACPI_ERROR ((AE_INFO, 592*9980SDana.Myers@Sun.COM "Unsupported object type, cannot convert to internal object: %s", 5937851SDana.Myers@Sun.COM AcpiUtGetTypeName (ExternalObject->Type))); 5947851SDana.Myers@Sun.COM 5953446Smrj return_ACPI_STATUS (AE_SUPPORT); 5963446Smrj } 5973446Smrj 5983446Smrj 5993446Smrj /* Must COPY string and buffer contents */ 6003446Smrj 6013446Smrj switch (ExternalObject->Type) 6023446Smrj { 6033446Smrj case ACPI_TYPE_STRING: 6043446Smrj 6053446Smrj InternalObject->String.Pointer = 606*9980SDana.Myers@Sun.COM ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) 607*9980SDana.Myers@Sun.COM ExternalObject->String.Length + 1); 608*9980SDana.Myers@Sun.COM 6093446Smrj if (!InternalObject->String.Pointer) 6103446Smrj { 6113446Smrj goto ErrorExit; 6123446Smrj } 6133446Smrj 6143446Smrj ACPI_MEMCPY (InternalObject->String.Pointer, 6153446Smrj ExternalObject->String.Pointer, 6163446Smrj ExternalObject->String.Length); 6173446Smrj 6183446Smrj InternalObject->String.Length = ExternalObject->String.Length; 6193446Smrj break; 6203446Smrj 6213446Smrj 6223446Smrj case ACPI_TYPE_BUFFER: 6233446Smrj 6243446Smrj InternalObject->Buffer.Pointer = 6253446Smrj ACPI_ALLOCATE_ZEROED (ExternalObject->Buffer.Length); 6263446Smrj if (!InternalObject->Buffer.Pointer) 6273446Smrj { 6283446Smrj goto ErrorExit; 6293446Smrj } 6303446Smrj 6313446Smrj ACPI_MEMCPY (InternalObject->Buffer.Pointer, 6323446Smrj ExternalObject->Buffer.Pointer, 6333446Smrj ExternalObject->Buffer.Length); 6343446Smrj 6353446Smrj InternalObject->Buffer.Length = ExternalObject->Buffer.Length; 6367851SDana.Myers@Sun.COM 6377851SDana.Myers@Sun.COM /* Mark buffer data valid */ 6387851SDana.Myers@Sun.COM 6397851SDana.Myers@Sun.COM InternalObject->Buffer.Flags |= AOPOBJ_DATA_VALID; 6403446Smrj break; 6413446Smrj 6423446Smrj 6433446Smrj case ACPI_TYPE_INTEGER: 6443446Smrj 6453446Smrj InternalObject->Integer.Value = ExternalObject->Integer.Value; 6463446Smrj break; 6473446Smrj 6487851SDana.Myers@Sun.COM case ACPI_TYPE_LOCAL_REFERENCE: 6497851SDana.Myers@Sun.COM 6507851SDana.Myers@Sun.COM /* TBD: should validate incoming handle */ 6517851SDana.Myers@Sun.COM 6527851SDana.Myers@Sun.COM InternalObject->Reference.Class = ACPI_REFCLASS_NAME; 6537851SDana.Myers@Sun.COM InternalObject->Reference.Node = ExternalObject->Reference.Handle; 6547851SDana.Myers@Sun.COM break; 6557851SDana.Myers@Sun.COM 6563446Smrj default: 6573446Smrj /* Other types can't get here */ 6583446Smrj break; 6593446Smrj } 6603446Smrj 6613446Smrj *RetInternalObject = InternalObject; 6623446Smrj return_ACPI_STATUS (AE_OK); 6633446Smrj 6643446Smrj 6653446Smrj ErrorExit: 6663446Smrj AcpiUtRemoveReference (InternalObject); 6673446Smrj return_ACPI_STATUS (AE_NO_MEMORY); 6683446Smrj } 6693446Smrj 6703446Smrj 6713446Smrj /******************************************************************************* 6723446Smrj * 6733446Smrj * FUNCTION: AcpiUtCopyEpackageToIpackage 6743446Smrj * 6757851SDana.Myers@Sun.COM * PARAMETERS: ExternalObject - The external object to be converted 6767851SDana.Myers@Sun.COM * InternalObject - Where the internal object is returned 6773446Smrj * 6783446Smrj * RETURN: Status 6793446Smrj * 6807851SDana.Myers@Sun.COM * DESCRIPTION: Copy an external package object to an internal package. 6817851SDana.Myers@Sun.COM * Handles nested packages. 6823446Smrj * 6833446Smrj ******************************************************************************/ 6843446Smrj 6853446Smrj static ACPI_STATUS 6863446Smrj AcpiUtCopyEpackageToIpackage ( 6877851SDana.Myers@Sun.COM ACPI_OBJECT *ExternalObject, 6887851SDana.Myers@Sun.COM ACPI_OPERAND_OBJECT **InternalObject) 6893446Smrj { 6907851SDana.Myers@Sun.COM ACPI_STATUS Status = AE_OK; 6917851SDana.Myers@Sun.COM ACPI_OPERAND_OBJECT *PackageObject; 6927851SDana.Myers@Sun.COM ACPI_OPERAND_OBJECT **PackageElements; 6937851SDana.Myers@Sun.COM UINT32 i; 6943446Smrj 6953446Smrj 6963446Smrj ACPI_FUNCTION_TRACE (UtCopyEpackageToIpackage); 6973446Smrj 6983446Smrj 6997851SDana.Myers@Sun.COM /* Create the package object */ 7007851SDana.Myers@Sun.COM 7017851SDana.Myers@Sun.COM PackageObject = AcpiUtCreatePackageObject (ExternalObject->Package.Count); 7027851SDana.Myers@Sun.COM if (!PackageObject) 7037851SDana.Myers@Sun.COM { 7047851SDana.Myers@Sun.COM return_ACPI_STATUS (AE_NO_MEMORY); 7057851SDana.Myers@Sun.COM } 7067851SDana.Myers@Sun.COM 7077851SDana.Myers@Sun.COM PackageElements = PackageObject->Package.Elements; 7083446Smrj 7093446Smrj /* 7107851SDana.Myers@Sun.COM * Recursive implementation. Probably ok, since nested external packages 7117851SDana.Myers@Sun.COM * as parameters should be very rare. 7123446Smrj */ 7137851SDana.Myers@Sun.COM for (i = 0; i < ExternalObject->Package.Count; i++) 7147851SDana.Myers@Sun.COM { 7157851SDana.Myers@Sun.COM Status = AcpiUtCopyEobjectToIobject ( 7167851SDana.Myers@Sun.COM &ExternalObject->Package.Elements[i], 7177851SDana.Myers@Sun.COM &PackageElements[i]); 7187851SDana.Myers@Sun.COM if (ACPI_FAILURE (Status)) 7197851SDana.Myers@Sun.COM { 7207851SDana.Myers@Sun.COM /* Truncate package and delete it */ 7213446Smrj 7227851SDana.Myers@Sun.COM PackageObject->Package.Count = i; 7237851SDana.Myers@Sun.COM PackageElements[i] = NULL; 7247851SDana.Myers@Sun.COM AcpiUtRemoveReference (PackageObject); 7257851SDana.Myers@Sun.COM return_ACPI_STATUS (Status); 7267851SDana.Myers@Sun.COM } 7277851SDana.Myers@Sun.COM } 7283446Smrj 7297851SDana.Myers@Sun.COM /* Mark package data valid */ 7303446Smrj 7317851SDana.Myers@Sun.COM PackageObject->Package.Flags |= AOPOBJ_DATA_VALID; 7323446Smrj 7337851SDana.Myers@Sun.COM *InternalObject = PackageObject; 7347851SDana.Myers@Sun.COM return_ACPI_STATUS (Status); 7353446Smrj } 7363446Smrj 7373446Smrj 7383446Smrj /******************************************************************************* 7393446Smrj * 7403446Smrj * FUNCTION: AcpiUtCopyEobjectToIobject 7413446Smrj * 7427851SDana.Myers@Sun.COM * PARAMETERS: ExternalObject - The external object to be converted 7437851SDana.Myers@Sun.COM * InternalObject - Where the internal object is returned 7443446Smrj * 7457851SDana.Myers@Sun.COM * RETURN: Status - the status of the call 7463446Smrj * 7473446Smrj * DESCRIPTION: Converts an external object to an internal object. 7483446Smrj * 7493446Smrj ******************************************************************************/ 7503446Smrj 7513446Smrj ACPI_STATUS 7523446Smrj AcpiUtCopyEobjectToIobject ( 7533446Smrj ACPI_OBJECT *ExternalObject, 7543446Smrj ACPI_OPERAND_OBJECT **InternalObject) 7553446Smrj { 7563446Smrj ACPI_STATUS Status; 7573446Smrj 7583446Smrj 7593446Smrj ACPI_FUNCTION_TRACE (UtCopyEobjectToIobject); 7603446Smrj 7613446Smrj 7623446Smrj if (ExternalObject->Type == ACPI_TYPE_PACKAGE) 7633446Smrj { 7647851SDana.Myers@Sun.COM Status = AcpiUtCopyEpackageToIpackage (ExternalObject, InternalObject); 7653446Smrj } 7663446Smrj else 7673446Smrj { 7683446Smrj /* 7693446Smrj * Build a simple object (no nested objects) 7703446Smrj */ 7713446Smrj Status = AcpiUtCopyEsimpleToIsimple (ExternalObject, InternalObject); 7723446Smrj } 7733446Smrj 7743446Smrj return_ACPI_STATUS (Status); 7753446Smrj } 7763446Smrj 7773446Smrj 7783446Smrj /******************************************************************************* 7793446Smrj * 7803446Smrj * FUNCTION: AcpiUtCopySimpleObject 7813446Smrj * 7823446Smrj * PARAMETERS: SourceDesc - The internal object to be copied 7833446Smrj * DestDesc - New target object 7843446Smrj * 7853446Smrj * RETURN: Status 7863446Smrj * 7873446Smrj * DESCRIPTION: Simple copy of one internal object to another. Reference count 7883446Smrj * of the destination object is preserved. 7893446Smrj * 7903446Smrj ******************************************************************************/ 7913446Smrj 7923446Smrj static ACPI_STATUS 7933446Smrj AcpiUtCopySimpleObject ( 7943446Smrj ACPI_OPERAND_OBJECT *SourceDesc, 7953446Smrj ACPI_OPERAND_OBJECT *DestDesc) 7963446Smrj { 7973446Smrj UINT16 ReferenceCount; 7983446Smrj ACPI_OPERAND_OBJECT *NextObject; 799*9980SDana.Myers@Sun.COM ACPI_STATUS Status; 8003446Smrj 8013446Smrj 8023446Smrj /* Save fields from destination that we don't want to overwrite */ 8033446Smrj 8043446Smrj ReferenceCount = DestDesc->Common.ReferenceCount; 8053446Smrj NextObject = DestDesc->Common.NextObject; 8063446Smrj 8073446Smrj /* Copy the entire source object over the destination object*/ 8083446Smrj 8093446Smrj ACPI_MEMCPY ((char *) DestDesc, (char *) SourceDesc, 8103446Smrj sizeof (ACPI_OPERAND_OBJECT)); 8113446Smrj 8123446Smrj /* Restore the saved fields */ 8133446Smrj 8143446Smrj DestDesc->Common.ReferenceCount = ReferenceCount; 8153446Smrj DestDesc->Common.NextObject = NextObject; 8163446Smrj 8173446Smrj /* New object is not static, regardless of source */ 8183446Smrj 8193446Smrj DestDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER; 8203446Smrj 8213446Smrj /* Handle the objects with extra data */ 8223446Smrj 823*9980SDana.Myers@Sun.COM switch (DestDesc->Common.Type) 8243446Smrj { 8253446Smrj case ACPI_TYPE_BUFFER: 8263446Smrj /* 8273446Smrj * Allocate and copy the actual buffer if and only if: 8283446Smrj * 1) There is a valid buffer pointer 8293446Smrj * 2) The buffer has a length > 0 8303446Smrj */ 8313446Smrj if ((SourceDesc->Buffer.Pointer) && 8323446Smrj (SourceDesc->Buffer.Length)) 8333446Smrj { 8343446Smrj DestDesc->Buffer.Pointer = 8353446Smrj ACPI_ALLOCATE (SourceDesc->Buffer.Length); 8363446Smrj if (!DestDesc->Buffer.Pointer) 8373446Smrj { 8383446Smrj return (AE_NO_MEMORY); 8393446Smrj } 8403446Smrj 8413446Smrj /* Copy the actual buffer data */ 8423446Smrj 8433446Smrj ACPI_MEMCPY (DestDesc->Buffer.Pointer, 8443446Smrj SourceDesc->Buffer.Pointer, 8453446Smrj SourceDesc->Buffer.Length); 8463446Smrj } 8473446Smrj break; 8483446Smrj 8493446Smrj case ACPI_TYPE_STRING: 8503446Smrj /* 8513446Smrj * Allocate and copy the actual string if and only if: 8523446Smrj * 1) There is a valid string pointer 8533446Smrj * (Pointer to a NULL string is allowed) 8543446Smrj */ 8553446Smrj if (SourceDesc->String.Pointer) 8563446Smrj { 8573446Smrj DestDesc->String.Pointer = 8583446Smrj ACPI_ALLOCATE ((ACPI_SIZE) SourceDesc->String.Length + 1); 8593446Smrj if (!DestDesc->String.Pointer) 8603446Smrj { 8613446Smrj return (AE_NO_MEMORY); 8623446Smrj } 8633446Smrj 8643446Smrj /* Copy the actual string data */ 8653446Smrj 8663446Smrj ACPI_MEMCPY (DestDesc->String.Pointer, SourceDesc->String.Pointer, 8673446Smrj (ACPI_SIZE) SourceDesc->String.Length + 1); 8683446Smrj } 8693446Smrj break; 8703446Smrj 8713446Smrj case ACPI_TYPE_LOCAL_REFERENCE: 8723446Smrj /* 8733446Smrj * We copied the reference object, so we now must add a reference 8743446Smrj * to the object pointed to by the reference 8757851SDana.Myers@Sun.COM * 8767851SDana.Myers@Sun.COM * DDBHandle reference (from Load/LoadTable) is a special reference, 8777851SDana.Myers@Sun.COM * it does not have a Reference.Object, so does not need to 8787851SDana.Myers@Sun.COM * increase the reference count 8793446Smrj */ 8807851SDana.Myers@Sun.COM if (SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE) 8817851SDana.Myers@Sun.COM { 8827851SDana.Myers@Sun.COM break; 8837851SDana.Myers@Sun.COM } 8847851SDana.Myers@Sun.COM 8853446Smrj AcpiUtAddReference (SourceDesc->Reference.Object); 8863446Smrj break; 8873446Smrj 8883446Smrj case ACPI_TYPE_REGION: 8893446Smrj /* 8903446Smrj * We copied the Region Handler, so we now must add a reference 8913446Smrj */ 8923446Smrj if (DestDesc->Region.Handler) 8933446Smrj { 8943446Smrj AcpiUtAddReference (DestDesc->Region.Handler); 8953446Smrj } 8963446Smrj break; 8973446Smrj 898*9980SDana.Myers@Sun.COM /* 899*9980SDana.Myers@Sun.COM * For Mutex and Event objects, we cannot simply copy the underlying 900*9980SDana.Myers@Sun.COM * OS object. We must create a new one. 901*9980SDana.Myers@Sun.COM */ 902*9980SDana.Myers@Sun.COM case ACPI_TYPE_MUTEX: 903*9980SDana.Myers@Sun.COM 904*9980SDana.Myers@Sun.COM Status = AcpiOsCreateMutex (&DestDesc->Mutex.OsMutex); 905*9980SDana.Myers@Sun.COM if (ACPI_FAILURE (Status)) 906*9980SDana.Myers@Sun.COM { 907*9980SDana.Myers@Sun.COM return (Status); 908*9980SDana.Myers@Sun.COM } 909*9980SDana.Myers@Sun.COM break; 910*9980SDana.Myers@Sun.COM 911*9980SDana.Myers@Sun.COM case ACPI_TYPE_EVENT: 912*9980SDana.Myers@Sun.COM 913*9980SDana.Myers@Sun.COM Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, 914*9980SDana.Myers@Sun.COM &DestDesc->Event.OsSemaphore); 915*9980SDana.Myers@Sun.COM if (ACPI_FAILURE (Status)) 916*9980SDana.Myers@Sun.COM { 917*9980SDana.Myers@Sun.COM return (Status); 918*9980SDana.Myers@Sun.COM } 919*9980SDana.Myers@Sun.COM break; 920*9980SDana.Myers@Sun.COM 9213446Smrj default: 9223446Smrj /* Nothing to do for other simple objects */ 9233446Smrj break; 9243446Smrj } 9253446Smrj 9263446Smrj return (AE_OK); 9273446Smrj } 9283446Smrj 9293446Smrj 9303446Smrj /******************************************************************************* 9313446Smrj * 9323446Smrj * FUNCTION: AcpiUtCopyIelementToIelement 9333446Smrj * 9343446Smrj * PARAMETERS: ACPI_PKG_CALLBACK 9353446Smrj * 9363446Smrj * RETURN: Status 9373446Smrj * 9383446Smrj * DESCRIPTION: Copy one package element to another package element 9393446Smrj * 9403446Smrj ******************************************************************************/ 9413446Smrj 9423446Smrj static ACPI_STATUS 9433446Smrj AcpiUtCopyIelementToIelement ( 9443446Smrj UINT8 ObjectType, 9453446Smrj ACPI_OPERAND_OBJECT *SourceObject, 9463446Smrj ACPI_GENERIC_STATE *State, 9473446Smrj void *Context) 9483446Smrj { 9493446Smrj ACPI_STATUS Status = AE_OK; 9503446Smrj UINT32 ThisIndex; 9513446Smrj ACPI_OPERAND_OBJECT **ThisTargetPtr; 9523446Smrj ACPI_OPERAND_OBJECT *TargetObject; 9533446Smrj 9543446Smrj 9553446Smrj ACPI_FUNCTION_ENTRY (); 9563446Smrj 9573446Smrj 9583446Smrj ThisIndex = State->Pkg.Index; 9593446Smrj ThisTargetPtr = (ACPI_OPERAND_OBJECT **) 9603446Smrj &State->Pkg.DestObject->Package.Elements[ThisIndex]; 9613446Smrj 9623446Smrj switch (ObjectType) 9633446Smrj { 9643446Smrj case ACPI_COPY_TYPE_SIMPLE: 9653446Smrj 9663446Smrj /* A null source object indicates a (legal) null package element */ 9673446Smrj 9683446Smrj if (SourceObject) 9693446Smrj { 9703446Smrj /* 9713446Smrj * This is a simple object, just copy it 9723446Smrj */ 9733446Smrj TargetObject = AcpiUtCreateInternalObject ( 974*9980SDana.Myers@Sun.COM SourceObject->Common.Type); 9753446Smrj if (!TargetObject) 9763446Smrj { 9773446Smrj return (AE_NO_MEMORY); 9783446Smrj } 9793446Smrj 9803446Smrj Status = AcpiUtCopySimpleObject (SourceObject, TargetObject); 9813446Smrj if (ACPI_FAILURE (Status)) 9823446Smrj { 9833446Smrj goto ErrorExit; 9843446Smrj } 9853446Smrj 9863446Smrj *ThisTargetPtr = TargetObject; 9873446Smrj } 9883446Smrj else 9893446Smrj { 9903446Smrj /* Pass through a null element */ 9913446Smrj 9923446Smrj *ThisTargetPtr = NULL; 9933446Smrj } 9943446Smrj break; 9953446Smrj 9963446Smrj 9973446Smrj case ACPI_COPY_TYPE_PACKAGE: 9983446Smrj 9993446Smrj /* 10003446Smrj * This object is a package - go down another nesting level 10013446Smrj * Create and build the package object 10023446Smrj */ 10037851SDana.Myers@Sun.COM TargetObject = AcpiUtCreatePackageObject (SourceObject->Package.Count); 10043446Smrj if (!TargetObject) 10053446Smrj { 10063446Smrj return (AE_NO_MEMORY); 10073446Smrj } 10083446Smrj 10097851SDana.Myers@Sun.COM TargetObject->Common.Flags = SourceObject->Common.Flags; 10103446Smrj 10117851SDana.Myers@Sun.COM /* Pass the new package object back to the package walk routine */ 10123446Smrj 10133446Smrj State->Pkg.ThisTargetObj = TargetObject; 10143446Smrj 10157851SDana.Myers@Sun.COM /* Store the object pointer in the parent package object */ 10167851SDana.Myers@Sun.COM 10173446Smrj *ThisTargetPtr = TargetObject; 10183446Smrj break; 10193446Smrj 10203446Smrj 10213446Smrj default: 10223446Smrj return (AE_BAD_PARAMETER); 10233446Smrj } 10243446Smrj 10253446Smrj return (Status); 10263446Smrj 10273446Smrj ErrorExit: 10283446Smrj AcpiUtRemoveReference (TargetObject); 10293446Smrj return (Status); 10303446Smrj } 10313446Smrj 10323446Smrj 10333446Smrj /******************************************************************************* 10343446Smrj * 10353446Smrj * FUNCTION: AcpiUtCopyIpackageToIpackage 10363446Smrj * 10373446Smrj * PARAMETERS: *SourceObj - Pointer to the source package object 10383446Smrj * *DestObj - Where the internal object is returned 10393446Smrj * 10403446Smrj * RETURN: Status - the status of the call 10413446Smrj * 10423446Smrj * DESCRIPTION: This function is called to copy an internal package object 10433446Smrj * into another internal package object. 10443446Smrj * 10453446Smrj ******************************************************************************/ 10463446Smrj 10473446Smrj static ACPI_STATUS 10483446Smrj AcpiUtCopyIpackageToIpackage ( 10493446Smrj ACPI_OPERAND_OBJECT *SourceObj, 10503446Smrj ACPI_OPERAND_OBJECT *DestObj, 10513446Smrj ACPI_WALK_STATE *WalkState) 10523446Smrj { 10533446Smrj ACPI_STATUS Status = AE_OK; 10543446Smrj 10553446Smrj 10563446Smrj ACPI_FUNCTION_TRACE (UtCopyIpackageToIpackage); 10573446Smrj 10583446Smrj 1059*9980SDana.Myers@Sun.COM DestObj->Common.Type = SourceObj->Common.Type; 10603446Smrj DestObj->Common.Flags = SourceObj->Common.Flags; 10613446Smrj DestObj->Package.Count = SourceObj->Package.Count; 10623446Smrj 10633446Smrj /* 10643446Smrj * Create the object array and walk the source package tree 10653446Smrj */ 10663446Smrj DestObj->Package.Elements = ACPI_ALLOCATE_ZEROED ( 10673446Smrj ((ACPI_SIZE) SourceObj->Package.Count + 1) * 10683446Smrj sizeof (void *)); 10693446Smrj if (!DestObj->Package.Elements) 10703446Smrj { 10713446Smrj ACPI_ERROR ((AE_INFO, "Package allocation failure")); 10723446Smrj return_ACPI_STATUS (AE_NO_MEMORY); 10733446Smrj } 10743446Smrj 10753446Smrj /* 10763446Smrj * Copy the package element-by-element by walking the package "tree". 10773446Smrj * This handles nested packages of arbitrary depth. 10783446Smrj */ 10793446Smrj Status = AcpiUtWalkPackageTree (SourceObj, DestObj, 10803446Smrj AcpiUtCopyIelementToIelement, WalkState); 10813446Smrj if (ACPI_FAILURE (Status)) 10823446Smrj { 10833446Smrj /* On failure, delete the destination package object */ 10843446Smrj 10853446Smrj AcpiUtRemoveReference (DestObj); 10863446Smrj } 10873446Smrj 10883446Smrj return_ACPI_STATUS (Status); 10893446Smrj } 10903446Smrj 10913446Smrj 10923446Smrj /******************************************************************************* 10933446Smrj * 10943446Smrj * FUNCTION: AcpiUtCopyIobjectToIobject 10953446Smrj * 10963446Smrj * PARAMETERS: WalkState - Current walk state 10973446Smrj * SourceDesc - The internal object to be copied 10983446Smrj * DestDesc - Where the copied object is returned 10993446Smrj * 11003446Smrj * RETURN: Status 11013446Smrj * 11023446Smrj * DESCRIPTION: Copy an internal object to a new internal object 11033446Smrj * 11043446Smrj ******************************************************************************/ 11053446Smrj 11063446Smrj ACPI_STATUS 11073446Smrj AcpiUtCopyIobjectToIobject ( 11083446Smrj ACPI_OPERAND_OBJECT *SourceDesc, 11093446Smrj ACPI_OPERAND_OBJECT **DestDesc, 11103446Smrj ACPI_WALK_STATE *WalkState) 11113446Smrj { 11123446Smrj ACPI_STATUS Status = AE_OK; 11133446Smrj 11143446Smrj 11153446Smrj ACPI_FUNCTION_TRACE (UtCopyIobjectToIobject); 11163446Smrj 11173446Smrj 11183446Smrj /* Create the top level object */ 11193446Smrj 1120*9980SDana.Myers@Sun.COM *DestDesc = AcpiUtCreateInternalObject (SourceDesc->Common.Type); 11213446Smrj if (!*DestDesc) 11223446Smrj { 11233446Smrj return_ACPI_STATUS (AE_NO_MEMORY); 11243446Smrj } 11253446Smrj 11263446Smrj /* Copy the object and possible subobjects */ 11273446Smrj 1128*9980SDana.Myers@Sun.COM if (SourceDesc->Common.Type == ACPI_TYPE_PACKAGE) 11293446Smrj { 11303446Smrj Status = AcpiUtCopyIpackageToIpackage (SourceDesc, *DestDesc, 11313446Smrj WalkState); 11323446Smrj } 11333446Smrj else 11343446Smrj { 11353446Smrj Status = AcpiUtCopySimpleObject (SourceDesc, *DestDesc); 11363446Smrj } 11373446Smrj 11383446Smrj return_ACPI_STATUS (Status); 11393446Smrj } 11403446Smrj 11413446Smrj 1142