rscreate.c revision 298714
1145519Sdarrenr/******************************************************************************* 2145510Sdarrenr * 3145510Sdarrenr * Module Name: rscreate - Create resource lists/tables 4255332Scy * 5145510Sdarrenr ******************************************************************************/ 6145510Sdarrenr 7145510Sdarrenr/* 8145510Sdarrenr * Copyright (C) 2000 - 2016, Intel Corp. 9145510Sdarrenr * All rights reserved. 10145510Sdarrenr * 11145510Sdarrenr * Redistribution and use in source and binary forms, with or without 12145510Sdarrenr * modification, are permitted provided that the following conditions 13145510Sdarrenr * are met: 14145510Sdarrenr * 1. Redistributions of source code must retain the above copyright 15145510Sdarrenr * notice, this list of conditions, and the following disclaimer, 16145510Sdarrenr * without modification. 17145510Sdarrenr * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18145510Sdarrenr * substantially similar to the "NO WARRANTY" disclaimer below 19255332Scy * ("Disclaimer") and any redistribution must be conditioned upon 20145510Sdarrenr * including a substantially similar Disclaimer requirement for further 21145510Sdarrenr * binary redistribution. 22145510Sdarrenr * 3. Neither the names of the above-listed copyright holders nor the names 23145510Sdarrenr * of any contributors may be used to endorse or promote products derived 24145510Sdarrenr * from this software without specific prior written permission. 25255332Scy * 26145510Sdarrenr * Alternatively, this software may be distributed under the terms of the 27145510Sdarrenr * GNU General Public License ("GPL") version 2 as published by the Free 28145510Sdarrenr * Software Foundation. 29145510Sdarrenr * 30145510Sdarrenr * NO WARRANTY 31145510Sdarrenr * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32145510Sdarrenr * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33145510Sdarrenr * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34145510Sdarrenr * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35145510Sdarrenr * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36145510Sdarrenr * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37145510Sdarrenr * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38145510Sdarrenr * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39145510Sdarrenr * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40145510Sdarrenr * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41145510Sdarrenr * POSSIBILITY OF SUCH DAMAGES. 42145510Sdarrenr */ 43145510Sdarrenr 44255332Scy#include <contrib/dev/acpica/include/acpi.h> 45145510Sdarrenr#include <contrib/dev/acpica/include/accommon.h> 46255332Scy#include <contrib/dev/acpica/include/acresrc.h> 47255332Scy#include <contrib/dev/acpica/include/acnamesp.h> 48255332Scy 49255332Scy#define _COMPONENT ACPI_RESOURCES 50255332Scy ACPI_MODULE_NAME ("rscreate") 51255332Scy 52145510Sdarrenr 53145510Sdarrenr/******************************************************************************* 54145510Sdarrenr * 55145510Sdarrenr * FUNCTION: AcpiBufferToResource 56145510Sdarrenr * 57145510Sdarrenr * PARAMETERS: AmlBuffer - Pointer to the resource byte stream 58255332Scy * AmlBufferLength - Length of the AmlBuffer 59145510Sdarrenr * ResourcePtr - Where the converted resource is returned 60145510Sdarrenr * 61145510Sdarrenr * RETURN: Status 62145510Sdarrenr * 63145510Sdarrenr * DESCRIPTION: Convert a raw AML buffer to a resource list 64145510Sdarrenr * 65255332Scy ******************************************************************************/ 66255332Scy 67255332ScyACPI_STATUS 68145510SdarrenrAcpiBufferToResource ( 69145510Sdarrenr UINT8 *AmlBuffer, 70145510Sdarrenr UINT16 AmlBufferLength, 71145510Sdarrenr ACPI_RESOURCE **ResourcePtr) 72145510Sdarrenr{ 73145510Sdarrenr ACPI_STATUS Status; 74145510Sdarrenr ACPI_SIZE ListSizeNeeded; 75145510Sdarrenr void *Resource; 76145510Sdarrenr void *CurrentResourcePtr; 77145510Sdarrenr 78145510Sdarrenr 79255332Scy ACPI_FUNCTION_TRACE (AcpiBufferToResource); 80255332Scy 81145510Sdarrenr 82255332Scy /* 83145510Sdarrenr * Note: we allow AE_AML_NO_RESOURCE_END_TAG, since an end tag 84145510Sdarrenr * is not required here. 85145510Sdarrenr */ 86145510Sdarrenr 87255332Scy /* Get the required length for the converted resource */ 88255332Scy 89255332Scy Status = AcpiRsGetListLength ( 90145510Sdarrenr AmlBuffer, AmlBufferLength, &ListSizeNeeded); 91145510Sdarrenr if (Status == AE_AML_NO_RESOURCE_END_TAG) 92145510Sdarrenr { 93145510Sdarrenr Status = AE_OK; 94145510Sdarrenr } 95255332Scy if (ACPI_FAILURE (Status)) 96255332Scy { 97255332Scy return_ACPI_STATUS (Status); 98145510Sdarrenr } 99145510Sdarrenr 100145510Sdarrenr /* Allocate a buffer for the converted resource */ 101145510Sdarrenr 102145510Sdarrenr Resource = ACPI_ALLOCATE_ZEROED (ListSizeNeeded); 103145510Sdarrenr CurrentResourcePtr = Resource; 104145510Sdarrenr if (!Resource) 105145510Sdarrenr { 106145510Sdarrenr return_ACPI_STATUS (AE_NO_MEMORY); 107145510Sdarrenr } 108145510Sdarrenr 109145510Sdarrenr /* Perform the AML-to-Resource conversion */ 110145510Sdarrenr 111145510Sdarrenr Status = AcpiUtWalkAmlResources (NULL, AmlBuffer, AmlBufferLength, 112145510Sdarrenr AcpiRsConvertAmlToResources, &CurrentResourcePtr); 113145510Sdarrenr if (Status == AE_AML_NO_RESOURCE_END_TAG) 114145510Sdarrenr { 115145510Sdarrenr Status = AE_OK; 116145510Sdarrenr } 117145510Sdarrenr if (ACPI_FAILURE (Status)) 118255332Scy { 119145510Sdarrenr ACPI_FREE (Resource); 120145510Sdarrenr } 121255332Scy else 122145510Sdarrenr { 123145510Sdarrenr *ResourcePtr = Resource; 124145510Sdarrenr } 125145510Sdarrenr 126145510Sdarrenr return_ACPI_STATUS (Status); 127145510Sdarrenr} 128145510Sdarrenr 129255332ScyACPI_EXPORT_SYMBOL (AcpiBufferToResource) 130255332Scy 131255332Scy 132145510Sdarrenr/******************************************************************************* 133255332Scy * 134145510Sdarrenr * FUNCTION: AcpiRsCreateResourceList 135145510Sdarrenr * 136145510Sdarrenr * PARAMETERS: AmlBuffer - Pointer to the resource byte stream 137145510Sdarrenr * OutputBuffer - Pointer to the user's buffer 138145510Sdarrenr * 139145510Sdarrenr * RETURN: Status: AE_OK if okay, else a valid ACPI_STATUS code 140145510Sdarrenr * If OutputBuffer is not large enough, OutputBufferLength 141145510Sdarrenr * indicates how large OutputBuffer should be, else it 142145510Sdarrenr * indicates how may UINT8 elements of OutputBuffer are valid. 143145510Sdarrenr * 144145510Sdarrenr * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method 145145510Sdarrenr * execution and parses the stream to create a linked list 146145510Sdarrenr * of device resources. 147145510Sdarrenr * 148145510Sdarrenr ******************************************************************************/ 149145510Sdarrenr 150145510SdarrenrACPI_STATUS 151145510SdarrenrAcpiRsCreateResourceList ( 152145510Sdarrenr ACPI_OPERAND_OBJECT *AmlBuffer, 153145510Sdarrenr ACPI_BUFFER *OutputBuffer) 154145510Sdarrenr{ 155145510Sdarrenr 156145510Sdarrenr ACPI_STATUS Status; 157145510Sdarrenr UINT8 *AmlStart; 158145510Sdarrenr ACPI_SIZE ListSizeNeeded = 0; 159145510Sdarrenr UINT32 AmlBufferLength; 160145510Sdarrenr void *Resource; 161145510Sdarrenr 162145510Sdarrenr 163145510Sdarrenr ACPI_FUNCTION_TRACE (RsCreateResourceList); 164145510Sdarrenr 165145510Sdarrenr 166145510Sdarrenr ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlBuffer = %p\n", 167145510Sdarrenr AmlBuffer)); 168145510Sdarrenr 169145510Sdarrenr /* Params already validated, so we don't re-validate here */ 170145510Sdarrenr 171145510Sdarrenr AmlBufferLength = AmlBuffer->Buffer.Length; 172145510Sdarrenr AmlStart = AmlBuffer->Buffer.Pointer; 173145510Sdarrenr 174145510Sdarrenr /* 175145510Sdarrenr * Pass the AmlBuffer into a module that can calculate 176145510Sdarrenr * the buffer size needed for the linked list 177145510Sdarrenr */ 178255332Scy Status = AcpiRsGetListLength (AmlStart, AmlBufferLength, 179145510Sdarrenr &ListSizeNeeded); 180145510Sdarrenr 181145510Sdarrenr ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X ListSizeNeeded=%X\n", 182145510Sdarrenr Status, (UINT32) ListSizeNeeded)); 183145510Sdarrenr if (ACPI_FAILURE (Status)) 184255332Scy { 185255332Scy return_ACPI_STATUS (Status); 186145510Sdarrenr } 187145510Sdarrenr 188145510Sdarrenr /* Validate/Allocate/Clear caller buffer */ 189145510Sdarrenr 190145510Sdarrenr Status = AcpiUtInitializeBuffer (OutputBuffer, ListSizeNeeded); 191145510Sdarrenr if (ACPI_FAILURE (Status)) 192145510Sdarrenr { 193145510Sdarrenr return_ACPI_STATUS (Status); 194145510Sdarrenr } 195145510Sdarrenr 196145510Sdarrenr /* Do the conversion */ 197145510Sdarrenr 198145510Sdarrenr Resource = OutputBuffer->Pointer; 199145510Sdarrenr Status = AcpiUtWalkAmlResources (NULL, AmlStart, AmlBufferLength, 200145510Sdarrenr AcpiRsConvertAmlToResources, &Resource); 201255332Scy if (ACPI_FAILURE (Status)) 202145510Sdarrenr { 203145510Sdarrenr return_ACPI_STATUS (Status); 204145510Sdarrenr } 205145510Sdarrenr 206145510Sdarrenr ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", 207145510Sdarrenr OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); 208145510Sdarrenr return_ACPI_STATUS (AE_OK); 209145510Sdarrenr} 210145510Sdarrenr 211145510Sdarrenr 212145510Sdarrenr/******************************************************************************* 213145510Sdarrenr * 214145510Sdarrenr * FUNCTION: AcpiRsCreatePciRoutingTable 215161357Sguido * 216145510Sdarrenr * PARAMETERS: PackageObject - Pointer to a package containing one 217145510Sdarrenr * of more ACPI_OPERAND_OBJECTs 218145510Sdarrenr * OutputBuffer - Pointer to the user's buffer 219255332Scy * 220145510Sdarrenr * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. 221145510Sdarrenr * If the OutputBuffer is too small, the error will be 222145510Sdarrenr * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point 223145510Sdarrenr * to the size buffer needed. 224145510Sdarrenr * 225145510Sdarrenr * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a 226145510Sdarrenr * linked list of PCI interrupt descriptions 227255332Scy * 228145510Sdarrenr * NOTE: It is the caller's responsibility to ensure that the start of the 229255332Scy * output buffer is aligned properly (if necessary). 230145510Sdarrenr * 231255332Scy ******************************************************************************/ 232145510Sdarrenr 233145510SdarrenrACPI_STATUS 234255332ScyAcpiRsCreatePciRoutingTable ( 235255332Scy ACPI_OPERAND_OBJECT *PackageObject, 236255332Scy ACPI_BUFFER *OutputBuffer) 237145510Sdarrenr{ 238255332Scy UINT8 *Buffer; 239145510Sdarrenr ACPI_OPERAND_OBJECT **TopObjectList; 240145510Sdarrenr ACPI_OPERAND_OBJECT **SubObjectList; 241145510Sdarrenr ACPI_OPERAND_OBJECT *ObjDesc; 242145510Sdarrenr ACPI_SIZE BufferSizeNeeded = 0; 243255332Scy UINT32 NumberOfElements; 244255332Scy UINT32 Index; 245145510Sdarrenr ACPI_PCI_ROUTING_TABLE *UserPrt; 246145510Sdarrenr ACPI_NAMESPACE_NODE *Node; 247145510Sdarrenr ACPI_STATUS Status; 248145510Sdarrenr ACPI_BUFFER PathBuffer; 249145510Sdarrenr 250145510Sdarrenr 251145510Sdarrenr ACPI_FUNCTION_TRACE (RsCreatePciRoutingTable); 252145510Sdarrenr 253145510Sdarrenr 254145510Sdarrenr /* Params already validated, so we don't re-validate here */ 255145510Sdarrenr 256145510Sdarrenr /* Get the required buffer length */ 257145510Sdarrenr 258145510Sdarrenr Status = AcpiRsGetPciRoutingTableLength ( 259145510Sdarrenr PackageObject,&BufferSizeNeeded); 260255332Scy if (ACPI_FAILURE (Status)) 261255332Scy { 262255332Scy return_ACPI_STATUS (Status); 263255332Scy } 264145510Sdarrenr 265145510Sdarrenr ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "BufferSizeNeeded = %X\n", 266145510Sdarrenr (UINT32) BufferSizeNeeded)); 267145510Sdarrenr 268255332Scy /* Validate/Allocate/Clear caller buffer */ 269255332Scy 270255332Scy Status = AcpiUtInitializeBuffer (OutputBuffer, BufferSizeNeeded); 271145510Sdarrenr if (ACPI_FAILURE (Status)) 272145510Sdarrenr { 273145510Sdarrenr return_ACPI_STATUS (Status); 274145510Sdarrenr } 275255332Scy 276145510Sdarrenr /* 277145510Sdarrenr * Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a 278145510Sdarrenr * package that in turn contains an UINT64 Address, a UINT8 Pin, 279145510Sdarrenr * a Name, and a UINT8 SourceIndex. 280145510Sdarrenr */ 281145510Sdarrenr TopObjectList = PackageObject->Package.Elements; 282145510Sdarrenr NumberOfElements = PackageObject->Package.Count; 283145510Sdarrenr Buffer = OutputBuffer->Pointer; 284145510Sdarrenr UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer); 285145510Sdarrenr 286145510Sdarrenr for (Index = 0; Index < NumberOfElements; Index++) 287145510Sdarrenr { 288145510Sdarrenr /* 289145510Sdarrenr * Point UserPrt past this current structure 290145510Sdarrenr * 291145510Sdarrenr * NOTE: On the first iteration, UserPrt->Length will 292145510Sdarrenr * be zero because we cleared the return buffer earlier 293145510Sdarrenr */ 294145510Sdarrenr Buffer += UserPrt->Length; 295145510Sdarrenr UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer); 296145510Sdarrenr 297145510Sdarrenr /* 298145510Sdarrenr * Fill in the Length field with the information we have at this 299283748Semaste * point. The minus four is to subtract the size of the UINT8 300145510Sdarrenr * Source[4] member because it is added below. 301145510Sdarrenr */ 302145510Sdarrenr UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4); 303145510Sdarrenr 304145510Sdarrenr /* Each subpackage must be of length 4 */ 305145510Sdarrenr 306145510Sdarrenr if ((*TopObjectList)->Package.Count != 4) 307145510Sdarrenr { 308145510Sdarrenr ACPI_ERROR ((AE_INFO, 309145510Sdarrenr "(PRT[%u]) Need package of length 4, found length %u", 310145510Sdarrenr Index, (*TopObjectList)->Package.Count)); 311145510Sdarrenr return_ACPI_STATUS (AE_AML_PACKAGE_LIMIT); 312145510Sdarrenr } 313145510Sdarrenr 314255332Scy /* 315145510Sdarrenr * Dereference the subpackage. 316145510Sdarrenr * The SubObjectList will now point to an array of the four IRQ 317145510Sdarrenr * elements: [Address, Pin, Source, SourceIndex] 318145510Sdarrenr */ 319145510Sdarrenr SubObjectList = (*TopObjectList)->Package.Elements; 320145510Sdarrenr 321145510Sdarrenr /* 1) First subobject: Dereference the PRT.Address */ 322145510Sdarrenr 323145510Sdarrenr ObjDesc = SubObjectList[0]; 324145510Sdarrenr if (!ObjDesc || ObjDesc->Common.Type != ACPI_TYPE_INTEGER) 325145510Sdarrenr { 326145510Sdarrenr ACPI_ERROR ((AE_INFO, 327145510Sdarrenr "(PRT[%u].Address) Need Integer, found %s", 328145510Sdarrenr Index, AcpiUtGetObjectTypeName (ObjDesc))); 329255332Scy return_ACPI_STATUS (AE_BAD_DATA); 330145510Sdarrenr } 331145510Sdarrenr 332145510Sdarrenr UserPrt->Address = ObjDesc->Integer.Value; 333255332Scy 334145510Sdarrenr /* 2) Second subobject: Dereference the PRT.Pin */ 335145510Sdarrenr 336145510Sdarrenr ObjDesc = SubObjectList[1]; 337145510Sdarrenr if (!ObjDesc || ObjDesc->Common.Type != ACPI_TYPE_INTEGER) 338145510Sdarrenr { 339145510Sdarrenr ACPI_ERROR ((AE_INFO, "(PRT[%u].Pin) Need Integer, found %s", 340145510Sdarrenr Index, AcpiUtGetObjectTypeName (ObjDesc))); 341145510Sdarrenr return_ACPI_STATUS (AE_BAD_DATA); 342145510Sdarrenr } 343145510Sdarrenr 344145510Sdarrenr UserPrt->Pin = (UINT32) ObjDesc->Integer.Value; 345145510Sdarrenr 346255332Scy /* 347145510Sdarrenr * 3) Third subobject: Dereference the PRT.SourceName 348145510Sdarrenr * The name may be unresolved (slack mode), so allow a null object 349145510Sdarrenr */ 350255332Scy ObjDesc = SubObjectList[2]; 351145510Sdarrenr if (ObjDesc) 352145510Sdarrenr { 353145510Sdarrenr switch (ObjDesc->Common.Type) 354145510Sdarrenr { 355145510Sdarrenr case ACPI_TYPE_LOCAL_REFERENCE: 356145510Sdarrenr 357145510Sdarrenr if (ObjDesc->Reference.Class != ACPI_REFCLASS_NAME) 358255332Scy { 359255332Scy ACPI_ERROR ((AE_INFO, 360255332Scy "(PRT[%u].Source) Need name, found Reference Class 0x%X", 361145510Sdarrenr Index, ObjDesc->Reference.Class)); 362145510Sdarrenr return_ACPI_STATUS (AE_BAD_DATA); 363145510Sdarrenr } 364145510Sdarrenr 365145510Sdarrenr Node = ObjDesc->Reference.Node; 366170268Sdarrenr 367145510Sdarrenr /* Use *remaining* length of the buffer as max for pathname */ 368145510Sdarrenr 369170268Sdarrenr PathBuffer.Length = OutputBuffer->Length - 370170268Sdarrenr (UINT32) ((UINT8 *) UserPrt->Source - 371145510Sdarrenr (UINT8 *) OutputBuffer->Pointer); 372170268Sdarrenr PathBuffer.Pointer = UserPrt->Source; 373145510Sdarrenr 374145510Sdarrenr Status = AcpiNsHandleToPathname ( 375145510Sdarrenr (ACPI_HANDLE) Node, &PathBuffer, FALSE); 376145510Sdarrenr 377145510Sdarrenr /* +1 to include null terminator */ 378145510Sdarrenr 379145510Sdarrenr UserPrt->Length += (UINT32) strlen (UserPrt->Source) + 1; 380145510Sdarrenr break; 381255332Scy 382255332Scy case ACPI_TYPE_STRING: 383255332Scy 384255332Scy strcpy (UserPrt->Source, ObjDesc->String.Pointer); 385255332Scy 386255332Scy /* 387255332Scy * Add to the Length field the length of the string 388255332Scy * (add 1 for terminator) 389255332Scy */ 390255332Scy UserPrt->Length += ObjDesc->String.Length + 1; 391255332Scy break; 392255332Scy 393255332Scy case ACPI_TYPE_INTEGER: 394255332Scy /* 395145510Sdarrenr * If this is a number, then the Source Name is NULL, since 396145510Sdarrenr * the entire buffer was zeroed out, we can leave this alone. 397145510Sdarrenr * 398255332Scy * Add to the Length field the length of the UINT32 NULL 399145510Sdarrenr */ 400145510Sdarrenr UserPrt->Length += sizeof (UINT32); 401145510Sdarrenr break; 402145510Sdarrenr 403255332Scy default: 404145510Sdarrenr 405145510Sdarrenr ACPI_ERROR ((AE_INFO, 406255332Scy "(PRT[%u].Source) Need Ref/String/Integer, found %s", 407255332Scy Index, AcpiUtGetObjectTypeName (ObjDesc))); 408255332Scy return_ACPI_STATUS (AE_BAD_DATA); 409145510Sdarrenr } 410145510Sdarrenr } 411145510Sdarrenr 412145510Sdarrenr /* Now align the current length */ 413145510Sdarrenr 414145510Sdarrenr UserPrt->Length = (UINT32) ACPI_ROUND_UP_TO_64BIT (UserPrt->Length); 415145510Sdarrenr 416145510Sdarrenr /* 4) Fourth subobject: Dereference the PRT.SourceIndex */ 417145510Sdarrenr 418145510Sdarrenr ObjDesc = SubObjectList[3]; 419145510Sdarrenr if (!ObjDesc || ObjDesc->Common.Type != ACPI_TYPE_INTEGER) 420145510Sdarrenr { 421145510Sdarrenr ACPI_ERROR ((AE_INFO, 422145510Sdarrenr "(PRT[%u].SourceIndex) Need Integer, found %s", 423255332Scy Index, AcpiUtGetObjectTypeName (ObjDesc))); 424145510Sdarrenr return_ACPI_STATUS (AE_BAD_DATA); 425145510Sdarrenr } 426145510Sdarrenr 427145510Sdarrenr UserPrt->SourceIndex = (UINT32) ObjDesc->Integer.Value; 428145510Sdarrenr 429145510Sdarrenr /* Point to the next ACPI_OPERAND_OBJECT in the top level package */ 430145510Sdarrenr 431145510Sdarrenr TopObjectList++; 432145510Sdarrenr } 433145510Sdarrenr 434145510Sdarrenr ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", 435145510Sdarrenr OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); 436145510Sdarrenr return_ACPI_STATUS (AE_OK); 437145510Sdarrenr} 438145510Sdarrenr 439145510Sdarrenr 440145510Sdarrenr/******************************************************************************* 441145510Sdarrenr * 442145510Sdarrenr * FUNCTION: AcpiRsCreateAmlResources 443145510Sdarrenr * 444145510Sdarrenr * PARAMETERS: ResourceList - Pointer to the resource list buffer 445145510Sdarrenr * OutputBuffer - Where the AML buffer is returned 446255332Scy * 447145510Sdarrenr * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. 448145510Sdarrenr * If the OutputBuffer is too small, the error will be 449145510Sdarrenr * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point 450145510Sdarrenr * to the size buffer needed. 451255332Scy * 452145510Sdarrenr * DESCRIPTION: Converts a list of device resources to an AML bytestream 453145510Sdarrenr * to be used as input for the _SRS control method. 454145510Sdarrenr * 455145510Sdarrenr ******************************************************************************/ 456145510Sdarrenr 457255332ScyACPI_STATUS 458145510SdarrenrAcpiRsCreateAmlResources ( 459145510Sdarrenr ACPI_BUFFER *ResourceList, 460145510Sdarrenr ACPI_BUFFER *OutputBuffer) 461255332Scy{ 462255332Scy ACPI_STATUS Status; 463255332Scy ACPI_SIZE AmlSizeNeeded = 0; 464145510Sdarrenr 465145510Sdarrenr 466145510Sdarrenr ACPI_FUNCTION_TRACE (RsCreateAmlResources); 467145510Sdarrenr 468145510Sdarrenr 469145510Sdarrenr /* Params already validated, no need to re-validate here */ 470145510Sdarrenr 471145510Sdarrenr ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "ResourceList Buffer = %p\n", 472145510Sdarrenr ResourceList->Pointer)); 473255332Scy 474145510Sdarrenr /* Get the buffer size needed for the AML byte stream */ 475145510Sdarrenr 476145510Sdarrenr Status = AcpiRsGetAmlLength ( 477145510Sdarrenr ResourceList->Pointer, ResourceList->Length, &AmlSizeNeeded); 478145510Sdarrenr 479145510Sdarrenr ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n", 480145510Sdarrenr (UINT32) AmlSizeNeeded, AcpiFormatException (Status))); 481145510Sdarrenr if (ACPI_FAILURE (Status)) 482145510Sdarrenr { 483145510Sdarrenr return_ACPI_STATUS (Status); 484255332Scy } 485145510Sdarrenr 486145510Sdarrenr /* Validate/Allocate/Clear caller buffer */ 487145510Sdarrenr 488145510Sdarrenr Status = AcpiUtInitializeBuffer (OutputBuffer, AmlSizeNeeded); 489145510Sdarrenr if (ACPI_FAILURE (Status)) 490145510Sdarrenr { 491145510Sdarrenr return_ACPI_STATUS (Status); 492157836Sdarrenr } 493145510Sdarrenr 494145510Sdarrenr /* Do the conversion */ 495157836Sdarrenr 496157836Sdarrenr Status = AcpiRsConvertResourcesToAml (ResourceList->Pointer, 497157836Sdarrenr AmlSizeNeeded, OutputBuffer->Pointer); 498157836Sdarrenr if (ACPI_FAILURE (Status)) 499157836Sdarrenr { 500157836Sdarrenr return_ACPI_STATUS (Status); 501145510Sdarrenr } 502157836Sdarrenr 503255332Scy ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", 504145510Sdarrenr OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); 505145510Sdarrenr return_ACPI_STATUS (AE_OK); 506157836Sdarrenr} 507145510Sdarrenr