17c478bd9Sstevel@tonic-gate /*******************************************************************************
27c478bd9Sstevel@tonic-gate  *
37c478bd9Sstevel@tonic-gate  * Module Name: rsxface - Public interfaces to the resource manager
47c478bd9Sstevel@tonic-gate  *
57c478bd9Sstevel@tonic-gate  ******************************************************************************/
67c478bd9Sstevel@tonic-gate 
7*35786f68SRobert Mustacchi /******************************************************************************
8*35786f68SRobert Mustacchi  *
9*35786f68SRobert Mustacchi  * 1. Copyright Notice
10*35786f68SRobert Mustacchi  *
11*35786f68SRobert Mustacchi  * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
127c478bd9Sstevel@tonic-gate  * All rights reserved.
137c478bd9Sstevel@tonic-gate  *
14*35786f68SRobert Mustacchi  * 2. License
15*35786f68SRobert Mustacchi  *
16*35786f68SRobert Mustacchi  * 2.1. This is your license from Intel Corp. under its intellectual property
17*35786f68SRobert Mustacchi  * rights. You may have additional license terms from the party that provided
18*35786f68SRobert Mustacchi  * you this software, covering your right to use that party's intellectual
19*35786f68SRobert Mustacchi  * property rights.
20*35786f68SRobert Mustacchi  *
21*35786f68SRobert Mustacchi  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22*35786f68SRobert Mustacchi  * copy of the source code appearing in this file ("Covered Code") an
23*35786f68SRobert Mustacchi  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24*35786f68SRobert Mustacchi  * base code distributed originally by Intel ("Original Intel Code") to copy,
25*35786f68SRobert Mustacchi  * make derivatives, distribute, use and display any portion of the Covered
26*35786f68SRobert Mustacchi  * Code in any form, with the right to sublicense such rights; and
27*35786f68SRobert Mustacchi  *
28*35786f68SRobert Mustacchi  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29*35786f68SRobert Mustacchi  * license (with the right to sublicense), under only those claims of Intel
30*35786f68SRobert Mustacchi  * patents that are infringed by the Original Intel Code, to make, use, sell,
31*35786f68SRobert Mustacchi  * offer to sell, and import the Covered Code and derivative works thereof
32*35786f68SRobert Mustacchi  * solely to the minimum extent necessary to exercise the above copyright
33*35786f68SRobert Mustacchi  * license, and in no event shall the patent license extend to any additions
34*35786f68SRobert Mustacchi  * to or modifications of the Original Intel Code. No other license or right
35*35786f68SRobert Mustacchi  * is granted directly or by implication, estoppel or otherwise;
36*35786f68SRobert Mustacchi  *
37*35786f68SRobert Mustacchi  * The above copyright and patent license is granted only if the following
38*35786f68SRobert Mustacchi  * conditions are met:
39*35786f68SRobert Mustacchi  *
40*35786f68SRobert Mustacchi  * 3. Conditions
41*35786f68SRobert Mustacchi  *
42*35786f68SRobert Mustacchi  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43*35786f68SRobert Mustacchi  * Redistribution of source code of any substantial portion of the Covered
44*35786f68SRobert Mustacchi  * Code or modification with rights to further distribute source must include
45*35786f68SRobert Mustacchi  * the above Copyright Notice, the above License, this list of Conditions,
46*35786f68SRobert Mustacchi  * and the following Disclaimer and Export Compliance provision. In addition,
47*35786f68SRobert Mustacchi  * Licensee must cause all Covered Code to which Licensee contributes to
48*35786f68SRobert Mustacchi  * contain a file documenting the changes Licensee made to create that Covered
49*35786f68SRobert Mustacchi  * Code and the date of any change. Licensee must include in that file the
50*35786f68SRobert Mustacchi  * documentation of any changes made by any predecessor Licensee. Licensee
51*35786f68SRobert Mustacchi  * must include a prominent statement that the modification is derived,
52*35786f68SRobert Mustacchi  * directly or indirectly, from Original Intel Code.
53*35786f68SRobert Mustacchi  *
54*35786f68SRobert Mustacchi  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55*35786f68SRobert Mustacchi  * Redistribution of source code of any substantial portion of the Covered
56*35786f68SRobert Mustacchi  * Code or modification without rights to further distribute source must
57*35786f68SRobert Mustacchi  * include the following Disclaimer and Export Compliance provision in the
58*35786f68SRobert Mustacchi  * documentation and/or other materials provided with distribution. In
59*35786f68SRobert Mustacchi  * addition, Licensee may not authorize further sublicense of source of any
60*35786f68SRobert Mustacchi  * portion of the Covered Code, and must include terms to the effect that the
61*35786f68SRobert Mustacchi  * license from Licensee to its licensee is limited to the intellectual
62*35786f68SRobert Mustacchi  * property embodied in the software Licensee provides to its licensee, and
63*35786f68SRobert Mustacchi  * not to intellectual property embodied in modifications its licensee may
64*35786f68SRobert Mustacchi  * make.
65*35786f68SRobert Mustacchi  *
66*35786f68SRobert Mustacchi  * 3.3. Redistribution of Executable. Redistribution in executable form of any
67*35786f68SRobert Mustacchi  * substantial portion of the Covered Code or modification must reproduce the
68*35786f68SRobert Mustacchi  * above Copyright Notice, and the following Disclaimer and Export Compliance
69*35786f68SRobert Mustacchi  * provision in the documentation and/or other materials provided with the
70*35786f68SRobert Mustacchi  * distribution.
71*35786f68SRobert Mustacchi  *
72*35786f68SRobert Mustacchi  * 3.4. Intel retains all right, title, and interest in and to the Original
73*35786f68SRobert Mustacchi  * Intel Code.
74*35786f68SRobert Mustacchi  *
75*35786f68SRobert Mustacchi  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76*35786f68SRobert Mustacchi  * Intel shall be used in advertising or otherwise to promote the sale, use or
77*35786f68SRobert Mustacchi  * other dealings in products derived from or relating to the Covered Code
78*35786f68SRobert Mustacchi  * without prior written authorization from Intel.
79*35786f68SRobert Mustacchi  *
80*35786f68SRobert Mustacchi  * 4. Disclaimer and Export Compliance
81*35786f68SRobert Mustacchi  *
82*35786f68SRobert Mustacchi  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83*35786f68SRobert Mustacchi  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84*35786f68SRobert Mustacchi  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85*35786f68SRobert Mustacchi  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86*35786f68SRobert Mustacchi  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87*35786f68SRobert Mustacchi  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88*35786f68SRobert Mustacchi  * PARTICULAR PURPOSE.
89*35786f68SRobert Mustacchi  *
90*35786f68SRobert Mustacchi  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91*35786f68SRobert Mustacchi  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92*35786f68SRobert Mustacchi  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93*35786f68SRobert Mustacchi  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94*35786f68SRobert Mustacchi  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95*35786f68SRobert Mustacchi  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96*35786f68SRobert Mustacchi  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97*35786f68SRobert Mustacchi  * LIMITED REMEDY.
98*35786f68SRobert Mustacchi  *
99*35786f68SRobert Mustacchi  * 4.3. Licensee shall not export, either directly or indirectly, any of this
100*35786f68SRobert Mustacchi  * software or system incorporating such software without first obtaining any
101*35786f68SRobert Mustacchi  * required license or other approval from the U. S. Department of Commerce or
102*35786f68SRobert Mustacchi  * any other agency or department of the United States Government. In the
103*35786f68SRobert Mustacchi  * event Licensee exports any such software from the United States or
104*35786f68SRobert Mustacchi  * re-exports any such software from a foreign destination, Licensee shall
105*35786f68SRobert Mustacchi  * ensure that the distribution and export/re-export of the software is in
106*35786f68SRobert Mustacchi  * compliance with all laws, regulations, orders, or other restrictions of the
107*35786f68SRobert Mustacchi  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108*35786f68SRobert Mustacchi  * any of its subsidiaries will export/re-export any technical data, process,
109*35786f68SRobert Mustacchi  * software, or service, directly or indirectly, to any country for which the
110*35786f68SRobert Mustacchi  * United States government or any agency thereof requires an export license,
111*35786f68SRobert Mustacchi  * other governmental approval, or letter of assurance, without first obtaining
112*35786f68SRobert Mustacchi  * such license, approval or letter.
113*35786f68SRobert Mustacchi  *
114*35786f68SRobert Mustacchi  *****************************************************************************
115*35786f68SRobert Mustacchi  *
116*35786f68SRobert Mustacchi  * Alternatively, you may choose to be licensed under the terms of the
117*35786f68SRobert Mustacchi  * following license:
118*35786f68SRobert Mustacchi  *
11926f3cdf0SGordon Ross  * Redistribution and use in source and binary forms, with or without
12026f3cdf0SGordon Ross  * modification, are permitted provided that the following conditions
12126f3cdf0SGordon Ross  * are met:
12226f3cdf0SGordon Ross  * 1. Redistributions of source code must retain the above copyright
12326f3cdf0SGordon Ross  *    notice, this list of conditions, and the following disclaimer,
12426f3cdf0SGordon Ross  *    without modification.
12526f3cdf0SGordon Ross  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
12626f3cdf0SGordon Ross  *    substantially similar to the "NO WARRANTY" disclaimer below
12726f3cdf0SGordon Ross  *    ("Disclaimer") and any redistribution must be conditioned upon
12826f3cdf0SGordon Ross  *    including a substantially similar Disclaimer requirement for further
12926f3cdf0SGordon Ross  *    binary redistribution.
13026f3cdf0SGordon Ross  * 3. Neither the names of the above-listed copyright holders nor the names
13126f3cdf0SGordon Ross  *    of any contributors may be used to endorse or promote products derived
13226f3cdf0SGordon Ross  *    from this software without specific prior written permission.
13326f3cdf0SGordon Ross  *
13426f3cdf0SGordon Ross  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
13526f3cdf0SGordon Ross  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136*35786f68SRobert Mustacchi  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
13726f3cdf0SGordon Ross  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138*35786f68SRobert Mustacchi  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139*35786f68SRobert Mustacchi  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140*35786f68SRobert Mustacchi  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141*35786f68SRobert Mustacchi  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142*35786f68SRobert Mustacchi  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143*35786f68SRobert Mustacchi  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144*35786f68SRobert Mustacchi  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145*35786f68SRobert Mustacchi  *
146*35786f68SRobert Mustacchi  * Alternatively, you may choose to be licensed under the terms of the
147*35786f68SRobert Mustacchi  * GNU General Public License ("GPL") version 2 as published by the Free
148*35786f68SRobert Mustacchi  * Software Foundation.
149*35786f68SRobert Mustacchi  *
150*35786f68SRobert Mustacchi  *****************************************************************************/
1517c478bd9Sstevel@tonic-gate 
1527b1019a6SJerry Jelinek #define EXPORT_ACPI_INTERFACES
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate #include "acpi.h"
155aa2aa9a6SDana Myers #include "accommon.h"
1567c478bd9Sstevel@tonic-gate #include "acresrc.h"
15727f7c583Smyers #include "acnamesp.h"
1587c478bd9Sstevel@tonic-gate 
1597c478bd9Sstevel@tonic-gate #define _COMPONENT          ACPI_RESOURCES
1607c478bd9Sstevel@tonic-gate         ACPI_MODULE_NAME    ("rsxface")
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate /* Local macros for 16,32-bit to 64-bit conversion */
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate #define ACPI_COPY_FIELD(Out, In, Field)  ((Out)->Field = (In)->Field)
1657b1019a6SJerry Jelinek #define ACPI_COPY_ADDRESS(Out, In)                       \
1667c478bd9Sstevel@tonic-gate     ACPI_COPY_FIELD(Out, In, ResourceType);              \
1677c478bd9Sstevel@tonic-gate     ACPI_COPY_FIELD(Out, In, ProducerConsumer);          \
1687c478bd9Sstevel@tonic-gate     ACPI_COPY_FIELD(Out, In, Decode);                    \
1697c478bd9Sstevel@tonic-gate     ACPI_COPY_FIELD(Out, In, MinAddressFixed);           \
1707c478bd9Sstevel@tonic-gate     ACPI_COPY_FIELD(Out, In, MaxAddressFixed);           \
17130082d0cSmyers     ACPI_COPY_FIELD(Out, In, Info);                      \
1727b1019a6SJerry Jelinek     ACPI_COPY_FIELD(Out, In, Address.Granularity);       \
1737b1019a6SJerry Jelinek     ACPI_COPY_FIELD(Out, In, Address.Minimum);           \
1747b1019a6SJerry Jelinek     ACPI_COPY_FIELD(Out, In, Address.Maximum);           \
1757b1019a6SJerry Jelinek     ACPI_COPY_FIELD(Out, In, Address.TranslationOffset); \
1767b1019a6SJerry Jelinek     ACPI_COPY_FIELD(Out, In, Address.AddressLength);     \
1777c478bd9Sstevel@tonic-gate     ACPI_COPY_FIELD(Out, In, ResourceSource);
1787c478bd9Sstevel@tonic-gate 
1797c478bd9Sstevel@tonic-gate 
18030082d0cSmyers /* Local prototypes */
18130082d0cSmyers 
18230082d0cSmyers static ACPI_STATUS
18330082d0cSmyers AcpiRsMatchVendorResource (
18430082d0cSmyers     ACPI_RESOURCE           *Resource,
18530082d0cSmyers     void                    *Context);
18630082d0cSmyers 
18727f7c583Smyers static ACPI_STATUS
18827f7c583Smyers AcpiRsValidateParameters (
18927f7c583Smyers     ACPI_HANDLE             DeviceHandle,
19027f7c583Smyers     ACPI_BUFFER             *Buffer,
19127f7c583Smyers     ACPI_NAMESPACE_NODE     **ReturnNode);
19227f7c583Smyers 
19330082d0cSmyers 
1947c478bd9Sstevel@tonic-gate /*******************************************************************************
1957c478bd9Sstevel@tonic-gate  *
19627f7c583Smyers  * FUNCTION:    AcpiRsValidateParameters
1977c478bd9Sstevel@tonic-gate  *
19827f7c583Smyers  * PARAMETERS:  DeviceHandle    - Handle to a device
19927f7c583Smyers  *              Buffer          - Pointer to a data buffer
20027f7c583Smyers  *              ReturnNode      - Pointer to where the device node is returned
2017c478bd9Sstevel@tonic-gate  *
2027c478bd9Sstevel@tonic-gate  * RETURN:      Status
2037c478bd9Sstevel@tonic-gate  *
20427f7c583Smyers  * DESCRIPTION: Common parameter validation for resource interfaces
2057c478bd9Sstevel@tonic-gate  *
2067c478bd9Sstevel@tonic-gate  ******************************************************************************/
2077c478bd9Sstevel@tonic-gate 
20827f7c583Smyers static ACPI_STATUS
AcpiRsValidateParameters(ACPI_HANDLE DeviceHandle,ACPI_BUFFER * Buffer,ACPI_NAMESPACE_NODE ** ReturnNode)20927f7c583Smyers AcpiRsValidateParameters (
2107c478bd9Sstevel@tonic-gate     ACPI_HANDLE             DeviceHandle,
21127f7c583Smyers     ACPI_BUFFER             *Buffer,
21227f7c583Smyers     ACPI_NAMESPACE_NODE     **ReturnNode)
2137c478bd9Sstevel@tonic-gate {
2147c478bd9Sstevel@tonic-gate     ACPI_STATUS             Status;
21527f7c583Smyers     ACPI_NAMESPACE_NODE     *Node;
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate 
21827f7c583Smyers     ACPI_FUNCTION_TRACE (RsValidateParameters);
2197c478bd9Sstevel@tonic-gate 
2207c478bd9Sstevel@tonic-gate 
2217c478bd9Sstevel@tonic-gate     /*
22227f7c583Smyers      * Must have a valid handle to an ACPI device
2237c478bd9Sstevel@tonic-gate      */
2247c478bd9Sstevel@tonic-gate     if (!DeviceHandle)
2257c478bd9Sstevel@tonic-gate     {
2267c478bd9Sstevel@tonic-gate         return_ACPI_STATUS (AE_BAD_PARAMETER);
2277c478bd9Sstevel@tonic-gate     }
2287c478bd9Sstevel@tonic-gate 
22926f3cdf0SGordon Ross     Node = AcpiNsValidateHandle (DeviceHandle);
23027f7c583Smyers     if (!Node)
23127f7c583Smyers     {
23227f7c583Smyers         return_ACPI_STATUS (AE_BAD_PARAMETER);
23327f7c583Smyers     }
23427f7c583Smyers 
23527f7c583Smyers     if (Node->Type != ACPI_TYPE_DEVICE)
23627f7c583Smyers     {
23727f7c583Smyers         return_ACPI_STATUS (AE_TYPE);
23827f7c583Smyers     }
23927f7c583Smyers 
24027f7c583Smyers     /*
24127f7c583Smyers      * Validate the user buffer object
24227f7c583Smyers      *
24327f7c583Smyers      * if there is a non-zero buffer length we also need a valid pointer in
24427f7c583Smyers      * the buffer. If it's a zero buffer length, we'll be returning the
24527f7c583Smyers      * needed buffer size (later), so keep going.
24627f7c583Smyers      */
24727f7c583Smyers     Status = AcpiUtValidateBuffer (Buffer);
2487c478bd9Sstevel@tonic-gate     if (ACPI_FAILURE (Status))
2497c478bd9Sstevel@tonic-gate     {
2507c478bd9Sstevel@tonic-gate         return_ACPI_STATUS (Status);
2517c478bd9Sstevel@tonic-gate     }
2527c478bd9Sstevel@tonic-gate 
25327f7c583Smyers     *ReturnNode = Node;
25427f7c583Smyers     return_ACPI_STATUS (AE_OK);
2557c478bd9Sstevel@tonic-gate }
2567c478bd9Sstevel@tonic-gate 
2577c478bd9Sstevel@tonic-gate 
2587c478bd9Sstevel@tonic-gate /*******************************************************************************
2597c478bd9Sstevel@tonic-gate  *
26027f7c583Smyers  * FUNCTION:    AcpiGetIrqRoutingTable
2617c478bd9Sstevel@tonic-gate  *
26227f7c583Smyers  * PARAMETERS:  DeviceHandle    - Handle to the Bus device we are querying
26327f7c583Smyers  *              RetBuffer       - Pointer to a buffer to receive the
2647c478bd9Sstevel@tonic-gate  *                                current resources for the device
2657c478bd9Sstevel@tonic-gate  *
2667c478bd9Sstevel@tonic-gate  * RETURN:      Status
2677c478bd9Sstevel@tonic-gate  *
26827f7c583Smyers  * DESCRIPTION: This function is called to get the IRQ routing table for a
26927f7c583Smyers  *              specific bus. The caller must first acquire a handle for the
27027f7c583Smyers  *              desired bus. The routine table is placed in the buffer pointed
27127f7c583Smyers  *              to by the RetBuffer variable parameter.
2727c478bd9Sstevel@tonic-gate  *
2737c478bd9Sstevel@tonic-gate  *              If the function fails an appropriate status will be returned
2747c478bd9Sstevel@tonic-gate  *              and the value of RetBuffer is undefined.
2757c478bd9Sstevel@tonic-gate  *
27627f7c583Smyers  *              This function attempts to execute the _PRT method contained in
2777c478bd9Sstevel@tonic-gate  *              the object indicated by the passed DeviceHandle.
2787c478bd9Sstevel@tonic-gate  *
2797c478bd9Sstevel@tonic-gate  ******************************************************************************/
2807c478bd9Sstevel@tonic-gate 
2817c478bd9Sstevel@tonic-gate ACPI_STATUS
AcpiGetIrqRoutingTable(ACPI_HANDLE DeviceHandle,ACPI_BUFFER * RetBuffer)28227f7c583Smyers AcpiGetIrqRoutingTable  (
2837c478bd9Sstevel@tonic-gate     ACPI_HANDLE             DeviceHandle,
2847c478bd9Sstevel@tonic-gate     ACPI_BUFFER             *RetBuffer)
2857c478bd9Sstevel@tonic-gate {
2867c478bd9Sstevel@tonic-gate     ACPI_STATUS             Status;
28727f7c583Smyers     ACPI_NAMESPACE_NODE     *Node;
2887c478bd9Sstevel@tonic-gate 
2897c478bd9Sstevel@tonic-gate 
29027f7c583Smyers     ACPI_FUNCTION_TRACE (AcpiGetIrqRoutingTable);
2917c478bd9Sstevel@tonic-gate 
2927c478bd9Sstevel@tonic-gate 
29327f7c583Smyers     /* Validate parameters then dispatch to internal routine */
2947c478bd9Sstevel@tonic-gate 
29527f7c583Smyers     Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
2967c478bd9Sstevel@tonic-gate     if (ACPI_FAILURE (Status))
2977c478bd9Sstevel@tonic-gate     {
2987c478bd9Sstevel@tonic-gate         return_ACPI_STATUS (Status);
2997c478bd9Sstevel@tonic-gate     }
3007c478bd9Sstevel@tonic-gate 
30127f7c583Smyers     Status = AcpiRsGetPrtMethodData (Node, RetBuffer);
3027c478bd9Sstevel@tonic-gate     return_ACPI_STATUS (Status);
3037c478bd9Sstevel@tonic-gate }
3047c478bd9Sstevel@tonic-gate 
ACPI_EXPORT_SYMBOL(AcpiGetIrqRoutingTable)30527f7c583Smyers ACPI_EXPORT_SYMBOL (AcpiGetIrqRoutingTable)
30627f7c583Smyers 
3077c478bd9Sstevel@tonic-gate 
3087c478bd9Sstevel@tonic-gate /*******************************************************************************
3097c478bd9Sstevel@tonic-gate  *
31027f7c583Smyers  * FUNCTION:    AcpiGetCurrentResources
3117c478bd9Sstevel@tonic-gate  *
31227f7c583Smyers  * PARAMETERS:  DeviceHandle    - Handle to the device object for the
3137c478bd9Sstevel@tonic-gate  *                                device we are querying
31427f7c583Smyers  *              RetBuffer       - Pointer to a buffer to receive the
31527f7c583Smyers  *                                current resources for the device
3167c478bd9Sstevel@tonic-gate  *
3177c478bd9Sstevel@tonic-gate  * RETURN:      Status
3187c478bd9Sstevel@tonic-gate  *
31927f7c583Smyers  * DESCRIPTION: This function is called to get the current resources for a
32027f7c583Smyers  *              specific device. The caller must first acquire a handle for
32127f7c583Smyers  *              the desired device. The resource data is placed in the buffer
32227f7c583Smyers  *              pointed to by the RetBuffer variable parameter.
3237c478bd9Sstevel@tonic-gate  *
3247c478bd9Sstevel@tonic-gate  *              If the function fails an appropriate status will be returned
3257c478bd9Sstevel@tonic-gate  *              and the value of RetBuffer is undefined.
3267c478bd9Sstevel@tonic-gate  *
32727f7c583Smyers  *              This function attempts to execute the _CRS method contained in
32827f7c583Smyers  *              the object indicated by the passed DeviceHandle.
32927f7c583Smyers  *
3307c478bd9Sstevel@tonic-gate  ******************************************************************************/
3317c478bd9Sstevel@tonic-gate 
3327c478bd9Sstevel@tonic-gate ACPI_STATUS
33327f7c583Smyers AcpiGetCurrentResources (
3347c478bd9Sstevel@tonic-gate     ACPI_HANDLE             DeviceHandle,
3357c478bd9Sstevel@tonic-gate     ACPI_BUFFER             *RetBuffer)
3367c478bd9Sstevel@tonic-gate {
3377c478bd9Sstevel@tonic-gate     ACPI_STATUS             Status;
33827f7c583Smyers     ACPI_NAMESPACE_NODE     *Node;
3397c478bd9Sstevel@tonic-gate 
3407c478bd9Sstevel@tonic-gate 
34127f7c583Smyers     ACPI_FUNCTION_TRACE (AcpiGetCurrentResources);
3427c478bd9Sstevel@tonic-gate 
3437c478bd9Sstevel@tonic-gate 
34427f7c583Smyers     /* Validate parameters then dispatch to internal routine */
3457c478bd9Sstevel@tonic-gate 
34627f7c583Smyers     Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
3477c478bd9Sstevel@tonic-gate     if (ACPI_FAILURE (Status))
3487c478bd9Sstevel@tonic-gate     {
3497c478bd9Sstevel@tonic-gate         return_ACPI_STATUS (Status);
3507c478bd9Sstevel@tonic-gate     }
3517c478bd9Sstevel@tonic-gate 
35227f7c583Smyers     Status = AcpiRsGetCrsMethodData (Node, RetBuffer);
3537c478bd9Sstevel@tonic-gate     return_ACPI_STATUS (Status);
3547c478bd9Sstevel@tonic-gate }
3557c478bd9Sstevel@tonic-gate 
ACPI_EXPORT_SYMBOL(AcpiGetCurrentResources)35627f7c583Smyers ACPI_EXPORT_SYMBOL (AcpiGetCurrentResources)
35727f7c583Smyers 
3587c478bd9Sstevel@tonic-gate 
3597c478bd9Sstevel@tonic-gate /*******************************************************************************
3607c478bd9Sstevel@tonic-gate  *
36127f7c583Smyers  * FUNCTION:    AcpiGetPossibleResources
3627c478bd9Sstevel@tonic-gate  *
36330082d0cSmyers  * PARAMETERS:  DeviceHandle    - Handle to the device object for the
3647c478bd9Sstevel@tonic-gate  *                                device we are querying
36527f7c583Smyers  *              RetBuffer       - Pointer to a buffer to receive the
36627f7c583Smyers  *                                resources for the device
3677c478bd9Sstevel@tonic-gate  *
3687c478bd9Sstevel@tonic-gate  * RETURN:      Status
3697c478bd9Sstevel@tonic-gate  *
37027f7c583Smyers  * DESCRIPTION: This function is called to get a list of the possible resources
37127f7c583Smyers  *              for a specific device. The caller must first acquire a handle
37227f7c583Smyers  *              for the desired device. The resource data is placed in the
37327f7c583Smyers  *              buffer pointed to by the RetBuffer variable.
37427f7c583Smyers  *
37527f7c583Smyers  *              If the function fails an appropriate status will be returned
37627f7c583Smyers  *              and the value of RetBuffer is undefined.
3777c478bd9Sstevel@tonic-gate  *
3787c478bd9Sstevel@tonic-gate  ******************************************************************************/
3797c478bd9Sstevel@tonic-gate 
3807c478bd9Sstevel@tonic-gate ACPI_STATUS
38127f7c583Smyers AcpiGetPossibleResources (
38227f7c583Smyers     ACPI_HANDLE             DeviceHandle,
38327f7c583Smyers     ACPI_BUFFER             *RetBuffer)
3847c478bd9Sstevel@tonic-gate {
38527f7c583Smyers     ACPI_STATUS             Status;
38627f7c583Smyers     ACPI_NAMESPACE_NODE     *Node;
3877c478bd9Sstevel@tonic-gate 
3887c478bd9Sstevel@tonic-gate 
38927f7c583Smyers     ACPI_FUNCTION_TRACE (AcpiGetPossibleResources);
39030082d0cSmyers 
3917c478bd9Sstevel@tonic-gate 
39227f7c583Smyers     /* Validate parameters then dispatch to internal routine */
39330082d0cSmyers 
39427f7c583Smyers     Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
3957c478bd9Sstevel@tonic-gate     if (ACPI_FAILURE (Status))
3967c478bd9Sstevel@tonic-gate     {
3977c478bd9Sstevel@tonic-gate         return_ACPI_STATUS (Status);
3987c478bd9Sstevel@tonic-gate     }
3997c478bd9Sstevel@tonic-gate 
40027f7c583Smyers     Status = AcpiRsGetPrsMethodData (Node, RetBuffer);
4017c478bd9Sstevel@tonic-gate     return_ACPI_STATUS (Status);
4027c478bd9Sstevel@tonic-gate }
4037c478bd9Sstevel@tonic-gate 
ACPI_EXPORT_SYMBOL(AcpiGetPossibleResources)40427f7c583Smyers ACPI_EXPORT_SYMBOL (AcpiGetPossibleResources)
40527f7c583Smyers 
4067c478bd9Sstevel@tonic-gate 
4077c478bd9Sstevel@tonic-gate /*******************************************************************************
4087c478bd9Sstevel@tonic-gate  *
4097c478bd9Sstevel@tonic-gate  * FUNCTION:    AcpiSetCurrentResources
4107c478bd9Sstevel@tonic-gate  *
41127f7c583Smyers  * PARAMETERS:  DeviceHandle    - Handle to the device object for the
41227f7c583Smyers  *                                device we are setting resources
41327f7c583Smyers  *              InBuffer        - Pointer to a buffer containing the
4147c478bd9Sstevel@tonic-gate  *                                resources to be set for the device
4157c478bd9Sstevel@tonic-gate  *
4167c478bd9Sstevel@tonic-gate  * RETURN:      Status
4177c478bd9Sstevel@tonic-gate  *
4187c478bd9Sstevel@tonic-gate  * DESCRIPTION: This function is called to set the current resources for a
41927f7c583Smyers  *              specific device. The caller must first acquire a handle for
42027f7c583Smyers  *              the desired device. The resource data is passed to the routine
4217c478bd9Sstevel@tonic-gate  *              the buffer pointed to by the InBuffer variable.
4227c478bd9Sstevel@tonic-gate  *
4237c478bd9Sstevel@tonic-gate  ******************************************************************************/
4247c478bd9Sstevel@tonic-gate 
4257c478bd9Sstevel@tonic-gate ACPI_STATUS
4267c478bd9Sstevel@tonic-gate AcpiSetCurrentResources (
4277c478bd9Sstevel@tonic-gate     ACPI_HANDLE             DeviceHandle,
4287c478bd9Sstevel@tonic-gate     ACPI_BUFFER             *InBuffer)
4297c478bd9Sstevel@tonic-gate {
4307c478bd9Sstevel@tonic-gate     ACPI_STATUS             Status;
43127f7c583Smyers     ACPI_NAMESPACE_NODE     *Node;
4327c478bd9Sstevel@tonic-gate 
4337c478bd9Sstevel@tonic-gate 
43427f7c583Smyers     ACPI_FUNCTION_TRACE (AcpiSetCurrentResources);
4357c478bd9Sstevel@tonic-gate 
4367c478bd9Sstevel@tonic-gate 
43727f7c583Smyers     /* Validate the buffer, don't allow zero length */
4387c478bd9Sstevel@tonic-gate 
43927f7c583Smyers     if ((!InBuffer) ||
44027f7c583Smyers         (!InBuffer->Pointer) ||
4417c478bd9Sstevel@tonic-gate         (!InBuffer->Length))
4427c478bd9Sstevel@tonic-gate     {
4437c478bd9Sstevel@tonic-gate         return_ACPI_STATUS (AE_BAD_PARAMETER);
4447c478bd9Sstevel@tonic-gate     }
4457c478bd9Sstevel@tonic-gate 
44627f7c583Smyers     /* Validate parameters then dispatch to internal routine */
44727f7c583Smyers 
44827f7c583Smyers     Status = AcpiRsValidateParameters (DeviceHandle, InBuffer, &Node);
44927f7c583Smyers     if (ACPI_FAILURE (Status))
45027f7c583Smyers     {
45127f7c583Smyers         return_ACPI_STATUS (Status);
45227f7c583Smyers     }
45327f7c583Smyers 
45427f7c583Smyers     Status = AcpiRsSetSrsMethodData (Node, InBuffer);
4557c478bd9Sstevel@tonic-gate     return_ACPI_STATUS (Status);
4567c478bd9Sstevel@tonic-gate }
4577c478bd9Sstevel@tonic-gate 
ACPI_EXPORT_SYMBOL(AcpiSetCurrentResources)45827f7c583Smyers ACPI_EXPORT_SYMBOL (AcpiSetCurrentResources)
45927f7c583Smyers 
4607c478bd9Sstevel@tonic-gate 
4617b1019a6SJerry Jelinek /*******************************************************************************
4627b1019a6SJerry Jelinek  *
4637b1019a6SJerry Jelinek  * FUNCTION:    AcpiGetEventResources
4647b1019a6SJerry Jelinek  *
4657b1019a6SJerry Jelinek  * PARAMETERS:  DeviceHandle    - Handle to the device object for the
4667b1019a6SJerry Jelinek  *                                device we are getting resources
4677b1019a6SJerry Jelinek  *              InBuffer        - Pointer to a buffer containing the
4687b1019a6SJerry Jelinek  *                                resources to be set for the device
4697b1019a6SJerry Jelinek  *
4707b1019a6SJerry Jelinek  * RETURN:      Status
4717b1019a6SJerry Jelinek  *
4727b1019a6SJerry Jelinek  * DESCRIPTION: This function is called to get the event resources for a
4737b1019a6SJerry Jelinek  *              specific device. The caller must first acquire a handle for
4747b1019a6SJerry Jelinek  *              the desired device. The resource data is passed to the routine
4757b1019a6SJerry Jelinek  *              the buffer pointed to by the InBuffer variable. Uses the
4767b1019a6SJerry Jelinek  *              _AEI method.
4777b1019a6SJerry Jelinek  *
4787b1019a6SJerry Jelinek  ******************************************************************************/
4797b1019a6SJerry Jelinek 
4807b1019a6SJerry Jelinek ACPI_STATUS
4817b1019a6SJerry Jelinek AcpiGetEventResources (
4827b1019a6SJerry Jelinek     ACPI_HANDLE             DeviceHandle,
4837b1019a6SJerry Jelinek     ACPI_BUFFER             *RetBuffer)
4847b1019a6SJerry Jelinek {
4857b1019a6SJerry Jelinek     ACPI_STATUS             Status;
4867b1019a6SJerry Jelinek     ACPI_NAMESPACE_NODE     *Node;
4877b1019a6SJerry Jelinek 
4887b1019a6SJerry Jelinek 
4897b1019a6SJerry Jelinek     ACPI_FUNCTION_TRACE (AcpiGetEventResources);
4907b1019a6SJerry Jelinek 
4917b1019a6SJerry Jelinek 
4927b1019a6SJerry Jelinek     /* Validate parameters then dispatch to internal routine */
4937b1019a6SJerry Jelinek 
4947b1019a6SJerry Jelinek     Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
4957b1019a6SJerry Jelinek     if (ACPI_FAILURE (Status))
4967b1019a6SJerry Jelinek     {
4977b1019a6SJerry Jelinek         return_ACPI_STATUS (Status);
4987b1019a6SJerry Jelinek     }
4997b1019a6SJerry Jelinek 
5007b1019a6SJerry Jelinek     Status = AcpiRsGetAeiMethodData (Node, RetBuffer);
5017b1019a6SJerry Jelinek     return_ACPI_STATUS (Status);
5027b1019a6SJerry Jelinek }
5037b1019a6SJerry Jelinek 
ACPI_EXPORT_SYMBOL(AcpiGetEventResources)5047b1019a6SJerry Jelinek ACPI_EXPORT_SYMBOL (AcpiGetEventResources)
5057b1019a6SJerry Jelinek 
5067b1019a6SJerry Jelinek 
5077c478bd9Sstevel@tonic-gate /******************************************************************************
5087c478bd9Sstevel@tonic-gate  *
5097c478bd9Sstevel@tonic-gate  * FUNCTION:    AcpiResourceToAddress64
5107c478bd9Sstevel@tonic-gate  *
51127f7c583Smyers  * PARAMETERS:  Resource        - Pointer to a resource
51227f7c583Smyers  *              Out             - Pointer to the users's return buffer
51327f7c583Smyers  *                                (a struct acpi_resource_address64)
5147c478bd9Sstevel@tonic-gate  *
5157c478bd9Sstevel@tonic-gate  * RETURN:      Status
5167c478bd9Sstevel@tonic-gate  *
5177c478bd9Sstevel@tonic-gate  * DESCRIPTION: If the resource is an address16, address32, or address64,
51827f7c583Smyers  *              copy it to the address64 return buffer. This saves the
5197c478bd9Sstevel@tonic-gate  *              caller from having to duplicate code for different-sized
5207c478bd9Sstevel@tonic-gate  *              addresses.
5217c478bd9Sstevel@tonic-gate  *
5227c478bd9Sstevel@tonic-gate  ******************************************************************************/
5237c478bd9Sstevel@tonic-gate 
5247c478bd9Sstevel@tonic-gate ACPI_STATUS
5257c478bd9Sstevel@tonic-gate AcpiResourceToAddress64 (
5267c478bd9Sstevel@tonic-gate     ACPI_RESOURCE               *Resource,
5277c478bd9Sstevel@tonic-gate     ACPI_RESOURCE_ADDRESS64     *Out)
5287c478bd9Sstevel@tonic-gate {
5297c478bd9Sstevel@tonic-gate     ACPI_RESOURCE_ADDRESS16     *Address16;
5307c478bd9Sstevel@tonic-gate     ACPI_RESOURCE_ADDRESS32     *Address32;
5317c478bd9Sstevel@tonic-gate 
5327c478bd9Sstevel@tonic-gate 
53330082d0cSmyers     if (!Resource || !Out)
53430082d0cSmyers     {
53530082d0cSmyers         return (AE_BAD_PARAMETER);
53630082d0cSmyers     }
53730082d0cSmyers 
53830082d0cSmyers     /* Convert 16 or 32 address descriptor to 64 */
53930082d0cSmyers 
540186507a7Smyers     switch (Resource->Type)
541186507a7Smyers     {
542186507a7Smyers     case ACPI_RESOURCE_TYPE_ADDRESS16:
5437c478bd9Sstevel@tonic-gate 
5447b1019a6SJerry Jelinek         Address16 = ACPI_CAST_PTR (
5457b1019a6SJerry Jelinek             ACPI_RESOURCE_ADDRESS16, &Resource->Data);
5467c478bd9Sstevel@tonic-gate         ACPI_COPY_ADDRESS (Out, Address16);
5477c478bd9Sstevel@tonic-gate         break;
5487c478bd9Sstevel@tonic-gate 
549186507a7Smyers     case ACPI_RESOURCE_TYPE_ADDRESS32:
5507c478bd9Sstevel@tonic-gate 
5517b1019a6SJerry Jelinek         Address32 = ACPI_CAST_PTR (
5527b1019a6SJerry Jelinek             ACPI_RESOURCE_ADDRESS32, &Resource->Data);
5537c478bd9Sstevel@tonic-gate         ACPI_COPY_ADDRESS (Out, Address32);
5547c478bd9Sstevel@tonic-gate         break;
5557c478bd9Sstevel@tonic-gate 
556186507a7Smyers     case ACPI_RESOURCE_TYPE_ADDRESS64:
5577c478bd9Sstevel@tonic-gate 
5587c478bd9Sstevel@tonic-gate         /* Simple copy for 64 bit source */
5597c478bd9Sstevel@tonic-gate 
5607b1019a6SJerry Jelinek         memcpy (Out, &Resource->Data, sizeof (ACPI_RESOURCE_ADDRESS64));
5617c478bd9Sstevel@tonic-gate         break;
5627c478bd9Sstevel@tonic-gate 
5637c478bd9Sstevel@tonic-gate     default:
5647b1019a6SJerry Jelinek 
5657c478bd9Sstevel@tonic-gate         return (AE_BAD_PARAMETER);
5667c478bd9Sstevel@tonic-gate     }
5677c478bd9Sstevel@tonic-gate 
5687c478bd9Sstevel@tonic-gate     return (AE_OK);
5697c478bd9Sstevel@tonic-gate }
57030082d0cSmyers 
ACPI_EXPORT_SYMBOL(AcpiResourceToAddress64)57127f7c583Smyers ACPI_EXPORT_SYMBOL (AcpiResourceToAddress64)
57227f7c583Smyers 
57330082d0cSmyers 
57430082d0cSmyers /*******************************************************************************
57530082d0cSmyers  *
57630082d0cSmyers  * FUNCTION:    AcpiGetVendorResource
57730082d0cSmyers  *
57827f7c583Smyers  * PARAMETERS:  DeviceHandle    - Handle for the parent device object
57927f7c583Smyers  *              Name            - Method name for the parent resource
58027f7c583Smyers  *                                (METHOD_NAME__CRS or METHOD_NAME__PRS)
58127f7c583Smyers  *              Uuid            - Pointer to the UUID to be matched.
58227f7c583Smyers  *                                includes both subtype and 16-byte UUID
58327f7c583Smyers  *              RetBuffer       - Where the vendor resource is returned
58430082d0cSmyers  *
58530082d0cSmyers  * RETURN:      Status
58630082d0cSmyers  *
5877b1019a6SJerry Jelinek  * DESCRIPTION: Walk a resource template for the specified device to find a
58830082d0cSmyers  *              vendor-defined resource that matches the supplied UUID and
58930082d0cSmyers  *              UUID subtype. Returns a ACPI_RESOURCE of type Vendor.
59030082d0cSmyers  *
59130082d0cSmyers  ******************************************************************************/
59230082d0cSmyers 
59330082d0cSmyers ACPI_STATUS
59430082d0cSmyers AcpiGetVendorResource (
59530082d0cSmyers     ACPI_HANDLE             DeviceHandle,
59630082d0cSmyers     char                    *Name,
59730082d0cSmyers     ACPI_VENDOR_UUID        *Uuid,
59830082d0cSmyers     ACPI_BUFFER             *RetBuffer)
59930082d0cSmyers {
60030082d0cSmyers     ACPI_VENDOR_WALK_INFO   Info;
60130082d0cSmyers     ACPI_STATUS             Status;
60230082d0cSmyers 
60330082d0cSmyers 
60430082d0cSmyers     /* Other parameters are validated by AcpiWalkResources */
60530082d0cSmyers 
60630082d0cSmyers     if (!Uuid || !RetBuffer)
60730082d0cSmyers     {
60830082d0cSmyers         return (AE_BAD_PARAMETER);
60930082d0cSmyers     }
61030082d0cSmyers 
61130082d0cSmyers     Info.Uuid = Uuid;
61230082d0cSmyers     Info.Buffer = RetBuffer;
61330082d0cSmyers     Info.Status = AE_NOT_EXIST;
61430082d0cSmyers 
61530082d0cSmyers     /* Walk the _CRS or _PRS resource list for this device */
61630082d0cSmyers 
6177b1019a6SJerry Jelinek     Status = AcpiWalkResources (
6187b1019a6SJerry Jelinek         DeviceHandle, Name, AcpiRsMatchVendorResource, &Info);
61930082d0cSmyers     if (ACPI_FAILURE (Status))
62030082d0cSmyers     {
62130082d0cSmyers         return (Status);
62230082d0cSmyers     }
62330082d0cSmyers 
62430082d0cSmyers     return (Info.Status);
62530082d0cSmyers }
62630082d0cSmyers 
ACPI_EXPORT_SYMBOL(AcpiGetVendorResource)62727f7c583Smyers ACPI_EXPORT_SYMBOL (AcpiGetVendorResource)
62827f7c583Smyers 
62930082d0cSmyers 
63030082d0cSmyers /*******************************************************************************
63130082d0cSmyers  *
63230082d0cSmyers  * FUNCTION:    AcpiRsMatchVendorResource
63330082d0cSmyers  *
63430082d0cSmyers  * PARAMETERS:  ACPI_WALK_RESOURCE_CALLBACK
63530082d0cSmyers  *
63630082d0cSmyers  * RETURN:      Status
63730082d0cSmyers  *
63830082d0cSmyers  * DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID
63930082d0cSmyers  *
64030082d0cSmyers  ******************************************************************************/
64130082d0cSmyers 
64230082d0cSmyers static ACPI_STATUS
64330082d0cSmyers AcpiRsMatchVendorResource (
64430082d0cSmyers     ACPI_RESOURCE           *Resource,
64530082d0cSmyers     void                    *Context)
64630082d0cSmyers {
64730082d0cSmyers     ACPI_VENDOR_WALK_INFO       *Info = Context;
64830082d0cSmyers     ACPI_RESOURCE_VENDOR_TYPED  *Vendor;
64930082d0cSmyers     ACPI_BUFFER                 *Buffer;
65030082d0cSmyers     ACPI_STATUS                 Status;
65130082d0cSmyers 
65230082d0cSmyers 
65330082d0cSmyers     /* Ignore all descriptors except Vendor */
65430082d0cSmyers 
65530082d0cSmyers     if (Resource->Type != ACPI_RESOURCE_TYPE_VENDOR)
65630082d0cSmyers     {
65730082d0cSmyers         return (AE_OK);
65830082d0cSmyers     }
65930082d0cSmyers 
66030082d0cSmyers     Vendor = &Resource->Data.VendorTyped;
66130082d0cSmyers 
66230082d0cSmyers     /*
66330082d0cSmyers      * For a valid match, these conditions must hold:
66430082d0cSmyers      *
66530082d0cSmyers      * 1) Length of descriptor data must be at least as long as a UUID struct
66630082d0cSmyers      * 2) The UUID subtypes must match
66730082d0cSmyers      * 3) The UUID data must match
66830082d0cSmyers      */
66930082d0cSmyers     if ((Vendor->ByteLength < (ACPI_UUID_LENGTH + 1)) ||
67030082d0cSmyers         (Vendor->UuidSubtype != Info->Uuid->Subtype)  ||
6717b1019a6SJerry Jelinek         (memcmp (Vendor->Uuid, Info->Uuid->Data, ACPI_UUID_LENGTH)))
67230082d0cSmyers     {
67330082d0cSmyers         return (AE_OK);
67430082d0cSmyers     }
67530082d0cSmyers 
67630082d0cSmyers     /* Validate/Allocate/Clear caller buffer */
67730082d0cSmyers 
67830082d0cSmyers     Buffer = Info->Buffer;
67930082d0cSmyers     Status = AcpiUtInitializeBuffer (Buffer, Resource->Length);
68030082d0cSmyers     if (ACPI_FAILURE (Status))
68130082d0cSmyers     {
68230082d0cSmyers         return (Status);
68330082d0cSmyers     }
68430082d0cSmyers 
68530082d0cSmyers     /* Found the correct resource, copy and return it */
68630082d0cSmyers 
6877b1019a6SJerry Jelinek     memcpy (Buffer->Pointer, Resource, Resource->Length);
68830082d0cSmyers     Buffer->Length = Resource->Length;
68930082d0cSmyers 
69030082d0cSmyers     /* Found the desired descriptor, terminate resource walk */
69130082d0cSmyers 
69230082d0cSmyers     Info->Status = AE_OK;
69330082d0cSmyers     return (AE_CTRL_TERMINATE);
69430082d0cSmyers }
69530082d0cSmyers 
69627f7c583Smyers 
69727f7c583Smyers /*******************************************************************************
69827f7c583Smyers  *
6997b1019a6SJerry Jelinek  * FUNCTION:    AcpiWalkResourceBuffer
70027f7c583Smyers  *
7017b1019a6SJerry Jelinek  * PARAMETERS:  Buffer          - Formatted buffer returned by one of the
7027b1019a6SJerry Jelinek  *                                various Get*Resource functions
70327f7c583Smyers  *              UserFunction    - Called for each resource
70427f7c583Smyers  *              Context         - Passed to UserFunction
70527f7c583Smyers  *
70627f7c583Smyers  * RETURN:      Status
70727f7c583Smyers  *
7087b1019a6SJerry Jelinek  * DESCRIPTION: Walks the input resource template. The UserFunction is called
7097b1019a6SJerry Jelinek  *              once for each resource in the list.
71027f7c583Smyers  *
71127f7c583Smyers  ******************************************************************************/
71227f7c583Smyers 
71327f7c583Smyers ACPI_STATUS
AcpiWalkResourceBuffer(ACPI_BUFFER * Buffer,ACPI_WALK_RESOURCE_CALLBACK UserFunction,void * Context)7147b1019a6SJerry Jelinek AcpiWalkResourceBuffer (
7157b1019a6SJerry Jelinek     ACPI_BUFFER                 *Buffer,
71627f7c583Smyers     ACPI_WALK_RESOURCE_CALLBACK UserFunction,
71727f7c583Smyers     void                        *Context)
71827f7c583Smyers {
7197b1019a6SJerry Jelinek     ACPI_STATUS                 Status = AE_OK;
72027f7c583Smyers     ACPI_RESOURCE               *Resource;
72127f7c583Smyers     ACPI_RESOURCE               *ResourceEnd;
72227f7c583Smyers 
72327f7c583Smyers 
7247b1019a6SJerry Jelinek     ACPI_FUNCTION_TRACE (AcpiWalkResourceBuffer);
72527f7c583Smyers 
72627f7c583Smyers 
72727f7c583Smyers     /* Parameter validation */
72827f7c583Smyers 
7297b1019a6SJerry Jelinek     if (!Buffer || !Buffer->Pointer || !UserFunction)
73027f7c583Smyers     {
73127f7c583Smyers         return_ACPI_STATUS (AE_BAD_PARAMETER);
73227f7c583Smyers     }
73327f7c583Smyers 
7347b1019a6SJerry Jelinek     /* Buffer contains the resource list and length */
73527f7c583Smyers 
7367b1019a6SJerry Jelinek     Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer->Pointer);
7377b1019a6SJerry Jelinek     ResourceEnd = ACPI_ADD_PTR (
7387b1019a6SJerry Jelinek         ACPI_RESOURCE, Buffer->Pointer, Buffer->Length);
73927f7c583Smyers 
74027f7c583Smyers     /* Walk the resource list until the EndTag is found (or buffer end) */
74127f7c583Smyers 
74227f7c583Smyers     while (Resource < ResourceEnd)
74327f7c583Smyers     {
7447b1019a6SJerry Jelinek         /* Sanity check the resource type */
74527f7c583Smyers 
74627f7c583Smyers         if (Resource->Type > ACPI_RESOURCE_TYPE_MAX)
74727f7c583Smyers         {
74827f7c583Smyers             Status = AE_AML_INVALID_RESOURCE_TYPE;
74927f7c583Smyers             break;
75027f7c583Smyers         }
75127f7c583Smyers 
7527b1019a6SJerry Jelinek         /* Sanity check the length. It must not be zero, or we loop forever */
7537b1019a6SJerry Jelinek 
7547b1019a6SJerry Jelinek         if (!Resource->Length)
7557b1019a6SJerry Jelinek         {
7567b1019a6SJerry Jelinek             return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH);
7577b1019a6SJerry Jelinek         }
7587b1019a6SJerry Jelinek 
75927f7c583Smyers         /* Invoke the user function, abort on any error returned */
76027f7c583Smyers 
76127f7c583Smyers         Status = UserFunction (Resource, Context);
76227f7c583Smyers         if (ACPI_FAILURE (Status))
76327f7c583Smyers         {
76427f7c583Smyers             if (Status == AE_CTRL_TERMINATE)
76527f7c583Smyers             {
76627f7c583Smyers                 /* This is an OK termination by the user function */
76727f7c583Smyers 
76827f7c583Smyers                 Status = AE_OK;
76927f7c583Smyers             }
77027f7c583Smyers             break;
77127f7c583Smyers         }
77227f7c583Smyers 
77327f7c583Smyers         /* EndTag indicates end-of-list */
77427f7c583Smyers 
77527f7c583Smyers         if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG)
77627f7c583Smyers         {
77727f7c583Smyers             break;
77827f7c583Smyers         }
77927f7c583Smyers 
78027f7c583Smyers         /* Get the next resource descriptor */
78127f7c583Smyers 
7827b1019a6SJerry Jelinek         Resource = ACPI_NEXT_RESOURCE (Resource);
78327f7c583Smyers     }
78427f7c583Smyers 
7857b1019a6SJerry Jelinek     return_ACPI_STATUS (Status);
7867b1019a6SJerry Jelinek }
7877b1019a6SJerry Jelinek 
ACPI_EXPORT_SYMBOL(AcpiWalkResourceBuffer)7887b1019a6SJerry Jelinek ACPI_EXPORT_SYMBOL (AcpiWalkResourceBuffer)
7897b1019a6SJerry Jelinek 
7907b1019a6SJerry Jelinek 
7917b1019a6SJerry Jelinek /*******************************************************************************
7927b1019a6SJerry Jelinek  *
7937b1019a6SJerry Jelinek  * FUNCTION:    AcpiWalkResources
7947b1019a6SJerry Jelinek  *
7957b1019a6SJerry Jelinek  * PARAMETERS:  DeviceHandle    - Handle to the device object for the
7967b1019a6SJerry Jelinek  *                                device we are querying
7977b1019a6SJerry Jelinek  *              Name            - Method name of the resources we want.
7987b1019a6SJerry Jelinek  *                                (METHOD_NAME__CRS, METHOD_NAME__PRS, or
799*35786f68SRobert Mustacchi  *                                METHOD_NAME__AEI or METHOD_NAME__DMA)
8007b1019a6SJerry Jelinek  *              UserFunction    - Called for each resource
8017b1019a6SJerry Jelinek  *              Context         - Passed to UserFunction
8027b1019a6SJerry Jelinek  *
8037b1019a6SJerry Jelinek  * RETURN:      Status
8047b1019a6SJerry Jelinek  *
8057b1019a6SJerry Jelinek  * DESCRIPTION: Retrieves the current or possible resource list for the
8067b1019a6SJerry Jelinek  *              specified device. The UserFunction is called once for
8077b1019a6SJerry Jelinek  *              each resource in the list.
8087b1019a6SJerry Jelinek  *
8097b1019a6SJerry Jelinek  ******************************************************************************/
8107b1019a6SJerry Jelinek 
8117b1019a6SJerry Jelinek ACPI_STATUS
8127b1019a6SJerry Jelinek AcpiWalkResources (
8137b1019a6SJerry Jelinek     ACPI_HANDLE                 DeviceHandle,
8147b1019a6SJerry Jelinek     char                        *Name,
8157b1019a6SJerry Jelinek     ACPI_WALK_RESOURCE_CALLBACK UserFunction,
8167b1019a6SJerry Jelinek     void                        *Context)
8177b1019a6SJerry Jelinek {
8187b1019a6SJerry Jelinek     ACPI_STATUS                 Status;
8197b1019a6SJerry Jelinek     ACPI_BUFFER                 Buffer;
8207b1019a6SJerry Jelinek 
8217b1019a6SJerry Jelinek 
8227b1019a6SJerry Jelinek     ACPI_FUNCTION_TRACE (AcpiWalkResources);
8237b1019a6SJerry Jelinek 
8247b1019a6SJerry Jelinek 
8257b1019a6SJerry Jelinek     /* Parameter validation */
8267b1019a6SJerry Jelinek 
8277b1019a6SJerry Jelinek     if (!DeviceHandle || !UserFunction || !Name ||
8287b1019a6SJerry Jelinek         (!ACPI_COMPARE_NAME (Name, METHOD_NAME__CRS) &&
8297b1019a6SJerry Jelinek          !ACPI_COMPARE_NAME (Name, METHOD_NAME__PRS) &&
830*35786f68SRobert Mustacchi          !ACPI_COMPARE_NAME (Name, METHOD_NAME__AEI) &&
831*35786f68SRobert Mustacchi          !ACPI_COMPARE_NAME (Name, METHOD_NAME__DMA)))
8327b1019a6SJerry Jelinek     {
8337b1019a6SJerry Jelinek         return_ACPI_STATUS (AE_BAD_PARAMETER);
8347b1019a6SJerry Jelinek     }
8357b1019a6SJerry Jelinek 
836*35786f68SRobert Mustacchi     /* Get the _CRS/_PRS/_AEI/_DMA resource list */
8377b1019a6SJerry Jelinek 
8387b1019a6SJerry Jelinek     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
8397b1019a6SJerry Jelinek     Status = AcpiRsGetMethodData (DeviceHandle, Name, &Buffer);
8407b1019a6SJerry Jelinek     if (ACPI_FAILURE (Status))
8417b1019a6SJerry Jelinek     {
8427b1019a6SJerry Jelinek         return_ACPI_STATUS (Status);
8437b1019a6SJerry Jelinek     }
8447b1019a6SJerry Jelinek 
8457b1019a6SJerry Jelinek     /* Walk the resource list and cleanup */
8467b1019a6SJerry Jelinek 
8477b1019a6SJerry Jelinek     Status = AcpiWalkResourceBuffer (&Buffer, UserFunction, Context);
84827f7c583Smyers     ACPI_FREE (Buffer.Pointer);
84927f7c583Smyers     return_ACPI_STATUS (Status);
85027f7c583Smyers }
85127f7c583Smyers 
85227f7c583Smyers ACPI_EXPORT_SYMBOL (AcpiWalkResources)
853