rscreate.c revision 193341
1100894Srwatson/******************************************************************************* 2100894Srwatson * 3100894Srwatson * Module Name: rscreate - Create resource lists/tables 4113681Srwatson * 5100894Srwatson ******************************************************************************/ 6100894Srwatson 7100894Srwatson/****************************************************************************** 8100894Srwatson * 9100894Srwatson * 1. Copyright Notice 10106392Srwatson * 11106392Srwatson * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp. 12106392Srwatson * All rights reserved. 13106392Srwatson * 14100894Srwatson * 2. License 15100894Srwatson * 16100894Srwatson * 2.1. This is your license from Intel Corp. under its intellectual property 17100894Srwatson * rights. You may have additional license terms from the party that provided 18100894Srwatson * you this software, covering your right to use that party's intellectual 19100894Srwatson * property rights. 20100894Srwatson * 21100894Srwatson * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22100894Srwatson * copy of the source code appearing in this file ("Covered Code") an 23100894Srwatson * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24100894Srwatson * base code distributed originally by Intel ("Original Intel Code") to copy, 25100894Srwatson * make derivatives, distribute, use and display any portion of the Covered 26100894Srwatson * Code in any form, with the right to sublicense such rights; and 27100894Srwatson * 28100894Srwatson * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29100894Srwatson * license (with the right to sublicense), under only those claims of Intel 30100894Srwatson * patents that are infringed by the Original Intel Code, to make, use, sell, 31100894Srwatson * offer to sell, and import the Covered Code and derivative works thereof 32100894Srwatson * solely to the minimum extent necessary to exercise the above copyright 33100894Srwatson * license, and in no event shall the patent license extend to any additions 34100894Srwatson * to or modifications of the Original Intel Code. No other license or right 35100894Srwatson * is granted directly or by implication, estoppel or otherwise; 36116182Sobrien * 37116182Sobrien * The above copyright and patent license is granted only if the following 38116182Sobrien * conditions are met: 39116182Sobrien * 40100894Srwatson * 3. Conditions 41101173Srwatson * 42100894Srwatson * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43106856Srwatson * Redistribution of source code of any substantial portion of the Covered 44106468Srwatson * Code or modification with rights to further distribute source must include 45100979Srwatson * the above Copyright Notice, the above License, this list of Conditions, 46100979Srwatson * and the following Disclaimer and Export Compliance provision. In addition, 47102949Sbde * Licensee must cause all Covered Code to which Licensee contributes to 48100979Srwatson * contain a file documenting the changes Licensee made to create that Covered 49100979Srwatson * Code and the date of any change. Licensee must include in that file the 50100979Srwatson * documentation of any changes made by any predecessor Licensee. Licensee 51116701Srwatson * must include a prominent statement that the modification is derived, 52100979Srwatson * directly or indirectly, from Original Intel Code. 53100979Srwatson * 54100979Srwatson * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55100979Srwatson * Redistribution of source code of any substantial portion of the Covered 56100979Srwatson * Code or modification without rights to further distribute source must 57100979Srwatson * include the following Disclaimer and Export Compliance provision in the 58100894Srwatson * documentation and/or other materials provided with distribution. In 59100979Srwatson * addition, Licensee may not authorize further sublicense of source of any 60100979Srwatson * portion of the Covered Code, and must include terms to the effect that the 61100979Srwatson * license from Licensee to its licensee is limited to the intellectual 62100979Srwatson * property embodied in the software Licensee provides to its licensee, and 63100979Srwatson * not to intellectual property embodied in modifications its licensee may 64100979Srwatson * make. 65100979Srwatson * 66121361Srwatson * 3.3. Redistribution of Executable. Redistribution in executable form of any 67100979Srwatson * substantial portion of the Covered Code or modification must reproduce the 68121361Srwatson * above Copyright Notice, and the following Disclaimer and Export Compliance 69100979Srwatson * provision in the documentation and/or other materials provided with the 70100979Srwatson * distribution. 71100979Srwatson * 72100979Srwatson * 3.4. Intel retains all right, title, and interest in and to the Original 73121361Srwatson * Intel Code. 74103514Srwatson * 75103514Srwatson * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76104236Srwatson * Intel shall be used in advertising or otherwise to promote the sale, use or 77103514Srwatson * other dealings in products derived from or relating to the Covered Code 78103136Srwatson * without prior written authorization from Intel. 79103136Srwatson * 80103136Srwatson * 4. Disclaimer and Export Compliance 81103136Srwatson * 82121361Srwatson * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83101892Srwatson * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84100979Srwatson * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85100979Srwatson * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86100979Srwatson * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87100979Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88101988Srwatson * PARTICULAR PURPOSE. 89121361Srwatson * 90104517Srwatson * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91100979Srwatson * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92107105Srwatson * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93107105Srwatson * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94101988Srwatson * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95100979Srwatson * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96100979Srwatson * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97100979Srwatson * LIMITED REMEDY. 98100979Srwatson * 99100979Srwatson * 4.3. Licensee shall not export, either directly or indirectly, any of this 100105694Srwatson * software or system incorporating such software without first obtaining any 101104521Srwatson * required license or other approval from the U. S. Department of Commerce or 102104521Srwatson * any other agency or department of the United States Government. In the 103105694Srwatson * event Licensee exports any such software from the United States or 104105694Srwatson * re-exports any such software from a foreign destination, Licensee shall 105119184Srwatson * ensure that the distribution and export/re-export of the software is in 106104521Srwatson * compliance with all laws, regulations, orders, or other restrictions of the 107104521Srwatson * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108104521Srwatson * any of its subsidiaries will export/re-export any technical data, process, 109105694Srwatson * software, or service, directly or indirectly, to any country for which the 110105694Srwatson * United States government or any agency thereof requires an export license, 111105694Srwatson * other governmental approval, or letter of assurance, without first obtaining 112105694Srwatson * such license, approval or letter. 113105694Srwatson * 114105694Srwatson *****************************************************************************/ 115105694Srwatson 116107105Srwatson#define __RSCREATE_C__ 117107105Srwatson 118107105Srwatson#include <contrib/dev/acpica/include/acpi.h> 119107105Srwatson#include <contrib/dev/acpica/include/accommon.h> 120107105Srwatson#include <contrib/dev/acpica/include/acresrc.h> 121119184Srwatson#include <contrib/dev/acpica/include/acnamesp.h> 122107105Srwatson 123107105Srwatson#define _COMPONENT ACPI_RESOURCES 124105988Srwatson ACPI_MODULE_NAME ("rscreate") 125105694Srwatson 126104521Srwatson 127104521Srwatson/******************************************************************************* 128105694Srwatson * 129105694Srwatson * FUNCTION: AcpiRsCreateResourceList 130119184Srwatson * 131104521Srwatson * PARAMETERS: AmlBuffer - Pointer to the resource byte stream 132104521Srwatson * OutputBuffer - Pointer to the user's buffer 133104521Srwatson * 134105694Srwatson * RETURN: Status: AE_OK if okay, else a valid ACPI_STATUS code 135105694Srwatson * If OutputBuffer is not large enough, OutputBufferLength 136105694Srwatson * indicates how large OutputBuffer should be, else it 137105694Srwatson * indicates how may UINT8 elements of OutputBuffer are valid. 138105694Srwatson * 139105694Srwatson * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method 140105694Srwatson * execution and parses the stream to create a linked list 141107105Srwatson * of device resources. 142107105Srwatson * 143107105Srwatson ******************************************************************************/ 144107105Srwatson 145107105SrwatsonACPI_STATUS 146119184SrwatsonAcpiRsCreateResourceList ( 147107105Srwatson ACPI_OPERAND_OBJECT *AmlBuffer, 148107105Srwatson ACPI_BUFFER *OutputBuffer) 149121361Srwatson{ 150105694Srwatson 151122159Srwatson ACPI_STATUS Status; 152105694Srwatson UINT8 *AmlStart; 153104522Srwatson ACPI_SIZE ListSizeNeeded = 0; 154104522Srwatson UINT32 AmlBufferLength; 155121507Srwatson void *Resource; 156104522Srwatson 157104522Srwatson 158104522Srwatson ACPI_FUNCTION_TRACE (RsCreateResourceList); 159104522Srwatson 160121361Srwatson 161105694Srwatson ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlBuffer = %p\n", 162105694Srwatson AmlBuffer)); 163105694Srwatson 164105694Srwatson /* Params already validated, so we don't re-validate here */ 165121507Srwatson 166105694Srwatson AmlBufferLength = AmlBuffer->Buffer.Length; 167105694Srwatson AmlStart = AmlBuffer->Buffer.Pointer; 168105694Srwatson 169105694Srwatson /* 170104522Srwatson * Pass the AmlBuffer into a module that can calculate 171104522Srwatson * the buffer size needed for the linked list 172104522Srwatson */ 173104522Srwatson Status = AcpiRsGetListLength (AmlStart, AmlBufferLength, 174104521Srwatson &ListSizeNeeded); 175104522Srwatson 176104522Srwatson ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X ListSizeNeeded=%X\n", 177104522Srwatson Status, (UINT32) ListSizeNeeded)); 178104522Srwatson if (ACPI_FAILURE (Status)) 179104522Srwatson { 180104522Srwatson return_ACPI_STATUS (Status); 181104522Srwatson } 182104522Srwatson 183104522Srwatson /* Validate/Allocate/Clear caller buffer */ 184104522Srwatson 185104522Srwatson Status = AcpiUtInitializeBuffer (OutputBuffer, ListSizeNeeded); 186104522Srwatson if (ACPI_FAILURE (Status)) 187104522Srwatson { 188104522Srwatson return_ACPI_STATUS (Status); 189104522Srwatson } 190104522Srwatson 191104522Srwatson /* Do the conversion */ 192104522Srwatson 193104522Srwatson Resource = OutputBuffer->Pointer; 194104522Srwatson Status = AcpiUtWalkAmlResources (AmlStart, AmlBufferLength, 195104522Srwatson AcpiRsConvertAmlToResources, &Resource); 196104522Srwatson if (ACPI_FAILURE (Status)) 197104522Srwatson { 198104522Srwatson return_ACPI_STATUS (Status); 199104522Srwatson } 200104522Srwatson 201104522Srwatson ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", 202104522Srwatson OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); 203104522Srwatson return_ACPI_STATUS (AE_OK); 204104522Srwatson} 205104522Srwatson 206104522Srwatson 207104522Srwatson/******************************************************************************* 208104522Srwatson * 209104522Srwatson * FUNCTION: AcpiRsCreatePciRoutingTable 210104522Srwatson * 211105988Srwatson * PARAMETERS: PackageObject - Pointer to an ACPI_OPERAND_OBJECT 212106468Srwatson * package 213106468Srwatson * OutputBuffer - Pointer to the user's buffer 214106468Srwatson * 215106468Srwatson * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. 216106468Srwatson * If the OutputBuffer is too small, the error will be 217106468Srwatson * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point 218106468Srwatson * to the size buffer needed. 219106468Srwatson * 220106468Srwatson * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a 221106468Srwatson * linked list of PCI interrupt descriptions 222106468Srwatson * 223106468Srwatson * NOTE: It is the caller's responsibility to ensure that the start of the 224106468Srwatson * output buffer is aligned properly (if necessary). 225106468Srwatson * 226106468Srwatson ******************************************************************************/ 227106468Srwatson 228106468SrwatsonACPI_STATUS 229106468SrwatsonAcpiRsCreatePciRoutingTable ( 230111119Simp ACPI_OPERAND_OBJECT *PackageObject, 231106468Srwatson ACPI_BUFFER *OutputBuffer) 232106468Srwatson{ 233106468Srwatson UINT8 *Buffer; 234106468Srwatson ACPI_OPERAND_OBJECT **TopObjectList; 235106468Srwatson ACPI_OPERAND_OBJECT **SubObjectList; 236106468Srwatson ACPI_OPERAND_OBJECT *ObjDesc; 237106468Srwatson ACPI_SIZE BufferSizeNeeded = 0; 238106468Srwatson UINT32 NumberOfElements; 239106468Srwatson UINT32 Index; 240106468Srwatson ACPI_PCI_ROUTING_TABLE *UserPrt; 241106468Srwatson ACPI_NAMESPACE_NODE *Node; 242106468Srwatson ACPI_STATUS Status; 243106468Srwatson ACPI_BUFFER PathBuffer; 244106468Srwatson 245106468Srwatson 246106468Srwatson ACPI_FUNCTION_TRACE (RsCreatePciRoutingTable); 247106468Srwatson 248100979Srwatson 249106468Srwatson /* Params already validated, so we don't re-validate here */ 250100979Srwatson 251106468Srwatson /* Get the required buffer length */ 252106468Srwatson 253106468Srwatson Status = AcpiRsGetPciRoutingTableLength (PackageObject, 254100979Srwatson &BufferSizeNeeded); 255100979Srwatson if (ACPI_FAILURE (Status)) 256100979Srwatson { 257100979Srwatson return_ACPI_STATUS (Status); 258100979Srwatson } 259100979Srwatson 260100979Srwatson ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "BufferSizeNeeded = %X\n", 261107271Srwatson (UINT32) BufferSizeNeeded)); 262100979Srwatson 263100979Srwatson /* Validate/Allocate/Clear caller buffer */ 264100979Srwatson 265100979Srwatson Status = AcpiUtInitializeBuffer (OutputBuffer, BufferSizeNeeded); 266100979Srwatson if (ACPI_FAILURE (Status)) 267100979Srwatson { 268100979Srwatson return_ACPI_STATUS (Status); 269100979Srwatson } 270100979Srwatson 271100979Srwatson /* 272100979Srwatson * Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a 273100979Srwatson * package that in turn contains an ACPI_INTEGER Address, a UINT8 Pin, 274100979Srwatson * a Name, and a UINT8 SourceIndex. 275100979Srwatson */ 276100979Srwatson TopObjectList = PackageObject->Package.Elements; 277100979Srwatson NumberOfElements = PackageObject->Package.Count; 278100979Srwatson Buffer = OutputBuffer->Pointer; 279100979Srwatson UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer); 280100979Srwatson 281100979Srwatson for (Index = 0; Index < NumberOfElements; Index++) 282100979Srwatson { 283100979Srwatson /* 284100979Srwatson * Point UserPrt past this current structure 285100979Srwatson * 286100979Srwatson * NOTE: On the first iteration, UserPrt->Length will 287100979Srwatson * be zero because we cleared the return buffer earlier 288100979Srwatson */ 289100979Srwatson Buffer += UserPrt->Length; 290100979Srwatson UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer); 291100979Srwatson 292100979Srwatson /* 293100979Srwatson * Fill in the Length field with the information we have at this point. 294100979Srwatson * The minus four is to subtract the size of the UINT8 Source[4] member 295100979Srwatson * because it is added below. 296100979Srwatson */ 297100979Srwatson UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4); 298100979Srwatson 299100979Srwatson /* Each element of the top-level package must also be a package */ 300104546Srwatson 301104546Srwatson if ((*TopObjectList)->Common.Type != ACPI_TYPE_PACKAGE) 302100979Srwatson { 303100979Srwatson ACPI_ERROR ((AE_INFO, 304100979Srwatson "(PRT[%X]) Need sub-package, found %s", 305100979Srwatson Index, AcpiUtGetObjectTypeName (*TopObjectList))); 306103136Srwatson return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 307103136Srwatson } 308103136Srwatson 309100979Srwatson /* Each sub-package must be of length 4 */ 310100979Srwatson 311100979Srwatson if ((*TopObjectList)->Package.Count != 4) 312100979Srwatson { 313100979Srwatson ACPI_ERROR ((AE_INFO, 314100979Srwatson "(PRT[%X]) Need package of length 4, found length %d", 315100979Srwatson Index, (*TopObjectList)->Package.Count)); 316100979Srwatson return_ACPI_STATUS (AE_AML_PACKAGE_LIMIT); 317100979Srwatson } 318100979Srwatson 319100979Srwatson /* 320100979Srwatson * Dereference the sub-package. 321100979Srwatson * The SubObjectList will now point to an array of the four IRQ 322100979Srwatson * elements: [Address, Pin, Source, SourceIndex] 323100979Srwatson */ 324100979Srwatson SubObjectList = (*TopObjectList)->Package.Elements; 325100979Srwatson 326100979Srwatson /* 1) First subobject: Dereference the PRT.Address */ 327100979Srwatson 328100979Srwatson ObjDesc = SubObjectList[0]; 329100979Srwatson if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) 330100979Srwatson { 331100979Srwatson ACPI_ERROR ((AE_INFO, "(PRT[%X].Address) Need Integer, found %s", 332100979Srwatson Index, AcpiUtGetObjectTypeName (ObjDesc))); 333100979Srwatson return_ACPI_STATUS (AE_BAD_DATA); 334100979Srwatson } 335100979Srwatson 336100979Srwatson UserPrt->Address = ObjDesc->Integer.Value; 337100979Srwatson 338100979Srwatson /* 2) Second subobject: Dereference the PRT.Pin */ 339100979Srwatson 340100979Srwatson ObjDesc = SubObjectList[1]; 341100979Srwatson if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) 342104546Srwatson { 343104546Srwatson ACPI_ERROR ((AE_INFO, "(PRT[%X].Pin) Need Integer, found %s", 344100979Srwatson Index, AcpiUtGetObjectTypeName (ObjDesc))); 345100979Srwatson return_ACPI_STATUS (AE_BAD_DATA); 346100979Srwatson } 347100979Srwatson 348100979Srwatson UserPrt->Pin = (UINT32) ObjDesc->Integer.Value; 349100979Srwatson 350100979Srwatson /* 351100979Srwatson * If the BIOS has erroneously reversed the _PRT SourceName (index 2) 352102949Sbde * and the SourceIndex (index 3), fix it. _PRT is important enough to 353102949Sbde * workaround this BIOS error. This also provides compatibility with 354102949Sbde * other ACPI implementations. 355102949Sbde */ 356100979Srwatson ObjDesc = SubObjectList[3]; 357100979Srwatson if (!ObjDesc || (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)) 358100979Srwatson { 359100979Srwatson SubObjectList[3] = SubObjectList[2]; 360100979Srwatson SubObjectList[2] = ObjDesc; 361100979Srwatson 362100979Srwatson ACPI_WARNING ((AE_INFO, 363100979Srwatson "(PRT[%X].Source) SourceName and SourceIndex are reversed, fixed", 364100979Srwatson Index)); 365100979Srwatson } 366100979Srwatson 367100979Srwatson /* 368100979Srwatson * 3) Third subobject: Dereference the PRT.SourceName 369100979Srwatson * The name may be unresolved (slack mode), so allow a null object 370100979Srwatson */ 371100979Srwatson ObjDesc = SubObjectList[2]; 372100979Srwatson if (ObjDesc) 373100979Srwatson { 374100979Srwatson switch (ObjDesc->Common.Type) 375100979Srwatson { 376113955Salc case ACPI_TYPE_LOCAL_REFERENCE: 377100979Srwatson 378100979Srwatson if (ObjDesc->Reference.Class != ACPI_REFCLASS_NAME) 379100979Srwatson { 380100979Srwatson ACPI_ERROR ((AE_INFO, 381100979Srwatson "(PRT[%X].Source) Need name, found Reference Class %X", 382113955Salc Index, ObjDesc->Reference.Class)); 383100979Srwatson return_ACPI_STATUS (AE_BAD_DATA); 384100979Srwatson } 385100979Srwatson 386100979Srwatson Node = ObjDesc->Reference.Node; 387100979Srwatson 388100979Srwatson /* Use *remaining* length of the buffer as max for pathname */ 389100979Srwatson 390100979Srwatson PathBuffer.Length = OutputBuffer->Length - 391100979Srwatson (UINT32) ((UINT8 *) UserPrt->Source - 392100979Srwatson (UINT8 *) OutputBuffer->Pointer); 393100979Srwatson PathBuffer.Pointer = UserPrt->Source; 394100979Srwatson 395100979Srwatson Status = AcpiNsHandleToPathname ((ACPI_HANDLE) Node, &PathBuffer); 396100979Srwatson 397100979Srwatson /* +1 to include null terminator */ 398100979Srwatson 399100979Srwatson UserPrt->Length += (UINT32) ACPI_STRLEN (UserPrt->Source) + 1; 400100979Srwatson break; 401100979Srwatson 402100979Srwatson 403100979Srwatson case ACPI_TYPE_STRING: 404100979Srwatson 405100979Srwatson ACPI_STRCPY (UserPrt->Source, ObjDesc->String.Pointer); 406100979Srwatson 407100979Srwatson /* 408100979Srwatson * Add to the Length field the length of the string 409100979Srwatson * (add 1 for terminator) 410100979Srwatson */ 411100979Srwatson UserPrt->Length += ObjDesc->String.Length + 1; 412100979Srwatson break; 413100979Srwatson 414100979Srwatson 415100979Srwatson case ACPI_TYPE_INTEGER: 416100979Srwatson /* 417100979Srwatson * If this is a number, then the Source Name is NULL, since the 418100979Srwatson * entire buffer was zeroed out, we can leave this alone. 419100979Srwatson * 420121361Srwatson * Add to the Length field the length of the UINT32 NULL 421100979Srwatson */ 422100979Srwatson UserPrt->Length += sizeof (UINT32); 423100979Srwatson break; 424100979Srwatson 425100979Srwatson 426100979Srwatson default: 427100979Srwatson 428100979Srwatson ACPI_ERROR ((AE_INFO, 429100979Srwatson "(PRT[%X].Source) Need Ref/String/Integer, found %s", 430100979Srwatson Index, AcpiUtGetObjectTypeName (ObjDesc))); 431100979Srwatson return_ACPI_STATUS (AE_BAD_DATA); 432100979Srwatson } 433100979Srwatson } 434100979Srwatson 435100979Srwatson /* Now align the current length */ 436100979Srwatson 437100979Srwatson UserPrt->Length = (UINT32) ACPI_ROUND_UP_TO_64BIT (UserPrt->Length); 438100979Srwatson 439100979Srwatson /* 4) Fourth subobject: Dereference the PRT.SourceIndex */ 440100979Srwatson 441100979Srwatson ObjDesc = SubObjectList[3]; 442100979Srwatson if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) 443100979Srwatson { 444100979Srwatson ACPI_ERROR ((AE_INFO, 445100979Srwatson "(PRT[%X].SourceIndex) Need Integer, found %s", 446100979Srwatson Index, AcpiUtGetObjectTypeName (ObjDesc))); 447100979Srwatson return_ACPI_STATUS (AE_BAD_DATA); 448100979Srwatson } 449100979Srwatson 450100979Srwatson UserPrt->SourceIndex = (UINT32) ObjDesc->Integer.Value; 451100979Srwatson 452100979Srwatson /* Point to the next ACPI_OPERAND_OBJECT in the top level package */ 453100979Srwatson 454100979Srwatson TopObjectList++; 455102103Srwatson } 456102103Srwatson 457100979Srwatson ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", 458100979Srwatson OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); 459100979Srwatson return_ACPI_STATUS (AE_OK); 460100979Srwatson} 461100979Srwatson 462100979Srwatson 463100979Srwatson/******************************************************************************* 464100979Srwatson * 465100979Srwatson * FUNCTION: AcpiRsCreateAmlResources 466100979Srwatson * 467100979Srwatson * PARAMETERS: LinkedListBuffer - Pointer to the resource linked list 468100979Srwatson * OutputBuffer - Pointer to the user's buffer 469100979Srwatson * 470102103Srwatson * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. 471102103Srwatson * If the OutputBuffer is too small, the error will be 472100979Srwatson * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point 473100979Srwatson * to the size buffer needed. 474100979Srwatson * 475100979Srwatson * DESCRIPTION: Takes the linked list of device resources and 476100979Srwatson * creates a bytestream to be used as input for the 477100979Srwatson * _SRS control method. 478100979Srwatson * 479100979Srwatson ******************************************************************************/ 480100979Srwatson 481100979SrwatsonACPI_STATUS 482100979SrwatsonAcpiRsCreateAmlResources ( 483100979Srwatson ACPI_RESOURCE *LinkedListBuffer, 484100979Srwatson ACPI_BUFFER *OutputBuffer) 485102103Srwatson{ 486102103Srwatson ACPI_STATUS Status; 487100979Srwatson ACPI_SIZE AmlSizeNeeded = 0; 488100979Srwatson 489100979Srwatson 490100979Srwatson ACPI_FUNCTION_TRACE (RsCreateAmlResources); 491100979Srwatson 492100979Srwatson 493100979Srwatson ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "LinkedListBuffer = %p\n", 494 LinkedListBuffer)); 495 496 /* 497 * Params already validated, so we don't re-validate here 498 * 499 * Pass the LinkedListBuffer into a module that calculates 500 * the buffer size needed for the byte stream. 501 */ 502 Status = AcpiRsGetAmlLength (LinkedListBuffer, 503 &AmlSizeNeeded); 504 505 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n", 506 (UINT32) AmlSizeNeeded, AcpiFormatException (Status))); 507 if (ACPI_FAILURE (Status)) 508 { 509 return_ACPI_STATUS (Status); 510 } 511 512 /* Validate/Allocate/Clear caller buffer */ 513 514 Status = AcpiUtInitializeBuffer (OutputBuffer, AmlSizeNeeded); 515 if (ACPI_FAILURE (Status)) 516 { 517 return_ACPI_STATUS (Status); 518 } 519 520 /* Do the conversion */ 521 522 Status = AcpiRsConvertResourcesToAml (LinkedListBuffer, AmlSizeNeeded, 523 OutputBuffer->Pointer); 524 if (ACPI_FAILURE (Status)) 525 { 526 return_ACPI_STATUS (Status); 527 } 528 529 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", 530 OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); 531 return_ACPI_STATUS (AE_OK); 532} 533 534