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/acnamesp.h>
 
  48 #define _COMPONENT          ACPI_UTILITIES
 
  49 ACPI_MODULE_NAME("utcopy")
 
  51 /* Local prototypes */
 
  53 acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
 
  54                                 union acpi_object *external_object,
 
  55                                 u8 * data_space, acpi_size * buffer_space_used);
 
  58 acpi_ut_copy_ielement_to_ielement(u8 object_type,
 
  59                                   union acpi_operand_object *source_object,
 
  60                                   union acpi_generic_state *state,
 
  64 acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object,
 
  65                                   u8 * buffer, acpi_size * space_used);
 
  68 acpi_ut_copy_esimple_to_isimple(union acpi_object *user_obj,
 
  69                                 union acpi_operand_object **return_obj);
 
  72 acpi_ut_copy_epackage_to_ipackage(union acpi_object *external_object,
 
  73                                   union acpi_operand_object **internal_object);
 
  76 acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
 
  77                            union acpi_operand_object *dest_desc);
 
  80 acpi_ut_copy_ielement_to_eelement(u8 object_type,
 
  81                                   union acpi_operand_object *source_object,
 
  82                                   union acpi_generic_state *state,
 
  86 acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
 
  87                                   union acpi_operand_object *dest_obj,
 
  88                                   struct acpi_walk_state *walk_state);
 
  90 /*******************************************************************************
 
  92  * FUNCTION:    acpi_ut_copy_isimple_to_esimple
 
  94  * PARAMETERS:  internal_object     - Source object to be copied
 
  95  *              external_object     - Where to return the copied object
 
  96  *              data_space          - Where object data is returned (such as
 
  97  *                                    buffer and string data)
 
  98  *              buffer_space_used   - Length of data_space that was used
 
 102  * DESCRIPTION: This function is called to copy a simple internal object to
 
 103  *              an external object.
 
 105  *              The data_space buffer is assumed to have sufficient space for
 
 108  ******************************************************************************/
 
 111 acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
 
 112                                 union acpi_object *external_object,
 
 113                                 u8 * data_space, acpi_size * buffer_space_used)
 
 115         acpi_status status = AE_OK;
 
 117         ACPI_FUNCTION_TRACE(ut_copy_isimple_to_esimple);
 
 119         *buffer_space_used = 0;
 
 122          * Check for NULL object case (could be an uninitialized
 
 125         if (!internal_object) {
 
 126                 return_ACPI_STATUS(AE_OK);
 
 129         /* Always clear the external object */
 
 131         ACPI_MEMSET(external_object, 0, sizeof(union acpi_object));
 
 134          * In general, the external object will be the same type as
 
 135          * the internal object
 
 137         external_object->type = ACPI_GET_OBJECT_TYPE(internal_object);
 
 139         /* However, only a limited number of external types are supported */
 
 141         switch (ACPI_GET_OBJECT_TYPE(internal_object)) {
 
 142         case ACPI_TYPE_STRING:
 
 144                 external_object->string.pointer = (char *)data_space;
 
 145                 external_object->string.length = internal_object->string.length;
 
 146                 *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD((acpi_size)
 
 151                 ACPI_MEMCPY((void *)data_space,
 
 152                             (void *)internal_object->string.pointer,
 
 153                             (acpi_size) internal_object->string.length + 1);
 
 156         case ACPI_TYPE_BUFFER:
 
 158                 external_object->buffer.pointer = data_space;
 
 159                 external_object->buffer.length = internal_object->buffer.length;
 
 161                     ACPI_ROUND_UP_TO_NATIVE_WORD(internal_object->string.
 
 164                 ACPI_MEMCPY((void *)data_space,
 
 165                             (void *)internal_object->buffer.pointer,
 
 166                             internal_object->buffer.length);
 
 169         case ACPI_TYPE_INTEGER:
 
 171                 external_object->integer.value = internal_object->integer.value;
 
 174         case ACPI_TYPE_LOCAL_REFERENCE:
 
 176                 /* This is an object reference. */
 
 178                 switch (internal_object->reference.class) {
 
 179                 case ACPI_REFCLASS_NAME:
 
 182                          * For namepath, return the object handle ("reference")
 
 183                          * We are referring to the namespace node
 
 185                         external_object->reference.handle =
 
 186                             internal_object->reference.node;
 
 187                         external_object->reference.actual_type =
 
 188                             acpi_ns_get_type(internal_object->reference.node);
 
 193                         /* All other reference types are unsupported */
 
 195                         return_ACPI_STATUS(AE_TYPE);
 
 199         case ACPI_TYPE_PROCESSOR:
 
 201                 external_object->processor.proc_id =
 
 202                     internal_object->processor.proc_id;
 
 203                 external_object->processor.pblk_address =
 
 204                     internal_object->processor.address;
 
 205                 external_object->processor.pblk_length =
 
 206                     internal_object->processor.length;
 
 209         case ACPI_TYPE_POWER:
 
 211                 external_object->power_resource.system_level =
 
 212                     internal_object->power_resource.system_level;
 
 214                 external_object->power_resource.resource_order =
 
 215                     internal_object->power_resource.resource_order;
 
 220                  * There is no corresponding external object type
 
 223                             "Unsupported object type, cannot convert to external object: %s",
 
 224                             acpi_ut_get_type_name(ACPI_GET_OBJECT_TYPE
 
 225                                                   (internal_object))));
 
 227                 return_ACPI_STATUS(AE_SUPPORT);
 
 230         return_ACPI_STATUS(status);
 
 233 /*******************************************************************************
 
 235  * FUNCTION:    acpi_ut_copy_ielement_to_eelement
 
 237  * PARAMETERS:  acpi_pkg_callback
 
 241  * DESCRIPTION: Copy one package element to another package element
 
 243  ******************************************************************************/
 
 246 acpi_ut_copy_ielement_to_eelement(u8 object_type,
 
 247                                   union acpi_operand_object *source_object,
 
 248                                   union acpi_generic_state *state,
 
 251         acpi_status status = AE_OK;
 
 252         struct acpi_pkg_info *info = (struct acpi_pkg_info *)context;
 
 253         acpi_size object_space;
 
 255         union acpi_object *target_object;
 
 257         ACPI_FUNCTION_ENTRY();
 
 259         this_index = state->pkg.index;
 
 260         target_object = (union acpi_object *)
 
 261             &((union acpi_object *)(state->pkg.dest_object))->package.
 
 262             elements[this_index];
 
 264         switch (object_type) {
 
 265         case ACPI_COPY_TYPE_SIMPLE:
 
 268                  * This is a simple or null object
 
 270                 status = acpi_ut_copy_isimple_to_esimple(source_object,
 
 274                 if (ACPI_FAILURE(status)) {
 
 279         case ACPI_COPY_TYPE_PACKAGE:
 
 282                  * Build the package object
 
 284                 target_object->type = ACPI_TYPE_PACKAGE;
 
 285                 target_object->package.count = source_object->package.count;
 
 286                 target_object->package.elements =
 
 287                     ACPI_CAST_PTR(union acpi_object, info->free_space);
 
 290                  * Pass the new package object back to the package walk routine
 
 292                 state->pkg.this_target_obj = target_object;
 
 295                  * Save space for the array of objects (Package elements)
 
 296                  * update the buffer length counter
 
 298                 object_space = ACPI_ROUND_UP_TO_NATIVE_WORD((acpi_size)
 
 306                 return (AE_BAD_PARAMETER);
 
 309         info->free_space += object_space;
 
 310         info->length += object_space;
 
 314 /*******************************************************************************
 
 316  * FUNCTION:    acpi_ut_copy_ipackage_to_epackage
 
 318  * PARAMETERS:  internal_object     - Pointer to the object we are returning
 
 319  *              Buffer              - Where the object is returned
 
 320  *              space_used          - Where the object length is returned
 
 324  * DESCRIPTION: This function is called to place a package object in a user
 
 325  *              buffer.  A package object by definition contains other objects.
 
 327  *              The buffer is assumed to have sufficient space for the object.
 
 328  *              The caller must have verified the buffer length needed using the
 
 329  *              acpi_ut_get_object_size function before calling this function.
 
 331  ******************************************************************************/
 
 334 acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object,
 
 335                                   u8 * buffer, acpi_size * space_used)
 
 337         union acpi_object *external_object;
 
 339         struct acpi_pkg_info info;
 
 341         ACPI_FUNCTION_TRACE(ut_copy_ipackage_to_epackage);
 
 344          * First package at head of the buffer
 
 346         external_object = ACPI_CAST_PTR(union acpi_object, buffer);
 
 349          * Free space begins right after the first package
 
 351         info.length = ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
 
 353             buffer + ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
 
 354         info.object_space = 0;
 
 355         info.num_packages = 1;
 
 357         external_object->type = ACPI_GET_OBJECT_TYPE(internal_object);
 
 358         external_object->package.count = internal_object->package.count;
 
 359         external_object->package.elements = ACPI_CAST_PTR(union acpi_object,
 
 363          * Leave room for an array of ACPI_OBJECTS in the buffer
 
 364          * and move the free space past it
 
 366         info.length += (acpi_size) external_object->package.count *
 
 367             ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
 
 368         info.free_space += external_object->package.count *
 
 369             ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
 
 371         status = acpi_ut_walk_package_tree(internal_object, external_object,
 
 372                                            acpi_ut_copy_ielement_to_eelement,
 
 375         *space_used = info.length;
 
 376         return_ACPI_STATUS(status);
 
 379 /*******************************************************************************
 
 381  * FUNCTION:    acpi_ut_copy_iobject_to_eobject
 
 383  * PARAMETERS:  internal_object     - The internal object to be converted
 
 384  *              buffer_ptr          - Where the object is returned
 
 388  * DESCRIPTION: This function is called to build an API object to be returned to
 
 391  ******************************************************************************/
 
 394 acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *internal_object,
 
 395                                 struct acpi_buffer *ret_buffer)
 
 399         ACPI_FUNCTION_TRACE(ut_copy_iobject_to_eobject);
 
 401         if (ACPI_GET_OBJECT_TYPE(internal_object) == ACPI_TYPE_PACKAGE) {
 
 403                  * Package object:  Copy all subobjects (including
 
 406                 status = acpi_ut_copy_ipackage_to_epackage(internal_object,
 
 408                                                            &ret_buffer->length);
 
 411                  * Build a simple object (no nested objects)
 
 413                 status = acpi_ut_copy_isimple_to_esimple(internal_object,
 
 421                                                                       ACPI_ROUND_UP_TO_NATIVE_WORD
 
 425                                                          &ret_buffer->length);
 
 427                  * build simple does not include the object size in the length
 
 428                  * so we add it in here
 
 430                 ret_buffer->length += sizeof(union acpi_object);
 
 433         return_ACPI_STATUS(status);
 
 436 /*******************************************************************************
 
 438  * FUNCTION:    acpi_ut_copy_esimple_to_isimple
 
 440  * PARAMETERS:  external_object     - The external object to be converted
 
 441  *              ret_internal_object - Where the internal object is returned
 
 445  * DESCRIPTION: This function copies an external object to an internal one.
 
 446  *              NOTE: Pointers can be copied, we don't need to copy data.
 
 447  *              (The pointers have to be valid in our address space no matter
 
 448  *              what we do with them!)
 
 450  ******************************************************************************/
 
 453 acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object,
 
 454                                 union acpi_operand_object **ret_internal_object)
 
 456         union acpi_operand_object *internal_object;
 
 458         ACPI_FUNCTION_TRACE(ut_copy_esimple_to_isimple);
 
 461          * Simple types supported are: String, Buffer, Integer
 
 463         switch (external_object->type) {
 
 464         case ACPI_TYPE_STRING:
 
 465         case ACPI_TYPE_BUFFER:
 
 466         case ACPI_TYPE_INTEGER:
 
 467         case ACPI_TYPE_LOCAL_REFERENCE:
 
 469                 internal_object = acpi_ut_create_internal_object((u8)
 
 472                 if (!internal_object) {
 
 473                         return_ACPI_STATUS(AE_NO_MEMORY);
 
 477         case ACPI_TYPE_ANY:     /* This is the case for a NULL object */
 
 479                 *ret_internal_object = NULL;
 
 480                 return_ACPI_STATUS(AE_OK);
 
 483                 /* All other types are not supported */
 
 486                             "Unsupported object type, cannot convert to internal object: %s",
 
 487                             acpi_ut_get_type_name(external_object->type)));
 
 489                 return_ACPI_STATUS(AE_SUPPORT);
 
 492         /* Must COPY string and buffer contents */
 
 494         switch (external_object->type) {
 
 495         case ACPI_TYPE_STRING:
 
 497                 internal_object->string.pointer =
 
 498                     ACPI_ALLOCATE_ZEROED((acpi_size) external_object->string.
 
 500                 if (!internal_object->string.pointer) {
 
 504                 ACPI_MEMCPY(internal_object->string.pointer,
 
 505                             external_object->string.pointer,
 
 506                             external_object->string.length);
 
 508                 internal_object->string.length = external_object->string.length;
 
 511         case ACPI_TYPE_BUFFER:
 
 513                 internal_object->buffer.pointer =
 
 514                     ACPI_ALLOCATE_ZEROED(external_object->buffer.length);
 
 515                 if (!internal_object->buffer.pointer) {
 
 519                 ACPI_MEMCPY(internal_object->buffer.pointer,
 
 520                             external_object->buffer.pointer,
 
 521                             external_object->buffer.length);
 
 523                 internal_object->buffer.length = external_object->buffer.length;
 
 525                 /* Mark buffer data valid */
 
 527                 internal_object->buffer.flags |= AOPOBJ_DATA_VALID;
 
 530         case ACPI_TYPE_INTEGER:
 
 532                 internal_object->integer.value = external_object->integer.value;
 
 535         case ACPI_TYPE_LOCAL_REFERENCE:
 
 537                 /* TBD: should validate incoming handle */
 
 539                 internal_object->reference.class = ACPI_REFCLASS_NAME;
 
 540                 internal_object->reference.node =
 
 541                     external_object->reference.handle;
 
 545                 /* Other types can't get here */
 
 549         *ret_internal_object = internal_object;
 
 550         return_ACPI_STATUS(AE_OK);
 
 553         acpi_ut_remove_reference(internal_object);
 
 554         return_ACPI_STATUS(AE_NO_MEMORY);
 
 557 /*******************************************************************************
 
 559  * FUNCTION:    acpi_ut_copy_epackage_to_ipackage
 
 561  * PARAMETERS:  external_object     - The external object to be converted
 
 562  *              internal_object     - Where the internal object is returned
 
 566  * DESCRIPTION: Copy an external package object to an internal package.
 
 567  *              Handles nested packages.
 
 569  ******************************************************************************/
 
 572 acpi_ut_copy_epackage_to_ipackage(union acpi_object *external_object,
 
 573                                   union acpi_operand_object **internal_object)
 
 575         acpi_status status = AE_OK;
 
 576         union acpi_operand_object *package_object;
 
 577         union acpi_operand_object **package_elements;
 
 580         ACPI_FUNCTION_TRACE(ut_copy_epackage_to_ipackage);
 
 582         /* Create the package object */
 
 585             acpi_ut_create_package_object(external_object->package.count);
 
 586         if (!package_object) {
 
 587                 return_ACPI_STATUS(AE_NO_MEMORY);
 
 590         package_elements = package_object->package.elements;
 
 593          * Recursive implementation. Probably ok, since nested external packages
 
 594          * as parameters should be very rare.
 
 596         for (i = 0; i < external_object->package.count; i++) {
 
 598                     acpi_ut_copy_eobject_to_iobject(&external_object->package.
 
 600                                                     &package_elements[i]);
 
 601                 if (ACPI_FAILURE(status)) {
 
 603                         /* Truncate package and delete it */
 
 605                         package_object->package.count = i;
 
 606                         package_elements[i] = NULL;
 
 607                         acpi_ut_remove_reference(package_object);
 
 608                         return_ACPI_STATUS(status);
 
 612         /* Mark package data valid */
 
 614         package_object->package.flags |= AOPOBJ_DATA_VALID;
 
 616         *internal_object = package_object;
 
 617         return_ACPI_STATUS(status);
 
 620 /*******************************************************************************
 
 622  * FUNCTION:    acpi_ut_copy_eobject_to_iobject
 
 624  * PARAMETERS:  external_object     - The external object to be converted
 
 625  *              internal_object     - Where the internal object is returned
 
 627  * RETURN:      Status              - the status of the call
 
 629  * DESCRIPTION: Converts an external object to an internal object.
 
 631  ******************************************************************************/
 
 634 acpi_ut_copy_eobject_to_iobject(union acpi_object *external_object,
 
 635                                 union acpi_operand_object **internal_object)
 
 639         ACPI_FUNCTION_TRACE(ut_copy_eobject_to_iobject);
 
 641         if (external_object->type == ACPI_TYPE_PACKAGE) {
 
 643                     acpi_ut_copy_epackage_to_ipackage(external_object,
 
 647                  * Build a simple object (no nested objects)
 
 650                     acpi_ut_copy_esimple_to_isimple(external_object,
 
 654         return_ACPI_STATUS(status);
 
 657 /*******************************************************************************
 
 659  * FUNCTION:    acpi_ut_copy_simple_object
 
 661  * PARAMETERS:  source_desc         - The internal object to be copied
 
 662  *              dest_desc           - New target object
 
 666  * DESCRIPTION: Simple copy of one internal object to another.  Reference count
 
 667  *              of the destination object is preserved.
 
 669  ******************************************************************************/
 
 672 acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
 
 673                            union acpi_operand_object *dest_desc)
 
 676         union acpi_operand_object *next_object;
 
 678         /* Save fields from destination that we don't want to overwrite */
 
 680         reference_count = dest_desc->common.reference_count;
 
 681         next_object = dest_desc->common.next_object;
 
 683         /* Copy the entire source object over the destination object */
 
 685         ACPI_MEMCPY((char *)dest_desc, (char *)source_desc,
 
 686                     sizeof(union acpi_operand_object));
 
 688         /* Restore the saved fields */
 
 690         dest_desc->common.reference_count = reference_count;
 
 691         dest_desc->common.next_object = next_object;
 
 693         /* New object is not static, regardless of source */
 
 695         dest_desc->common.flags &= ~AOPOBJ_STATIC_POINTER;
 
 697         /* Handle the objects with extra data */
 
 699         switch (ACPI_GET_OBJECT_TYPE(dest_desc)) {
 
 700         case ACPI_TYPE_BUFFER:
 
 702                  * Allocate and copy the actual buffer if and only if:
 
 703                  * 1) There is a valid buffer pointer
 
 704                  * 2) The buffer has a length > 0
 
 706                 if ((source_desc->buffer.pointer) &&
 
 707                     (source_desc->buffer.length)) {
 
 708                         dest_desc->buffer.pointer =
 
 709                             ACPI_ALLOCATE(source_desc->buffer.length);
 
 710                         if (!dest_desc->buffer.pointer) {
 
 711                                 return (AE_NO_MEMORY);
 
 714                         /* Copy the actual buffer data */
 
 716                         ACPI_MEMCPY(dest_desc->buffer.pointer,
 
 717                                     source_desc->buffer.pointer,
 
 718                                     source_desc->buffer.length);
 
 722         case ACPI_TYPE_STRING:
 
 724                  * Allocate and copy the actual string if and only if:
 
 725                  * 1) There is a valid string pointer
 
 726                  * (Pointer to a NULL string is allowed)
 
 728                 if (source_desc->string.pointer) {
 
 729                         dest_desc->string.pointer =
 
 730                             ACPI_ALLOCATE((acpi_size) source_desc->string.
 
 732                         if (!dest_desc->string.pointer) {
 
 733                                 return (AE_NO_MEMORY);
 
 736                         /* Copy the actual string data */
 
 738                         ACPI_MEMCPY(dest_desc->string.pointer,
 
 739                                     source_desc->string.pointer,
 
 740                                     (acpi_size) source_desc->string.length + 1);
 
 744         case ACPI_TYPE_LOCAL_REFERENCE:
 
 746                  * We copied the reference object, so we now must add a reference
 
 747                  * to the object pointed to by the reference
 
 749                  * DDBHandle reference (from Load/load_table) is a special reference,
 
 750                  * it does not have a Reference.Object, so does not need to
 
 751                  * increase the reference count
 
 753                 if (source_desc->reference.class == ACPI_REFCLASS_TABLE) {
 
 757                 acpi_ut_add_reference(source_desc->reference.object);
 
 760         case ACPI_TYPE_REGION:
 
 762                  * We copied the Region Handler, so we now must add a reference
 
 764                 if (dest_desc->region.handler) {
 
 765                         acpi_ut_add_reference(dest_desc->region.handler);
 
 770                 /* Nothing to do for other simple objects */
 
 777 /*******************************************************************************
 
 779  * FUNCTION:    acpi_ut_copy_ielement_to_ielement
 
 781  * PARAMETERS:  acpi_pkg_callback
 
 785  * DESCRIPTION: Copy one package element to another package element
 
 787  ******************************************************************************/
 
 790 acpi_ut_copy_ielement_to_ielement(u8 object_type,
 
 791                                   union acpi_operand_object *source_object,
 
 792                                   union acpi_generic_state *state,
 
 795         acpi_status status = AE_OK;
 
 797         union acpi_operand_object **this_target_ptr;
 
 798         union acpi_operand_object *target_object;
 
 800         ACPI_FUNCTION_ENTRY();
 
 802         this_index = state->pkg.index;
 
 803         this_target_ptr = (union acpi_operand_object **)
 
 804             &state->pkg.dest_object->package.elements[this_index];
 
 806         switch (object_type) {
 
 807         case ACPI_COPY_TYPE_SIMPLE:
 
 809                 /* A null source object indicates a (legal) null package element */
 
 813                          * This is a simple object, just copy it
 
 816                             acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE
 
 818                         if (!target_object) {
 
 819                                 return (AE_NO_MEMORY);
 
 823                             acpi_ut_copy_simple_object(source_object,
 
 825                         if (ACPI_FAILURE(status)) {
 
 829                         *this_target_ptr = target_object;
 
 831                         /* Pass through a null element */
 
 833                         *this_target_ptr = NULL;
 
 837         case ACPI_COPY_TYPE_PACKAGE:
 
 840                  * This object is a package - go down another nesting level
 
 841                  * Create and build the package object
 
 844                     acpi_ut_create_package_object(source_object->package.count);
 
 845                 if (!target_object) {
 
 846                         return (AE_NO_MEMORY);
 
 849                 target_object->common.flags = source_object->common.flags;
 
 851                 /* Pass the new package object back to the package walk routine */
 
 853                 state->pkg.this_target_obj = target_object;
 
 855                 /* Store the object pointer in the parent package object */
 
 857                 *this_target_ptr = target_object;
 
 861                 return (AE_BAD_PARAMETER);
 
 867         acpi_ut_remove_reference(target_object);
 
 871 /*******************************************************************************
 
 873  * FUNCTION:    acpi_ut_copy_ipackage_to_ipackage
 
 875  * PARAMETERS:  *source_obj     - Pointer to the source package object
 
 876  *              *dest_obj       - Where the internal object is returned
 
 878  * RETURN:      Status          - the status of the call
 
 880  * DESCRIPTION: This function is called to copy an internal package object
 
 881  *              into another internal package object.
 
 883  ******************************************************************************/
 
 886 acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
 
 887                                   union acpi_operand_object *dest_obj,
 
 888                                   struct acpi_walk_state *walk_state)
 
 890         acpi_status status = AE_OK;
 
 892         ACPI_FUNCTION_TRACE(ut_copy_ipackage_to_ipackage);
 
 894         dest_obj->common.type = ACPI_GET_OBJECT_TYPE(source_obj);
 
 895         dest_obj->common.flags = source_obj->common.flags;
 
 896         dest_obj->package.count = source_obj->package.count;
 
 899          * Create the object array and walk the source package tree
 
 901         dest_obj->package.elements = ACPI_ALLOCATE_ZEROED(((acpi_size)
 
 904                                                            1) * sizeof(void *));
 
 905         if (!dest_obj->package.elements) {
 
 906                 ACPI_ERROR((AE_INFO, "Package allocation failure"));
 
 907                 return_ACPI_STATUS(AE_NO_MEMORY);
 
 911          * Copy the package element-by-element by walking the package "tree".
 
 912          * This handles nested packages of arbitrary depth.
 
 914         status = acpi_ut_walk_package_tree(source_obj, dest_obj,
 
 915                                            acpi_ut_copy_ielement_to_ielement,
 
 917         if (ACPI_FAILURE(status)) {
 
 919                 /* On failure, delete the destination package object */
 
 921                 acpi_ut_remove_reference(dest_obj);
 
 924         return_ACPI_STATUS(status);
 
 927 /*******************************************************************************
 
 929  * FUNCTION:    acpi_ut_copy_iobject_to_iobject
 
 931  * PARAMETERS:  walk_state          - Current walk state
 
 932  *              source_desc         - The internal object to be copied
 
 933  *              dest_desc           - Where the copied object is returned
 
 937  * DESCRIPTION: Copy an internal object to a new internal object
 
 939  ******************************************************************************/
 
 942 acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc,
 
 943                                 union acpi_operand_object **dest_desc,
 
 944                                 struct acpi_walk_state *walk_state)
 
 946         acpi_status status = AE_OK;
 
 948         ACPI_FUNCTION_TRACE(ut_copy_iobject_to_iobject);
 
 950         /* Create the top level object */
 
 953             acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE(source_desc));
 
 955                 return_ACPI_STATUS(AE_NO_MEMORY);
 
 958         /* Copy the object and possible subobjects */
 
 960         if (ACPI_GET_OBJECT_TYPE(source_desc) == ACPI_TYPE_PACKAGE) {
 
 962                     acpi_ut_copy_ipackage_to_ipackage(source_desc, *dest_desc,
 
 965                 status = acpi_ut_copy_simple_object(source_desc, *dest_desc);
 
 968         return_ACPI_STATUS(status);