13446Smrj /*******************************************************************************
23446Smrj *
33446Smrj * Module Name: rscreate - Create resource lists/tables
43446Smrj *
53446Smrj ******************************************************************************/
63446Smrj
73446Smrj /******************************************************************************
83446Smrj *
93446Smrj * 1. Copyright Notice
103446Smrj *
11*9980SDana.Myers@Sun.COM * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
123446Smrj * All rights reserved.
133446Smrj *
143446Smrj * 2. License
153446Smrj *
163446Smrj * 2.1. This is your license from Intel Corp. under its intellectual property
173446Smrj * rights. You may have additional license terms from the party that provided
183446Smrj * you this software, covering your right to use that party's intellectual
193446Smrj * property rights.
203446Smrj *
213446Smrj * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
223446Smrj * copy of the source code appearing in this file ("Covered Code") an
233446Smrj * irrevocable, perpetual, worldwide license under Intel's copyrights in the
243446Smrj * base code distributed originally by Intel ("Original Intel Code") to copy,
253446Smrj * make derivatives, distribute, use and display any portion of the Covered
263446Smrj * Code in any form, with the right to sublicense such rights; and
273446Smrj *
283446Smrj * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
293446Smrj * license (with the right to sublicense), under only those claims of Intel
303446Smrj * patents that are infringed by the Original Intel Code, to make, use, sell,
313446Smrj * offer to sell, and import the Covered Code and derivative works thereof
323446Smrj * solely to the minimum extent necessary to exercise the above copyright
333446Smrj * license, and in no event shall the patent license extend to any additions
343446Smrj * to or modifications of the Original Intel Code. No other license or right
353446Smrj * is granted directly or by implication, estoppel or otherwise;
363446Smrj *
373446Smrj * The above copyright and patent license is granted only if the following
383446Smrj * conditions are met:
393446Smrj *
403446Smrj * 3. Conditions
413446Smrj *
423446Smrj * 3.1. Redistribution of Source with Rights to Further Distribute Source.
433446Smrj * Redistribution of source code of any substantial portion of the Covered
443446Smrj * Code or modification with rights to further distribute source must include
453446Smrj * the above Copyright Notice, the above License, this list of Conditions,
463446Smrj * and the following Disclaimer and Export Compliance provision. In addition,
473446Smrj * Licensee must cause all Covered Code to which Licensee contributes to
483446Smrj * contain a file documenting the changes Licensee made to create that Covered
493446Smrj * Code and the date of any change. Licensee must include in that file the
503446Smrj * documentation of any changes made by any predecessor Licensee. Licensee
513446Smrj * must include a prominent statement that the modification is derived,
523446Smrj * directly or indirectly, from Original Intel Code.
533446Smrj *
543446Smrj * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
553446Smrj * Redistribution of source code of any substantial portion of the Covered
563446Smrj * Code or modification without rights to further distribute source must
573446Smrj * include the following Disclaimer and Export Compliance provision in the
583446Smrj * documentation and/or other materials provided with distribution. In
593446Smrj * addition, Licensee may not authorize further sublicense of source of any
603446Smrj * portion of the Covered Code, and must include terms to the effect that the
613446Smrj * license from Licensee to its licensee is limited to the intellectual
623446Smrj * property embodied in the software Licensee provides to its licensee, and
633446Smrj * not to intellectual property embodied in modifications its licensee may
643446Smrj * make.
653446Smrj *
663446Smrj * 3.3. Redistribution of Executable. Redistribution in executable form of any
673446Smrj * substantial portion of the Covered Code or modification must reproduce the
683446Smrj * above Copyright Notice, and the following Disclaimer and Export Compliance
693446Smrj * provision in the documentation and/or other materials provided with the
703446Smrj * distribution.
713446Smrj *
723446Smrj * 3.4. Intel retains all right, title, and interest in and to the Original
733446Smrj * Intel Code.
743446Smrj *
753446Smrj * 3.5. Neither the name Intel nor any other trademark owned or controlled by
763446Smrj * Intel shall be used in advertising or otherwise to promote the sale, use or
773446Smrj * other dealings in products derived from or relating to the Covered Code
783446Smrj * without prior written authorization from Intel.
793446Smrj *
803446Smrj * 4. Disclaimer and Export Compliance
813446Smrj *
823446Smrj * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
833446Smrj * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
843446Smrj * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
853446Smrj * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
863446Smrj * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
873446Smrj * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
883446Smrj * PARTICULAR PURPOSE.
893446Smrj *
903446Smrj * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
913446Smrj * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
923446Smrj * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
933446Smrj * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
943446Smrj * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
953446Smrj * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
963446Smrj * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
973446Smrj * LIMITED REMEDY.
983446Smrj *
993446Smrj * 4.3. Licensee shall not export, either directly or indirectly, any of this
1003446Smrj * software or system incorporating such software without first obtaining any
1013446Smrj * required license or other approval from the U. S. Department of Commerce or
1023446Smrj * any other agency or department of the United States Government. In the
1033446Smrj * event Licensee exports any such software from the United States or
1043446Smrj * re-exports any such software from a foreign destination, Licensee shall
1053446Smrj * ensure that the distribution and export/re-export of the software is in
1063446Smrj * compliance with all laws, regulations, orders, or other restrictions of the
1073446Smrj * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1083446Smrj * any of its subsidiaries will export/re-export any technical data, process,
1093446Smrj * software, or service, directly or indirectly, to any country for which the
1103446Smrj * United States government or any agency thereof requires an export license,
1113446Smrj * other governmental approval, or letter of assurance, without first obtaining
1123446Smrj * such license, approval or letter.
1133446Smrj *
1143446Smrj *****************************************************************************/
1153446Smrj
1163446Smrj #define __RSCREATE_C__
1173446Smrj
1183446Smrj #include "acpi.h"
119*9980SDana.Myers@Sun.COM #include "accommon.h"
1203446Smrj #include "acresrc.h"
1213446Smrj #include "acnamesp.h"
1223446Smrj
1233446Smrj #define _COMPONENT ACPI_RESOURCES
1243446Smrj ACPI_MODULE_NAME ("rscreate")
1253446Smrj
1263446Smrj
1273446Smrj /*******************************************************************************
1283446Smrj *
1293446Smrj * FUNCTION: AcpiRsCreateResourceList
1303446Smrj *
1313446Smrj * PARAMETERS: AmlBuffer - Pointer to the resource byte stream
1323446Smrj * OutputBuffer - Pointer to the user's buffer
1333446Smrj *
1343446Smrj * RETURN: Status: AE_OK if okay, else a valid ACPI_STATUS code
1353446Smrj * If OutputBuffer is not large enough, OutputBufferLength
1363446Smrj * indicates how large OutputBuffer should be, else it
1373446Smrj * indicates how may UINT8 elements of OutputBuffer are valid.
1383446Smrj *
1393446Smrj * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method
1403446Smrj * execution and parses the stream to create a linked list
1413446Smrj * of device resources.
1423446Smrj *
1433446Smrj ******************************************************************************/
1443446Smrj
1453446Smrj ACPI_STATUS
AcpiRsCreateResourceList(ACPI_OPERAND_OBJECT * AmlBuffer,ACPI_BUFFER * OutputBuffer)1463446Smrj AcpiRsCreateResourceList (
1473446Smrj ACPI_OPERAND_OBJECT *AmlBuffer,
1483446Smrj ACPI_BUFFER *OutputBuffer)
1493446Smrj {
1503446Smrj
1513446Smrj ACPI_STATUS Status;
1523446Smrj UINT8 *AmlStart;
1533446Smrj ACPI_SIZE ListSizeNeeded = 0;
1543446Smrj UINT32 AmlBufferLength;
1553446Smrj void *Resource;
1563446Smrj
1573446Smrj
1583446Smrj ACPI_FUNCTION_TRACE (RsCreateResourceList);
1593446Smrj
1603446Smrj
1613446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlBuffer = %p\n",
1623446Smrj AmlBuffer));
1633446Smrj
1643446Smrj /* Params already validated, so we don't re-validate here */
1653446Smrj
1663446Smrj AmlBufferLength = AmlBuffer->Buffer.Length;
1673446Smrj AmlStart = AmlBuffer->Buffer.Pointer;
1683446Smrj
1693446Smrj /*
1703446Smrj * Pass the AmlBuffer into a module that can calculate
1713446Smrj * the buffer size needed for the linked list
1723446Smrj */
1733446Smrj Status = AcpiRsGetListLength (AmlStart, AmlBufferLength,
1743446Smrj &ListSizeNeeded);
1753446Smrj
1763446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X ListSizeNeeded=%X\n",
1773446Smrj Status, (UINT32) ListSizeNeeded));
1783446Smrj if (ACPI_FAILURE (Status))
1793446Smrj {
1803446Smrj return_ACPI_STATUS (Status);
1813446Smrj }
1823446Smrj
1833446Smrj /* Validate/Allocate/Clear caller buffer */
1843446Smrj
1853446Smrj Status = AcpiUtInitializeBuffer (OutputBuffer, ListSizeNeeded);
1863446Smrj if (ACPI_FAILURE (Status))
1873446Smrj {
1883446Smrj return_ACPI_STATUS (Status);
1893446Smrj }
1903446Smrj
1913446Smrj /* Do the conversion */
1923446Smrj
1933446Smrj Resource = OutputBuffer->Pointer;
1943446Smrj Status = AcpiUtWalkAmlResources (AmlStart, AmlBufferLength,
1953446Smrj AcpiRsConvertAmlToResources, &Resource);
1963446Smrj if (ACPI_FAILURE (Status))
1973446Smrj {
1983446Smrj return_ACPI_STATUS (Status);
1993446Smrj }
2003446Smrj
2013446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
2023446Smrj OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
2033446Smrj return_ACPI_STATUS (AE_OK);
2043446Smrj }
2053446Smrj
2063446Smrj
2073446Smrj /*******************************************************************************
2083446Smrj *
2093446Smrj * FUNCTION: AcpiRsCreatePciRoutingTable
2103446Smrj *
2113446Smrj * PARAMETERS: PackageObject - Pointer to an ACPI_OPERAND_OBJECT
2123446Smrj * package
2133446Smrj * OutputBuffer - Pointer to the user's buffer
2143446Smrj *
2153446Smrj * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code.
2163446Smrj * If the OutputBuffer is too small, the error will be
2173446Smrj * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
2183446Smrj * to the size buffer needed.
2193446Smrj *
2203446Smrj * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a
2213446Smrj * linked list of PCI interrupt descriptions
2223446Smrj *
2233446Smrj * NOTE: It is the caller's responsibility to ensure that the start of the
2243446Smrj * output buffer is aligned properly (if necessary).
2253446Smrj *
2263446Smrj ******************************************************************************/
2273446Smrj
2283446Smrj ACPI_STATUS
AcpiRsCreatePciRoutingTable(ACPI_OPERAND_OBJECT * PackageObject,ACPI_BUFFER * OutputBuffer)2293446Smrj AcpiRsCreatePciRoutingTable (
2303446Smrj ACPI_OPERAND_OBJECT *PackageObject,
2313446Smrj ACPI_BUFFER *OutputBuffer)
2323446Smrj {
2333446Smrj UINT8 *Buffer;
2343446Smrj ACPI_OPERAND_OBJECT **TopObjectList;
2353446Smrj ACPI_OPERAND_OBJECT **SubObjectList;
2363446Smrj ACPI_OPERAND_OBJECT *ObjDesc;
2373446Smrj ACPI_SIZE BufferSizeNeeded = 0;
2383446Smrj UINT32 NumberOfElements;
2393446Smrj UINT32 Index;
2403446Smrj ACPI_PCI_ROUTING_TABLE *UserPrt;
2413446Smrj ACPI_NAMESPACE_NODE *Node;
2423446Smrj ACPI_STATUS Status;
2433446Smrj ACPI_BUFFER PathBuffer;
2443446Smrj
2453446Smrj
2463446Smrj ACPI_FUNCTION_TRACE (RsCreatePciRoutingTable);
2473446Smrj
2483446Smrj
2493446Smrj /* Params already validated, so we don't re-validate here */
2503446Smrj
2513446Smrj /* Get the required buffer length */
2523446Smrj
2533446Smrj Status = AcpiRsGetPciRoutingTableLength (PackageObject,
2543446Smrj &BufferSizeNeeded);
2553446Smrj if (ACPI_FAILURE (Status))
2563446Smrj {
2573446Smrj return_ACPI_STATUS (Status);
2583446Smrj }
2593446Smrj
2603446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "BufferSizeNeeded = %X\n",
2613446Smrj (UINT32) BufferSizeNeeded));
2623446Smrj
2633446Smrj /* Validate/Allocate/Clear caller buffer */
2643446Smrj
2653446Smrj Status = AcpiUtInitializeBuffer (OutputBuffer, BufferSizeNeeded);
2663446Smrj if (ACPI_FAILURE (Status))
2673446Smrj {
2683446Smrj return_ACPI_STATUS (Status);
2693446Smrj }
2703446Smrj
2713446Smrj /*
2727851SDana.Myers@Sun.COM * Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a
2737851SDana.Myers@Sun.COM * package that in turn contains an ACPI_INTEGER Address, a UINT8 Pin,
2747851SDana.Myers@Sun.COM * a Name, and a UINT8 SourceIndex.
2753446Smrj */
2763446Smrj TopObjectList = PackageObject->Package.Elements;
2773446Smrj NumberOfElements = PackageObject->Package.Count;
2783446Smrj Buffer = OutputBuffer->Pointer;
2793446Smrj UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
2803446Smrj
2813446Smrj for (Index = 0; Index < NumberOfElements; Index++)
2823446Smrj {
2833446Smrj /*
2843446Smrj * Point UserPrt past this current structure
2853446Smrj *
2863446Smrj * NOTE: On the first iteration, UserPrt->Length will
2873446Smrj * be zero because we cleared the return buffer earlier
2883446Smrj */
2893446Smrj Buffer += UserPrt->Length;
2903446Smrj UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
2913446Smrj
2923446Smrj /*
2933446Smrj * Fill in the Length field with the information we have at this point.
2943446Smrj * The minus four is to subtract the size of the UINT8 Source[4] member
2953446Smrj * because it is added below.
2963446Smrj */
2973446Smrj UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4);
2983446Smrj
2993446Smrj /* Each element of the top-level package must also be a package */
3003446Smrj
301*9980SDana.Myers@Sun.COM if ((*TopObjectList)->Common.Type != ACPI_TYPE_PACKAGE)
3023446Smrj {
3033446Smrj ACPI_ERROR ((AE_INFO,
3043446Smrj "(PRT[%X]) Need sub-package, found %s",
3053446Smrj Index, AcpiUtGetObjectTypeName (*TopObjectList)));
3063446Smrj return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
3073446Smrj }
3083446Smrj
3093446Smrj /* Each sub-package must be of length 4 */
3103446Smrj
3113446Smrj if ((*TopObjectList)->Package.Count != 4)
3123446Smrj {
3133446Smrj ACPI_ERROR ((AE_INFO,
3143446Smrj "(PRT[%X]) Need package of length 4, found length %d",
3153446Smrj Index, (*TopObjectList)->Package.Count));
3163446Smrj return_ACPI_STATUS (AE_AML_PACKAGE_LIMIT);
3173446Smrj }
3183446Smrj
3193446Smrj /*
3203446Smrj * Dereference the sub-package.
3213446Smrj * The SubObjectList will now point to an array of the four IRQ
3223446Smrj * elements: [Address, Pin, Source, SourceIndex]
3233446Smrj */
3243446Smrj SubObjectList = (*TopObjectList)->Package.Elements;
3253446Smrj
3263446Smrj /* 1) First subobject: Dereference the PRT.Address */
3273446Smrj
3283446Smrj ObjDesc = SubObjectList[0];
329*9980SDana.Myers@Sun.COM if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
3303446Smrj {
3317851SDana.Myers@Sun.COM ACPI_ERROR ((AE_INFO, "(PRT[%X].Address) Need Integer, found %s",
3323446Smrj Index, AcpiUtGetObjectTypeName (ObjDesc)));
3333446Smrj return_ACPI_STATUS (AE_BAD_DATA);
3343446Smrj }
3353446Smrj
3367851SDana.Myers@Sun.COM UserPrt->Address = ObjDesc->Integer.Value;
3377851SDana.Myers@Sun.COM
3383446Smrj /* 2) Second subobject: Dereference the PRT.Pin */
3393446Smrj
3403446Smrj ObjDesc = SubObjectList[1];
341*9980SDana.Myers@Sun.COM if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
3423446Smrj {
3437851SDana.Myers@Sun.COM ACPI_ERROR ((AE_INFO, "(PRT[%X].Pin) Need Integer, found %s",
3443446Smrj Index, AcpiUtGetObjectTypeName (ObjDesc)));
3453446Smrj return_ACPI_STATUS (AE_BAD_DATA);
3463446Smrj }
3473446Smrj
3487851SDana.Myers@Sun.COM UserPrt->Pin = (UINT32) ObjDesc->Integer.Value;
3497851SDana.Myers@Sun.COM
3507851SDana.Myers@Sun.COM /*
3517851SDana.Myers@Sun.COM * If the BIOS has erroneously reversed the _PRT SourceName (index 2)
3527851SDana.Myers@Sun.COM * and the SourceIndex (index 3), fix it. _PRT is important enough to
3537851SDana.Myers@Sun.COM * workaround this BIOS error. This also provides compatibility with
3547851SDana.Myers@Sun.COM * other ACPI implementations.
3557851SDana.Myers@Sun.COM */
3567851SDana.Myers@Sun.COM ObjDesc = SubObjectList[3];
357*9980SDana.Myers@Sun.COM if (!ObjDesc || (ObjDesc->Common.Type != ACPI_TYPE_INTEGER))
3587851SDana.Myers@Sun.COM {
3597851SDana.Myers@Sun.COM SubObjectList[3] = SubObjectList[2];
3607851SDana.Myers@Sun.COM SubObjectList[2] = ObjDesc;
3617851SDana.Myers@Sun.COM
3627851SDana.Myers@Sun.COM ACPI_WARNING ((AE_INFO,
3637851SDana.Myers@Sun.COM "(PRT[%X].Source) SourceName and SourceIndex are reversed, fixed",
3647851SDana.Myers@Sun.COM Index));
3657851SDana.Myers@Sun.COM }
3667851SDana.Myers@Sun.COM
3673446Smrj /*
3683446Smrj * 3) Third subobject: Dereference the PRT.SourceName
3693446Smrj * The name may be unresolved (slack mode), so allow a null object
3703446Smrj */
3713446Smrj ObjDesc = SubObjectList[2];
3723446Smrj if (ObjDesc)
3733446Smrj {
374*9980SDana.Myers@Sun.COM switch (ObjDesc->Common.Type)
3753446Smrj {
3763446Smrj case ACPI_TYPE_LOCAL_REFERENCE:
3773446Smrj
3787851SDana.Myers@Sun.COM if (ObjDesc->Reference.Class != ACPI_REFCLASS_NAME)
3793446Smrj {
3803446Smrj ACPI_ERROR ((AE_INFO,
3817851SDana.Myers@Sun.COM "(PRT[%X].Source) Need name, found Reference Class %X",
3827851SDana.Myers@Sun.COM Index, ObjDesc->Reference.Class));
3833446Smrj return_ACPI_STATUS (AE_BAD_DATA);
3843446Smrj }
3853446Smrj
3863446Smrj Node = ObjDesc->Reference.Node;
3873446Smrj
3883446Smrj /* Use *remaining* length of the buffer as max for pathname */
3893446Smrj
3903446Smrj PathBuffer.Length = OutputBuffer->Length -
3913446Smrj (UINT32) ((UINT8 *) UserPrt->Source -
3923446Smrj (UINT8 *) OutputBuffer->Pointer);
3933446Smrj PathBuffer.Pointer = UserPrt->Source;
3943446Smrj
3953446Smrj Status = AcpiNsHandleToPathname ((ACPI_HANDLE) Node, &PathBuffer);
3963446Smrj
3973446Smrj /* +1 to include null terminator */
3983446Smrj
3993446Smrj UserPrt->Length += (UINT32) ACPI_STRLEN (UserPrt->Source) + 1;
4003446Smrj break;
4013446Smrj
4023446Smrj
4033446Smrj case ACPI_TYPE_STRING:
4043446Smrj
4053446Smrj ACPI_STRCPY (UserPrt->Source, ObjDesc->String.Pointer);
4063446Smrj
4073446Smrj /*
4083446Smrj * Add to the Length field the length of the string
4093446Smrj * (add 1 for terminator)
4103446Smrj */
4113446Smrj UserPrt->Length += ObjDesc->String.Length + 1;
4123446Smrj break;
4133446Smrj
4143446Smrj
4153446Smrj case ACPI_TYPE_INTEGER:
4163446Smrj /*
4173446Smrj * If this is a number, then the Source Name is NULL, since the
4183446Smrj * entire buffer was zeroed out, we can leave this alone.
4193446Smrj *
4203446Smrj * Add to the Length field the length of the UINT32 NULL
4213446Smrj */
4223446Smrj UserPrt->Length += sizeof (UINT32);
4233446Smrj break;
4243446Smrj
4253446Smrj
4263446Smrj default:
4273446Smrj
4283446Smrj ACPI_ERROR ((AE_INFO,
4293446Smrj "(PRT[%X].Source) Need Ref/String/Integer, found %s",
4303446Smrj Index, AcpiUtGetObjectTypeName (ObjDesc)));
4313446Smrj return_ACPI_STATUS (AE_BAD_DATA);
4323446Smrj }
4333446Smrj }
4343446Smrj
4353446Smrj /* Now align the current length */
4363446Smrj
4373446Smrj UserPrt->Length = (UINT32) ACPI_ROUND_UP_TO_64BIT (UserPrt->Length);
4383446Smrj
4393446Smrj /* 4) Fourth subobject: Dereference the PRT.SourceIndex */
4403446Smrj
4413446Smrj ObjDesc = SubObjectList[3];
442*9980SDana.Myers@Sun.COM if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
4433446Smrj {
4443446Smrj ACPI_ERROR ((AE_INFO,
4453446Smrj "(PRT[%X].SourceIndex) Need Integer, found %s",
4463446Smrj Index, AcpiUtGetObjectTypeName (ObjDesc)));
4473446Smrj return_ACPI_STATUS (AE_BAD_DATA);
4483446Smrj }
4493446Smrj
4507851SDana.Myers@Sun.COM UserPrt->SourceIndex = (UINT32) ObjDesc->Integer.Value;
4517851SDana.Myers@Sun.COM
4523446Smrj /* Point to the next ACPI_OPERAND_OBJECT in the top level package */
4533446Smrj
4543446Smrj TopObjectList++;
4553446Smrj }
4563446Smrj
4573446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
4583446Smrj OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
4593446Smrj return_ACPI_STATUS (AE_OK);
4603446Smrj }
4613446Smrj
4623446Smrj
4633446Smrj /*******************************************************************************
4643446Smrj *
4653446Smrj * FUNCTION: AcpiRsCreateAmlResources
4663446Smrj *
4673446Smrj * PARAMETERS: LinkedListBuffer - Pointer to the resource linked list
4683446Smrj * OutputBuffer - Pointer to the user's buffer
4693446Smrj *
4703446Smrj * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code.
4713446Smrj * If the OutputBuffer is too small, the error will be
4723446Smrj * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
4733446Smrj * to the size buffer needed.
4743446Smrj *
4753446Smrj * DESCRIPTION: Takes the linked list of device resources and
4763446Smrj * creates a bytestream to be used as input for the
4773446Smrj * _SRS control method.
4783446Smrj *
4793446Smrj ******************************************************************************/
4803446Smrj
4813446Smrj ACPI_STATUS
AcpiRsCreateAmlResources(ACPI_RESOURCE * LinkedListBuffer,ACPI_BUFFER * OutputBuffer)4823446Smrj AcpiRsCreateAmlResources (
4833446Smrj ACPI_RESOURCE *LinkedListBuffer,
4843446Smrj ACPI_BUFFER *OutputBuffer)
4853446Smrj {
4863446Smrj ACPI_STATUS Status;
4873446Smrj ACPI_SIZE AmlSizeNeeded = 0;
4883446Smrj
4893446Smrj
4903446Smrj ACPI_FUNCTION_TRACE (RsCreateAmlResources);
4913446Smrj
4923446Smrj
4933446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "LinkedListBuffer = %p\n",
4943446Smrj LinkedListBuffer));
4953446Smrj
4963446Smrj /*
4973446Smrj * Params already validated, so we don't re-validate here
4983446Smrj *
4993446Smrj * Pass the LinkedListBuffer into a module that calculates
5003446Smrj * the buffer size needed for the byte stream.
5013446Smrj */
5023446Smrj Status = AcpiRsGetAmlLength (LinkedListBuffer,
5033446Smrj &AmlSizeNeeded);
5043446Smrj
5053446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n",
5063446Smrj (UINT32) AmlSizeNeeded, AcpiFormatException (Status)));
5073446Smrj if (ACPI_FAILURE (Status))
5083446Smrj {
5093446Smrj return_ACPI_STATUS (Status);
5103446Smrj }
5113446Smrj
5123446Smrj /* Validate/Allocate/Clear caller buffer */
5133446Smrj
5143446Smrj Status = AcpiUtInitializeBuffer (OutputBuffer, AmlSizeNeeded);
5153446Smrj if (ACPI_FAILURE (Status))
5163446Smrj {
5173446Smrj return_ACPI_STATUS (Status);
5183446Smrj }
5193446Smrj
5203446Smrj /* Do the conversion */
5213446Smrj
5223446Smrj Status = AcpiRsConvertResourcesToAml (LinkedListBuffer, AmlSizeNeeded,
5233446Smrj OutputBuffer->Pointer);
5243446Smrj if (ACPI_FAILURE (Status))
5253446Smrj {
5263446Smrj return_ACPI_STATUS (Status);
5273446Smrj }
5283446Smrj
5293446Smrj ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
5303446Smrj OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
5313446Smrj return_ACPI_STATUS (AE_OK);
5323446Smrj }
5333446Smrj
534