rscreate.c revision 193251
1285612Sdelphij/******************************************************************************* 2132451Sroberto * 354359Sroberto * Module Name: rscreate - Create resource lists/tables 4285612Sdelphij * $Revision: 1.78 $ 5285612Sdelphij * 654359Sroberto ******************************************************************************/ 754359Sroberto 854359Sroberto/****************************************************************************** 954359Sroberto * 1054359Sroberto * 1. Copyright Notice 1154359Sroberto * 1254359Sroberto * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp. 1354359Sroberto * All rights reserved. 1454359Sroberto * 15106163Sroberto * 2. License 16106163Sroberto * 17182007Sroberto * 2.1. This is your license from Intel Corp. under its intellectual property 18182007Sroberto * rights. You may have additional license terms from the party that provided 19182007Sroberto * you this software, covering your right to use that party's intellectual 20182007Sroberto * property rights. 21182007Sroberto * 22285612Sdelphij * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2354359Sroberto * copy of the source code appearing in this file ("Covered Code") an 24285612Sdelphij * irrevocable, perpetual, worldwide license under Intel's copyrights in the 25285612Sdelphij * base code distributed originally by Intel ("Original Intel Code") to copy, 26285612Sdelphij * make derivatives, distribute, use and display any portion of the Covered 27285612Sdelphij * Code in any form, with the right to sublicense such rights; and 28285612Sdelphij * 29285612Sdelphij * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 30285612Sdelphij * license (with the right to sublicense), under only those claims of Intel 31285612Sdelphij * patents that are infringed by the Original Intel Code, to make, use, sell, 32285612Sdelphij * offer to sell, and import the Covered Code and derivative works thereof 33285612Sdelphij * solely to the minimum extent necessary to exercise the above copyright 34285612Sdelphij * license, and in no event shall the patent license extend to any additions 35285612Sdelphij * to or modifications of the Original Intel Code. No other license or right 36285612Sdelphij * is granted directly or by implication, estoppel or otherwise; 37285612Sdelphij * 38285612Sdelphij * The above copyright and patent license is granted only if the following 39285612Sdelphij * conditions are met: 40285612Sdelphij * 41285612Sdelphij * 3. Conditions 42285612Sdelphij * 43285612Sdelphij * 3.1. Redistribution of Source with Rights to Further Distribute Source. 44285612Sdelphij * Redistribution of source code of any substantial portion of the Covered 45285612Sdelphij * Code or modification with rights to further distribute source must include 46285612Sdelphij * the above Copyright Notice, the above License, this list of Conditions, 47285612Sdelphij * and the following Disclaimer and Export Compliance provision. In addition, 48285612Sdelphij * Licensee must cause all Covered Code to which Licensee contributes to 49285612Sdelphij * contain a file documenting the changes Licensee made to create that Covered 50285612Sdelphij * Code and the date of any change. Licensee must include in that file the 51285612Sdelphij * documentation of any changes made by any predecessor Licensee. Licensee 52285612Sdelphij * must include a prominent statement that the modification is derived, 53285612Sdelphij * directly or indirectly, from Original Intel Code. 54285612Sdelphij * 55285612Sdelphij * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 56285612Sdelphij * Redistribution of source code of any substantial portion of the Covered 57285612Sdelphij * Code or modification without rights to further distribute source must 58285612Sdelphij * include the following Disclaimer and Export Compliance provision in the 59285612Sdelphij * documentation and/or other materials provided with distribution. In 60285612Sdelphij * addition, Licensee may not authorize further sublicense of source of any 61285612Sdelphij * portion of the Covered Code, and must include terms to the effect that the 62285612Sdelphij * license from Licensee to its licensee is limited to the intellectual 63285612Sdelphij * property embodied in the software Licensee provides to its licensee, and 64285612Sdelphij * not to intellectual property embodied in modifications its licensee may 65285612Sdelphij * make. 66285612Sdelphij * 67285612Sdelphij * 3.3. Redistribution of Executable. Redistribution in executable form of any 68285612Sdelphij * substantial portion of the Covered Code or modification must reproduce the 69285612Sdelphij * above Copyright Notice, and the following Disclaimer and Export Compliance 70285612Sdelphij * provision in the documentation and/or other materials provided with the 71285612Sdelphij * distribution. 72285612Sdelphij * 73285612Sdelphij * 3.4. Intel retains all right, title, and interest in and to the Original 74285612Sdelphij * Intel Code. 75285612Sdelphij * 76285612Sdelphij * 3.5. Neither the name Intel nor any other trademark owned or controlled by 77285612Sdelphij * Intel shall be used in advertising or otherwise to promote the sale, use or 78285612Sdelphij * other dealings in products derived from or relating to the Covered Code 7954359Sroberto * without prior written authorization from Intel. 80200576Sroberto * 8154359Sroberto * 4. Disclaimer and Export Compliance 82200576Sroberto * 83132451Sroberto * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 84132451Sroberto * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 85132451Sroberto * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 86132451Sroberto * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8782498Sroberto * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 88132451Sroberto * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 8954359Sroberto * PARTICULAR PURPOSE. 9054359Sroberto * 9154359Sroberto * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 9254359Sroberto * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 9354359Sroberto * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9454359Sroberto * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 9554359Sroberto * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9654359Sroberto * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 97285612Sdelphij * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 98182007Sroberto * LIMITED REMEDY. 99182007Sroberto * 100285612Sdelphij * 4.3. Licensee shall not export, either directly or indirectly, any of this 101285612Sdelphij * software or system incorporating such software without first obtaining any 102285612Sdelphij * required license or other approval from the U. S. Department of Commerce or 103285612Sdelphij * any other agency or department of the United States Government. In the 104285612Sdelphij * event Licensee exports any such software from the United States or 105285612Sdelphij * re-exports any such software from a foreign destination, Licensee shall 106285612Sdelphij * ensure that the distribution and export/re-export of the software is in 107285612Sdelphij * compliance with all laws, regulations, orders, or other restrictions of the 108285612Sdelphij * U.S. Export Administration Regulations. Licensee agrees that neither it nor 109285612Sdelphij * any of its subsidiaries will export/re-export any technical data, process, 110330567Sgordon * software, or service, directly or indirectly, to any country for which the 111285612Sdelphij * United States government or any agency thereof requires an export license, 112285612Sdelphij * other governmental approval, or letter of assurance, without first obtaining 113285612Sdelphij * such license, approval or letter. 114285612Sdelphij * 115285612Sdelphij *****************************************************************************/ 116285612Sdelphij 117285612Sdelphij 118285612Sdelphij#define __RSCREATE_C__ 119316722Sdelphij 120285612Sdelphij#include "acpi.h" 121285612Sdelphij#include "acresrc.h" 122285612Sdelphij#include "amlcode.h" 123285612Sdelphij#include "acnamesp.h" 124285612Sdelphij 125285612Sdelphij#define _COMPONENT ACPI_RESOURCES 126285612Sdelphij ACPI_MODULE_NAME ("rscreate") 127285612Sdelphij 128289997Sglebius 129285612Sdelphij/******************************************************************************* 130285612Sdelphij * 131285612Sdelphij * FUNCTION: AcpiRsCreateResourceList 132285612Sdelphij * 133285612Sdelphij * PARAMETERS: AmlBuffer - Pointer to the resource byte stream 134285612Sdelphij * OutputBuffer - Pointer to the user's buffer 135285612Sdelphij * 136285612Sdelphij * RETURN: Status: AE_OK if okay, else a valid ACPI_STATUS code 137285612Sdelphij * If OutputBuffer is not large enough, OutputBufferLength 138285612Sdelphij * indicates how large OutputBuffer should be, else it 139285612Sdelphij * indicates how may UINT8 elements of OutputBuffer are valid. 140182007Sroberto * 141182007Sroberto * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method 142285612Sdelphij * execution and parses the stream to create a linked list 143285612Sdelphij * of device resources. 144182007Sroberto * 145182007Sroberto ******************************************************************************/ 146182007Sroberto 147200576SrobertoACPI_STATUS 148285612SdelphijAcpiRsCreateResourceList ( 149285612Sdelphij ACPI_OPERAND_OBJECT *AmlBuffer, 150285612Sdelphij ACPI_BUFFER *OutputBuffer) 151285612Sdelphij{ 152285612Sdelphij 153285612Sdelphij ACPI_STATUS Status; 154182007Sroberto UINT8 *AmlStart; 155182007Sroberto ACPI_SIZE ListSizeNeeded = 0; 156182007Sroberto UINT32 AmlBufferLength; 157285612Sdelphij void *Resource; 158285612Sdelphij 159285612Sdelphij 160285612Sdelphij ACPI_FUNCTION_TRACE (RsCreateResourceList); 161285612Sdelphij 162285612Sdelphij 163285612Sdelphij ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlBuffer = %p\n", 164182007Sroberto AmlBuffer)); 165285612Sdelphij 166182007Sroberto /* Params already validated, so we don't re-validate here */ 167285612Sdelphij 168285612Sdelphij AmlBufferLength = AmlBuffer->Buffer.Length; 169285612Sdelphij AmlStart = AmlBuffer->Buffer.Pointer; 170285612Sdelphij 171285612Sdelphij /* 172285612Sdelphij * Pass the AmlBuffer into a module that can calculate 173285612Sdelphij * the buffer size needed for the linked list 174285612Sdelphij */ 175285612Sdelphij Status = AcpiRsGetListLength (AmlStart, AmlBufferLength, 176285612Sdelphij &ListSizeNeeded); 177285612Sdelphij 178285612Sdelphij ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X ListSizeNeeded=%X\n", 179200576Sroberto Status, (UINT32) ListSizeNeeded)); 180285612Sdelphij if (ACPI_FAILURE (Status)) 181182007Sroberto { 182200576Sroberto return_ACPI_STATUS (Status); 183182007Sroberto } 184182007Sroberto 185285612Sdelphij /* Validate/Allocate/Clear caller buffer */ 186285612Sdelphij 187285612Sdelphij Status = AcpiUtInitializeBuffer (OutputBuffer, ListSizeNeeded); 188285612Sdelphij if (ACPI_FAILURE (Status)) 189285612Sdelphij { 190285612Sdelphij return_ACPI_STATUS (Status); 191285612Sdelphij } 192285612Sdelphij 193182007Sroberto /* Do the conversion */ 194285612Sdelphij 195285612Sdelphij Resource = OutputBuffer->Pointer; 196285612Sdelphij Status = AcpiUtWalkAmlResources (AmlStart, AmlBufferLength, 197285612Sdelphij AcpiRsConvertAmlToResources, &Resource); 198285612Sdelphij if (ACPI_FAILURE (Status)) 199285612Sdelphij { 200285612Sdelphij return_ACPI_STATUS (Status); 201182007Sroberto } 202182007Sroberto 203285612Sdelphij ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", 204285612Sdelphij OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); 205285612Sdelphij return_ACPI_STATUS (AE_OK); 206285612Sdelphij} 207285612Sdelphij 208200576Sroberto 209200576Sroberto/******************************************************************************* 210200576Sroberto * 211200576Sroberto * FUNCTION: AcpiRsCreatePciRoutingTable 212200576Sroberto * 213200576Sroberto * PARAMETERS: PackageObject - Pointer to an ACPI_OPERAND_OBJECT 214200576Sroberto * package 215200576Sroberto * OutputBuffer - Pointer to the user's buffer 216200576Sroberto * 217200576Sroberto * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. 218200576Sroberto * If the OutputBuffer is too small, the error will be 219200576Sroberto * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point 220200576Sroberto * to the size buffer needed. 221200576Sroberto * 222200576Sroberto * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a 223200576Sroberto * linked list of PCI interrupt descriptions 224200576Sroberto * 225200576Sroberto * NOTE: It is the caller's responsibility to ensure that the start of the 226200576Sroberto * output buffer is aligned properly (if necessary). 227200576Sroberto * 228200576Sroberto ******************************************************************************/ 229285612Sdelphij 230285612SdelphijACPI_STATUS 231285612SdelphijAcpiRsCreatePciRoutingTable ( 232285612Sdelphij ACPI_OPERAND_OBJECT *PackageObject, 233285612Sdelphij ACPI_BUFFER *OutputBuffer) 234285612Sdelphij{ 235182007Sroberto UINT8 *Buffer; 236285612Sdelphij ACPI_OPERAND_OBJECT **TopObjectList; 237182007Sroberto ACPI_OPERAND_OBJECT **SubObjectList; 238285612Sdelphij ACPI_OPERAND_OBJECT *ObjDesc; 239285612Sdelphij ACPI_SIZE BufferSizeNeeded = 0; 240182007Sroberto UINT32 NumberOfElements; 241285612Sdelphij UINT32 Index; 242285612Sdelphij ACPI_PCI_ROUTING_TABLE *UserPrt; 243285612Sdelphij ACPI_NAMESPACE_NODE *Node; 244285612Sdelphij ACPI_STATUS Status; 245285612Sdelphij ACPI_BUFFER PathBuffer; 246285612Sdelphij 247285612Sdelphij 248285612Sdelphij ACPI_FUNCTION_TRACE (RsCreatePciRoutingTable); 249285612Sdelphij 250285612Sdelphij 251285612Sdelphij /* Params already validated, so we don't re-validate here */ 252285612Sdelphij 253285612Sdelphij /* Get the required buffer length */ 254285612Sdelphij 255285612Sdelphij Status = AcpiRsGetPciRoutingTableLength (PackageObject, 256285612Sdelphij &BufferSizeNeeded); 257285612Sdelphij if (ACPI_FAILURE (Status)) 258182007Sroberto { 259182007Sroberto return_ACPI_STATUS (Status); 260285612Sdelphij } 261285612Sdelphij 262285612Sdelphij ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "BufferSizeNeeded = %X\n", 263285612Sdelphij (UINT32) BufferSizeNeeded)); 264285612Sdelphij 265182007Sroberto /* Validate/Allocate/Clear caller buffer */ 266132451Sroberto 267285612Sdelphij Status = AcpiUtInitializeBuffer (OutputBuffer, BufferSizeNeeded); 26854359Sroberto if (ACPI_FAILURE (Status)) 269285612Sdelphij { 270182007Sroberto return_ACPI_STATUS (Status); 271132451Sroberto } 272132451Sroberto 273132451Sroberto /* 27454359Sroberto * Loop through the ACPI_INTERNAL_OBJECTS - Each object 275289997Sglebius * should be a package that in turn contains an 276285612Sdelphij * ACPI_INTEGER Address, a UINT8 Pin, a Name and a UINT8 SourceIndex. 277285612Sdelphij */ 278285612Sdelphij TopObjectList = PackageObject->Package.Elements; 279285612Sdelphij NumberOfElements = PackageObject->Package.Count; 280285612Sdelphij Buffer = OutputBuffer->Pointer; 28154359Sroberto UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer); 282132451Sroberto 28354359Sroberto for (Index = 0; Index < NumberOfElements; Index++) 284289997Sglebius { 285285612Sdelphij /* 28654359Sroberto * Point UserPrt past this current structure 287285612Sdelphij * 28854359Sroberto * NOTE: On the first iteration, UserPrt->Length will 289132451Sroberto * be zero because we cleared the return buffer earlier 290285612Sdelphij */ 291285612Sdelphij Buffer += UserPrt->Length; 292132451Sroberto UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer); 29354359Sroberto 294132451Sroberto /* 29556746Sroberto * Fill in the Length field with the information we have at this point. 296285612Sdelphij * The minus four is to subtract the size of the UINT8 Source[4] member 297285612Sdelphij * because it is added below. 298285612Sdelphij */ 299132451Sroberto UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4); 300132451Sroberto 301132451Sroberto /* Each element of the top-level package must also be a package */ 302285612Sdelphij 303132451Sroberto if (ACPI_GET_OBJECT_TYPE (*TopObjectList) != ACPI_TYPE_PACKAGE) 304106163Sroberto { 305285612Sdelphij ACPI_ERROR ((AE_INFO, 306200576Sroberto "(PRT[%X]) Need sub-package, found %s", 307285612Sdelphij Index, AcpiUtGetObjectTypeName (*TopObjectList))); 308285612Sdelphij return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 309285612Sdelphij } 310285612Sdelphij 311285612Sdelphij /* Each sub-package must be of length 4 */ 312200576Sroberto 313285612Sdelphij if ((*TopObjectList)->Package.Count != 4) 314285612Sdelphij { 315285612Sdelphij ACPI_ERROR ((AE_INFO, 316200576Sroberto "(PRT[%X]) Need package of length 4, found length %d", 317132451Sroberto Index, (*TopObjectList)->Package.Count)); 318132451Sroberto return_ACPI_STATUS (AE_AML_PACKAGE_LIMIT); 319132451Sroberto } 32082498Sroberto 321285612Sdelphij /* 322285612Sdelphij * Dereference the sub-package. 323285612Sdelphij * The SubObjectList will now point to an array of the four IRQ 324285612Sdelphij * elements: [Address, Pin, Source, SourceIndex] 325285612Sdelphij */ 326285612Sdelphij SubObjectList = (*TopObjectList)->Package.Elements; 32754359Sroberto 328285612Sdelphij /* 1) First subobject: Dereference the PRT.Address */ 329285612Sdelphij 330285612Sdelphij ObjDesc = SubObjectList[0]; 331132451Sroberto if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) 332182007Sroberto { 333182007Sroberto UserPrt->Address = ObjDesc->Integer.Value; 334182007Sroberto } 33554359Sroberto else 336132451Sroberto { 337182007Sroberto ACPI_ERROR ((AE_INFO, 338285612Sdelphij "(PRT[%X].Address) Need Integer, found %s", 339285612Sdelphij Index, AcpiUtGetObjectTypeName (ObjDesc))); 34054359Sroberto return_ACPI_STATUS (AE_BAD_DATA); 341200576Sroberto } 342289997Sglebius 343132451Sroberto /* 2) Second subobject: Dereference the PRT.Pin */ 344316722Sdelphij 345132451Sroberto ObjDesc = SubObjectList[1]; 34654359Sroberto if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) 347182007Sroberto { 34854359Sroberto UserPrt->Pin = (UINT32) ObjDesc->Integer.Value; 349132451Sroberto } 35054359Sroberto else 35154359Sroberto { 352132451Sroberto ACPI_ERROR ((AE_INFO, 353285612Sdelphij "(PRT[%X].Pin) Need Integer, found %s", 35454359Sroberto Index, AcpiUtGetObjectTypeName (ObjDesc))); 35554359Sroberto return_ACPI_STATUS (AE_BAD_DATA); 35654359Sroberto } 35782498Sroberto 358285612Sdelphij /* 359285612Sdelphij * 3) Third subobject: Dereference the PRT.SourceName 360200576Sroberto * The name may be unresolved (slack mode), so allow a null object 361285612Sdelphij */ 362285612Sdelphij ObjDesc = SubObjectList[2]; 363285612Sdelphij if (ObjDesc) 364285612Sdelphij { 365285612Sdelphij switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) 366285612Sdelphij { 367285612Sdelphij case ACPI_TYPE_LOCAL_REFERENCE: 368285612Sdelphij 369285612Sdelphij if (ObjDesc->Reference.Opcode != AML_INT_NAMEPATH_OP) 370285612Sdelphij { 371285612Sdelphij ACPI_ERROR ((AE_INFO, 372285612Sdelphij "(PRT[%X].Source) Need name, found reference op %X", 373285612Sdelphij Index, ObjDesc->Reference.Opcode)); 374285612Sdelphij return_ACPI_STATUS (AE_BAD_DATA); 375285612Sdelphij } 376285612Sdelphij 377285612Sdelphij Node = ObjDesc->Reference.Node; 378285612Sdelphij 379285612Sdelphij /* Use *remaining* length of the buffer as max for pathname */ 380285612Sdelphij 381285612Sdelphij PathBuffer.Length = OutputBuffer->Length - 382285612Sdelphij (UINT32) ((UINT8 *) UserPrt->Source - 383285612Sdelphij (UINT8 *) OutputBuffer->Pointer); 384285612Sdelphij PathBuffer.Pointer = UserPrt->Source; 385285612Sdelphij 386285612Sdelphij Status = AcpiNsHandleToPathname ((ACPI_HANDLE) Node, &PathBuffer); 387285612Sdelphij 388285612Sdelphij /* +1 to include null terminator */ 389285612Sdelphij 390285612Sdelphij UserPrt->Length += (UINT32) ACPI_STRLEN (UserPrt->Source) + 1; 391285612Sdelphij break; 392285612Sdelphij 393285612Sdelphij 394285612Sdelphij case ACPI_TYPE_STRING: 395285612Sdelphij 396285612Sdelphij ACPI_STRCPY (UserPrt->Source, ObjDesc->String.Pointer); 397285612Sdelphij 398285612Sdelphij /* 399285612Sdelphij * Add to the Length field the length of the string 400285612Sdelphij * (add 1 for terminator) 401285612Sdelphij */ 402285612Sdelphij UserPrt->Length += ObjDesc->String.Length + 1; 403285612Sdelphij break; 404285612Sdelphij 405285612Sdelphij 406285612Sdelphij case ACPI_TYPE_INTEGER: 407285612Sdelphij /* 408316722Sdelphij * If this is a number, then the Source Name is NULL, since the 409316722Sdelphij * entire buffer was zeroed out, we can leave this alone. 410316722Sdelphij * 411285612Sdelphij * Add to the Length field the length of the UINT32 NULL 412285612Sdelphij */ 413285612Sdelphij UserPrt->Length += sizeof (UINT32); 414285612Sdelphij break; 415285612Sdelphij 416285612Sdelphij 417285612Sdelphij default: 418285612Sdelphij 419285612Sdelphij ACPI_ERROR ((AE_INFO, 420285612Sdelphij "(PRT[%X].Source) Need Ref/String/Integer, found %s", 421285612Sdelphij Index, AcpiUtGetObjectTypeName (ObjDesc))); 422285612Sdelphij return_ACPI_STATUS (AE_BAD_DATA); 423106163Sroberto } 424285612Sdelphij } 425285612Sdelphij 42654359Sroberto /* Now align the current length */ 427132451Sroberto 428132451Sroberto UserPrt->Length = (UINT32) ACPI_ROUND_UP_TO_64BIT (UserPrt->Length); 429132451Sroberto 430132451Sroberto /* 4) Fourth subobject: Dereference the PRT.SourceIndex */ 431200576Sroberto 432132451Sroberto ObjDesc = SubObjectList[3]; 433285612Sdelphij if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) 43482498Sroberto { 435285612Sdelphij UserPrt->SourceIndex = (UINT32) ObjDesc->Integer.Value; 436132451Sroberto } 437285612Sdelphij else 438285612Sdelphij { 439285612Sdelphij ACPI_ERROR ((AE_INFO, 440285612Sdelphij "(PRT[%X].SourceIndex) Need Integer, found %s", 44154359Sroberto Index, AcpiUtGetObjectTypeName (ObjDesc))); 442285612Sdelphij return_ACPI_STATUS (AE_BAD_DATA); 44354359Sroberto } 444285612Sdelphij 445132451Sroberto /* Point to the next ACPI_OPERAND_OBJECT in the top level package */ 446132451Sroberto 447285612Sdelphij TopObjectList++; 448285612Sdelphij } 449285612Sdelphij 450285612Sdelphij ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", 451285612Sdelphij OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); 452285612Sdelphij return_ACPI_STATUS (AE_OK); 453285612Sdelphij} 454285612Sdelphij 455285612Sdelphij 456285612Sdelphij/******************************************************************************* 457132451Sroberto * 45854359Sroberto * FUNCTION: AcpiRsCreateAmlResources 459285612Sdelphij * 460285612Sdelphij * PARAMETERS: LinkedListBuffer - Pointer to the resource linked list 461285612Sdelphij * OutputBuffer - Pointer to the user's buffer 462285612Sdelphij * 463285612Sdelphij * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. 464285612Sdelphij * If the OutputBuffer is too small, the error will be 465285612Sdelphij * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point 466285612Sdelphij * to the size buffer needed. 467285612Sdelphij * 468285612Sdelphij * DESCRIPTION: Takes the linked list of device resources and 469285612Sdelphij * creates a bytestream to be used as input for the 470285612Sdelphij * _SRS control method. 471285612Sdelphij * 472285612Sdelphij ******************************************************************************/ 473285612Sdelphij 47454359SrobertoACPI_STATUS 475285612SdelphijAcpiRsCreateAmlResources ( 476285612Sdelphij ACPI_RESOURCE *LinkedListBuffer, 477285612Sdelphij ACPI_BUFFER *OutputBuffer) 478200576Sroberto{ 479200576Sroberto ACPI_STATUS Status; 480200576Sroberto ACPI_SIZE AmlSizeNeeded = 0; 481200576Sroberto 482285612Sdelphij 483132451Sroberto ACPI_FUNCTION_TRACE (RsCreateAmlResources); 484285612Sdelphij 485106163Sroberto 486132451Sroberto ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "LinkedListBuffer = %p\n", 487106163Sroberto LinkedListBuffer)); 488182007Sroberto 489182007Sroberto /* 490285612Sdelphij * Params already validated, so we don't re-validate here 491132451Sroberto * 492132451Sroberto * Pass the LinkedListBuffer into a module that calculates 493132451Sroberto * the buffer size needed for the byte stream. 494132451Sroberto */ 495132451Sroberto Status = AcpiRsGetAmlLength (LinkedListBuffer, 496200576Sroberto &AmlSizeNeeded); 497132451Sroberto 498200576Sroberto ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n", 499200576Sroberto (UINT32) AmlSizeNeeded, AcpiFormatException (Status))); 500200576Sroberto if (ACPI_FAILURE (Status)) 501132451Sroberto { 502132451Sroberto return_ACPI_STATUS (Status); 503132451Sroberto } 504132451Sroberto 505132451Sroberto /* Validate/Allocate/Clear caller buffer */ 506132451Sroberto 507200576Sroberto Status = AcpiUtInitializeBuffer (OutputBuffer, AmlSizeNeeded); 508132451Sroberto if (ACPI_FAILURE (Status)) 509132451Sroberto { 51056746Sroberto return_ACPI_STATUS (Status); 511132451Sroberto } 512132451Sroberto 513200576Sroberto /* Do the conversion */ 514132451Sroberto 515132451Sroberto Status = AcpiRsConvertResourcesToAml (LinkedListBuffer, AmlSizeNeeded, 516182007Sroberto OutputBuffer->Pointer); 517132451Sroberto if (ACPI_FAILURE (Status)) 518200576Sroberto { 519132451Sroberto return_ACPI_STATUS (Status); 520132451Sroberto } 521200576Sroberto 522132451Sroberto ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", 523132451Sroberto OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); 524200576Sroberto return_ACPI_STATUS (AE_OK); 525132451Sroberto} 526132451Sroberto 527132451Sroberto