1 /******************************************************************************
3 * Module Name: utcopy - Internal to external object translation utilities
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2005, R. Byron Moore
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
45 #include <acpi/acpi.h>
46 #include <acpi/amlcode.h>
49 #define _COMPONENT ACPI_UTILITIES
50 ACPI_MODULE_NAME ("utcopy")
52 /* Local prototypes */
55 acpi_ut_copy_isimple_to_esimple (
56 union acpi_operand_object
*internal_object
,
57 union acpi_object
*external_object
,
59 acpi_size
*buffer_space_used
);
62 acpi_ut_copy_ielement_to_ielement (
64 union acpi_operand_object
*source_object
,
65 union acpi_generic_state
*state
,
69 acpi_ut_copy_ipackage_to_epackage (
70 union acpi_operand_object
*internal_object
,
72 acpi_size
*space_used
);
75 acpi_ut_copy_esimple_to_isimple(
76 union acpi_object
*user_obj
,
77 union acpi_operand_object
**return_obj
);
80 acpi_ut_copy_simple_object (
81 union acpi_operand_object
*source_desc
,
82 union acpi_operand_object
*dest_desc
);
85 acpi_ut_copy_ielement_to_eelement (
87 union acpi_operand_object
*source_object
,
88 union acpi_generic_state
*state
,
92 acpi_ut_copy_ipackage_to_ipackage (
93 union acpi_operand_object
*source_obj
,
94 union acpi_operand_object
*dest_obj
,
95 struct acpi_walk_state
*walk_state
);
98 /*******************************************************************************
100 * FUNCTION: acpi_ut_copy_isimple_to_esimple
102 * PARAMETERS: internal_object - Source object to be copied
103 * external_object - Where to return the copied object
104 * data_space - Where object data is returned (such as
105 * buffer and string data)
106 * buffer_space_used - Length of data_space that was used
110 * DESCRIPTION: This function is called to copy a simple internal object to
111 * an external object.
113 * The data_space buffer is assumed to have sufficient space for
116 ******************************************************************************/
119 acpi_ut_copy_isimple_to_esimple (
120 union acpi_operand_object
*internal_object
,
121 union acpi_object
*external_object
,
123 acpi_size
*buffer_space_used
)
125 acpi_status status
= AE_OK
;
128 ACPI_FUNCTION_TRACE ("ut_copy_isimple_to_esimple");
131 *buffer_space_used
= 0;
134 * Check for NULL object case (could be an uninitialized
137 if (!internal_object
) {
138 return_ACPI_STATUS (AE_OK
);
141 /* Always clear the external object */
143 ACPI_MEMSET (external_object
, 0, sizeof (union acpi_object
));
146 * In general, the external object will be the same type as
147 * the internal object
149 external_object
->type
= ACPI_GET_OBJECT_TYPE (internal_object
);
151 /* However, only a limited number of external types are supported */
153 switch (ACPI_GET_OBJECT_TYPE (internal_object
)) {
154 case ACPI_TYPE_STRING
:
156 external_object
->string
.pointer
= (char *) data_space
;
157 external_object
->string
.length
= internal_object
->string
.length
;
158 *buffer_space_used
= ACPI_ROUND_UP_TO_NATIVE_WORD (
159 (acpi_size
) internal_object
->string
.length
+ 1);
161 ACPI_MEMCPY ((void *) data_space
,
162 (void *) internal_object
->string
.pointer
,
163 (acpi_size
) internal_object
->string
.length
+ 1);
167 case ACPI_TYPE_BUFFER
:
169 external_object
->buffer
.pointer
= data_space
;
170 external_object
->buffer
.length
= internal_object
->buffer
.length
;
171 *buffer_space_used
= ACPI_ROUND_UP_TO_NATIVE_WORD (
172 internal_object
->string
.length
);
174 ACPI_MEMCPY ((void *) data_space
,
175 (void *) internal_object
->buffer
.pointer
,
176 internal_object
->buffer
.length
);
180 case ACPI_TYPE_INTEGER
:
182 external_object
->integer
.value
= internal_object
->integer
.value
;
186 case ACPI_TYPE_LOCAL_REFERENCE
:
189 * This is an object reference. Attempt to dereference it.
191 switch (internal_object
->reference
.opcode
) {
192 case AML_INT_NAMEPATH_OP
:
194 /* For namepath, return the object handle ("reference") */
198 * Use the object type of "Any" to indicate a reference
199 * to object containing a handle to an ACPI named object.
201 external_object
->type
= ACPI_TYPE_ANY
;
202 external_object
->reference
.handle
= internal_object
->reference
.node
;
208 case ACPI_TYPE_PROCESSOR
:
210 external_object
->processor
.proc_id
= internal_object
->processor
.proc_id
;
211 external_object
->processor
.pblk_address
= internal_object
->processor
.address
;
212 external_object
->processor
.pblk_length
= internal_object
->processor
.length
;
216 case ACPI_TYPE_POWER
:
218 external_object
->power_resource
.system_level
=
219 internal_object
->power_resource
.system_level
;
221 external_object
->power_resource
.resource_order
=
222 internal_object
->power_resource
.resource_order
;
228 * There is no corresponding external object type
230 return_ACPI_STATUS (AE_SUPPORT
);
233 return_ACPI_STATUS (status
);
237 /*******************************************************************************
239 * FUNCTION: acpi_ut_copy_ielement_to_eelement
241 * PARAMETERS: acpi_pkg_callback
245 * DESCRIPTION: Copy one package element to another package element
247 ******************************************************************************/
250 acpi_ut_copy_ielement_to_eelement (
252 union acpi_operand_object
*source_object
,
253 union acpi_generic_state
*state
,
256 acpi_status status
= AE_OK
;
257 struct acpi_pkg_info
*info
= (struct acpi_pkg_info
*) context
;
258 acpi_size object_space
;
260 union acpi_object
*target_object
;
263 ACPI_FUNCTION_ENTRY ();
266 this_index
= state
->pkg
.index
;
267 target_object
= (union acpi_object
*)
268 &((union acpi_object
*)(state
->pkg
.dest_object
))->package
.elements
[this_index
];
270 switch (object_type
) {
271 case ACPI_COPY_TYPE_SIMPLE
:
274 * This is a simple or null object
276 status
= acpi_ut_copy_isimple_to_esimple (source_object
,
277 target_object
, info
->free_space
, &object_space
);
278 if (ACPI_FAILURE (status
)) {
284 case ACPI_COPY_TYPE_PACKAGE
:
287 * Build the package object
289 target_object
->type
= ACPI_TYPE_PACKAGE
;
290 target_object
->package
.count
= source_object
->package
.count
;
291 target_object
->package
.elements
=
292 ACPI_CAST_PTR (union acpi_object
, info
->free_space
);
295 * Pass the new package object back to the package walk routine
297 state
->pkg
.this_target_obj
= target_object
;
300 * Save space for the array of objects (Package elements)
301 * update the buffer length counter
303 object_space
= ACPI_ROUND_UP_TO_NATIVE_WORD (
304 (acpi_size
) target_object
->package
.count
*
305 sizeof (union acpi_object
));
310 return (AE_BAD_PARAMETER
);
313 info
->free_space
+= object_space
;
314 info
->length
+= object_space
;
319 /*******************************************************************************
321 * FUNCTION: acpi_ut_copy_ipackage_to_epackage
323 * PARAMETERS: internal_object - Pointer to the object we are returning
324 * Buffer - Where the object is returned
325 * space_used - Where the object length is returned
329 * DESCRIPTION: This function is called to place a package object in a user
330 * buffer. A package object by definition contains other objects.
332 * The buffer is assumed to have sufficient space for the object.
333 * The caller must have verified the buffer length needed using the
334 * acpi_ut_get_object_size function before calling this function.
336 ******************************************************************************/
339 acpi_ut_copy_ipackage_to_epackage (
340 union acpi_operand_object
*internal_object
,
342 acpi_size
*space_used
)
344 union acpi_object
*external_object
;
346 struct acpi_pkg_info info
;
349 ACPI_FUNCTION_TRACE ("ut_copy_ipackage_to_epackage");
353 * First package at head of the buffer
355 external_object
= ACPI_CAST_PTR (union acpi_object
, buffer
);
358 * Free space begins right after the first package
360 info
.length
= ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object
));
361 info
.free_space
= buffer
+ ACPI_ROUND_UP_TO_NATIVE_WORD (
362 sizeof (union acpi_object
));
363 info
.object_space
= 0;
364 info
.num_packages
= 1;
366 external_object
->type
= ACPI_GET_OBJECT_TYPE (internal_object
);
367 external_object
->package
.count
= internal_object
->package
.count
;
368 external_object
->package
.elements
= ACPI_CAST_PTR (union acpi_object
,
372 * Leave room for an array of ACPI_OBJECTS in the buffer
373 * and move the free space past it
375 info
.length
+= (acpi_size
) external_object
->package
.count
*
376 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object
));
377 info
.free_space
+= external_object
->package
.count
*
378 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object
));
380 status
= acpi_ut_walk_package_tree (internal_object
, external_object
,
381 acpi_ut_copy_ielement_to_eelement
, &info
);
383 *space_used
= info
.length
;
384 return_ACPI_STATUS (status
);
388 /*******************************************************************************
390 * FUNCTION: acpi_ut_copy_iobject_to_eobject
392 * PARAMETERS: internal_object - The internal object to be converted
393 * buffer_ptr - Where the object is returned
397 * DESCRIPTION: This function is called to build an API object to be returned to
400 ******************************************************************************/
403 acpi_ut_copy_iobject_to_eobject (
404 union acpi_operand_object
*internal_object
,
405 struct acpi_buffer
*ret_buffer
)
410 ACPI_FUNCTION_TRACE ("ut_copy_iobject_to_eobject");
413 if (ACPI_GET_OBJECT_TYPE (internal_object
) == ACPI_TYPE_PACKAGE
) {
415 * Package object: Copy all subobjects (including
418 status
= acpi_ut_copy_ipackage_to_epackage (internal_object
,
419 ret_buffer
->pointer
, &ret_buffer
->length
);
423 * Build a simple object (no nested objects)
425 status
= acpi_ut_copy_isimple_to_esimple (internal_object
,
426 (union acpi_object
*) ret_buffer
->pointer
,
427 ((u8
*) ret_buffer
->pointer
+
428 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object
))),
429 &ret_buffer
->length
);
431 * build simple does not include the object size in the length
432 * so we add it in here
434 ret_buffer
->length
+= sizeof (union acpi_object
);
437 return_ACPI_STATUS (status
);
441 /*******************************************************************************
443 * FUNCTION: acpi_ut_copy_esimple_to_isimple
445 * PARAMETERS: external_object - The external object to be converted
446 * ret_internal_object - Where the internal object is returned
450 * DESCRIPTION: This function copies an external object to an internal one.
451 * NOTE: Pointers can be copied, we don't need to copy data.
452 * (The pointers have to be valid in our address space no matter
453 * what we do with them!)
455 ******************************************************************************/
458 acpi_ut_copy_esimple_to_isimple (
459 union acpi_object
*external_object
,
460 union acpi_operand_object
**ret_internal_object
)
462 union acpi_operand_object
*internal_object
;
465 ACPI_FUNCTION_TRACE ("ut_copy_esimple_to_isimple");
469 * Simple types supported are: String, Buffer, Integer
471 switch (external_object
->type
) {
472 case ACPI_TYPE_STRING
:
473 case ACPI_TYPE_BUFFER
:
474 case ACPI_TYPE_INTEGER
:
476 internal_object
= acpi_ut_create_internal_object (
477 (u8
) external_object
->type
);
478 if (!internal_object
) {
479 return_ACPI_STATUS (AE_NO_MEMORY
);
484 /* All other types are not supported */
486 return_ACPI_STATUS (AE_SUPPORT
);
490 /* Must COPY string and buffer contents */
492 switch (external_object
->type
) {
493 case ACPI_TYPE_STRING
:
495 internal_object
->string
.pointer
=
496 ACPI_MEM_CALLOCATE ((acpi_size
) external_object
->string
.length
+ 1);
497 if (!internal_object
->string
.pointer
) {
501 ACPI_MEMCPY (internal_object
->string
.pointer
,
502 external_object
->string
.pointer
,
503 external_object
->string
.length
);
505 internal_object
->string
.length
= external_object
->string
.length
;
509 case ACPI_TYPE_BUFFER
:
511 internal_object
->buffer
.pointer
=
512 ACPI_MEM_CALLOCATE (external_object
->buffer
.length
);
513 if (!internal_object
->buffer
.pointer
) {
517 ACPI_MEMCPY (internal_object
->buffer
.pointer
,
518 external_object
->buffer
.pointer
,
519 external_object
->buffer
.length
);
521 internal_object
->buffer
.length
= external_object
->buffer
.length
;
525 case ACPI_TYPE_INTEGER
:
527 internal_object
->integer
.value
= external_object
->integer
.value
;
531 /* Other types can't get here */
535 *ret_internal_object
= internal_object
;
536 return_ACPI_STATUS (AE_OK
);
540 acpi_ut_remove_reference (internal_object
);
541 return_ACPI_STATUS (AE_NO_MEMORY
);
545 #ifdef ACPI_FUTURE_IMPLEMENTATION
546 /* Code to convert packages that are parameters to control methods */
548 /*******************************************************************************
550 * FUNCTION: acpi_ut_copy_epackage_to_ipackage
552 * PARAMETERS: *internal_object - Pointer to the object we are returning
553 * *Buffer - Where the object is returned
554 * *space_used - Where the length of the object is returned
558 * DESCRIPTION: This function is called to place a package object in a user
559 * buffer. A package object by definition contains other objects.
561 * The buffer is assumed to have sufficient space for the object.
562 * The caller must have verified the buffer length needed using the
563 * acpi_ut_get_object_size function before calling this function.
565 ******************************************************************************/
568 acpi_ut_copy_epackage_to_ipackage (
569 union acpi_operand_object
*internal_object
,
574 union acpi_object
*external_object
;
577 u32 object_space
= 0;
578 union acpi_operand_object
*this_internal_obj
;
579 union acpi_object
*this_external_obj
;
582 ACPI_FUNCTION_TRACE ("ut_copy_epackage_to_ipackage");
586 * First package at head of the buffer
588 external_object
= (union acpi_object
*)buffer
;
591 * Free space begins right after the first package
593 free_space
= buffer
+ sizeof(union acpi_object
);
596 external_object
->type
= ACPI_GET_OBJECT_TYPE (internal_object
);
597 external_object
->package
.count
= internal_object
->package
.count
;
598 external_object
->package
.elements
= (union acpi_object
*)free_space
;
601 * Build an array of ACPI_OBJECTS in the buffer
602 * and move the free space past it
604 free_space
+= external_object
->package
.count
* sizeof(union acpi_object
);
607 /* Call walk_package */
611 #endif /* Future implementation */
614 /*******************************************************************************
616 * FUNCTION: acpi_ut_copy_eobject_to_iobject
618 * PARAMETERS: *internal_object - The external object to be converted
619 * *buffer_ptr - Where the internal object is returned
621 * RETURN: Status - the status of the call
623 * DESCRIPTION: Converts an external object to an internal object.
625 ******************************************************************************/
628 acpi_ut_copy_eobject_to_iobject (
629 union acpi_object
*external_object
,
630 union acpi_operand_object
**internal_object
)
635 ACPI_FUNCTION_TRACE ("ut_copy_eobject_to_iobject");
638 if (external_object
->type
== ACPI_TYPE_PACKAGE
) {
640 * Packages as external input to control methods are not supported,
642 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR
,
643 "Packages as parameters not implemented!\n"));
645 return_ACPI_STATUS (AE_NOT_IMPLEMENTED
);
650 * Build a simple object (no nested objects)
652 status
= acpi_ut_copy_esimple_to_isimple (external_object
, internal_object
);
655 return_ACPI_STATUS (status
);
659 /*******************************************************************************
661 * FUNCTION: acpi_ut_copy_simple_object
663 * PARAMETERS: source_desc - The internal object to be copied
664 * dest_desc - New target object
668 * DESCRIPTION: Simple copy of one internal object to another. Reference count
669 * of the destination object is preserved.
671 ******************************************************************************/
674 acpi_ut_copy_simple_object (
675 union acpi_operand_object
*source_desc
,
676 union acpi_operand_object
*dest_desc
)
679 union acpi_operand_object
*next_object
;
682 /* Save fields from destination that we don't want to overwrite */
684 reference_count
= dest_desc
->common
.reference_count
;
685 next_object
= dest_desc
->common
.next_object
;
687 /* Copy the entire source object over the destination object*/
689 ACPI_MEMCPY ((char *) dest_desc
, (char *) source_desc
,
690 sizeof (union acpi_operand_object
));
692 /* Restore the saved fields */
694 dest_desc
->common
.reference_count
= reference_count
;
695 dest_desc
->common
.next_object
= next_object
;
697 /* Handle the objects with extra data */
699 switch (ACPI_GET_OBJECT_TYPE (dest_desc
)) {
700 case ACPI_TYPE_BUFFER
:
702 dest_desc
->buffer
.node
= NULL
;
703 dest_desc
->common
.flags
= source_desc
->common
.flags
;
706 * Allocate and copy the actual buffer if and only if:
707 * 1) There is a valid buffer pointer
708 * 2) The buffer is not static (not in an ACPI table) (in this case,
709 * the actual pointer was already copied above)
711 if ((source_desc
->buffer
.pointer
) &&
712 (!(source_desc
->common
.flags
& AOPOBJ_STATIC_POINTER
))) {
713 dest_desc
->buffer
.pointer
= NULL
;
715 /* Create an actual buffer only if length > 0 */
717 if (source_desc
->buffer
.length
) {
718 dest_desc
->buffer
.pointer
=
719 ACPI_MEM_ALLOCATE (source_desc
->buffer
.length
);
720 if (!dest_desc
->buffer
.pointer
) {
721 return (AE_NO_MEMORY
);
724 /* Copy the actual buffer data */
726 ACPI_MEMCPY (dest_desc
->buffer
.pointer
,
727 source_desc
->buffer
.pointer
,
728 source_desc
->buffer
.length
);
733 case ACPI_TYPE_STRING
:
736 * Allocate and copy the actual string if and only if:
737 * 1) There is a valid string pointer
738 * 2) The string is not static (not in an ACPI table) (in this case,
739 * the actual pointer was already copied above)
741 if ((source_desc
->string
.pointer
) &&
742 (!(source_desc
->common
.flags
& AOPOBJ_STATIC_POINTER
))) {
743 dest_desc
->string
.pointer
=
744 ACPI_MEM_ALLOCATE ((acpi_size
) source_desc
->string
.length
+ 1);
745 if (!dest_desc
->string
.pointer
) {
746 return (AE_NO_MEMORY
);
749 ACPI_MEMCPY (dest_desc
->string
.pointer
, source_desc
->string
.pointer
,
750 (acpi_size
) source_desc
->string
.length
+ 1);
754 case ACPI_TYPE_LOCAL_REFERENCE
:
756 * We copied the reference object, so we now must add a reference
757 * to the object pointed to by the reference
759 acpi_ut_add_reference (source_desc
->reference
.object
);
763 /* Nothing to do for other simple objects */
771 /*******************************************************************************
773 * FUNCTION: acpi_ut_copy_ielement_to_ielement
775 * PARAMETERS: acpi_pkg_callback
779 * DESCRIPTION: Copy one package element to another package element
781 ******************************************************************************/
784 acpi_ut_copy_ielement_to_ielement (
786 union acpi_operand_object
*source_object
,
787 union acpi_generic_state
*state
,
790 acpi_status status
= AE_OK
;
792 union acpi_operand_object
**this_target_ptr
;
793 union acpi_operand_object
*target_object
;
796 ACPI_FUNCTION_ENTRY ();
799 this_index
= state
->pkg
.index
;
800 this_target_ptr
= (union acpi_operand_object
**)
801 &state
->pkg
.dest_object
->package
.elements
[this_index
];
803 switch (object_type
) {
804 case ACPI_COPY_TYPE_SIMPLE
:
806 /* A null source object indicates a (legal) null package element */
810 * This is a simple object, just copy it
812 target_object
= acpi_ut_create_internal_object (
813 ACPI_GET_OBJECT_TYPE (source_object
));
814 if (!target_object
) {
815 return (AE_NO_MEMORY
);
818 status
= acpi_ut_copy_simple_object (source_object
, target_object
);
819 if (ACPI_FAILURE (status
)) {
823 *this_target_ptr
= target_object
;
826 /* Pass through a null element */
828 *this_target_ptr
= NULL
;
833 case ACPI_COPY_TYPE_PACKAGE
:
836 * This object is a package - go down another nesting level
837 * Create and build the package object
839 target_object
= acpi_ut_create_internal_object (ACPI_TYPE_PACKAGE
);
840 if (!target_object
) {
841 return (AE_NO_MEMORY
);
844 target_object
->package
.count
= source_object
->package
.count
;
845 target_object
->common
.flags
= source_object
->common
.flags
;
848 * Create the object array
850 target_object
->package
.elements
=
851 ACPI_MEM_CALLOCATE (((acpi_size
) source_object
->package
.count
+ 1) *
853 if (!target_object
->package
.elements
) {
854 status
= AE_NO_MEMORY
;
859 * Pass the new package object back to the package walk routine
861 state
->pkg
.this_target_obj
= target_object
;
864 * Store the object pointer in the parent package object
866 *this_target_ptr
= target_object
;
871 return (AE_BAD_PARAMETER
);
877 acpi_ut_remove_reference (target_object
);
882 /*******************************************************************************
884 * FUNCTION: acpi_ut_copy_ipackage_to_ipackage
886 * PARAMETERS: *source_obj - Pointer to the source package object
887 * *dest_obj - Where the internal object is returned
889 * RETURN: Status - the status of the call
891 * DESCRIPTION: This function is called to copy an internal package object
892 * into another internal package object.
894 ******************************************************************************/
897 acpi_ut_copy_ipackage_to_ipackage (
898 union acpi_operand_object
*source_obj
,
899 union acpi_operand_object
*dest_obj
,
900 struct acpi_walk_state
*walk_state
)
902 acpi_status status
= AE_OK
;
905 ACPI_FUNCTION_TRACE ("ut_copy_ipackage_to_ipackage");
908 dest_obj
->common
.type
= ACPI_GET_OBJECT_TYPE (source_obj
);
909 dest_obj
->common
.flags
= source_obj
->common
.flags
;
910 dest_obj
->package
.count
= source_obj
->package
.count
;
913 * Create the object array and walk the source package tree
915 dest_obj
->package
.elements
= ACPI_MEM_CALLOCATE (
916 ((acpi_size
) source_obj
->package
.count
+ 1) *
918 if (!dest_obj
->package
.elements
) {
920 ("aml_build_copy_internal_package_object: Package allocation failure\n"));
921 return_ACPI_STATUS (AE_NO_MEMORY
);
925 * Copy the package element-by-element by walking the package "tree".
926 * This handles nested packages of arbitrary depth.
928 status
= acpi_ut_walk_package_tree (source_obj
, dest_obj
,
929 acpi_ut_copy_ielement_to_ielement
, walk_state
);
930 if (ACPI_FAILURE (status
)) {
931 /* On failure, delete the destination package object */
933 acpi_ut_remove_reference (dest_obj
);
936 return_ACPI_STATUS (status
);
940 /*******************************************************************************
942 * FUNCTION: acpi_ut_copy_iobject_to_iobject
944 * PARAMETERS: walk_state - Current walk state
945 * source_desc - The internal object to be copied
946 * dest_desc - Where the copied object is returned
950 * DESCRIPTION: Copy an internal object to a new internal object
952 ******************************************************************************/
955 acpi_ut_copy_iobject_to_iobject (
956 union acpi_operand_object
*source_desc
,
957 union acpi_operand_object
**dest_desc
,
958 struct acpi_walk_state
*walk_state
)
960 acpi_status status
= AE_OK
;
963 ACPI_FUNCTION_TRACE ("ut_copy_iobject_to_iobject");
966 /* Create the top level object */
968 *dest_desc
= acpi_ut_create_internal_object (ACPI_GET_OBJECT_TYPE (source_desc
));
970 return_ACPI_STATUS (AE_NO_MEMORY
);
973 /* Copy the object and possible subobjects */
975 if (ACPI_GET_OBJECT_TYPE (source_desc
) == ACPI_TYPE_PACKAGE
) {
976 status
= acpi_ut_copy_ipackage_to_ipackage (source_desc
, *dest_desc
,
980 status
= acpi_ut_copy_simple_object (source_desc
, *dest_desc
);
983 return_ACPI_STATUS (status
);