Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:03

0001 /*******************************************************************************
0002  *
0003  * Module Name: rsutils - Utilities for the resource manager
0004  *
0005  ******************************************************************************/
0006 
0007 /******************************************************************************
0008  *
0009  * 1. Copyright Notice
0010  *
0011  * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
0012  * All rights reserved.
0013  *
0014  * 2. License
0015  *
0016  * 2.1. This is your license from Intel Corp. under its intellectual property
0017  * rights. You may have additional license terms from the party that provided
0018  * you this software, covering your right to use that party's intellectual
0019  * property rights.
0020  *
0021  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
0022  * copy of the source code appearing in this file ("Covered Code") an
0023  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
0024  * base code distributed originally by Intel ("Original Intel Code") to copy,
0025  * make derivatives, distribute, use and display any portion of the Covered
0026  * Code in any form, with the right to sublicense such rights; and
0027  *
0028  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
0029  * license (with the right to sublicense), under only those claims of Intel
0030  * patents that are infringed by the Original Intel Code, to make, use, sell,
0031  * offer to sell, and import the Covered Code and derivative works thereof
0032  * solely to the minimum extent necessary to exercise the above copyright
0033  * license, and in no event shall the patent license extend to any additions
0034  * to or modifications of the Original Intel Code. No other license or right
0035  * is granted directly or by implication, estoppel or otherwise;
0036  *
0037  * The above copyright and patent license is granted only if the following
0038  * conditions are met:
0039  *
0040  * 3. Conditions
0041  *
0042  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
0043  * Redistribution of source code of any substantial portion of the Covered
0044  * Code or modification with rights to further distribute source must include
0045  * the above Copyright Notice, the above License, this list of Conditions,
0046  * and the following Disclaimer and Export Compliance provision. In addition,
0047  * Licensee must cause all Covered Code to which Licensee contributes to
0048  * contain a file documenting the changes Licensee made to create that Covered
0049  * Code and the date of any change. Licensee must include in that file the
0050  * documentation of any changes made by any predecessor Licensee. Licensee
0051  * must include a prominent statement that the modification is derived,
0052  * directly or indirectly, from Original Intel Code.
0053  *
0054  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
0055  * Redistribution of source code of any substantial portion of the Covered
0056  * Code or modification without rights to further distribute source must
0057  * include the following Disclaimer and Export Compliance provision in the
0058  * documentation and/or other materials provided with distribution. In
0059  * addition, Licensee may not authorize further sublicense of source of any
0060  * portion of the Covered Code, and must include terms to the effect that the
0061  * license from Licensee to its licensee is limited to the intellectual
0062  * property embodied in the software Licensee provides to its licensee, and
0063  * not to intellectual property embodied in modifications its licensee may
0064  * make.
0065  *
0066  * 3.3. Redistribution of Executable. Redistribution in executable form of any
0067  * substantial portion of the Covered Code or modification must reproduce the
0068  * above Copyright Notice, and the following Disclaimer and Export Compliance
0069  * provision in the documentation and/or other materials provided with the
0070  * distribution.
0071  *
0072  * 3.4. Intel retains all right, title, and interest in and to the Original
0073  * Intel Code.
0074  *
0075  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
0076  * Intel shall be used in advertising or otherwise to promote the sale, use or
0077  * other dealings in products derived from or relating to the Covered Code
0078  * without prior written authorization from Intel.
0079  *
0080  * 4. Disclaimer and Export Compliance
0081  *
0082  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
0083  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
0084  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
0085  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
0086  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
0087  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
0088  * PARTICULAR PURPOSE.
0089  *
0090  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
0091  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
0092  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
0093  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
0094  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
0095  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
0096  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
0097  * LIMITED REMEDY.
0098  *
0099  * 4.3. Licensee shall not export, either directly or indirectly, any of this
0100  * software or system incorporating such software without first obtaining any
0101  * required license or other approval from the U. S. Department of Commerce or
0102  * any other agency or department of the United States Government. In the
0103  * event Licensee exports any such software from the United States or
0104  * re-exports any such software from a foreign destination, Licensee shall
0105  * ensure that the distribution and export/re-export of the software is in
0106  * compliance with all laws, regulations, orders, or other restrictions of the
0107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
0108  * any of its subsidiaries will export/re-export any technical data, process,
0109  * software, or service, directly or indirectly, to any country for which the
0110  * United States government or any agency thereof requires an export license,
0111  * other governmental approval, or letter of assurance, without first obtaining
0112  * such license, approval or letter.
0113  *
0114  *****************************************************************************
0115  *
0116  * Alternatively, you may choose to be licensed under the terms of the
0117  * following license:
0118  *
0119  * Redistribution and use in source and binary forms, with or without
0120  * modification, are permitted provided that the following conditions
0121  * are met:
0122  * 1. Redistributions of source code must retain the above copyright
0123  *    notice, this list of conditions, and the following disclaimer,
0124  *    without modification.
0125  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
0126  *    substantially similar to the "NO WARRANTY" disclaimer below
0127  *    ("Disclaimer") and any redistribution must be conditioned upon
0128  *    including a substantially similar Disclaimer requirement for further
0129  *    binary redistribution.
0130  * 3. Neither the names of the above-listed copyright holders nor the names
0131  *    of any contributors may be used to endorse or promote products derived
0132  *    from this software without specific prior written permission.
0133  *
0134  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0135  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0136  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0137  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0138  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0139  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0140  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0141  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0142  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0143  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0144  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
0145  *
0146  * Alternatively, you may choose to be licensed under the terms of the
0147  * GNU General Public License ("GPL") version 2 as published by the Free
0148  * Software Foundation.
0149  *
0150  *****************************************************************************/
0151 
0152 #include "acpi.h"
0153 #include "accommon.h"
0154 #include "acnamesp.h"
0155 #include "acresrc.h"
0156 
0157 
0158 #define _COMPONENT          ACPI_RESOURCES
0159         ACPI_MODULE_NAME    ("rsutils")
0160 
0161 
0162 /*******************************************************************************
0163  *
0164  * FUNCTION:    AcpiRsDecodeBitmask
0165  *
0166  * PARAMETERS:  Mask            - Bitmask to decode
0167  *              List            - Where the converted list is returned
0168  *
0169  * RETURN:      Count of bits set (length of list)
0170  *
0171  * DESCRIPTION: Convert a bit mask into a list of values
0172  *
0173  ******************************************************************************/
0174 
0175 UINT8
0176 AcpiRsDecodeBitmask (
0177     UINT16                  Mask,
0178     UINT8                   *List)
0179 {
0180     UINT8                   i;
0181     UINT8                   BitCount;
0182 
0183 
0184     ACPI_FUNCTION_ENTRY ();
0185 
0186 
0187     /* Decode the mask bits */
0188 
0189     for (i = 0, BitCount = 0; Mask; i++)
0190     {
0191         if (Mask & 0x0001)
0192         {
0193             List[BitCount] = i;
0194             BitCount++;
0195         }
0196 
0197         Mask >>= 1;
0198     }
0199 
0200     return (BitCount);
0201 }
0202 
0203 
0204 /*******************************************************************************
0205  *
0206  * FUNCTION:    AcpiRsEncodeBitmask
0207  *
0208  * PARAMETERS:  List            - List of values to encode
0209  *              Count           - Length of list
0210  *
0211  * RETURN:      Encoded bitmask
0212  *
0213  * DESCRIPTION: Convert a list of values to an encoded bitmask
0214  *
0215  ******************************************************************************/
0216 
0217 UINT16
0218 AcpiRsEncodeBitmask (
0219     UINT8                   *List,
0220     UINT8                   Count)
0221 {
0222     UINT32                  i;
0223     UINT16                  Mask;
0224 
0225 
0226     ACPI_FUNCTION_ENTRY ();
0227 
0228 
0229     /* Encode the list into a single bitmask */
0230 
0231     for (i = 0, Mask = 0; i < Count; i++)
0232     {
0233         Mask |= (0x1 << List[i]);
0234     }
0235 
0236     return (Mask);
0237 }
0238 
0239 
0240 /*******************************************************************************
0241  *
0242  * FUNCTION:    AcpiRsMoveData
0243  *
0244  * PARAMETERS:  Destination         - Pointer to the destination descriptor
0245  *              Source              - Pointer to the source descriptor
0246  *              ItemCount           - How many items to move
0247  *              MoveType            - Byte width
0248  *
0249  * RETURN:      None
0250  *
0251  * DESCRIPTION: Move multiple data items from one descriptor to another. Handles
0252  *              alignment issues and endian issues if necessary, as configured
0253  *              via the ACPI_MOVE_* macros. (This is why a memcpy is not used)
0254  *
0255  ******************************************************************************/
0256 
0257 void
0258 AcpiRsMoveData (
0259     void                    *Destination,
0260     void                    *Source,
0261     UINT16                  ItemCount,
0262     UINT8                   MoveType)
0263 {
0264     UINT32                  i;
0265 
0266 
0267     ACPI_FUNCTION_ENTRY ();
0268 
0269 
0270     /* One move per item */
0271 
0272     for (i = 0; i < ItemCount; i++)
0273     {
0274         switch (MoveType)
0275         {
0276         /*
0277          * For the 8-bit case, we can perform the move all at once
0278          * since there are no alignment or endian issues
0279          */
0280         case ACPI_RSC_MOVE8:
0281         case ACPI_RSC_MOVE_GPIO_RES:
0282         case ACPI_RSC_MOVE_SERIAL_VEN:
0283         case ACPI_RSC_MOVE_SERIAL_RES:
0284 
0285             memcpy (Destination, Source, ItemCount);
0286             return;
0287 
0288         /*
0289          * 16-, 32-, and 64-bit cases must use the move macros that perform
0290          * endian conversion and/or accommodate hardware that cannot perform
0291          * misaligned memory transfers
0292          */
0293         case ACPI_RSC_MOVE16:
0294         case ACPI_RSC_MOVE_GPIO_PIN:
0295 
0296             ACPI_MOVE_16_TO_16 (
0297                 &ACPI_CAST_PTR (UINT16, Destination)[i],
0298                 &ACPI_CAST_PTR (UINT16, Source)[i]);
0299             break;
0300 
0301         case ACPI_RSC_MOVE32:
0302 
0303             ACPI_MOVE_32_TO_32 (
0304                 &ACPI_CAST_PTR (UINT32, Destination)[i],
0305                 &ACPI_CAST_PTR (UINT32, Source)[i]);
0306             break;
0307 
0308         case ACPI_RSC_MOVE64:
0309 
0310             ACPI_MOVE_64_TO_64 (
0311                 &ACPI_CAST_PTR (UINT64, Destination)[i],
0312                 &ACPI_CAST_PTR (UINT64, Source)[i]);
0313             break;
0314 
0315         default:
0316 
0317             return;
0318         }
0319     }
0320 }
0321 
0322 
0323 /*******************************************************************************
0324  *
0325  * FUNCTION:    AcpiRsSetResourceLength
0326  *
0327  * PARAMETERS:  TotalLength         - Length of the AML descriptor, including
0328  *                                    the header and length fields.
0329  *              Aml                 - Pointer to the raw AML descriptor
0330  *
0331  * RETURN:      None
0332  *
0333  * DESCRIPTION: Set the ResourceLength field of an AML
0334  *              resource descriptor, both Large and Small descriptors are
0335  *              supported automatically. Note: Descriptor Type field must
0336  *              be valid.
0337  *
0338  ******************************************************************************/
0339 
0340 void
0341 AcpiRsSetResourceLength (
0342     ACPI_RSDESC_SIZE        TotalLength,
0343     AML_RESOURCE            *Aml)
0344 {
0345     ACPI_RS_LENGTH          ResourceLength;
0346 
0347 
0348     ACPI_FUNCTION_ENTRY ();
0349 
0350 
0351     /* Length is the total descriptor length minus the header length */
0352 
0353     ResourceLength = (ACPI_RS_LENGTH)
0354         (TotalLength - AcpiUtGetResourceHeaderLength (Aml));
0355 
0356     /* Length is stored differently for large and small descriptors */
0357 
0358     if (Aml->SmallHeader.DescriptorType & ACPI_RESOURCE_NAME_LARGE)
0359     {
0360         /* Large descriptor -- bytes 1-2 contain the 16-bit length */
0361 
0362         ACPI_MOVE_16_TO_16 (
0363             &Aml->LargeHeader.ResourceLength, &ResourceLength);
0364     }
0365     else
0366     {
0367         /*
0368          * Small descriptor -- bits 2:0 of byte 0 contain the length
0369          * Clear any existing length, preserving descriptor type bits
0370          */
0371         Aml->SmallHeader.DescriptorType = (UINT8)
0372             ((Aml->SmallHeader.DescriptorType &
0373                 ~ACPI_RESOURCE_NAME_SMALL_LENGTH_MASK)
0374             | ResourceLength);
0375     }
0376 }
0377 
0378 
0379 /*******************************************************************************
0380  *
0381  * FUNCTION:    AcpiRsSetResourceHeader
0382  *
0383  * PARAMETERS:  DescriptorType      - Byte to be inserted as the type
0384  *              TotalLength         - Length of the AML descriptor, including
0385  *                                    the header and length fields.
0386  *              Aml                 - Pointer to the raw AML descriptor
0387  *
0388  * RETURN:      None
0389  *
0390  * DESCRIPTION: Set the DescriptorType and ResourceLength fields of an AML
0391  *              resource descriptor, both Large and Small descriptors are
0392  *              supported automatically
0393  *
0394  ******************************************************************************/
0395 
0396 void
0397 AcpiRsSetResourceHeader (
0398     UINT8                   DescriptorType,
0399     ACPI_RSDESC_SIZE        TotalLength,
0400     AML_RESOURCE            *Aml)
0401 {
0402     ACPI_FUNCTION_ENTRY ();
0403 
0404 
0405     /* Set the Resource Type */
0406 
0407     Aml->SmallHeader.DescriptorType = DescriptorType;
0408 
0409     /* Set the Resource Length */
0410 
0411     AcpiRsSetResourceLength (TotalLength, Aml);
0412 }
0413 
0414 
0415 /*******************************************************************************
0416  *
0417  * FUNCTION:    AcpiRsStrcpy
0418  *
0419  * PARAMETERS:  Destination         - Pointer to the destination string
0420  *              Source              - Pointer to the source string
0421  *
0422  * RETURN:      String length, including NULL terminator
0423  *
0424  * DESCRIPTION: Local string copy that returns the string length, saving a
0425  *              strcpy followed by a strlen.
0426  *
0427  ******************************************************************************/
0428 
0429 static UINT16
0430 AcpiRsStrcpy (
0431     char                    *Destination,
0432     char                    *Source)
0433 {
0434     UINT16                  i;
0435 
0436 
0437     ACPI_FUNCTION_ENTRY ();
0438 
0439 
0440     for (i = 0; Source[i]; i++)
0441     {
0442         Destination[i] = Source[i];
0443     }
0444 
0445     Destination[i] = 0;
0446 
0447     /* Return string length including the NULL terminator */
0448 
0449     return ((UINT16) (i + 1));
0450 }
0451 
0452 
0453 /*******************************************************************************
0454  *
0455  * FUNCTION:    AcpiRsGetResourceSource
0456  *
0457  * PARAMETERS:  ResourceLength      - Length field of the descriptor
0458  *              MinimumLength       - Minimum length of the descriptor (minus
0459  *                                    any optional fields)
0460  *              ResourceSource      - Where the ResourceSource is returned
0461  *              Aml                 - Pointer to the raw AML descriptor
0462  *              StringPtr           - (optional) where to store the actual
0463  *                                    ResourceSource string
0464  *
0465  * RETURN:      Length of the string plus NULL terminator, rounded up to native
0466  *              word boundary
0467  *
0468  * DESCRIPTION: Copy the optional ResourceSource data from a raw AML descriptor
0469  *              to an internal resource descriptor
0470  *
0471  ******************************************************************************/
0472 
0473 ACPI_RS_LENGTH
0474 AcpiRsGetResourceSource (
0475     ACPI_RS_LENGTH          ResourceLength,
0476     ACPI_RS_LENGTH          MinimumLength,
0477     ACPI_RESOURCE_SOURCE    *ResourceSource,
0478     AML_RESOURCE            *Aml,
0479     char                    *StringPtr)
0480 {
0481     ACPI_RSDESC_SIZE        TotalLength;
0482     UINT8                   *AmlResourceSource;
0483 
0484 
0485     ACPI_FUNCTION_ENTRY ();
0486 
0487 
0488     TotalLength = ResourceLength + sizeof (AML_RESOURCE_LARGE_HEADER);
0489     AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
0490 
0491     /*
0492      * ResourceSource is present if the length of the descriptor is longer
0493      * than the minimum length.
0494      *
0495      * Note: Some resource descriptors will have an additional null, so
0496      * we add 1 to the minimum length.
0497      */
0498     if (TotalLength > (ACPI_RSDESC_SIZE) (MinimumLength + 1))
0499     {
0500         /* Get the ResourceSourceIndex */
0501 
0502         ResourceSource->Index = AmlResourceSource[0];
0503 
0504         ResourceSource->StringPtr = StringPtr;
0505         if (!StringPtr)
0506         {
0507             /*
0508              * String destination pointer is not specified; Set the String
0509              * pointer to the end of the current ResourceSource structure.
0510              */
0511             ResourceSource->StringPtr = ACPI_ADD_PTR (
0512                 char, ResourceSource, sizeof (ACPI_RESOURCE_SOURCE));
0513         }
0514 
0515         /*
0516          * In order for the Resource length to be a multiple of the native
0517          * word, calculate the length of the string (+1 for NULL terminator)
0518          * and expand to the next word multiple.
0519          *
0520          * Zero the entire area of the buffer.
0521          */
0522         TotalLength = (UINT32) strlen (
0523             ACPI_CAST_PTR (char, &AmlResourceSource[1])) + 1;
0524 
0525         TotalLength = (UINT32) ACPI_ROUND_UP_TO_NATIVE_WORD (TotalLength);
0526 
0527         memset (ResourceSource->StringPtr, 0, TotalLength);
0528 
0529         /* Copy the ResourceSource string to the destination */
0530 
0531         ResourceSource->StringLength = AcpiRsStrcpy (
0532             ResourceSource->StringPtr,
0533             ACPI_CAST_PTR (char, &AmlResourceSource[1]));
0534 
0535         return ((ACPI_RS_LENGTH) TotalLength);
0536     }
0537 
0538     /* ResourceSource is not present */
0539 
0540     ResourceSource->Index = 0;
0541     ResourceSource->StringLength = 0;
0542     ResourceSource->StringPtr = NULL;
0543     return (0);
0544 }
0545 
0546 
0547 /*******************************************************************************
0548  *
0549  * FUNCTION:    AcpiRsSetResourceSource
0550  *
0551  * PARAMETERS:  Aml                 - Pointer to the raw AML descriptor
0552  *              MinimumLength       - Minimum length of the descriptor (minus
0553  *                                    any optional fields)
0554  *              ResourceSource      - Internal ResourceSource
0555 
0556  *
0557  * RETURN:      Total length of the AML descriptor
0558  *
0559  * DESCRIPTION: Convert an optional ResourceSource from internal format to a
0560  *              raw AML resource descriptor
0561  *
0562  ******************************************************************************/
0563 
0564 ACPI_RSDESC_SIZE
0565 AcpiRsSetResourceSource (
0566     AML_RESOURCE            *Aml,
0567     ACPI_RS_LENGTH          MinimumLength,
0568     ACPI_RESOURCE_SOURCE    *ResourceSource)
0569 {
0570     UINT8                   *AmlResourceSource;
0571     ACPI_RSDESC_SIZE        DescriptorLength;
0572 
0573 
0574     ACPI_FUNCTION_ENTRY ();
0575 
0576 
0577     DescriptorLength = MinimumLength;
0578 
0579     /* Non-zero string length indicates presence of a ResourceSource */
0580 
0581     if (ResourceSource->StringLength)
0582     {
0583         /* Point to the end of the AML descriptor */
0584 
0585         AmlResourceSource = ACPI_ADD_PTR (UINT8, Aml, MinimumLength);
0586 
0587         /* Copy the ResourceSourceIndex */
0588 
0589         AmlResourceSource[0] = (UINT8) ResourceSource->Index;
0590 
0591         /* Copy the ResourceSource string */
0592 
0593         strcpy (ACPI_CAST_PTR (char, &AmlResourceSource[1]),
0594             ResourceSource->StringPtr);
0595 
0596         /*
0597          * Add the length of the string (+ 1 for null terminator) to the
0598          * final descriptor length
0599          */
0600         DescriptorLength += ((ACPI_RSDESC_SIZE)
0601             ResourceSource->StringLength + 1);
0602     }
0603 
0604     /* Return the new total length of the AML descriptor */
0605 
0606     return (DescriptorLength);
0607 }
0608 
0609 
0610 /*******************************************************************************
0611  *
0612  * FUNCTION:    AcpiRsGetPrtMethodData
0613  *
0614  * PARAMETERS:  Node            - Device node
0615  *              RetBuffer       - Pointer to a buffer structure for the
0616  *                                results
0617  *
0618  * RETURN:      Status
0619  *
0620  * DESCRIPTION: This function is called to get the _PRT value of an object
0621  *              contained in an object specified by the handle passed in
0622  *
0623  *              If the function fails an appropriate status will be returned
0624  *              and the contents of the callers buffer is undefined.
0625  *
0626  ******************************************************************************/
0627 
0628 ACPI_STATUS
0629 AcpiRsGetPrtMethodData (
0630     ACPI_NAMESPACE_NODE     *Node,
0631     ACPI_BUFFER             *RetBuffer)
0632 {
0633     ACPI_OPERAND_OBJECT     *ObjDesc;
0634     ACPI_STATUS             Status;
0635 
0636 
0637     ACPI_FUNCTION_TRACE (RsGetPrtMethodData);
0638 
0639 
0640     /* Parameters guaranteed valid by caller */
0641 
0642     /* Execute the method, no parameters */
0643 
0644     Status = AcpiUtEvaluateObject (
0645         Node, METHOD_NAME__PRT, ACPI_BTYPE_PACKAGE, &ObjDesc);
0646     if (ACPI_FAILURE (Status))
0647     {
0648         return_ACPI_STATUS (Status);
0649     }
0650 
0651     /*
0652      * Create a resource linked list from the byte stream buffer that comes
0653      * back from the _CRS method execution.
0654      */
0655     Status = AcpiRsCreatePciRoutingTable (ObjDesc, RetBuffer);
0656 
0657     /* On exit, we must delete the object returned by EvaluateObject */
0658 
0659     AcpiUtRemoveReference (ObjDesc);
0660     return_ACPI_STATUS (Status);
0661 }
0662 
0663 
0664 /*******************************************************************************
0665  *
0666  * FUNCTION:    AcpiRsGetCrsMethodData
0667  *
0668  * PARAMETERS:  Node            - Device node
0669  *              RetBuffer       - Pointer to a buffer structure for the
0670  *                                results
0671  *
0672  * RETURN:      Status
0673  *
0674  * DESCRIPTION: This function is called to get the _CRS value of an object
0675  *              contained in an object specified by the handle passed in
0676  *
0677  *              If the function fails an appropriate status will be returned
0678  *              and the contents of the callers buffer is undefined.
0679  *
0680  ******************************************************************************/
0681 
0682 ACPI_STATUS
0683 AcpiRsGetCrsMethodData (
0684     ACPI_NAMESPACE_NODE     *Node,
0685     ACPI_BUFFER             *RetBuffer)
0686 {
0687     ACPI_OPERAND_OBJECT     *ObjDesc;
0688     ACPI_STATUS             Status;
0689 
0690 
0691     ACPI_FUNCTION_TRACE (RsGetCrsMethodData);
0692 
0693 
0694     /* Parameters guaranteed valid by caller */
0695 
0696     /* Execute the method, no parameters */
0697 
0698     Status = AcpiUtEvaluateObject (
0699         Node, METHOD_NAME__CRS, ACPI_BTYPE_BUFFER, &ObjDesc);
0700     if (ACPI_FAILURE (Status))
0701     {
0702         return_ACPI_STATUS (Status);
0703     }
0704 
0705     /*
0706      * Make the call to create a resource linked list from the
0707      * byte stream buffer that comes back from the _CRS method
0708      * execution.
0709      */
0710     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
0711 
0712     /* On exit, we must delete the object returned by evaluateObject */
0713 
0714     AcpiUtRemoveReference (ObjDesc);
0715     return_ACPI_STATUS (Status);
0716 }
0717 
0718 
0719 /*******************************************************************************
0720  *
0721  * FUNCTION:    AcpiRsGetPrsMethodData
0722  *
0723  * PARAMETERS:  Node            - Device node
0724  *              RetBuffer       - Pointer to a buffer structure for the
0725  *                                results
0726  *
0727  * RETURN:      Status
0728  *
0729  * DESCRIPTION: This function is called to get the _PRS value of an object
0730  *              contained in an object specified by the handle passed in
0731  *
0732  *              If the function fails an appropriate status will be returned
0733  *              and the contents of the callers buffer is undefined.
0734  *
0735  ******************************************************************************/
0736 
0737 ACPI_STATUS
0738 AcpiRsGetPrsMethodData (
0739     ACPI_NAMESPACE_NODE     *Node,
0740     ACPI_BUFFER             *RetBuffer)
0741 {
0742     ACPI_OPERAND_OBJECT     *ObjDesc;
0743     ACPI_STATUS             Status;
0744 
0745 
0746     ACPI_FUNCTION_TRACE (RsGetPrsMethodData);
0747 
0748 
0749     /* Parameters guaranteed valid by caller */
0750 
0751     /* Execute the method, no parameters */
0752 
0753     Status = AcpiUtEvaluateObject (
0754         Node, METHOD_NAME__PRS, ACPI_BTYPE_BUFFER, &ObjDesc);
0755     if (ACPI_FAILURE (Status))
0756     {
0757         return_ACPI_STATUS (Status);
0758     }
0759 
0760     /*
0761      * Make the call to create a resource linked list from the
0762      * byte stream buffer that comes back from the _CRS method
0763      * execution.
0764      */
0765     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
0766 
0767     /* On exit, we must delete the object returned by evaluateObject */
0768 
0769     AcpiUtRemoveReference (ObjDesc);
0770     return_ACPI_STATUS (Status);
0771 }
0772 
0773 
0774 /*******************************************************************************
0775  *
0776  * FUNCTION:    AcpiRsGetAeiMethodData
0777  *
0778  * PARAMETERS:  Node            - Device node
0779  *              RetBuffer       - Pointer to a buffer structure for the
0780  *                                results
0781  *
0782  * RETURN:      Status
0783  *
0784  * DESCRIPTION: This function is called to get the _AEI value of an object
0785  *              contained in an object specified by the handle passed in
0786  *
0787  *              If the function fails an appropriate status will be returned
0788  *              and the contents of the callers buffer is undefined.
0789  *
0790  ******************************************************************************/
0791 
0792 ACPI_STATUS
0793 AcpiRsGetAeiMethodData (
0794     ACPI_NAMESPACE_NODE     *Node,
0795     ACPI_BUFFER             *RetBuffer)
0796 {
0797     ACPI_OPERAND_OBJECT     *ObjDesc;
0798     ACPI_STATUS             Status;
0799 
0800 
0801     ACPI_FUNCTION_TRACE (RsGetAeiMethodData);
0802 
0803 
0804     /* Parameters guaranteed valid by caller */
0805 
0806     /* Execute the method, no parameters */
0807 
0808     Status = AcpiUtEvaluateObject (
0809         Node, METHOD_NAME__AEI, ACPI_BTYPE_BUFFER, &ObjDesc);
0810     if (ACPI_FAILURE (Status))
0811     {
0812         return_ACPI_STATUS (Status);
0813     }
0814 
0815     /*
0816      * Make the call to create a resource linked list from the
0817      * byte stream buffer that comes back from the _CRS method
0818      * execution.
0819      */
0820     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
0821 
0822     /* On exit, we must delete the object returned by evaluateObject */
0823 
0824     AcpiUtRemoveReference (ObjDesc);
0825     return_ACPI_STATUS (Status);
0826 }
0827 
0828 
0829 /*******************************************************************************
0830  *
0831  * FUNCTION:    AcpiRsGetMethodData
0832  *
0833  * PARAMETERS:  Handle          - Handle to the containing object
0834  *              Path            - Path to method, relative to Handle
0835  *              RetBuffer       - Pointer to a buffer structure for the
0836  *                                results
0837  *
0838  * RETURN:      Status
0839  *
0840  * DESCRIPTION: This function is called to get the _CRS or _PRS value of an
0841  *              object contained in an object specified by the handle passed in
0842  *
0843  *              If the function fails an appropriate status will be returned
0844  *              and the contents of the callers buffer is undefined.
0845  *
0846  ******************************************************************************/
0847 
0848 ACPI_STATUS
0849 AcpiRsGetMethodData (
0850     ACPI_HANDLE             Handle,
0851     const char              *Path,
0852     ACPI_BUFFER             *RetBuffer)
0853 {
0854     ACPI_OPERAND_OBJECT     *ObjDesc;
0855     ACPI_STATUS             Status;
0856 
0857 
0858     ACPI_FUNCTION_TRACE (RsGetMethodData);
0859 
0860 
0861     /* Parameters guaranteed valid by caller */
0862 
0863     /* Execute the method, no parameters */
0864 
0865     Status = AcpiUtEvaluateObject (
0866         ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, Handle),
0867         Path, ACPI_BTYPE_BUFFER, &ObjDesc);
0868     if (ACPI_FAILURE (Status))
0869     {
0870         return_ACPI_STATUS (Status);
0871     }
0872 
0873     /*
0874      * Make the call to create a resource linked list from the
0875      * byte stream buffer that comes back from the method
0876      * execution.
0877      */
0878     Status = AcpiRsCreateResourceList (ObjDesc, RetBuffer);
0879 
0880     /* On exit, we must delete the object returned by EvaluateObject */
0881 
0882     AcpiUtRemoveReference (ObjDesc);
0883     return_ACPI_STATUS (Status);
0884 }
0885 
0886 
0887 /*******************************************************************************
0888  *
0889  * FUNCTION:    AcpiRsSetSrsMethodData
0890  *
0891  * PARAMETERS:  Node            - Device node
0892  *              InBuffer        - Pointer to a buffer structure of the
0893  *                                parameter
0894  *
0895  * RETURN:      Status
0896  *
0897  * DESCRIPTION: This function is called to set the _SRS of an object contained
0898  *              in an object specified by the handle passed in
0899  *
0900  *              If the function fails an appropriate status will be returned
0901  *              and the contents of the callers buffer is undefined.
0902  *
0903  * Note: Parameters guaranteed valid by caller
0904  *
0905  ******************************************************************************/
0906 
0907 ACPI_STATUS
0908 AcpiRsSetSrsMethodData (
0909     ACPI_NAMESPACE_NODE     *Node,
0910     ACPI_BUFFER             *InBuffer)
0911 {
0912     ACPI_EVALUATE_INFO      *Info;
0913     ACPI_OPERAND_OBJECT     *Args[2];
0914     ACPI_STATUS             Status;
0915     ACPI_BUFFER             Buffer;
0916 
0917 
0918     ACPI_FUNCTION_TRACE (RsSetSrsMethodData);
0919 
0920 
0921     /* Allocate and initialize the evaluation information block */
0922 
0923     Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
0924     if (!Info)
0925     {
0926         return_ACPI_STATUS (AE_NO_MEMORY);
0927     }
0928 
0929     Info->PrefixNode = Node;
0930     Info->RelativePathname = METHOD_NAME__SRS;
0931     Info->Parameters = Args;
0932     Info->Flags = ACPI_IGNORE_RETURN_VALUE;
0933 
0934     /*
0935      * The InBuffer parameter will point to a linked list of
0936      * resource parameters. It needs to be formatted into a
0937      * byte stream to be sent in as an input parameter to _SRS
0938      *
0939      * Convert the linked list into a byte stream
0940      */
0941     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
0942     Status = AcpiRsCreateAmlResources (InBuffer, &Buffer);
0943     if (ACPI_FAILURE (Status))
0944     {
0945         goto Cleanup;
0946     }
0947 
0948     /* Create and initialize the method parameter object */
0949 
0950     Args[0] = AcpiUtCreateInternalObject (ACPI_TYPE_BUFFER);
0951     if (!Args[0])
0952     {
0953         /*
0954          * Must free the buffer allocated above (otherwise it is freed
0955          * later)
0956          */
0957         ACPI_FREE (Buffer.Pointer);
0958         Status = AE_NO_MEMORY;
0959         goto Cleanup;
0960     }
0961 
0962     Args[0]->Buffer.Length  = (UINT32) Buffer.Length;
0963     Args[0]->Buffer.Pointer = Buffer.Pointer;
0964     Args[0]->Common.Flags   = AOPOBJ_DATA_VALID;
0965     Args[1] = NULL;
0966 
0967     /* Execute the method, no return value is expected */
0968 
0969     Status = AcpiNsEvaluate (Info);
0970 
0971     /* Clean up and return the status from AcpiNsEvaluate */
0972 
0973     AcpiUtRemoveReference (Args[0]);
0974 
0975 Cleanup:
0976     ACPI_FREE (Info);
0977     return_ACPI_STATUS (Status);
0978 }