Print this page
update to acpica-unix2-20131115
acpica-unix2-20130823
PANKOVs restructure
   1 /*******************************************************************************
   2  *
   3  * Module Name: rsutils - Utilities for the resource manager
   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.


 156     UINT16                  ItemCount,
 157     UINT8                   MoveType)
 158 {
 159     UINT32                  i;
 160 
 161 
 162     ACPI_FUNCTION_ENTRY ();
 163 
 164 
 165     /* One move per item */
 166 
 167     for (i = 0; i < ItemCount; i++)
 168     {
 169         switch (MoveType)
 170         {
 171         /*
 172          * For the 8-bit case, we can perform the move all at once
 173          * since there are no alignment or endian issues
 174          */
 175         case ACPI_RSC_MOVE8:




 176             ACPI_MEMCPY (Destination, Source, ItemCount);
 177             return;
 178 
 179         /*
 180          * 16-, 32-, and 64-bit cases must use the move macros that perform
 181          * endian conversion and/or accomodate hardware that cannot perform
 182          * misaligned memory transfers
 183          */
 184         case ACPI_RSC_MOVE16:


 185             ACPI_MOVE_16_TO_16 (&ACPI_CAST_PTR (UINT16, Destination)[i],
 186                                 &ACPI_CAST_PTR (UINT16, Source)[i]);
 187             break;
 188 
 189         case ACPI_RSC_MOVE32:

 190             ACPI_MOVE_32_TO_32 (&ACPI_CAST_PTR (UINT32, Destination)[i],
 191                                 &ACPI_CAST_PTR (UINT32, Source)[i]);
 192             break;
 193 
 194         case ACPI_RSC_MOVE64:

 195             ACPI_MOVE_64_TO_64 (&ACPI_CAST_PTR (UINT64, Destination)[i],
 196                                 &ACPI_CAST_PTR (UINT64, Source)[i]);
 197             break;
 198 
 199         default:

 200             return;
 201         }
 202     }
 203 }
 204 
 205 
 206 /*******************************************************************************
 207  *
 208  * FUNCTION:    AcpiRsSetResourceLength
 209  *
 210  * PARAMETERS:  TotalLength         - Length of the AML descriptor, including
 211  *                                    the header and length fields.
 212  *              Aml                 - Pointer to the raw AML descriptor
 213  *
 214  * RETURN:      None
 215  *
 216  * DESCRIPTION: Set the ResourceLength field of an AML
 217  *              resource descriptor, both Large and Small descriptors are
 218  *              supported automatically. Note: Descriptor Type field must
 219  *              be valid.


 636     {
 637         return_ACPI_STATUS (Status);
 638     }
 639 
 640     /*
 641      * Make the call to create a resource linked list from the
 642      * byte stream buffer that comes back from the _CRS method
 643      * execution.
 644      */
 645     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
 646 
 647     /* On exit, we must delete the object returned by evaluateObject */
 648 
 649     AcpiUtRemoveReference (ObjDesc);
 650     return_ACPI_STATUS (Status);
 651 }
 652 
 653 
 654 /*******************************************************************************
 655  *























































 656  * FUNCTION:    AcpiRsGetMethodData
 657  *
 658  * PARAMETERS:  Handle          - Handle to the containing object
 659  *              Path            - Path to method, relative to Handle
 660  *              RetBuffer       - Pointer to a buffer structure for the
 661  *                                results
 662  *
 663  * RETURN:      Status
 664  *
 665  * DESCRIPTION: This function is called to get the _CRS or _PRS value of an
 666  *              object contained in an object specified by the handle passed in
 667  *
 668  *              If the function fails an appropriate status will be returned
 669  *              and the contents of the callers buffer is undefined.
 670  *
 671  ******************************************************************************/
 672 
 673 ACPI_STATUS
 674 AcpiRsGetMethodData (
 675     ACPI_HANDLE             Handle,
 676     char                    *Path,
 677     ACPI_BUFFER             *RetBuffer)
 678 {
 679     ACPI_OPERAND_OBJECT     *ObjDesc;
 680     ACPI_STATUS             Status;
 681 
 682 
 683     ACPI_FUNCTION_TRACE (RsGetMethodData);
 684 
 685 
 686     /* Parameters guaranteed valid by caller */
 687 
 688     /* Execute the method, no parameters */
 689 
 690     Status = AcpiUtEvaluateObject (Handle, Path, ACPI_BTYPE_BUFFER, &ObjDesc);

 691     if (ACPI_FAILURE (Status))
 692     {
 693         return_ACPI_STATUS (Status);
 694     }
 695 
 696     /*
 697      * Make the call to create a resource linked list from the
 698      * byte stream buffer that comes back from the method
 699      * execution.
 700      */
 701     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
 702 
 703     /* On exit, we must delete the object returned by EvaluateObject */
 704 
 705     AcpiUtRemoveReference (ObjDesc);
 706     return_ACPI_STATUS (Status);
 707 }
 708 
 709 
 710 /*******************************************************************************


 733     ACPI_BUFFER             *InBuffer)
 734 {
 735     ACPI_EVALUATE_INFO      *Info;
 736     ACPI_OPERAND_OBJECT     *Args[2];
 737     ACPI_STATUS             Status;
 738     ACPI_BUFFER             Buffer;
 739 
 740 
 741     ACPI_FUNCTION_TRACE (RsSetSrsMethodData);
 742 
 743 
 744     /* Allocate and initialize the evaluation information block */
 745 
 746     Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
 747     if (!Info)
 748     {
 749         return_ACPI_STATUS (AE_NO_MEMORY);
 750     }
 751 
 752     Info->PrefixNode = Node;
 753     Info->Pathname = METHOD_NAME__SRS;
 754     Info->Parameters = Args;
 755     Info->Flags = ACPI_IGNORE_RETURN_VALUE;
 756 
 757     /*
 758      * The InBuffer parameter will point to a linked list of
 759      * resource parameters. It needs to be formatted into a
 760      * byte stream to be sent in as an input parameter to _SRS
 761      *
 762      * Convert the linked list into a byte stream
 763      */
 764     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
 765     Status = AcpiRsCreateAmlResources (InBuffer->Pointer, &Buffer);
 766     if (ACPI_FAILURE (Status))
 767     {
 768         goto Cleanup;
 769     }
 770 
 771     /* Create and initialize the method parameter object */
 772 
 773     Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
 774     if (!Args[0])
 775     {
 776         /*
 777          * Must free the buffer allocated above (otherwise it is freed
 778          * later)
 779          */
 780         ACPI_FREE (Buffer.Pointer);
 781         Status = AE_NO_MEMORY;
 782         goto Cleanup;
 783     }
 784 
 785     Args[0]->Buffer.Length  = (UINT32) Buffer.Length;
 786     Args[0]->Buffer.Pointer = Buffer.Pointer;
 787     Args[0]->Common.Flags   = AOPOBJ_DATA_VALID;
 788     Args[1] = NULL;
 789 
 790     /* Execute the method, no return value is expected */
 791 
 792     Status = AcpiNsEvaluate (Info);
 793 
 794     /* Clean up and return the status from AcpiNsEvaluate */
 795 
 796     AcpiUtRemoveReference (Args[0]);
 797 
 798 Cleanup:
 799     ACPI_FREE (Info);
 800     return_ACPI_STATUS (Status);
 801 }
 802 
   1 /*******************************************************************************
   2  *
   3  * Module Name: rsutils - Utilities for the resource manager
   4  *
   5  ******************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2013, 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.


 156     UINT16                  ItemCount,
 157     UINT8                   MoveType)
 158 {
 159     UINT32                  i;
 160 
 161 
 162     ACPI_FUNCTION_ENTRY ();
 163 
 164 
 165     /* One move per item */
 166 
 167     for (i = 0; i < ItemCount; i++)
 168     {
 169         switch (MoveType)
 170         {
 171         /*
 172          * For the 8-bit case, we can perform the move all at once
 173          * since there are no alignment or endian issues
 174          */
 175         case ACPI_RSC_MOVE8:
 176         case ACPI_RSC_MOVE_GPIO_RES:
 177         case ACPI_RSC_MOVE_SERIAL_VEN:
 178         case ACPI_RSC_MOVE_SERIAL_RES:
 179 
 180             ACPI_MEMCPY (Destination, Source, ItemCount);
 181             return;
 182 
 183         /*
 184          * 16-, 32-, and 64-bit cases must use the move macros that perform
 185          * endian conversion and/or accommodate hardware that cannot perform
 186          * misaligned memory transfers
 187          */
 188         case ACPI_RSC_MOVE16:
 189         case ACPI_RSC_MOVE_GPIO_PIN:
 190 
 191             ACPI_MOVE_16_TO_16 (&ACPI_CAST_PTR (UINT16, Destination)[i],
 192                                 &ACPI_CAST_PTR (UINT16, Source)[i]);
 193             break;
 194 
 195         case ACPI_RSC_MOVE32:
 196 
 197             ACPI_MOVE_32_TO_32 (&ACPI_CAST_PTR (UINT32, Destination)[i],
 198                                 &ACPI_CAST_PTR (UINT32, Source)[i]);
 199             break;
 200 
 201         case ACPI_RSC_MOVE64:
 202 
 203             ACPI_MOVE_64_TO_64 (&ACPI_CAST_PTR (UINT64, Destination)[i],
 204                                 &ACPI_CAST_PTR (UINT64, Source)[i]);
 205             break;
 206 
 207         default:
 208 
 209             return;
 210         }
 211     }
 212 }
 213 
 214 
 215 /*******************************************************************************
 216  *
 217  * FUNCTION:    AcpiRsSetResourceLength
 218  *
 219  * PARAMETERS:  TotalLength         - Length of the AML descriptor, including
 220  *                                    the header and length fields.
 221  *              Aml                 - Pointer to the raw AML descriptor
 222  *
 223  * RETURN:      None
 224  *
 225  * DESCRIPTION: Set the ResourceLength field of an AML
 226  *              resource descriptor, both Large and Small descriptors are
 227  *              supported automatically. Note: Descriptor Type field must
 228  *              be valid.


 645     {
 646         return_ACPI_STATUS (Status);
 647     }
 648 
 649     /*
 650      * Make the call to create a resource linked list from the
 651      * byte stream buffer that comes back from the _CRS method
 652      * execution.
 653      */
 654     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
 655 
 656     /* On exit, we must delete the object returned by evaluateObject */
 657 
 658     AcpiUtRemoveReference (ObjDesc);
 659     return_ACPI_STATUS (Status);
 660 }
 661 
 662 
 663 /*******************************************************************************
 664  *
 665  * FUNCTION:    AcpiRsGetAeiMethodData
 666  *
 667  * PARAMETERS:  Node            - Device node
 668  *              RetBuffer       - Pointer to a buffer structure for the
 669  *                                results
 670  *
 671  * RETURN:      Status
 672  *
 673  * DESCRIPTION: This function is called to get the _AEI value of an object
 674  *              contained in an object specified by the handle passed in
 675  *
 676  *              If the function fails an appropriate status will be returned
 677  *              and the contents of the callers buffer is undefined.
 678  *
 679  ******************************************************************************/
 680 
 681 ACPI_STATUS
 682 AcpiRsGetAeiMethodData (
 683     ACPI_NAMESPACE_NODE     *Node,
 684     ACPI_BUFFER             *RetBuffer)
 685 {
 686     ACPI_OPERAND_OBJECT     *ObjDesc;
 687     ACPI_STATUS             Status;
 688 
 689 
 690     ACPI_FUNCTION_TRACE (RsGetAeiMethodData);
 691 
 692 
 693     /* Parameters guaranteed valid by caller */
 694 
 695     /* Execute the method, no parameters */
 696 
 697     Status = AcpiUtEvaluateObject (Node, METHOD_NAME__AEI,
 698                 ACPI_BTYPE_BUFFER, &ObjDesc);
 699     if (ACPI_FAILURE (Status))
 700     {
 701         return_ACPI_STATUS (Status);
 702     }
 703 
 704     /*
 705      * Make the call to create a resource linked list from the
 706      * byte stream buffer that comes back from the _CRS method
 707      * execution.
 708      */
 709     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
 710 
 711     /* On exit, we must delete the object returned by evaluateObject */
 712 
 713     AcpiUtRemoveReference (ObjDesc);
 714     return_ACPI_STATUS (Status);
 715 }
 716 
 717 
 718 /*******************************************************************************
 719  *
 720  * FUNCTION:    AcpiRsGetMethodData
 721  *
 722  * PARAMETERS:  Handle          - Handle to the containing object
 723  *              Path            - Path to method, relative to Handle
 724  *              RetBuffer       - Pointer to a buffer structure for the
 725  *                                results
 726  *
 727  * RETURN:      Status
 728  *
 729  * DESCRIPTION: This function is called to get the _CRS or _PRS value of an
 730  *              object contained in an object specified by the handle passed in
 731  *
 732  *              If the function fails an appropriate status will be returned
 733  *              and the contents of the callers buffer is undefined.
 734  *
 735  ******************************************************************************/
 736 
 737 ACPI_STATUS
 738 AcpiRsGetMethodData (
 739     ACPI_HANDLE             Handle,
 740     char                    *Path,
 741     ACPI_BUFFER             *RetBuffer)
 742 {
 743     ACPI_OPERAND_OBJECT     *ObjDesc;
 744     ACPI_STATUS             Status;
 745 
 746 
 747     ACPI_FUNCTION_TRACE (RsGetMethodData);
 748 
 749 
 750     /* Parameters guaranteed valid by caller */
 751 
 752     /* Execute the method, no parameters */
 753 
 754     Status = AcpiUtEvaluateObject (ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle),
 755         Path, ACPI_BTYPE_BUFFER, &ObjDesc);
 756     if (ACPI_FAILURE (Status))
 757     {
 758         return_ACPI_STATUS (Status);
 759     }
 760 
 761     /*
 762      * Make the call to create a resource linked list from the
 763      * byte stream buffer that comes back from the method
 764      * execution.
 765      */
 766     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
 767 
 768     /* On exit, we must delete the object returned by EvaluateObject */
 769 
 770     AcpiUtRemoveReference (ObjDesc);
 771     return_ACPI_STATUS (Status);
 772 }
 773 
 774 
 775 /*******************************************************************************


 798     ACPI_BUFFER             *InBuffer)
 799 {
 800     ACPI_EVALUATE_INFO      *Info;
 801     ACPI_OPERAND_OBJECT     *Args[2];
 802     ACPI_STATUS             Status;
 803     ACPI_BUFFER             Buffer;
 804 
 805 
 806     ACPI_FUNCTION_TRACE (RsSetSrsMethodData);
 807 
 808 
 809     /* Allocate and initialize the evaluation information block */
 810 
 811     Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
 812     if (!Info)
 813     {
 814         return_ACPI_STATUS (AE_NO_MEMORY);
 815     }
 816 
 817     Info->PrefixNode = Node;
 818     Info->RelativePathname = METHOD_NAME__SRS;
 819     Info->Parameters = Args;
 820     Info->Flags = ACPI_IGNORE_RETURN_VALUE;
 821 
 822     /*
 823      * The InBuffer parameter will point to a linked list of
 824      * resource parameters. It needs to be formatted into a
 825      * byte stream to be sent in as an input parameter to _SRS
 826      *
 827      * Convert the linked list into a byte stream
 828      */
 829     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
 830     Status = AcpiRsCreateAmlResources (InBuffer, &Buffer);
 831     if (ACPI_FAILURE (Status))
 832     {
 833         goto Cleanup;
 834     }
 835 
 836     /* Create and initialize the method parameter object */
 837 
 838     Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
 839     if (!Args[0])
 840     {
 841         /*
 842          * Must free the buffer allocated above (otherwise it is freed
 843          * later)
 844          */
 845         ACPI_FREE (Buffer.Pointer);
 846         Status = AE_NO_MEMORY;
 847         goto Cleanup;
 848     }
 849 
 850     Args[0]->Buffer.Length  = (UINT32) Buffer.Length;
 851     Args[0]->Buffer.Pointer = Buffer.Pointer;
 852     Args[0]->Common.Flags   = AOPOBJ_DATA_VALID;
 853     Args[1] = NULL;
 854 
 855     /* Execute the method, no return value is expected */
 856 
 857     Status = AcpiNsEvaluate (Info);
 858 
 859     /* Clean up and return the status from AcpiNsEvaluate */
 860 
 861     AcpiUtRemoveReference (Args[0]);
 862 
 863 Cleanup:
 864     ACPI_FREE (Info);
 865     return_ACPI_STATUS (Status);
 866 }