blob: 879eaa10d3ae77cf92777f4198dc60eb1b4c7058 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
3 * Module Name: utcopy - Internal to external object translation utilities
4 *
5 *****************************************************************************/
6
7/*
Bob Moore6c9deb72007-02-02 19:48:24 +03008 * Copyright (C) 2000 - 2007, R. Byron Moore
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
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.
25 *
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.
29 *
30 * NO WARRANTY
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.
42 */
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <acpi/acpi.h>
45#include <acpi/amlcode.h>
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#define _COMPONENT ACPI_UTILITIES
Len Brown4be44fc2005-08-05 00:44:28 -040048ACPI_MODULE_NAME("utcopy")
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
Robert Moore44f6c012005-04-18 22:49:35 -040050/* Local prototypes */
Len Brown4be44fc2005-08-05 00:44:28 -040051static acpi_status
52acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
53 union acpi_object *external_object,
54 u8 * data_space, acpi_size * buffer_space_used);
Robert Moore44f6c012005-04-18 22:49:35 -040055
56static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040057acpi_ut_copy_ielement_to_ielement(u8 object_type,
58 union acpi_operand_object *source_object,
59 union acpi_generic_state *state,
60 void *context);
Robert Moore44f6c012005-04-18 22:49:35 -040061
62static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040063acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object,
64 u8 * buffer, acpi_size * space_used);
Robert Moore44f6c012005-04-18 22:49:35 -040065
66static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040067acpi_ut_copy_esimple_to_isimple(union acpi_object *user_obj,
68 union acpi_operand_object **return_obj);
Robert Moore44f6c012005-04-18 22:49:35 -040069
70static acpi_status
Bob Moore6287ee32007-04-03 19:59:37 -040071acpi_ut_copy_epackage_to_ipackage(union acpi_object *external_object,
72 union acpi_operand_object **internal_object);
73
74static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040075acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
76 union acpi_operand_object *dest_desc);
Robert Moore44f6c012005-04-18 22:49:35 -040077
78static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040079acpi_ut_copy_ielement_to_eelement(u8 object_type,
80 union acpi_operand_object *source_object,
81 union acpi_generic_state *state,
82 void *context);
Robert Moore44f6c012005-04-18 22:49:35 -040083
84static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040085acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
86 union acpi_operand_object *dest_obj,
87 struct acpi_walk_state *walk_state);
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
89/*******************************************************************************
90 *
91 * FUNCTION: acpi_ut_copy_isimple_to_esimple
92 *
Robert Moore44f6c012005-04-18 22:49:35 -040093 * PARAMETERS: internal_object - Source object to be copied
94 * external_object - Where to return the copied object
95 * data_space - Where object data is returned (such as
96 * buffer and string data)
97 * buffer_space_used - Length of data_space that was used
Linus Torvalds1da177e2005-04-16 15:20:36 -070098 *
99 * RETURN: Status
100 *
Robert Moore44f6c012005-04-18 22:49:35 -0400101 * DESCRIPTION: This function is called to copy a simple internal object to
102 * an external object.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 *
Robert Moore44f6c012005-04-18 22:49:35 -0400104 * The data_space buffer is assumed to have sufficient space for
105 * the object.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 *
107 ******************************************************************************/
108
109static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400110acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
111 union acpi_object *external_object,
112 u8 * data_space, acpi_size * buffer_space_used)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113{
Len Brown4be44fc2005-08-05 00:44:28 -0400114 acpi_status status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
Bob Mooreb229cf92006-04-21 17:15:00 -0400116 ACPI_FUNCTION_TRACE(ut_copy_isimple_to_esimple);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117
118 *buffer_space_used = 0;
119
120 /*
121 * Check for NULL object case (could be an uninitialized
122 * package element)
123 */
124 if (!internal_object) {
Len Brown4be44fc2005-08-05 00:44:28 -0400125 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 }
127
128 /* Always clear the external object */
129
Len Brown4be44fc2005-08-05 00:44:28 -0400130 ACPI_MEMSET(external_object, 0, sizeof(union acpi_object));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131
132 /*
133 * In general, the external object will be the same type as
134 * the internal object
135 */
Len Brown4be44fc2005-08-05 00:44:28 -0400136 external_object->type = ACPI_GET_OBJECT_TYPE(internal_object);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137
138 /* However, only a limited number of external types are supported */
139
Len Brown4be44fc2005-08-05 00:44:28 -0400140 switch (ACPI_GET_OBJECT_TYPE(internal_object)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 case ACPI_TYPE_STRING:
142
Len Brown4be44fc2005-08-05 00:44:28 -0400143 external_object->string.pointer = (char *)data_space;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 external_object->string.length = internal_object->string.length;
Len Brown4be44fc2005-08-05 00:44:28 -0400145 *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD((acpi_size)
146 internal_object->
147 string.
148 length + 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149
Len Brown4be44fc2005-08-05 00:44:28 -0400150 ACPI_MEMCPY((void *)data_space,
151 (void *)internal_object->string.pointer,
152 (acpi_size) internal_object->string.length + 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 break;
154
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 case ACPI_TYPE_BUFFER:
156
157 external_object->buffer.pointer = data_space;
158 external_object->buffer.length = internal_object->buffer.length;
Len Brown4be44fc2005-08-05 00:44:28 -0400159 *buffer_space_used =
160 ACPI_ROUND_UP_TO_NATIVE_WORD(internal_object->string.
161 length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162
Len Brown4be44fc2005-08-05 00:44:28 -0400163 ACPI_MEMCPY((void *)data_space,
164 (void *)internal_object->buffer.pointer,
165 internal_object->buffer.length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 break;
167
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 case ACPI_TYPE_INTEGER:
169
170 external_object->integer.value = internal_object->integer.value;
171 break;
172
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 case ACPI_TYPE_LOCAL_REFERENCE:
174
175 /*
176 * This is an object reference. Attempt to dereference it.
177 */
178 switch (internal_object->reference.opcode) {
179 case AML_INT_NAMEPATH_OP:
180
181 /* For namepath, return the object handle ("reference") */
182
183 default:
184 /*
185 * Use the object type of "Any" to indicate a reference
186 * to object containing a handle to an ACPI named object.
187 */
188 external_object->type = ACPI_TYPE_ANY;
Len Brown4be44fc2005-08-05 00:44:28 -0400189 external_object->reference.handle =
190 internal_object->reference.node;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 break;
192 }
193 break;
194
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 case ACPI_TYPE_PROCESSOR:
196
Len Brown4be44fc2005-08-05 00:44:28 -0400197 external_object->processor.proc_id =
198 internal_object->processor.proc_id;
199 external_object->processor.pblk_address =
200 internal_object->processor.address;
201 external_object->processor.pblk_length =
202 internal_object->processor.length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 break;
204
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 case ACPI_TYPE_POWER:
206
207 external_object->power_resource.system_level =
Len Brown4be44fc2005-08-05 00:44:28 -0400208 internal_object->power_resource.system_level;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209
210 external_object->power_resource.resource_order =
Len Brown4be44fc2005-08-05 00:44:28 -0400211 internal_object->power_resource.resource_order;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 break;
213
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 default:
215 /*
216 * There is no corresponding external object type
217 */
Len Brown4be44fc2005-08-05 00:44:28 -0400218 return_ACPI_STATUS(AE_SUPPORT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 }
220
Len Brown4be44fc2005-08-05 00:44:28 -0400221 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222}
223
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224/*******************************************************************************
225 *
226 * FUNCTION: acpi_ut_copy_ielement_to_eelement
227 *
228 * PARAMETERS: acpi_pkg_callback
229 *
230 * RETURN: Status
231 *
232 * DESCRIPTION: Copy one package element to another package element
233 *
234 ******************************************************************************/
235
Robert Moore44f6c012005-04-18 22:49:35 -0400236static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400237acpi_ut_copy_ielement_to_eelement(u8 object_type,
238 union acpi_operand_object *source_object,
239 union acpi_generic_state *state,
240 void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241{
Len Brown4be44fc2005-08-05 00:44:28 -0400242 acpi_status status = AE_OK;
243 struct acpi_pkg_info *info = (struct acpi_pkg_info *)context;
244 acpi_size object_space;
245 u32 this_index;
246 union acpi_object *target_object;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247
Len Brown4be44fc2005-08-05 00:44:28 -0400248 ACPI_FUNCTION_ENTRY();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249
Len Brown4be44fc2005-08-05 00:44:28 -0400250 this_index = state->pkg.index;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 target_object = (union acpi_object *)
Len Brown4be44fc2005-08-05 00:44:28 -0400252 &((union acpi_object *)(state->pkg.dest_object))->package.
253 elements[this_index];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254
255 switch (object_type) {
256 case ACPI_COPY_TYPE_SIMPLE:
257
258 /*
259 * This is a simple or null object
260 */
Len Brown4be44fc2005-08-05 00:44:28 -0400261 status = acpi_ut_copy_isimple_to_esimple(source_object,
262 target_object,
263 info->free_space,
264 &object_space);
265 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266 return (status);
267 }
268 break;
269
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270 case ACPI_COPY_TYPE_PACKAGE:
271
272 /*
273 * Build the package object
274 */
Len Brown4be44fc2005-08-05 00:44:28 -0400275 target_object->type = ACPI_TYPE_PACKAGE;
276 target_object->package.count = source_object->package.count;
Robert Moore44f6c012005-04-18 22:49:35 -0400277 target_object->package.elements =
Len Brown4be44fc2005-08-05 00:44:28 -0400278 ACPI_CAST_PTR(union acpi_object, info->free_space);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279
280 /*
281 * Pass the new package object back to the package walk routine
282 */
283 state->pkg.this_target_obj = target_object;
284
285 /*
286 * Save space for the array of objects (Package elements)
287 * update the buffer length counter
288 */
Len Brown4be44fc2005-08-05 00:44:28 -0400289 object_space = ACPI_ROUND_UP_TO_NATIVE_WORD((acpi_size)
290 target_object->
291 package.count *
292 sizeof(union
293 acpi_object));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 break;
295
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 default:
297 return (AE_BAD_PARAMETER);
298 }
299
Len Brown4be44fc2005-08-05 00:44:28 -0400300 info->free_space += object_space;
301 info->length += object_space;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302 return (status);
303}
304
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305/*******************************************************************************
306 *
307 * FUNCTION: acpi_ut_copy_ipackage_to_epackage
308 *
Robert Moore44f6c012005-04-18 22:49:35 -0400309 * PARAMETERS: internal_object - Pointer to the object we are returning
310 * Buffer - Where the object is returned
311 * space_used - Where the object length is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 *
313 * RETURN: Status
314 *
315 * DESCRIPTION: This function is called to place a package object in a user
316 * buffer. A package object by definition contains other objects.
317 *
318 * The buffer is assumed to have sufficient space for the object.
319 * The caller must have verified the buffer length needed using the
320 * acpi_ut_get_object_size function before calling this function.
321 *
322 ******************************************************************************/
323
324static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400325acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object,
326 u8 * buffer, acpi_size * space_used)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327{
Len Brown4be44fc2005-08-05 00:44:28 -0400328 union acpi_object *external_object;
329 acpi_status status;
330 struct acpi_pkg_info info;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331
Bob Mooreb229cf92006-04-21 17:15:00 -0400332 ACPI_FUNCTION_TRACE(ut_copy_ipackage_to_epackage);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333
334 /*
335 * First package at head of the buffer
336 */
Len Brown4be44fc2005-08-05 00:44:28 -0400337 external_object = ACPI_CAST_PTR(union acpi_object, buffer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338
339 /*
340 * Free space begins right after the first package
341 */
Len Brown4be44fc2005-08-05 00:44:28 -0400342 info.length = ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
343 info.free_space =
344 buffer + ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 info.object_space = 0;
346 info.num_packages = 1;
347
Len Brown4be44fc2005-08-05 00:44:28 -0400348 external_object->type = ACPI_GET_OBJECT_TYPE(internal_object);
349 external_object->package.count = internal_object->package.count;
350 external_object->package.elements = ACPI_CAST_PTR(union acpi_object,
351 info.free_space);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352
353 /*
354 * Leave room for an array of ACPI_OBJECTS in the buffer
355 * and move the free space past it
356 */
Len Brown4be44fc2005-08-05 00:44:28 -0400357 info.length += (acpi_size) external_object->package.count *
358 ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 info.free_space += external_object->package.count *
Len Brown4be44fc2005-08-05 00:44:28 -0400360 ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361
Len Brown4be44fc2005-08-05 00:44:28 -0400362 status = acpi_ut_walk_package_tree(internal_object, external_object,
363 acpi_ut_copy_ielement_to_eelement,
364 &info);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365
366 *space_used = info.length;
Len Brown4be44fc2005-08-05 00:44:28 -0400367 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368}
369
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370/*******************************************************************************
371 *
372 * FUNCTION: acpi_ut_copy_iobject_to_eobject
373 *
Robert Moore44f6c012005-04-18 22:49:35 -0400374 * PARAMETERS: internal_object - The internal object to be converted
375 * buffer_ptr - Where the object is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 *
377 * RETURN: Status
378 *
379 * DESCRIPTION: This function is called to build an API object to be returned to
380 * the caller.
381 *
382 ******************************************************************************/
383
384acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400385acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *internal_object,
386 struct acpi_buffer *ret_buffer)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387{
Len Brown4be44fc2005-08-05 00:44:28 -0400388 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389
Bob Mooreb229cf92006-04-21 17:15:00 -0400390 ACPI_FUNCTION_TRACE(ut_copy_iobject_to_eobject);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391
Len Brown4be44fc2005-08-05 00:44:28 -0400392 if (ACPI_GET_OBJECT_TYPE(internal_object) == ACPI_TYPE_PACKAGE) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 /*
394 * Package object: Copy all subobjects (including
395 * nested packages)
396 */
Len Brown4be44fc2005-08-05 00:44:28 -0400397 status = acpi_ut_copy_ipackage_to_epackage(internal_object,
398 ret_buffer->pointer,
399 &ret_buffer->length);
400 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401 /*
402 * Build a simple object (no nested objects)
403 */
Len Brown4be44fc2005-08-05 00:44:28 -0400404 status = acpi_ut_copy_isimple_to_esimple(internal_object,
Bob Moorec51a4de2005-11-17 13:07:00 -0500405 ACPI_CAST_PTR(union
406 acpi_object,
407 ret_buffer->
408 pointer),
409 ACPI_ADD_PTR(u8,
410 ret_buffer->
411 pointer,
412 ACPI_ROUND_UP_TO_NATIVE_WORD
413 (sizeof
414 (union
415 acpi_object))),
Len Brown4be44fc2005-08-05 00:44:28 -0400416 &ret_buffer->length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417 /*
418 * build simple does not include the object size in the length
419 * so we add it in here
420 */
Len Brown4be44fc2005-08-05 00:44:28 -0400421 ret_buffer->length += sizeof(union acpi_object);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422 }
423
Len Brown4be44fc2005-08-05 00:44:28 -0400424 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425}
426
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427/*******************************************************************************
428 *
429 * FUNCTION: acpi_ut_copy_esimple_to_isimple
430 *
Robert Moore44f6c012005-04-18 22:49:35 -0400431 * PARAMETERS: external_object - The external object to be converted
432 * ret_internal_object - Where the internal object is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 *
434 * RETURN: Status
435 *
436 * DESCRIPTION: This function copies an external object to an internal one.
437 * NOTE: Pointers can be copied, we don't need to copy data.
438 * (The pointers have to be valid in our address space no matter
439 * what we do with them!)
440 *
441 ******************************************************************************/
442
Robert Moore44f6c012005-04-18 22:49:35 -0400443static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400444acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object,
445 union acpi_operand_object **ret_internal_object)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446{
Len Brown4be44fc2005-08-05 00:44:28 -0400447 union acpi_operand_object *internal_object;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448
Bob Mooreb229cf92006-04-21 17:15:00 -0400449 ACPI_FUNCTION_TRACE(ut_copy_esimple_to_isimple);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450
451 /*
452 * Simple types supported are: String, Buffer, Integer
453 */
454 switch (external_object->type) {
455 case ACPI_TYPE_STRING:
456 case ACPI_TYPE_BUFFER:
457 case ACPI_TYPE_INTEGER:
458
Len Brown4be44fc2005-08-05 00:44:28 -0400459 internal_object = acpi_ut_create_internal_object((u8)
460 external_object->
461 type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 if (!internal_object) {
Len Brown4be44fc2005-08-05 00:44:28 -0400463 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 }
465 break;
466
467 default:
468 /* All other types are not supported */
469
Len Brown4be44fc2005-08-05 00:44:28 -0400470 return_ACPI_STATUS(AE_SUPPORT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 }
472
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 /* Must COPY string and buffer contents */
474
475 switch (external_object->type) {
476 case ACPI_TYPE_STRING:
477
478 internal_object->string.pointer =
Bob Moore83135242006-10-03 00:00:00 -0400479 ACPI_ALLOCATE_ZEROED((acpi_size) external_object->string.
480 length + 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481 if (!internal_object->string.pointer) {
482 goto error_exit;
483 }
484
Len Brown4be44fc2005-08-05 00:44:28 -0400485 ACPI_MEMCPY(internal_object->string.pointer,
486 external_object->string.pointer,
487 external_object->string.length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488
489 internal_object->string.length = external_object->string.length;
490 break;
491
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 case ACPI_TYPE_BUFFER:
493
494 internal_object->buffer.pointer =
Bob Moore83135242006-10-03 00:00:00 -0400495 ACPI_ALLOCATE_ZEROED(external_object->buffer.length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 if (!internal_object->buffer.pointer) {
497 goto error_exit;
498 }
499
Len Brown4be44fc2005-08-05 00:44:28 -0400500 ACPI_MEMCPY(internal_object->buffer.pointer,
501 external_object->buffer.pointer,
502 external_object->buffer.length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503
504 internal_object->buffer.length = external_object->buffer.length;
505 break;
506
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 case ACPI_TYPE_INTEGER:
508
Len Brown4be44fc2005-08-05 00:44:28 -0400509 internal_object->integer.value = external_object->integer.value;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 break;
511
512 default:
513 /* Other types can't get here */
514 break;
515 }
516
517 *ret_internal_object = internal_object;
Len Brown4be44fc2005-08-05 00:44:28 -0400518 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519
Len Brown4be44fc2005-08-05 00:44:28 -0400520 error_exit:
521 acpi_ut_remove_reference(internal_object);
522 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523}
524
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525/*******************************************************************************
526 *
527 * FUNCTION: acpi_ut_copy_epackage_to_ipackage
528 *
Bob Moore6287ee32007-04-03 19:59:37 -0400529 * PARAMETERS: external_object - The external object to be converted
530 * internal_object - Where the internal object is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 *
532 * RETURN: Status
533 *
Bob Moore6287ee32007-04-03 19:59:37 -0400534 * DESCRIPTION: Copy an external package object to an internal package.
535 * Handles nested packages.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 *
537 ******************************************************************************/
538
539static acpi_status
Bob Moore6287ee32007-04-03 19:59:37 -0400540acpi_ut_copy_epackage_to_ipackage(union acpi_object *external_object,
541 union acpi_operand_object **internal_object)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542{
Bob Moore6287ee32007-04-03 19:59:37 -0400543 acpi_status status = AE_OK;
544 union acpi_operand_object *package_object;
545 union acpi_operand_object **package_elements;
546 acpi_native_uint i;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547
Bob Mooreb229cf92006-04-21 17:15:00 -0400548 ACPI_FUNCTION_TRACE(ut_copy_epackage_to_ipackage);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549
Bob Moore6287ee32007-04-03 19:59:37 -0400550 /* Create the package object */
551
552 package_object =
553 acpi_ut_create_package_object(external_object->package.count);
554 if (!package_object) {
555 return_ACPI_STATUS(AE_NO_MEMORY);
556 }
557
558 package_elements = package_object->package.elements;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559
560 /*
Bob Moore6287ee32007-04-03 19:59:37 -0400561 * Recursive implementation. Probably ok, since nested external packages
562 * as parameters should be very rare.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 */
Bob Moore6287ee32007-04-03 19:59:37 -0400564 for (i = 0; i < external_object->package.count; i++) {
565 status =
566 acpi_ut_copy_eobject_to_iobject(&external_object->package.
567 elements[i],
568 &package_elements[i]);
569 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570
Bob Moore6287ee32007-04-03 19:59:37 -0400571 /* Truncate package and delete it */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572
Bob Moore6287ee32007-04-03 19:59:37 -0400573 package_object->package.count = i;
574 package_elements[i] = NULL;
575 acpi_ut_remove_reference(package_object);
576 return_ACPI_STATUS(status);
577 }
578 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579
Bob Moore6287ee32007-04-03 19:59:37 -0400580 *internal_object = package_object;
581 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582}
583
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584/*******************************************************************************
585 *
586 * FUNCTION: acpi_ut_copy_eobject_to_iobject
587 *
Bob Moore6287ee32007-04-03 19:59:37 -0400588 * PARAMETERS: external_object - The external object to be converted
589 * internal_object - Where the internal object is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 *
Bob Moore6287ee32007-04-03 19:59:37 -0400591 * RETURN: Status - the status of the call
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 *
593 * DESCRIPTION: Converts an external object to an internal object.
594 *
595 ******************************************************************************/
596
597acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400598acpi_ut_copy_eobject_to_iobject(union acpi_object *external_object,
599 union acpi_operand_object **internal_object)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600{
Len Brown4be44fc2005-08-05 00:44:28 -0400601 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602
Bob Mooreb229cf92006-04-21 17:15:00 -0400603 ACPI_FUNCTION_TRACE(ut_copy_eobject_to_iobject);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604
605 if (external_object->type == ACPI_TYPE_PACKAGE) {
Bob Moore6287ee32007-04-03 19:59:37 -0400606 status =
607 acpi_ut_copy_epackage_to_ipackage(external_object,
608 internal_object);
609 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 /*
611 * Build a simple object (no nested objects)
612 */
Len Brown4be44fc2005-08-05 00:44:28 -0400613 status =
614 acpi_ut_copy_esimple_to_isimple(external_object,
615 internal_object);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 }
617
Len Brown4be44fc2005-08-05 00:44:28 -0400618 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619}
620
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621/*******************************************************************************
622 *
623 * FUNCTION: acpi_ut_copy_simple_object
624 *
625 * PARAMETERS: source_desc - The internal object to be copied
626 * dest_desc - New target object
627 *
628 * RETURN: Status
629 *
630 * DESCRIPTION: Simple copy of one internal object to another. Reference count
631 * of the destination object is preserved.
632 *
633 ******************************************************************************/
634
Robert Moore44f6c012005-04-18 22:49:35 -0400635static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400636acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
637 union acpi_operand_object *dest_desc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638{
Len Brown4be44fc2005-08-05 00:44:28 -0400639 u16 reference_count;
640 union acpi_operand_object *next_object;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641
642 /* Save fields from destination that we don't want to overwrite */
643
644 reference_count = dest_desc->common.reference_count;
645 next_object = dest_desc->common.next_object;
646
Len Brown4be44fc2005-08-05 00:44:28 -0400647 /* Copy the entire source object over the destination object */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648
Len Brown4be44fc2005-08-05 00:44:28 -0400649 ACPI_MEMCPY((char *)dest_desc, (char *)source_desc,
650 sizeof(union acpi_operand_object));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651
652 /* Restore the saved fields */
653
654 dest_desc->common.reference_count = reference_count;
655 dest_desc->common.next_object = next_object;
656
Robert Moore6f42ccf2005-05-13 00:00:00 -0400657 /* New object is not static, regardless of source */
658
659 dest_desc->common.flags &= ~AOPOBJ_STATIC_POINTER;
660
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 /* Handle the objects with extra data */
662
Len Brown4be44fc2005-08-05 00:44:28 -0400663 switch (ACPI_GET_OBJECT_TYPE(dest_desc)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 case ACPI_TYPE_BUFFER:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 /*
666 * Allocate and copy the actual buffer if and only if:
667 * 1) There is a valid buffer pointer
Robert Moore6f42ccf2005-05-13 00:00:00 -0400668 * 2) The buffer has a length > 0
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 */
670 if ((source_desc->buffer.pointer) &&
Len Brown4be44fc2005-08-05 00:44:28 -0400671 (source_desc->buffer.length)) {
Robert Moore6f42ccf2005-05-13 00:00:00 -0400672 dest_desc->buffer.pointer =
Bob Moore83135242006-10-03 00:00:00 -0400673 ACPI_ALLOCATE(source_desc->buffer.length);
Robert Moore6f42ccf2005-05-13 00:00:00 -0400674 if (!dest_desc->buffer.pointer) {
675 return (AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 }
Robert Moore6f42ccf2005-05-13 00:00:00 -0400677
678 /* Copy the actual buffer data */
679
Len Brown4be44fc2005-08-05 00:44:28 -0400680 ACPI_MEMCPY(dest_desc->buffer.pointer,
681 source_desc->buffer.pointer,
682 source_desc->buffer.length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 }
684 break;
685
686 case ACPI_TYPE_STRING:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 /*
688 * Allocate and copy the actual string if and only if:
689 * 1) There is a valid string pointer
Robert Moore6f42ccf2005-05-13 00:00:00 -0400690 * (Pointer to a NULL string is allowed)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691 */
Robert Moore6f42ccf2005-05-13 00:00:00 -0400692 if (source_desc->string.pointer) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 dest_desc->string.pointer =
Bob Moore83135242006-10-03 00:00:00 -0400694 ACPI_ALLOCATE((acpi_size) source_desc->string.
695 length + 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696 if (!dest_desc->string.pointer) {
697 return (AE_NO_MEMORY);
698 }
699
Robert Moore6f42ccf2005-05-13 00:00:00 -0400700 /* Copy the actual string data */
701
Len Brown4be44fc2005-08-05 00:44:28 -0400702 ACPI_MEMCPY(dest_desc->string.pointer,
703 source_desc->string.pointer,
704 (acpi_size) source_desc->string.length + 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705 }
706 break;
707
708 case ACPI_TYPE_LOCAL_REFERENCE:
709 /*
710 * We copied the reference object, so we now must add a reference
711 * to the object pointed to by the reference
712 */
Len Brown4be44fc2005-08-05 00:44:28 -0400713 acpi_ut_add_reference(source_desc->reference.object);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 break;
715
Fiodor Suietov6b366e22007-02-02 19:48:18 +0300716 case ACPI_TYPE_REGION:
717 /*
718 * We copied the Region Handler, so we now must add a reference
719 */
720 if (dest_desc->region.handler) {
721 acpi_ut_add_reference(dest_desc->region.handler);
722 }
723 break;
724
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 default:
726 /* Nothing to do for other simple objects */
727 break;
728 }
729
730 return (AE_OK);
731}
732
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733/*******************************************************************************
734 *
735 * FUNCTION: acpi_ut_copy_ielement_to_ielement
736 *
737 * PARAMETERS: acpi_pkg_callback
738 *
739 * RETURN: Status
740 *
741 * DESCRIPTION: Copy one package element to another package element
742 *
743 ******************************************************************************/
744
Robert Moore44f6c012005-04-18 22:49:35 -0400745static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400746acpi_ut_copy_ielement_to_ielement(u8 object_type,
747 union acpi_operand_object *source_object,
748 union acpi_generic_state *state,
749 void *context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750{
Len Brown4be44fc2005-08-05 00:44:28 -0400751 acpi_status status = AE_OK;
752 u32 this_index;
753 union acpi_operand_object **this_target_ptr;
754 union acpi_operand_object *target_object;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755
Len Brown4be44fc2005-08-05 00:44:28 -0400756 ACPI_FUNCTION_ENTRY();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757
Len Brown4be44fc2005-08-05 00:44:28 -0400758 this_index = state->pkg.index;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 this_target_ptr = (union acpi_operand_object **)
Len Brown4be44fc2005-08-05 00:44:28 -0400760 &state->pkg.dest_object->package.elements[this_index];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761
762 switch (object_type) {
763 case ACPI_COPY_TYPE_SIMPLE:
764
765 /* A null source object indicates a (legal) null package element */
766
767 if (source_object) {
768 /*
769 * This is a simple object, just copy it
770 */
Len Brown4be44fc2005-08-05 00:44:28 -0400771 target_object =
772 acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE
773 (source_object));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 if (!target_object) {
775 return (AE_NO_MEMORY);
776 }
777
Len Brown4be44fc2005-08-05 00:44:28 -0400778 status =
779 acpi_ut_copy_simple_object(source_object,
780 target_object);
781 if (ACPI_FAILURE(status)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 goto error_exit;
783 }
784
785 *this_target_ptr = target_object;
Len Brown4be44fc2005-08-05 00:44:28 -0400786 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 /* Pass through a null element */
788
789 *this_target_ptr = NULL;
790 }
791 break;
792
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 case ACPI_COPY_TYPE_PACKAGE:
794
795 /*
796 * This object is a package - go down another nesting level
797 * Create and build the package object
798 */
Len Brown4be44fc2005-08-05 00:44:28 -0400799 target_object =
Bob Moore6287ee32007-04-03 19:59:37 -0400800 acpi_ut_create_package_object(source_object->package.count);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 if (!target_object) {
802 return (AE_NO_MEMORY);
803 }
804
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805 target_object->common.flags = source_object->common.flags;
806
Bob Moore6287ee32007-04-03 19:59:37 -0400807 /* Pass the new package object back to the package walk routine */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 state->pkg.this_target_obj = target_object;
810
Bob Moore6287ee32007-04-03 19:59:37 -0400811 /* Store the object pointer in the parent package object */
812
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813 *this_target_ptr = target_object;
814 break;
815
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816 default:
817 return (AE_BAD_PARAMETER);
818 }
819
820 return (status);
821
Len Brown4be44fc2005-08-05 00:44:28 -0400822 error_exit:
823 acpi_ut_remove_reference(target_object);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824 return (status);
825}
826
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827/*******************************************************************************
828 *
829 * FUNCTION: acpi_ut_copy_ipackage_to_ipackage
830 *
831 * PARAMETERS: *source_obj - Pointer to the source package object
832 * *dest_obj - Where the internal object is returned
833 *
834 * RETURN: Status - the status of the call
835 *
836 * DESCRIPTION: This function is called to copy an internal package object
837 * into another internal package object.
838 *
839 ******************************************************************************/
840
Robert Moore44f6c012005-04-18 22:49:35 -0400841static acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400842acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
843 union acpi_operand_object *dest_obj,
844 struct acpi_walk_state *walk_state)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845{
Len Brown4be44fc2005-08-05 00:44:28 -0400846 acpi_status status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847
Bob Mooreb229cf92006-04-21 17:15:00 -0400848 ACPI_FUNCTION_TRACE(ut_copy_ipackage_to_ipackage);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849
Len Brown4be44fc2005-08-05 00:44:28 -0400850 dest_obj->common.type = ACPI_GET_OBJECT_TYPE(source_obj);
851 dest_obj->common.flags = source_obj->common.flags;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852 dest_obj->package.count = source_obj->package.count;
853
854 /*
855 * Create the object array and walk the source package tree
856 */
Bob Moore83135242006-10-03 00:00:00 -0400857 dest_obj->package.elements = ACPI_ALLOCATE_ZEROED(((acpi_size)
858 source_obj->package.
859 count +
860 1) * sizeof(void *));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700861 if (!dest_obj->package.elements) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500862 ACPI_ERROR((AE_INFO, "Package allocation failure"));
Len Brown4be44fc2005-08-05 00:44:28 -0400863 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700864 }
865
866 /*
867 * Copy the package element-by-element by walking the package "tree".
868 * This handles nested packages of arbitrary depth.
869 */
Len Brown4be44fc2005-08-05 00:44:28 -0400870 status = acpi_ut_walk_package_tree(source_obj, dest_obj,
871 acpi_ut_copy_ielement_to_ielement,
872 walk_state);
873 if (ACPI_FAILURE(status)) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400874
Linus Torvalds1da177e2005-04-16 15:20:36 -0700875 /* On failure, delete the destination package object */
876
Len Brown4be44fc2005-08-05 00:44:28 -0400877 acpi_ut_remove_reference(dest_obj);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878 }
879
Len Brown4be44fc2005-08-05 00:44:28 -0400880 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700881}
882
Linus Torvalds1da177e2005-04-16 15:20:36 -0700883/*******************************************************************************
884 *
885 * FUNCTION: acpi_ut_copy_iobject_to_iobject
886 *
887 * PARAMETERS: walk_state - Current walk state
888 * source_desc - The internal object to be copied
889 * dest_desc - Where the copied object is returned
890 *
891 * RETURN: Status
892 *
893 * DESCRIPTION: Copy an internal object to a new internal object
894 *
895 ******************************************************************************/
896
897acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400898acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc,
899 union acpi_operand_object **dest_desc,
900 struct acpi_walk_state *walk_state)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700901{
Len Brown4be44fc2005-08-05 00:44:28 -0400902 acpi_status status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700903
Bob Mooreb229cf92006-04-21 17:15:00 -0400904 ACPI_FUNCTION_TRACE(ut_copy_iobject_to_iobject);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700905
906 /* Create the top level object */
907
Len Brown4be44fc2005-08-05 00:44:28 -0400908 *dest_desc =
909 acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE(source_desc));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700910 if (!*dest_desc) {
Len Brown4be44fc2005-08-05 00:44:28 -0400911 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700912 }
913
914 /* Copy the object and possible subobjects */
915
Len Brown4be44fc2005-08-05 00:44:28 -0400916 if (ACPI_GET_OBJECT_TYPE(source_desc) == ACPI_TYPE_PACKAGE) {
917 status =
918 acpi_ut_copy_ipackage_to_ipackage(source_desc, *dest_desc,
919 walk_state);
920 } else {
921 status = acpi_ut_copy_simple_object(source_desc, *dest_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700922 }
923
Len Brown4be44fc2005-08-05 00:44:28 -0400924 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700925}