aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/utilities/utcopy.c
diff options
context:
space:
mode:
authorLen Brown <len.brown@intel.com>2005-08-05 00:44:28 -0400
committerLen Brown <len.brown@intel.com>2005-08-05 00:45:14 -0400
commit4be44fcd3bf648b782f4460fd06dfae6c42ded4b (patch)
tree5b5b7d296ea58786f53b95e5eac9565ff66890b0 /drivers/acpi/utilities/utcopy.c
parentc65ade4dc8b486e8c8b9b0a6399789a5428e2039 (diff)
[ACPI] Lindent all ACPI files
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/utilities/utcopy.c')
-rw-r--r--drivers/acpi/utilities/utcopy.c556
1 files changed, 255 insertions, 301 deletions
diff --git a/drivers/acpi/utilities/utcopy.c b/drivers/acpi/utilities/utcopy.c
index 31c30a32e5c9..5442b32de611 100644
--- a/drivers/acpi/utilities/utcopy.c
+++ b/drivers/acpi/utilities/utcopy.c
@@ -41,59 +41,46 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/amlcode.h> 45#include <acpi/amlcode.h>
47 46
48
49#define _COMPONENT ACPI_UTILITIES 47#define _COMPONENT ACPI_UTILITIES
50 ACPI_MODULE_NAME ("utcopy") 48ACPI_MODULE_NAME("utcopy")
51 49
52/* Local prototypes */ 50/* Local prototypes */
53
54static acpi_status 51static acpi_status
55acpi_ut_copy_isimple_to_esimple ( 52acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
56 union acpi_operand_object *internal_object, 53 union acpi_object *external_object,
57 union acpi_object *external_object, 54 u8 * data_space, acpi_size * buffer_space_used);
58 u8 *data_space,
59 acpi_size *buffer_space_used);
60 55
61static acpi_status 56static acpi_status
62acpi_ut_copy_ielement_to_ielement ( 57acpi_ut_copy_ielement_to_ielement(u8 object_type,
63 u8 object_type, 58 union acpi_operand_object *source_object,
64 union acpi_operand_object *source_object, 59 union acpi_generic_state *state,
65 union acpi_generic_state *state, 60 void *context);
66 void *context);
67 61
68static acpi_status 62static acpi_status
69acpi_ut_copy_ipackage_to_epackage ( 63acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object,
70 union acpi_operand_object *internal_object, 64 u8 * buffer, acpi_size * space_used);
71 u8 *buffer,
72 acpi_size *space_used);
73 65
74static acpi_status 66static acpi_status
75acpi_ut_copy_esimple_to_isimple( 67acpi_ut_copy_esimple_to_isimple(union acpi_object *user_obj,
76 union acpi_object *user_obj, 68 union acpi_operand_object **return_obj);
77 union acpi_operand_object **return_obj);
78 69
79static acpi_status 70static acpi_status
80acpi_ut_copy_simple_object ( 71acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
81 union acpi_operand_object *source_desc, 72 union acpi_operand_object *dest_desc);
82 union acpi_operand_object *dest_desc);
83 73
84static acpi_status 74static acpi_status
85acpi_ut_copy_ielement_to_eelement ( 75acpi_ut_copy_ielement_to_eelement(u8 object_type,
86 u8 object_type, 76 union acpi_operand_object *source_object,
87 union acpi_operand_object *source_object, 77 union acpi_generic_state *state,
88 union acpi_generic_state *state, 78 void *context);
89 void *context);
90 79
91static acpi_status 80static acpi_status
92acpi_ut_copy_ipackage_to_ipackage ( 81acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
93 union acpi_operand_object *source_obj, 82 union acpi_operand_object *dest_obj,
94 union acpi_operand_object *dest_obj, 83 struct acpi_walk_state *walk_state);
95 struct acpi_walk_state *walk_state);
96
97 84
98/******************************************************************************* 85/*******************************************************************************
99 * 86 *
@@ -116,17 +103,13 @@ acpi_ut_copy_ipackage_to_ipackage (
116 ******************************************************************************/ 103 ******************************************************************************/
117 104
118static acpi_status 105static acpi_status
119acpi_ut_copy_isimple_to_esimple ( 106acpi_ut_copy_isimple_to_esimple(union acpi_operand_object *internal_object,
120 union acpi_operand_object *internal_object, 107 union acpi_object *external_object,
121 union acpi_object *external_object, 108 u8 * data_space, acpi_size * buffer_space_used)
122 u8 *data_space,
123 acpi_size *buffer_space_used)
124{ 109{
125 acpi_status status = AE_OK; 110 acpi_status status = AE_OK;
126
127
128 ACPI_FUNCTION_TRACE ("ut_copy_isimple_to_esimple");
129 111
112 ACPI_FUNCTION_TRACE("ut_copy_isimple_to_esimple");
130 113
131 *buffer_space_used = 0; 114 *buffer_space_used = 0;
132 115
@@ -135,54 +118,54 @@ acpi_ut_copy_isimple_to_esimple (
135 * package element) 118 * package element)
136 */ 119 */
137 if (!internal_object) { 120 if (!internal_object) {
138 return_ACPI_STATUS (AE_OK); 121 return_ACPI_STATUS(AE_OK);
139 } 122 }
140 123
141 /* Always clear the external object */ 124 /* Always clear the external object */
142 125
143 ACPI_MEMSET (external_object, 0, sizeof (union acpi_object)); 126 ACPI_MEMSET(external_object, 0, sizeof(union acpi_object));
144 127
145 /* 128 /*
146 * In general, the external object will be the same type as 129 * In general, the external object will be the same type as
147 * the internal object 130 * the internal object
148 */ 131 */
149 external_object->type = ACPI_GET_OBJECT_TYPE (internal_object); 132 external_object->type = ACPI_GET_OBJECT_TYPE(internal_object);
150 133
151 /* However, only a limited number of external types are supported */ 134 /* However, only a limited number of external types are supported */
152 135
153 switch (ACPI_GET_OBJECT_TYPE (internal_object)) { 136 switch (ACPI_GET_OBJECT_TYPE(internal_object)) {
154 case ACPI_TYPE_STRING: 137 case ACPI_TYPE_STRING:
155 138
156 external_object->string.pointer = (char *) data_space; 139 external_object->string.pointer = (char *)data_space;
157 external_object->string.length = internal_object->string.length; 140 external_object->string.length = internal_object->string.length;
158 *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD ( 141 *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD((acpi_size)
159 (acpi_size) internal_object->string.length + 1); 142 internal_object->
160 143 string.
161 ACPI_MEMCPY ((void *) data_space, 144 length + 1);
162 (void *) internal_object->string.pointer, 145
163 (acpi_size) internal_object->string.length + 1); 146 ACPI_MEMCPY((void *)data_space,
147 (void *)internal_object->string.pointer,
148 (acpi_size) internal_object->string.length + 1);
164 break; 149 break;
165 150
166
167 case ACPI_TYPE_BUFFER: 151 case ACPI_TYPE_BUFFER:
168 152
169 external_object->buffer.pointer = data_space; 153 external_object->buffer.pointer = data_space;
170 external_object->buffer.length = internal_object->buffer.length; 154 external_object->buffer.length = internal_object->buffer.length;
171 *buffer_space_used = ACPI_ROUND_UP_TO_NATIVE_WORD ( 155 *buffer_space_used =
172 internal_object->string.length); 156 ACPI_ROUND_UP_TO_NATIVE_WORD(internal_object->string.
157 length);
173 158
174 ACPI_MEMCPY ((void *) data_space, 159 ACPI_MEMCPY((void *)data_space,
175 (void *) internal_object->buffer.pointer, 160 (void *)internal_object->buffer.pointer,
176 internal_object->buffer.length); 161 internal_object->buffer.length);
177 break; 162 break;
178 163
179
180 case ACPI_TYPE_INTEGER: 164 case ACPI_TYPE_INTEGER:
181 165
182 external_object->integer.value = internal_object->integer.value; 166 external_object->integer.value = internal_object->integer.value;
183 break; 167 break;
184 168
185
186 case ACPI_TYPE_LOCAL_REFERENCE: 169 case ACPI_TYPE_LOCAL_REFERENCE:
187 170
188 /* 171 /*
@@ -199,41 +182,41 @@ acpi_ut_copy_isimple_to_esimple (
199 * to object containing a handle to an ACPI named object. 182 * to object containing a handle to an ACPI named object.
200 */ 183 */
201 external_object->type = ACPI_TYPE_ANY; 184 external_object->type = ACPI_TYPE_ANY;
202 external_object->reference.handle = internal_object->reference.node; 185 external_object->reference.handle =
186 internal_object->reference.node;
203 break; 187 break;
204 } 188 }
205 break; 189 break;
206 190
207
208 case ACPI_TYPE_PROCESSOR: 191 case ACPI_TYPE_PROCESSOR:
209 192
210 external_object->processor.proc_id = internal_object->processor.proc_id; 193 external_object->processor.proc_id =
211 external_object->processor.pblk_address = internal_object->processor.address; 194 internal_object->processor.proc_id;
212 external_object->processor.pblk_length = internal_object->processor.length; 195 external_object->processor.pblk_address =
196 internal_object->processor.address;
197 external_object->processor.pblk_length =
198 internal_object->processor.length;
213 break; 199 break;
214 200
215
216 case ACPI_TYPE_POWER: 201 case ACPI_TYPE_POWER:
217 202
218 external_object->power_resource.system_level = 203 external_object->power_resource.system_level =
219 internal_object->power_resource.system_level; 204 internal_object->power_resource.system_level;
220 205
221 external_object->power_resource.resource_order = 206 external_object->power_resource.resource_order =
222 internal_object->power_resource.resource_order; 207 internal_object->power_resource.resource_order;
223 break; 208 break;
224 209
225
226 default: 210 default:
227 /* 211 /*
228 * There is no corresponding external object type 212 * There is no corresponding external object type
229 */ 213 */
230 return_ACPI_STATUS (AE_SUPPORT); 214 return_ACPI_STATUS(AE_SUPPORT);
231 } 215 }
232 216
233 return_ACPI_STATUS (status); 217 return_ACPI_STATUS(status);
234} 218}
235 219
236
237/******************************************************************************* 220/*******************************************************************************
238 * 221 *
239 * FUNCTION: acpi_ut_copy_ielement_to_eelement 222 * FUNCTION: acpi_ut_copy_ielement_to_eelement
@@ -247,25 +230,23 @@ acpi_ut_copy_isimple_to_esimple (
247 ******************************************************************************/ 230 ******************************************************************************/
248 231
249static acpi_status 232static acpi_status
250acpi_ut_copy_ielement_to_eelement ( 233acpi_ut_copy_ielement_to_eelement(u8 object_type,
251 u8 object_type, 234 union acpi_operand_object *source_object,
252 union acpi_operand_object *source_object, 235 union acpi_generic_state *state,
253 union acpi_generic_state *state, 236 void *context)
254 void *context)
255{ 237{
256 acpi_status status = AE_OK; 238 acpi_status status = AE_OK;
257 struct acpi_pkg_info *info = (struct acpi_pkg_info *) context; 239 struct acpi_pkg_info *info = (struct acpi_pkg_info *)context;
258 acpi_size object_space; 240 acpi_size object_space;
259 u32 this_index; 241 u32 this_index;
260 union acpi_object *target_object; 242 union acpi_object *target_object;
261
262 243
263 ACPI_FUNCTION_ENTRY (); 244 ACPI_FUNCTION_ENTRY();
264 245
265 246 this_index = state->pkg.index;
266 this_index = state->pkg.index;
267 target_object = (union acpi_object *) 247 target_object = (union acpi_object *)
268 &((union acpi_object *)(state->pkg.dest_object))->package.elements[this_index]; 248 &((union acpi_object *)(state->pkg.dest_object))->package.
249 elements[this_index];
269 250
270 switch (object_type) { 251 switch (object_type) {
271 case ACPI_COPY_TYPE_SIMPLE: 252 case ACPI_COPY_TYPE_SIMPLE:
@@ -273,23 +254,24 @@ acpi_ut_copy_ielement_to_eelement (
273 /* 254 /*
274 * This is a simple or null object 255 * This is a simple or null object
275 */ 256 */
276 status = acpi_ut_copy_isimple_to_esimple (source_object, 257 status = acpi_ut_copy_isimple_to_esimple(source_object,
277 target_object, info->free_space, &object_space); 258 target_object,
278 if (ACPI_FAILURE (status)) { 259 info->free_space,
260 &object_space);
261 if (ACPI_FAILURE(status)) {
279 return (status); 262 return (status);
280 } 263 }
281 break; 264 break;
282 265
283
284 case ACPI_COPY_TYPE_PACKAGE: 266 case ACPI_COPY_TYPE_PACKAGE:
285 267
286 /* 268 /*
287 * Build the package object 269 * Build the package object
288 */ 270 */
289 target_object->type = ACPI_TYPE_PACKAGE; 271 target_object->type = ACPI_TYPE_PACKAGE;
290 target_object->package.count = source_object->package.count; 272 target_object->package.count = source_object->package.count;
291 target_object->package.elements = 273 target_object->package.elements =
292 ACPI_CAST_PTR (union acpi_object, info->free_space); 274 ACPI_CAST_PTR(union acpi_object, info->free_space);
293 275
294 /* 276 /*
295 * Pass the new package object back to the package walk routine 277 * Pass the new package object back to the package walk routine
@@ -300,22 +282,22 @@ acpi_ut_copy_ielement_to_eelement (
300 * Save space for the array of objects (Package elements) 282 * Save space for the array of objects (Package elements)
301 * update the buffer length counter 283 * update the buffer length counter
302 */ 284 */
303 object_space = ACPI_ROUND_UP_TO_NATIVE_WORD ( 285 object_space = ACPI_ROUND_UP_TO_NATIVE_WORD((acpi_size)
304 (acpi_size) target_object->package.count * 286 target_object->
305 sizeof (union acpi_object)); 287 package.count *
288 sizeof(union
289 acpi_object));
306 break; 290 break;
307 291
308
309 default: 292 default:
310 return (AE_BAD_PARAMETER); 293 return (AE_BAD_PARAMETER);
311 } 294 }
312 295
313 info->free_space += object_space; 296 info->free_space += object_space;
314 info->length += object_space; 297 info->length += object_space;
315 return (status); 298 return (status);
316} 299}
317 300
318
319/******************************************************************************* 301/*******************************************************************************
320 * 302 *
321 * FUNCTION: acpi_ut_copy_ipackage_to_epackage 303 * FUNCTION: acpi_ut_copy_ipackage_to_epackage
@@ -336,55 +318,51 @@ acpi_ut_copy_ielement_to_eelement (
336 ******************************************************************************/ 318 ******************************************************************************/
337 319
338static acpi_status 320static acpi_status
339acpi_ut_copy_ipackage_to_epackage ( 321acpi_ut_copy_ipackage_to_epackage(union acpi_operand_object *internal_object,
340 union acpi_operand_object *internal_object, 322 u8 * buffer, acpi_size * space_used)
341 u8 *buffer,
342 acpi_size *space_used)
343{ 323{
344 union acpi_object *external_object; 324 union acpi_object *external_object;
345 acpi_status status; 325 acpi_status status;
346 struct acpi_pkg_info info; 326 struct acpi_pkg_info info;
347
348
349 ACPI_FUNCTION_TRACE ("ut_copy_ipackage_to_epackage");
350 327
328 ACPI_FUNCTION_TRACE("ut_copy_ipackage_to_epackage");
351 329
352 /* 330 /*
353 * First package at head of the buffer 331 * First package at head of the buffer
354 */ 332 */
355 external_object = ACPI_CAST_PTR (union acpi_object, buffer); 333 external_object = ACPI_CAST_PTR(union acpi_object, buffer);
356 334
357 /* 335 /*
358 * Free space begins right after the first package 336 * Free space begins right after the first package
359 */ 337 */
360 info.length = ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object)); 338 info.length = ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
361 info.free_space = buffer + ACPI_ROUND_UP_TO_NATIVE_WORD ( 339 info.free_space =
362 sizeof (union acpi_object)); 340 buffer + ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
363 info.object_space = 0; 341 info.object_space = 0;
364 info.num_packages = 1; 342 info.num_packages = 1;
365 343
366 external_object->type = ACPI_GET_OBJECT_TYPE (internal_object); 344 external_object->type = ACPI_GET_OBJECT_TYPE(internal_object);
367 external_object->package.count = internal_object->package.count; 345 external_object->package.count = internal_object->package.count;
368 external_object->package.elements = ACPI_CAST_PTR (union acpi_object, 346 external_object->package.elements = ACPI_CAST_PTR(union acpi_object,
369 info.free_space); 347 info.free_space);
370 348
371 /* 349 /*
372 * Leave room for an array of ACPI_OBJECTS in the buffer 350 * Leave room for an array of ACPI_OBJECTS in the buffer
373 * and move the free space past it 351 * and move the free space past it
374 */ 352 */
375 info.length += (acpi_size) external_object->package.count * 353 info.length += (acpi_size) external_object->package.count *
376 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object)); 354 ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
377 info.free_space += external_object->package.count * 355 info.free_space += external_object->package.count *
378 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object)); 356 ACPI_ROUND_UP_TO_NATIVE_WORD(sizeof(union acpi_object));
379 357
380 status = acpi_ut_walk_package_tree (internal_object, external_object, 358 status = acpi_ut_walk_package_tree(internal_object, external_object,
381 acpi_ut_copy_ielement_to_eelement, &info); 359 acpi_ut_copy_ielement_to_eelement,
360 &info);
382 361
383 *space_used = info.length; 362 *space_used = info.length;
384 return_ACPI_STATUS (status); 363 return_ACPI_STATUS(status);
385} 364}
386 365
387
388/******************************************************************************* 366/*******************************************************************************
389 * 367 *
390 * FUNCTION: acpi_ut_copy_iobject_to_eobject 368 * FUNCTION: acpi_ut_copy_iobject_to_eobject
@@ -400,44 +378,45 @@ acpi_ut_copy_ipackage_to_epackage (
400 ******************************************************************************/ 378 ******************************************************************************/
401 379
402acpi_status 380acpi_status
403acpi_ut_copy_iobject_to_eobject ( 381acpi_ut_copy_iobject_to_eobject(union acpi_operand_object *internal_object,
404 union acpi_operand_object *internal_object, 382 struct acpi_buffer *ret_buffer)
405 struct acpi_buffer *ret_buffer)
406{ 383{
407 acpi_status status; 384 acpi_status status;
408 385
386 ACPI_FUNCTION_TRACE("ut_copy_iobject_to_eobject");
409 387
410 ACPI_FUNCTION_TRACE ("ut_copy_iobject_to_eobject"); 388 if (ACPI_GET_OBJECT_TYPE(internal_object) == ACPI_TYPE_PACKAGE) {
411
412
413 if (ACPI_GET_OBJECT_TYPE (internal_object) == ACPI_TYPE_PACKAGE) {
414 /* 389 /*
415 * Package object: Copy all subobjects (including 390 * Package object: Copy all subobjects (including
416 * nested packages) 391 * nested packages)
417 */ 392 */
418 status = acpi_ut_copy_ipackage_to_epackage (internal_object, 393 status = acpi_ut_copy_ipackage_to_epackage(internal_object,
419 ret_buffer->pointer, &ret_buffer->length); 394 ret_buffer->pointer,
420 } 395 &ret_buffer->length);
421 else { 396 } else {
422 /* 397 /*
423 * Build a simple object (no nested objects) 398 * Build a simple object (no nested objects)
424 */ 399 */
425 status = acpi_ut_copy_isimple_to_esimple (internal_object, 400 status = acpi_ut_copy_isimple_to_esimple(internal_object,
426 (union acpi_object *) ret_buffer->pointer, 401 (union acpi_object *)
427 ((u8 *) ret_buffer->pointer + 402 ret_buffer->pointer,
428 ACPI_ROUND_UP_TO_NATIVE_WORD (sizeof (union acpi_object))), 403 ((u8 *) ret_buffer->
429 &ret_buffer->length); 404 pointer +
405 ACPI_ROUND_UP_TO_NATIVE_WORD
406 (sizeof
407 (union
408 acpi_object))),
409 &ret_buffer->length);
430 /* 410 /*
431 * build simple does not include the object size in the length 411 * build simple does not include the object size in the length
432 * so we add it in here 412 * so we add it in here
433 */ 413 */
434 ret_buffer->length += sizeof (union acpi_object); 414 ret_buffer->length += sizeof(union acpi_object);
435 } 415 }
436 416
437 return_ACPI_STATUS (status); 417 return_ACPI_STATUS(status);
438} 418}
439 419
440
441/******************************************************************************* 420/*******************************************************************************
442 * 421 *
443 * FUNCTION: acpi_ut_copy_esimple_to_isimple 422 * FUNCTION: acpi_ut_copy_esimple_to_isimple
@@ -455,15 +434,12 @@ acpi_ut_copy_iobject_to_eobject (
455 ******************************************************************************/ 434 ******************************************************************************/
456 435
457static acpi_status 436static acpi_status
458acpi_ut_copy_esimple_to_isimple ( 437acpi_ut_copy_esimple_to_isimple(union acpi_object *external_object,
459 union acpi_object *external_object, 438 union acpi_operand_object **ret_internal_object)
460 union acpi_operand_object **ret_internal_object)
461{ 439{
462 union acpi_operand_object *internal_object; 440 union acpi_operand_object *internal_object;
463
464
465 ACPI_FUNCTION_TRACE ("ut_copy_esimple_to_isimple");
466 441
442 ACPI_FUNCTION_TRACE("ut_copy_esimple_to_isimple");
467 443
468 /* 444 /*
469 * Simple types supported are: String, Buffer, Integer 445 * Simple types supported are: String, Buffer, Integer
@@ -473,58 +449,57 @@ acpi_ut_copy_esimple_to_isimple (
473 case ACPI_TYPE_BUFFER: 449 case ACPI_TYPE_BUFFER:
474 case ACPI_TYPE_INTEGER: 450 case ACPI_TYPE_INTEGER:
475 451
476 internal_object = acpi_ut_create_internal_object ( 452 internal_object = acpi_ut_create_internal_object((u8)
477 (u8) external_object->type); 453 external_object->
454 type);
478 if (!internal_object) { 455 if (!internal_object) {
479 return_ACPI_STATUS (AE_NO_MEMORY); 456 return_ACPI_STATUS(AE_NO_MEMORY);
480 } 457 }
481 break; 458 break;
482 459
483 default: 460 default:
484 /* All other types are not supported */ 461 /* All other types are not supported */
485 462
486 return_ACPI_STATUS (AE_SUPPORT); 463 return_ACPI_STATUS(AE_SUPPORT);
487 } 464 }
488 465
489
490 /* Must COPY string and buffer contents */ 466 /* Must COPY string and buffer contents */
491 467
492 switch (external_object->type) { 468 switch (external_object->type) {
493 case ACPI_TYPE_STRING: 469 case ACPI_TYPE_STRING:
494 470
495 internal_object->string.pointer = 471 internal_object->string.pointer =
496 ACPI_MEM_CALLOCATE ((acpi_size) external_object->string.length + 1); 472 ACPI_MEM_CALLOCATE((acpi_size) external_object->string.
473 length + 1);
497 if (!internal_object->string.pointer) { 474 if (!internal_object->string.pointer) {
498 goto error_exit; 475 goto error_exit;
499 } 476 }
500 477
501 ACPI_MEMCPY (internal_object->string.pointer, 478 ACPI_MEMCPY(internal_object->string.pointer,
502 external_object->string.pointer, 479 external_object->string.pointer,
503 external_object->string.length); 480 external_object->string.length);
504 481
505 internal_object->string.length = external_object->string.length; 482 internal_object->string.length = external_object->string.length;
506 break; 483 break;
507 484
508
509 case ACPI_TYPE_BUFFER: 485 case ACPI_TYPE_BUFFER:
510 486
511 internal_object->buffer.pointer = 487 internal_object->buffer.pointer =
512 ACPI_MEM_CALLOCATE (external_object->buffer.length); 488 ACPI_MEM_CALLOCATE(external_object->buffer.length);
513 if (!internal_object->buffer.pointer) { 489 if (!internal_object->buffer.pointer) {
514 goto error_exit; 490 goto error_exit;
515 } 491 }
516 492
517 ACPI_MEMCPY (internal_object->buffer.pointer, 493 ACPI_MEMCPY(internal_object->buffer.pointer,
518 external_object->buffer.pointer, 494 external_object->buffer.pointer,
519 external_object->buffer.length); 495 external_object->buffer.length);
520 496
521 internal_object->buffer.length = external_object->buffer.length; 497 internal_object->buffer.length = external_object->buffer.length;
522 break; 498 break;
523 499
524
525 case ACPI_TYPE_INTEGER: 500 case ACPI_TYPE_INTEGER:
526 501
527 internal_object->integer.value = external_object->integer.value; 502 internal_object->integer.value = external_object->integer.value;
528 break; 503 break;
529 504
530 default: 505 default:
@@ -533,15 +508,13 @@ acpi_ut_copy_esimple_to_isimple (
533 } 508 }
534 509
535 *ret_internal_object = internal_object; 510 *ret_internal_object = internal_object;
536 return_ACPI_STATUS (AE_OK); 511 return_ACPI_STATUS(AE_OK);
537
538 512
539error_exit: 513 error_exit:
540 acpi_ut_remove_reference (internal_object); 514 acpi_ut_remove_reference(internal_object);
541 return_ACPI_STATUS (AE_NO_MEMORY); 515 return_ACPI_STATUS(AE_NO_MEMORY);
542} 516}
543 517
544
545#ifdef ACPI_FUTURE_IMPLEMENTATION 518#ifdef ACPI_FUTURE_IMPLEMENTATION
546/* Code to convert packages that are parameters to control methods */ 519/* Code to convert packages that are parameters to control methods */
547 520
@@ -565,22 +538,18 @@ error_exit:
565 ******************************************************************************/ 538 ******************************************************************************/
566 539
567static acpi_status 540static acpi_status
568acpi_ut_copy_epackage_to_ipackage ( 541acpi_ut_copy_epackage_to_ipackage(union acpi_operand_object *internal_object,
569 union acpi_operand_object *internal_object, 542 u8 * buffer, u32 * space_used)
570 u8 *buffer,
571 u32 *space_used)
572{ 543{
573 u8 *free_space; 544 u8 *free_space;
574 union acpi_object *external_object; 545 union acpi_object *external_object;
575 u32 length = 0; 546 u32 length = 0;
576 u32 this_index; 547 u32 this_index;
577 u32 object_space = 0; 548 u32 object_space = 0;
578 union acpi_operand_object *this_internal_obj; 549 union acpi_operand_object *this_internal_obj;
579 union acpi_object *this_external_obj; 550 union acpi_object *this_external_obj;
580
581
582 ACPI_FUNCTION_TRACE ("ut_copy_epackage_to_ipackage");
583 551
552 ACPI_FUNCTION_TRACE("ut_copy_epackage_to_ipackage");
584 553
585 /* 554 /*
586 * First package at head of the buffer 555 * First package at head of the buffer
@@ -592,24 +561,22 @@ acpi_ut_copy_epackage_to_ipackage (
592 */ 561 */
593 free_space = buffer + sizeof(union acpi_object); 562 free_space = buffer + sizeof(union acpi_object);
594 563
595 564 external_object->type = ACPI_GET_OBJECT_TYPE(internal_object);
596 external_object->type = ACPI_GET_OBJECT_TYPE (internal_object); 565 external_object->package.count = internal_object->package.count;
597 external_object->package.count = internal_object->package.count; 566 external_object->package.elements = (union acpi_object *)free_space;
598 external_object->package.elements = (union acpi_object *)free_space;
599 567
600 /* 568 /*
601 * Build an array of ACPI_OBJECTS in the buffer 569 * Build an array of ACPI_OBJECTS in the buffer
602 * and move the free space past it 570 * and move the free space past it
603 */ 571 */
604 free_space += external_object->package.count * sizeof(union acpi_object); 572 free_space +=
605 573 external_object->package.count * sizeof(union acpi_object);
606 574
607 /* Call walk_package */ 575 /* Call walk_package */
608 576
609} 577}
610 578
611#endif /* Future implementation */ 579#endif /* Future implementation */
612
613 580
614/******************************************************************************* 581/*******************************************************************************
615 * 582 *
@@ -625,37 +592,35 @@ acpi_ut_copy_epackage_to_ipackage (
625 ******************************************************************************/ 592 ******************************************************************************/
626 593
627acpi_status 594acpi_status
628acpi_ut_copy_eobject_to_iobject ( 595acpi_ut_copy_eobject_to_iobject(union acpi_object *external_object,
629 union acpi_object *external_object, 596 union acpi_operand_object **internal_object)
630 union acpi_operand_object **internal_object)
631{ 597{
632 acpi_status status; 598 acpi_status status;
633
634
635 ACPI_FUNCTION_TRACE ("ut_copy_eobject_to_iobject");
636 599
600 ACPI_FUNCTION_TRACE("ut_copy_eobject_to_iobject");
637 601
638 if (external_object->type == ACPI_TYPE_PACKAGE) { 602 if (external_object->type == ACPI_TYPE_PACKAGE) {
639 /* 603 /*
640 * Packages as external input to control methods are not supported, 604 * Packages as external input to control methods are not supported,
641 */ 605 */
642 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 606 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
643 "Packages as parameters not implemented!\n")); 607 "Packages as parameters not implemented!\n"));
644 608
645 return_ACPI_STATUS (AE_NOT_IMPLEMENTED); 609 return_ACPI_STATUS(AE_NOT_IMPLEMENTED);
646 } 610 }
647 611
648 else { 612 else {
649 /* 613 /*
650 * Build a simple object (no nested objects) 614 * Build a simple object (no nested objects)
651 */ 615 */
652 status = acpi_ut_copy_esimple_to_isimple (external_object, internal_object); 616 status =
617 acpi_ut_copy_esimple_to_isimple(external_object,
618 internal_object);
653 } 619 }
654 620
655 return_ACPI_STATUS (status); 621 return_ACPI_STATUS(status);
656} 622}
657 623
658
659/******************************************************************************* 624/*******************************************************************************
660 * 625 *
661 * FUNCTION: acpi_ut_copy_simple_object 626 * FUNCTION: acpi_ut_copy_simple_object
@@ -671,23 +636,21 @@ acpi_ut_copy_eobject_to_iobject (
671 ******************************************************************************/ 636 ******************************************************************************/
672 637
673static acpi_status 638static acpi_status
674acpi_ut_copy_simple_object ( 639acpi_ut_copy_simple_object(union acpi_operand_object *source_desc,
675 union acpi_operand_object *source_desc, 640 union acpi_operand_object *dest_desc)
676 union acpi_operand_object *dest_desc)
677{ 641{
678 u16 reference_count; 642 u16 reference_count;
679 union acpi_operand_object *next_object; 643 union acpi_operand_object *next_object;
680
681 644
682 /* Save fields from destination that we don't want to overwrite */ 645 /* Save fields from destination that we don't want to overwrite */
683 646
684 reference_count = dest_desc->common.reference_count; 647 reference_count = dest_desc->common.reference_count;
685 next_object = dest_desc->common.next_object; 648 next_object = dest_desc->common.next_object;
686 649
687 /* Copy the entire source object over the destination object*/ 650 /* Copy the entire source object over the destination object */
688 651
689 ACPI_MEMCPY ((char *) dest_desc, (char *) source_desc, 652 ACPI_MEMCPY((char *)dest_desc, (char *)source_desc,
690 sizeof (union acpi_operand_object)); 653 sizeof(union acpi_operand_object));
691 654
692 /* Restore the saved fields */ 655 /* Restore the saved fields */
693 656
@@ -700,7 +663,7 @@ acpi_ut_copy_simple_object (
700 663
701 /* Handle the objects with extra data */ 664 /* Handle the objects with extra data */
702 665
703 switch (ACPI_GET_OBJECT_TYPE (dest_desc)) { 666 switch (ACPI_GET_OBJECT_TYPE(dest_desc)) {
704 case ACPI_TYPE_BUFFER: 667 case ACPI_TYPE_BUFFER:
705 /* 668 /*
706 * Allocate and copy the actual buffer if and only if: 669 * Allocate and copy the actual buffer if and only if:
@@ -708,18 +671,18 @@ acpi_ut_copy_simple_object (
708 * 2) The buffer has a length > 0 671 * 2) The buffer has a length > 0
709 */ 672 */
710 if ((source_desc->buffer.pointer) && 673 if ((source_desc->buffer.pointer) &&
711 (source_desc->buffer.length)) { 674 (source_desc->buffer.length)) {
712 dest_desc->buffer.pointer = 675 dest_desc->buffer.pointer =
713 ACPI_MEM_ALLOCATE (source_desc->buffer.length); 676 ACPI_MEM_ALLOCATE(source_desc->buffer.length);
714 if (!dest_desc->buffer.pointer) { 677 if (!dest_desc->buffer.pointer) {
715 return (AE_NO_MEMORY); 678 return (AE_NO_MEMORY);
716 } 679 }
717 680
718 /* Copy the actual buffer data */ 681 /* Copy the actual buffer data */
719 682
720 ACPI_MEMCPY (dest_desc->buffer.pointer, 683 ACPI_MEMCPY(dest_desc->buffer.pointer,
721 source_desc->buffer.pointer, 684 source_desc->buffer.pointer,
722 source_desc->buffer.length); 685 source_desc->buffer.length);
723 } 686 }
724 break; 687 break;
725 688
@@ -731,15 +694,17 @@ acpi_ut_copy_simple_object (
731 */ 694 */
732 if (source_desc->string.pointer) { 695 if (source_desc->string.pointer) {
733 dest_desc->string.pointer = 696 dest_desc->string.pointer =
734 ACPI_MEM_ALLOCATE ((acpi_size) source_desc->string.length + 1); 697 ACPI_MEM_ALLOCATE((acpi_size) source_desc->string.
698 length + 1);
735 if (!dest_desc->string.pointer) { 699 if (!dest_desc->string.pointer) {
736 return (AE_NO_MEMORY); 700 return (AE_NO_MEMORY);
737 } 701 }
738 702
739 /* Copy the actual string data */ 703 /* Copy the actual string data */
740 704
741 ACPI_MEMCPY (dest_desc->string.pointer, source_desc->string.pointer, 705 ACPI_MEMCPY(dest_desc->string.pointer,
742 (acpi_size) source_desc->string.length + 1); 706 source_desc->string.pointer,
707 (acpi_size) source_desc->string.length + 1);
743 } 708 }
744 break; 709 break;
745 710
@@ -748,7 +713,7 @@ acpi_ut_copy_simple_object (
748 * We copied the reference object, so we now must add a reference 713 * We copied the reference object, so we now must add a reference
749 * to the object pointed to by the reference 714 * to the object pointed to by the reference
750 */ 715 */
751 acpi_ut_add_reference (source_desc->reference.object); 716 acpi_ut_add_reference(source_desc->reference.object);
752 break; 717 break;
753 718
754 default: 719 default:
@@ -759,7 +724,6 @@ acpi_ut_copy_simple_object (
759 return (AE_OK); 724 return (AE_OK);
760} 725}
761 726
762
763/******************************************************************************* 727/*******************************************************************************
764 * 728 *
765 * FUNCTION: acpi_ut_copy_ielement_to_ielement 729 * FUNCTION: acpi_ut_copy_ielement_to_ielement
@@ -773,24 +737,21 @@ acpi_ut_copy_simple_object (
773 ******************************************************************************/ 737 ******************************************************************************/
774 738
775static acpi_status 739static acpi_status
776acpi_ut_copy_ielement_to_ielement ( 740acpi_ut_copy_ielement_to_ielement(u8 object_type,
777 u8 object_type, 741 union acpi_operand_object *source_object,
778 union acpi_operand_object *source_object, 742 union acpi_generic_state *state,
779 union acpi_generic_state *state, 743 void *context)
780 void *context)
781{ 744{
782 acpi_status status = AE_OK; 745 acpi_status status = AE_OK;
783 u32 this_index; 746 u32 this_index;
784 union acpi_operand_object **this_target_ptr; 747 union acpi_operand_object **this_target_ptr;
785 union acpi_operand_object *target_object; 748 union acpi_operand_object *target_object;
786 749
750 ACPI_FUNCTION_ENTRY();
787 751
788 ACPI_FUNCTION_ENTRY (); 752 this_index = state->pkg.index;
789
790
791 this_index = state->pkg.index;
792 this_target_ptr = (union acpi_operand_object **) 753 this_target_ptr = (union acpi_operand_object **)
793 &state->pkg.dest_object->package.elements[this_index]; 754 &state->pkg.dest_object->package.elements[this_index];
794 755
795 switch (object_type) { 756 switch (object_type) {
796 case ACPI_COPY_TYPE_SIMPLE: 757 case ACPI_COPY_TYPE_SIMPLE:
@@ -801,34 +762,36 @@ acpi_ut_copy_ielement_to_ielement (
801 /* 762 /*
802 * This is a simple object, just copy it 763 * This is a simple object, just copy it
803 */ 764 */
804 target_object = acpi_ut_create_internal_object ( 765 target_object =
805 ACPI_GET_OBJECT_TYPE (source_object)); 766 acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE
767 (source_object));
806 if (!target_object) { 768 if (!target_object) {
807 return (AE_NO_MEMORY); 769 return (AE_NO_MEMORY);
808 } 770 }
809 771
810 status = acpi_ut_copy_simple_object (source_object, target_object); 772 status =
811 if (ACPI_FAILURE (status)) { 773 acpi_ut_copy_simple_object(source_object,
774 target_object);
775 if (ACPI_FAILURE(status)) {
812 goto error_exit; 776 goto error_exit;
813 } 777 }
814 778
815 *this_target_ptr = target_object; 779 *this_target_ptr = target_object;
816 } 780 } else {
817 else {
818 /* Pass through a null element */ 781 /* Pass through a null element */
819 782
820 *this_target_ptr = NULL; 783 *this_target_ptr = NULL;
821 } 784 }
822 break; 785 break;
823 786
824
825 case ACPI_COPY_TYPE_PACKAGE: 787 case ACPI_COPY_TYPE_PACKAGE:
826 788
827 /* 789 /*
828 * This object is a package - go down another nesting level 790 * This object is a package - go down another nesting level
829 * Create and build the package object 791 * Create and build the package object
830 */ 792 */
831 target_object = acpi_ut_create_internal_object (ACPI_TYPE_PACKAGE); 793 target_object =
794 acpi_ut_create_internal_object(ACPI_TYPE_PACKAGE);
832 if (!target_object) { 795 if (!target_object) {
833 return (AE_NO_MEMORY); 796 return (AE_NO_MEMORY);
834 } 797 }
@@ -840,8 +803,8 @@ acpi_ut_copy_ielement_to_ielement (
840 * Create the object array 803 * Create the object array
841 */ 804 */
842 target_object->package.elements = 805 target_object->package.elements =
843 ACPI_MEM_CALLOCATE (((acpi_size) source_object->package.count + 1) * 806 ACPI_MEM_CALLOCATE(((acpi_size) source_object->package.
844 sizeof (void *)); 807 count + 1) * sizeof(void *));
845 if (!target_object->package.elements) { 808 if (!target_object->package.elements) {
846 status = AE_NO_MEMORY; 809 status = AE_NO_MEMORY;
847 goto error_exit; 810 goto error_exit;
@@ -858,19 +821,17 @@ acpi_ut_copy_ielement_to_ielement (
858 *this_target_ptr = target_object; 821 *this_target_ptr = target_object;
859 break; 822 break;
860 823
861
862 default: 824 default:
863 return (AE_BAD_PARAMETER); 825 return (AE_BAD_PARAMETER);
864 } 826 }
865 827
866 return (status); 828 return (status);
867 829
868error_exit: 830 error_exit:
869 acpi_ut_remove_reference (target_object); 831 acpi_ut_remove_reference(target_object);
870 return (status); 832 return (status);
871} 833}
872 834
873
874/******************************************************************************* 835/*******************************************************************************
875 * 836 *
876 * FUNCTION: acpi_ut_copy_ipackage_to_ipackage 837 * FUNCTION: acpi_ut_copy_ipackage_to_ipackage
@@ -886,49 +847,46 @@ error_exit:
886 ******************************************************************************/ 847 ******************************************************************************/
887 848
888static acpi_status 849static acpi_status
889acpi_ut_copy_ipackage_to_ipackage ( 850acpi_ut_copy_ipackage_to_ipackage(union acpi_operand_object *source_obj,
890 union acpi_operand_object *source_obj, 851 union acpi_operand_object *dest_obj,
891 union acpi_operand_object *dest_obj, 852 struct acpi_walk_state *walk_state)
892 struct acpi_walk_state *walk_state)
893{ 853{
894 acpi_status status = AE_OK; 854 acpi_status status = AE_OK;
895
896
897 ACPI_FUNCTION_TRACE ("ut_copy_ipackage_to_ipackage");
898 855
856 ACPI_FUNCTION_TRACE("ut_copy_ipackage_to_ipackage");
899 857
900 dest_obj->common.type = ACPI_GET_OBJECT_TYPE (source_obj); 858 dest_obj->common.type = ACPI_GET_OBJECT_TYPE(source_obj);
901 dest_obj->common.flags = source_obj->common.flags; 859 dest_obj->common.flags = source_obj->common.flags;
902 dest_obj->package.count = source_obj->package.count; 860 dest_obj->package.count = source_obj->package.count;
903 861
904 /* 862 /*
905 * Create the object array and walk the source package tree 863 * Create the object array and walk the source package tree
906 */ 864 */
907 dest_obj->package.elements = ACPI_MEM_CALLOCATE ( 865 dest_obj->package.elements = ACPI_MEM_CALLOCATE(((acpi_size)
908 ((acpi_size) source_obj->package.count + 1) * 866 source_obj->package.
909 sizeof (void *)); 867 count +
868 1) * sizeof(void *));
910 if (!dest_obj->package.elements) { 869 if (!dest_obj->package.elements) {
911 ACPI_REPORT_ERROR ( 870 ACPI_REPORT_ERROR(("aml_build_copy_internal_package_object: Package allocation failure\n"));
912 ("aml_build_copy_internal_package_object: Package allocation failure\n")); 871 return_ACPI_STATUS(AE_NO_MEMORY);
913 return_ACPI_STATUS (AE_NO_MEMORY);
914 } 872 }
915 873
916 /* 874 /*
917 * Copy the package element-by-element by walking the package "tree". 875 * Copy the package element-by-element by walking the package "tree".
918 * This handles nested packages of arbitrary depth. 876 * This handles nested packages of arbitrary depth.
919 */ 877 */
920 status = acpi_ut_walk_package_tree (source_obj, dest_obj, 878 status = acpi_ut_walk_package_tree(source_obj, dest_obj,
921 acpi_ut_copy_ielement_to_ielement, walk_state); 879 acpi_ut_copy_ielement_to_ielement,
922 if (ACPI_FAILURE (status)) { 880 walk_state);
881 if (ACPI_FAILURE(status)) {
923 /* On failure, delete the destination package object */ 882 /* On failure, delete the destination package object */
924 883
925 acpi_ut_remove_reference (dest_obj); 884 acpi_ut_remove_reference(dest_obj);
926 } 885 }
927 886
928 return_ACPI_STATUS (status); 887 return_ACPI_STATUS(status);
929} 888}
930 889
931
932/******************************************************************************* 890/*******************************************************************************
933 * 891 *
934 * FUNCTION: acpi_ut_copy_iobject_to_iobject 892 * FUNCTION: acpi_ut_copy_iobject_to_iobject
@@ -944,35 +902,31 @@ acpi_ut_copy_ipackage_to_ipackage (
944 ******************************************************************************/ 902 ******************************************************************************/
945 903
946acpi_status 904acpi_status
947acpi_ut_copy_iobject_to_iobject ( 905acpi_ut_copy_iobject_to_iobject(union acpi_operand_object *source_desc,
948 union acpi_operand_object *source_desc, 906 union acpi_operand_object **dest_desc,
949 union acpi_operand_object **dest_desc, 907 struct acpi_walk_state *walk_state)
950 struct acpi_walk_state *walk_state)
951{ 908{
952 acpi_status status = AE_OK; 909 acpi_status status = AE_OK;
953
954
955 ACPI_FUNCTION_TRACE ("ut_copy_iobject_to_iobject");
956 910
911 ACPI_FUNCTION_TRACE("ut_copy_iobject_to_iobject");
957 912
958 /* Create the top level object */ 913 /* Create the top level object */
959 914
960 *dest_desc = acpi_ut_create_internal_object (ACPI_GET_OBJECT_TYPE (source_desc)); 915 *dest_desc =
916 acpi_ut_create_internal_object(ACPI_GET_OBJECT_TYPE(source_desc));
961 if (!*dest_desc) { 917 if (!*dest_desc) {
962 return_ACPI_STATUS (AE_NO_MEMORY); 918 return_ACPI_STATUS(AE_NO_MEMORY);
963 } 919 }
964 920
965 /* Copy the object and possible subobjects */ 921 /* Copy the object and possible subobjects */
966 922
967 if (ACPI_GET_OBJECT_TYPE (source_desc) == ACPI_TYPE_PACKAGE) { 923 if (ACPI_GET_OBJECT_TYPE(source_desc) == ACPI_TYPE_PACKAGE) {
968 status = acpi_ut_copy_ipackage_to_ipackage (source_desc, *dest_desc, 924 status =
969 walk_state); 925 acpi_ut_copy_ipackage_to_ipackage(source_desc, *dest_desc,
970 } 926 walk_state);
971 else { 927 } else {
972 status = acpi_ut_copy_simple_object (source_desc, *dest_desc); 928 status = acpi_ut_copy_simple_object(source_desc, *dest_desc);
973 } 929 }
974 930
975 return_ACPI_STATUS (status); 931 return_ACPI_STATUS(status);
976} 932}
977
978