Print this page
update to acpica-unix2-20140114
acpica-unix2-20130823
PANKOVs restructure
   1 /******************************************************************************
   2  *
   3  * Module Name: utobject - ACPI object create/delete/size/cache routines
   4  *
   5  *****************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2011, Intel Corp.
   9  * 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.


 123 
 124         /* These types require a secondary object */
 125 
 126         SecondObject = AcpiUtAllocateObjectDescDbg (ModuleName,
 127                             LineNumber, ComponentId);
 128         if (!SecondObject)
 129         {
 130             AcpiUtDeleteObjectDesc (Object);
 131             return_PTR (NULL);
 132         }
 133 
 134         SecondObject->Common.Type = ACPI_TYPE_LOCAL_EXTRA;
 135         SecondObject->Common.ReferenceCount = 1;
 136 
 137         /* Link the second object to the first */
 138 
 139         Object->Common.NextObject = SecondObject;
 140         break;
 141 
 142     default:

 143         /* All others have no secondary object */
 144         break;
 145     }
 146 
 147     /* Save the object type in the object descriptor */
 148 
 149     Object->Common.Type = (UINT8) Type;
 150 
 151     /* Init the reference count */
 152 
 153     Object->Common.ReferenceCount = 1;
 154 
 155     /* Any per-type initialization should go here */
 156 
 157     return_PTR (Object);
 158 }
 159 
 160 
 161 /*******************************************************************************
 162  *


 349 
 350     /* Complete string object initialization */
 351 
 352     StringDesc->String.Pointer = String;
 353     StringDesc->String.Length = (UINT32) StringSize;
 354 
 355     /* Return the new string descriptor */
 356 
 357     return_PTR (StringDesc);
 358 }
 359 
 360 
 361 /*******************************************************************************
 362  *
 363  * FUNCTION:    AcpiUtValidInternalObject
 364  *
 365  * PARAMETERS:  Object              - Object to be validated
 366  *
 367  * RETURN:      TRUE if object is valid, FALSE otherwise
 368  *
 369  * DESCRIPTION: Validate a pointer to be an ACPI_OPERAND_OBJECT
 370  *
 371  ******************************************************************************/
 372 
 373 BOOLEAN
 374 AcpiUtValidInternalObject (
 375     void                    *Object)
 376 {
 377 
 378     ACPI_FUNCTION_NAME (UtValidInternalObject);
 379 
 380 
 381     /* Check for a null pointer */
 382 
 383     if (!Object)
 384     {
 385         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "**** Null Object Ptr\n"));
 386         return (FALSE);
 387     }
 388 
 389     /* Check the descriptor type field */
 390 
 391     switch (ACPI_GET_DESCRIPTOR_TYPE (Object))
 392     {
 393     case ACPI_DESC_TYPE_OPERAND:
 394 
 395         /* The object appears to be a valid ACPI_OPERAND_OBJECT  */
 396 
 397         return (TRUE);
 398 
 399     default:

 400         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
 401                 "%p is not not an ACPI operand obj [%s]\n",
 402                 Object, AcpiUtGetDescriptorName (Object)));
 403         break;
 404     }
 405 
 406     return (FALSE);
 407 }
 408 
 409 
 410 /*******************************************************************************
 411  *
 412  * FUNCTION:    AcpiUtAllocateObjectDescDbg
 413  *
 414  * PARAMETERS:  ModuleName          - Caller's module name (for error output)
 415  *              LineNumber          - Caller's line number (for error output)
 416  *              ComponentId         - Caller's component ID (for error output)
 417  *
 418  * RETURN:      Pointer to newly allocated object descriptor.  Null on error
 419  *


 456 
 457 /*******************************************************************************
 458  *
 459  * FUNCTION:    AcpiUtDeleteObjectDesc
 460  *
 461  * PARAMETERS:  Object          - An Acpi internal object to be deleted
 462  *
 463  * RETURN:      None.
 464  *
 465  * DESCRIPTION: Free an ACPI object descriptor or add it to the object cache
 466  *
 467  ******************************************************************************/
 468 
 469 void
 470 AcpiUtDeleteObjectDesc (
 471     ACPI_OPERAND_OBJECT     *Object)
 472 {
 473     ACPI_FUNCTION_TRACE_PTR (UtDeleteObjectDesc, Object);
 474 
 475 
 476     /* Object must be an ACPI_OPERAND_OBJECT  */
 477 
 478     if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
 479     {
 480         ACPI_ERROR ((AE_INFO,
 481             "%p is not an ACPI Operand object [%s]", Object,
 482             AcpiUtGetDescriptorName (Object)));
 483         return_VOID;
 484     }
 485 
 486     (void) AcpiOsReleaseObject (AcpiGbl_OperandCache, Object);
 487     return_VOID;
 488 }
 489 
 490 
 491 /*******************************************************************************
 492  *
 493  * FUNCTION:    AcpiUtGetSimpleObjectSize
 494  *
 495  * PARAMETERS:  InternalObject     - An ACPI operand object
 496  *              ObjLength          - Where the length is returned


 539     if (ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_NAMED)
 540     {
 541         /* A namespace node should never get here */
 542 
 543         return_ACPI_STATUS (AE_AML_INTERNAL);
 544     }
 545 
 546     /*
 547      * The final length depends on the object type
 548      * Strings and Buffers are packed right up against the parent object and
 549      * must be accessed bytewise or there may be alignment problems on
 550      * certain processors
 551      */
 552     switch (InternalObject->Common.Type)
 553     {
 554     case ACPI_TYPE_STRING:
 555 
 556         Length += (ACPI_SIZE) InternalObject->String.Length + 1;
 557         break;
 558 
 559 
 560     case ACPI_TYPE_BUFFER:
 561 
 562         Length += (ACPI_SIZE) InternalObject->Buffer.Length;
 563         break;
 564 
 565 
 566     case ACPI_TYPE_INTEGER:
 567     case ACPI_TYPE_PROCESSOR:
 568     case ACPI_TYPE_POWER:
 569 
 570         /* No extra data for these types */
 571 
 572         break;
 573 
 574 
 575     case ACPI_TYPE_LOCAL_REFERENCE:
 576 
 577         switch (InternalObject->Reference.Class)
 578         {
 579         case ACPI_REFCLASS_NAME:
 580 
 581             /*
 582              * Get the actual length of the full pathname to this object.
 583              * The reference will be converted to the pathname to the object
 584              */
 585             Size = AcpiNsGetPathnameLength (InternalObject->Reference.Node);
 586             if (!Size)
 587             {
 588                 return_ACPI_STATUS (AE_BAD_PARAMETER);
 589             }
 590 
 591             Length += ACPI_ROUND_UP_TO_NATIVE_WORD (Size);
 592             break;
 593 
 594         default:
 595 
 596             /*
 597              * No other reference opcodes are supported.
 598              * Notably, Locals and Args are not supported, but this may be
 599              * required eventually.
 600              */
 601             ACPI_ERROR ((AE_INFO, "Cannot convert to external object - "
 602                 "unsupported Reference Class [%s] 0x%X in object %p",
 603                 AcpiUtGetReferenceName (InternalObject),
 604                 InternalObject->Reference.Class, InternalObject));
 605             Status = AE_TYPE;
 606             break;
 607         }
 608         break;
 609 
 610 
 611     default:
 612 
 613         ACPI_ERROR ((AE_INFO, "Cannot convert to external object - "
 614             "unsupported type [%s] 0x%X in object %p",
 615             AcpiUtGetObjectTypeName (InternalObject),
 616             InternalObject->Common.Type, InternalObject));
 617         Status = AE_TYPE;
 618         break;
 619     }
 620 
 621     /*
 622      * Account for the space required by the object rounded up to the next
 623      * multiple of the machine word size.  This keeps each object aligned
 624      * on a machine word boundary. (preventing alignment faults on some
 625      * machines.)
 626      */
 627     *ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length);
 628     return_ACPI_STATUS (Status);
 629 }
 630 


 639  *
 640  * DESCRIPTION: Get the length of one package element.
 641  *
 642  ******************************************************************************/
 643 
 644 static ACPI_STATUS
 645 AcpiUtGetElementLength (
 646     UINT8                   ObjectType,
 647     ACPI_OPERAND_OBJECT     *SourceObject,
 648     ACPI_GENERIC_STATE      *State,
 649     void                    *Context)
 650 {
 651     ACPI_STATUS             Status = AE_OK;
 652     ACPI_PKG_INFO           *Info = (ACPI_PKG_INFO *) Context;
 653     ACPI_SIZE               ObjectSpace;
 654 
 655 
 656     switch (ObjectType)
 657     {
 658     case ACPI_COPY_TYPE_SIMPLE:
 659 
 660         /*
 661          * Simple object - just get the size (Null object/entry is handled
 662          * here also) and sum it into the running package length
 663          */
 664         Status = AcpiUtGetSimpleObjectSize (SourceObject, &ObjectSpace);
 665         if (ACPI_FAILURE (Status))
 666         {
 667             return (Status);
 668         }
 669 
 670         Info->Length += ObjectSpace;
 671         break;
 672 
 673 
 674     case ACPI_COPY_TYPE_PACKAGE:
 675 
 676         /* Package object - nothing much to do here, let the walk handle it */
 677 
 678         Info->NumPackages++;
 679         State->Pkg.ThisTargetObj = NULL;
 680         break;
 681 
 682 
 683     default:
 684 
 685         /* No other types allowed */
 686 
 687         return (AE_BAD_PARAMETER);
 688     }
 689 
 690     return (Status);
 691 }
 692 
 693 
 694 /*******************************************************************************
 695  *
 696  * FUNCTION:    AcpiUtGetPackageObjectSize
 697  *
 698  * PARAMETERS:  InternalObject      - An ACPI internal object
 699  *              ObjLength           - Where the length is returned
 700  *
 701  * RETURN:      Status
 702  *


 766     ACPI_SIZE               *ObjLength)
 767 {
 768     ACPI_STATUS             Status;
 769 
 770 
 771     ACPI_FUNCTION_ENTRY ();
 772 
 773 
 774     if ((ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_OPERAND) &&
 775         (InternalObject->Common.Type == ACPI_TYPE_PACKAGE))
 776     {
 777         Status = AcpiUtGetPackageObjectSize (InternalObject, ObjLength);
 778     }
 779     else
 780     {
 781         Status = AcpiUtGetSimpleObjectSize (InternalObject, ObjLength);
 782     }
 783 
 784     return (Status);
 785 }
 786 
 787 
   1 /******************************************************************************
   2  *
   3  * Module Name: utobject - ACPI object create/delete/size/cache routines
   4  *
   5  *****************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2014, Intel Corp.
   9  * 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.


 123 
 124         /* These types require a secondary object */
 125 
 126         SecondObject = AcpiUtAllocateObjectDescDbg (ModuleName,
 127                             LineNumber, ComponentId);
 128         if (!SecondObject)
 129         {
 130             AcpiUtDeleteObjectDesc (Object);
 131             return_PTR (NULL);
 132         }
 133 
 134         SecondObject->Common.Type = ACPI_TYPE_LOCAL_EXTRA;
 135         SecondObject->Common.ReferenceCount = 1;
 136 
 137         /* Link the second object to the first */
 138 
 139         Object->Common.NextObject = SecondObject;
 140         break;
 141 
 142     default:
 143 
 144         /* All others have no secondary object */
 145         break;
 146     }
 147 
 148     /* Save the object type in the object descriptor */
 149 
 150     Object->Common.Type = (UINT8) Type;
 151 
 152     /* Init the reference count */
 153 
 154     Object->Common.ReferenceCount = 1;
 155 
 156     /* Any per-type initialization should go here */
 157 
 158     return_PTR (Object);
 159 }
 160 
 161 
 162 /*******************************************************************************
 163  *


 350 
 351     /* Complete string object initialization */
 352 
 353     StringDesc->String.Pointer = String;
 354     StringDesc->String.Length = (UINT32) StringSize;
 355 
 356     /* Return the new string descriptor */
 357 
 358     return_PTR (StringDesc);
 359 }
 360 
 361 
 362 /*******************************************************************************
 363  *
 364  * FUNCTION:    AcpiUtValidInternalObject
 365  *
 366  * PARAMETERS:  Object              - Object to be validated
 367  *
 368  * RETURN:      TRUE if object is valid, FALSE otherwise
 369  *
 370  * DESCRIPTION: Validate a pointer to be of type ACPI_OPERAND_OBJECT
 371  *
 372  ******************************************************************************/
 373 
 374 BOOLEAN
 375 AcpiUtValidInternalObject (
 376     void                    *Object)
 377 {
 378 
 379     ACPI_FUNCTION_NAME (UtValidInternalObject);
 380 
 381 
 382     /* Check for a null pointer */
 383 
 384     if (!Object)
 385     {
 386         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "**** Null Object Ptr\n"));
 387         return (FALSE);
 388     }
 389 
 390     /* Check the descriptor type field */
 391 
 392     switch (ACPI_GET_DESCRIPTOR_TYPE (Object))
 393     {
 394     case ACPI_DESC_TYPE_OPERAND:
 395 
 396         /* The object appears to be a valid ACPI_OPERAND_OBJECT */
 397 
 398         return (TRUE);
 399 
 400     default:
 401 
 402         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
 403                 "%p is not not an ACPI operand obj [%s]\n",
 404                 Object, AcpiUtGetDescriptorName (Object)));
 405         break;
 406     }
 407 
 408     return (FALSE);
 409 }
 410 
 411 
 412 /*******************************************************************************
 413  *
 414  * FUNCTION:    AcpiUtAllocateObjectDescDbg
 415  *
 416  * PARAMETERS:  ModuleName          - Caller's module name (for error output)
 417  *              LineNumber          - Caller's line number (for error output)
 418  *              ComponentId         - Caller's component ID (for error output)
 419  *
 420  * RETURN:      Pointer to newly allocated object descriptor. Null on error
 421  *


 458 
 459 /*******************************************************************************
 460  *
 461  * FUNCTION:    AcpiUtDeleteObjectDesc
 462  *
 463  * PARAMETERS:  Object          - An Acpi internal object to be deleted
 464  *
 465  * RETURN:      None.
 466  *
 467  * DESCRIPTION: Free an ACPI object descriptor or add it to the object cache
 468  *
 469  ******************************************************************************/
 470 
 471 void
 472 AcpiUtDeleteObjectDesc (
 473     ACPI_OPERAND_OBJECT     *Object)
 474 {
 475     ACPI_FUNCTION_TRACE_PTR (UtDeleteObjectDesc, Object);
 476 
 477 
 478     /* Object must be of type ACPI_OPERAND_OBJECT */
 479 
 480     if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
 481     {
 482         ACPI_ERROR ((AE_INFO,
 483             "%p is not an ACPI Operand object [%s]", Object,
 484             AcpiUtGetDescriptorName (Object)));
 485         return_VOID;
 486     }
 487 
 488     (void) AcpiOsReleaseObject (AcpiGbl_OperandCache, Object);
 489     return_VOID;
 490 }
 491 
 492 
 493 /*******************************************************************************
 494  *
 495  * FUNCTION:    AcpiUtGetSimpleObjectSize
 496  *
 497  * PARAMETERS:  InternalObject     - An ACPI operand object
 498  *              ObjLength          - Where the length is returned


 541     if (ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_NAMED)
 542     {
 543         /* A namespace node should never get here */
 544 
 545         return_ACPI_STATUS (AE_AML_INTERNAL);
 546     }
 547 
 548     /*
 549      * The final length depends on the object type
 550      * Strings and Buffers are packed right up against the parent object and
 551      * must be accessed bytewise or there may be alignment problems on
 552      * certain processors
 553      */
 554     switch (InternalObject->Common.Type)
 555     {
 556     case ACPI_TYPE_STRING:
 557 
 558         Length += (ACPI_SIZE) InternalObject->String.Length + 1;
 559         break;
 560 

 561     case ACPI_TYPE_BUFFER:
 562 
 563         Length += (ACPI_SIZE) InternalObject->Buffer.Length;
 564         break;
 565 

 566     case ACPI_TYPE_INTEGER:
 567     case ACPI_TYPE_PROCESSOR:
 568     case ACPI_TYPE_POWER:
 569 
 570         /* No extra data for these types */
 571 
 572         break;
 573 

 574     case ACPI_TYPE_LOCAL_REFERENCE:
 575 
 576         switch (InternalObject->Reference.Class)
 577         {
 578         case ACPI_REFCLASS_NAME:

 579             /*
 580              * Get the actual length of the full pathname to this object.
 581              * The reference will be converted to the pathname to the object
 582              */
 583             Size = AcpiNsGetPathnameLength (InternalObject->Reference.Node);
 584             if (!Size)
 585             {
 586                 return_ACPI_STATUS (AE_BAD_PARAMETER);
 587             }
 588 
 589             Length += ACPI_ROUND_UP_TO_NATIVE_WORD (Size);
 590             break;
 591 
 592         default:

 593             /*
 594              * No other reference opcodes are supported.
 595              * Notably, Locals and Args are not supported, but this may be
 596              * required eventually.
 597              */
 598             ACPI_ERROR ((AE_INFO, "Cannot convert to external object - "
 599                 "unsupported Reference Class [%s] 0x%X in object %p",
 600                 AcpiUtGetReferenceName (InternalObject),
 601                 InternalObject->Reference.Class, InternalObject));
 602             Status = AE_TYPE;
 603             break;
 604         }
 605         break;
 606 

 607     default:
 608 
 609         ACPI_ERROR ((AE_INFO, "Cannot convert to external object - "
 610             "unsupported type [%s] 0x%X in object %p",
 611             AcpiUtGetObjectTypeName (InternalObject),
 612             InternalObject->Common.Type, InternalObject));
 613         Status = AE_TYPE;
 614         break;
 615     }
 616 
 617     /*
 618      * Account for the space required by the object rounded up to the next
 619      * multiple of the machine word size. This keeps each object aligned
 620      * on a machine word boundary. (preventing alignment faults on some
 621      * machines.)
 622      */
 623     *ObjLength = ACPI_ROUND_UP_TO_NATIVE_WORD (Length);
 624     return_ACPI_STATUS (Status);
 625 }
 626 


 635  *
 636  * DESCRIPTION: Get the length of one package element.
 637  *
 638  ******************************************************************************/
 639 
 640 static ACPI_STATUS
 641 AcpiUtGetElementLength (
 642     UINT8                   ObjectType,
 643     ACPI_OPERAND_OBJECT     *SourceObject,
 644     ACPI_GENERIC_STATE      *State,
 645     void                    *Context)
 646 {
 647     ACPI_STATUS             Status = AE_OK;
 648     ACPI_PKG_INFO           *Info = (ACPI_PKG_INFO *) Context;
 649     ACPI_SIZE               ObjectSpace;
 650 
 651 
 652     switch (ObjectType)
 653     {
 654     case ACPI_COPY_TYPE_SIMPLE:

 655         /*
 656          * Simple object - just get the size (Null object/entry is handled
 657          * here also) and sum it into the running package length
 658          */
 659         Status = AcpiUtGetSimpleObjectSize (SourceObject, &ObjectSpace);
 660         if (ACPI_FAILURE (Status))
 661         {
 662             return (Status);
 663         }
 664 
 665         Info->Length += ObjectSpace;
 666         break;
 667 

 668     case ACPI_COPY_TYPE_PACKAGE:
 669 
 670         /* Package object - nothing much to do here, let the walk handle it */
 671 
 672         Info->NumPackages++;
 673         State->Pkg.ThisTargetObj = NULL;
 674         break;
 675 

 676     default:
 677 
 678         /* No other types allowed */
 679 
 680         return (AE_BAD_PARAMETER);
 681     }
 682 
 683     return (Status);
 684 }
 685 
 686 
 687 /*******************************************************************************
 688  *
 689  * FUNCTION:    AcpiUtGetPackageObjectSize
 690  *
 691  * PARAMETERS:  InternalObject      - An ACPI internal object
 692  *              ObjLength           - Where the length is returned
 693  *
 694  * RETURN:      Status
 695  *


 759     ACPI_SIZE               *ObjLength)
 760 {
 761     ACPI_STATUS             Status;
 762 
 763 
 764     ACPI_FUNCTION_ENTRY ();
 765 
 766 
 767     if ((ACPI_GET_DESCRIPTOR_TYPE (InternalObject) == ACPI_DESC_TYPE_OPERAND) &&
 768         (InternalObject->Common.Type == ACPI_TYPE_PACKAGE))
 769     {
 770         Status = AcpiUtGetPackageObjectSize (InternalObject, ObjLength);
 771     }
 772     else
 773     {
 774         Status = AcpiUtGetSimpleObjectSize (InternalObject, ObjLength);
 775     }
 776 
 777     return (Status);
 778 }