1*3446Smrj /****************************************************************************** 2*3446Smrj * 3*3446Smrj * Module Name: utcopy - Internal to external object translation utilities 4*3446Smrj * $Revision: 1.129 $ 5*3446Smrj * 6*3446Smrj *****************************************************************************/ 7*3446Smrj 8*3446Smrj /****************************************************************************** 9*3446Smrj * 10*3446Smrj * 1. Copyright Notice 11*3446Smrj * 12*3446Smrj * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp. 13*3446Smrj * All rights reserved. 14*3446Smrj * 15*3446Smrj * 2. License 16*3446Smrj * 17*3446Smrj * 2.1. This is your license from Intel Corp. under its intellectual property 18*3446Smrj * rights. You may have additional license terms from the party that provided 19*3446Smrj * you this software, covering your right to use that party's intellectual 20*3446Smrj * property rights. 21*3446Smrj * 22*3446Smrj * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23*3446Smrj * copy of the source code appearing in this file ("Covered Code") an 24*3446Smrj * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25*3446Smrj * base code distributed originally by Intel ("Original Intel Code") to copy, 26*3446Smrj * make derivatives, distribute, use and display any portion of the Covered 27*3446Smrj * Code in any form, with the right to sublicense such rights; and 28*3446Smrj * 29*3446Smrj * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30*3446Smrj * license (with the right to sublicense), under only those claims of Intel 31*3446Smrj * patents that are infringed by the Original Intel Code, to make, use, sell, 32*3446Smrj * offer to sell, and import the Covered Code and derivative works thereof 33*3446Smrj * solely to the minimum extent necessary to exercise the above copyright 34*3446Smrj * license, and in no event shall the patent license extend to any additions 35*3446Smrj * to or modifications of the Original Intel Code. No other license or right 36*3446Smrj * is granted directly or by implication, estoppel or otherwise; 37*3446Smrj * 38*3446Smrj * The above copyright and patent license is granted only if the following 39*3446Smrj * conditions are met: 40*3446Smrj * 41*3446Smrj * 3. Conditions 42*3446Smrj * 43*3446Smrj * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44*3446Smrj * Redistribution of source code of any substantial portion of the Covered 45*3446Smrj * Code or modification with rights to further distribute source must include 46*3446Smrj * the above Copyright Notice, the above License, this list of Conditions, 47*3446Smrj * and the following Disclaimer and Export Compliance provision. In addition, 48*3446Smrj * Licensee must cause all Covered Code to which Licensee contributes to 49*3446Smrj * contain a file documenting the changes Licensee made to create that Covered 50*3446Smrj * Code and the date of any change. Licensee must include in that file the 51*3446Smrj * documentation of any changes made by any predecessor Licensee. Licensee 52*3446Smrj * must include a prominent statement that the modification is derived, 53*3446Smrj * directly or indirectly, from Original Intel Code. 54*3446Smrj * 55*3446Smrj * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56*3446Smrj * Redistribution of source code of any substantial portion of the Covered 57*3446Smrj * Code or modification without rights to further distribute source must 58*3446Smrj * include the following Disclaimer and Export Compliance provision in the 59*3446Smrj * documentation and/or other materials provided with distribution. In 60*3446Smrj * addition, Licensee may not authorize further sublicense of source of any 61*3446Smrj * portion of the Covered Code, and must include terms to the effect that the 62*3446Smrj * license from Licensee to its licensee is limited to the intellectual 63*3446Smrj * property embodied in the software Licensee provides to its licensee, and 64*3446Smrj * not to intellectual property embodied in modifications its licensee may 65*3446Smrj * make. 66*3446Smrj * 67*3446Smrj * 3.3. Redistribution of Executable. Redistribution in executable form of any 68*3446Smrj * substantial portion of the Covered Code or modification must reproduce the 69*3446Smrj * above Copyright Notice, and the following Disclaimer and Export Compliance 70*3446Smrj * provision in the documentation and/or other materials provided with the 71*3446Smrj * distribution. 72*3446Smrj * 73*3446Smrj * 3.4. Intel retains all right, title, and interest in and to the Original 74*3446Smrj * Intel Code. 75*3446Smrj * 76*3446Smrj * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77*3446Smrj * Intel shall be used in advertising or otherwise to promote the sale, use or 78*3446Smrj * other dealings in products derived from or relating to the Covered Code 79*3446Smrj * without prior written authorization from Intel. 80*3446Smrj * 81*3446Smrj * 4. Disclaimer and Export Compliance 82*3446Smrj * 83*3446Smrj * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84*3446Smrj * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85*3446Smrj * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86*3446Smrj * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87*3446Smrj * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88*3446Smrj * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89*3446Smrj * PARTICULAR PURPOSE. 90*3446Smrj * 91*3446Smrj * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92*3446Smrj * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93*3446Smrj * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94*3446Smrj * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95*3446Smrj * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96*3446Smrj * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97*3446Smrj * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98*3446Smrj * LIMITED REMEDY. 99*3446Smrj * 100*3446Smrj * 4.3. Licensee shall not export, either directly or indirectly, any of this 101*3446Smrj * software or system incorporating such software without first obtaining any 102*3446Smrj * required license or other approval from the U. S. Department of Commerce or 103*3446Smrj * any other agency or department of the United States Government. In the 104*3446Smrj * event Licensee exports any such software from the United States or 105*3446Smrj * re-exports any such software from a foreign destination, Licensee shall 106*3446Smrj * ensure that the distribution and export/re-export of the software is in 107*3446Smrj * compliance with all laws, regulations, orders, or other restrictions of the 108*3446Smrj * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109*3446Smrj * any of its subsidiaries will export/re-export any technical data, process, 110*3446Smrj * software, or service, directly or indirectly, to any country for which the 111*3446Smrj * United States government or any agency thereof requires an export license, 112*3446Smrj * other governmental approval, or letter of assurance, without first obtaining 113*3446Smrj * such license, approval or letter. 114*3446Smrj * 115*3446Smrj *****************************************************************************/ 116*3446Smrj 117*3446Smrj #define __UTCOPY_C__ 118*3446Smrj 119*3446Smrj #include "acpi.h" 120*3446Smrj #include "amlcode.h" 121*3446Smrj 122*3446Smrj 123*3446Smrj #define _COMPONENT ACPI_UTILITIES 124*3446Smrj ACPI_MODULE_NAME ("utcopy") 125*3446Smrj 126*3446Smrj /* Local prototypes */ 127*3446Smrj 128*3446Smrj static ACPI_STATUS 129*3446Smrj AcpiUtCopyIsimpleToEsimple ( 130*3446Smrj ACPI_OPERAND_OBJECT *InternalObject, 131*3446Smrj ACPI_OBJECT *ExternalObject, 132*3446Smrj UINT8 *DataSpace, 133*3446Smrj ACPI_SIZE *BufferSpaceUsed); 134*3446Smrj 135*3446Smrj static ACPI_STATUS 136*3446Smrj AcpiUtCopyIelementToIelement ( 137*3446Smrj UINT8 ObjectType, 138*3446Smrj ACPI_OPERAND_OBJECT *SourceObject, 139*3446Smrj ACPI_GENERIC_STATE *State, 140*3446Smrj void *Context); 141*3446Smrj 142*3446Smrj static ACPI_STATUS 143*3446Smrj AcpiUtCopyIpackageToEpackage ( 144*3446Smrj ACPI_OPERAND_OBJECT *InternalObject, 145*3446Smrj UINT8 *Buffer, 146*3446Smrj ACPI_SIZE *SpaceUsed); 147*3446Smrj 148*3446Smrj static ACPI_STATUS 149*3446Smrj AcpiUtCopyEsimpleToIsimple( 150*3446Smrj ACPI_OBJECT *UserObj, 151*3446Smrj ACPI_OPERAND_OBJECT **ReturnObj); 152*3446Smrj 153*3446Smrj static ACPI_STATUS 154*3446Smrj AcpiUtCopySimpleObject ( 155*3446Smrj ACPI_OPERAND_OBJECT *SourceDesc, 156*3446Smrj ACPI_OPERAND_OBJECT *DestDesc); 157*3446Smrj 158*3446Smrj static ACPI_STATUS 159*3446Smrj AcpiUtCopyIelementToEelement ( 160*3446Smrj UINT8 ObjectType, 161*3446Smrj ACPI_OPERAND_OBJECT *SourceObject, 162*3446Smrj ACPI_GENERIC_STATE *State, 163*3446Smrj void *Context); 164*3446Smrj 165*3446Smrj static ACPI_STATUS 166*3446Smrj AcpiUtCopyIpackageToIpackage ( 167*3446Smrj ACPI_OPERAND_OBJECT *SourceObj, 168*3446Smrj ACPI_OPERAND_OBJECT *DestObj, 169*3446Smrj ACPI_WALK_STATE *WalkState); 170*3446Smrj 171*3446Smrj 172*3446Smrj /******************************************************************************* 173*3446Smrj * 174*3446Smrj * FUNCTION: AcpiUtCopyIsimpleToEsimple 175*3446Smrj * 176*3446Smrj * PARAMETERS: InternalObject - Source object to be copied 177*3446Smrj * ExternalObject - Where to return the copied object 178*3446Smrj * DataSpace - Where object data is returned (such as 179*3446Smrj * buffer and string data) 180*3446Smrj * BufferSpaceUsed - Length of DataSpace that was used 181*3446Smrj * 182*3446Smrj * RETURN: Status 183*3446Smrj * 184*3446Smrj * DESCRIPTION: This function is called to copy a simple internal object to 185*3446Smrj * an external object. 186*3446Smrj * 187*3446Smrj * The DataSpace buffer is assumed to have sufficient space for 188*3446Smrj * the object. 189*3446Smrj * 190*3446Smrj ******************************************************************************/ 191*3446Smrj 192*3446Smrj static ACPI_STATUS 193*3446Smrj AcpiUtCopyIsimpleToEsimple ( 194*3446Smrj ACPI_OPERAND_OBJECT *InternalObject, 195*3446Smrj ACPI_OBJECT *ExternalObject, 196*3446Smrj UINT8 *DataSpace, 197*3446Smrj ACPI_SIZE *BufferSpaceUsed) 198*3446Smrj { 199*3446Smrj ACPI_STATUS Status = AE_OK; 200*3446Smrj 201*3446Smrj 202*3446Smrj ACPI_FUNCTION_TRACE (UtCopyIsimpleToEsimple); 203*3446Smrj 204*3446Smrj 205*3446Smrj *BufferSpaceUsed = 0; 206*3446Smrj 207*3446Smrj /* 208*3446Smrj * Check for NULL object case (could be an uninitialized 209*3446Smrj * package element) 210*3446Smrj */ 211*3446Smrj if (!InternalObject) 212*3446Smrj { 213*3446Smrj return_ACPI_STATUS (AE_OK); 214*3446Smrj } 215*3446Smrj 216*3446Smrj /* Always clear the external object */ 217*3446Smrj 218*3446Smrj ACPI_MEMSET (ExternalObject, 0, sizeof (ACPI_OBJECT)); 219*3446Smrj 220*3446Smrj /* 221*3446Smrj * In general, the external object will be the same type as 222*3446Smrj * the internal object 223*3446Smrj */ 224*3446Smrj ExternalObject->Type = ACPI_GET_OBJECT_TYPE (InternalObject); 225*3446Smrj 226*3446Smrj /* However, only a limited number of external types are supported */ 227*3446Smrj 228*3446Smrj switch (ACPI_GET_OBJECT_TYPE (InternalObject)) 229*3446Smrj { 230*3446Smrj case ACPI_TYPE_STRING: 231*3446Smrj 232*3446Smrj ExternalObject->String.Pointer = (char *) DataSpace; 233*3446Smrj ExternalObject->String.Length = InternalObject->String.Length; 234*3446Smrj *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD ( 235*3446Smrj (ACPI_SIZE) InternalObject->String.Length + 1); 236*3446Smrj 237*3446Smrj ACPI_MEMCPY ((void *) DataSpace, 238*3446Smrj (void *) InternalObject->String.Pointer, 239*3446Smrj (ACPI_SIZE) InternalObject->String.Length + 1); 240*3446Smrj break; 241*3446Smrj 242*3446Smrj 243*3446Smrj case ACPI_TYPE_BUFFER: 244*3446Smrj 245*3446Smrj ExternalObject->Buffer.Pointer = DataSpace; 246*3446Smrj ExternalObject->Buffer.Length = InternalObject->Buffer.Length; 247*3446Smrj *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD ( 248*3446Smrj InternalObject->String.Length); 249*3446Smrj 250*3446Smrj ACPI_MEMCPY ((void *) DataSpace, 251*3446Smrj (void *) InternalObject->Buffer.Pointer, 252*3446Smrj InternalObject->Buffer.Length); 253*3446Smrj break; 254*3446Smrj 255*3446Smrj 256*3446Smrj case ACPI_TYPE_INTEGER: 257*3446Smrj 258*3446Smrj ExternalObject->Integer.Value = InternalObject->Integer.Value; 259*3446Smrj break; 260*3446Smrj 261*3446Smrj 262*3446Smrj case ACPI_TYPE_LOCAL_REFERENCE: 263*3446Smrj 264*3446Smrj /* 265*3446Smrj * This is an object reference. Attempt to dereference it. 266*3446Smrj */ 267*3446Smrj switch (InternalObject->Reference.Opcode) 268*3446Smrj { 269*3446Smrj case AML_INT_NAMEPATH_OP: 270*3446Smrj 271*3446Smrj /* For namepath, return the object handle ("reference") */ 272*3446Smrj 273*3446Smrj default: 274*3446Smrj /* 275*3446Smrj * Use the object type of "Any" to indicate a reference 276*3446Smrj * to object containing a handle to an ACPI named object. 277*3446Smrj */ 278*3446Smrj ExternalObject->Type = ACPI_TYPE_ANY; 279*3446Smrj ExternalObject->Reference.Handle = InternalObject->Reference.Node; 280*3446Smrj break; 281*3446Smrj } 282*3446Smrj break; 283*3446Smrj 284*3446Smrj 285*3446Smrj case ACPI_TYPE_PROCESSOR: 286*3446Smrj 287*3446Smrj ExternalObject->Processor.ProcId = InternalObject->Processor.ProcId; 288*3446Smrj ExternalObject->Processor.PblkAddress = InternalObject->Processor.Address; 289*3446Smrj ExternalObject->Processor.PblkLength = InternalObject->Processor.Length; 290*3446Smrj break; 291*3446Smrj 292*3446Smrj 293*3446Smrj case ACPI_TYPE_POWER: 294*3446Smrj 295*3446Smrj ExternalObject->PowerResource.SystemLevel = 296*3446Smrj InternalObject->PowerResource.SystemLevel; 297*3446Smrj 298*3446Smrj ExternalObject->PowerResource.ResourceOrder = 299*3446Smrj InternalObject->PowerResource.ResourceOrder; 300*3446Smrj break; 301*3446Smrj 302*3446Smrj 303*3446Smrj default: 304*3446Smrj /* 305*3446Smrj * There is no corresponding external object type 306*3446Smrj */ 307*3446Smrj return_ACPI_STATUS (AE_SUPPORT); 308*3446Smrj } 309*3446Smrj 310*3446Smrj return_ACPI_STATUS (Status); 311*3446Smrj } 312*3446Smrj 313*3446Smrj 314*3446Smrj /******************************************************************************* 315*3446Smrj * 316*3446Smrj * FUNCTION: AcpiUtCopyIelementToEelement 317*3446Smrj * 318*3446Smrj * PARAMETERS: ACPI_PKG_CALLBACK 319*3446Smrj * 320*3446Smrj * RETURN: Status 321*3446Smrj * 322*3446Smrj * DESCRIPTION: Copy one package element to another package element 323*3446Smrj * 324*3446Smrj ******************************************************************************/ 325*3446Smrj 326*3446Smrj static ACPI_STATUS 327*3446Smrj AcpiUtCopyIelementToEelement ( 328*3446Smrj UINT8 ObjectType, 329*3446Smrj ACPI_OPERAND_OBJECT *SourceObject, 330*3446Smrj ACPI_GENERIC_STATE *State, 331*3446Smrj void *Context) 332*3446Smrj { 333*3446Smrj ACPI_STATUS Status = AE_OK; 334*3446Smrj ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context; 335*3446Smrj ACPI_SIZE ObjectSpace; 336*3446Smrj UINT32 ThisIndex; 337*3446Smrj ACPI_OBJECT *TargetObject; 338*3446Smrj 339*3446Smrj 340*3446Smrj ACPI_FUNCTION_ENTRY (); 341*3446Smrj 342*3446Smrj 343*3446Smrj ThisIndex = State->Pkg.Index; 344*3446Smrj TargetObject = (ACPI_OBJECT *) 345*3446Smrj &((ACPI_OBJECT *)(State->Pkg.DestObject))->Package.Elements[ThisIndex]; 346*3446Smrj 347*3446Smrj switch (ObjectType) 348*3446Smrj { 349*3446Smrj case ACPI_COPY_TYPE_SIMPLE: 350*3446Smrj 351*3446Smrj /* 352*3446Smrj * This is a simple or null object 353*3446Smrj */ 354*3446Smrj Status = AcpiUtCopyIsimpleToEsimple (SourceObject, 355*3446Smrj TargetObject, Info->FreeSpace, &ObjectSpace); 356*3446Smrj if (ACPI_FAILURE (Status)) 357*3446Smrj { 358*3446Smrj return (Status); 359*3446Smrj } 360*3446Smrj break; 361*3446Smrj 362*3446Smrj 363*3446Smrj case ACPI_COPY_TYPE_PACKAGE: 364*3446Smrj 365*3446Smrj /* 366*3446Smrj * Build the package object 367*3446Smrj */ 368*3446Smrj TargetObject->Type = ACPI_TYPE_PACKAGE; 369*3446Smrj TargetObject->Package.Count = SourceObject->Package.Count; 370*3446Smrj TargetObject->Package.Elements = 371*3446Smrj ACPI_CAST_PTR (ACPI_OBJECT, Info->FreeSpace); 372*3446Smrj 373*3446Smrj /* 374*3446Smrj * Pass the new package object back to the package walk routine 375*3446Smrj */ 376*3446Smrj State->Pkg.ThisTargetObj = TargetObject; 377*3446Smrj 378*3446Smrj /* 379*3446Smrj * Save space for the array of objects (Package elements) 380*3446Smrj * update the buffer length counter 381*3446Smrj */ 382*3446Smrj ObjectSpace = ACPI_ROUND_UP_TO_NATIVE_WORD ( 383*3446Smrj (ACPI_SIZE) TargetObject->Package.Count * 384*3446Smrj sizeof (ACPI_OBJECT)); 385*3446Smrj break; 386*3446Smrj 387*3446Smrj 388*3446Smrj default: 389*3446Smrj return (AE_BAD_PARAMETER); 390*3446Smrj } 391*3446Smrj 392*3446Smrj Info->FreeSpace += ObjectSpace; 393*3446Smrj Info->Length += ObjectSpace; 394*3446Smrj return (Status); 395*3446Smrj } 396*3446Smrj 397*3446Smrj 398*3446Smrj /******************************************************************************* 399*3446Smrj * 400*3446Smrj * FUNCTION: AcpiUtCopyIpackageToEpackage 401*3446Smrj * 402*3446Smrj * PARAMETERS: InternalObject - Pointer to the object we are returning 403*3446Smrj * Buffer - Where the object is returned 404*3446Smrj * SpaceUsed - Where the object length is returned 405*3446Smrj * 406*3446Smrj * RETURN: Status 407*3446Smrj * 408*3446Smrj * DESCRIPTION: This function is called to place a package object in a user 409*3446Smrj * buffer. A package object by definition contains other objects. 410*3446Smrj * 411*3446Smrj * The buffer is assumed to have sufficient space for the object. 412*3446Smrj * The caller must have verified the buffer length needed using the 413*3446Smrj * AcpiUtGetObjectSize function before calling this function. 414*3446Smrj * 415*3446Smrj ******************************************************************************/ 416*3446Smrj 417*3446Smrj static ACPI_STATUS 418*3446Smrj AcpiUtCopyIpackageToEpackage ( 419*3446Smrj ACPI_OPERAND_OBJECT *InternalObject, 420*3446Smrj UINT8 *Buffer, 421*3446Smrj ACPI_SIZE *SpaceUsed) 422*3446Smrj { 423*3446Smrj ACPI_OBJECT *ExternalObject; 424*3446Smrj ACPI_STATUS Status; 425*3446Smrj ACPI_PKG_INFO Info; 426*3446Smrj 427*3446Smrj 428*3446Smrj ACPI_FUNCTION_TRACE (UtCopyIpackageToEpackage); 429*3446Smrj 430*3446Smrj 431*3446Smrj /* 432*3446Smrj * First package at head of the buffer 433*3446Smrj */ 434*3446Smrj ExternalObject = ACPI_CAST_PTR (ACPI_OBJECT, Buffer); 435*3446Smrj 436*3446Smrj /* 437*3446Smrj * Free space begins right after the first package 438*3446Smrj */ 439*3446Smrj Info.Length = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); 440*3446Smrj Info.FreeSpace = Buffer + ACPI_ROUND_UP_TO_NATIVE_WORD ( 441*3446Smrj sizeof (ACPI_OBJECT)); 442*3446Smrj Info.ObjectSpace = 0; 443*3446Smrj Info.NumPackages = 1; 444*3446Smrj 445*3446Smrj ExternalObject->Type = ACPI_GET_OBJECT_TYPE (InternalObject); 446*3446Smrj ExternalObject->Package.Count = InternalObject->Package.Count; 447*3446Smrj ExternalObject->Package.Elements = ACPI_CAST_PTR (ACPI_OBJECT, 448*3446Smrj Info.FreeSpace); 449*3446Smrj 450*3446Smrj /* 451*3446Smrj * Leave room for an array of ACPI_OBJECTS in the buffer 452*3446Smrj * and move the free space past it 453*3446Smrj */ 454*3446Smrj Info.Length += (ACPI_SIZE) ExternalObject->Package.Count * 455*3446Smrj ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); 456*3446Smrj Info.FreeSpace += ExternalObject->Package.Count * 457*3446Smrj ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); 458*3446Smrj 459*3446Smrj Status = AcpiUtWalkPackageTree (InternalObject, ExternalObject, 460*3446Smrj AcpiUtCopyIelementToEelement, &Info); 461*3446Smrj 462*3446Smrj *SpaceUsed = Info.Length; 463*3446Smrj return_ACPI_STATUS (Status); 464*3446Smrj } 465*3446Smrj 466*3446Smrj 467*3446Smrj /******************************************************************************* 468*3446Smrj * 469*3446Smrj * FUNCTION: AcpiUtCopyIobjectToEobject 470*3446Smrj * 471*3446Smrj * PARAMETERS: InternalObject - The internal object to be converted 472*3446Smrj * BufferPtr - Where the object is returned 473*3446Smrj * 474*3446Smrj * RETURN: Status 475*3446Smrj * 476*3446Smrj * DESCRIPTION: This function is called to build an API object to be returned to 477*3446Smrj * the caller. 478*3446Smrj * 479*3446Smrj ******************************************************************************/ 480*3446Smrj 481*3446Smrj ACPI_STATUS 482*3446Smrj AcpiUtCopyIobjectToEobject ( 483*3446Smrj ACPI_OPERAND_OBJECT *InternalObject, 484*3446Smrj ACPI_BUFFER *RetBuffer) 485*3446Smrj { 486*3446Smrj ACPI_STATUS Status; 487*3446Smrj 488*3446Smrj 489*3446Smrj ACPI_FUNCTION_TRACE (UtCopyIobjectToEobject); 490*3446Smrj 491*3446Smrj 492*3446Smrj if (ACPI_GET_OBJECT_TYPE (InternalObject) == ACPI_TYPE_PACKAGE) 493*3446Smrj { 494*3446Smrj /* 495*3446Smrj * Package object: Copy all subobjects (including 496*3446Smrj * nested packages) 497*3446Smrj */ 498*3446Smrj Status = AcpiUtCopyIpackageToEpackage (InternalObject, 499*3446Smrj RetBuffer->Pointer, &RetBuffer->Length); 500*3446Smrj } 501*3446Smrj else 502*3446Smrj { 503*3446Smrj /* 504*3446Smrj * Build a simple object (no nested objects) 505*3446Smrj */ 506*3446Smrj Status = AcpiUtCopyIsimpleToEsimple (InternalObject, 507*3446Smrj ACPI_CAST_PTR (ACPI_OBJECT, RetBuffer->Pointer), 508*3446Smrj ACPI_ADD_PTR (UINT8, RetBuffer->Pointer, 509*3446Smrj ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT))), 510*3446Smrj &RetBuffer->Length); 511*3446Smrj /* 512*3446Smrj * build simple does not include the object size in the length 513*3446Smrj * so we add it in here 514*3446Smrj */ 515*3446Smrj RetBuffer->Length += sizeof (ACPI_OBJECT); 516*3446Smrj } 517*3446Smrj 518*3446Smrj return_ACPI_STATUS (Status); 519*3446Smrj } 520*3446Smrj 521*3446Smrj 522*3446Smrj /******************************************************************************* 523*3446Smrj * 524*3446Smrj * FUNCTION: AcpiUtCopyEsimpleToIsimple 525*3446Smrj * 526*3446Smrj * PARAMETERS: ExternalObject - The external object to be converted 527*3446Smrj * RetInternalObject - Where the internal object is returned 528*3446Smrj * 529*3446Smrj * RETURN: Status 530*3446Smrj * 531*3446Smrj * DESCRIPTION: This function copies an external object to an internal one. 532*3446Smrj * NOTE: Pointers can be copied, we don't need to copy data. 533*3446Smrj * (The pointers have to be valid in our address space no matter 534*3446Smrj * what we do with them!) 535*3446Smrj * 536*3446Smrj ******************************************************************************/ 537*3446Smrj 538*3446Smrj static ACPI_STATUS 539*3446Smrj AcpiUtCopyEsimpleToIsimple ( 540*3446Smrj ACPI_OBJECT *ExternalObject, 541*3446Smrj ACPI_OPERAND_OBJECT **RetInternalObject) 542*3446Smrj { 543*3446Smrj ACPI_OPERAND_OBJECT *InternalObject; 544*3446Smrj 545*3446Smrj 546*3446Smrj ACPI_FUNCTION_TRACE (UtCopyEsimpleToIsimple); 547*3446Smrj 548*3446Smrj 549*3446Smrj /* 550*3446Smrj * Simple types supported are: String, Buffer, Integer 551*3446Smrj */ 552*3446Smrj switch (ExternalObject->Type) 553*3446Smrj { 554*3446Smrj case ACPI_TYPE_STRING: 555*3446Smrj case ACPI_TYPE_BUFFER: 556*3446Smrj case ACPI_TYPE_INTEGER: 557*3446Smrj 558*3446Smrj InternalObject = AcpiUtCreateInternalObject ( 559*3446Smrj (UINT8) ExternalObject->Type); 560*3446Smrj if (!InternalObject) 561*3446Smrj { 562*3446Smrj return_ACPI_STATUS (AE_NO_MEMORY); 563*3446Smrj } 564*3446Smrj break; 565*3446Smrj 566*3446Smrj default: 567*3446Smrj /* All other types are not supported */ 568*3446Smrj 569*3446Smrj return_ACPI_STATUS (AE_SUPPORT); 570*3446Smrj } 571*3446Smrj 572*3446Smrj 573*3446Smrj /* Must COPY string and buffer contents */ 574*3446Smrj 575*3446Smrj switch (ExternalObject->Type) 576*3446Smrj { 577*3446Smrj case ACPI_TYPE_STRING: 578*3446Smrj 579*3446Smrj InternalObject->String.Pointer = 580*3446Smrj ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) ExternalObject->String.Length + 1); 581*3446Smrj if (!InternalObject->String.Pointer) 582*3446Smrj { 583*3446Smrj goto ErrorExit; 584*3446Smrj } 585*3446Smrj 586*3446Smrj ACPI_MEMCPY (InternalObject->String.Pointer, 587*3446Smrj ExternalObject->String.Pointer, 588*3446Smrj ExternalObject->String.Length); 589*3446Smrj 590*3446Smrj InternalObject->String.Length = ExternalObject->String.Length; 591*3446Smrj break; 592*3446Smrj 593*3446Smrj 594*3446Smrj case ACPI_TYPE_BUFFER: 595*3446Smrj 596*3446Smrj InternalObject->Buffer.Pointer = 597*3446Smrj ACPI_ALLOCATE_ZEROED (ExternalObject->Buffer.Length); 598*3446Smrj if (!InternalObject->Buffer.Pointer) 599*3446Smrj { 600*3446Smrj goto ErrorExit; 601*3446Smrj } 602*3446Smrj 603*3446Smrj ACPI_MEMCPY (InternalObject->Buffer.Pointer, 604*3446Smrj ExternalObject->Buffer.Pointer, 605*3446Smrj ExternalObject->Buffer.Length); 606*3446Smrj 607*3446Smrj InternalObject->Buffer.Length = ExternalObject->Buffer.Length; 608*3446Smrj break; 609*3446Smrj 610*3446Smrj 611*3446Smrj case ACPI_TYPE_INTEGER: 612*3446Smrj 613*3446Smrj InternalObject->Integer.Value = ExternalObject->Integer.Value; 614*3446Smrj break; 615*3446Smrj 616*3446Smrj default: 617*3446Smrj /* Other types can't get here */ 618*3446Smrj break; 619*3446Smrj } 620*3446Smrj 621*3446Smrj *RetInternalObject = InternalObject; 622*3446Smrj return_ACPI_STATUS (AE_OK); 623*3446Smrj 624*3446Smrj 625*3446Smrj ErrorExit: 626*3446Smrj AcpiUtRemoveReference (InternalObject); 627*3446Smrj return_ACPI_STATUS (AE_NO_MEMORY); 628*3446Smrj } 629*3446Smrj 630*3446Smrj 631*3446Smrj #ifdef ACPI_FUTURE_IMPLEMENTATION 632*3446Smrj /* Code to convert packages that are parameters to control methods */ 633*3446Smrj 634*3446Smrj /******************************************************************************* 635*3446Smrj * 636*3446Smrj * FUNCTION: AcpiUtCopyEpackageToIpackage 637*3446Smrj * 638*3446Smrj * PARAMETERS: *InternalObject - Pointer to the object we are returning 639*3446Smrj * *Buffer - Where the object is returned 640*3446Smrj * *SpaceUsed - Where the length of the object is returned 641*3446Smrj * 642*3446Smrj * RETURN: Status 643*3446Smrj * 644*3446Smrj * DESCRIPTION: This function is called to place a package object in a user 645*3446Smrj * buffer. A package object by definition contains other objects. 646*3446Smrj * 647*3446Smrj * The buffer is assumed to have sufficient space for the object. 648*3446Smrj * The caller must have verified the buffer length needed using the 649*3446Smrj * AcpiUtGetObjectSize function before calling this function. 650*3446Smrj * 651*3446Smrj ******************************************************************************/ 652*3446Smrj 653*3446Smrj static ACPI_STATUS 654*3446Smrj AcpiUtCopyEpackageToIpackage ( 655*3446Smrj ACPI_OPERAND_OBJECT *InternalObject, 656*3446Smrj UINT8 *Buffer, 657*3446Smrj UINT32 *SpaceUsed) 658*3446Smrj { 659*3446Smrj UINT8 *FreeSpace; 660*3446Smrj ACPI_OBJECT *ExternalObject; 661*3446Smrj UINT32 Length = 0; 662*3446Smrj UINT32 ThisIndex; 663*3446Smrj UINT32 ObjectSpace = 0; 664*3446Smrj ACPI_OPERAND_OBJECT *ThisInternalObj; 665*3446Smrj ACPI_OBJECT *ThisExternalObj; 666*3446Smrj 667*3446Smrj 668*3446Smrj ACPI_FUNCTION_TRACE (UtCopyEpackageToIpackage); 669*3446Smrj 670*3446Smrj 671*3446Smrj /* 672*3446Smrj * First package at head of the buffer 673*3446Smrj */ 674*3446Smrj ExternalObject = (ACPI_OBJECT *)Buffer; 675*3446Smrj 676*3446Smrj /* 677*3446Smrj * Free space begins right after the first package 678*3446Smrj */ 679*3446Smrj FreeSpace = Buffer + sizeof(ACPI_OBJECT); 680*3446Smrj 681*3446Smrj 682*3446Smrj ExternalObject->Type = ACPI_GET_OBJECT_TYPE (InternalObject); 683*3446Smrj ExternalObject->Package.Count = InternalObject->Package.Count; 684*3446Smrj ExternalObject->Package.Elements = (ACPI_OBJECT *)FreeSpace; 685*3446Smrj 686*3446Smrj /* 687*3446Smrj * Build an array of ACPI_OBJECTS in the buffer 688*3446Smrj * and move the free space past it 689*3446Smrj */ 690*3446Smrj FreeSpace += ExternalObject->Package.Count * sizeof(ACPI_OBJECT); 691*3446Smrj 692*3446Smrj 693*3446Smrj /* Call WalkPackage */ 694*3446Smrj 695*3446Smrj } 696*3446Smrj 697*3446Smrj #endif /* Future implementation */ 698*3446Smrj 699*3446Smrj 700*3446Smrj /******************************************************************************* 701*3446Smrj * 702*3446Smrj * FUNCTION: AcpiUtCopyEobjectToIobject 703*3446Smrj * 704*3446Smrj * PARAMETERS: *InternalObject - The external object to be converted 705*3446Smrj * *BufferPtr - Where the internal object is returned 706*3446Smrj * 707*3446Smrj * RETURN: Status - the status of the call 708*3446Smrj * 709*3446Smrj * DESCRIPTION: Converts an external object to an internal object. 710*3446Smrj * 711*3446Smrj ******************************************************************************/ 712*3446Smrj 713*3446Smrj ACPI_STATUS 714*3446Smrj AcpiUtCopyEobjectToIobject ( 715*3446Smrj ACPI_OBJECT *ExternalObject, 716*3446Smrj ACPI_OPERAND_OBJECT **InternalObject) 717*3446Smrj { 718*3446Smrj ACPI_STATUS Status; 719*3446Smrj 720*3446Smrj 721*3446Smrj ACPI_FUNCTION_TRACE (UtCopyEobjectToIobject); 722*3446Smrj 723*3446Smrj 724*3446Smrj if (ExternalObject->Type == ACPI_TYPE_PACKAGE) 725*3446Smrj { 726*3446Smrj /* 727*3446Smrj * Packages as external input to control methods are not supported, 728*3446Smrj */ 729*3446Smrj ACPI_ERROR ((AE_INFO, 730*3446Smrj "Packages as parameters not implemented!")); 731*3446Smrj 732*3446Smrj return_ACPI_STATUS (AE_NOT_IMPLEMENTED); 733*3446Smrj } 734*3446Smrj 735*3446Smrj else 736*3446Smrj { 737*3446Smrj /* 738*3446Smrj * Build a simple object (no nested objects) 739*3446Smrj */ 740*3446Smrj Status = AcpiUtCopyEsimpleToIsimple (ExternalObject, InternalObject); 741*3446Smrj } 742*3446Smrj 743*3446Smrj return_ACPI_STATUS (Status); 744*3446Smrj } 745*3446Smrj 746*3446Smrj 747*3446Smrj /******************************************************************************* 748*3446Smrj * 749*3446Smrj * FUNCTION: AcpiUtCopySimpleObject 750*3446Smrj * 751*3446Smrj * PARAMETERS: SourceDesc - The internal object to be copied 752*3446Smrj * DestDesc - New target object 753*3446Smrj * 754*3446Smrj * RETURN: Status 755*3446Smrj * 756*3446Smrj * DESCRIPTION: Simple copy of one internal object to another. Reference count 757*3446Smrj * of the destination object is preserved. 758*3446Smrj * 759*3446Smrj ******************************************************************************/ 760*3446Smrj 761*3446Smrj static ACPI_STATUS 762*3446Smrj AcpiUtCopySimpleObject ( 763*3446Smrj ACPI_OPERAND_OBJECT *SourceDesc, 764*3446Smrj ACPI_OPERAND_OBJECT *DestDesc) 765*3446Smrj { 766*3446Smrj UINT16 ReferenceCount; 767*3446Smrj ACPI_OPERAND_OBJECT *NextObject; 768*3446Smrj 769*3446Smrj 770*3446Smrj /* Save fields from destination that we don't want to overwrite */ 771*3446Smrj 772*3446Smrj ReferenceCount = DestDesc->Common.ReferenceCount; 773*3446Smrj NextObject = DestDesc->Common.NextObject; 774*3446Smrj 775*3446Smrj /* Copy the entire source object over the destination object*/ 776*3446Smrj 777*3446Smrj ACPI_MEMCPY ((char *) DestDesc, (char *) SourceDesc, 778*3446Smrj sizeof (ACPI_OPERAND_OBJECT)); 779*3446Smrj 780*3446Smrj /* Restore the saved fields */ 781*3446Smrj 782*3446Smrj DestDesc->Common.ReferenceCount = ReferenceCount; 783*3446Smrj DestDesc->Common.NextObject = NextObject; 784*3446Smrj 785*3446Smrj /* New object is not static, regardless of source */ 786*3446Smrj 787*3446Smrj DestDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER; 788*3446Smrj 789*3446Smrj /* Handle the objects with extra data */ 790*3446Smrj 791*3446Smrj switch (ACPI_GET_OBJECT_TYPE (DestDesc)) 792*3446Smrj { 793*3446Smrj case ACPI_TYPE_BUFFER: 794*3446Smrj /* 795*3446Smrj * Allocate and copy the actual buffer if and only if: 796*3446Smrj * 1) There is a valid buffer pointer 797*3446Smrj * 2) The buffer has a length > 0 798*3446Smrj */ 799*3446Smrj if ((SourceDesc->Buffer.Pointer) && 800*3446Smrj (SourceDesc->Buffer.Length)) 801*3446Smrj { 802*3446Smrj DestDesc->Buffer.Pointer = 803*3446Smrj ACPI_ALLOCATE (SourceDesc->Buffer.Length); 804*3446Smrj if (!DestDesc->Buffer.Pointer) 805*3446Smrj { 806*3446Smrj return (AE_NO_MEMORY); 807*3446Smrj } 808*3446Smrj 809*3446Smrj /* Copy the actual buffer data */ 810*3446Smrj 811*3446Smrj ACPI_MEMCPY (DestDesc->Buffer.Pointer, 812*3446Smrj SourceDesc->Buffer.Pointer, 813*3446Smrj SourceDesc->Buffer.Length); 814*3446Smrj } 815*3446Smrj break; 816*3446Smrj 817*3446Smrj case ACPI_TYPE_STRING: 818*3446Smrj /* 819*3446Smrj * Allocate and copy the actual string if and only if: 820*3446Smrj * 1) There is a valid string pointer 821*3446Smrj * (Pointer to a NULL string is allowed) 822*3446Smrj */ 823*3446Smrj if (SourceDesc->String.Pointer) 824*3446Smrj { 825*3446Smrj DestDesc->String.Pointer = 826*3446Smrj ACPI_ALLOCATE ((ACPI_SIZE) SourceDesc->String.Length + 1); 827*3446Smrj if (!DestDesc->String.Pointer) 828*3446Smrj { 829*3446Smrj return (AE_NO_MEMORY); 830*3446Smrj } 831*3446Smrj 832*3446Smrj /* Copy the actual string data */ 833*3446Smrj 834*3446Smrj ACPI_MEMCPY (DestDesc->String.Pointer, SourceDesc->String.Pointer, 835*3446Smrj (ACPI_SIZE) SourceDesc->String.Length + 1); 836*3446Smrj } 837*3446Smrj break; 838*3446Smrj 839*3446Smrj case ACPI_TYPE_LOCAL_REFERENCE: 840*3446Smrj /* 841*3446Smrj * We copied the reference object, so we now must add a reference 842*3446Smrj * to the object pointed to by the reference 843*3446Smrj */ 844*3446Smrj AcpiUtAddReference (SourceDesc->Reference.Object); 845*3446Smrj break; 846*3446Smrj 847*3446Smrj case ACPI_TYPE_REGION: 848*3446Smrj /* 849*3446Smrj * We copied the Region Handler, so we now must add a reference 850*3446Smrj */ 851*3446Smrj if (DestDesc->Region.Handler) 852*3446Smrj { 853*3446Smrj AcpiUtAddReference (DestDesc->Region.Handler); 854*3446Smrj } 855*3446Smrj break; 856*3446Smrj 857*3446Smrj default: 858*3446Smrj /* Nothing to do for other simple objects */ 859*3446Smrj break; 860*3446Smrj } 861*3446Smrj 862*3446Smrj return (AE_OK); 863*3446Smrj } 864*3446Smrj 865*3446Smrj 866*3446Smrj /******************************************************************************* 867*3446Smrj * 868*3446Smrj * FUNCTION: AcpiUtCopyIelementToIelement 869*3446Smrj * 870*3446Smrj * PARAMETERS: ACPI_PKG_CALLBACK 871*3446Smrj * 872*3446Smrj * RETURN: Status 873*3446Smrj * 874*3446Smrj * DESCRIPTION: Copy one package element to another package element 875*3446Smrj * 876*3446Smrj ******************************************************************************/ 877*3446Smrj 878*3446Smrj static ACPI_STATUS 879*3446Smrj AcpiUtCopyIelementToIelement ( 880*3446Smrj UINT8 ObjectType, 881*3446Smrj ACPI_OPERAND_OBJECT *SourceObject, 882*3446Smrj ACPI_GENERIC_STATE *State, 883*3446Smrj void *Context) 884*3446Smrj { 885*3446Smrj ACPI_STATUS Status = AE_OK; 886*3446Smrj UINT32 ThisIndex; 887*3446Smrj ACPI_OPERAND_OBJECT **ThisTargetPtr; 888*3446Smrj ACPI_OPERAND_OBJECT *TargetObject; 889*3446Smrj 890*3446Smrj 891*3446Smrj ACPI_FUNCTION_ENTRY (); 892*3446Smrj 893*3446Smrj 894*3446Smrj ThisIndex = State->Pkg.Index; 895*3446Smrj ThisTargetPtr = (ACPI_OPERAND_OBJECT **) 896*3446Smrj &State->Pkg.DestObject->Package.Elements[ThisIndex]; 897*3446Smrj 898*3446Smrj switch (ObjectType) 899*3446Smrj { 900*3446Smrj case ACPI_COPY_TYPE_SIMPLE: 901*3446Smrj 902*3446Smrj /* A null source object indicates a (legal) null package element */ 903*3446Smrj 904*3446Smrj if (SourceObject) 905*3446Smrj { 906*3446Smrj /* 907*3446Smrj * This is a simple object, just copy it 908*3446Smrj */ 909*3446Smrj TargetObject = AcpiUtCreateInternalObject ( 910*3446Smrj ACPI_GET_OBJECT_TYPE (SourceObject)); 911*3446Smrj if (!TargetObject) 912*3446Smrj { 913*3446Smrj return (AE_NO_MEMORY); 914*3446Smrj } 915*3446Smrj 916*3446Smrj Status = AcpiUtCopySimpleObject (SourceObject, TargetObject); 917*3446Smrj if (ACPI_FAILURE (Status)) 918*3446Smrj { 919*3446Smrj goto ErrorExit; 920*3446Smrj } 921*3446Smrj 922*3446Smrj *ThisTargetPtr = TargetObject; 923*3446Smrj } 924*3446Smrj else 925*3446Smrj { 926*3446Smrj /* Pass through a null element */ 927*3446Smrj 928*3446Smrj *ThisTargetPtr = NULL; 929*3446Smrj } 930*3446Smrj break; 931*3446Smrj 932*3446Smrj 933*3446Smrj case ACPI_COPY_TYPE_PACKAGE: 934*3446Smrj 935*3446Smrj /* 936*3446Smrj * This object is a package - go down another nesting level 937*3446Smrj * Create and build the package object 938*3446Smrj */ 939*3446Smrj TargetObject = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE); 940*3446Smrj if (!TargetObject) 941*3446Smrj { 942*3446Smrj return (AE_NO_MEMORY); 943*3446Smrj } 944*3446Smrj 945*3446Smrj TargetObject->Package.Count = SourceObject->Package.Count; 946*3446Smrj TargetObject->Common.Flags = SourceObject->Common.Flags; 947*3446Smrj 948*3446Smrj /* 949*3446Smrj * Create the object array 950*3446Smrj */ 951*3446Smrj TargetObject->Package.Elements = ACPI_ALLOCATE_ZEROED ( 952*3446Smrj ((ACPI_SIZE) SourceObject->Package.Count + 1) * sizeof (void *)); 953*3446Smrj if (!TargetObject->Package.Elements) 954*3446Smrj { 955*3446Smrj Status = AE_NO_MEMORY; 956*3446Smrj goto ErrorExit; 957*3446Smrj } 958*3446Smrj 959*3446Smrj /* 960*3446Smrj * Pass the new package object back to the package walk routine 961*3446Smrj */ 962*3446Smrj State->Pkg.ThisTargetObj = TargetObject; 963*3446Smrj 964*3446Smrj /* 965*3446Smrj * Store the object pointer in the parent package object 966*3446Smrj */ 967*3446Smrj *ThisTargetPtr = TargetObject; 968*3446Smrj break; 969*3446Smrj 970*3446Smrj 971*3446Smrj default: 972*3446Smrj return (AE_BAD_PARAMETER); 973*3446Smrj } 974*3446Smrj 975*3446Smrj return (Status); 976*3446Smrj 977*3446Smrj ErrorExit: 978*3446Smrj AcpiUtRemoveReference (TargetObject); 979*3446Smrj return (Status); 980*3446Smrj } 981*3446Smrj 982*3446Smrj 983*3446Smrj /******************************************************************************* 984*3446Smrj * 985*3446Smrj * FUNCTION: AcpiUtCopyIpackageToIpackage 986*3446Smrj * 987*3446Smrj * PARAMETERS: *SourceObj - Pointer to the source package object 988*3446Smrj * *DestObj - Where the internal object is returned 989*3446Smrj * 990*3446Smrj * RETURN: Status - the status of the call 991*3446Smrj * 992*3446Smrj * DESCRIPTION: This function is called to copy an internal package object 993*3446Smrj * into another internal package object. 994*3446Smrj * 995*3446Smrj ******************************************************************************/ 996*3446Smrj 997*3446Smrj static ACPI_STATUS 998*3446Smrj AcpiUtCopyIpackageToIpackage ( 999*3446Smrj ACPI_OPERAND_OBJECT *SourceObj, 1000*3446Smrj ACPI_OPERAND_OBJECT *DestObj, 1001*3446Smrj ACPI_WALK_STATE *WalkState) 1002*3446Smrj { 1003*3446Smrj ACPI_STATUS Status = AE_OK; 1004*3446Smrj 1005*3446Smrj 1006*3446Smrj ACPI_FUNCTION_TRACE (UtCopyIpackageToIpackage); 1007*3446Smrj 1008*3446Smrj 1009*3446Smrj DestObj->Common.Type = ACPI_GET_OBJECT_TYPE (SourceObj); 1010*3446Smrj DestObj->Common.Flags = SourceObj->Common.Flags; 1011*3446Smrj DestObj->Package.Count = SourceObj->Package.Count; 1012*3446Smrj 1013*3446Smrj /* 1014*3446Smrj * Create the object array and walk the source package tree 1015*3446Smrj */ 1016*3446Smrj DestObj->Package.Elements = ACPI_ALLOCATE_ZEROED ( 1017*3446Smrj ((ACPI_SIZE) SourceObj->Package.Count + 1) * 1018*3446Smrj sizeof (void *)); 1019*3446Smrj if (!DestObj->Package.Elements) 1020*3446Smrj { 1021*3446Smrj ACPI_ERROR ((AE_INFO, "Package allocation failure")); 1022*3446Smrj return_ACPI_STATUS (AE_NO_MEMORY); 1023*3446Smrj } 1024*3446Smrj 1025*3446Smrj /* 1026*3446Smrj * Copy the package element-by-element by walking the package "tree". 1027*3446Smrj * This handles nested packages of arbitrary depth. 1028*3446Smrj */ 1029*3446Smrj Status = AcpiUtWalkPackageTree (SourceObj, DestObj, 1030*3446Smrj AcpiUtCopyIelementToIelement, WalkState); 1031*3446Smrj if (ACPI_FAILURE (Status)) 1032*3446Smrj { 1033*3446Smrj /* On failure, delete the destination package object */ 1034*3446Smrj 1035*3446Smrj AcpiUtRemoveReference (DestObj); 1036*3446Smrj } 1037*3446Smrj 1038*3446Smrj return_ACPI_STATUS (Status); 1039*3446Smrj } 1040*3446Smrj 1041*3446Smrj 1042*3446Smrj /******************************************************************************* 1043*3446Smrj * 1044*3446Smrj * FUNCTION: AcpiUtCopyIobjectToIobject 1045*3446Smrj * 1046*3446Smrj * PARAMETERS: WalkState - Current walk state 1047*3446Smrj * SourceDesc - The internal object to be copied 1048*3446Smrj * DestDesc - Where the copied object is returned 1049*3446Smrj * 1050*3446Smrj * RETURN: Status 1051*3446Smrj * 1052*3446Smrj * DESCRIPTION: Copy an internal object to a new internal object 1053*3446Smrj * 1054*3446Smrj ******************************************************************************/ 1055*3446Smrj 1056*3446Smrj ACPI_STATUS 1057*3446Smrj AcpiUtCopyIobjectToIobject ( 1058*3446Smrj ACPI_OPERAND_OBJECT *SourceDesc, 1059*3446Smrj ACPI_OPERAND_OBJECT **DestDesc, 1060*3446Smrj ACPI_WALK_STATE *WalkState) 1061*3446Smrj { 1062*3446Smrj ACPI_STATUS Status = AE_OK; 1063*3446Smrj 1064*3446Smrj 1065*3446Smrj ACPI_FUNCTION_TRACE (UtCopyIobjectToIobject); 1066*3446Smrj 1067*3446Smrj 1068*3446Smrj /* Create the top level object */ 1069*3446Smrj 1070*3446Smrj *DestDesc = AcpiUtCreateInternalObject (ACPI_GET_OBJECT_TYPE (SourceDesc)); 1071*3446Smrj if (!*DestDesc) 1072*3446Smrj { 1073*3446Smrj return_ACPI_STATUS (AE_NO_MEMORY); 1074*3446Smrj } 1075*3446Smrj 1076*3446Smrj /* Copy the object and possible subobjects */ 1077*3446Smrj 1078*3446Smrj if (ACPI_GET_OBJECT_TYPE (SourceDesc) == ACPI_TYPE_PACKAGE) 1079*3446Smrj { 1080*3446Smrj Status = AcpiUtCopyIpackageToIpackage (SourceDesc, *DestDesc, 1081*3446Smrj WalkState); 1082*3446Smrj } 1083*3446Smrj else 1084*3446Smrj { 1085*3446Smrj Status = AcpiUtCopySimpleObject (SourceDesc, *DestDesc); 1086*3446Smrj } 1087*3446Smrj 1088*3446Smrj return_ACPI_STATUS (Status); 1089*3446Smrj } 1090*3446Smrj 1091*3446Smrj 1092