1 /******************************************************************************
3 * Module Name: utcopy - Internal to external object translation utilities
6 *****************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2005, 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 *****************************************************************************/
123 #define _COMPONENT ACPI_UTILITIES
124 ACPI_MODULE_NAME ("utcopy")
127 /*******************************************************************************
129 * FUNCTION: AcpiUtCopyIsimpleToEsimple
131 * PARAMETERS: *InternalObject - Pointer to the object we are examining
132 * *Buffer - Where the object is returned
133 * *SpaceUsed - Where the data length is returned
137 * DESCRIPTION: This function is called to place a simple object in a user
140 * The buffer is assumed to have sufficient space for the object.
142 ******************************************************************************/
145 AcpiUtCopyIsimpleToEsimple (
146 ACPI_OPERAND_OBJECT
*InternalObject
,
147 ACPI_OBJECT
*ExternalObject
,
149 ACPI_SIZE
*BufferSpaceUsed
)
151 ACPI_STATUS Status
= AE_OK
;
154 ACPI_FUNCTION_TRACE ("UtCopyIsimpleToEsimple");
157 *BufferSpaceUsed
= 0;
160 * Check for NULL object case (could be an uninitialized
165 return_ACPI_STATUS (AE_OK
);
168 /* Always clear the external object */
170 ACPI_MEMSET (ExternalObject
, 0, sizeof (ACPI_OBJECT
));
173 * In general, the external object will be the same type as
174 * the internal object
176 ExternalObject
->Type
= ACPI_GET_OBJECT_TYPE (InternalObject
);
178 /* However, only a limited number of external types are supported */
180 switch (ACPI_GET_OBJECT_TYPE (InternalObject
))
182 case ACPI_TYPE_STRING
:
184 ExternalObject
->String
.Pointer
= (char *) DataSpace
;
185 ExternalObject
->String
.Length
= InternalObject
->String
.Length
;
186 *BufferSpaceUsed
= ACPI_ROUND_UP_TO_NATIVE_WORD ((ACPI_SIZE
) InternalObject
->String
.Length
+ 1);
188 ACPI_MEMCPY ((void *) DataSpace
, (void *) InternalObject
->String
.Pointer
,
189 (ACPI_SIZE
) InternalObject
->String
.Length
+ 1);
193 case ACPI_TYPE_BUFFER
:
195 ExternalObject
->Buffer
.Pointer
= DataSpace
;
196 ExternalObject
->Buffer
.Length
= InternalObject
->Buffer
.Length
;
197 *BufferSpaceUsed
= ACPI_ROUND_UP_TO_NATIVE_WORD (InternalObject
->String
.Length
);
199 ACPI_MEMCPY ((void *) DataSpace
, (void *) InternalObject
->Buffer
.Pointer
,
200 InternalObject
->Buffer
.Length
);
204 case ACPI_TYPE_INTEGER
:
206 ExternalObject
->Integer
.Value
= InternalObject
->Integer
.Value
;
210 case ACPI_TYPE_LOCAL_REFERENCE
:
213 * This is an object reference. Attempt to dereference it.
215 switch (InternalObject
->Reference
.Opcode
)
217 case AML_INT_NAMEPATH_OP
:
219 /* For namepath, return the object handle ("reference") */
223 * Use the object type of "Any" to indicate a reference
224 * to object containing a handle to an ACPI named object.
226 ExternalObject
->Type
= ACPI_TYPE_ANY
;
227 ExternalObject
->Reference
.Handle
= InternalObject
->Reference
.Node
;
233 case ACPI_TYPE_PROCESSOR
:
235 ExternalObject
->Processor
.ProcId
= InternalObject
->Processor
.ProcId
;
236 ExternalObject
->Processor
.PblkAddress
= InternalObject
->Processor
.Address
;
237 ExternalObject
->Processor
.PblkLength
= InternalObject
->Processor
.Length
;
241 case ACPI_TYPE_POWER
:
243 ExternalObject
->PowerResource
.SystemLevel
=
244 InternalObject
->PowerResource
.SystemLevel
;
246 ExternalObject
->PowerResource
.ResourceOrder
=
247 InternalObject
->PowerResource
.ResourceOrder
;
253 * There is no corresponding external object type
255 return_ACPI_STATUS (AE_SUPPORT
);
258 return_ACPI_STATUS (Status
);
262 /*******************************************************************************
264 * FUNCTION: AcpiUtCopyIelementToEelement
266 * PARAMETERS: ACPI_PKG_CALLBACK
270 * DESCRIPTION: Copy one package element to another package element
272 ******************************************************************************/
275 AcpiUtCopyIelementToEelement (
277 ACPI_OPERAND_OBJECT
*SourceObject
,
278 ACPI_GENERIC_STATE
*State
,
281 ACPI_STATUS Status
= AE_OK
;
282 ACPI_PKG_INFO
*Info
= (ACPI_PKG_INFO
*) Context
;
283 ACPI_SIZE ObjectSpace
;
285 ACPI_OBJECT
*TargetObject
;
288 ACPI_FUNCTION_ENTRY ();
291 ThisIndex
= State
->Pkg
.Index
;
292 TargetObject
= (ACPI_OBJECT
*)
293 &((ACPI_OBJECT
*)(State
->Pkg
.DestObject
))->Package
.Elements
[ThisIndex
];
297 case ACPI_COPY_TYPE_SIMPLE
:
300 * This is a simple or null object
302 Status
= AcpiUtCopyIsimpleToEsimple (SourceObject
,
303 TargetObject
, Info
->FreeSpace
, &ObjectSpace
);
304 if (ACPI_FAILURE (Status
))
311 case ACPI_COPY_TYPE_PACKAGE
:
314 * Build the package object
316 TargetObject
->Type
= ACPI_TYPE_PACKAGE
;
317 TargetObject
->Package
.Count
= SourceObject
->Package
.Count
;
318 TargetObject
->Package
.Elements
= ACPI_CAST_PTR (ACPI_OBJECT
, Info
->FreeSpace
);
321 * Pass the new package object back to the package walk routine
323 State
->Pkg
.ThisTargetObj
= TargetObject
;
326 * Save space for the array of objects (Package elements)
327 * update the buffer length counter
329 ObjectSpace
= ACPI_ROUND_UP_TO_NATIVE_WORD (
330 (ACPI_SIZE
) TargetObject
->Package
.Count
* sizeof (ACPI_OBJECT
));
335 return (AE_BAD_PARAMETER
);
338 Info
->FreeSpace
+= ObjectSpace
;
339 Info
->Length
+= ObjectSpace
;
344 /*******************************************************************************
346 * FUNCTION: AcpiUtCopyIpackageToEpackage
348 * PARAMETERS: *InternalObject - Pointer to the object we are returning
349 * *Buffer - Where the object is returned
350 * *SpaceUsed - Where the object length is returned
354 * DESCRIPTION: This function is called to place a package object in a user
355 * buffer. A package object by definition contains other objects.
357 * The buffer is assumed to have sufficient space for the object.
358 * The caller must have verified the buffer length needed using the
359 * AcpiUtGetObjectSize function before calling this function.
361 ******************************************************************************/
364 AcpiUtCopyIpackageToEpackage (
365 ACPI_OPERAND_OBJECT
*InternalObject
,
367 ACPI_SIZE
*SpaceUsed
)
369 ACPI_OBJECT
*ExternalObject
;
374 ACPI_FUNCTION_TRACE ("UtCopyIpackageToEpackage");
378 * First package at head of the buffer
380 ExternalObject
= ACPI_CAST_PTR (ACPI_OBJECT
, Buffer
);
383 * Free space begins right after the first package
385 Info
.Length
= ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT
));
386 Info
.FreeSpace
= Buffer
+ ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT
));
387 Info
.ObjectSpace
= 0;
388 Info
.NumPackages
= 1;
390 ExternalObject
->Type
= ACPI_GET_OBJECT_TYPE (InternalObject
);
391 ExternalObject
->Package
.Count
= InternalObject
->Package
.Count
;
392 ExternalObject
->Package
.Elements
= ACPI_CAST_PTR (ACPI_OBJECT
, Info
.FreeSpace
);
395 * Leave room for an array of ACPI_OBJECTS in the buffer
396 * and move the free space past it
398 Info
.Length
+= (ACPI_SIZE
) ExternalObject
->Package
.Count
*
399 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT
));
400 Info
.FreeSpace
+= ExternalObject
->Package
.Count
*
401 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT
));
403 Status
= AcpiUtWalkPackageTree (InternalObject
, ExternalObject
,
404 AcpiUtCopyIelementToEelement
, &Info
);
406 *SpaceUsed
= Info
.Length
;
407 return_ACPI_STATUS (Status
);
411 /*******************************************************************************
413 * FUNCTION: AcpiUtCopyIobjectToEobject
415 * PARAMETERS: *InternalObject - The internal object to be converted
416 * *BufferPtr - Where the object is returned
420 * DESCRIPTION: This function is called to build an API object to be returned to
423 ******************************************************************************/
426 AcpiUtCopyIobjectToEobject (
427 ACPI_OPERAND_OBJECT
*InternalObject
,
428 ACPI_BUFFER
*RetBuffer
)
433 ACPI_FUNCTION_TRACE ("UtCopyIobjectToEobject");
436 if (ACPI_GET_OBJECT_TYPE (InternalObject
) == ACPI_TYPE_PACKAGE
)
439 * Package object: Copy all subobjects (including
442 Status
= AcpiUtCopyIpackageToEpackage (InternalObject
,
443 RetBuffer
->Pointer
, &RetBuffer
->Length
);
448 * Build a simple object (no nested objects)
450 Status
= AcpiUtCopyIsimpleToEsimple (InternalObject
,
451 (ACPI_OBJECT
*) RetBuffer
->Pointer
,
452 ((UINT8
*) RetBuffer
->Pointer
+
453 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT
))),
456 * build simple does not include the object size in the length
457 * so we add it in here
459 RetBuffer
->Length
+= sizeof (ACPI_OBJECT
);
462 return_ACPI_STATUS (Status
);
466 /*******************************************************************************
468 * FUNCTION: AcpiUtCopyEsimpleToIsimple
470 * PARAMETERS: *ExternalObject - The external object to be converted
471 * *InternalObject - Where the internal object is returned
475 * DESCRIPTION: This function copies an external object to an internal one.
476 * NOTE: Pointers can be copied, we don't need to copy data.
477 * (The pointers have to be valid in our address space no matter
478 * what we do with them!)
480 ******************************************************************************/
483 AcpiUtCopyEsimpleToIsimple (
484 ACPI_OBJECT
*ExternalObject
,
485 ACPI_OPERAND_OBJECT
**RetInternalObject
)
487 ACPI_OPERAND_OBJECT
*InternalObject
;
490 ACPI_FUNCTION_TRACE ("UtCopyEsimpleToIsimple");
494 * Simple types supported are: String, Buffer, Integer
496 switch (ExternalObject
->Type
)
498 case ACPI_TYPE_STRING
:
499 case ACPI_TYPE_BUFFER
:
500 case ACPI_TYPE_INTEGER
:
502 InternalObject
= AcpiUtCreateInternalObject ((UINT8
) ExternalObject
->Type
);
505 return_ACPI_STATUS (AE_NO_MEMORY
);
510 /* All other types are not supported */
512 return_ACPI_STATUS (AE_SUPPORT
);
516 /* Must COPY string and buffer contents */
518 switch (ExternalObject
->Type
)
520 case ACPI_TYPE_STRING
:
522 InternalObject
->String
.Pointer
=
523 ACPI_MEM_CALLOCATE ((ACPI_SIZE
) ExternalObject
->String
.Length
+ 1);
524 if (!InternalObject
->String
.Pointer
)
529 ACPI_MEMCPY (InternalObject
->String
.Pointer
,
530 ExternalObject
->String
.Pointer
,
531 ExternalObject
->String
.Length
);
533 InternalObject
->String
.Length
= ExternalObject
->String
.Length
;
537 case ACPI_TYPE_BUFFER
:
539 InternalObject
->Buffer
.Pointer
=
540 ACPI_MEM_CALLOCATE (ExternalObject
->Buffer
.Length
);
541 if (!InternalObject
->Buffer
.Pointer
)
546 ACPI_MEMCPY (InternalObject
->Buffer
.Pointer
,
547 ExternalObject
->Buffer
.Pointer
,
548 ExternalObject
->Buffer
.Length
);
550 InternalObject
->Buffer
.Length
= ExternalObject
->Buffer
.Length
;
554 case ACPI_TYPE_INTEGER
:
556 InternalObject
->Integer
.Value
= ExternalObject
->Integer
.Value
;
560 /* Other types can't get here */
564 *RetInternalObject
= InternalObject
;
565 return_ACPI_STATUS (AE_OK
);
569 AcpiUtRemoveReference (InternalObject
);
570 return_ACPI_STATUS (AE_NO_MEMORY
);
574 #ifdef ACPI_FUTURE_IMPLEMENTATION
576 /* Code to convert packages that are parameters to control methods */
578 /*******************************************************************************
580 * FUNCTION: AcpiUtCopyEpackageToIpackage
582 * PARAMETERS: *InternalObject - Pointer to the object we are returning
583 * *Buffer - Where the object is returned
584 * *SpaceUsed - Where the length of the object is returned
588 * DESCRIPTION: This function is called to place a package object in a user
589 * buffer. A package object by definition contains other objects.
591 * The buffer is assumed to have sufficient space for the object.
592 * The caller must have verified the buffer length needed using the
593 * AcpiUtGetObjectSize function before calling this function.
595 ******************************************************************************/
598 AcpiUtCopyEpackageToIpackage (
599 ACPI_OPERAND_OBJECT
*InternalObject
,
604 ACPI_OBJECT
*ExternalObject
;
607 UINT32 ObjectSpace
= 0;
608 ACPI_OPERAND_OBJECT
*ThisInternalObj
;
609 ACPI_OBJECT
*ThisExternalObj
;
612 ACPI_FUNCTION_TRACE ("UtCopyEpackageToIpackage");
616 * First package at head of the buffer
618 ExternalObject
= (ACPI_OBJECT
*)Buffer
;
621 * Free space begins right after the first package
623 FreeSpace
= Buffer
+ sizeof(ACPI_OBJECT
);
626 ExternalObject
->Type
= ACPI_GET_OBJECT_TYPE (InternalObject
);
627 ExternalObject
->Package
.Count
= InternalObject
->Package
.Count
;
628 ExternalObject
->Package
.Elements
= (ACPI_OBJECT
*)FreeSpace
;
631 * Build an array of ACPI_OBJECTS in the buffer
632 * and move the free space past it
634 FreeSpace
+= ExternalObject
->Package
.Count
* sizeof(ACPI_OBJECT
);
637 /* Call WalkPackage */
641 #endif /* Future implementation */
644 /*******************************************************************************
646 * FUNCTION: AcpiUtCopyEobjectToIobject
648 * PARAMETERS: *InternalObject - The external object to be converted
649 * *BufferPtr - Where the internal object is returned
651 * RETURN: Status - the status of the call
653 * DESCRIPTION: Converts an external object to an internal object.
655 ******************************************************************************/
658 AcpiUtCopyEobjectToIobject (
659 ACPI_OBJECT
*ExternalObject
,
660 ACPI_OPERAND_OBJECT
**InternalObject
)
665 ACPI_FUNCTION_TRACE ("UtCopyEobjectToIobject");
668 if (ExternalObject
->Type
== ACPI_TYPE_PACKAGE
)
671 * Packages as external input to control methods are not supported,
673 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
,
674 "Packages as parameters not implemented!\n"));
676 return_ACPI_STATUS (AE_NOT_IMPLEMENTED
);
682 * Build a simple object (no nested objects)
684 Status
= AcpiUtCopyEsimpleToIsimple (ExternalObject
, InternalObject
);
687 return_ACPI_STATUS (Status
);
691 /*******************************************************************************
693 * FUNCTION: AcpiUtCopySimpleObject
695 * PARAMETERS: SourceDesc - The internal object to be copied
696 * DestDesc - New target object
700 * DESCRIPTION: Simple copy of one internal object to another. Reference count
701 * of the destination object is preserved.
703 ******************************************************************************/
706 AcpiUtCopySimpleObject (
707 ACPI_OPERAND_OBJECT
*SourceDesc
,
708 ACPI_OPERAND_OBJECT
*DestDesc
)
710 UINT16 ReferenceCount
;
711 ACPI_OPERAND_OBJECT
*NextObject
;
714 /* Save fields from destination that we don't want to overwrite */
716 ReferenceCount
= DestDesc
->Common
.ReferenceCount
;
717 NextObject
= DestDesc
->Common
.NextObject
;
719 /* Copy the entire source object over the destination object*/
721 ACPI_MEMCPY ((char *) DestDesc
, (char *) SourceDesc
,
722 sizeof (ACPI_OPERAND_OBJECT
));
724 /* Restore the saved fields */
726 DestDesc
->Common
.ReferenceCount
= ReferenceCount
;
727 DestDesc
->Common
.NextObject
= NextObject
;
729 /* Handle the objects with extra data */
731 switch (ACPI_GET_OBJECT_TYPE (DestDesc
))
733 case ACPI_TYPE_BUFFER
:
735 DestDesc
->Buffer
.Node
= NULL
;
736 DestDesc
->Common
.Flags
= SourceDesc
->Common
.Flags
;
739 * Allocate and copy the actual buffer if and only if:
740 * 1) There is a valid buffer pointer
741 * 2) The buffer is not static (not in an ACPI table) (in this case,
742 * the actual pointer was already copied above)
744 if ((SourceDesc
->Buffer
.Pointer
) &&
745 (!(SourceDesc
->Common
.Flags
& AOPOBJ_STATIC_POINTER
)))
747 DestDesc
->Buffer
.Pointer
= NULL
;
749 /* Create an actual buffer only if length > 0 */
751 if (SourceDesc
->Buffer
.Length
)
753 DestDesc
->Buffer
.Pointer
= ACPI_MEM_ALLOCATE (SourceDesc
->Buffer
.Length
);
754 if (!DestDesc
->Buffer
.Pointer
)
756 return (AE_NO_MEMORY
);
759 /* Copy the actual buffer data */
761 ACPI_MEMCPY (DestDesc
->Buffer
.Pointer
, SourceDesc
->Buffer
.Pointer
,
762 SourceDesc
->Buffer
.Length
);
767 case ACPI_TYPE_STRING
:
770 * Allocate and copy the actual string if and only if:
771 * 1) There is a valid string pointer
772 * 2) The string is not static (not in an ACPI table) (in this case,
773 * the actual pointer was already copied above)
775 if ((SourceDesc
->String
.Pointer
) &&
776 (!(SourceDesc
->Common
.Flags
& AOPOBJ_STATIC_POINTER
)))
778 DestDesc
->String
.Pointer
= ACPI_MEM_ALLOCATE ((ACPI_SIZE
) SourceDesc
->String
.Length
+ 1);
779 if (!DestDesc
->String
.Pointer
)
781 return (AE_NO_MEMORY
);
784 ACPI_MEMCPY (DestDesc
->String
.Pointer
, SourceDesc
->String
.Pointer
,
785 (ACPI_SIZE
) SourceDesc
->String
.Length
+ 1);
790 /* Nothing to do for other simple objects */
798 /*******************************************************************************
800 * FUNCTION: AcpiUtCopyIelementToIelement
802 * PARAMETERS: ACPI_PKG_CALLBACK
806 * DESCRIPTION: Copy one package element to another package element
808 ******************************************************************************/
811 AcpiUtCopyIelementToIelement (
813 ACPI_OPERAND_OBJECT
*SourceObject
,
814 ACPI_GENERIC_STATE
*State
,
817 ACPI_STATUS Status
= AE_OK
;
819 ACPI_OPERAND_OBJECT
**ThisTargetPtr
;
820 ACPI_OPERAND_OBJECT
*TargetObject
;
823 ACPI_FUNCTION_ENTRY ();
826 ThisIndex
= State
->Pkg
.Index
;
827 ThisTargetPtr
= (ACPI_OPERAND_OBJECT
**)
828 &State
->Pkg
.DestObject
->Package
.Elements
[ThisIndex
];
832 case ACPI_COPY_TYPE_SIMPLE
:
834 /* A null source object indicates a (legal) null package element */
839 * This is a simple object, just copy it
841 TargetObject
= AcpiUtCreateInternalObject (
842 ACPI_GET_OBJECT_TYPE (SourceObject
));
845 return (AE_NO_MEMORY
);
848 Status
= AcpiUtCopySimpleObject (SourceObject
, TargetObject
);
849 if (ACPI_FAILURE (Status
))
854 *ThisTargetPtr
= TargetObject
;
858 /* Pass through a null element */
860 *ThisTargetPtr
= NULL
;
865 case ACPI_COPY_TYPE_PACKAGE
:
868 * This object is a package - go down another nesting level
869 * Create and build the package object
871 TargetObject
= AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE
);
874 return (AE_NO_MEMORY
);
877 TargetObject
->Package
.Count
= SourceObject
->Package
.Count
;
878 TargetObject
->Common
.Flags
= SourceObject
->Common
.Flags
;
881 * Create the object array
883 TargetObject
->Package
.Elements
=
884 ACPI_MEM_CALLOCATE (((ACPI_SIZE
) SourceObject
->Package
.Count
+ 1) *
886 if (!TargetObject
->Package
.Elements
)
888 Status
= AE_NO_MEMORY
;
893 * Pass the new package object back to the package walk routine
895 State
->Pkg
.ThisTargetObj
= TargetObject
;
898 * Store the object pointer in the parent package object
900 *ThisTargetPtr
= TargetObject
;
905 return (AE_BAD_PARAMETER
);
911 AcpiUtRemoveReference (TargetObject
);
916 /*******************************************************************************
918 * FUNCTION: AcpiUtCopyIpackageToIpackage
920 * PARAMETERS: *SourceObj - Pointer to the source package object
921 * *DestObj - Where the internal object is returned
923 * RETURN: Status - the status of the call
925 * DESCRIPTION: This function is called to copy an internal package object
926 * into another internal package object.
928 ******************************************************************************/
931 AcpiUtCopyIpackageToIpackage (
932 ACPI_OPERAND_OBJECT
*SourceObj
,
933 ACPI_OPERAND_OBJECT
*DestObj
,
934 ACPI_WALK_STATE
*WalkState
)
936 ACPI_STATUS Status
= AE_OK
;
939 ACPI_FUNCTION_TRACE ("UtCopyIpackageToIpackage");
942 DestObj
->Common
.Type
= ACPI_GET_OBJECT_TYPE (SourceObj
);
943 DestObj
->Common
.Flags
= SourceObj
->Common
.Flags
;
944 DestObj
->Package
.Count
= SourceObj
->Package
.Count
;
947 * Create the object array and walk the source package tree
949 DestObj
->Package
.Elements
= ACPI_MEM_CALLOCATE (
950 ((ACPI_SIZE
) SourceObj
->Package
.Count
+ 1) *
952 if (!DestObj
->Package
.Elements
)
955 ("AmlBuildCopyInternalPackageObject: Package allocation failure\n"));
956 return_ACPI_STATUS (AE_NO_MEMORY
);
960 * Copy the package element-by-element by walking the package "tree".
961 * This handles nested packages of arbitrary depth.
963 Status
= AcpiUtWalkPackageTree (SourceObj
, DestObj
,
964 AcpiUtCopyIelementToIelement
, WalkState
);
965 if (ACPI_FAILURE (Status
))
967 /* On failure, delete the destination package object */
969 AcpiUtRemoveReference (DestObj
);
972 return_ACPI_STATUS (Status
);
976 /*******************************************************************************
978 * FUNCTION: AcpiUtCopyIobjectToIobject
980 * PARAMETERS: WalkState - Current walk state
981 * SourceDesc - The internal object to be copied
982 * DestDesc - Where the copied object is returned
986 * DESCRIPTION: Copy an internal object to a new internal object
988 ******************************************************************************/
991 AcpiUtCopyIobjectToIobject (
992 ACPI_OPERAND_OBJECT
*SourceDesc
,
993 ACPI_OPERAND_OBJECT
**DestDesc
,
994 ACPI_WALK_STATE
*WalkState
)
996 ACPI_STATUS Status
= AE_OK
;
999 ACPI_FUNCTION_TRACE ("UtCopyIobjectToIobject");
1002 /* Create the top level object */
1004 *DestDesc
= AcpiUtCreateInternalObject (ACPI_GET_OBJECT_TYPE (SourceDesc
));
1007 return_ACPI_STATUS (AE_NO_MEMORY
);
1010 /* Copy the object and possible subobjects */
1012 if (ACPI_GET_OBJECT_TYPE (SourceDesc
) == ACPI_TYPE_PACKAGE
)
1014 Status
= AcpiUtCopyIpackageToIpackage (SourceDesc
, *DestDesc
,
1019 Status
= AcpiUtCopySimpleObject (SourceDesc
, *DestDesc
);
1022 return_ACPI_STATUS (Status
);