rscreate.c revision 67754
167754Smsmith/******************************************************************************* 267754Smsmith * 367754Smsmith * Module Name: rscreate - AcpiRsCreateResourceList 467754Smsmith * AcpiRsCreatePciRoutingTable 567754Smsmith * AcpiRsCreateByteStream 667754Smsmith * $Revision: 19 $ 767754Smsmith * 867754Smsmith ******************************************************************************/ 967754Smsmith 1067754Smsmith/****************************************************************************** 1167754Smsmith * 1267754Smsmith * 1. Copyright Notice 1367754Smsmith * 1467754Smsmith * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights 1567754Smsmith * reserved. 1667754Smsmith * 1767754Smsmith * 2. License 1867754Smsmith * 1967754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property 2067754Smsmith * rights. You may have additional license terms from the party that provided 2167754Smsmith * you this software, covering your right to use that party's intellectual 2267754Smsmith * property rights. 2367754Smsmith * 2467754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 2567754Smsmith * copy of the source code appearing in this file ("Covered Code") an 2667754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the 2767754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy, 2867754Smsmith * make derivatives, distribute, use and display any portion of the Covered 2967754Smsmith * Code in any form, with the right to sublicense such rights; and 3067754Smsmith * 3167754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 3267754Smsmith * license (with the right to sublicense), under only those claims of Intel 3367754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell, 3467754Smsmith * offer to sell, and import the Covered Code and derivative works thereof 3567754Smsmith * solely to the minimum extent necessary to exercise the above copyright 3667754Smsmith * license, and in no event shall the patent license extend to any additions 3767754Smsmith * to or modifications of the Original Intel Code. No other license or right 3867754Smsmith * is granted directly or by implication, estoppel or otherwise; 3967754Smsmith * 4067754Smsmith * The above copyright and patent license is granted only if the following 4167754Smsmith * conditions are met: 4267754Smsmith * 4367754Smsmith * 3. Conditions 4467754Smsmith * 4567754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source. 4667754Smsmith * Redistribution of source code of any substantial portion of the Covered 4767754Smsmith * Code or modification with rights to further distribute source must include 4867754Smsmith * the above Copyright Notice, the above License, this list of Conditions, 4967754Smsmith * and the following Disclaimer and Export Compliance provision. In addition, 5067754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to 5167754Smsmith * contain a file documenting the changes Licensee made to create that Covered 5267754Smsmith * Code and the date of any change. Licensee must include in that file the 5367754Smsmith * documentation of any changes made by any predecessor Licensee. Licensee 5467754Smsmith * must include a prominent statement that the modification is derived, 5567754Smsmith * directly or indirectly, from Original Intel Code. 5667754Smsmith * 5767754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 5867754Smsmith * Redistribution of source code of any substantial portion of the Covered 5967754Smsmith * Code or modification without rights to further distribute source must 6067754Smsmith * include the following Disclaimer and Export Compliance provision in the 6167754Smsmith * documentation and/or other materials provided with distribution. In 6267754Smsmith * addition, Licensee may not authorize further sublicense of source of any 6367754Smsmith * portion of the Covered Code, and must include terms to the effect that the 6467754Smsmith * license from Licensee to its licensee is limited to the intellectual 6567754Smsmith * property embodied in the software Licensee provides to its licensee, and 6667754Smsmith * not to intellectual property embodied in modifications its licensee may 6767754Smsmith * make. 6867754Smsmith * 6967754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any 7067754Smsmith * substantial portion of the Covered Code or modification must reproduce the 7167754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance 7267754Smsmith * provision in the documentation and/or other materials provided with the 7367754Smsmith * distribution. 7467754Smsmith * 7567754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original 7667754Smsmith * Intel Code. 7767754Smsmith * 7867754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by 7967754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or 8067754Smsmith * other dealings in products derived from or relating to the Covered Code 8167754Smsmith * without prior written authorization from Intel. 8267754Smsmith * 8367754Smsmith * 4. Disclaimer and Export Compliance 8467754Smsmith * 8567754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 8667754Smsmith * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 8767754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 8867754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 8967754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 9067754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 9167754Smsmith * PARTICULAR PURPOSE. 9267754Smsmith * 9367754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 9467754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 9567754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 9667754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 9767754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 9867754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 9967754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 10067754Smsmith * LIMITED REMEDY. 10167754Smsmith * 10267754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this 10367754Smsmith * software or system incorporating such software without first obtaining any 10467754Smsmith * required license or other approval from the U. S. Department of Commerce or 10567754Smsmith * any other agency or department of the United States Government. In the 10667754Smsmith * event Licensee exports any such software from the United States or 10767754Smsmith * re-exports any such software from a foreign destination, Licensee shall 10867754Smsmith * ensure that the distribution and export/re-export of the software is in 10967754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the 11067754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor 11167754Smsmith * any of its subsidiaries will export/re-export any technical data, process, 11267754Smsmith * software, or service, directly or indirectly, to any country for which the 11367754Smsmith * United States government or any agency thereof requires an export license, 11467754Smsmith * other governmental approval, or letter of assurance, without first obtaining 11567754Smsmith * such license, approval or letter. 11667754Smsmith * 11767754Smsmith *****************************************************************************/ 11867754Smsmith 11967754Smsmith 12067754Smsmith#define __RSCREATE_C__ 12167754Smsmith 12267754Smsmith#include "acpi.h" 12367754Smsmith#include "acresrc.h" 12467754Smsmith 12567754Smsmith#define _COMPONENT RESOURCE_MANAGER 12667754Smsmith MODULE_NAME ("rscreate") 12767754Smsmith 12867754Smsmith 12967754Smsmith/******************************************************************************* 13067754Smsmith * 13167754Smsmith * FUNCTION: AcpiRsCreateResourceList 13267754Smsmith * 13367754Smsmith * PARAMETERS: 13467754Smsmith * ByteStreamBuffer - Pointer to the resource byte stream 13567754Smsmith * OutputBuffer - Pointer to the user's buffer 13667754Smsmith * OutputBufferLength - Pointer to the size of OutputBuffer 13767754Smsmith * 13867754Smsmith * RETURN: Status - AE_OK if okay, else a valid ACPI_STATUS code 13967754Smsmith * If OutputBuffer is not large enough, OutputBufferLength 14067754Smsmith * indicates how large OutputBuffer should be, else it 14167754Smsmith * indicates how may UINT8 elements of OutputBuffer are valid. 14267754Smsmith * 14367754Smsmith * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method 14467754Smsmith * execution and parses the stream to create a linked list 14567754Smsmith * of device resources. 14667754Smsmith * 14767754Smsmith ******************************************************************************/ 14867754Smsmith 14967754SmsmithACPI_STATUS 15067754SmsmithAcpiRsCreateResourceList ( 15167754Smsmith ACPI_OPERAND_OBJECT *ByteStreamBuffer, 15267754Smsmith UINT8 *OutputBuffer, 15367754Smsmith UINT32 *OutputBufferLength) 15467754Smsmith{ 15567754Smsmith 15667754Smsmith ACPI_STATUS Status; 15767754Smsmith UINT8 *ByteStreamStart = NULL; 15867754Smsmith UINT32 ListSizeNeeded = 0; 15967754Smsmith UINT32 ByteStreamBufferLength = 0; 16067754Smsmith 16167754Smsmith 16267754Smsmith FUNCTION_TRACE ("RsCreateResourceList"); 16367754Smsmith 16467754Smsmith 16567754Smsmith DEBUG_PRINT (VERBOSE_INFO, ("RsCreateResourceList: ByteStreamBuffer = %p\n", 16667754Smsmith ByteStreamBuffer)); 16767754Smsmith 16867754Smsmith /* 16967754Smsmith * Params already validated, so we don't re-validate here 17067754Smsmith */ 17167754Smsmith 17267754Smsmith ByteStreamBufferLength = ByteStreamBuffer->Buffer.Length; 17367754Smsmith ByteStreamStart = ByteStreamBuffer->Buffer.Pointer; 17467754Smsmith 17567754Smsmith /* 17667754Smsmith * Pass the ByteStreamBuffer into a module that can calculate 17767754Smsmith * the buffer size needed for the linked list 17867754Smsmith */ 17967754Smsmith Status = AcpiRsCalculateListLength (ByteStreamStart, 18067754Smsmith ByteStreamBufferLength, 18167754Smsmith &ListSizeNeeded); 18267754Smsmith 18367754Smsmith DEBUG_PRINT (VERBOSE_INFO, 18467754Smsmith ("RsCreateResourceList: Status=%d ListSizeNeeded=%d\n", 18567754Smsmith Status, ListSizeNeeded)); 18667754Smsmith 18767754Smsmith /* 18867754Smsmith * Exit with the error passed back 18967754Smsmith */ 19067754Smsmith if (ACPI_FAILURE (Status)) 19167754Smsmith { 19267754Smsmith return_ACPI_STATUS (Status); 19367754Smsmith } 19467754Smsmith 19567754Smsmith /* 19667754Smsmith * If the linked list will fit into the available buffer 19767754Smsmith * call to fill in the list 19867754Smsmith */ 19967754Smsmith 20067754Smsmith if (ListSizeNeeded <= *OutputBufferLength) 20167754Smsmith { 20267754Smsmith /* 20367754Smsmith * Zero out the return buffer before proceeding 20467754Smsmith */ 20567754Smsmith MEMSET (OutputBuffer, 0x00, *OutputBufferLength); 20667754Smsmith 20767754Smsmith Status = AcpiRsByteStreamToList (ByteStreamStart, 20867754Smsmith ByteStreamBufferLength, 20967754Smsmith &OutputBuffer); 21067754Smsmith 21167754Smsmith /* 21267754Smsmith * Exit with the error passed back 21367754Smsmith */ 21467754Smsmith if (ACPI_FAILURE (Status)) 21567754Smsmith { 21667754Smsmith return_ACPI_STATUS (Status); 21767754Smsmith } 21867754Smsmith 21967754Smsmith DEBUG_PRINT (VERBOSE_INFO, ("RsByteStreamToList: OutputBuffer = %p\n", 22067754Smsmith OutputBuffer)); 22167754Smsmith } 22267754Smsmith 22367754Smsmith else 22467754Smsmith { 22567754Smsmith *OutputBufferLength = ListSizeNeeded; 22667754Smsmith return_ACPI_STATUS (AE_BUFFER_OVERFLOW); 22767754Smsmith } 22867754Smsmith 22967754Smsmith *OutputBufferLength = ListSizeNeeded; 23067754Smsmith return_ACPI_STATUS (AE_OK); 23167754Smsmith 23267754Smsmith} 23367754Smsmith 23467754Smsmith 23567754Smsmith/******************************************************************************* 23667754Smsmith * 23767754Smsmith * FUNCTION: AcpiRsCreatePciRoutingTable 23867754Smsmith * 23967754Smsmith * PARAMETERS: 24067754Smsmith * PackageObject - Pointer to an ACPI_OPERAND_OBJECT 24167754Smsmith * package 24267754Smsmith * OutputBuffer - Pointer to the user's buffer 24367754Smsmith * OutputBufferLength - Size of OutputBuffer 24467754Smsmith * 24567754Smsmith * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. 24667754Smsmith * If the OutputBuffer is too small, the error will be 24767754Smsmith * AE_BUFFER_OVERFLOW and OutputBufferLength will point 24867754Smsmith * to the size buffer needed. 24967754Smsmith * 25067754Smsmith * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT package and creates a 25167754Smsmith * linked list of PCI interrupt descriptions 25267754Smsmith * 25367754Smsmith ******************************************************************************/ 25467754Smsmith 25567754SmsmithACPI_STATUS 25667754SmsmithAcpiRsCreatePciRoutingTable ( 25767754Smsmith ACPI_OPERAND_OBJECT *PackageObject, 25867754Smsmith UINT8 *OutputBuffer, 25967754Smsmith UINT32 *OutputBufferLength) 26067754Smsmith{ 26167754Smsmith UINT8 *Buffer = OutputBuffer; 26267754Smsmith ACPI_OPERAND_OBJECT **TopObjectList = NULL; 26367754Smsmith ACPI_OPERAND_OBJECT **SubObjectList = NULL; 26467754Smsmith ACPI_OPERAND_OBJECT *PackageElement = NULL; 26567754Smsmith UINT32 BufferSizeNeeded = 0; 26667754Smsmith UINT32 NumberOfElements = 0; 26767754Smsmith UINT32 Index = 0; 26867754Smsmith PCI_ROUTING_TABLE *UserPrt = NULL; 26967754Smsmith ACPI_STATUS Status; 27067754Smsmith 27167754Smsmith 27267754Smsmith FUNCTION_TRACE ("RsCreatePciRoutingTable"); 27367754Smsmith 27467754Smsmith 27567754Smsmith /* 27667754Smsmith * Params already validated, so we don't re-validate here 27767754Smsmith */ 27867754Smsmith 27967754Smsmith Status = AcpiRsCalculatePciRoutingTableLength(PackageObject, 28067754Smsmith &BufferSizeNeeded); 28167754Smsmith 28267754Smsmith DEBUG_PRINT (VERBOSE_INFO, 28367754Smsmith ("RsCreatePciRoutingTable: BufferSizeNeeded = %d\n", 28467754Smsmith BufferSizeNeeded)); 28567754Smsmith 28667754Smsmith /* 28767754Smsmith * If the data will fit into the available buffer 28867754Smsmith * call to fill in the list 28967754Smsmith */ 29067754Smsmith if (BufferSizeNeeded <= *OutputBufferLength) 29167754Smsmith { 29267754Smsmith /* 29367754Smsmith * Zero out the return buffer before proceeding 29467754Smsmith */ 29567754Smsmith MEMSET (OutputBuffer, 0x00, *OutputBufferLength); 29667754Smsmith 29767754Smsmith /* 29867754Smsmith * Loop through the ACPI_INTERNAL_OBJECTS - Each object should 29967754Smsmith * contain a UINT32 Address, a UINT8 Pin, a Name and a UINT8 30067754Smsmith * SourceIndex. 30167754Smsmith */ 30267754Smsmith TopObjectList = PackageObject->Package.Elements; 30367754Smsmith NumberOfElements = PackageObject->Package.Count; 30467754Smsmith UserPrt = (PCI_ROUTING_TABLE *) Buffer; 30567754Smsmith 30667754Smsmith for (Index = 0; Index < NumberOfElements; Index++) 30767754Smsmith { 30867754Smsmith /* 30967754Smsmith * Point UserPrt past this current structure 31067754Smsmith * 31167754Smsmith * NOTE: On the first iteration, UserPrt->Length will 31267754Smsmith * be zero because we cleared the return buffer earlier 31367754Smsmith */ 31467754Smsmith Buffer += UserPrt->Length; 31567754Smsmith Buffer = ROUND_PTR_UP_TO_4 (Buffer, UINT8); 31667754Smsmith UserPrt = (PCI_ROUTING_TABLE *) Buffer; 31767754Smsmith 31867754Smsmith /* 31967754Smsmith * Fill in the Length field with the information we 32067754Smsmith * have at this point. 32167754Smsmith * The minus one is to subtract the size of the 32267754Smsmith * UINT8 Source[1] member because it is added below. 32367754Smsmith */ 32467754Smsmith UserPrt->Length = (sizeof (PCI_ROUTING_TABLE) - 1); 32567754Smsmith 32667754Smsmith /* 32767754Smsmith * Dereference the sub-package 32867754Smsmith */ 32967754Smsmith PackageElement = *TopObjectList; 33067754Smsmith 33167754Smsmith /* 33267754Smsmith * The SubObjectList will now point to an array of 33367754Smsmith * the four IRQ elements: Address, Pin, Source and 33467754Smsmith * SourceIndex 33567754Smsmith */ 33667754Smsmith SubObjectList = PackageElement->Package.Elements; 33767754Smsmith 33867754Smsmith /* 33967754Smsmith * Dereference the Address 34067754Smsmith */ 34167754Smsmith if (ACPI_TYPE_NUMBER == (*SubObjectList)->Common.Type) 34267754Smsmith { 34367754Smsmith UserPrt->Data.Address = 34467754Smsmith (*SubObjectList)->Number.Value; 34567754Smsmith } 34667754Smsmith 34767754Smsmith else 34867754Smsmith { 34967754Smsmith return_ACPI_STATUS (AE_BAD_DATA); 35067754Smsmith } 35167754Smsmith 35267754Smsmith /* 35367754Smsmith * Dereference the Pin 35467754Smsmith */ 35567754Smsmith SubObjectList++; 35667754Smsmith 35767754Smsmith if (ACPI_TYPE_NUMBER == (*SubObjectList)->Common.Type) 35867754Smsmith { 35967754Smsmith UserPrt->Data.Pin = 36067754Smsmith (UINT32) (*SubObjectList)->Number.Value; 36167754Smsmith } 36267754Smsmith 36367754Smsmith else 36467754Smsmith { 36567754Smsmith return_ACPI_STATUS (AE_BAD_DATA); 36667754Smsmith } 36767754Smsmith 36867754Smsmith /* 36967754Smsmith * Dereference the Source Name 37067754Smsmith */ 37167754Smsmith SubObjectList++; 37267754Smsmith 37367754Smsmith if (ACPI_TYPE_STRING == (*SubObjectList)->Common.Type) 37467754Smsmith { 37567754Smsmith STRCPY (UserPrt->Data.Source, 37667754Smsmith (*SubObjectList)->String.Pointer); 37767754Smsmith 37867754Smsmith /* 37967754Smsmith * Add to the Length field the length of the string 38067754Smsmith */ 38167754Smsmith UserPrt->Length += (*SubObjectList)->String.Length; 38267754Smsmith } 38367754Smsmith 38467754Smsmith else 38567754Smsmith { 38667754Smsmith /* 38767754Smsmith * If this is a number, then the Source Name 38867754Smsmith * is NULL, since the entire buffer was zeroed 38967754Smsmith * out, we can leave this alone. 39067754Smsmith */ 39167754Smsmith if (ACPI_TYPE_NUMBER == (*SubObjectList)->Common.Type) 39267754Smsmith { 39367754Smsmith /* 39467754Smsmith * Add to the Length field the length of 39567754Smsmith * the UINT32 NULL 39667754Smsmith */ 39767754Smsmith UserPrt->Length += sizeof (UINT32); 39867754Smsmith } 39967754Smsmith 40067754Smsmith else 40167754Smsmith { 40267754Smsmith return_ACPI_STATUS (AE_BAD_DATA); 40367754Smsmith } 40467754Smsmith } 40567754Smsmith 40667754Smsmith /* Now align the current length */ 40767754Smsmith 40867754Smsmith UserPrt->Length = ROUND_UP_TO_32BITS (UserPrt->Length); 40967754Smsmith 41067754Smsmith /* 41167754Smsmith * Dereference the Source Index 41267754Smsmith */ 41367754Smsmith SubObjectList++; 41467754Smsmith 41567754Smsmith if (ACPI_TYPE_NUMBER == (*SubObjectList)->Common.Type) 41667754Smsmith { 41767754Smsmith UserPrt->Data.SourceIndex = 41867754Smsmith (UINT32) (*SubObjectList)->Number.Value; 41967754Smsmith } 42067754Smsmith 42167754Smsmith else 42267754Smsmith { 42367754Smsmith return_ACPI_STATUS (AE_BAD_DATA); 42467754Smsmith } 42567754Smsmith 42667754Smsmith /* 42767754Smsmith * Point to the next ACPI_OPERAND_OBJECT 42867754Smsmith */ 42967754Smsmith TopObjectList++; 43067754Smsmith } 43167754Smsmith 43267754Smsmith DEBUG_PRINT (VERBOSE_INFO, 43367754Smsmith ("RsCreatePciRoutingTable: OutputBuffer = %p\n", 43467754Smsmith OutputBuffer)); 43567754Smsmith } 43667754Smsmith 43767754Smsmith else 43867754Smsmith { 43967754Smsmith *OutputBufferLength = BufferSizeNeeded; 44067754Smsmith 44167754Smsmith return_ACPI_STATUS (AE_BUFFER_OVERFLOW); 44267754Smsmith } 44367754Smsmith 44467754Smsmith /* 44567754Smsmith * Report the amount of buffer used 44667754Smsmith */ 44767754Smsmith *OutputBufferLength = BufferSizeNeeded; 44867754Smsmith 44967754Smsmith return_ACPI_STATUS (AE_OK); 45067754Smsmith} 45167754Smsmith 45267754Smsmith 45367754Smsmith/******************************************************************************* 45467754Smsmith * 45567754Smsmith * FUNCTION: AcpiRsCreateByteStream 45667754Smsmith * 45767754Smsmith * PARAMETERS: 45867754Smsmith * LinkedListBuffer - Pointer to the resource linked list 45967754Smsmith * OutputBuffer - Pointer to the user's buffer 46067754Smsmith * OutputBufferLength - Size of OutputBuffer 46167754Smsmith * 46267754Smsmith * RETURN: Status AE_OK if okay, else a valid ACPI_STATUS code. 46367754Smsmith * If the OutputBuffer is too small, the error will be 46467754Smsmith * AE_BUFFER_OVERFLOW and OutputBufferLength will point 46567754Smsmith * to the size buffer needed. 46667754Smsmith * 46767754Smsmith * DESCRIPTION: Takes the linked list of device resources and 46867754Smsmith * creates a bytestream to be used as input for the 46967754Smsmith * _SRS control method. 47067754Smsmith * 47167754Smsmith ******************************************************************************/ 47267754Smsmith 47367754SmsmithACPI_STATUS 47467754SmsmithAcpiRsCreateByteStream ( 47567754Smsmith RESOURCE *LinkedListBuffer, 47667754Smsmith UINT8 *OutputBuffer, 47767754Smsmith UINT32 *OutputBufferLength) 47867754Smsmith{ 47967754Smsmith ACPI_STATUS Status; 48067754Smsmith UINT32 ByteStreamSizeNeeded = 0; 48167754Smsmith 48267754Smsmith 48367754Smsmith FUNCTION_TRACE ("RsCreateByteStream"); 48467754Smsmith 48567754Smsmith 48667754Smsmith DEBUG_PRINT (VERBOSE_INFO, 48767754Smsmith ("RsCreateByteStream: LinkedListBuffer = %p\n", 48867754Smsmith LinkedListBuffer)); 48967754Smsmith 49067754Smsmith /* 49167754Smsmith * Params already validated, so we don't re-validate here 49267754Smsmith * 49367754Smsmith * Pass the LinkedListBuffer into a module that can calculate 49467754Smsmith * the buffer size needed for the byte stream. 49567754Smsmith */ 49667754Smsmith Status = AcpiRsCalculateByteStreamLength (LinkedListBuffer, 49767754Smsmith &ByteStreamSizeNeeded); 49867754Smsmith 49967754Smsmith DEBUG_PRINT (VERBOSE_INFO, 50067754Smsmith ("RsCreateByteStream: ByteStreamSizeNeeded=%d, %s\n", 50167754Smsmith ByteStreamSizeNeeded, 50267754Smsmith AcpiCmFormatException (Status))); 50367754Smsmith 50467754Smsmith /* 50567754Smsmith * Exit with the error passed back 50667754Smsmith */ 50767754Smsmith if (ACPI_FAILURE (Status)) 50867754Smsmith { 50967754Smsmith return_ACPI_STATUS (Status); 51067754Smsmith } 51167754Smsmith 51267754Smsmith /* 51367754Smsmith * If the linked list will fit into the available buffer 51467754Smsmith * call to fill in the list 51567754Smsmith */ 51667754Smsmith 51767754Smsmith if (ByteStreamSizeNeeded <= *OutputBufferLength) 51867754Smsmith { 51967754Smsmith /* 52067754Smsmith * Zero out the return buffer before proceeding 52167754Smsmith */ 52267754Smsmith MEMSET (OutputBuffer, 0x00, *OutputBufferLength); 52367754Smsmith 52467754Smsmith Status = AcpiRsListToByteStream (LinkedListBuffer, 52567754Smsmith ByteStreamSizeNeeded, 52667754Smsmith &OutputBuffer); 52767754Smsmith 52867754Smsmith /* 52967754Smsmith * Exit with the error passed back 53067754Smsmith */ 53167754Smsmith if (ACPI_FAILURE (Status)) 53267754Smsmith { 53367754Smsmith return_ACPI_STATUS (Status); 53467754Smsmith } 53567754Smsmith 53667754Smsmith DEBUG_PRINT (VERBOSE_INFO, 53767754Smsmith ("RsListToByteStream: OutputBuffer = %p\n", 53867754Smsmith OutputBuffer)); 53967754Smsmith } 54067754Smsmith else 54167754Smsmith { 54267754Smsmith *OutputBufferLength = ByteStreamSizeNeeded; 54367754Smsmith return_ACPI_STATUS (AE_BUFFER_OVERFLOW); 54467754Smsmith } 54567754Smsmith 54667754Smsmith return_ACPI_STATUS (AE_OK); 54767754Smsmith} 54867754Smsmith 549