167754Smsmith/****************************************************************************** 267754Smsmith * 377424Smsmith * Module Name: utcopy - Internal to external object translation utilities 467754Smsmith * 567754Smsmith *****************************************************************************/ 667754Smsmith 7217365Sjkim/* 8306536Sjkim * Copyright (C) 2000 - 2016, Intel Corp. 970243Smsmith * All rights reserved. 1067754Smsmith * 11217365Sjkim * Redistribution and use in source and binary forms, with or without 12217365Sjkim * modification, are permitted provided that the following conditions 13217365Sjkim * are met: 14217365Sjkim * 1. Redistributions of source code must retain the above copyright 15217365Sjkim * notice, this list of conditions, and the following disclaimer, 16217365Sjkim * without modification. 17217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18217365Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 19217365Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 20217365Sjkim * including a substantially similar Disclaimer requirement for further 21217365Sjkim * binary redistribution. 22217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 23217365Sjkim * of any contributors may be used to endorse or promote products derived 24217365Sjkim * from this software without specific prior written permission. 2567754Smsmith * 26217365Sjkim * Alternatively, this software may be distributed under the terms of the 27217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 28217365Sjkim * Software Foundation. 2967754Smsmith * 30217365Sjkim * NO WARRANTY 31217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41217365Sjkim * POSSIBILITY OF SUCH DAMAGES. 42217365Sjkim */ 4367754Smsmith 44193341Sjkim#include <contrib/dev/acpica/include/acpi.h> 45193341Sjkim#include <contrib/dev/acpica/include/accommon.h> 46193341Sjkim#include <contrib/dev/acpica/include/acnamesp.h> 4767754Smsmith 4867754Smsmith 4977424Smsmith#define _COMPONENT ACPI_UTILITIES 5091116Smsmith ACPI_MODULE_NAME ("utcopy") 5167754Smsmith 52151937Sjkim/* Local prototypes */ 5367754Smsmith 54151937Sjkimstatic ACPI_STATUS 55151937SjkimAcpiUtCopyIsimpleToEsimple ( 56151937Sjkim ACPI_OPERAND_OBJECT *InternalObject, 57151937Sjkim ACPI_OBJECT *ExternalObject, 58151937Sjkim UINT8 *DataSpace, 59151937Sjkim ACPI_SIZE *BufferSpaceUsed); 60151937Sjkim 61151937Sjkimstatic ACPI_STATUS 62151937SjkimAcpiUtCopyIelementToIelement ( 63151937Sjkim UINT8 ObjectType, 64151937Sjkim ACPI_OPERAND_OBJECT *SourceObject, 65151937Sjkim ACPI_GENERIC_STATE *State, 66151937Sjkim void *Context); 67151937Sjkim 68151937Sjkimstatic ACPI_STATUS 69151937SjkimAcpiUtCopyIpackageToEpackage ( 70151937Sjkim ACPI_OPERAND_OBJECT *InternalObject, 71151937Sjkim UINT8 *Buffer, 72151937Sjkim ACPI_SIZE *SpaceUsed); 73151937Sjkim 74151937Sjkimstatic ACPI_STATUS 75151937SjkimAcpiUtCopyEsimpleToIsimple( 76151937Sjkim ACPI_OBJECT *UserObj, 77151937Sjkim ACPI_OPERAND_OBJECT **ReturnObj); 78151937Sjkim 79151937Sjkimstatic ACPI_STATUS 80193267SjkimAcpiUtCopyEpackageToIpackage ( 81193267Sjkim ACPI_OBJECT *ExternalObject, 82193267Sjkim ACPI_OPERAND_OBJECT **InternalObject); 83193267Sjkim 84193267Sjkimstatic ACPI_STATUS 85151937SjkimAcpiUtCopySimpleObject ( 86151937Sjkim ACPI_OPERAND_OBJECT *SourceDesc, 87151937Sjkim ACPI_OPERAND_OBJECT *DestDesc); 88151937Sjkim 89151937Sjkimstatic ACPI_STATUS 90151937SjkimAcpiUtCopyIelementToEelement ( 91151937Sjkim UINT8 ObjectType, 92151937Sjkim ACPI_OPERAND_OBJECT *SourceObject, 93151937Sjkim ACPI_GENERIC_STATE *State, 94151937Sjkim void *Context); 95151937Sjkim 96151937Sjkimstatic ACPI_STATUS 97151937SjkimAcpiUtCopyIpackageToIpackage ( 98151937Sjkim ACPI_OPERAND_OBJECT *SourceObj, 99151937Sjkim ACPI_OPERAND_OBJECT *DestObj, 100151937Sjkim ACPI_WALK_STATE *WalkState); 101151937Sjkim 102151937Sjkim 10373561Smsmith/******************************************************************************* 10467754Smsmith * 10577424Smsmith * FUNCTION: AcpiUtCopyIsimpleToEsimple 10667754Smsmith * 107151937Sjkim * PARAMETERS: InternalObject - Source object to be copied 108151937Sjkim * ExternalObject - Where to return the copied object 109151937Sjkim * DataSpace - Where object data is returned (such as 110151937Sjkim * buffer and string data) 111151937Sjkim * BufferSpaceUsed - Length of DataSpace that was used 11267754Smsmith * 11373561Smsmith * RETURN: Status 11467754Smsmith * 115151937Sjkim * DESCRIPTION: This function is called to copy a simple internal object to 116151937Sjkim * an external object. 11767754Smsmith * 118151937Sjkim * The DataSpace buffer is assumed to have sufficient space for 119151937Sjkim * the object. 12067754Smsmith * 12167754Smsmith ******************************************************************************/ 12267754Smsmith 12369450Smsmithstatic ACPI_STATUS 12477424SmsmithAcpiUtCopyIsimpleToEsimple ( 12573561Smsmith ACPI_OPERAND_OBJECT *InternalObject, 12673561Smsmith ACPI_OBJECT *ExternalObject, 12767754Smsmith UINT8 *DataSpace, 12891116Smsmith ACPI_SIZE *BufferSpaceUsed) 12967754Smsmith{ 13073561Smsmith ACPI_STATUS Status = AE_OK; 13167754Smsmith 13267754Smsmith 133167802Sjkim ACPI_FUNCTION_TRACE (UtCopyIsimpleToEsimple); 13467754Smsmith 13567754Smsmith 13691116Smsmith *BufferSpaceUsed = 0; 13791116Smsmith 13867754Smsmith /* 13967754Smsmith * Check for NULL object case (could be an uninitialized 14099679Siwasaki * package element) 14167754Smsmith */ 14273561Smsmith if (!InternalObject) 14367754Smsmith { 14467754Smsmith return_ACPI_STATUS (AE_OK); 14567754Smsmith } 14667754Smsmith 14767754Smsmith /* Always clear the external object */ 14867754Smsmith 149306536Sjkim memset (ExternalObject, 0, sizeof (ACPI_OBJECT)); 15067754Smsmith 15167754Smsmith /* 15267754Smsmith * In general, the external object will be the same type as 15367754Smsmith * the internal object 15467754Smsmith */ 155193267Sjkim ExternalObject->Type = InternalObject->Common.Type; 15667754Smsmith 15767754Smsmith /* However, only a limited number of external types are supported */ 15867754Smsmith 159193267Sjkim switch (InternalObject->Common.Type) 16067754Smsmith { 16167754Smsmith case ACPI_TYPE_STRING: 16267754Smsmith 163114237Snjl ExternalObject->String.Pointer = (char *) DataSpace; 16491116Smsmith ExternalObject->String.Length = InternalObject->String.Length; 165151937Sjkim *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD ( 166306536Sjkim (ACPI_SIZE) InternalObject->String.Length + 1); 16791116Smsmith 168306536Sjkim memcpy ((void *) DataSpace, 169151937Sjkim (void *) InternalObject->String.Pointer, 170151937Sjkim (ACPI_SIZE) InternalObject->String.Length + 1); 17167754Smsmith break; 17267754Smsmith 17367754Smsmith case ACPI_TYPE_BUFFER: 17467754Smsmith 17573561Smsmith ExternalObject->Buffer.Pointer = DataSpace; 17691116Smsmith ExternalObject->Buffer.Length = InternalObject->Buffer.Length; 177151937Sjkim *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD ( 178306536Sjkim InternalObject->String.Length); 17991116Smsmith 180306536Sjkim memcpy ((void *) DataSpace, 181151937Sjkim (void *) InternalObject->Buffer.Pointer, 182151937Sjkim InternalObject->Buffer.Length); 18367754Smsmith break; 18467754Smsmith 18571867Smsmith case ACPI_TYPE_INTEGER: 18667754Smsmith 18791116Smsmith ExternalObject->Integer.Value = InternalObject->Integer.Value; 18867754Smsmith break; 18967754Smsmith 190107325Siwasaki case ACPI_TYPE_LOCAL_REFERENCE: 19167754Smsmith 192193267Sjkim /* This is an object reference. */ 193193267Sjkim 194193267Sjkim switch (InternalObject->Reference.Class) 19573561Smsmith { 196193267Sjkim case ACPI_REFCLASS_NAME: 19777424Smsmith /* 198193267Sjkim * For namepath, return the object handle ("reference") 199193267Sjkim * We are referring to the namespace node 20077424Smsmith */ 201193267Sjkim ExternalObject->Reference.Handle = 202193267Sjkim InternalObject->Reference.Node; 203193267Sjkim ExternalObject->Reference.ActualType = 204193267Sjkim AcpiNsGetType (InternalObject->Reference.Node); 20573561Smsmith break; 206193267Sjkim 207193267Sjkim default: 208193267Sjkim 209193267Sjkim /* All other reference types are unsupported */ 210193267Sjkim 211193267Sjkim return_ACPI_STATUS (AE_TYPE); 21273561Smsmith } 21367754Smsmith break; 21467754Smsmith 21567754Smsmith case ACPI_TYPE_PROCESSOR: 21667754Smsmith 217193267Sjkim ExternalObject->Processor.ProcId = 218193267Sjkim InternalObject->Processor.ProcId; 219193267Sjkim ExternalObject->Processor.PblkAddress = 220193267Sjkim InternalObject->Processor.Address; 221193267Sjkim ExternalObject->Processor.PblkLength = 222193267Sjkim InternalObject->Processor.Length; 22373561Smsmith break; 22467754Smsmith 22567754Smsmith case ACPI_TYPE_POWER: 22667754Smsmith 22777424Smsmith ExternalObject->PowerResource.SystemLevel = 228193267Sjkim InternalObject->PowerResource.SystemLevel; 22967754Smsmith 23073561Smsmith ExternalObject->PowerResource.ResourceOrder = 231193267Sjkim InternalObject->PowerResource.ResourceOrder; 23267754Smsmith break; 23367754Smsmith 23467754Smsmith default: 23573561Smsmith /* 23673561Smsmith * There is no corresponding external object type 23773561Smsmith */ 238193267Sjkim ACPI_ERROR ((AE_INFO, 239193267Sjkim "Unsupported object type, cannot convert to external object: %s", 240193267Sjkim AcpiUtGetTypeName (InternalObject->Common.Type))); 241193267Sjkim 24273561Smsmith return_ACPI_STATUS (AE_SUPPORT); 24367754Smsmith } 24467754Smsmith 24573561Smsmith return_ACPI_STATUS (Status); 24673561Smsmith} 24773561Smsmith 24873561Smsmith 24973561Smsmith/******************************************************************************* 25073561Smsmith * 25177424Smsmith * FUNCTION: AcpiUtCopyIelementToEelement 25273561Smsmith * 25373561Smsmith * PARAMETERS: ACPI_PKG_CALLBACK 25473561Smsmith * 25573561Smsmith * RETURN: Status 25673561Smsmith * 25773561Smsmith * DESCRIPTION: Copy one package element to another package element 25873561Smsmith * 25973561Smsmith ******************************************************************************/ 26073561Smsmith 261151937Sjkimstatic ACPI_STATUS 26277424SmsmithAcpiUtCopyIelementToEelement ( 26373561Smsmith UINT8 ObjectType, 26473561Smsmith ACPI_OPERAND_OBJECT *SourceObject, 26573561Smsmith ACPI_GENERIC_STATE *State, 26673561Smsmith void *Context) 26773561Smsmith{ 26873561Smsmith ACPI_STATUS Status = AE_OK; 26973561Smsmith ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context; 27091116Smsmith ACPI_SIZE ObjectSpace; 27173561Smsmith UINT32 ThisIndex; 27273561Smsmith ACPI_OBJECT *TargetObject; 27373561Smsmith 27473561Smsmith 27591116Smsmith ACPI_FUNCTION_ENTRY (); 27683174Smsmith 27783174Smsmith 278306536Sjkim ThisIndex = State->Pkg.Index; 279306536Sjkim TargetObject = (ACPI_OBJECT *) &((ACPI_OBJECT *) 280306536Sjkim (State->Pkg.DestObject))->Package.Elements[ThisIndex]; 28173561Smsmith 28273561Smsmith switch (ObjectType) 28367754Smsmith { 28477424Smsmith case ACPI_COPY_TYPE_SIMPLE: 28567754Smsmith /* 28687031Smsmith * This is a simple or null object 28767754Smsmith */ 28877424Smsmith Status = AcpiUtCopyIsimpleToEsimple (SourceObject, 289306536Sjkim TargetObject, Info->FreeSpace, &ObjectSpace); 29073561Smsmith if (ACPI_FAILURE (Status)) 29173561Smsmith { 29273561Smsmith return (Status); 29373561Smsmith } 29473561Smsmith break; 29573561Smsmith 29677424Smsmith case ACPI_COPY_TYPE_PACKAGE: 29773561Smsmith /* 29873561Smsmith * Build the package object 29973561Smsmith */ 300306536Sjkim TargetObject->Type = ACPI_TYPE_PACKAGE; 301306536Sjkim TargetObject->Package.Count = SourceObject->Package.Count; 302306536Sjkim TargetObject->Package.Elements = 303151937Sjkim ACPI_CAST_PTR (ACPI_OBJECT, Info->FreeSpace); 30473561Smsmith 30573561Smsmith /* 30673561Smsmith * Pass the new package object back to the package walk routine 30773561Smsmith */ 30873561Smsmith State->Pkg.ThisTargetObj = TargetObject; 30973561Smsmith 31073561Smsmith /* 31173561Smsmith * Save space for the array of objects (Package elements) 31273561Smsmith * update the buffer length counter 31373561Smsmith */ 31491116Smsmith ObjectSpace = ACPI_ROUND_UP_TO_NATIVE_WORD ( 315306536Sjkim (ACPI_SIZE) TargetObject->Package.Count * 316306536Sjkim sizeof (ACPI_OBJECT)); 31773561Smsmith break; 31873561Smsmith 319250838Sjkim default: 32087031Smsmith 32173561Smsmith return (AE_BAD_PARAMETER); 32267754Smsmith } 32367754Smsmith 324306536Sjkim Info->FreeSpace += ObjectSpace; 325306536Sjkim Info->Length += ObjectSpace; 32673561Smsmith return (Status); 32767754Smsmith} 32867754Smsmith 32967754Smsmith 33073561Smsmith/******************************************************************************* 33167754Smsmith * 33277424Smsmith * FUNCTION: AcpiUtCopyIpackageToEpackage 33367754Smsmith * 334151937Sjkim * PARAMETERS: InternalObject - Pointer to the object we are returning 335151937Sjkim * Buffer - Where the object is returned 336151937Sjkim * SpaceUsed - Where the object length is returned 33767754Smsmith * 33873561Smsmith * RETURN: Status 33967754Smsmith * 34067754Smsmith * DESCRIPTION: This function is called to place a package object in a user 341200553Sjkim * buffer. A package object by definition contains other objects. 34267754Smsmith * 34367754Smsmith * The buffer is assumed to have sufficient space for the object. 344200553Sjkim * The caller must have verified the buffer length needed using 345200553Sjkim * the AcpiUtGetObjectSize function before calling this function. 34667754Smsmith * 34767754Smsmith ******************************************************************************/ 34867754Smsmith 34969450Smsmithstatic ACPI_STATUS 35077424SmsmithAcpiUtCopyIpackageToEpackage ( 35173561Smsmith ACPI_OPERAND_OBJECT *InternalObject, 35267754Smsmith UINT8 *Buffer, 35391116Smsmith ACPI_SIZE *SpaceUsed) 35467754Smsmith{ 35573561Smsmith ACPI_OBJECT *ExternalObject; 35667754Smsmith ACPI_STATUS Status; 35773561Smsmith ACPI_PKG_INFO Info; 35867754Smsmith 35967754Smsmith 360167802Sjkim ACPI_FUNCTION_TRACE (UtCopyIpackageToEpackage); 36167754Smsmith 36267754Smsmith 36367754Smsmith /* 36467754Smsmith * First package at head of the buffer 36567754Smsmith */ 36699679Siwasaki ExternalObject = ACPI_CAST_PTR (ACPI_OBJECT, Buffer); 36767754Smsmith 36867754Smsmith /* 36967754Smsmith * Free space begins right after the first package 37067754Smsmith */ 371306536Sjkim Info.Length = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); 372306536Sjkim Info.FreeSpace = Buffer + 373306536Sjkim ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); 37473561Smsmith Info.ObjectSpace = 0; 37573561Smsmith Info.NumPackages = 1; 37667754Smsmith 377306536Sjkim ExternalObject->Type = InternalObject->Common.Type; 378306536Sjkim ExternalObject->Package.Count = InternalObject->Package.Count; 379306536Sjkim ExternalObject->Package.Elements = 380306536Sjkim ACPI_CAST_PTR (ACPI_OBJECT, Info.FreeSpace); 38167754Smsmith 38267754Smsmith /* 383100966Siwasaki * Leave room for an array of ACPI_OBJECTS in the buffer 38467754Smsmith * and move the free space past it 38567754Smsmith */ 386306536Sjkim Info.Length += (ACPI_SIZE) ExternalObject->Package.Count * 387306536Sjkim ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); 38873561Smsmith Info.FreeSpace += ExternalObject->Package.Count * 389306536Sjkim ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); 39067754Smsmith 39177424Smsmith Status = AcpiUtWalkPackageTree (InternalObject, ExternalObject, 392306536Sjkim AcpiUtCopyIelementToEelement, &Info); 39367754Smsmith 39473561Smsmith *SpaceUsed = Info.Length; 39573561Smsmith return_ACPI_STATUS (Status); 39667754Smsmith} 39767754Smsmith 39887031Smsmith 39973561Smsmith/******************************************************************************* 40067754Smsmith * 40177424Smsmith * FUNCTION: AcpiUtCopyIobjectToEobject 40267754Smsmith * 403151937Sjkim * PARAMETERS: InternalObject - The internal object to be converted 404200553Sjkim * RetBuffer - Where the object is returned 40567754Smsmith * 40677424Smsmith * RETURN: Status 40767754Smsmith * 408200553Sjkim * DESCRIPTION: This function is called to build an API object to be returned 409200553Sjkim * to the caller. 41067754Smsmith * 41167754Smsmith ******************************************************************************/ 41267754Smsmith 41367754SmsmithACPI_STATUS 41477424SmsmithAcpiUtCopyIobjectToEobject ( 41573561Smsmith ACPI_OPERAND_OBJECT *InternalObject, 41667754Smsmith ACPI_BUFFER *RetBuffer) 41767754Smsmith{ 41867754Smsmith ACPI_STATUS Status; 41967754Smsmith 42067754Smsmith 421167802Sjkim ACPI_FUNCTION_TRACE (UtCopyIobjectToEobject); 42267754Smsmith 42367754Smsmith 424193267Sjkim if (InternalObject->Common.Type == ACPI_TYPE_PACKAGE) 42567754Smsmith { 42667754Smsmith /* 42777424Smsmith * Package object: Copy all subobjects (including 42873561Smsmith * nested packages) 42967754Smsmith */ 43077424Smsmith Status = AcpiUtCopyIpackageToEpackage (InternalObject, 431306536Sjkim RetBuffer->Pointer, &RetBuffer->Length); 43267754Smsmith } 43367754Smsmith else 43467754Smsmith { 43567754Smsmith /* 43667754Smsmith * Build a simple object (no nested objects) 43767754Smsmith */ 43877424Smsmith Status = AcpiUtCopyIsimpleToEsimple (InternalObject, 439306536Sjkim ACPI_CAST_PTR (ACPI_OBJECT, RetBuffer->Pointer), 440306536Sjkim ACPI_ADD_PTR (UINT8, RetBuffer->Pointer, 441306536Sjkim ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT))), 442306536Sjkim &RetBuffer->Length); 44367754Smsmith /* 44467754Smsmith * build simple does not include the object size in the length 44567754Smsmith * so we add it in here 44667754Smsmith */ 44767754Smsmith RetBuffer->Length += sizeof (ACPI_OBJECT); 44867754Smsmith } 44967754Smsmith 45067754Smsmith return_ACPI_STATUS (Status); 45167754Smsmith} 45267754Smsmith 45367754Smsmith 45473561Smsmith/******************************************************************************* 45567754Smsmith * 45677424Smsmith * FUNCTION: AcpiUtCopyEsimpleToIsimple 45767754Smsmith * 458151937Sjkim * PARAMETERS: ExternalObject - The external object to be converted 459151937Sjkim * RetInternalObject - Where the internal object is returned 46067754Smsmith * 46173561Smsmith * RETURN: Status 46267754Smsmith * 46367754Smsmith * DESCRIPTION: This function copies an external object to an internal one. 46467754Smsmith * NOTE: Pointers can be copied, we don't need to copy data. 46567754Smsmith * (The pointers have to be valid in our address space no matter 46667754Smsmith * what we do with them!) 46767754Smsmith * 46867754Smsmith ******************************************************************************/ 46967754Smsmith 470151937Sjkimstatic ACPI_STATUS 47177424SmsmithAcpiUtCopyEsimpleToIsimple ( 47273561Smsmith ACPI_OBJECT *ExternalObject, 47384491Smsmith ACPI_OPERAND_OBJECT **RetInternalObject) 47467754Smsmith{ 47584491Smsmith ACPI_OPERAND_OBJECT *InternalObject; 47667754Smsmith 47784491Smsmith 478167802Sjkim ACPI_FUNCTION_TRACE (UtCopyEsimpleToIsimple); 47967754Smsmith 48067754Smsmith 48180062Smsmith /* 48280062Smsmith * Simple types supported are: String, Buffer, Integer 48380062Smsmith */ 48473561Smsmith switch (ExternalObject->Type) 48567754Smsmith { 48684491Smsmith case ACPI_TYPE_STRING: 48784491Smsmith case ACPI_TYPE_BUFFER: 48884491Smsmith case ACPI_TYPE_INTEGER: 489193267Sjkim case ACPI_TYPE_LOCAL_REFERENCE: 49067754Smsmith 491151937Sjkim InternalObject = AcpiUtCreateInternalObject ( 492306536Sjkim (UINT8) ExternalObject->Type); 49384491Smsmith if (!InternalObject) 49484491Smsmith { 49584491Smsmith return_ACPI_STATUS (AE_NO_MEMORY); 49684491Smsmith } 49784491Smsmith break; 49884491Smsmith 499193267Sjkim case ACPI_TYPE_ANY: /* This is the case for a NULL object */ 500193267Sjkim 501193267Sjkim *RetInternalObject = NULL; 502193267Sjkim return_ACPI_STATUS (AE_OK); 503193267Sjkim 50484491Smsmith default: 505250838Sjkim 506138287Smarks /* All other types are not supported */ 507138287Smarks 508193267Sjkim ACPI_ERROR ((AE_INFO, 509193267Sjkim "Unsupported object type, cannot convert to internal object: %s", 510193267Sjkim AcpiUtGetTypeName (ExternalObject->Type))); 511193267Sjkim 51284491Smsmith return_ACPI_STATUS (AE_SUPPORT); 51384491Smsmith } 51484491Smsmith 51584491Smsmith 516138287Smarks /* Must COPY string and buffer contents */ 517138287Smarks 51884491Smsmith switch (ExternalObject->Type) 51984491Smsmith { 52067754Smsmith case ACPI_TYPE_STRING: 52167754Smsmith 522114237Snjl InternalObject->String.Pointer = 523193267Sjkim ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) 524193267Sjkim ExternalObject->String.Length + 1); 525193267Sjkim 52684491Smsmith if (!InternalObject->String.Pointer) 52784491Smsmith { 528138287Smarks goto ErrorExit; 52984491Smsmith } 53084491Smsmith 531306536Sjkim memcpy (InternalObject->String.Pointer, 532306536Sjkim ExternalObject->String.Pointer, 533306536Sjkim ExternalObject->String.Length); 53484491Smsmith 535306536Sjkim InternalObject->String.Length = ExternalObject->String.Length; 53667754Smsmith break; 53767754Smsmith 53867754Smsmith case ACPI_TYPE_BUFFER: 53967754Smsmith 540114237Snjl InternalObject->Buffer.Pointer = 541167802Sjkim ACPI_ALLOCATE_ZEROED (ExternalObject->Buffer.Length); 54284491Smsmith if (!InternalObject->Buffer.Pointer) 54384491Smsmith { 544138287Smarks goto ErrorExit; 54584491Smsmith } 54684491Smsmith 547306536Sjkim memcpy (InternalObject->Buffer.Pointer, 548306536Sjkim ExternalObject->Buffer.Pointer, 549306536Sjkim ExternalObject->Buffer.Length); 55084491Smsmith 551306536Sjkim InternalObject->Buffer.Length = ExternalObject->Buffer.Length; 552193267Sjkim 553193267Sjkim /* Mark buffer data valid */ 554193267Sjkim 555193267Sjkim InternalObject->Buffer.Flags |= AOPOBJ_DATA_VALID; 55667754Smsmith break; 55767754Smsmith 55871867Smsmith case ACPI_TYPE_INTEGER: 55980062Smsmith 560306536Sjkim InternalObject->Integer.Value = ExternalObject->Integer.Value; 56167754Smsmith break; 56299679Siwasaki 563193267Sjkim case ACPI_TYPE_LOCAL_REFERENCE: 564193267Sjkim 565281075Sdim /* An incoming reference is defined to be a namespace node */ 566193267Sjkim 567281075Sdim InternalObject->Reference.Class = ACPI_REFCLASS_REFOF; 568281075Sdim InternalObject->Reference.Object = ExternalObject->Reference.Handle; 569193267Sjkim break; 570193267Sjkim 57199679Siwasaki default: 572250838Sjkim 57399679Siwasaki /* Other types can't get here */ 574250838Sjkim 57599679Siwasaki break; 57667754Smsmith } 57767754Smsmith 57884491Smsmith *RetInternalObject = InternalObject; 57967754Smsmith return_ACPI_STATUS (AE_OK); 580138287Smarks 581138287Smarks 582138287SmarksErrorExit: 583138287Smarks AcpiUtRemoveReference (InternalObject); 584138287Smarks return_ACPI_STATUS (AE_NO_MEMORY); 58567754Smsmith} 58667754Smsmith 58767754Smsmith 58873561Smsmith/******************************************************************************* 58967754Smsmith * 59077424Smsmith * FUNCTION: AcpiUtCopyEpackageToIpackage 59167754Smsmith * 592193267Sjkim * PARAMETERS: ExternalObject - The external object to be converted 593193267Sjkim * InternalObject - Where the internal object is returned 59467754Smsmith * 595114237Snjl * RETURN: Status 59667754Smsmith * 597193267Sjkim * DESCRIPTION: Copy an external package object to an internal package. 598193267Sjkim * Handles nested packages. 59967754Smsmith * 60067754Smsmith ******************************************************************************/ 60167754Smsmith 60269450Smsmithstatic ACPI_STATUS 60377424SmsmithAcpiUtCopyEpackageToIpackage ( 604193267Sjkim ACPI_OBJECT *ExternalObject, 605193267Sjkim ACPI_OPERAND_OBJECT **InternalObject) 60667754Smsmith{ 607193267Sjkim ACPI_STATUS Status = AE_OK; 608193267Sjkim ACPI_OPERAND_OBJECT *PackageObject; 609193267Sjkim ACPI_OPERAND_OBJECT **PackageElements; 610193267Sjkim UINT32 i; 61167754Smsmith 61267754Smsmith 613167802Sjkim ACPI_FUNCTION_TRACE (UtCopyEpackageToIpackage); 61467754Smsmith 61567754Smsmith 616193267Sjkim /* Create the package object */ 61767754Smsmith 618306536Sjkim PackageObject = AcpiUtCreatePackageObject ( 619306536Sjkim ExternalObject->Package.Count); 620193267Sjkim if (!PackageObject) 621193267Sjkim { 622193267Sjkim return_ACPI_STATUS (AE_NO_MEMORY); 623193267Sjkim } 62467754Smsmith 625193267Sjkim PackageElements = PackageObject->Package.Elements; 62667754Smsmith 62767754Smsmith /* 628306536Sjkim * Recursive implementation. Probably ok, since nested external 629306536Sjkim * packages as parameters should be very rare. 63067754Smsmith */ 631193267Sjkim for (i = 0; i < ExternalObject->Package.Count; i++) 632193267Sjkim { 633193267Sjkim Status = AcpiUtCopyEobjectToIobject ( 634306536Sjkim &ExternalObject->Package.Elements[i], 635306536Sjkim &PackageElements[i]); 636193267Sjkim if (ACPI_FAILURE (Status)) 637193267Sjkim { 638193267Sjkim /* Truncate package and delete it */ 63967754Smsmith 640193267Sjkim PackageObject->Package.Count = i; 641193267Sjkim PackageElements[i] = NULL; 642193267Sjkim AcpiUtRemoveReference (PackageObject); 643193267Sjkim return_ACPI_STATUS (Status); 644193267Sjkim } 645193267Sjkim } 64667754Smsmith 647193267Sjkim /* Mark package data valid */ 64867754Smsmith 649193267Sjkim PackageObject->Package.Flags |= AOPOBJ_DATA_VALID; 650193267Sjkim 651193267Sjkim *InternalObject = PackageObject; 652193267Sjkim return_ACPI_STATUS (Status); 65367754Smsmith} 65467754Smsmith 65567754Smsmith 65673561Smsmith/******************************************************************************* 65767754Smsmith * 65877424Smsmith * FUNCTION: AcpiUtCopyEobjectToIobject 65967754Smsmith * 660193267Sjkim * PARAMETERS: ExternalObject - The external object to be converted 661193267Sjkim * InternalObject - Where the internal object is returned 66267754Smsmith * 663200553Sjkim * RETURN: Status 66467754Smsmith * 66567754Smsmith * DESCRIPTION: Converts an external object to an internal object. 66667754Smsmith * 66767754Smsmith ******************************************************************************/ 66867754Smsmith 66967754SmsmithACPI_STATUS 67077424SmsmithAcpiUtCopyEobjectToIobject ( 67173561Smsmith ACPI_OBJECT *ExternalObject, 67284491Smsmith ACPI_OPERAND_OBJECT **InternalObject) 67367754Smsmith{ 67467754Smsmith ACPI_STATUS Status; 67567754Smsmith 67667754Smsmith 677167802Sjkim ACPI_FUNCTION_TRACE (UtCopyEobjectToIobject); 67867754Smsmith 67967754Smsmith 68073561Smsmith if (ExternalObject->Type == ACPI_TYPE_PACKAGE) 68167754Smsmith { 682306536Sjkim Status = AcpiUtCopyEpackageToIpackage ( 683306536Sjkim ExternalObject, InternalObject); 68467754Smsmith } 68567754Smsmith else 68667754Smsmith { 68767754Smsmith /* 68867754Smsmith * Build a simple object (no nested objects) 68967754Smsmith */ 690306536Sjkim Status = AcpiUtCopyEsimpleToIsimple (ExternalObject, 691306536Sjkim InternalObject); 69267754Smsmith } 69367754Smsmith 69467754Smsmith return_ACPI_STATUS (Status); 69567754Smsmith} 69667754Smsmith 69773561Smsmith 69873561Smsmith/******************************************************************************* 69973561Smsmith * 70091116Smsmith * FUNCTION: AcpiUtCopySimpleObject 70191116Smsmith * 70291116Smsmith * PARAMETERS: SourceDesc - The internal object to be copied 70391116Smsmith * DestDesc - New target object 70491116Smsmith * 70591116Smsmith * RETURN: Status 70691116Smsmith * 707200553Sjkim * DESCRIPTION: Simple copy of one internal object to another. Reference count 70891116Smsmith * of the destination object is preserved. 70991116Smsmith * 71091116Smsmith ******************************************************************************/ 71191116Smsmith 712151937Sjkimstatic ACPI_STATUS 71391116SmsmithAcpiUtCopySimpleObject ( 71491116Smsmith ACPI_OPERAND_OBJECT *SourceDesc, 71591116Smsmith ACPI_OPERAND_OBJECT *DestDesc) 71691116Smsmith{ 71791116Smsmith UINT16 ReferenceCount; 71891116Smsmith ACPI_OPERAND_OBJECT *NextObject; 719193267Sjkim ACPI_STATUS Status; 720207344Sjkim ACPI_SIZE CopySize; 72191116Smsmith 72291116Smsmith 72391116Smsmith /* Save fields from destination that we don't want to overwrite */ 72491116Smsmith 72591116Smsmith ReferenceCount = DestDesc->Common.ReferenceCount; 72691116Smsmith NextObject = DestDesc->Common.NextObject; 72791116Smsmith 728207344Sjkim /* 729207344Sjkim * Copy the entire source object over the destination object. 730207344Sjkim * Note: Source can be either an operand object or namespace node. 731207344Sjkim */ 732207344Sjkim CopySize = sizeof (ACPI_OPERAND_OBJECT); 733207344Sjkim if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED) 734207344Sjkim { 735207344Sjkim CopySize = sizeof (ACPI_NAMESPACE_NODE); 736207344Sjkim } 73791116Smsmith 738306536Sjkim memcpy (ACPI_CAST_PTR (char, DestDesc), 739207344Sjkim ACPI_CAST_PTR (char, SourceDesc), CopySize); 74091116Smsmith 74191116Smsmith /* Restore the saved fields */ 74291116Smsmith 74391116Smsmith DestDesc->Common.ReferenceCount = ReferenceCount; 74491116Smsmith DestDesc->Common.NextObject = NextObject; 74591116Smsmith 746151937Sjkim /* New object is not static, regardless of source */ 747151937Sjkim 748151937Sjkim DestDesc->Common.Flags &= ~AOPOBJ_STATIC_POINTER; 749151937Sjkim 75091116Smsmith /* Handle the objects with extra data */ 75191116Smsmith 752193267Sjkim switch (DestDesc->Common.Type) 75391116Smsmith { 75491116Smsmith case ACPI_TYPE_BUFFER: 755114237Snjl /* 756114237Snjl * Allocate and copy the actual buffer if and only if: 757114237Snjl * 1) There is a valid buffer pointer 758151937Sjkim * 2) The buffer has a length > 0 759114237Snjl */ 760114237Snjl if ((SourceDesc->Buffer.Pointer) && 761151937Sjkim (SourceDesc->Buffer.Length)) 762114237Snjl { 763151937Sjkim DestDesc->Buffer.Pointer = 764167802Sjkim ACPI_ALLOCATE (SourceDesc->Buffer.Length); 765151937Sjkim if (!DestDesc->Buffer.Pointer) 766114237Snjl { 767151937Sjkim return (AE_NO_MEMORY); 768151937Sjkim } 769117521Snjl 770151937Sjkim /* Copy the actual buffer data */ 771117521Snjl 772306536Sjkim memcpy (DestDesc->Buffer.Pointer, 773207344Sjkim SourceDesc->Buffer.Pointer, SourceDesc->Buffer.Length); 774114237Snjl } 775114237Snjl break; 776114237Snjl 77791116Smsmith case ACPI_TYPE_STRING: 77891116Smsmith /* 77991116Smsmith * Allocate and copy the actual string if and only if: 780114237Snjl * 1) There is a valid string pointer 781151937Sjkim * (Pointer to a NULL string is allowed) 78291116Smsmith */ 783151937Sjkim if (SourceDesc->String.Pointer) 78491116Smsmith { 785151937Sjkim DestDesc->String.Pointer = 786167802Sjkim ACPI_ALLOCATE ((ACPI_SIZE) SourceDesc->String.Length + 1); 78791116Smsmith if (!DestDesc->String.Pointer) 78891116Smsmith { 78991116Smsmith return (AE_NO_MEMORY); 79091116Smsmith } 79191116Smsmith 792151937Sjkim /* Copy the actual string data */ 793151937Sjkim 794306536Sjkim memcpy (DestDesc->String.Pointer, SourceDesc->String.Pointer, 795207344Sjkim (ACPI_SIZE) SourceDesc->String.Length + 1); 79691116Smsmith } 79791116Smsmith break; 79899679Siwasaki 799151937Sjkim case ACPI_TYPE_LOCAL_REFERENCE: 800151937Sjkim /* 801151937Sjkim * We copied the reference object, so we now must add a reference 802151937Sjkim * to the object pointed to by the reference 803193267Sjkim * 804193267Sjkim * DDBHandle reference (from Load/LoadTable) is a special reference, 805193267Sjkim * it does not have a Reference.Object, so does not need to 806193267Sjkim * increase the reference count 807151937Sjkim */ 808193267Sjkim if (SourceDesc->Reference.Class == ACPI_REFCLASS_TABLE) 809193267Sjkim { 810193267Sjkim break; 811193267Sjkim } 812193267Sjkim 813151937Sjkim AcpiUtAddReference (SourceDesc->Reference.Object); 814151937Sjkim break; 815151937Sjkim 816167802Sjkim case ACPI_TYPE_REGION: 817167802Sjkim /* 818167802Sjkim * We copied the Region Handler, so we now must add a reference 819167802Sjkim */ 820167802Sjkim if (DestDesc->Region.Handler) 821167802Sjkim { 822167802Sjkim AcpiUtAddReference (DestDesc->Region.Handler); 823167802Sjkim } 824167802Sjkim break; 825167802Sjkim 826193267Sjkim /* 827193267Sjkim * For Mutex and Event objects, we cannot simply copy the underlying 828193267Sjkim * OS object. We must create a new one. 829193267Sjkim */ 830193267Sjkim case ACPI_TYPE_MUTEX: 831193267Sjkim 832193267Sjkim Status = AcpiOsCreateMutex (&DestDesc->Mutex.OsMutex); 833193267Sjkim if (ACPI_FAILURE (Status)) 834193267Sjkim { 835193267Sjkim return (Status); 836193267Sjkim } 837193267Sjkim break; 838193267Sjkim 839193267Sjkim case ACPI_TYPE_EVENT: 840193267Sjkim 841193267Sjkim Status = AcpiOsCreateSemaphore (ACPI_NO_UNIT_LIMIT, 0, 842306536Sjkim &DestDesc->Event.OsSemaphore); 843193267Sjkim if (ACPI_FAILURE (Status)) 844193267Sjkim { 845193267Sjkim return (Status); 846193267Sjkim } 847193267Sjkim break; 848193267Sjkim 84999679Siwasaki default: 850250838Sjkim 85199679Siwasaki /* Nothing to do for other simple objects */ 852250838Sjkim 85399679Siwasaki break; 85491116Smsmith } 85591116Smsmith 85691116Smsmith return (AE_OK); 85791116Smsmith} 85891116Smsmith 85991116Smsmith 86091116Smsmith/******************************************************************************* 86191116Smsmith * 86277424Smsmith * FUNCTION: AcpiUtCopyIelementToIelement 86373561Smsmith * 86473561Smsmith * PARAMETERS: ACPI_PKG_CALLBACK 86573561Smsmith * 86691116Smsmith * RETURN: Status 86773561Smsmith * 86873561Smsmith * DESCRIPTION: Copy one package element to another package element 86973561Smsmith * 87073561Smsmith ******************************************************************************/ 87173561Smsmith 872151937Sjkimstatic ACPI_STATUS 87377424SmsmithAcpiUtCopyIelementToIelement ( 87473561Smsmith UINT8 ObjectType, 87573561Smsmith ACPI_OPERAND_OBJECT *SourceObject, 87673561Smsmith ACPI_GENERIC_STATE *State, 87773561Smsmith void *Context) 87873561Smsmith{ 87973561Smsmith ACPI_STATUS Status = AE_OK; 88073561Smsmith UINT32 ThisIndex; 88173561Smsmith ACPI_OPERAND_OBJECT **ThisTargetPtr; 88273561Smsmith ACPI_OPERAND_OBJECT *TargetObject; 88373561Smsmith 88473561Smsmith 88591116Smsmith ACPI_FUNCTION_ENTRY (); 88683174Smsmith 88783174Smsmith 888306536Sjkim ThisIndex = State->Pkg.Index; 88977424Smsmith ThisTargetPtr = (ACPI_OPERAND_OBJECT **) 890306536Sjkim &State->Pkg.DestObject->Package.Elements[ThisIndex]; 89173561Smsmith 89273561Smsmith switch (ObjectType) 89373561Smsmith { 894114237Snjl case ACPI_COPY_TYPE_SIMPLE: 89573561Smsmith 896114237Snjl /* A null source object indicates a (legal) null package element */ 897114237Snjl 898114237Snjl if (SourceObject) 89973561Smsmith { 900114237Snjl /* 901114237Snjl * This is a simple object, just copy it 902114237Snjl */ 903114237Snjl TargetObject = AcpiUtCreateInternalObject ( 904306536Sjkim SourceObject->Common.Type); 905114237Snjl if (!TargetObject) 906114237Snjl { 907114237Snjl return (AE_NO_MEMORY); 908114237Snjl } 909114237Snjl 910114237Snjl Status = AcpiUtCopySimpleObject (SourceObject, TargetObject); 911114237Snjl if (ACPI_FAILURE (Status)) 912114237Snjl { 913138287Smarks goto ErrorExit; 914114237Snjl } 915114237Snjl 916114237Snjl *ThisTargetPtr = TargetObject; 91773561Smsmith } 918114237Snjl else 919114237Snjl { 920114237Snjl /* Pass through a null element */ 92173561Smsmith 922114237Snjl *ThisTargetPtr = NULL; 92373561Smsmith } 92473561Smsmith break; 92573561Smsmith 926114237Snjl case ACPI_COPY_TYPE_PACKAGE: 92773561Smsmith /* 92877424Smsmith * This object is a package - go down another nesting level 92973561Smsmith * Create and build the package object 93073561Smsmith */ 931306536Sjkim TargetObject = AcpiUtCreatePackageObject ( 932306536Sjkim SourceObject->Package.Count); 93373561Smsmith if (!TargetObject) 93473561Smsmith { 93573561Smsmith return (AE_NO_MEMORY); 93673561Smsmith } 93773561Smsmith 938193267Sjkim TargetObject->Common.Flags = SourceObject->Common.Flags; 93973561Smsmith 940193267Sjkim /* Pass the new package object back to the package walk routine */ 941114237Snjl 94273561Smsmith State->Pkg.ThisTargetObj = TargetObject; 94373561Smsmith 944193267Sjkim /* Store the object pointer in the parent package object */ 945193267Sjkim 94673561Smsmith *ThisTargetPtr = TargetObject; 94773561Smsmith break; 94873561Smsmith 949250838Sjkim default: 95087031Smsmith 95173561Smsmith return (AE_BAD_PARAMETER); 95273561Smsmith } 95373561Smsmith 95473561Smsmith return (Status); 955138287Smarks 956138287SmarksErrorExit: 957138287Smarks AcpiUtRemoveReference (TargetObject); 958138287Smarks return (Status); 95973561Smsmith} 96073561Smsmith 96173561Smsmith 96273561Smsmith/******************************************************************************* 96373561Smsmith * 96477424Smsmith * FUNCTION: AcpiUtCopyIpackageToIpackage 96573561Smsmith * 966200553Sjkim * PARAMETERS: SourceObj - Pointer to the source package object 967200553Sjkim * DestObj - Where the internal object is returned 968200553Sjkim * WalkState - Current Walk state descriptor 96973561Smsmith * 970200553Sjkim * RETURN: Status 97173561Smsmith * 97273561Smsmith * DESCRIPTION: This function is called to copy an internal package object 97373561Smsmith * into another internal package object. 97473561Smsmith * 97573561Smsmith ******************************************************************************/ 97673561Smsmith 977151937Sjkimstatic ACPI_STATUS 97877424SmsmithAcpiUtCopyIpackageToIpackage ( 97973561Smsmith ACPI_OPERAND_OBJECT *SourceObj, 98073561Smsmith ACPI_OPERAND_OBJECT *DestObj, 98173561Smsmith ACPI_WALK_STATE *WalkState) 98273561Smsmith{ 98373561Smsmith ACPI_STATUS Status = AE_OK; 98473561Smsmith 98583174Smsmith 986167802Sjkim ACPI_FUNCTION_TRACE (UtCopyIpackageToIpackage); 98773561Smsmith 98873561Smsmith 989306536Sjkim DestObj->Common.Type = SourceObj->Common.Type; 990306536Sjkim DestObj->Common.Flags = SourceObj->Common.Flags; 991306536Sjkim DestObj->Package.Count = SourceObj->Package.Count; 99273561Smsmith 99373561Smsmith /* 99473561Smsmith * Create the object array and walk the source package tree 99573561Smsmith */ 996167802Sjkim DestObj->Package.Elements = ACPI_ALLOCATE_ZEROED ( 997306536Sjkim ((ACPI_SIZE) SourceObj->Package.Count + 1) * 998306536Sjkim sizeof (void *)); 99973561Smsmith if (!DestObj->Package.Elements) 100073561Smsmith { 1001167802Sjkim ACPI_ERROR ((AE_INFO, "Package allocation failure")); 100273561Smsmith return_ACPI_STATUS (AE_NO_MEMORY); 100373561Smsmith } 100473561Smsmith 100587031Smsmith /* 100687031Smsmith * Copy the package element-by-element by walking the package "tree". 100787031Smsmith * This handles nested packages of arbitrary depth. 100887031Smsmith */ 100977424Smsmith Status = AcpiUtWalkPackageTree (SourceObj, DestObj, 1010306536Sjkim AcpiUtCopyIelementToIelement, WalkState); 101187031Smsmith if (ACPI_FAILURE (Status)) 101287031Smsmith { 101387031Smsmith /* On failure, delete the destination package object */ 101473561Smsmith 101587031Smsmith AcpiUtRemoveReference (DestObj); 101687031Smsmith } 101787031Smsmith 101873561Smsmith return_ACPI_STATUS (Status); 101973561Smsmith} 102073561Smsmith 102191116Smsmith 102291116Smsmith/******************************************************************************* 102391116Smsmith * 102491116Smsmith * FUNCTION: AcpiUtCopyIobjectToIobject 102591116Smsmith * 1026200553Sjkim * PARAMETERS: SourceDesc - The internal object to be copied 102791116Smsmith * DestDesc - Where the copied object is returned 1028200553Sjkim * WalkState - Current walk state 102991116Smsmith * 103091116Smsmith * RETURN: Status 103191116Smsmith * 103291116Smsmith * DESCRIPTION: Copy an internal object to a new internal object 103391116Smsmith * 103491116Smsmith ******************************************************************************/ 103591116Smsmith 103691116SmsmithACPI_STATUS 103791116SmsmithAcpiUtCopyIobjectToIobject ( 103891116Smsmith ACPI_OPERAND_OBJECT *SourceDesc, 103991116Smsmith ACPI_OPERAND_OBJECT **DestDesc, 104091116Smsmith ACPI_WALK_STATE *WalkState) 104191116Smsmith{ 104291116Smsmith ACPI_STATUS Status = AE_OK; 104391116Smsmith 104491116Smsmith 1045167802Sjkim ACPI_FUNCTION_TRACE (UtCopyIobjectToIobject); 104691116Smsmith 104791116Smsmith 104891116Smsmith /* Create the top level object */ 104991116Smsmith 1050193267Sjkim *DestDesc = AcpiUtCreateInternalObject (SourceDesc->Common.Type); 105191116Smsmith if (!*DestDesc) 105291116Smsmith { 105391116Smsmith return_ACPI_STATUS (AE_NO_MEMORY); 105491116Smsmith } 105591116Smsmith 105691116Smsmith /* Copy the object and possible subobjects */ 105791116Smsmith 1058193267Sjkim if (SourceDesc->Common.Type == ACPI_TYPE_PACKAGE) 105991116Smsmith { 1060306536Sjkim Status = AcpiUtCopyIpackageToIpackage ( 1061306536Sjkim SourceDesc, *DestDesc, WalkState); 106291116Smsmith } 106391116Smsmith else 106491116Smsmith { 106591116Smsmith Status = AcpiUtCopySimpleObject (SourceDesc, *DestDesc); 106691116Smsmith } 106791116Smsmith 1068281075Sdim /* Delete the allocated object if copy failed */ 1069281075Sdim 1070281075Sdim if (ACPI_FAILURE (Status)) 1071281075Sdim { 1072306536Sjkim AcpiUtRemoveReference (*DestDesc); 1073281075Sdim } 1074281075Sdim 107591116Smsmith return_ACPI_STATUS (Status); 107691116Smsmith} 1077