1 /******************************************************************************
3 * Module Name: utcopy - Internal to external object translation utilities
6 *****************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
13 * All rights reserved.
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
38 * The above copyright and patent license is granted only if the following
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
73 * 3.4. Intel retains all right, title, and interest in and to the Original
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
81 * 4. Disclaimer and Export Compliance
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
115 *****************************************************************************/
116 /* $DragonFly: src/sys/contrib/dev/acpica/Attic/utcopy.c,v 1.1 2003/09/24 03:32:16 drhodus Exp $ */
124 #define _COMPONENT ACPI_UTILITIES
125 ACPI_MODULE_NAME ("utcopy")
128 /*******************************************************************************
130 * FUNCTION: AcpiUtCopyIsimpleToEsimple
132 * PARAMETERS: *InternalObject - Pointer to the object we are examining
133 * *Buffer - Where the object is returned
134 * *SpaceUsed - Where the data length is returned
138 * DESCRIPTION: This function is called to place a simple object in a user
141 * The buffer is assumed to have sufficient space for the object.
143 ******************************************************************************/
146 AcpiUtCopyIsimpleToEsimple (
147 ACPI_OPERAND_OBJECT *InternalObject,
148 ACPI_OBJECT *ExternalObject,
150 ACPI_SIZE *BufferSpaceUsed)
152 ACPI_STATUS Status = AE_OK;
155 ACPI_FUNCTION_TRACE ("UtCopyIsimpleToEsimple");
158 *BufferSpaceUsed = 0;
161 * Check for NULL object case (could be an uninitialized
166 return_ACPI_STATUS (AE_OK);
169 /* Always clear the external object */
171 ACPI_MEMSET (ExternalObject, 0, sizeof (ACPI_OBJECT));
174 * In general, the external object will be the same type as
175 * the internal object
177 ExternalObject->Type = ACPI_GET_OBJECT_TYPE (InternalObject);
179 /* However, only a limited number of external types are supported */
181 switch (ACPI_GET_OBJECT_TYPE (InternalObject))
183 case ACPI_TYPE_STRING:
185 ExternalObject->String.Pointer = (char *) DataSpace;
186 ExternalObject->String.Length = InternalObject->String.Length;
187 *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD ((ACPI_SIZE) InternalObject->String.Length + 1);
189 ACPI_MEMCPY ((void *) DataSpace, (void *) InternalObject->String.Pointer,
190 (ACPI_SIZE) InternalObject->String.Length + 1);
194 case ACPI_TYPE_BUFFER:
196 ExternalObject->Buffer.Pointer = DataSpace;
197 ExternalObject->Buffer.Length = InternalObject->Buffer.Length;
198 *BufferSpaceUsed = ACPI_ROUND_UP_TO_NATIVE_WORD (InternalObject->String.Length);
200 ACPI_MEMCPY ((void *) DataSpace, (void *) InternalObject->Buffer.Pointer,
201 InternalObject->Buffer.Length);
205 case ACPI_TYPE_INTEGER:
207 ExternalObject->Integer.Value = InternalObject->Integer.Value;
211 case ACPI_TYPE_LOCAL_REFERENCE:
214 * This is an object reference. Attempt to dereference it.
216 switch (InternalObject->Reference.Opcode)
218 case AML_INT_NAMEPATH_OP:
220 /* For namepath, return the object handle ("reference") */
224 * Use the object type of "Any" to indicate a reference
225 * to object containing a handle to an ACPI named object.
227 ExternalObject->Type = ACPI_TYPE_ANY;
228 ExternalObject->Reference.Handle = InternalObject->Reference.Node;
234 case ACPI_TYPE_PROCESSOR:
236 ExternalObject->Processor.ProcId = InternalObject->Processor.ProcId;
237 ExternalObject->Processor.PblkAddress = InternalObject->Processor.Address;
238 ExternalObject->Processor.PblkLength = InternalObject->Processor.Length;
242 case ACPI_TYPE_POWER:
244 ExternalObject->PowerResource.SystemLevel =
245 InternalObject->PowerResource.SystemLevel;
247 ExternalObject->PowerResource.ResourceOrder =
248 InternalObject->PowerResource.ResourceOrder;
254 * There is no corresponding external object type
256 return_ACPI_STATUS (AE_SUPPORT);
259 return_ACPI_STATUS (Status);
263 /*******************************************************************************
265 * FUNCTION: AcpiUtCopyIelementToEelement
267 * PARAMETERS: ACPI_PKG_CALLBACK
271 * DESCRIPTION: Copy one package element to another package element
273 ******************************************************************************/
276 AcpiUtCopyIelementToEelement (
278 ACPI_OPERAND_OBJECT *SourceObject,
279 ACPI_GENERIC_STATE *State,
282 ACPI_STATUS Status = AE_OK;
283 ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context;
284 ACPI_SIZE ObjectSpace;
286 ACPI_OBJECT *TargetObject;
289 ACPI_FUNCTION_ENTRY ();
292 ThisIndex = State->Pkg.Index;
293 TargetObject = (ACPI_OBJECT *)
294 &((ACPI_OBJECT *)(State->Pkg.DestObject))->Package.Elements[ThisIndex];
298 case ACPI_COPY_TYPE_SIMPLE:
301 * This is a simple or null object
303 Status = AcpiUtCopyIsimpleToEsimple (SourceObject,
304 TargetObject, Info->FreeSpace, &ObjectSpace);
305 if (ACPI_FAILURE (Status))
312 case ACPI_COPY_TYPE_PACKAGE:
315 * Build the package object
317 TargetObject->Type = ACPI_TYPE_PACKAGE;
318 TargetObject->Package.Count = SourceObject->Package.Count;
319 TargetObject->Package.Elements = ACPI_CAST_PTR (ACPI_OBJECT, Info->FreeSpace);
322 * Pass the new package object back to the package walk routine
324 State->Pkg.ThisTargetObj = TargetObject;
327 * Save space for the array of objects (Package elements)
328 * update the buffer length counter
330 ObjectSpace = ACPI_ROUND_UP_TO_NATIVE_WORD (
331 (ACPI_SIZE) TargetObject->Package.Count * sizeof (ACPI_OBJECT));
336 return (AE_BAD_PARAMETER);
339 Info->FreeSpace += ObjectSpace;
340 Info->Length += ObjectSpace;
345 /*******************************************************************************
347 * FUNCTION: AcpiUtCopyIpackageToEpackage
349 * PARAMETERS: *InternalObject - Pointer to the object we are returning
350 * *Buffer - Where the object is returned
351 * *SpaceUsed - Where the object length is returned
355 * DESCRIPTION: This function is called to place a package object in a user
356 * buffer. A package object by definition contains other objects.
358 * The buffer is assumed to have sufficient space for the object.
359 * The caller must have verified the buffer length needed using the
360 * AcpiUtGetObjectSize function before calling this function.
362 ******************************************************************************/
365 AcpiUtCopyIpackageToEpackage (
366 ACPI_OPERAND_OBJECT *InternalObject,
368 ACPI_SIZE *SpaceUsed)
370 ACPI_OBJECT *ExternalObject;
375 ACPI_FUNCTION_TRACE ("UtCopyIpackageToEpackage");
379 * First package at head of the buffer
381 ExternalObject = ACPI_CAST_PTR (ACPI_OBJECT, Buffer);
384 * Free space begins right after the first package
386 Info.Length = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
387 Info.FreeSpace = Buffer + ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
388 Info.ObjectSpace = 0;
389 Info.NumPackages = 1;
391 ExternalObject->Type = ACPI_GET_OBJECT_TYPE (InternalObject);
392 ExternalObject->Package.Count = InternalObject->Package.Count;
393 ExternalObject->Package.Elements = ACPI_CAST_PTR (ACPI_OBJECT, Info.FreeSpace);
396 * Leave room for an array of ACPI_OBJECTS in the buffer
397 * and move the free space past it
399 Info.Length += (ACPI_SIZE) ExternalObject->Package.Count *
400 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
401 Info.FreeSpace += ExternalObject->Package.Count *
402 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT));
404 Status = AcpiUtWalkPackageTree (InternalObject, ExternalObject,
405 AcpiUtCopyIelementToEelement, &Info);
407 *SpaceUsed = Info.Length;
408 return_ACPI_STATUS (Status);
412 /*******************************************************************************
414 * FUNCTION: AcpiUtCopyIobjectToEobject
416 * PARAMETERS: *InternalObject - The internal object to be converted
417 * *BufferPtr - Where the object is returned
421 * DESCRIPTION: This function is called to build an API object to be returned to
424 ******************************************************************************/
427 AcpiUtCopyIobjectToEobject (
428 ACPI_OPERAND_OBJECT *InternalObject,
429 ACPI_BUFFER *RetBuffer)
434 ACPI_FUNCTION_TRACE ("UtCopyIobjectToEobject");
437 if (ACPI_GET_OBJECT_TYPE (InternalObject) == ACPI_TYPE_PACKAGE)
440 * Package object: Copy all subobjects (including
443 Status = AcpiUtCopyIpackageToEpackage (InternalObject,
444 RetBuffer->Pointer, &RetBuffer->Length);
449 * Build a simple object (no nested objects)
451 Status = AcpiUtCopyIsimpleToEsimple (InternalObject,
452 (ACPI_OBJECT *) RetBuffer->Pointer,
453 ((UINT8 *) RetBuffer->Pointer +
454 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT))),
457 * build simple does not include the object size in the length
458 * so we add it in here
460 RetBuffer->Length += sizeof (ACPI_OBJECT);
463 return_ACPI_STATUS (Status);
467 /*******************************************************************************
469 * FUNCTION: AcpiUtCopyEsimpleToIsimple
471 * PARAMETERS: *ExternalObject - The external object to be converted
472 * *InternalObject - Where the internal object is returned
476 * DESCRIPTION: This function copies an external object to an internal one.
477 * NOTE: Pointers can be copied, we don't need to copy data.
478 * (The pointers have to be valid in our address space no matter
479 * what we do with them!)
481 ******************************************************************************/
484 AcpiUtCopyEsimpleToIsimple (
485 ACPI_OBJECT *ExternalObject,
486 ACPI_OPERAND_OBJECT **RetInternalObject)
488 ACPI_OPERAND_OBJECT *InternalObject;
491 ACPI_FUNCTION_TRACE ("UtCopyEsimpleToIsimple");
495 * Simple types supported are: String, Buffer, Integer
497 switch (ExternalObject->Type)
499 case ACPI_TYPE_STRING:
500 case ACPI_TYPE_BUFFER:
501 case ACPI_TYPE_INTEGER:
503 InternalObject = AcpiUtCreateInternalObject ((UINT8) ExternalObject->Type);
506 return_ACPI_STATUS (AE_NO_MEMORY);
512 * Whatever other type -- it is not supported
514 return_ACPI_STATUS (AE_SUPPORT);
518 switch (ExternalObject->Type)
521 /* Must COPY string and buffer contents */
523 case ACPI_TYPE_STRING:
525 InternalObject->String.Pointer =
526 ACPI_MEM_CALLOCATE ((ACPI_SIZE) ExternalObject->String.Length + 1);
527 if (!InternalObject->String.Pointer)
529 return_ACPI_STATUS (AE_NO_MEMORY);
532 ACPI_MEMCPY (InternalObject->String.Pointer,
533 ExternalObject->String.Pointer,
534 ExternalObject->String.Length);
536 InternalObject->String.Length = ExternalObject->String.Length;
540 case ACPI_TYPE_BUFFER:
542 InternalObject->Buffer.Pointer =
543 ACPI_MEM_CALLOCATE (ExternalObject->Buffer.Length);
544 if (!InternalObject->Buffer.Pointer)
546 return_ACPI_STATUS (AE_NO_MEMORY);
549 ACPI_MEMCPY (InternalObject->Buffer.Pointer,
550 ExternalObject->Buffer.Pointer,
551 ExternalObject->Buffer.Length);
553 InternalObject->Buffer.Length = ExternalObject->Buffer.Length;
557 case ACPI_TYPE_INTEGER:
559 InternalObject->Integer.Value = ExternalObject->Integer.Value;
563 /* Other types can't get here */
567 *RetInternalObject = InternalObject;
568 return_ACPI_STATUS (AE_OK);
572 #ifdef ACPI_FUTURE_IMPLEMENTATION
574 /* Code to convert packages that are parameters to control methods */
576 /*******************************************************************************
578 * FUNCTION: AcpiUtCopyEpackageToIpackage
580 * PARAMETERS: *InternalObject - Pointer to the object we are returning
581 * *Buffer - Where the object is returned
582 * *SpaceUsed - Where the length of the object is returned
586 * DESCRIPTION: This function is called to place a package object in a user
587 * buffer. A package object by definition contains other objects.
589 * The buffer is assumed to have sufficient space for the object.
590 * The caller must have verified the buffer length needed using the
591 * AcpiUtGetObjectSize function before calling this function.
593 ******************************************************************************/
596 AcpiUtCopyEpackageToIpackage (
597 ACPI_OPERAND_OBJECT *InternalObject,
602 ACPI_OBJECT *ExternalObject;
605 UINT32 ObjectSpace = 0;
606 ACPI_OPERAND_OBJECT *ThisInternalObj;
607 ACPI_OBJECT *ThisExternalObj;
610 ACPI_FUNCTION_TRACE ("UtCopyEpackageToIpackage");
614 * First package at head of the buffer
616 ExternalObject = (ACPI_OBJECT *)Buffer;
619 * Free space begins right after the first package
621 FreeSpace = Buffer + sizeof(ACPI_OBJECT);
624 ExternalObject->Type = ACPI_GET_OBJECT_TYPE (InternalObject);
625 ExternalObject->Package.Count = InternalObject->Package.Count;
626 ExternalObject->Package.Elements = (ACPI_OBJECT *)FreeSpace;
629 * Build an array of ACPI_OBJECTS in the buffer
630 * and move the free space past it
632 FreeSpace += ExternalObject->Package.Count * sizeof(ACPI_OBJECT);
635 /* Call WalkPackage */
639 #endif /* Future implementation */
642 /*******************************************************************************
644 * FUNCTION: AcpiUtCopyEobjectToIobject
646 * PARAMETERS: *InternalObject - The external object to be converted
647 * *BufferPtr - Where the internal object is returned
649 * RETURN: Status - the status of the call
651 * DESCRIPTION: Converts an external object to an internal object.
653 ******************************************************************************/
656 AcpiUtCopyEobjectToIobject (
657 ACPI_OBJECT *ExternalObject,
658 ACPI_OPERAND_OBJECT **InternalObject)
663 ACPI_FUNCTION_TRACE ("UtCopyEobjectToIobject");
666 if (ExternalObject->Type == ACPI_TYPE_PACKAGE)
669 * Packages as external input to control methods are not supported,
671 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
672 "Packages as parameters not implemented!\n"));
674 return_ACPI_STATUS (AE_NOT_IMPLEMENTED);
680 * Build a simple object (no nested objects)
682 Status = AcpiUtCopyEsimpleToIsimple (ExternalObject, InternalObject);
685 return_ACPI_STATUS (Status);
689 /*******************************************************************************
691 * FUNCTION: AcpiUtCopySimpleObject
693 * PARAMETERS: SourceDesc - The internal object to be copied
694 * DestDesc - New target object
698 * DESCRIPTION: Simple copy of one internal object to another. Reference count
699 * of the destination object is preserved.
701 ******************************************************************************/
704 AcpiUtCopySimpleObject (
705 ACPI_OPERAND_OBJECT *SourceDesc,
706 ACPI_OPERAND_OBJECT *DestDesc)
708 UINT16 ReferenceCount;
709 ACPI_OPERAND_OBJECT *NextObject;
712 /* Save fields from destination that we don't want to overwrite */
714 ReferenceCount = DestDesc->Common.ReferenceCount;
715 NextObject = DestDesc->Common.NextObject;
717 /* Copy the entire source object over the destination object*/
719 ACPI_MEMCPY ((char *) DestDesc, (char *) SourceDesc,
720 sizeof (ACPI_OPERAND_OBJECT));
722 /* Restore the saved fields */
724 DestDesc->Common.ReferenceCount = ReferenceCount;
725 DestDesc->Common.NextObject = NextObject;
727 /* Handle the objects with extra data */
729 switch (ACPI_GET_OBJECT_TYPE (DestDesc))
731 case ACPI_TYPE_BUFFER:
733 DestDesc->Buffer.Node = NULL;
734 DestDesc->Common.Flags = SourceDesc->Common.Flags;
737 * Allocate and copy the actual buffer if and only if:
738 * 1) There is a valid buffer pointer
739 * 2) The buffer is not static (not in an ACPI table) (in this case,
740 * the actual pointer was already copied above)
742 if ((SourceDesc->Buffer.Pointer) &&
743 (!(SourceDesc->Common.Flags & AOPOBJ_STATIC_POINTER)))
745 DestDesc->Buffer.Pointer = ACPI_MEM_ALLOCATE (SourceDesc->Buffer.Length);
746 if (!DestDesc->Buffer.Pointer)
748 return (AE_NO_MEMORY);
751 ACPI_MEMCPY (DestDesc->Buffer.Pointer, SourceDesc->Buffer.Pointer,
752 SourceDesc->Buffer.Length);
756 case ACPI_TYPE_STRING:
759 * Allocate and copy the actual string if and only if:
760 * 1) There is a valid string pointer
761 * 2) The string is not static (not in an ACPI table) (in this case,
762 * the actual pointer was already copied above)
764 if ((SourceDesc->String.Pointer) &&
765 (!(SourceDesc->Common.Flags & AOPOBJ_STATIC_POINTER)))
767 DestDesc->String.Pointer = ACPI_MEM_ALLOCATE ((ACPI_SIZE) SourceDesc->String.Length + 1);
768 if (!DestDesc->String.Pointer)
770 return (AE_NO_MEMORY);
773 ACPI_MEMCPY (DestDesc->String.Pointer, SourceDesc->String.Pointer,
774 (ACPI_SIZE) SourceDesc->String.Length + 1);
779 /* Nothing to do for other simple objects */
787 /*******************************************************************************
789 * FUNCTION: AcpiUtCopyIelementToIelement
791 * PARAMETERS: ACPI_PKG_CALLBACK
795 * DESCRIPTION: Copy one package element to another package element
797 ******************************************************************************/
800 AcpiUtCopyIelementToIelement (
802 ACPI_OPERAND_OBJECT *SourceObject,
803 ACPI_GENERIC_STATE *State,
806 ACPI_STATUS Status = AE_OK;
808 ACPI_OPERAND_OBJECT **ThisTargetPtr;
809 ACPI_OPERAND_OBJECT *TargetObject;
812 ACPI_FUNCTION_ENTRY ();
815 ThisIndex = State->Pkg.Index;
816 ThisTargetPtr = (ACPI_OPERAND_OBJECT **)
817 &State->Pkg.DestObject->Package.Elements[ThisIndex];
821 case ACPI_COPY_TYPE_SIMPLE:
823 /* A null source object indicates a (legal) null package element */
828 * This is a simple object, just copy it
830 TargetObject = AcpiUtCreateInternalObject (
831 ACPI_GET_OBJECT_TYPE (SourceObject));
834 return (AE_NO_MEMORY);
837 Status = AcpiUtCopySimpleObject (SourceObject, TargetObject);
838 if (ACPI_FAILURE (Status))
843 *ThisTargetPtr = TargetObject;
847 /* Pass through a null element */
849 *ThisTargetPtr = NULL;
854 case ACPI_COPY_TYPE_PACKAGE:
857 * This object is a package - go down another nesting level
858 * Create and build the package object
860 TargetObject = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE);
863 return (AE_NO_MEMORY);
866 TargetObject->Package.Count = SourceObject->Package.Count;
867 TargetObject->Common.Flags = SourceObject->Common.Flags;
870 * Create the object array
872 TargetObject->Package.Elements =
873 ACPI_MEM_CALLOCATE (((ACPI_SIZE) SourceObject->Package.Count + 1) *
875 if (!TargetObject->Package.Elements)
877 ACPI_MEM_FREE (TargetObject);
878 return (AE_NO_MEMORY);
882 * Pass the new package object back to the package walk routine
884 State->Pkg.ThisTargetObj = TargetObject;
887 * Store the object pointer in the parent package object
889 *ThisTargetPtr = TargetObject;
894 return (AE_BAD_PARAMETER);
901 /*******************************************************************************
903 * FUNCTION: AcpiUtCopyIpackageToIpackage
905 * PARAMETERS: *SourceObj - Pointer to the source package object
906 * *DestObj - Where the internal object is returned
908 * RETURN: Status - the status of the call
910 * DESCRIPTION: This function is called to copy an internal package object
911 * into another internal package object.
913 ******************************************************************************/
916 AcpiUtCopyIpackageToIpackage (
917 ACPI_OPERAND_OBJECT *SourceObj,
918 ACPI_OPERAND_OBJECT *DestObj,
919 ACPI_WALK_STATE *WalkState)
921 ACPI_STATUS Status = AE_OK;
924 ACPI_FUNCTION_TRACE ("UtCopyIpackageToIpackage");
927 DestObj->Common.Type = ACPI_GET_OBJECT_TYPE (SourceObj);
928 DestObj->Common.Flags = SourceObj->Common.Flags;
929 DestObj->Package.Count = SourceObj->Package.Count;
932 * Create the object array and walk the source package tree
934 DestObj->Package.Elements = ACPI_MEM_CALLOCATE (
935 ((ACPI_SIZE) SourceObj->Package.Count + 1) *
937 if (!DestObj->Package.Elements)
940 ("AmlBuildCopyInternalPackageObject: Package allocation failure\n"));
941 return_ACPI_STATUS (AE_NO_MEMORY);
945 * Copy the package element-by-element by walking the package "tree".
946 * This handles nested packages of arbitrary depth.
948 Status = AcpiUtWalkPackageTree (SourceObj, DestObj,
949 AcpiUtCopyIelementToIelement, WalkState);
950 if (ACPI_FAILURE (Status))
952 /* On failure, delete the destination package object */
954 AcpiUtRemoveReference (DestObj);
957 return_ACPI_STATUS (Status);
961 /*******************************************************************************
963 * FUNCTION: AcpiUtCopyIobjectToIobject
965 * PARAMETERS: WalkState - Current walk state
966 * SourceDesc - The internal object to be copied
967 * DestDesc - Where the copied object is returned
971 * DESCRIPTION: Copy an internal object to a new internal object
973 ******************************************************************************/
976 AcpiUtCopyIobjectToIobject (
977 ACPI_OPERAND_OBJECT *SourceDesc,
978 ACPI_OPERAND_OBJECT **DestDesc,
979 ACPI_WALK_STATE *WalkState)
981 ACPI_STATUS Status = AE_OK;
984 ACPI_FUNCTION_TRACE ("UtCopyIobjectToIobject");
987 /* Create the top level object */
989 *DestDesc = AcpiUtCreateInternalObject (ACPI_GET_OBJECT_TYPE (SourceDesc));
992 return_ACPI_STATUS (AE_NO_MEMORY);
995 /* Copy the object and possible subobjects */
997 if (ACPI_GET_OBJECT_TYPE (SourceDesc) == ACPI_TYPE_PACKAGE)
999 Status = AcpiUtCopyIpackageToIpackage (SourceDesc, *DestDesc,
1004 Status = AcpiUtCopySimpleObject (SourceDesc, *DestDesc);
1007 return_ACPI_STATUS (Status);