utcopy.c revision 85756
1/****************************************************************************** 2 * 3 * Module Name: utcopy - Internal to external object translation utilities 4 * $Revision: 83 $ 5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. 13 * All rights reserved. 14 * 15 * 2. License 16 * 17 * 2.1. This is your license from Intel Corp. under its intellectual property 18 * rights. You may have additional license terms from the party that provided 19 * you this software, covering your right to use that party's intellectual 20 * property rights. 21 * 22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 23 * copy of the source code appearing in this file ("Covered Code") an 24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25 * base code distributed originally by Intel ("Original Intel Code") to copy, 26 * make derivatives, distribute, use and display any portion of the Covered 27 * Code in any form, with the right to sublicense such rights; and 28 * 29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30 * license (with the right to sublicense), under only those claims of Intel 31 * patents that are infringed by the Original Intel Code, to make, use, sell, 32 * offer to sell, and import the Covered Code and derivative works thereof 33 * solely to the minimum extent necessary to exercise the above copyright 34 * license, and in no event shall the patent license extend to any additions 35 * to or modifications of the Original Intel Code. No other license or right 36 * is granted directly or by implication, estoppel or otherwise; 37 * 38 * The above copyright and patent license is granted only if the following 39 * conditions are met: 40 * 41 * 3. Conditions 42 * 43 * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44 * Redistribution of source code of any substantial portion of the Covered 45 * Code or modification with rights to further distribute source must include 46 * the above Copyright Notice, the above License, this list of Conditions, 47 * and the following Disclaimer and Export Compliance provision. In addition, 48 * Licensee must cause all Covered Code to which Licensee contributes to 49 * contain a file documenting the changes Licensee made to create that Covered 50 * Code and the date of any change. Licensee must include in that file the 51 * documentation of any changes made by any predecessor Licensee. Licensee 52 * must include a prominent statement that the modification is derived, 53 * directly or indirectly, from Original Intel Code. 54 * 55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56 * Redistribution of source code of any substantial portion of the Covered 57 * Code or modification without rights to further distribute source must 58 * include the following Disclaimer and Export Compliance provision in the 59 * documentation and/or other materials provided with distribution. In 60 * addition, Licensee may not authorize further sublicense of source of any 61 * portion of the Covered Code, and must include terms to the effect that the 62 * license from Licensee to its licensee is limited to the intellectual 63 * property embodied in the software Licensee provides to its licensee, and 64 * not to intellectual property embodied in modifications its licensee may 65 * make. 66 * 67 * 3.3. Redistribution of Executable. Redistribution in executable form of any 68 * substantial portion of the Covered Code or modification must reproduce the 69 * above Copyright Notice, and the following Disclaimer and Export Compliance 70 * provision in the documentation and/or other materials provided with the 71 * distribution. 72 * 73 * 3.4. Intel retains all right, title, and interest in and to the Original 74 * Intel Code. 75 * 76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77 * Intel shall be used in advertising or otherwise to promote the sale, use or 78 * other dealings in products derived from or relating to the Covered Code 79 * without prior written authorization from Intel. 80 * 81 * 4. Disclaimer and Export Compliance 82 * 83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 89 * PARTICULAR PURPOSE. 90 * 91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98 * LIMITED REMEDY. 99 * 100 * 4.3. Licensee shall not export, either directly or indirectly, any of this 101 * software or system incorporating such software without first obtaining any 102 * required license or other approval from the U. S. Department of Commerce or 103 * any other agency or department of the United States Government. In the 104 * event Licensee exports any such software from the United States or 105 * re-exports any such software from a foreign destination, Licensee shall 106 * ensure that the distribution and export/re-export of the software is in 107 * compliance with all laws, regulations, orders, or other restrictions of the 108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109 * any of its subsidiaries will export/re-export any technical data, process, 110 * software, or service, directly or indirectly, to any country for which the 111 * United States government or any agency thereof requires an export license, 112 * other governmental approval, or letter of assurance, without first obtaining 113 * such license, approval or letter. 114 * 115 *****************************************************************************/ 116 117#define __UTCOPY_C__ 118 119#include "acpi.h" 120#include "acinterp.h" 121#include "acnamesp.h" 122#include "amlcode.h" 123 124 125#define _COMPONENT ACPI_UTILITIES 126 MODULE_NAME ("utcopy") 127 128 129/******************************************************************************* 130 * 131 * FUNCTION: AcpiUtCopyIsimpleToEsimple 132 * 133 * PARAMETERS: *InternalObject - Pointer to the object we are examining 134 * *Buffer - Where the object is returned 135 * *SpaceUsed - Where the data length is returned 136 * 137 * RETURN: Status 138 * 139 * DESCRIPTION: This function is called to place a simple object in a user 140 * buffer. 141 * 142 * The buffer is assumed to have sufficient space for the object. 143 * 144 ******************************************************************************/ 145 146static ACPI_STATUS 147AcpiUtCopyIsimpleToEsimple ( 148 ACPI_OPERAND_OBJECT *InternalObject, 149 ACPI_OBJECT *ExternalObject, 150 UINT8 *DataSpace, 151 UINT32 *BufferSpaceUsed) 152{ 153 UINT32 Length = 0; 154 ACPI_STATUS Status = AE_OK; 155 156 157 FUNCTION_TRACE ("UtCopyIsimpleToEsimple"); 158 159 160 /* 161 * Check for NULL object case (could be an uninitialized 162 * package element 163 */ 164 if (!InternalObject) 165 { 166 *BufferSpaceUsed = 0; 167 return_ACPI_STATUS (AE_OK); 168 } 169 170 /* Always clear the external object */ 171 172 MEMSET (ExternalObject, 0, sizeof (ACPI_OBJECT)); 173 174 /* 175 * In general, the external object will be the same type as 176 * the internal object 177 */ 178 ExternalObject->Type = InternalObject->Common.Type; 179 180 /* However, only a limited number of external types are supported */ 181 182 switch (InternalObject->Common.Type) 183 { 184 185 case ACPI_TYPE_STRING: 186 187 Length = InternalObject->String.Length + 1; 188 ExternalObject->String.Length = InternalObject->String.Length; 189 ExternalObject->String.Pointer = (NATIVE_CHAR *) DataSpace; 190 MEMCPY ((void *) DataSpace, (void *) InternalObject->String.Pointer, Length); 191 break; 192 193 194 case ACPI_TYPE_BUFFER: 195 196 Length = InternalObject->Buffer.Length; 197 ExternalObject->Buffer.Length = InternalObject->Buffer.Length; 198 ExternalObject->Buffer.Pointer = DataSpace; 199 MEMCPY ((void *) DataSpace, (void *) InternalObject->Buffer.Pointer, Length); 200 break; 201 202 203 case ACPI_TYPE_INTEGER: 204 205 ExternalObject->Integer.Value= InternalObject->Integer.Value; 206 break; 207 208 209 case INTERNAL_TYPE_REFERENCE: 210 211 /* 212 * This is an object reference. Attempt to dereference it. 213 */ 214 switch (InternalObject->Reference.Opcode) 215 { 216 case AML_ZERO_OP: 217 ExternalObject->Type = ACPI_TYPE_INTEGER; 218 ExternalObject->Integer.Value = 0; 219 break; 220 221 case AML_ONE_OP: 222 ExternalObject->Type = ACPI_TYPE_INTEGER; 223 ExternalObject->Integer.Value = 1; 224 break; 225 226 case AML_ONES_OP: 227 ExternalObject->Type = ACPI_TYPE_INTEGER; 228 ExternalObject->Integer.Value = ACPI_INTEGER_MAX; 229 break; 230 231 case AML_REVISION_OP: 232 ExternalObject->Type = ACPI_TYPE_INTEGER; 233 ExternalObject->Integer.Value = ACPI_CA_SUPPORT_LEVEL; 234 break; 235 236 case AML_INT_NAMEPATH_OP: 237 /* 238 * This is a named reference, get the string. We already know that 239 * we have room for it, use max length 240 */ 241 Length = MAX_STRING_LENGTH; 242 ExternalObject->Type = ACPI_TYPE_STRING; 243 ExternalObject->String.Pointer = (NATIVE_CHAR *) DataSpace; 244 Status = AcpiNsHandleToPathname ((ACPI_HANDLE *) InternalObject->Reference.Node, 245 &Length, (char *) DataSpace); 246 247 /* Converted (external) string length is returned from above */ 248 249 ExternalObject->String.Length = Length; 250 break; 251 252 default: 253 /* 254 * Use the object type of "Any" to indicate a reference 255 * to object containing a handle to an ACPI named object. 256 */ 257 ExternalObject->Type = ACPI_TYPE_ANY; 258 ExternalObject->Reference.Handle = InternalObject->Reference.Node; 259 break; 260 } 261 break; 262 263 264 case ACPI_TYPE_PROCESSOR: 265 266 ExternalObject->Processor.ProcId = InternalObject->Processor.ProcId; 267 ExternalObject->Processor.PblkAddress = InternalObject->Processor.Address; 268 ExternalObject->Processor.PblkLength = InternalObject->Processor.Length; 269 break; 270 271 272 case ACPI_TYPE_POWER: 273 274 ExternalObject->PowerResource.SystemLevel = 275 InternalObject->PowerResource.SystemLevel; 276 277 ExternalObject->PowerResource.ResourceOrder = 278 InternalObject->PowerResource.ResourceOrder; 279 break; 280 281 282 default: 283 /* 284 * There is no corresponding external object type 285 */ 286 return_ACPI_STATUS (AE_SUPPORT); 287 break; 288 } 289 290 291 *BufferSpaceUsed = (UINT32) ROUND_UP_TO_NATIVE_WORD (Length); 292 293 return_ACPI_STATUS (Status); 294} 295 296 297/******************************************************************************* 298 * 299 * FUNCTION: AcpiUtCopyIelementToEelement 300 * 301 * PARAMETERS: ACPI_PKG_CALLBACK 302 * 303 * RETURN: Status 304 * 305 * DESCRIPTION: Copy one package element to another package element 306 * 307 ******************************************************************************/ 308 309ACPI_STATUS 310AcpiUtCopyIelementToEelement ( 311 UINT8 ObjectType, 312 ACPI_OPERAND_OBJECT *SourceObject, 313 ACPI_GENERIC_STATE *State, 314 void *Context) 315{ 316 ACPI_STATUS Status = AE_OK; 317 ACPI_PKG_INFO *Info = (ACPI_PKG_INFO *) Context; 318 UINT32 ObjectSpace; 319 UINT32 ThisIndex; 320 ACPI_OBJECT *TargetObject; 321 322 323 FUNCTION_ENTRY (); 324 325 326 ThisIndex = State->Pkg.Index; 327 TargetObject = (ACPI_OBJECT *) 328 &((ACPI_OBJECT *)(State->Pkg.DestObject))->Package.Elements[ThisIndex]; 329 330 switch (ObjectType) 331 { 332 case ACPI_COPY_TYPE_SIMPLE: 333 334 /* 335 * This is a simple or null object -- get the size 336 */ 337 Status = AcpiUtCopyIsimpleToEsimple (SourceObject, 338 TargetObject, Info->FreeSpace, &ObjectSpace); 339 if (ACPI_FAILURE (Status)) 340 { 341 return (Status); 342 } 343 344 break; 345 346 case ACPI_COPY_TYPE_PACKAGE: 347 348 /* 349 * Build the package object 350 */ 351 TargetObject->Type = ACPI_TYPE_PACKAGE; 352 TargetObject->Package.Count = SourceObject->Package.Count; 353 TargetObject->Package.Elements = (ACPI_OBJECT *) Info->FreeSpace; 354 355 /* 356 * Pass the new package object back to the package walk routine 357 */ 358 State->Pkg.ThisTargetObj = TargetObject; 359 360 /* 361 * Save space for the array of objects (Package elements) 362 * update the buffer length counter 363 */ 364 ObjectSpace = (UINT32) ROUND_UP_TO_NATIVE_WORD ( 365 TargetObject->Package.Count * sizeof (ACPI_OBJECT)); 366 break; 367 368 default: 369 return (AE_BAD_PARAMETER); 370 } 371 372 373 Info->FreeSpace += ObjectSpace; 374 Info->Length += ObjectSpace; 375 376 return (Status); 377} 378 379 380/******************************************************************************* 381 * 382 * FUNCTION: AcpiUtCopyIpackageToEpackage 383 * 384 * PARAMETERS: *InternalObject - Pointer to the object we are returning 385 * *Buffer - Where the object is returned 386 * *SpaceUsed - Where the object length is returned 387 * 388 * RETURN: Status 389 * 390 * DESCRIPTION: This function is called to place a package object in a user 391 * buffer. A package object by definition contains other objects. 392 * 393 * The buffer is assumed to have sufficient space for the object. 394 * The caller must have verified the buffer length needed using the 395 * AcpiUtGetObjectSize function before calling this function. 396 * 397 ******************************************************************************/ 398 399static ACPI_STATUS 400AcpiUtCopyIpackageToEpackage ( 401 ACPI_OPERAND_OBJECT *InternalObject, 402 UINT8 *Buffer, 403 UINT32 *SpaceUsed) 404{ 405 ACPI_OBJECT *ExternalObject; 406 ACPI_STATUS Status; 407 ACPI_PKG_INFO Info; 408 409 410 FUNCTION_TRACE ("UtCopyIpackageToEpackage"); 411 412 413 /* 414 * First package at head of the buffer 415 */ 416 ExternalObject = (ACPI_OBJECT *) Buffer; 417 418 /* 419 * Free space begins right after the first package 420 */ 421 Info.Length = 0; 422 Info.ObjectSpace = 0; 423 Info.NumPackages = 1; 424 Info.FreeSpace = Buffer + ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); 425 426 427 ExternalObject->Type = InternalObject->Common.Type; 428 ExternalObject->Package.Count = InternalObject->Package.Count; 429 ExternalObject->Package.Elements = (ACPI_OBJECT *) Info.FreeSpace; 430 431 432 /* 433 * Build an array of ACPI_OBJECTS in the buffer 434 * and move the free space past it 435 */ 436 Info.FreeSpace += ExternalObject->Package.Count * 437 ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT)); 438 439 440 Status = AcpiUtWalkPackageTree (InternalObject, ExternalObject, 441 AcpiUtCopyIelementToEelement, &Info); 442 443 *SpaceUsed = Info.Length; 444 445 return_ACPI_STATUS (Status); 446 447} 448 449/******************************************************************************* 450 * 451 * FUNCTION: AcpiUtCopyIobjectToEobject 452 * 453 * PARAMETERS: *InternalObject - The internal object to be converted 454 * *BufferPtr - Where the object is returned 455 * 456 * RETURN: Status 457 * 458 * DESCRIPTION: This function is called to build an API object to be returned to 459 * the caller. 460 * 461 ******************************************************************************/ 462 463ACPI_STATUS 464AcpiUtCopyIobjectToEobject ( 465 ACPI_OPERAND_OBJECT *InternalObject, 466 ACPI_BUFFER *RetBuffer) 467{ 468 ACPI_STATUS Status; 469 470 471 FUNCTION_TRACE ("UtCopyIobjectToEobject"); 472 473 474 if (IS_THIS_OBJECT_TYPE (InternalObject, ACPI_TYPE_PACKAGE)) 475 { 476 /* 477 * Package object: Copy all subobjects (including 478 * nested packages) 479 */ 480 Status = AcpiUtCopyIpackageToEpackage (InternalObject, 481 RetBuffer->Pointer, &RetBuffer->Length); 482 } 483 484 else 485 { 486 /* 487 * Build a simple object (no nested objects) 488 */ 489 Status = AcpiUtCopyIsimpleToEsimple (InternalObject, 490 (ACPI_OBJECT *) RetBuffer->Pointer, 491 ((UINT8 *) RetBuffer->Pointer + 492 ROUND_UP_TO_NATIVE_WORD (sizeof (ACPI_OBJECT))), 493 &RetBuffer->Length); 494 /* 495 * build simple does not include the object size in the length 496 * so we add it in here 497 */ 498 RetBuffer->Length += sizeof (ACPI_OBJECT); 499 } 500 501 return_ACPI_STATUS (Status); 502} 503 504 505/******************************************************************************* 506 * 507 * FUNCTION: AcpiUtCopyEsimpleToIsimple 508 * 509 * PARAMETERS: *ExternalObject - The external object to be converted 510 * *InternalObject - Where the internal object is returned 511 * 512 * RETURN: Status 513 * 514 * DESCRIPTION: This function copies an external object to an internal one. 515 * NOTE: Pointers can be copied, we don't need to copy data. 516 * (The pointers have to be valid in our address space no matter 517 * what we do with them!) 518 * 519 ******************************************************************************/ 520 521ACPI_STATUS 522AcpiUtCopyEsimpleToIsimple ( 523 ACPI_OBJECT *ExternalObject, 524 ACPI_OPERAND_OBJECT **RetInternalObject) 525{ 526 ACPI_OPERAND_OBJECT *InternalObject; 527 528 529 FUNCTION_TRACE ("UtCopyEsimpleToIsimple"); 530 531 532 533 /* 534 * Simple types supported are: String, Buffer, Integer 535 */ 536 switch (ExternalObject->Type) 537 { 538 case ACPI_TYPE_STRING: 539 case ACPI_TYPE_BUFFER: 540 case ACPI_TYPE_INTEGER: 541 542 InternalObject = AcpiUtCreateInternalObject ((UINT8) ExternalObject->Type); 543 if (!InternalObject) 544 { 545 return_ACPI_STATUS (AE_NO_MEMORY); 546 } 547 break; 548 549 default: 550 /* 551 * Whatever other type -- it is not supported 552 */ 553 return_ACPI_STATUS (AE_SUPPORT); 554 break; 555 } 556 557 558 switch (ExternalObject->Type) 559 { 560 561 /* Must COPY string and buffer contents */ 562 563 case ACPI_TYPE_STRING: 564 565 InternalObject->String.Pointer = ACPI_MEM_CALLOCATE (ExternalObject->String.Length + 1); 566 if (!InternalObject->String.Pointer) 567 { 568 return_ACPI_STATUS (AE_NO_MEMORY); 569 } 570 571 MEMCPY (InternalObject->String.Pointer, 572 ExternalObject->String.Pointer, 573 ExternalObject->String.Length); 574 575 InternalObject->String.Length = ExternalObject->String.Length; 576 break; 577 578 579 case ACPI_TYPE_BUFFER: 580 581 InternalObject->Buffer.Pointer = ACPI_MEM_CALLOCATE (ExternalObject->Buffer.Length); 582 if (!InternalObject->Buffer.Pointer) 583 { 584 return_ACPI_STATUS (AE_NO_MEMORY); 585 } 586 587 MEMCPY (InternalObject->Buffer.Pointer, 588 ExternalObject->Buffer.Pointer, 589 ExternalObject->Buffer.Length); 590 591 InternalObject->Buffer.Length = ExternalObject->Buffer.Length; 592 break; 593 594 595 case ACPI_TYPE_INTEGER: 596 597 InternalObject->Integer.Value = ExternalObject->Integer.Value; 598 break; 599 } 600 601 602 *RetInternalObject = InternalObject; 603 return_ACPI_STATUS (AE_OK); 604} 605 606 607#ifdef ACPI_FUTURE_IMPLEMENTATION 608 609/* Code to convert packages that are parameters to control methods */ 610 611/******************************************************************************* 612 * 613 * FUNCTION: AcpiUtCopyEpackageToIpackage 614 * 615 * PARAMETERS: *InternalObject - Pointer to the object we are returning 616 * *Buffer - Where the object is returned 617 * *SpaceUsed - Where the length of the object is returned 618 * 619 * RETURN: Status - the status of the call 620 * 621 * DESCRIPTION: This function is called to place a package object in a user 622 * buffer. A package object by definition contains other objects. 623 * 624 * The buffer is assumed to have sufficient space for the object. 625 * The caller must have verified the buffer length needed using the 626 * AcpiUtGetObjectSize function before calling this function. 627 * 628 ******************************************************************************/ 629 630static ACPI_STATUS 631AcpiUtCopyEpackageToIpackage ( 632 ACPI_OPERAND_OBJECT *InternalObject, 633 UINT8 *Buffer, 634 UINT32 *SpaceUsed) 635{ 636 UINT8 *FreeSpace; 637 ACPI_OBJECT *ExternalObject; 638 UINT32 Length = 0; 639 UINT32 ThisIndex; 640 UINT32 ObjectSpace = 0; 641 ACPI_OPERAND_OBJECT *ThisInternalObj; 642 ACPI_OBJECT *ThisExternalObj; 643 644 645 FUNCTION_TRACE ("UtCopyEpackageToIpackage"); 646 647 648 /* 649 * First package at head of the buffer 650 */ 651 ExternalObject = (ACPI_OBJECT *)Buffer; 652 653 /* 654 * Free space begins right after the first package 655 */ 656 FreeSpace = Buffer + sizeof(ACPI_OBJECT); 657 658 659 ExternalObject->Type = InternalObject->Common.Type; 660 ExternalObject->Package.Count = InternalObject->Package.Count; 661 ExternalObject->Package.Elements = (ACPI_OBJECT *)FreeSpace; 662 663 664 /* 665 * Build an array of ACPI_OBJECTS in the buffer 666 * and move the free space past it 667 */ 668 FreeSpace += ExternalObject->Package.Count * sizeof(ACPI_OBJECT); 669 670 671 /* Call WalkPackage */ 672 673} 674 675#endif /* Future implementation */ 676 677 678/******************************************************************************* 679 * 680 * FUNCTION: AcpiUtCopyEobjectToIobject 681 * 682 * PARAMETERS: *InternalObject - The external object to be converted 683 * *BufferPtr - Where the internal object is returned 684 * 685 * RETURN: Status - the status of the call 686 * 687 * DESCRIPTION: Converts an external object to an internal object. 688 * 689 ******************************************************************************/ 690 691ACPI_STATUS 692AcpiUtCopyEobjectToIobject ( 693 ACPI_OBJECT *ExternalObject, 694 ACPI_OPERAND_OBJECT **InternalObject) 695{ 696 ACPI_STATUS Status; 697 698 699 FUNCTION_TRACE ("UtCopyEobjectToIobject"); 700 701 702 if (ExternalObject->Type == ACPI_TYPE_PACKAGE) 703 { 704 /* 705 * Package objects contain other objects (which can be objects) 706 * buildpackage does it all 707 * 708 * TBD: Package conversion must be completed and tested 709 * NOTE: this code converts packages as input parameters to 710 * control methods only. This is a very, very rare case. 711 */ 712/* 713 Status = AcpiUtCopyEpackageToIpackage(InternalObject, 714 RetBuffer->Pointer, 715 &RetBuffer->Length); 716*/ 717 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 718 "Packages as parameters not implemented!\n")); 719 720 return_ACPI_STATUS (AE_NOT_IMPLEMENTED); 721 } 722 723 else 724 { 725 /* 726 * Build a simple object (no nested objects) 727 */ 728 Status = AcpiUtCopyEsimpleToIsimple (ExternalObject, InternalObject); 729 } 730 731 return_ACPI_STATUS (Status); 732} 733 734 735/******************************************************************************* 736 * 737 * FUNCTION: AcpiUtCopyIelementToIelement 738 * 739 * PARAMETERS: ACPI_PKG_CALLBACK 740 * 741 * RETURN: Status - the status of the call 742 * 743 * DESCRIPTION: Copy one package element to another package element 744 * 745 ******************************************************************************/ 746 747ACPI_STATUS 748AcpiUtCopyIelementToIelement ( 749 UINT8 ObjectType, 750 ACPI_OPERAND_OBJECT *SourceObject, 751 ACPI_GENERIC_STATE *State, 752 void *Context) 753{ 754 ACPI_STATUS Status = AE_OK; 755 UINT32 ThisIndex; 756 ACPI_OPERAND_OBJECT **ThisTargetPtr; 757 ACPI_OPERAND_OBJECT *TargetObject; 758 759 760 FUNCTION_ENTRY (); 761 762 763 ThisIndex = State->Pkg.Index; 764 ThisTargetPtr = (ACPI_OPERAND_OBJECT **) 765 &State->Pkg.DestObject->Package.Elements[ThisIndex]; 766 767 switch (ObjectType) 768 { 769 case 0: 770 771 /* 772 * This is a simple object, just copy it 773 */ 774 TargetObject = AcpiUtCreateInternalObject (SourceObject->Common.Type); 775 if (!TargetObject) 776 { 777 return (AE_NO_MEMORY); 778 } 779 780 Status = AcpiExStoreObjectToObject (SourceObject, TargetObject, 781 (ACPI_WALK_STATE *) Context); 782 if (ACPI_FAILURE (Status)) 783 { 784 return (Status); 785 } 786 787 *ThisTargetPtr = TargetObject; 788 break; 789 790 791 case 1: 792 /* 793 * This object is a package - go down another nesting level 794 * Create and build the package object 795 */ 796 TargetObject = AcpiUtCreateInternalObject (ACPI_TYPE_PACKAGE); 797 if (!TargetObject) 798 { 799 /* TBD: must delete package created up to this point */ 800 801 return (AE_NO_MEMORY); 802 } 803 804 TargetObject->Package.Count = SourceObject->Package.Count; 805 806 /* 807 * Pass the new package object back to the package walk routine 808 */ 809 State->Pkg.ThisTargetObj = TargetObject; 810 811 /* 812 * Store the object pointer in the parent package object 813 */ 814 *ThisTargetPtr = TargetObject; 815 break; 816 817 default: 818 return (AE_BAD_PARAMETER); 819 } 820 821 822 return (Status); 823} 824 825 826/******************************************************************************* 827 * 828 * FUNCTION: AcpiUtCopyIpackageToIpackage 829 * 830 * PARAMETERS: *SourceObj - Pointer to the source package object 831 * *DestObj - Where the internal object is returned 832 * 833 * RETURN: Status - the status of the call 834 * 835 * DESCRIPTION: This function is called to copy an internal package object 836 * into another internal package object. 837 * 838 ******************************************************************************/ 839 840ACPI_STATUS 841AcpiUtCopyIpackageToIpackage ( 842 ACPI_OPERAND_OBJECT *SourceObj, 843 ACPI_OPERAND_OBJECT *DestObj, 844 ACPI_WALK_STATE *WalkState) 845{ 846 ACPI_STATUS Status = AE_OK; 847 848 849 FUNCTION_TRACE ("UtCopyIpackageToIpackage"); 850 851 852 DestObj->Common.Type = SourceObj->Common.Type; 853 DestObj->Package.Count = SourceObj->Package.Count; 854 855 856 /* 857 * Create the object array and walk the source package tree 858 */ 859 DestObj->Package.Elements = ACPI_MEM_CALLOCATE ((SourceObj->Package.Count + 1) * 860 sizeof (void *)); 861 DestObj->Package.NextElement = DestObj->Package.Elements; 862 863 if (!DestObj->Package.Elements) 864 { 865 REPORT_ERROR ( 866 ("AmlBuildCopyInternalPackageObject: Package allocation failure\n")); 867 return_ACPI_STATUS (AE_NO_MEMORY); 868 } 869 870 871 Status = AcpiUtWalkPackageTree (SourceObj, DestObj, 872 AcpiUtCopyIelementToIelement, WalkState); 873 874 return_ACPI_STATUS (Status); 875} 876 877