rscreate.c revision 228110
167754Smsmith/******************************************************************************* 267754Smsmith * 377424Smsmith * Module Name: rscreate - Create resource lists/tables 467754Smsmith * 567754Smsmith ******************************************************************************/ 667754Smsmith 7217365Sjkim/* 8217365Sjkim * Copyright (C) 2000 - 2011, Intel Corp. 970243Smsmith * All rights reserved. 1067754Smsmith * 11217365Sjkim * Redistribution and use in source and binary forms, with or without 12217365Sjkim * modification, are permitted provided that the following conditions 13217365Sjkim * are met: 14217365Sjkim * 1. Redistributions of source code must retain the above copyright 15217365Sjkim * notice, this list of conditions, and the following disclaimer, 16217365Sjkim * without modification. 17217365Sjkim * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18217365Sjkim * substantially similar to the "NO WARRANTY" disclaimer below 19217365Sjkim * ("Disclaimer") and any redistribution must be conditioned upon 20217365Sjkim * including a substantially similar Disclaimer requirement for further 21217365Sjkim * binary redistribution. 22217365Sjkim * 3. Neither the names of the above-listed copyright holders nor the names 23217365Sjkim * of any contributors may be used to endorse or promote products derived 24217365Sjkim * from this software without specific prior written permission. 2567754Smsmith * 26217365Sjkim * Alternatively, this software may be distributed under the terms of the 27217365Sjkim * GNU General Public License ("GPL") version 2 as published by the Free 28217365Sjkim * Software Foundation. 2967754Smsmith * 30217365Sjkim * NO WARRANTY 31217365Sjkim * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32217365Sjkim * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33217365Sjkim * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 34217365Sjkim * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35217365Sjkim * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36217365Sjkim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37217365Sjkim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38217365Sjkim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39217365Sjkim * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40217365Sjkim * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41217365Sjkim * POSSIBILITY OF SUCH DAMAGES. 42217365Sjkim */ 4367754Smsmith 4467754Smsmith#define __RSCREATE_C__ 4567754Smsmith 46193341Sjkim#include <contrib/dev/acpica/include/acpi.h> 47193341Sjkim#include <contrib/dev/acpica/include/accommon.h> 48193341Sjkim#include <contrib/dev/acpica/include/acresrc.h> 49193341Sjkim#include <contrib/dev/acpica/include/acnamesp.h> 5067754Smsmith 5177424Smsmith#define _COMPONENT ACPI_RESOURCES 5291116Smsmith ACPI_MODULE_NAME ("rscreate") 5367754Smsmith 5467754Smsmith 5567754Smsmith/******************************************************************************* 5667754Smsmith * 57228110Sjkim * FUNCTION: AcpiBufferToResource 58228110Sjkim * 59228110Sjkim * PARAMETERS: AmlBuffer - Pointer to the resource byte stream 60228110Sjkim * AmlBufferLength - Length of the AmlBuffer 61228110Sjkim * ResourcePtr - Where the converted resource is returned 62228110Sjkim * 63228110Sjkim * RETURN: Status 64228110Sjkim * 65228110Sjkim * DESCRIPTION: Convert a raw AML buffer to a resource list 66228110Sjkim * 67228110Sjkim ******************************************************************************/ 68228110Sjkim 69228110SjkimACPI_STATUS 70228110SjkimAcpiBufferToResource ( 71228110Sjkim UINT8 *AmlBuffer, 72228110Sjkim UINT16 AmlBufferLength, 73228110Sjkim ACPI_RESOURCE **ResourcePtr) 74228110Sjkim{ 75228110Sjkim ACPI_STATUS Status; 76228110Sjkim ACPI_SIZE ListSizeNeeded; 77228110Sjkim void *Resource; 78228110Sjkim void *CurrentResourcePtr; 79228110Sjkim 80228110Sjkim /* 81228110Sjkim * Note: we allow AE_AML_NO_RESOURCE_END_TAG, since an end tag 82228110Sjkim * is not required here. 83228110Sjkim */ 84228110Sjkim 85228110Sjkim /* Get the required length for the converted resource */ 86228110Sjkim 87228110Sjkim Status = AcpiRsGetListLength (AmlBuffer, AmlBufferLength, 88228110Sjkim &ListSizeNeeded); 89228110Sjkim if (Status == AE_AML_NO_RESOURCE_END_TAG) 90228110Sjkim { 91228110Sjkim Status = AE_OK; 92228110Sjkim } 93228110Sjkim if (ACPI_FAILURE (Status)) 94228110Sjkim { 95228110Sjkim return (Status); 96228110Sjkim } 97228110Sjkim 98228110Sjkim /* Allocate a buffer for the converted resource */ 99228110Sjkim 100228110Sjkim Resource = ACPI_ALLOCATE_ZEROED (ListSizeNeeded); 101228110Sjkim CurrentResourcePtr = Resource; 102228110Sjkim if (!Resource) 103228110Sjkim { 104228110Sjkim return (AE_NO_MEMORY); 105228110Sjkim } 106228110Sjkim 107228110Sjkim /* Perform the AML-to-Resource conversion */ 108228110Sjkim 109228110Sjkim Status = AcpiUtWalkAmlResources (AmlBuffer, AmlBufferLength, 110228110Sjkim AcpiRsConvertAmlToResources, &CurrentResourcePtr); 111228110Sjkim if (Status == AE_AML_NO_RESOURCE_END_TAG) 112228110Sjkim { 113228110Sjkim Status = AE_OK; 114228110Sjkim } 115228110Sjkim if (ACPI_FAILURE (Status)) 116228110Sjkim { 117228110Sjkim ACPI_FREE (Resource); 118228110Sjkim } 119228110Sjkim else 120228110Sjkim { 121228110Sjkim *ResourcePtr = Resource; 122228110Sjkim } 123228110Sjkim 124228110Sjkim return (Status); 125228110Sjkim} 126228110Sjkim 127228110Sjkim 128228110Sjkim/******************************************************************************* 129228110Sjkim * 13067754Smsmith * FUNCTION: AcpiRsCreateResourceList 13167754Smsmith * 132151937Sjkim * PARAMETERS: AmlBuffer - Pointer to the resource byte stream 133151937Sjkim * OutputBuffer - Pointer to the user's buffer 13467754Smsmith * 135151937Sjkim * RETURN: Status: AE_OK if okay, else a valid ACPI_STATUS code 13667754Smsmith * If OutputBuffer is not large enough, OutputBufferLength 13767754Smsmith * indicates how large OutputBuffer should be, else it 13867754Smsmith * indicates how may UINT8 elements of OutputBuffer are valid. 13967754Smsmith * 14067754Smsmith * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method 14167754Smsmith * execution and parses the stream to create a linked list 14267754Smsmith * of device resources. 14367754Smsmith * 14467754Smsmith ******************************************************************************/ 14567754Smsmith 14667754SmsmithACPI_STATUS 14767754SmsmithAcpiRsCreateResourceList ( 148151937Sjkim ACPI_OPERAND_OBJECT *AmlBuffer, 14991116Smsmith ACPI_BUFFER *OutputBuffer) 15067754Smsmith{ 15167754Smsmith 15267754Smsmith ACPI_STATUS Status; 153151937Sjkim UINT8 *AmlStart; 15491116Smsmith ACPI_SIZE ListSizeNeeded = 0; 155151937Sjkim UINT32 AmlBufferLength; 156167802Sjkim void *Resource; 15767754Smsmith 15867754Smsmith 159167802Sjkim ACPI_FUNCTION_TRACE (RsCreateResourceList); 16067754Smsmith 16167754Smsmith 162151937Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlBuffer = %p\n", 163151937Sjkim AmlBuffer)); 16467754Smsmith 165151937Sjkim /* Params already validated, so we don't re-validate here */ 16667754Smsmith 167151937Sjkim AmlBufferLength = AmlBuffer->Buffer.Length; 168151937Sjkim AmlStart = AmlBuffer->Buffer.Pointer; 169151937Sjkim 17067754Smsmith /* 171151937Sjkim * Pass the AmlBuffer into a module that can calculate 17267754Smsmith * the buffer size needed for the linked list 17367754Smsmith */ 174151937Sjkim Status = AcpiRsGetListLength (AmlStart, AmlBufferLength, 17577424Smsmith &ListSizeNeeded); 17667754Smsmith 17782367Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X ListSizeNeeded=%X\n", 17899679Siwasaki Status, (UINT32) ListSizeNeeded)); 17967754Smsmith if (ACPI_FAILURE (Status)) 18067754Smsmith { 18167754Smsmith return_ACPI_STATUS (Status); 18267754Smsmith } 18367754Smsmith 18491116Smsmith /* Validate/Allocate/Clear caller buffer */ 18591116Smsmith 18691116Smsmith Status = AcpiUtInitializeBuffer (OutputBuffer, ListSizeNeeded); 18791116Smsmith if (ACPI_FAILURE (Status)) 18867754Smsmith { 18991116Smsmith return_ACPI_STATUS (Status); 19087031Smsmith } 19167754Smsmith 19291116Smsmith /* Do the conversion */ 19367754Smsmith 194167802Sjkim Resource = OutputBuffer->Pointer; 195167802Sjkim Status = AcpiUtWalkAmlResources (AmlStart, AmlBufferLength, 196167802Sjkim AcpiRsConvertAmlToResources, &Resource); 19787031Smsmith if (ACPI_FAILURE (Status)) 19867754Smsmith { 19987031Smsmith return_ACPI_STATUS (Status); 20067754Smsmith } 20167754Smsmith 20291116Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", 20399679Siwasaki OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); 20467754Smsmith return_ACPI_STATUS (AE_OK); 20567754Smsmith} 20667754Smsmith 20767754Smsmith 20867754Smsmith/******************************************************************************* 20967754Smsmith * 21067754Smsmith * FUNCTION: AcpiRsCreatePciRoutingTable 21167754Smsmith * 21277424Smsmith * PARAMETERS: PackageObject - Pointer to an ACPI_OPERAND_OBJECT 21377424Smsmith * package 21467754Smsmith * OutputBuffer - Pointer to the user's buffer 21567754Smsmith * 21667754Smsmith * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. 21767754Smsmith * If the OutputBuffer is too small, the error will be 21891116Smsmith * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point 21967754Smsmith * to the size buffer needed. 22067754Smsmith * 22167754Smsmith * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a 22267754Smsmith * linked list of PCI interrupt descriptions 22367754Smsmith * 22491116Smsmith * NOTE: It is the caller's responsibility to ensure that the start of the 22591116Smsmith * output buffer is aligned properly (if necessary). 22691116Smsmith * 22767754Smsmith ******************************************************************************/ 22867754Smsmith 22967754SmsmithACPI_STATUS 23067754SmsmithAcpiRsCreatePciRoutingTable ( 23167754Smsmith ACPI_OPERAND_OBJECT *PackageObject, 23291116Smsmith ACPI_BUFFER *OutputBuffer) 23367754Smsmith{ 23491116Smsmith UINT8 *Buffer; 235107325Siwasaki ACPI_OPERAND_OBJECT **TopObjectList; 236107325Siwasaki ACPI_OPERAND_OBJECT **SubObjectList; 237107325Siwasaki ACPI_OPERAND_OBJECT *ObjDesc; 23891116Smsmith ACPI_SIZE BufferSizeNeeded = 0; 239107325Siwasaki UINT32 NumberOfElements; 240107325Siwasaki UINT32 Index; 241107325Siwasaki ACPI_PCI_ROUTING_TABLE *UserPrt; 24273561Smsmith ACPI_NAMESPACE_NODE *Node; 24367754Smsmith ACPI_STATUS Status; 24491116Smsmith ACPI_BUFFER PathBuffer; 24567754Smsmith 24667754Smsmith 247167802Sjkim ACPI_FUNCTION_TRACE (RsCreatePciRoutingTable); 24867754Smsmith 24967754Smsmith 25091116Smsmith /* Params already validated, so we don't re-validate here */ 25191116Smsmith 252151937Sjkim /* Get the required buffer length */ 253151937Sjkim 25499679Siwasaki Status = AcpiRsGetPciRoutingTableLength (PackageObject, 25577424Smsmith &BufferSizeNeeded); 25691116Smsmith if (ACPI_FAILURE (Status)) 25777424Smsmith { 25877424Smsmith return_ACPI_STATUS (Status); 25977424Smsmith } 26067754Smsmith 261114237Snjl ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "BufferSizeNeeded = %X\n", 262107325Siwasaki (UINT32) BufferSizeNeeded)); 26377424Smsmith 26491116Smsmith /* Validate/Allocate/Clear caller buffer */ 26587031Smsmith 26691116Smsmith Status = AcpiUtInitializeBuffer (OutputBuffer, BufferSizeNeeded); 26791116Smsmith if (ACPI_FAILURE (Status)) 26887031Smsmith { 26991116Smsmith return_ACPI_STATUS (Status); 27087031Smsmith } 27187031Smsmith 27267754Smsmith /* 273193267Sjkim * Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a 274202771Sjkim * package that in turn contains an UINT64 Address, a UINT8 Pin, 275193267Sjkim * a Name, and a UINT8 SourceIndex. 27667754Smsmith */ 27787031Smsmith TopObjectList = PackageObject->Package.Elements; 27887031Smsmith NumberOfElements = PackageObject->Package.Count; 27991116Smsmith Buffer = OutputBuffer->Pointer; 28099679Siwasaki UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer); 28187031Smsmith 28287031Smsmith for (Index = 0; Index < NumberOfElements; Index++) 28367754Smsmith { 28467754Smsmith /* 28587031Smsmith * Point UserPrt past this current structure 28687031Smsmith * 28787031Smsmith * NOTE: On the first iteration, UserPrt->Length will 28887031Smsmith * be zero because we cleared the return buffer earlier 28967754Smsmith */ 29087031Smsmith Buffer += UserPrt->Length; 29199679Siwasaki UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer); 29267754Smsmith 29367754Smsmith /* 29491116Smsmith * Fill in the Length field with the information we have at this point. 29591116Smsmith * The minus four is to subtract the size of the UINT8 Source[4] member 29691116Smsmith * because it is added below. 29767754Smsmith */ 298107325Siwasaki UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4); 29967754Smsmith 300151937Sjkim /* Each element of the top-level package must also be a package */ 301151937Sjkim 302193267Sjkim if ((*TopObjectList)->Common.Type != ACPI_TYPE_PACKAGE) 303107325Siwasaki { 304167802Sjkim ACPI_ERROR ((AE_INFO, 305204773Sjkim "(PRT[%u]) Need sub-package, found %s", 306107325Siwasaki Index, AcpiUtGetObjectTypeName (*TopObjectList))); 307107325Siwasaki return_ACPI_STATUS (AE_AML_OPERAND_TYPE); 308107325Siwasaki } 30969450Smsmith 310107325Siwasaki /* Each sub-package must be of length 4 */ 311107325Siwasaki 312107325Siwasaki if ((*TopObjectList)->Package.Count != 4) 313107325Siwasaki { 314167802Sjkim ACPI_ERROR ((AE_INFO, 315204773Sjkim "(PRT[%u]) Need package of length 4, found length %u", 316107325Siwasaki Index, (*TopObjectList)->Package.Count)); 317107325Siwasaki return_ACPI_STATUS (AE_AML_PACKAGE_LIMIT); 318107325Siwasaki } 319107325Siwasaki 32087031Smsmith /* 321107325Siwasaki * Dereference the sub-package. 32291116Smsmith * The SubObjectList will now point to an array of the four IRQ 323107325Siwasaki * elements: [Address, Pin, Source, SourceIndex] 32487031Smsmith */ 325107325Siwasaki SubObjectList = (*TopObjectList)->Package.Elements; 32669450Smsmith 327151937Sjkim /* 1) First subobject: Dereference the PRT.Address */ 328151937Sjkim 329107325Siwasaki ObjDesc = SubObjectList[0]; 330193267Sjkim if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) 33167754Smsmith { 332204773Sjkim ACPI_ERROR ((AE_INFO, "(PRT[%u].Address) Need Integer, found %s", 333107325Siwasaki Index, AcpiUtGetObjectTypeName (ObjDesc))); 33487031Smsmith return_ACPI_STATUS (AE_BAD_DATA); 33587031Smsmith } 33667754Smsmith 337193267Sjkim UserPrt->Address = ObjDesc->Integer.Value; 338193267Sjkim 339151937Sjkim /* 2) Second subobject: Dereference the PRT.Pin */ 340151937Sjkim 341107325Siwasaki ObjDesc = SubObjectList[1]; 342193267Sjkim if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) 34387031Smsmith { 344204773Sjkim ACPI_ERROR ((AE_INFO, "(PRT[%u].Pin) Need Integer, found %s", 345107325Siwasaki Index, AcpiUtGetObjectTypeName (ObjDesc))); 34687031Smsmith return_ACPI_STATUS (AE_BAD_DATA); 34787031Smsmith } 34867754Smsmith 349193267Sjkim UserPrt->Pin = (UINT32) ObjDesc->Integer.Value; 350193267Sjkim 351167802Sjkim /* 352193267Sjkim * If the BIOS has erroneously reversed the _PRT SourceName (index 2) 353193267Sjkim * and the SourceIndex (index 3), fix it. _PRT is important enough to 354193267Sjkim * workaround this BIOS error. This also provides compatibility with 355193267Sjkim * other ACPI implementations. 356193267Sjkim */ 357193267Sjkim ObjDesc = SubObjectList[3]; 358193267Sjkim if (!ObjDesc || (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)) 359193267Sjkim { 360193267Sjkim SubObjectList[3] = SubObjectList[2]; 361193267Sjkim SubObjectList[2] = ObjDesc; 362193267Sjkim 363193267Sjkim ACPI_WARNING ((AE_INFO, 364193267Sjkim "(PRT[%X].Source) SourceName and SourceIndex are reversed, fixed", 365193267Sjkim Index)); 366193267Sjkim } 367193267Sjkim 368193267Sjkim /* 369167802Sjkim * 3) Third subobject: Dereference the PRT.SourceName 370167802Sjkim * The name may be unresolved (slack mode), so allow a null object 371167802Sjkim */ 372107325Siwasaki ObjDesc = SubObjectList[2]; 373167802Sjkim if (ObjDesc) 37487031Smsmith { 375193267Sjkim switch (ObjDesc->Common.Type) 37667754Smsmith { 377167802Sjkim case ACPI_TYPE_LOCAL_REFERENCE: 37867754Smsmith 379193267Sjkim if (ObjDesc->Reference.Class != ACPI_REFCLASS_NAME) 380167802Sjkim { 381167802Sjkim ACPI_ERROR ((AE_INFO, 382204773Sjkim "(PRT[%u].Source) Need name, found Reference Class 0x%X", 383193267Sjkim Index, ObjDesc->Reference.Class)); 384167802Sjkim return_ACPI_STATUS (AE_BAD_DATA); 385167802Sjkim } 38667754Smsmith 387167802Sjkim Node = ObjDesc->Reference.Node; 38867754Smsmith 389167802Sjkim /* Use *remaining* length of the buffer as max for pathname */ 39067754Smsmith 391167802Sjkim PathBuffer.Length = OutputBuffer->Length - 392167802Sjkim (UINT32) ((UINT8 *) UserPrt->Source - 393167802Sjkim (UINT8 *) OutputBuffer->Pointer); 394167802Sjkim PathBuffer.Pointer = UserPrt->Source; 39567754Smsmith 396167802Sjkim Status = AcpiNsHandleToPathname ((ACPI_HANDLE) Node, &PathBuffer); 397151937Sjkim 398167802Sjkim /* +1 to include null terminator */ 39977424Smsmith 400167802Sjkim UserPrt->Length += (UINT32) ACPI_STRLEN (UserPrt->Source) + 1; 401167802Sjkim break; 40273561Smsmith 40373561Smsmith 404167802Sjkim case ACPI_TYPE_STRING: 40573561Smsmith 406167802Sjkim ACPI_STRCPY (UserPrt->Source, ObjDesc->String.Pointer); 40773561Smsmith 408167802Sjkim /* 409167802Sjkim * Add to the Length field the length of the string 410167802Sjkim * (add 1 for terminator) 411167802Sjkim */ 412167802Sjkim UserPrt->Length += ObjDesc->String.Length + 1; 413167802Sjkim break; 41473561Smsmith 41573561Smsmith 416167802Sjkim case ACPI_TYPE_INTEGER: 417167802Sjkim /* 418167802Sjkim * If this is a number, then the Source Name is NULL, since the 419167802Sjkim * entire buffer was zeroed out, we can leave this alone. 420167802Sjkim * 421167802Sjkim * Add to the Length field the length of the UINT32 NULL 422167802Sjkim */ 423167802Sjkim UserPrt->Length += sizeof (UINT32); 424167802Sjkim break; 42573561Smsmith 42667754Smsmith 427167802Sjkim default: 428167802Sjkim 429167802Sjkim ACPI_ERROR ((AE_INFO, 430204773Sjkim "(PRT[%u].Source) Need Ref/String/Integer, found %s", 431167802Sjkim Index, AcpiUtGetObjectTypeName (ObjDesc))); 432167802Sjkim return_ACPI_STATUS (AE_BAD_DATA); 433167802Sjkim } 43487031Smsmith } 43567754Smsmith 43687031Smsmith /* Now align the current length */ 43773561Smsmith 438167802Sjkim UserPrt->Length = (UINT32) ACPI_ROUND_UP_TO_64BIT (UserPrt->Length); 43967754Smsmith 440151937Sjkim /* 4) Fourth subobject: Dereference the PRT.SourceIndex */ 441151937Sjkim 442107325Siwasaki ObjDesc = SubObjectList[3]; 443193267Sjkim if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER) 44487031Smsmith { 445167802Sjkim ACPI_ERROR ((AE_INFO, 446204773Sjkim "(PRT[%u].SourceIndex) Need Integer, found %s", 447107325Siwasaki Index, AcpiUtGetObjectTypeName (ObjDesc))); 44887031Smsmith return_ACPI_STATUS (AE_BAD_DATA); 44987031Smsmith } 45067754Smsmith 451193267Sjkim UserPrt->SourceIndex = (UINT32) ObjDesc->Integer.Value; 452193267Sjkim 453107325Siwasaki /* Point to the next ACPI_OPERAND_OBJECT in the top level package */ 45491116Smsmith 45587031Smsmith TopObjectList++; 45667754Smsmith } 45767754Smsmith 45891116Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", 45999679Siwasaki OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); 46067754Smsmith return_ACPI_STATUS (AE_OK); 46167754Smsmith} 46267754Smsmith 46367754Smsmith 46467754Smsmith/******************************************************************************* 46567754Smsmith * 466151937Sjkim * FUNCTION: AcpiRsCreateAmlResources 46767754Smsmith * 46877424Smsmith * PARAMETERS: LinkedListBuffer - Pointer to the resource linked list 46967754Smsmith * OutputBuffer - Pointer to the user's buffer 47067754Smsmith * 47167754Smsmith * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. 47267754Smsmith * If the OutputBuffer is too small, the error will be 47391116Smsmith * AE_BUFFER_OVERFLOW and OutputBuffer->Length will point 47467754Smsmith * to the size buffer needed. 47567754Smsmith * 47667754Smsmith * DESCRIPTION: Takes the linked list of device resources and 47767754Smsmith * creates a bytestream to be used as input for the 47867754Smsmith * _SRS control method. 47967754Smsmith * 48067754Smsmith ******************************************************************************/ 48167754Smsmith 48267754SmsmithACPI_STATUS 483151937SjkimAcpiRsCreateAmlResources ( 48477424Smsmith ACPI_RESOURCE *LinkedListBuffer, 48591116Smsmith ACPI_BUFFER *OutputBuffer) 48667754Smsmith{ 48767754Smsmith ACPI_STATUS Status; 488151937Sjkim ACPI_SIZE AmlSizeNeeded = 0; 48967754Smsmith 49067754Smsmith 491167802Sjkim ACPI_FUNCTION_TRACE (RsCreateAmlResources); 49267754Smsmith 49367754Smsmith 494114237Snjl ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "LinkedListBuffer = %p\n", 495107325Siwasaki LinkedListBuffer)); 49667754Smsmith 49767754Smsmith /* 49867754Smsmith * Params already validated, so we don't re-validate here 49967754Smsmith * 50087031Smsmith * Pass the LinkedListBuffer into a module that calculates 50167754Smsmith * the buffer size needed for the byte stream. 50267754Smsmith */ 503151937Sjkim Status = AcpiRsGetAmlLength (LinkedListBuffer, 504151937Sjkim &AmlSizeNeeded); 50567754Smsmith 506151937Sjkim ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n", 507151937Sjkim (UINT32) AmlSizeNeeded, AcpiFormatException (Status))); 50867754Smsmith if (ACPI_FAILURE (Status)) 50967754Smsmith { 51067754Smsmith return_ACPI_STATUS (Status); 51167754Smsmith } 51267754Smsmith 51391116Smsmith /* Validate/Allocate/Clear caller buffer */ 51491116Smsmith 515151937Sjkim Status = AcpiUtInitializeBuffer (OutputBuffer, AmlSizeNeeded); 51691116Smsmith if (ACPI_FAILURE (Status)) 51767754Smsmith { 51891116Smsmith return_ACPI_STATUS (Status); 51987031Smsmith } 52067754Smsmith 52191116Smsmith /* Do the conversion */ 52267754Smsmith 523151937Sjkim Status = AcpiRsConvertResourcesToAml (LinkedListBuffer, AmlSizeNeeded, 52491116Smsmith OutputBuffer->Pointer); 52587031Smsmith if (ACPI_FAILURE (Status)) 52667754Smsmith { 52787031Smsmith return_ACPI_STATUS (Status); 52867754Smsmith } 52967754Smsmith 53091116Smsmith ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n", 53199679Siwasaki OutputBuffer->Pointer, (UINT32) OutputBuffer->Length)); 53267754Smsmith return_ACPI_STATUS (AE_OK); 53367754Smsmith} 53467754Smsmith 535