Back to home page

LXR

 
 

    


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

0001 /*******************************************************************************
0002  *
0003  * Module Name: rscreate - Create resource lists/tables
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 "acresrc.h"
0155 #include "acnamesp.h"
0156 
0157 #define _COMPONENT          ACPI_RESOURCES
0158         ACPI_MODULE_NAME    ("rscreate")
0159 
0160 
0161 /*******************************************************************************
0162  *
0163  * FUNCTION:    AcpiBufferToResource
0164  *
0165  * PARAMETERS:  AmlBuffer           - Pointer to the resource byte stream
0166  *              AmlBufferLength     - Length of the AmlBuffer
0167  *              ResourcePtr         - Where the converted resource is returned
0168  *
0169  * RETURN:      Status
0170  *
0171  * DESCRIPTION: Convert a raw AML buffer to a resource list
0172  *
0173  ******************************************************************************/
0174 
0175 ACPI_STATUS
0176 AcpiBufferToResource (
0177     UINT8                   *AmlBuffer,
0178     UINT16                  AmlBufferLength,
0179     ACPI_RESOURCE           **ResourcePtr)
0180 {
0181     ACPI_STATUS             Status;
0182     ACPI_SIZE               ListSizeNeeded;
0183     void                    *Resource;
0184     void                    *CurrentResourcePtr;
0185 
0186 
0187     ACPI_FUNCTION_TRACE (AcpiBufferToResource);
0188 
0189 
0190     /*
0191      * Note: we allow AE_AML_NO_RESOURCE_END_TAG, since an end tag
0192      * is not required here.
0193      */
0194 
0195     /* Get the required length for the converted resource */
0196 
0197     Status = AcpiRsGetListLength (
0198         AmlBuffer, AmlBufferLength, &ListSizeNeeded);
0199     if (Status == AE_AML_NO_RESOURCE_END_TAG)
0200     {
0201         Status = AE_OK;
0202     }
0203     if (ACPI_FAILURE (Status))
0204     {
0205         return_ACPI_STATUS (Status);
0206     }
0207 
0208     /* Allocate a buffer for the converted resource */
0209 
0210     Resource = ACPI_ALLOCATE_ZEROED (ListSizeNeeded);
0211     CurrentResourcePtr = Resource;
0212     if (!Resource)
0213     {
0214         return_ACPI_STATUS (AE_NO_MEMORY);
0215     }
0216 
0217     /* Perform the AML-to-Resource conversion */
0218 
0219     Status = AcpiUtWalkAmlResources (NULL, AmlBuffer, AmlBufferLength,
0220         AcpiRsConvertAmlToResources, &CurrentResourcePtr);
0221     if (Status == AE_AML_NO_RESOURCE_END_TAG)
0222     {
0223         Status = AE_OK;
0224     }
0225     if (ACPI_FAILURE (Status))
0226     {
0227         ACPI_FREE (Resource);
0228     }
0229     else
0230     {
0231         *ResourcePtr = Resource;
0232     }
0233 
0234     return_ACPI_STATUS (Status);
0235 }
0236 
0237 ACPI_EXPORT_SYMBOL (AcpiBufferToResource)
0238 
0239 
0240 /*******************************************************************************
0241  *
0242  * FUNCTION:    AcpiRsCreateResourceList
0243  *
0244  * PARAMETERS:  AmlBuffer           - Pointer to the resource byte stream
0245  *              OutputBuffer        - Pointer to the user's buffer
0246  *
0247  * RETURN:      Status: AE_OK if okay, else a valid ACPI_STATUS code
0248  *              If OutputBuffer is not large enough, OutputBufferLength
0249  *              indicates how large OutputBuffer should be, else it
0250  *              indicates how may UINT8 elements of OutputBuffer are valid.
0251  *
0252  * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method
0253  *              execution and parses the stream to create a linked list
0254  *              of device resources.
0255  *
0256  ******************************************************************************/
0257 
0258 ACPI_STATUS
0259 AcpiRsCreateResourceList (
0260     ACPI_OPERAND_OBJECT     *AmlBuffer,
0261     ACPI_BUFFER             *OutputBuffer)
0262 {
0263 
0264     ACPI_STATUS             Status;
0265     UINT8                   *AmlStart;
0266     ACPI_SIZE               ListSizeNeeded = 0;
0267     UINT32                  AmlBufferLength;
0268     void                    *Resource;
0269 
0270 
0271     ACPI_FUNCTION_TRACE (RsCreateResourceList);
0272 
0273 
0274     ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlBuffer = %p\n",
0275         AmlBuffer));
0276 
0277     /* Params already validated, so we don't re-validate here */
0278 
0279     AmlBufferLength = AmlBuffer->Buffer.Length;
0280     AmlStart = AmlBuffer->Buffer.Pointer;
0281 
0282     /*
0283      * Pass the AmlBuffer into a module that can calculate
0284      * the buffer size needed for the linked list
0285      */
0286     Status = AcpiRsGetListLength (AmlStart, AmlBufferLength,
0287                 &ListSizeNeeded);
0288 
0289     ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X ListSizeNeeded=%X\n",
0290         Status, (UINT32) ListSizeNeeded));
0291     if (ACPI_FAILURE (Status))
0292     {
0293         return_ACPI_STATUS (Status);
0294     }
0295 
0296     /* Validate/Allocate/Clear caller buffer */
0297 
0298     Status = AcpiUtInitializeBuffer (OutputBuffer, ListSizeNeeded);
0299     if (ACPI_FAILURE (Status))
0300     {
0301         return_ACPI_STATUS (Status);
0302     }
0303 
0304     /* Do the conversion */
0305 
0306     Resource = OutputBuffer->Pointer;
0307     Status = AcpiUtWalkAmlResources (NULL, AmlStart, AmlBufferLength,
0308         AcpiRsConvertAmlToResources, &Resource);
0309     if (ACPI_FAILURE (Status))
0310     {
0311         return_ACPI_STATUS (Status);
0312     }
0313 
0314     ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
0315         OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
0316     return_ACPI_STATUS (AE_OK);
0317 }
0318 
0319 
0320 /*******************************************************************************
0321  *
0322  * FUNCTION:    AcpiRsCreatePciRoutingTable
0323  *
0324  * PARAMETERS:  PackageObject           - Pointer to a package containing one
0325  *                                        of more ACPI_OPERAND_OBJECTs
0326  *              OutputBuffer            - Pointer to the user's buffer
0327  *
0328  * RETURN:      Status  AE_OK if okay, else a valid ACPI_STATUS code.
0329  *              If the OutputBuffer is too small, the error will be
0330  *              AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
0331  *              to the size buffer needed.
0332  *
0333  * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a
0334  *              linked list of PCI interrupt descriptions
0335  *
0336  * NOTE: It is the caller's responsibility to ensure that the start of the
0337  * output buffer is aligned properly (if necessary).
0338  *
0339  ******************************************************************************/
0340 
0341 ACPI_STATUS
0342 AcpiRsCreatePciRoutingTable (
0343     ACPI_OPERAND_OBJECT     *PackageObject,
0344     ACPI_BUFFER             *OutputBuffer)
0345 {
0346     UINT8                   *Buffer;
0347     ACPI_OPERAND_OBJECT     **TopObjectList;
0348     ACPI_OPERAND_OBJECT     **SubObjectList;
0349     ACPI_OPERAND_OBJECT     *ObjDesc;
0350     ACPI_SIZE               BufferSizeNeeded = 0;
0351     UINT32                  NumberOfElements;
0352     UINT32                  Index;
0353     ACPI_PCI_ROUTING_TABLE  *UserPrt;
0354     ACPI_NAMESPACE_NODE     *Node;
0355     ACPI_STATUS             Status;
0356     ACPI_BUFFER             PathBuffer;
0357 
0358 
0359     ACPI_FUNCTION_TRACE (RsCreatePciRoutingTable);
0360 
0361 
0362     /* Params already validated, so we don't re-validate here */
0363 
0364     /* Get the required buffer length */
0365 
0366     Status = AcpiRsGetPciRoutingTableLength (
0367         PackageObject,&BufferSizeNeeded);
0368     if (ACPI_FAILURE (Status))
0369     {
0370         return_ACPI_STATUS (Status);
0371     }
0372 
0373     ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "BufferSizeNeeded = %X\n",
0374         (UINT32) BufferSizeNeeded));
0375 
0376     /* Validate/Allocate/Clear caller buffer */
0377 
0378     Status = AcpiUtInitializeBuffer (OutputBuffer, BufferSizeNeeded);
0379     if (ACPI_FAILURE (Status))
0380     {
0381         return_ACPI_STATUS (Status);
0382     }
0383 
0384     /*
0385      * Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a
0386      * package that in turn contains an UINT64 Address, a UINT8 Pin,
0387      * a Name, and a UINT8 SourceIndex.
0388      */
0389     TopObjectList = PackageObject->Package.Elements;
0390     NumberOfElements = PackageObject->Package.Count;
0391     Buffer = OutputBuffer->Pointer;
0392     UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
0393 
0394     for (Index = 0; Index < NumberOfElements; Index++)
0395     {
0396         /*
0397          * Point UserPrt past this current structure
0398          *
0399          * NOTE: On the first iteration, UserPrt->Length will
0400          * be zero because we cleared the return buffer earlier
0401          */
0402         Buffer += UserPrt->Length;
0403         UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
0404 
0405         /*
0406          * Fill in the Length field with the information we have at this
0407          * point. The minus four is to subtract the size of the UINT8
0408          * Source[4] member because it is added below.
0409          */
0410         UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4);
0411 
0412         /* Each subpackage must be of length 4 */
0413 
0414         if ((*TopObjectList)->Package.Count != 4)
0415         {
0416             ACPI_ERROR ((AE_INFO,
0417                 "(PRT[%u]) Need package of length 4, found length %u",
0418                 Index, (*TopObjectList)->Package.Count));
0419             return_ACPI_STATUS (AE_AML_PACKAGE_LIMIT);
0420         }
0421 
0422         /*
0423          * Dereference the subpackage.
0424          * The SubObjectList will now point to an array of the four IRQ
0425          * elements: [Address, Pin, Source, SourceIndex]
0426          */
0427         SubObjectList = (*TopObjectList)->Package.Elements;
0428 
0429         /* 1) First subobject: Dereference the PRT.Address */
0430 
0431         ObjDesc = SubObjectList[0];
0432         if (!ObjDesc || ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
0433         {
0434             ACPI_ERROR ((AE_INFO,
0435                 "(PRT[%u].Address) Need Integer, found %s",
0436                 Index, AcpiUtGetObjectTypeName (ObjDesc)));
0437             return_ACPI_STATUS (AE_BAD_DATA);
0438         }
0439 
0440         UserPrt->Address = ObjDesc->Integer.Value;
0441 
0442         /* 2) Second subobject: Dereference the PRT.Pin */
0443 
0444         ObjDesc = SubObjectList[1];
0445         if (!ObjDesc || ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
0446         {
0447             ACPI_ERROR ((AE_INFO, "(PRT[%u].Pin) Need Integer, found %s",
0448                 Index, AcpiUtGetObjectTypeName (ObjDesc)));
0449             return_ACPI_STATUS (AE_BAD_DATA);
0450         }
0451 
0452         UserPrt->Pin = (UINT32) ObjDesc->Integer.Value;
0453 
0454         /*
0455          * 3) Third subobject: Dereference the PRT.SourceName
0456          * The name may be unresolved (slack mode), so allow a null object
0457          */
0458         ObjDesc = SubObjectList[2];
0459         if (ObjDesc)
0460         {
0461             switch (ObjDesc->Common.Type)
0462             {
0463             case ACPI_TYPE_LOCAL_REFERENCE:
0464 
0465                 if (ObjDesc->Reference.Class != ACPI_REFCLASS_NAME)
0466                 {
0467                     ACPI_ERROR ((AE_INFO,
0468                         "(PRT[%u].Source) Need name, found Reference Class 0x%X",
0469                         Index, ObjDesc->Reference.Class));
0470                     return_ACPI_STATUS (AE_BAD_DATA);
0471                 }
0472 
0473                 Node = ObjDesc->Reference.Node;
0474 
0475                 /* Use *remaining* length of the buffer as max for pathname */
0476 
0477                 PathBuffer.Length = OutputBuffer->Length -
0478                     (UINT32) ((UINT8 *) UserPrt->Source -
0479                     (UINT8 *) OutputBuffer->Pointer);
0480                 PathBuffer.Pointer = UserPrt->Source;
0481 
0482                 Status = AcpiNsHandleToPathname (
0483                     (ACPI_HANDLE) Node, &PathBuffer, FALSE);
0484                 if (ACPI_FAILURE (Status))
0485                 {
0486                     return_ACPI_STATUS (Status);
0487                 }
0488 
0489                 /* +1 to include null terminator */
0490 
0491                 UserPrt->Length += (UINT32) strlen (UserPrt->Source) + 1;
0492                 break;
0493 
0494             case ACPI_TYPE_STRING:
0495 
0496                 strcpy (UserPrt->Source, ObjDesc->String.Pointer);
0497 
0498                 /*
0499                  * Add to the Length field the length of the string
0500                  * (add 1 for terminator)
0501                  */
0502                 UserPrt->Length += ObjDesc->String.Length + 1;
0503                 break;
0504 
0505             case ACPI_TYPE_INTEGER:
0506                 /*
0507                  * If this is a number, then the Source Name is NULL, since
0508                  * the entire buffer was zeroed out, we can leave this alone.
0509                  *
0510                  * Add to the Length field the length of the UINT32 NULL
0511                  */
0512                 UserPrt->Length += sizeof (UINT32);
0513                 break;
0514 
0515             default:
0516 
0517                ACPI_ERROR ((AE_INFO,
0518                    "(PRT[%u].Source) Need Ref/String/Integer, found %s",
0519                    Index, AcpiUtGetObjectTypeName (ObjDesc)));
0520                return_ACPI_STATUS (AE_BAD_DATA);
0521             }
0522         }
0523 
0524         /* Now align the current length */
0525 
0526         UserPrt->Length = (UINT32) ACPI_ROUND_UP_TO_64BIT (UserPrt->Length);
0527 
0528         /* 4) Fourth subobject: Dereference the PRT.SourceIndex */
0529 
0530         ObjDesc = SubObjectList[3];
0531         if (!ObjDesc || ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
0532         {
0533             ACPI_ERROR ((AE_INFO,
0534                 "(PRT[%u].SourceIndex) Need Integer, found %s",
0535                 Index, AcpiUtGetObjectTypeName (ObjDesc)));
0536             return_ACPI_STATUS (AE_BAD_DATA);
0537         }
0538 
0539         UserPrt->SourceIndex = (UINT32) ObjDesc->Integer.Value;
0540 
0541         /* Point to the next ACPI_OPERAND_OBJECT in the top level package */
0542 
0543         TopObjectList++;
0544     }
0545 
0546     ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
0547         OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
0548     return_ACPI_STATUS (AE_OK);
0549 }
0550 
0551 
0552 /*******************************************************************************
0553  *
0554  * FUNCTION:    AcpiRsCreateAmlResources
0555  *
0556  * PARAMETERS:  ResourceList            - Pointer to the resource list buffer
0557  *              OutputBuffer            - Where the AML buffer is returned
0558  *
0559  * RETURN:      Status  AE_OK if okay, else a valid ACPI_STATUS code.
0560  *              If the OutputBuffer is too small, the error will be
0561  *              AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
0562  *              to the size buffer needed.
0563  *
0564  * DESCRIPTION: Converts a list of device resources to an AML bytestream
0565  *              to be used as input for the _SRS control method.
0566  *
0567  ******************************************************************************/
0568 
0569 ACPI_STATUS
0570 AcpiRsCreateAmlResources (
0571     ACPI_BUFFER             *ResourceList,
0572     ACPI_BUFFER             *OutputBuffer)
0573 {
0574     ACPI_STATUS             Status;
0575     ACPI_SIZE               AmlSizeNeeded = 0;
0576 
0577 
0578     ACPI_FUNCTION_TRACE (RsCreateAmlResources);
0579 
0580 
0581     /* Params already validated, no need to re-validate here */
0582 
0583     ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ResourceList Buffer = %p\n",
0584         ResourceList->Pointer));
0585 
0586     /* Get the buffer size needed for the AML byte stream */
0587 
0588     Status = AcpiRsGetAmlLength (
0589         ResourceList->Pointer, ResourceList->Length, &AmlSizeNeeded);
0590 
0591     ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n",
0592         (UINT32) AmlSizeNeeded, AcpiFormatException (Status)));
0593     if (ACPI_FAILURE (Status))
0594     {
0595         return_ACPI_STATUS (Status);
0596     }
0597 
0598     /* Validate/Allocate/Clear caller buffer */
0599 
0600     Status = AcpiUtInitializeBuffer (OutputBuffer, AmlSizeNeeded);
0601     if (ACPI_FAILURE (Status))
0602     {
0603         return_ACPI_STATUS (Status);
0604     }
0605 
0606     /* Do the conversion */
0607 
0608     Status = AcpiRsConvertResourcesToAml (ResourceList->Pointer,
0609         AmlSizeNeeded, OutputBuffer->Pointer);
0610     if (ACPI_FAILURE (Status))
0611     {
0612         return_ACPI_STATUS (Status);
0613     }
0614 
0615     ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
0616         OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
0617     return_ACPI_STATUS (AE_OK);
0618 }