1 /******************************************************************************
3 * Module Name: utcopy - Internal to external object translation utilities
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2008, Intel Corp.
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.
44 #include <acpi/acpi.h>
45 #include <acpi/amlcode.h>
46 #include <acpi/acnamesp.h>
49 #define _COMPONENT ACPI_UTILITIES
50 ACPI_MODULE_NAME("utcopy")
52 /* Local prototypes */
54 acpi_ut_copy_isimple_to_esimple(union acpi_operand_object
*internal_object
,
55 union acpi_object
*external_object
,
56 u8
* data_space
, acpi_size
* buffer_space_used
);
59 acpi_ut_copy_ielement_to_ielement(u8 object_type
,
60 union acpi_operand_object
*source_object
,
61 union acpi_generic_state
*state
,
65 acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object
*internal_object
,
66 u8
* buffer
, acpi_size
* space_used
);
69 acpi_ut_copy_esimple_to_isimple(union acpi_object
*user_obj
,
70 union acpi_operand_object
**return_obj
);
73 acpi_ut_copy_epackage_to_ipackage(union acpi_object
*external_object
,
74 union acpi_operand_object
**internal_object
);
77 acpi_ut_copy_simple_object(union acpi_operand_object
*source_desc
,
78 union acpi_operand_object
*dest_desc
);
81 acpi_ut_copy_ielement_to_eelement(u8 object_type
,
82 union acpi_operand_object
*source_object
,
83 union acpi_generic_state
*state
,
87 acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object
*source_obj
,
88 union acpi_operand_object
*dest_obj
,
89 struct acpi_walk_state
*walk_state
);
91 /*******************************************************************************
93 * FUNCTION: acpi_ut_copy_isimple_to_esimple
95 * PARAMETERS: internal_object - Source object to be copied
96 * external_object - Where to return the copied object
97 * data_space - Where object data is returned (such as
98 * buffer and string data)
99 * buffer_space_used - Length of data_space that was used
103 * DESCRIPTION: This function is called to copy a simple internal object to
104 * an external object.
106 * The data_space buffer is assumed to have sufficient space for
109 ******************************************************************************/
112 acpi_ut_copy_isimple_to_esimple(union acpi_operand_object
*internal_object
,
113 union acpi_object
*external_object
,
114 u8
* data_space
, acpi_size
* buffer_space_used
)
116 acpi_status status
= AE_OK
;
118 ACPI_FUNCTION_TRACE(ut_copy_isimple_to_esimple
);
120 *buffer_space_used
= 0;
123 * Check for NULL object case (could be an uninitialized
126 if (!internal_object
) {
127 return_ACPI_STATUS(AE_OK
);
130 /* Always clear the external object */
132 ACPI_MEMSET(external_object
, 0, sizeof(union acpi_object
));
135 * In general, the external object will be the same type as
136 * the internal object
138 external_object
->type
= ACPI_GET_OBJECT_TYPE(internal_object
);
140 /* However, only a limited number of external types are supported */
142 switch (ACPI_GET_OBJECT_TYPE(internal_object
)) {
143 case ACPI_TYPE_STRING
:
145 external_object
->string
.pointer
= (char *)data_space
;
146 external_object
->string
.length
= internal_object
->string
.length
;
147 *buffer_space_used
= ACPI_ROUND_UP_TO_NATIVE_WORD((acpi_size
)
152 ACPI_MEMCPY((void *)data_space
,
153 (void *)internal_object
->string
.pointer
,
154 (acpi_size
) internal_object
->string
.length
+ 1);
157 case ACPI_TYPE_BUFFER
:
159 external_object
->buffer
.pointer
= data_space
;
160 external_object
->buffer
.length
= internal_object
->buffer
.length
;
162 ACPI_ROUND_UP_TO_NATIVE_WORD(internal_object
->string
.
165 ACPI_MEMCPY((void *)data_space
,
166 (void *)internal_object
->buffer
.pointer
,
167 internal_object
->buffer
.length
);
170 case ACPI_TYPE_INTEGER
:
172 external_object
->integer
.value
= internal_object
->integer
.value
;
175 case ACPI_TYPE_LOCAL_REFERENCE
:
177 /* This is an object reference. */
179 switch (internal_object
->reference
.opcode
) {
180 case AML_INT_NAMEPATH_OP
:
182 /* For namepath, return the object handle ("reference") */
186 /* We are referring to the namespace node */
188 external_object
->reference
.handle
=
189 internal_object
->reference
.node
;
190 external_object
->reference
.actual_type
=
191 acpi_ns_get_type(internal_object
->reference
.node
);
196 case ACPI_TYPE_PROCESSOR
:
198 external_object
->processor
.proc_id
=
199 internal_object
->processor
.proc_id
;
200 external_object
->processor
.pblk_address
=
201 internal_object
->processor
.address
;
202 external_object
->processor
.pblk_length
=
203 internal_object
->processor
.length
;
206 case ACPI_TYPE_POWER
:
208 external_object
->power_resource
.system_level
=
209 internal_object
->power_resource
.system_level
;
211 external_object
->power_resource
.resource_order
=
212 internal_object
->power_resource
.resource_order
;
217 * There is no corresponding external object type
220 "Unsupported object type, cannot convert to external object: %s",
221 acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE
222 (internal_object
))));
224 return_ACPI_STATUS(AE_SUPPORT
);
227 return_ACPI_STATUS(status
);
230 /*******************************************************************************
232 * FUNCTION: acpi_ut_copy_ielement_to_eelement
234 * PARAMETERS: acpi_pkg_callback
238 * DESCRIPTION: Copy one package element to another package element
240 ******************************************************************************/
243 acpi_ut_copy_ielement_to_eelement(u8 object_type
,
244 union acpi_operand_object
*source_object
,
245 union acpi_generic_state
*state
,
248 acpi_status status
= AE_OK
;
249 struct acpi_pkg_info
*info
= (struct acpi_pkg_info
*)context
;
250 acpi_size object_space
;
252 union acpi_object
*target_object
;
254 ACPI_FUNCTION_ENTRY();
256 this_index
= state
->pkg
.index
;
257 target_object
= (union acpi_object
*)
258 &((union acpi_object
*)(state
->pkg
.dest_object
))->package
.
259 elements
[this_index
];
261 switch (object_type
) {
262 case ACPI_COPY_TYPE_SIMPLE
:
265 * This is a simple or null object
267 status
= acpi_ut_copy_isimple_to_esimple(source_object
,
271 if (ACPI_FAILURE(status
)) {
276 case ACPI_COPY_TYPE_PACKAGE
:
279 * Build the package object
281 target_object
->type
= ACPI_TYPE_PACKAGE
;
282 target_object
->package
.count
= source_object
->package
.count
;
283 target_object
->package
.elements
=
284 ACPI_CAST_PTR(union acpi_object
, info
->free_space
);
287 * Pass the new package object back to the package walk routine
289 state
->pkg
.this_target_obj
= target_object
;
292 * Save space for the array of objects (Package elements)
293 * update the buffer length counter
295 object_space
= ACPI_ROUND_UP_TO_NATIVE_WORD((acpi_size
)
303 return (AE_BAD_PARAMETER
);
306 info
->free_space
+= object_space
;
307 info
->length
+= object_space
;
311 /*******************************************************************************
313 * FUNCTION: acpi_ut_copy_ipackage_to_epackage
315 * PARAMETERS: internal_object - Pointer to the object we are returning
316 * Buffer - Where the object is returned
317 * space_used - Where the object length is returned
321 * DESCRIPTION: This function is called to place a package object in a user
322 * buffer. A package object by definition contains other objects.
324 * The buffer is assumed to have sufficient space for the object.
325 * The caller must have verified the buffer length needed using the
326 * acpi_ut_get_object_size function before calling this function.
328 ******************************************************************************/
331 acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object
*internal_object
,
332 u8
* buffer
, acpi_size
* space_used
)
334 union acpi_object
*external_object
;
336 struct acpi_pkg_info info
;
338 ACPI_FUNCTION_TRACE(ut_copy_ipackage_to_epackage
);
341 * First package at head of the buffer
343 external_object
= ACPI_CAST_PTR(union acpi_object
, buffer
);
346 * Free space begins right after the first package
348 info
.length
= ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object
));
350 buffer
+ ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object
));
351 info
.object_space
= 0;
352 info
.num_packages
= 1;
354 external_object
->type
= ACPI_GET_OBJECT_TYPE(internal_object
);
355 external_object
->package
.count
= internal_object
->package
.count
;
356 external_object
->package
.elements
= ACPI_CAST_PTR(union acpi_object
,
360 * Leave room for an array of ACPI_OBJECTS in the buffer
361 * and move the free space past it
363 info
.length
+= (acpi_size
) external_object
->package
.count
*
364 ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object
));
365 info
.free_space
+= external_object
->package
.count
*
366 ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object
));
368 status
= acpi_ut_walk_package_tree(internal_object
, external_object
,
369 acpi_ut_copy_ielement_to_eelement
,
372 *space_used
= info
.length
;
373 return_ACPI_STATUS(status
);
376 /*******************************************************************************
378 * FUNCTION: acpi_ut_copy_iobject_to_eobject
380 * PARAMETERS: internal_object - The internal object to be converted
381 * buffer_ptr - Where the object is returned
385 * DESCRIPTION: This function is called to build an API object to be returned to
388 ******************************************************************************/
391 acpi_ut_copy_iobject_to_eobject(union acpi_operand_object
*internal_object
,
392 struct acpi_buffer
*ret_buffer
)
396 ACPI_FUNCTION_TRACE(ut_copy_iobject_to_eobject
);
398 if (ACPI_GET_OBJECT_TYPE(internal_object
) == ACPI_TYPE_PACKAGE
) {
400 * Package object: Copy all subobjects (including
403 status
= acpi_ut_copy_ipackage_to_epackage(internal_object
,
405 &ret_buffer
->length
);
408 * Build a simple object (no nested objects)
410 status
= acpi_ut_copy_isimple_to_esimple(internal_object
,
418 ACPI_ROUND_UP_TO_NATIVE_WORD
422 &ret_buffer
->length
);
424 * build simple does not include the object size in the length
425 * so we add it in here
427 ret_buffer
->length
+= sizeof(union acpi_object
);
430 return_ACPI_STATUS(status
);
433 /*******************************************************************************
435 * FUNCTION: acpi_ut_copy_esimple_to_isimple
437 * PARAMETERS: external_object - The external object to be converted
438 * ret_internal_object - Where the internal object is returned
442 * DESCRIPTION: This function copies an external object to an internal one.
443 * NOTE: Pointers can be copied, we don't need to copy data.
444 * (The pointers have to be valid in our address space no matter
445 * what we do with them!)
447 ******************************************************************************/
450 acpi_ut_copy_esimple_to_isimple(union acpi_object
*external_object
,
451 union acpi_operand_object
**ret_internal_object
)
453 union acpi_operand_object
*internal_object
;
455 ACPI_FUNCTION_TRACE(ut_copy_esimple_to_isimple
);
458 * Simple types supported are: String, Buffer, Integer
460 switch (external_object
->type
) {
461 case ACPI_TYPE_STRING
:
462 case ACPI_TYPE_BUFFER
:
463 case ACPI_TYPE_INTEGER
:
464 case ACPI_TYPE_LOCAL_REFERENCE
:
466 internal_object
= acpi_ut_create_internal_object((u8
)
469 if (!internal_object
) {
470 return_ACPI_STATUS(AE_NO_MEMORY
);
474 case ACPI_TYPE_ANY
: /* This is the case for a NULL object */
476 *ret_internal_object
= NULL
;
477 return_ACPI_STATUS(AE_OK
);
480 /* All other types are not supported */
483 "Unsupported object type, cannot convert to internal object: %s",
484 acpi_ut_get_type_name(external_object
->type
)));
486 return_ACPI_STATUS(AE_SUPPORT
);
489 /* Must COPY string and buffer contents */
491 switch (external_object
->type
) {
492 case ACPI_TYPE_STRING
:
494 internal_object
->string
.pointer
=
495 ACPI_ALLOCATE_ZEROED((acpi_size
) external_object
->string
.
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
;
508 case ACPI_TYPE_BUFFER
:
510 internal_object
->buffer
.pointer
=
511 ACPI_ALLOCATE_ZEROED(external_object
->buffer
.length
);
512 if (!internal_object
->buffer
.pointer
) {
516 ACPI_MEMCPY(internal_object
->buffer
.pointer
,
517 external_object
->buffer
.pointer
,
518 external_object
->buffer
.length
);
520 internal_object
->buffer
.length
= external_object
->buffer
.length
;
522 /* Mark buffer data valid */
524 internal_object
->buffer
.flags
|= AOPOBJ_DATA_VALID
;
527 case ACPI_TYPE_INTEGER
:
529 internal_object
->integer
.value
= external_object
->integer
.value
;
532 case ACPI_TYPE_LOCAL_REFERENCE
:
534 /* TBD: should validate incoming handle */
536 internal_object
->reference
.opcode
= AML_INT_NAMEPATH_OP
;
537 internal_object
->reference
.node
=
538 external_object
->reference
.handle
;
542 /* Other types can't get here */
546 *ret_internal_object
= internal_object
;
547 return_ACPI_STATUS(AE_OK
);
550 acpi_ut_remove_reference(internal_object
);
551 return_ACPI_STATUS(AE_NO_MEMORY
);
554 /*******************************************************************************
556 * FUNCTION: acpi_ut_copy_epackage_to_ipackage
558 * PARAMETERS: external_object - The external object to be converted
559 * internal_object - Where the internal object is returned
563 * DESCRIPTION: Copy an external package object to an internal package.
564 * Handles nested packages.
566 ******************************************************************************/
569 acpi_ut_copy_epackage_to_ipackage(union acpi_object
*external_object
,
570 union acpi_operand_object
**internal_object
)
572 acpi_status status
= AE_OK
;
573 union acpi_operand_object
*package_object
;
574 union acpi_operand_object
**package_elements
;
577 ACPI_FUNCTION_TRACE(ut_copy_epackage_to_ipackage
);
579 /* Create the package object */
582 acpi_ut_create_package_object(external_object
->package
.count
);
583 if (!package_object
) {
584 return_ACPI_STATUS(AE_NO_MEMORY
);
587 package_elements
= package_object
->package
.elements
;
590 * Recursive implementation. Probably ok, since nested external packages
591 * as parameters should be very rare.
593 for (i
= 0; i
< external_object
->package
.count
; i
++) {
595 acpi_ut_copy_eobject_to_iobject(&external_object
->package
.
597 &package_elements
[i
]);
598 if (ACPI_FAILURE(status
)) {
600 /* Truncate package and delete it */
602 package_object
->package
.count
= (u32
) i
;
603 package_elements
[i
] = NULL
;
604 acpi_ut_remove_reference(package_object
);
605 return_ACPI_STATUS(status
);
609 /* Mark package data valid */
611 package_object
->package
.flags
|= AOPOBJ_DATA_VALID
;
613 *internal_object
= package_object
;
614 return_ACPI_STATUS(status
);
617 /*******************************************************************************
619 * FUNCTION: acpi_ut_copy_eobject_to_iobject
621 * PARAMETERS: external_object - The external object to be converted
622 * internal_object - Where the internal object is returned
624 * RETURN: Status - the status of the call
626 * DESCRIPTION: Converts an external object to an internal object.
628 ******************************************************************************/
631 acpi_ut_copy_eobject_to_iobject(union acpi_object
*external_object
,
632 union acpi_operand_object
**internal_object
)
636 ACPI_FUNCTION_TRACE(ut_copy_eobject_to_iobject
);
638 if (external_object
->type
== ACPI_TYPE_PACKAGE
) {
640 acpi_ut_copy_epackage_to_ipackage(external_object
,
644 * Build a simple object (no nested objects)
647 acpi_ut_copy_esimple_to_isimple(external_object
,
651 return_ACPI_STATUS(status
);
654 /*******************************************************************************
656 * FUNCTION: acpi_ut_copy_simple_object
658 * PARAMETERS: source_desc - The internal object to be copied
659 * dest_desc - New target object
663 * DESCRIPTION: Simple copy of one internal object to another. Reference count
664 * of the destination object is preserved.
666 ******************************************************************************/
669 acpi_ut_copy_simple_object(union acpi_operand_object
*source_desc
,
670 union acpi_operand_object
*dest_desc
)
673 union acpi_operand_object
*next_object
;
675 /* Save fields from destination that we don't want to overwrite */
677 reference_count
= dest_desc
->common
.reference_count
;
678 next_object
= dest_desc
->common
.next_object
;
680 /* Copy the entire source object over the destination object */
682 ACPI_MEMCPY((char *)dest_desc
, (char *)source_desc
,
683 sizeof(union acpi_operand_object
));
685 /* Restore the saved fields */
687 dest_desc
->common
.reference_count
= reference_count
;
688 dest_desc
->common
.next_object
= next_object
;
690 /* New object is not static, regardless of source */
692 dest_desc
->common
.flags
&= ~AOPOBJ_STATIC_POINTER
;
694 /* Handle the objects with extra data */
696 switch (ACPI_GET_OBJECT_TYPE(dest_desc
)) {
697 case ACPI_TYPE_BUFFER
:
699 * Allocate and copy the actual buffer if and only if:
700 * 1) There is a valid buffer pointer
701 * 2) The buffer has a length > 0
703 if ((source_desc
->buffer
.pointer
) &&
704 (source_desc
->buffer
.length
)) {
705 dest_desc
->buffer
.pointer
=
706 ACPI_ALLOCATE(source_desc
->buffer
.length
);
707 if (!dest_desc
->buffer
.pointer
) {
708 return (AE_NO_MEMORY
);
711 /* Copy the actual buffer data */
713 ACPI_MEMCPY(dest_desc
->buffer
.pointer
,
714 source_desc
->buffer
.pointer
,
715 source_desc
->buffer
.length
);
719 case ACPI_TYPE_STRING
:
721 * Allocate and copy the actual string if and only if:
722 * 1) There is a valid string pointer
723 * (Pointer to a NULL string is allowed)
725 if (source_desc
->string
.pointer
) {
726 dest_desc
->string
.pointer
=
727 ACPI_ALLOCATE((acpi_size
) source_desc
->string
.
729 if (!dest_desc
->string
.pointer
) {
730 return (AE_NO_MEMORY
);
733 /* Copy the actual string data */
735 ACPI_MEMCPY(dest_desc
->string
.pointer
,
736 source_desc
->string
.pointer
,
737 (acpi_size
) source_desc
->string
.length
+ 1);
741 case ACPI_TYPE_LOCAL_REFERENCE
:
743 * We copied the reference object, so we now must add a reference
744 * to the object pointed to by the reference
746 * DDBHandle reference (from Load/load_table is a special reference,
747 * it's Reference.Object is the table index, so does not need to
748 * increase the reference count
750 if (source_desc
->reference
.opcode
== AML_LOAD_OP
) {
754 acpi_ut_add_reference(source_desc
->reference
.object
);
757 case ACPI_TYPE_REGION
:
759 * We copied the Region Handler, so we now must add a reference
761 if (dest_desc
->region
.handler
) {
762 acpi_ut_add_reference(dest_desc
->region
.handler
);
767 /* Nothing to do for other simple objects */
774 /*******************************************************************************
776 * FUNCTION: acpi_ut_copy_ielement_to_ielement
778 * PARAMETERS: acpi_pkg_callback
782 * DESCRIPTION: Copy one package element to another package element
784 ******************************************************************************/
787 acpi_ut_copy_ielement_to_ielement(u8 object_type
,
788 union acpi_operand_object
*source_object
,
789 union acpi_generic_state
*state
,
792 acpi_status status
= AE_OK
;
794 union acpi_operand_object
**this_target_ptr
;
795 union acpi_operand_object
*target_object
;
797 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
813 acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE
815 if (!target_object
) {
816 return (AE_NO_MEMORY
);
820 acpi_ut_copy_simple_object(source_object
,
822 if (ACPI_FAILURE(status
)) {
826 *this_target_ptr
= target_object
;
828 /* Pass through a null element */
830 *this_target_ptr
= NULL
;
834 case ACPI_COPY_TYPE_PACKAGE
:
837 * This object is a package - go down another nesting level
838 * Create and build the package object
841 acpi_ut_create_package_object(source_object
->package
.count
);
842 if (!target_object
) {
843 return (AE_NO_MEMORY
);
846 target_object
->common
.flags
= source_object
->common
.flags
;
848 /* Pass the new package object back to the package walk routine */
850 state
->pkg
.this_target_obj
= target_object
;
852 /* Store the object pointer in the parent package object */
854 *this_target_ptr
= target_object
;
858 return (AE_BAD_PARAMETER
);
864 acpi_ut_remove_reference(target_object
);
868 /*******************************************************************************
870 * FUNCTION: acpi_ut_copy_ipackage_to_ipackage
872 * PARAMETERS: *source_obj - Pointer to the source package object
873 * *dest_obj - Where the internal object is returned
875 * RETURN: Status - the status of the call
877 * DESCRIPTION: This function is called to copy an internal package object
878 * into another internal package object.
880 ******************************************************************************/
883 acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object
*source_obj
,
884 union acpi_operand_object
*dest_obj
,
885 struct acpi_walk_state
*walk_state
)
887 acpi_status status
= AE_OK
;
889 ACPI_FUNCTION_TRACE(ut_copy_ipackage_to_ipackage
);
891 dest_obj
->common
.type
= ACPI_GET_OBJECT_TYPE(source_obj
);
892 dest_obj
->common
.flags
= source_obj
->common
.flags
;
893 dest_obj
->package
.count
= source_obj
->package
.count
;
896 * Create the object array and walk the source package tree
898 dest_obj
->package
.elements
= ACPI_ALLOCATE_ZEROED(((acpi_size
)
901 1) * sizeof(void *));
902 if (!dest_obj
->package
.elements
) {
903 ACPI_ERROR((AE_INFO
, "Package allocation failure"));
904 return_ACPI_STATUS(AE_NO_MEMORY
);
908 * Copy the package element-by-element by walking the package "tree".
909 * This handles nested packages of arbitrary depth.
911 status
= acpi_ut_walk_package_tree(source_obj
, dest_obj
,
912 acpi_ut_copy_ielement_to_ielement
,
914 if (ACPI_FAILURE(status
)) {
916 /* On failure, delete the destination package object */
918 acpi_ut_remove_reference(dest_obj
);
921 return_ACPI_STATUS(status
);
924 /*******************************************************************************
926 * FUNCTION: acpi_ut_copy_iobject_to_iobject
928 * PARAMETERS: walk_state - Current walk state
929 * source_desc - The internal object to be copied
930 * dest_desc - Where the copied object is returned
934 * DESCRIPTION: Copy an internal object to a new internal object
936 ******************************************************************************/
939 acpi_ut_copy_iobject_to_iobject(union acpi_operand_object
*source_desc
,
940 union acpi_operand_object
**dest_desc
,
941 struct acpi_walk_state
*walk_state
)
943 acpi_status status
= AE_OK
;
945 ACPI_FUNCTION_TRACE(ut_copy_iobject_to_iobject
);
947 /* Create the top level object */
950 acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE(source_desc
));
952 return_ACPI_STATUS(AE_NO_MEMORY
);
955 /* Copy the object and possible subobjects */
957 if (ACPI_GET_OBJECT_TYPE(source_desc
) == ACPI_TYPE_PACKAGE
) {
959 acpi_ut_copy_ipackage_to_ipackage(source_desc
, *dest_desc
,
962 status
= acpi_ut_copy_simple_object(source_desc
, *dest_desc
);
965 return_ACPI_STATUS(status
);