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 *
5767754Smsmith * FUNCTION:    AcpiRsCreateResourceList
5867754Smsmith *
59151937Sjkim * PARAMETERS:  AmlBuffer           - Pointer to the resource byte stream
60151937Sjkim *              OutputBuffer        - Pointer to the user's buffer
6167754Smsmith *
62151937Sjkim * RETURN:      Status: AE_OK if okay, else a valid ACPI_STATUS code
6367754Smsmith *              If OutputBuffer is not large enough, OutputBufferLength
6467754Smsmith *              indicates how large OutputBuffer should be, else it
6567754Smsmith *              indicates how may UINT8 elements of OutputBuffer are valid.
6667754Smsmith *
6767754Smsmith * DESCRIPTION: Takes the byte stream returned from a _CRS, _PRS control method
6867754Smsmith *              execution and parses the stream to create a linked list
6967754Smsmith *              of device resources.
7067754Smsmith *
7167754Smsmith ******************************************************************************/
7267754Smsmith
7367754SmsmithACPI_STATUS
7467754SmsmithAcpiRsCreateResourceList (
75151937Sjkim    ACPI_OPERAND_OBJECT     *AmlBuffer,
7691116Smsmith    ACPI_BUFFER             *OutputBuffer)
7767754Smsmith{
7867754Smsmith
7967754Smsmith    ACPI_STATUS             Status;
80151937Sjkim    UINT8                   *AmlStart;
8191116Smsmith    ACPI_SIZE               ListSizeNeeded = 0;
82151937Sjkim    UINT32                  AmlBufferLength;
83167802Sjkim    void                    *Resource;
8467754Smsmith
8567754Smsmith
86167802Sjkim    ACPI_FUNCTION_TRACE (RsCreateResourceList);
8767754Smsmith
8867754Smsmith
89151937Sjkim    ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlBuffer = %p\n",
90151937Sjkim        AmlBuffer));
9167754Smsmith
92151937Sjkim    /* Params already validated, so we don't re-validate here */
9367754Smsmith
94151937Sjkim    AmlBufferLength = AmlBuffer->Buffer.Length;
95151937Sjkim    AmlStart = AmlBuffer->Buffer.Pointer;
96151937Sjkim
9767754Smsmith    /*
98151937Sjkim     * Pass the AmlBuffer into a module that can calculate
9967754Smsmith     * the buffer size needed for the linked list
10067754Smsmith     */
101151937Sjkim    Status = AcpiRsGetListLength (AmlStart, AmlBufferLength,
10277424Smsmith                &ListSizeNeeded);
10367754Smsmith
10482367Smsmith    ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Status=%X ListSizeNeeded=%X\n",
10599679Siwasaki        Status, (UINT32) ListSizeNeeded));
10667754Smsmith    if (ACPI_FAILURE (Status))
10767754Smsmith    {
10867754Smsmith        return_ACPI_STATUS (Status);
10967754Smsmith    }
11067754Smsmith
11191116Smsmith    /* Validate/Allocate/Clear caller buffer */
11291116Smsmith
11391116Smsmith    Status = AcpiUtInitializeBuffer (OutputBuffer, ListSizeNeeded);
11491116Smsmith    if (ACPI_FAILURE (Status))
11567754Smsmith    {
11691116Smsmith        return_ACPI_STATUS (Status);
11787031Smsmith    }
11867754Smsmith
11991116Smsmith    /* Do the conversion */
12067754Smsmith
121167802Sjkim    Resource = OutputBuffer->Pointer;
122167802Sjkim    Status = AcpiUtWalkAmlResources (AmlStart, AmlBufferLength,
123167802Sjkim                AcpiRsConvertAmlToResources, &Resource);
12487031Smsmith    if (ACPI_FAILURE (Status))
12567754Smsmith    {
12687031Smsmith        return_ACPI_STATUS (Status);
12767754Smsmith    }
12867754Smsmith
12991116Smsmith    ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
13099679Siwasaki            OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
13167754Smsmith    return_ACPI_STATUS (AE_OK);
13267754Smsmith}
13367754Smsmith
13467754Smsmith
13567754Smsmith/*******************************************************************************
13667754Smsmith *
13767754Smsmith * FUNCTION:    AcpiRsCreatePciRoutingTable
13867754Smsmith *
13977424Smsmith * PARAMETERS:  PackageObject           - Pointer to an ACPI_OPERAND_OBJECT
14077424Smsmith *                                        package
14167754Smsmith *              OutputBuffer            - Pointer to the user's buffer
14267754Smsmith *
14367754Smsmith * RETURN:      Status  AE_OK if okay, else a valid ACPI_STATUS code.
14467754Smsmith *              If the OutputBuffer is too small, the error will be
14591116Smsmith *              AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
14667754Smsmith *              to the size buffer needed.
14767754Smsmith *
14867754Smsmith * DESCRIPTION: Takes the ACPI_OPERAND_OBJECT  package and creates a
14967754Smsmith *              linked list of PCI interrupt descriptions
15067754Smsmith *
15191116Smsmith * NOTE: It is the caller's responsibility to ensure that the start of the
15291116Smsmith * output buffer is aligned properly (if necessary).
15391116Smsmith *
15467754Smsmith ******************************************************************************/
15567754Smsmith
15667754SmsmithACPI_STATUS
15767754SmsmithAcpiRsCreatePciRoutingTable (
15867754Smsmith    ACPI_OPERAND_OBJECT     *PackageObject,
15991116Smsmith    ACPI_BUFFER             *OutputBuffer)
16067754Smsmith{
16191116Smsmith    UINT8                   *Buffer;
162107325Siwasaki    ACPI_OPERAND_OBJECT     **TopObjectList;
163107325Siwasaki    ACPI_OPERAND_OBJECT     **SubObjectList;
164107325Siwasaki    ACPI_OPERAND_OBJECT     *ObjDesc;
16591116Smsmith    ACPI_SIZE               BufferSizeNeeded = 0;
166107325Siwasaki    UINT32                  NumberOfElements;
167107325Siwasaki    UINT32                  Index;
168107325Siwasaki    ACPI_PCI_ROUTING_TABLE  *UserPrt;
16973561Smsmith    ACPI_NAMESPACE_NODE     *Node;
17067754Smsmith    ACPI_STATUS             Status;
17191116Smsmith    ACPI_BUFFER             PathBuffer;
17267754Smsmith
17367754Smsmith
174167802Sjkim    ACPI_FUNCTION_TRACE (RsCreatePciRoutingTable);
17567754Smsmith
17667754Smsmith
17791116Smsmith    /* Params already validated, so we don't re-validate here */
17891116Smsmith
179151937Sjkim    /* Get the required buffer length */
180151937Sjkim
18199679Siwasaki    Status = AcpiRsGetPciRoutingTableLength (PackageObject,
18277424Smsmith                &BufferSizeNeeded);
18391116Smsmith    if (ACPI_FAILURE (Status))
18477424Smsmith    {
18577424Smsmith        return_ACPI_STATUS (Status);
18677424Smsmith    }
18767754Smsmith
188114237Snjl    ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "BufferSizeNeeded = %X\n",
189107325Siwasaki        (UINT32) BufferSizeNeeded));
19077424Smsmith
19191116Smsmith    /* Validate/Allocate/Clear caller buffer */
19287031Smsmith
19391116Smsmith    Status = AcpiUtInitializeBuffer (OutputBuffer, BufferSizeNeeded);
19491116Smsmith    if (ACPI_FAILURE (Status))
19587031Smsmith    {
19691116Smsmith        return_ACPI_STATUS (Status);
19787031Smsmith    }
19887031Smsmith
19967754Smsmith    /*
200193267Sjkim     * Loop through the ACPI_INTERNAL_OBJECTS - Each object should be a
201202771Sjkim     * package that in turn contains an UINT64 Address, a UINT8 Pin,
202193267Sjkim     * a Name, and a UINT8 SourceIndex.
20367754Smsmith     */
20487031Smsmith    TopObjectList    = PackageObject->Package.Elements;
20587031Smsmith    NumberOfElements = PackageObject->Package.Count;
20691116Smsmith    Buffer           = OutputBuffer->Pointer;
20799679Siwasaki    UserPrt          = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
20887031Smsmith
20987031Smsmith    for (Index = 0; Index < NumberOfElements; Index++)
21067754Smsmith    {
21167754Smsmith        /*
21287031Smsmith         * Point UserPrt past this current structure
21387031Smsmith         *
21487031Smsmith         * NOTE: On the first iteration, UserPrt->Length will
21587031Smsmith         * be zero because we cleared the return buffer earlier
21667754Smsmith         */
21787031Smsmith        Buffer += UserPrt->Length;
21899679Siwasaki        UserPrt = ACPI_CAST_PTR (ACPI_PCI_ROUTING_TABLE, Buffer);
21967754Smsmith
22067754Smsmith        /*
22191116Smsmith         * Fill in the Length field with the information we have at this point.
22291116Smsmith         * The minus four is to subtract the size of the UINT8 Source[4] member
22391116Smsmith         * because it is added below.
22467754Smsmith         */
225107325Siwasaki        UserPrt->Length = (sizeof (ACPI_PCI_ROUTING_TABLE) - 4);
22667754Smsmith
227151937Sjkim        /* Each element of the top-level package must also be a package */
228151937Sjkim
229193267Sjkim        if ((*TopObjectList)->Common.Type != ACPI_TYPE_PACKAGE)
230107325Siwasaki        {
231167802Sjkim            ACPI_ERROR ((AE_INFO,
232204773Sjkim                "(PRT[%u]) Need sub-package, found %s",
233107325Siwasaki                Index, AcpiUtGetObjectTypeName (*TopObjectList)));
234107325Siwasaki            return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
235107325Siwasaki        }
23669450Smsmith
237107325Siwasaki        /* Each sub-package must be of length 4 */
238107325Siwasaki
239107325Siwasaki        if ((*TopObjectList)->Package.Count != 4)
240107325Siwasaki        {
241167802Sjkim            ACPI_ERROR ((AE_INFO,
242204773Sjkim                "(PRT[%u]) Need package of length 4, found length %u",
243107325Siwasaki                Index, (*TopObjectList)->Package.Count));
244107325Siwasaki            return_ACPI_STATUS (AE_AML_PACKAGE_LIMIT);
245107325Siwasaki        }
246107325Siwasaki
24787031Smsmith        /*
248107325Siwasaki         * Dereference the sub-package.
24991116Smsmith         * The SubObjectList will now point to an array of the four IRQ
250107325Siwasaki         * elements: [Address, Pin, Source, SourceIndex]
25187031Smsmith         */
252107325Siwasaki        SubObjectList = (*TopObjectList)->Package.Elements;
25369450Smsmith
254151937Sjkim        /* 1) First subobject: Dereference the PRT.Address */
255151937Sjkim
256107325Siwasaki        ObjDesc = SubObjectList[0];
257193267Sjkim        if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
25867754Smsmith        {
259204773Sjkim            ACPI_ERROR ((AE_INFO, "(PRT[%u].Address) Need Integer, found %s",
260107325Siwasaki                Index, AcpiUtGetObjectTypeName (ObjDesc)));
26187031Smsmith            return_ACPI_STATUS (AE_BAD_DATA);
26287031Smsmith        }
26367754Smsmith
264193267Sjkim        UserPrt->Address = ObjDesc->Integer.Value;
265193267Sjkim
266151937Sjkim        /* 2) Second subobject: Dereference the PRT.Pin */
267151937Sjkim
268107325Siwasaki        ObjDesc = SubObjectList[1];
269193267Sjkim        if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
27087031Smsmith        {
271204773Sjkim            ACPI_ERROR ((AE_INFO, "(PRT[%u].Pin) Need Integer, found %s",
272107325Siwasaki                Index, AcpiUtGetObjectTypeName (ObjDesc)));
27387031Smsmith            return_ACPI_STATUS (AE_BAD_DATA);
27487031Smsmith        }
27567754Smsmith
276193267Sjkim        UserPrt->Pin = (UINT32) ObjDesc->Integer.Value;
277193267Sjkim
278167802Sjkim        /*
279193267Sjkim         * If the BIOS has erroneously reversed the _PRT SourceName (index 2)
280193267Sjkim         * and the SourceIndex (index 3), fix it. _PRT is important enough to
281193267Sjkim         * workaround this BIOS error. This also provides compatibility with
282193267Sjkim         * other ACPI implementations.
283193267Sjkim         */
284193267Sjkim        ObjDesc = SubObjectList[3];
285193267Sjkim        if (!ObjDesc || (ObjDesc->Common.Type != ACPI_TYPE_INTEGER))
286193267Sjkim        {
287193267Sjkim            SubObjectList[3] = SubObjectList[2];
288193267Sjkim            SubObjectList[2] = ObjDesc;
289193267Sjkim
290193267Sjkim            ACPI_WARNING ((AE_INFO,
291193267Sjkim                "(PRT[%X].Source) SourceName and SourceIndex are reversed, fixed",
292193267Sjkim                Index));
293193267Sjkim        }
294193267Sjkim
295193267Sjkim        /*
296167802Sjkim         * 3) Third subobject: Dereference the PRT.SourceName
297167802Sjkim         * The name may be unresolved (slack mode), so allow a null object
298167802Sjkim         */
299107325Siwasaki        ObjDesc = SubObjectList[2];
300167802Sjkim        if (ObjDesc)
30187031Smsmith        {
302193267Sjkim            switch (ObjDesc->Common.Type)
30367754Smsmith            {
304167802Sjkim            case ACPI_TYPE_LOCAL_REFERENCE:
30567754Smsmith
306193267Sjkim                if (ObjDesc->Reference.Class != ACPI_REFCLASS_NAME)
307167802Sjkim                {
308167802Sjkim                    ACPI_ERROR ((AE_INFO,
309204773Sjkim                        "(PRT[%u].Source) Need name, found Reference Class 0x%X",
310193267Sjkim                        Index, ObjDesc->Reference.Class));
311167802Sjkim                    return_ACPI_STATUS (AE_BAD_DATA);
312167802Sjkim                }
31367754Smsmith
314167802Sjkim                Node = ObjDesc->Reference.Node;
31567754Smsmith
316167802Sjkim                /* Use *remaining* length of the buffer as max for pathname */
31767754Smsmith
318167802Sjkim                PathBuffer.Length = OutputBuffer->Length -
319167802Sjkim                                    (UINT32) ((UINT8 *) UserPrt->Source -
320167802Sjkim                                    (UINT8 *) OutputBuffer->Pointer);
321167802Sjkim                PathBuffer.Pointer = UserPrt->Source;
32267754Smsmith
323167802Sjkim                Status = AcpiNsHandleToPathname ((ACPI_HANDLE) Node, &PathBuffer);
324151937Sjkim
325167802Sjkim                /* +1 to include null terminator */
32677424Smsmith
327167802Sjkim                UserPrt->Length += (UINT32) ACPI_STRLEN (UserPrt->Source) + 1;
328167802Sjkim                break;
32973561Smsmith
33073561Smsmith
331167802Sjkim            case ACPI_TYPE_STRING:
33273561Smsmith
333167802Sjkim                ACPI_STRCPY (UserPrt->Source, ObjDesc->String.Pointer);
33473561Smsmith
335167802Sjkim                /*
336167802Sjkim                 * Add to the Length field the length of the string
337167802Sjkim                 * (add 1 for terminator)
338167802Sjkim                 */
339167802Sjkim                UserPrt->Length += ObjDesc->String.Length + 1;
340167802Sjkim                break;
34173561Smsmith
34273561Smsmith
343167802Sjkim            case ACPI_TYPE_INTEGER:
344167802Sjkim                /*
345167802Sjkim                 * If this is a number, then the Source Name is NULL, since the
346167802Sjkim                 * entire buffer was zeroed out, we can leave this alone.
347167802Sjkim                 *
348167802Sjkim                 * Add to the Length field the length of the UINT32 NULL
349167802Sjkim                 */
350167802Sjkim                UserPrt->Length += sizeof (UINT32);
351167802Sjkim                break;
35273561Smsmith
35367754Smsmith
354167802Sjkim            default:
355167802Sjkim
356167802Sjkim               ACPI_ERROR ((AE_INFO,
357204773Sjkim                   "(PRT[%u].Source) Need Ref/String/Integer, found %s",
358167802Sjkim                   Index, AcpiUtGetObjectTypeName (ObjDesc)));
359167802Sjkim               return_ACPI_STATUS (AE_BAD_DATA);
360167802Sjkim            }
36187031Smsmith        }
36267754Smsmith
36387031Smsmith        /* Now align the current length */
36473561Smsmith
365167802Sjkim        UserPrt->Length = (UINT32) ACPI_ROUND_UP_TO_64BIT (UserPrt->Length);
36667754Smsmith
367151937Sjkim        /* 4) Fourth subobject: Dereference the PRT.SourceIndex */
368151937Sjkim
369107325Siwasaki        ObjDesc = SubObjectList[3];
370193267Sjkim        if (ObjDesc->Common.Type != ACPI_TYPE_INTEGER)
37187031Smsmith        {
372167802Sjkim            ACPI_ERROR ((AE_INFO,
373204773Sjkim                "(PRT[%u].SourceIndex) Need Integer, found %s",
374107325Siwasaki                Index, AcpiUtGetObjectTypeName (ObjDesc)));
37587031Smsmith            return_ACPI_STATUS (AE_BAD_DATA);
37687031Smsmith        }
37767754Smsmith
378193267Sjkim        UserPrt->SourceIndex = (UINT32) ObjDesc->Integer.Value;
379193267Sjkim
380107325Siwasaki        /* Point to the next ACPI_OPERAND_OBJECT in the top level package */
38191116Smsmith
38287031Smsmith        TopObjectList++;
38367754Smsmith    }
38467754Smsmith
38591116Smsmith    ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
38699679Siwasaki            OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
38767754Smsmith    return_ACPI_STATUS (AE_OK);
38867754Smsmith}
38967754Smsmith
39067754Smsmith
39167754Smsmith/*******************************************************************************
39267754Smsmith *
393151937Sjkim * FUNCTION:    AcpiRsCreateAmlResources
39467754Smsmith *
39577424Smsmith * PARAMETERS:  LinkedListBuffer        - Pointer to the resource linked list
39667754Smsmith *              OutputBuffer            - Pointer to the user's buffer
39767754Smsmith *
39867754Smsmith * RETURN:      Status  AE_OK if okay, else a valid ACPI_STATUS code.
39967754Smsmith *              If the OutputBuffer is too small, the error will be
40091116Smsmith *              AE_BUFFER_OVERFLOW and OutputBuffer->Length will point
40167754Smsmith *              to the size buffer needed.
40267754Smsmith *
40367754Smsmith * DESCRIPTION: Takes the linked list of device resources and
40467754Smsmith *              creates a bytestream to be used as input for the
40567754Smsmith *              _SRS control method.
40667754Smsmith *
40767754Smsmith ******************************************************************************/
40867754Smsmith
40967754SmsmithACPI_STATUS
410151937SjkimAcpiRsCreateAmlResources (
41177424Smsmith    ACPI_RESOURCE           *LinkedListBuffer,
41291116Smsmith    ACPI_BUFFER             *OutputBuffer)
41367754Smsmith{
41467754Smsmith    ACPI_STATUS             Status;
415151937Sjkim    ACPI_SIZE               AmlSizeNeeded = 0;
41667754Smsmith
41767754Smsmith
418167802Sjkim    ACPI_FUNCTION_TRACE (RsCreateAmlResources);
41967754Smsmith
42067754Smsmith
421114237Snjl    ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "LinkedListBuffer = %p\n",
422107325Siwasaki        LinkedListBuffer));
42367754Smsmith
42467754Smsmith    /*
42567754Smsmith     * Params already validated, so we don't re-validate here
42667754Smsmith     *
42787031Smsmith     * Pass the LinkedListBuffer into a module that calculates
42867754Smsmith     * the buffer size needed for the byte stream.
42967754Smsmith     */
430151937Sjkim    Status = AcpiRsGetAmlLength (LinkedListBuffer,
431151937Sjkim                &AmlSizeNeeded);
43267754Smsmith
433151937Sjkim    ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AmlSizeNeeded=%X, %s\n",
434151937Sjkim        (UINT32) AmlSizeNeeded, AcpiFormatException (Status)));
43567754Smsmith    if (ACPI_FAILURE (Status))
43667754Smsmith    {
43767754Smsmith        return_ACPI_STATUS (Status);
43867754Smsmith    }
43967754Smsmith
44091116Smsmith    /* Validate/Allocate/Clear caller buffer */
44191116Smsmith
442151937Sjkim    Status = AcpiUtInitializeBuffer (OutputBuffer, AmlSizeNeeded);
44391116Smsmith    if (ACPI_FAILURE (Status))
44467754Smsmith    {
44591116Smsmith        return_ACPI_STATUS (Status);
44687031Smsmith    }
44767754Smsmith
44891116Smsmith    /* Do the conversion */
44967754Smsmith
450151937Sjkim    Status = AcpiRsConvertResourcesToAml (LinkedListBuffer, AmlSizeNeeded,
45191116Smsmith                    OutputBuffer->Pointer);
45287031Smsmith    if (ACPI_FAILURE (Status))
45367754Smsmith    {
45487031Smsmith        return_ACPI_STATUS (Status);
45567754Smsmith    }
45667754Smsmith
45791116Smsmith    ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "OutputBuffer %p Length %X\n",
45899679Siwasaki            OutputBuffer->Pointer, (UINT32) OutputBuffer->Length));
45967754Smsmith    return_ACPI_STATUS (AE_OK);
46067754Smsmith}
46167754Smsmith
462