exutils.c (71867) | exutils.c (73561) |
---|---|
1 2/****************************************************************************** 3 * 4 * Module Name: amutils - interpreter/scanner utilities | 1 2/****************************************************************************** 3 * 4 * Module Name: amutils - interpreter/scanner utilities |
5 * $Revision: 68 $ | 5 * $Revision: 69 $ |
6 * 7 *****************************************************************************/ 8 9/****************************************************************************** 10 * 11 * 1. Copyright Notice 12 * 13 * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. --- 109 unchanged lines hidden (view full) --- 123#include "amlcode.h" 124#include "acnamesp.h" 125#include "acevents.h" 126 127#define _COMPONENT INTERPRETER 128 MODULE_NAME ("amutils") 129 130 | 6 * 7 *****************************************************************************/ 8 9/****************************************************************************** 10 * 11 * 1. Copyright Notice 12 * 13 * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp. --- 109 unchanged lines hidden (view full) --- 123#include "amlcode.h" 124#include "acnamesp.h" 125#include "acevents.h" 126 127#define _COMPONENT INTERPRETER 128 MODULE_NAME ("amutils") 129 130 |
131typedef struct Internal_Search_st 132{ 133 ACPI_OPERAND_OBJECT *DestObj; 134 UINT32 Index; 135 ACPI_OPERAND_OBJECT *SourceObj; | |
136 | 131 |
137} INTERNAL_PKG_SEARCH_INFO; 138 139 140/* Used to traverse nested packages when copying*/ 141/* TBD: This must be removed! */ 142 143INTERNAL_PKG_SEARCH_INFO CopyLevel[MAX_PACKAGE_DEPTH]; 144 145 | |
146/******************************************************************************* 147 * 148 * FUNCTION: AcpiAmlEnterInterpreter 149 * 150 * PARAMETERS: None 151 * 152 * DESCRIPTION: Enter the interpreter execution region 153 * --- 345 unchanged lines hidden (view full) --- 499 OutString[Count-1] = (NATIVE_CHAR) ('0' + (ACPI_MODULO (Value, 10))); 500 Value = ACPI_DIVIDE (Value, 10); 501 } 502 503 return (AE_OK); 504} 505 506 | 132/******************************************************************************* 133 * 134 * FUNCTION: AcpiAmlEnterInterpreter 135 * 136 * PARAMETERS: None 137 * 138 * DESCRIPTION: Enter the interpreter execution region 139 * --- 345 unchanged lines hidden (view full) --- 485 OutString[Count-1] = (NATIVE_CHAR) ('0' + (ACPI_MODULO (Value, 10))); 486 Value = ACPI_DIVIDE (Value, 10); 487 } 488 489 return (AE_OK); 490} 491 492 |
507/******************************************************************************* 508 * 509 * FUNCTION: AcpiAmlBuildCopyInternalPackageObject 510 * 511 * PARAMETERS: *SourceObj - Pointer to the source package object 512 * *DestObj - Where the internal object is returned 513 * 514 * RETURN: Status - the status of the call 515 * 516 * DESCRIPTION: This function is called to copy an internal package object 517 * into another internal package object. 518 * 519 ******************************************************************************/ | |
520 | 493 |
521ACPI_STATUS 522AcpiAmlBuildCopyInternalPackageObject ( 523 ACPI_OPERAND_OBJECT *SourceObj, 524 ACPI_OPERAND_OBJECT *DestObj, 525 ACPI_WALK_STATE *WalkState) 526{ 527 UINT32 CurrentDepth = 0; 528 ACPI_STATUS Status = AE_OK; 529 UINT32 Length = 0; 530 UINT32 ThisIndex; 531 UINT32 ObjectSpace = 0; 532 ACPI_OPERAND_OBJECT *ThisDestObj; 533 ACPI_OPERAND_OBJECT *ThisSourceObj; 534 INTERNAL_PKG_SEARCH_INFO *LevelPtr; | |
535 536 | 494 495 |
537 FUNCTION_TRACE ("AmlBuildCopyInternalPackageObject"); | |
538 | 496 |
539 540 /* 541 * Initialize the working variables 542 */ 543 544 MEMSET ((void *) CopyLevel, 0, sizeof(CopyLevel)); 545 546 CopyLevel[0].DestObj = DestObj; 547 CopyLevel[0].SourceObj = SourceObj; 548 LevelPtr = &CopyLevel[0]; 549 CurrentDepth = 0; 550 551 DestObj->Common.Type = SourceObj->Common.Type; 552 DestObj->Package.Count = SourceObj->Package.Count; 553 554 555 /* 556 * Build an array of ACPI_OBJECTS in the buffer 557 * and move the free space past it 558 */ 559 560 DestObj->Package.Elements = AcpiCmCallocate ( 561 (DestObj->Package.Count + 1) * 562 sizeof (void *)); 563 if (!DestObj->Package.Elements) 564 { 565 /* Package vector allocation failure */ 566 567 REPORT_ERROR (("AmlBuildCopyInternalPackageObject: Package vector allocation failure\n")); 568 return_ACPI_STATUS (AE_NO_MEMORY); 569 } 570 571 DestObj->Package.NextElement = DestObj->Package.Elements; 572 573 574 while (1) 575 { 576 ThisIndex = LevelPtr->Index; 577 ThisDestObj = (ACPI_OPERAND_OBJECT *) LevelPtr->DestObj->Package.Elements[ThisIndex]; 578 ThisSourceObj = (ACPI_OPERAND_OBJECT *) LevelPtr->SourceObj->Package.Elements[ThisIndex]; 579 580 if (IS_THIS_OBJECT_TYPE (ThisSourceObj, ACPI_TYPE_PACKAGE)) 581 { 582 /* 583 * If this object is a package then we go one deeper 584 */ 585 if (CurrentDepth >= MAX_PACKAGE_DEPTH-1) 586 { 587 /* 588 * Too many nested levels of packages for us to handle 589 */ 590 DEBUG_PRINT (ACPI_ERROR, 591 ("AmlBuildCopyInternalPackageObject: Pkg nested too deep (max %X)\n", 592 MAX_PACKAGE_DEPTH)); 593 return_ACPI_STATUS (AE_LIMIT); 594 } 595 596 /* 597 * Build the package object 598 */ 599 ThisDestObj = AcpiCmCreateInternalObject (ACPI_TYPE_PACKAGE); 600 LevelPtr->DestObj->Package.Elements[ThisIndex] = ThisDestObj; 601 602 603 ThisDestObj->Common.Type = ACPI_TYPE_PACKAGE; 604 ThisDestObj->Package.Count = ThisDestObj->Package.Count; 605 606 /* 607 * Save space for the array of objects (Package elements) 608 * update the buffer length counter 609 */ 610 ObjectSpace = ThisDestObj->Package.Count * 611 sizeof (ACPI_OPERAND_OBJECT); 612 Length += ObjectSpace; 613 CurrentDepth++; 614 LevelPtr = &CopyLevel[CurrentDepth]; 615 LevelPtr->DestObj = ThisDestObj; 616 LevelPtr->SourceObj = ThisSourceObj; 617 LevelPtr->Index = 0; 618 619 } /* if object is a package */ 620 621 else 622 { 623 624 ThisDestObj = AcpiCmCreateInternalObject ( 625 ThisSourceObj->Common.Type); 626 LevelPtr->DestObj->Package.Elements[ThisIndex] = ThisDestObj; 627 628 Status = AcpiAmlStoreObjectToObject(ThisSourceObj, ThisDestObj, WalkState); 629 630 if (ACPI_FAILURE (Status)) 631 { 632 /* 633 * Failure get out 634 */ 635 return_ACPI_STATUS (Status); 636 } 637 638 Length +=ObjectSpace; 639 640 LevelPtr->Index++; 641 while (LevelPtr->Index >= LevelPtr->DestObj->Package.Count) 642 { 643 /* 644 * We've handled all of the objects at this level, This means 645 * that we have just completed a package. That package may 646 * have contained one or more packages itself 647 */ 648 if (CurrentDepth == 0) 649 { 650 /* 651 * We have handled all of the objects in the top level 652 * package just add the length of the package objects 653 * and exit 654 */ 655 return_ACPI_STATUS (AE_OK); 656 } 657 658 /* 659 * Go back up a level and move the index past the just 660 * completed package object. 661 */ 662 CurrentDepth--; 663 LevelPtr = &CopyLevel[CurrentDepth]; 664 LevelPtr->Index++; 665 } 666 } /* else object is NOT a package */ 667 } /* while (1) */ 668} 669 670 | |