10174267aSFredrik Holmqvist /*******************************************************************************
20174267aSFredrik Holmqvist *
30174267aSFredrik Holmqvist * Module Name: rsxface - Public interfaces to the resource manager
40174267aSFredrik Holmqvist *
50174267aSFredrik Holmqvist ******************************************************************************/
60174267aSFredrik Holmqvist
70174267aSFredrik Holmqvist /******************************************************************************
80174267aSFredrik Holmqvist *
90174267aSFredrik Holmqvist * 1. Copyright Notice
100174267aSFredrik Holmqvist *
11*6dde014fSPulkoMandy * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
120174267aSFredrik Holmqvist * All rights reserved.
130174267aSFredrik Holmqvist *
140174267aSFredrik Holmqvist * 2. License
150174267aSFredrik Holmqvist *
160174267aSFredrik Holmqvist * 2.1. This is your license from Intel Corp. under its intellectual property
170174267aSFredrik Holmqvist * rights. You may have additional license terms from the party that provided
180174267aSFredrik Holmqvist * you this software, covering your right to use that party's intellectual
190174267aSFredrik Holmqvist * property rights.
200174267aSFredrik Holmqvist *
210174267aSFredrik Holmqvist * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
220174267aSFredrik Holmqvist * copy of the source code appearing in this file ("Covered Code") an
230174267aSFredrik Holmqvist * irrevocable, perpetual, worldwide license under Intel's copyrights in the
240174267aSFredrik Holmqvist * base code distributed originally by Intel ("Original Intel Code") to copy,
250174267aSFredrik Holmqvist * make derivatives, distribute, use and display any portion of the Covered
260174267aSFredrik Holmqvist * Code in any form, with the right to sublicense such rights; and
270174267aSFredrik Holmqvist *
280174267aSFredrik Holmqvist * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
290174267aSFredrik Holmqvist * license (with the right to sublicense), under only those claims of Intel
300174267aSFredrik Holmqvist * patents that are infringed by the Original Intel Code, to make, use, sell,
310174267aSFredrik Holmqvist * offer to sell, and import the Covered Code and derivative works thereof
320174267aSFredrik Holmqvist * solely to the minimum extent necessary to exercise the above copyright
330174267aSFredrik Holmqvist * license, and in no event shall the patent license extend to any additions
340174267aSFredrik Holmqvist * to or modifications of the Original Intel Code. No other license or right
350174267aSFredrik Holmqvist * is granted directly or by implication, estoppel or otherwise;
360174267aSFredrik Holmqvist *
370174267aSFredrik Holmqvist * The above copyright and patent license is granted only if the following
380174267aSFredrik Holmqvist * conditions are met:
390174267aSFredrik Holmqvist *
400174267aSFredrik Holmqvist * 3. Conditions
410174267aSFredrik Holmqvist *
420174267aSFredrik Holmqvist * 3.1. Redistribution of Source with Rights to Further Distribute Source.
430174267aSFredrik Holmqvist * Redistribution of source code of any substantial portion of the Covered
440174267aSFredrik Holmqvist * Code or modification with rights to further distribute source must include
450174267aSFredrik Holmqvist * the above Copyright Notice, the above License, this list of Conditions,
460174267aSFredrik Holmqvist * and the following Disclaimer and Export Compliance provision. In addition,
470174267aSFredrik Holmqvist * Licensee must cause all Covered Code to which Licensee contributes to
480174267aSFredrik Holmqvist * contain a file documenting the changes Licensee made to create that Covered
490174267aSFredrik Holmqvist * Code and the date of any change. Licensee must include in that file the
500174267aSFredrik Holmqvist * documentation of any changes made by any predecessor Licensee. Licensee
510174267aSFredrik Holmqvist * must include a prominent statement that the modification is derived,
520174267aSFredrik Holmqvist * directly or indirectly, from Original Intel Code.
530174267aSFredrik Holmqvist *
540174267aSFredrik Holmqvist * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
550174267aSFredrik Holmqvist * Redistribution of source code of any substantial portion of the Covered
560174267aSFredrik Holmqvist * Code or modification without rights to further distribute source must
570174267aSFredrik Holmqvist * include the following Disclaimer and Export Compliance provision in the
580174267aSFredrik Holmqvist * documentation and/or other materials provided with distribution. In
590174267aSFredrik Holmqvist * addition, Licensee may not authorize further sublicense of source of any
600174267aSFredrik Holmqvist * portion of the Covered Code, and must include terms to the effect that the
610174267aSFredrik Holmqvist * license from Licensee to its licensee is limited to the intellectual
620174267aSFredrik Holmqvist * property embodied in the software Licensee provides to its licensee, and
630174267aSFredrik Holmqvist * not to intellectual property embodied in modifications its licensee may
640174267aSFredrik Holmqvist * make.
650174267aSFredrik Holmqvist *
660174267aSFredrik Holmqvist * 3.3. Redistribution of Executable. Redistribution in executable form of any
670174267aSFredrik Holmqvist * substantial portion of the Covered Code or modification must reproduce the
680174267aSFredrik Holmqvist * above Copyright Notice, and the following Disclaimer and Export Compliance
690174267aSFredrik Holmqvist * provision in the documentation and/or other materials provided with the
700174267aSFredrik Holmqvist * distribution.
710174267aSFredrik Holmqvist *
720174267aSFredrik Holmqvist * 3.4. Intel retains all right, title, and interest in and to the Original
730174267aSFredrik Holmqvist * Intel Code.
740174267aSFredrik Holmqvist *
750174267aSFredrik Holmqvist * 3.5. Neither the name Intel nor any other trademark owned or controlled by
760174267aSFredrik Holmqvist * Intel shall be used in advertising or otherwise to promote the sale, use or
770174267aSFredrik Holmqvist * other dealings in products derived from or relating to the Covered Code
780174267aSFredrik Holmqvist * without prior written authorization from Intel.
790174267aSFredrik Holmqvist *
800174267aSFredrik Holmqvist * 4. Disclaimer and Export Compliance
810174267aSFredrik Holmqvist *
820174267aSFredrik Holmqvist * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
830174267aSFredrik Holmqvist * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
840174267aSFredrik Holmqvist * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
850174267aSFredrik Holmqvist * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
860174267aSFredrik Holmqvist * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
870174267aSFredrik Holmqvist * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
880174267aSFredrik Holmqvist * PARTICULAR PURPOSE.
890174267aSFredrik Holmqvist *
900174267aSFredrik Holmqvist * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
910174267aSFredrik Holmqvist * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
920174267aSFredrik Holmqvist * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
930174267aSFredrik Holmqvist * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
940174267aSFredrik Holmqvist * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
950174267aSFredrik Holmqvist * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
960174267aSFredrik Holmqvist * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
970174267aSFredrik Holmqvist * LIMITED REMEDY.
980174267aSFredrik Holmqvist *
990174267aSFredrik Holmqvist * 4.3. Licensee shall not export, either directly or indirectly, any of this
1000174267aSFredrik Holmqvist * software or system incorporating such software without first obtaining any
1010174267aSFredrik Holmqvist * required license or other approval from the U. S. Department of Commerce or
1020174267aSFredrik Holmqvist * any other agency or department of the United States Government. In the
1030174267aSFredrik Holmqvist * event Licensee exports any such software from the United States or
1040174267aSFredrik Holmqvist * re-exports any such software from a foreign destination, Licensee shall
1050174267aSFredrik Holmqvist * ensure that the distribution and export/re-export of the software is in
1060174267aSFredrik Holmqvist * compliance with all laws, regulations, orders, or other restrictions of the
1070174267aSFredrik Holmqvist * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1080174267aSFredrik Holmqvist * any of its subsidiaries will export/re-export any technical data, process,
1090174267aSFredrik Holmqvist * software, or service, directly or indirectly, to any country for which the
1100174267aSFredrik Holmqvist * United States government or any agency thereof requires an export license,
1110174267aSFredrik Holmqvist * other governmental approval, or letter of assurance, without first obtaining
1120174267aSFredrik Holmqvist * such license, approval or letter.
1130174267aSFredrik Holmqvist *
114ff2e2f81SFredrik Holmqvist *****************************************************************************
115ff2e2f81SFredrik Holmqvist *
116ff2e2f81SFredrik Holmqvist * Alternatively, you may choose to be licensed under the terms of the
117ff2e2f81SFredrik Holmqvist * following license:
118ff2e2f81SFredrik Holmqvist *
119ff2e2f81SFredrik Holmqvist * Redistribution and use in source and binary forms, with or without
120ff2e2f81SFredrik Holmqvist * modification, are permitted provided that the following conditions
121ff2e2f81SFredrik Holmqvist * are met:
122ff2e2f81SFredrik Holmqvist * 1. Redistributions of source code must retain the above copyright
123ff2e2f81SFredrik Holmqvist * notice, this list of conditions, and the following disclaimer,
124ff2e2f81SFredrik Holmqvist * without modification.
125ff2e2f81SFredrik Holmqvist * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126ff2e2f81SFredrik Holmqvist * substantially similar to the "NO WARRANTY" disclaimer below
127ff2e2f81SFredrik Holmqvist * ("Disclaimer") and any redistribution must be conditioned upon
128ff2e2f81SFredrik Holmqvist * including a substantially similar Disclaimer requirement for further
129ff2e2f81SFredrik Holmqvist * binary redistribution.
130ff2e2f81SFredrik Holmqvist * 3. Neither the names of the above-listed copyright holders nor the names
131ff2e2f81SFredrik Holmqvist * of any contributors may be used to endorse or promote products derived
132ff2e2f81SFredrik Holmqvist * from this software without specific prior written permission.
133ff2e2f81SFredrik Holmqvist *
134ff2e2f81SFredrik Holmqvist * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135ff2e2f81SFredrik Holmqvist * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136ff2e2f81SFredrik Holmqvist * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137ff2e2f81SFredrik Holmqvist * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138ff2e2f81SFredrik Holmqvist * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139ff2e2f81SFredrik Holmqvist * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140ff2e2f81SFredrik Holmqvist * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141ff2e2f81SFredrik Holmqvist * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142ff2e2f81SFredrik Holmqvist * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143ff2e2f81SFredrik Holmqvist * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144ff2e2f81SFredrik Holmqvist * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145ff2e2f81SFredrik Holmqvist *
146ff2e2f81SFredrik Holmqvist * Alternatively, you may choose to be licensed under the terms of the
147ff2e2f81SFredrik Holmqvist * GNU General Public License ("GPL") version 2 as published by the Free
148ff2e2f81SFredrik Holmqvist * Software Foundation.
149ff2e2f81SFredrik Holmqvist *
1500174267aSFredrik Holmqvist *****************************************************************************/
1510174267aSFredrik Holmqvist
152ad5bbfb8SFredrik Holmqvist #define EXPORT_ACPI_INTERFACES
1530174267aSFredrik Holmqvist
1540174267aSFredrik Holmqvist #include "acpi.h"
1550174267aSFredrik Holmqvist #include "accommon.h"
1560174267aSFredrik Holmqvist #include "acresrc.h"
1570174267aSFredrik Holmqvist #include "acnamesp.h"
1580174267aSFredrik Holmqvist
1590174267aSFredrik Holmqvist #define _COMPONENT ACPI_RESOURCES
1600174267aSFredrik Holmqvist ACPI_MODULE_NAME ("rsxface")
1610174267aSFredrik Holmqvist
1620174267aSFredrik Holmqvist /* Local macros for 16,32-bit to 64-bit conversion */
1630174267aSFredrik Holmqvist
1640174267aSFredrik Holmqvist #define ACPI_COPY_FIELD(Out, In, Field) ((Out)->Field = (In)->Field)
1650174267aSFredrik Holmqvist #define ACPI_COPY_ADDRESS(Out, In) \
1660174267aSFredrik Holmqvist ACPI_COPY_FIELD(Out, In, ResourceType); \
1670174267aSFredrik Holmqvist ACPI_COPY_FIELD(Out, In, ProducerConsumer); \
1680174267aSFredrik Holmqvist ACPI_COPY_FIELD(Out, In, Decode); \
1690174267aSFredrik Holmqvist ACPI_COPY_FIELD(Out, In, MinAddressFixed); \
1700174267aSFredrik Holmqvist ACPI_COPY_FIELD(Out, In, MaxAddressFixed); \
1710174267aSFredrik Holmqvist ACPI_COPY_FIELD(Out, In, Info); \
172e226d1d0SFredrik Holmqvist ACPI_COPY_FIELD(Out, In, Address.Granularity); \
173e226d1d0SFredrik Holmqvist ACPI_COPY_FIELD(Out, In, Address.Minimum); \
174e226d1d0SFredrik Holmqvist ACPI_COPY_FIELD(Out, In, Address.Maximum); \
175e226d1d0SFredrik Holmqvist ACPI_COPY_FIELD(Out, In, Address.TranslationOffset); \
176e226d1d0SFredrik Holmqvist ACPI_COPY_FIELD(Out, In, Address.AddressLength); \
1770174267aSFredrik Holmqvist ACPI_COPY_FIELD(Out, In, ResourceSource);
1780174267aSFredrik Holmqvist
1790174267aSFredrik Holmqvist
1800174267aSFredrik Holmqvist /* Local prototypes */
1810174267aSFredrik Holmqvist
1820174267aSFredrik Holmqvist static ACPI_STATUS
1830174267aSFredrik Holmqvist AcpiRsMatchVendorResource (
1840174267aSFredrik Holmqvist ACPI_RESOURCE *Resource,
1850174267aSFredrik Holmqvist void *Context);
1860174267aSFredrik Holmqvist
1870174267aSFredrik Holmqvist static ACPI_STATUS
1880174267aSFredrik Holmqvist AcpiRsValidateParameters (
1890174267aSFredrik Holmqvist ACPI_HANDLE DeviceHandle,
1900174267aSFredrik Holmqvist ACPI_BUFFER *Buffer,
1910174267aSFredrik Holmqvist ACPI_NAMESPACE_NODE **ReturnNode);
1920174267aSFredrik Holmqvist
1930174267aSFredrik Holmqvist
1940174267aSFredrik Holmqvist /*******************************************************************************
1950174267aSFredrik Holmqvist *
1960174267aSFredrik Holmqvist * FUNCTION: AcpiRsValidateParameters
1970174267aSFredrik Holmqvist *
1980174267aSFredrik Holmqvist * PARAMETERS: DeviceHandle - Handle to a device
1990174267aSFredrik Holmqvist * Buffer - Pointer to a data buffer
2000174267aSFredrik Holmqvist * ReturnNode - Pointer to where the device node is returned
2010174267aSFredrik Holmqvist *
2020174267aSFredrik Holmqvist * RETURN: Status
2030174267aSFredrik Holmqvist *
2040174267aSFredrik Holmqvist * DESCRIPTION: Common parameter validation for resource interfaces
2050174267aSFredrik Holmqvist *
2060174267aSFredrik Holmqvist ******************************************************************************/
2070174267aSFredrik Holmqvist
2080174267aSFredrik Holmqvist static ACPI_STATUS
AcpiRsValidateParameters(ACPI_HANDLE DeviceHandle,ACPI_BUFFER * Buffer,ACPI_NAMESPACE_NODE ** ReturnNode)2090174267aSFredrik Holmqvist AcpiRsValidateParameters (
2100174267aSFredrik Holmqvist ACPI_HANDLE DeviceHandle,
2110174267aSFredrik Holmqvist ACPI_BUFFER *Buffer,
2120174267aSFredrik Holmqvist ACPI_NAMESPACE_NODE **ReturnNode)
2130174267aSFredrik Holmqvist {
2140174267aSFredrik Holmqvist ACPI_STATUS Status;
2150174267aSFredrik Holmqvist ACPI_NAMESPACE_NODE *Node;
2160174267aSFredrik Holmqvist
2170174267aSFredrik Holmqvist
2180174267aSFredrik Holmqvist ACPI_FUNCTION_TRACE (RsValidateParameters);
2190174267aSFredrik Holmqvist
2200174267aSFredrik Holmqvist
2210174267aSFredrik Holmqvist /*
2220174267aSFredrik Holmqvist * Must have a valid handle to an ACPI device
2230174267aSFredrik Holmqvist */
2240174267aSFredrik Holmqvist if (!DeviceHandle)
2250174267aSFredrik Holmqvist {
2260174267aSFredrik Holmqvist return_ACPI_STATUS (AE_BAD_PARAMETER);
2270174267aSFredrik Holmqvist }
2280174267aSFredrik Holmqvist
2290174267aSFredrik Holmqvist Node = AcpiNsValidateHandle (DeviceHandle);
2300174267aSFredrik Holmqvist if (!Node)
2310174267aSFredrik Holmqvist {
2320174267aSFredrik Holmqvist return_ACPI_STATUS (AE_BAD_PARAMETER);
2330174267aSFredrik Holmqvist }
2340174267aSFredrik Holmqvist
2350174267aSFredrik Holmqvist if (Node->Type != ACPI_TYPE_DEVICE)
2360174267aSFredrik Holmqvist {
2370174267aSFredrik Holmqvist return_ACPI_STATUS (AE_TYPE);
2380174267aSFredrik Holmqvist }
2390174267aSFredrik Holmqvist
2400174267aSFredrik Holmqvist /*
2410174267aSFredrik Holmqvist * Validate the user buffer object
2420174267aSFredrik Holmqvist *
2430174267aSFredrik Holmqvist * if there is a non-zero buffer length we also need a valid pointer in
2440174267aSFredrik Holmqvist * the buffer. If it's a zero buffer length, we'll be returning the
2450174267aSFredrik Holmqvist * needed buffer size (later), so keep going.
2460174267aSFredrik Holmqvist */
2470174267aSFredrik Holmqvist Status = AcpiUtValidateBuffer (Buffer);
2480174267aSFredrik Holmqvist if (ACPI_FAILURE (Status))
2490174267aSFredrik Holmqvist {
2500174267aSFredrik Holmqvist return_ACPI_STATUS (Status);
2510174267aSFredrik Holmqvist }
2520174267aSFredrik Holmqvist
2530174267aSFredrik Holmqvist *ReturnNode = Node;
2540174267aSFredrik Holmqvist return_ACPI_STATUS (AE_OK);
2550174267aSFredrik Holmqvist }
2560174267aSFredrik Holmqvist
2570174267aSFredrik Holmqvist
2580174267aSFredrik Holmqvist /*******************************************************************************
2590174267aSFredrik Holmqvist *
2600174267aSFredrik Holmqvist * FUNCTION: AcpiGetIrqRoutingTable
2610174267aSFredrik Holmqvist *
2620174267aSFredrik Holmqvist * PARAMETERS: DeviceHandle - Handle to the Bus device we are querying
2630174267aSFredrik Holmqvist * RetBuffer - Pointer to a buffer to receive the
2640174267aSFredrik Holmqvist * current resources for the device
2650174267aSFredrik Holmqvist *
2660174267aSFredrik Holmqvist * RETURN: Status
2670174267aSFredrik Holmqvist *
2680174267aSFredrik Holmqvist * DESCRIPTION: This function is called to get the IRQ routing table for a
2690174267aSFredrik Holmqvist * specific bus. The caller must first acquire a handle for the
2700174267aSFredrik Holmqvist * desired bus. The routine table is placed in the buffer pointed
2710174267aSFredrik Holmqvist * to by the RetBuffer variable parameter.
2720174267aSFredrik Holmqvist *
2730174267aSFredrik Holmqvist * If the function fails an appropriate status will be returned
2740174267aSFredrik Holmqvist * and the value of RetBuffer is undefined.
2750174267aSFredrik Holmqvist *
2760174267aSFredrik Holmqvist * This function attempts to execute the _PRT method contained in
2770174267aSFredrik Holmqvist * the object indicated by the passed DeviceHandle.
2780174267aSFredrik Holmqvist *
2790174267aSFredrik Holmqvist ******************************************************************************/
2800174267aSFredrik Holmqvist
2810174267aSFredrik Holmqvist ACPI_STATUS
AcpiGetIrqRoutingTable(ACPI_HANDLE DeviceHandle,ACPI_BUFFER * RetBuffer)2820174267aSFredrik Holmqvist AcpiGetIrqRoutingTable (
2830174267aSFredrik Holmqvist ACPI_HANDLE DeviceHandle,
2840174267aSFredrik Holmqvist ACPI_BUFFER *RetBuffer)
2850174267aSFredrik Holmqvist {
2860174267aSFredrik Holmqvist ACPI_STATUS Status;
2870174267aSFredrik Holmqvist ACPI_NAMESPACE_NODE *Node;
2880174267aSFredrik Holmqvist
2890174267aSFredrik Holmqvist
2900174267aSFredrik Holmqvist ACPI_FUNCTION_TRACE (AcpiGetIrqRoutingTable);
2910174267aSFredrik Holmqvist
2920174267aSFredrik Holmqvist
2930174267aSFredrik Holmqvist /* Validate parameters then dispatch to internal routine */
2940174267aSFredrik Holmqvist
2950174267aSFredrik Holmqvist Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
2960174267aSFredrik Holmqvist if (ACPI_FAILURE (Status))
2970174267aSFredrik Holmqvist {
2980174267aSFredrik Holmqvist return_ACPI_STATUS (Status);
2990174267aSFredrik Holmqvist }
3000174267aSFredrik Holmqvist
3010174267aSFredrik Holmqvist Status = AcpiRsGetPrtMethodData (Node, RetBuffer);
3020174267aSFredrik Holmqvist return_ACPI_STATUS (Status);
3030174267aSFredrik Holmqvist }
3040174267aSFredrik Holmqvist
ACPI_EXPORT_SYMBOL(AcpiGetIrqRoutingTable)3050174267aSFredrik Holmqvist ACPI_EXPORT_SYMBOL (AcpiGetIrqRoutingTable)
3060174267aSFredrik Holmqvist
3070174267aSFredrik Holmqvist
3080174267aSFredrik Holmqvist /*******************************************************************************
3090174267aSFredrik Holmqvist *
3100174267aSFredrik Holmqvist * FUNCTION: AcpiGetCurrentResources
3110174267aSFredrik Holmqvist *
3120174267aSFredrik Holmqvist * PARAMETERS: DeviceHandle - Handle to the device object for the
3130174267aSFredrik Holmqvist * device we are querying
3140174267aSFredrik Holmqvist * RetBuffer - Pointer to a buffer to receive the
3150174267aSFredrik Holmqvist * current resources for the device
3160174267aSFredrik Holmqvist *
3170174267aSFredrik Holmqvist * RETURN: Status
3180174267aSFredrik Holmqvist *
3190174267aSFredrik Holmqvist * DESCRIPTION: This function is called to get the current resources for a
3200174267aSFredrik Holmqvist * specific device. The caller must first acquire a handle for
3210174267aSFredrik Holmqvist * the desired device. The resource data is placed in the buffer
3220174267aSFredrik Holmqvist * pointed to by the RetBuffer variable parameter.
3230174267aSFredrik Holmqvist *
3240174267aSFredrik Holmqvist * If the function fails an appropriate status will be returned
3250174267aSFredrik Holmqvist * and the value of RetBuffer is undefined.
3260174267aSFredrik Holmqvist *
3270174267aSFredrik Holmqvist * This function attempts to execute the _CRS method contained in
3280174267aSFredrik Holmqvist * the object indicated by the passed DeviceHandle.
3290174267aSFredrik Holmqvist *
3300174267aSFredrik Holmqvist ******************************************************************************/
3310174267aSFredrik Holmqvist
3320174267aSFredrik Holmqvist ACPI_STATUS
3330174267aSFredrik Holmqvist AcpiGetCurrentResources (
3340174267aSFredrik Holmqvist ACPI_HANDLE DeviceHandle,
3350174267aSFredrik Holmqvist ACPI_BUFFER *RetBuffer)
3360174267aSFredrik Holmqvist {
3370174267aSFredrik Holmqvist ACPI_STATUS Status;
3380174267aSFredrik Holmqvist ACPI_NAMESPACE_NODE *Node;
3390174267aSFredrik Holmqvist
3400174267aSFredrik Holmqvist
3410174267aSFredrik Holmqvist ACPI_FUNCTION_TRACE (AcpiGetCurrentResources);
3420174267aSFredrik Holmqvist
3430174267aSFredrik Holmqvist
3440174267aSFredrik Holmqvist /* Validate parameters then dispatch to internal routine */
3450174267aSFredrik Holmqvist
3460174267aSFredrik Holmqvist Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
3470174267aSFredrik Holmqvist if (ACPI_FAILURE (Status))
3480174267aSFredrik Holmqvist {
3490174267aSFredrik Holmqvist return_ACPI_STATUS (Status);
3500174267aSFredrik Holmqvist }
3510174267aSFredrik Holmqvist
3520174267aSFredrik Holmqvist Status = AcpiRsGetCrsMethodData (Node, RetBuffer);
3530174267aSFredrik Holmqvist return_ACPI_STATUS (Status);
3540174267aSFredrik Holmqvist }
3550174267aSFredrik Holmqvist
ACPI_EXPORT_SYMBOL(AcpiGetCurrentResources)3560174267aSFredrik Holmqvist ACPI_EXPORT_SYMBOL (AcpiGetCurrentResources)
3570174267aSFredrik Holmqvist
3580174267aSFredrik Holmqvist
3590174267aSFredrik Holmqvist /*******************************************************************************
3600174267aSFredrik Holmqvist *
3610174267aSFredrik Holmqvist * FUNCTION: AcpiGetPossibleResources
3620174267aSFredrik Holmqvist *
3630174267aSFredrik Holmqvist * PARAMETERS: DeviceHandle - Handle to the device object for the
3640174267aSFredrik Holmqvist * device we are querying
3650174267aSFredrik Holmqvist * RetBuffer - Pointer to a buffer to receive the
3660174267aSFredrik Holmqvist * resources for the device
3670174267aSFredrik Holmqvist *
3680174267aSFredrik Holmqvist * RETURN: Status
3690174267aSFredrik Holmqvist *
3700174267aSFredrik Holmqvist * DESCRIPTION: This function is called to get a list of the possible resources
3710174267aSFredrik Holmqvist * for a specific device. The caller must first acquire a handle
3720174267aSFredrik Holmqvist * for the desired device. The resource data is placed in the
3730174267aSFredrik Holmqvist * buffer pointed to by the RetBuffer variable.
3740174267aSFredrik Holmqvist *
3750174267aSFredrik Holmqvist * If the function fails an appropriate status will be returned
3760174267aSFredrik Holmqvist * and the value of RetBuffer is undefined.
3770174267aSFredrik Holmqvist *
3780174267aSFredrik Holmqvist ******************************************************************************/
3790174267aSFredrik Holmqvist
3800174267aSFredrik Holmqvist ACPI_STATUS
3810174267aSFredrik Holmqvist AcpiGetPossibleResources (
3820174267aSFredrik Holmqvist ACPI_HANDLE DeviceHandle,
3830174267aSFredrik Holmqvist ACPI_BUFFER *RetBuffer)
3840174267aSFredrik Holmqvist {
3850174267aSFredrik Holmqvist ACPI_STATUS Status;
3860174267aSFredrik Holmqvist ACPI_NAMESPACE_NODE *Node;
3870174267aSFredrik Holmqvist
3880174267aSFredrik Holmqvist
3890174267aSFredrik Holmqvist ACPI_FUNCTION_TRACE (AcpiGetPossibleResources);
3900174267aSFredrik Holmqvist
3910174267aSFredrik Holmqvist
3920174267aSFredrik Holmqvist /* Validate parameters then dispatch to internal routine */
3930174267aSFredrik Holmqvist
3940174267aSFredrik Holmqvist Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
3950174267aSFredrik Holmqvist if (ACPI_FAILURE (Status))
3960174267aSFredrik Holmqvist {
3970174267aSFredrik Holmqvist return_ACPI_STATUS (Status);
3980174267aSFredrik Holmqvist }
3990174267aSFredrik Holmqvist
4000174267aSFredrik Holmqvist Status = AcpiRsGetPrsMethodData (Node, RetBuffer);
4010174267aSFredrik Holmqvist return_ACPI_STATUS (Status);
4020174267aSFredrik Holmqvist }
4030174267aSFredrik Holmqvist
ACPI_EXPORT_SYMBOL(AcpiGetPossibleResources)4040174267aSFredrik Holmqvist ACPI_EXPORT_SYMBOL (AcpiGetPossibleResources)
4050174267aSFredrik Holmqvist
4060174267aSFredrik Holmqvist
4070174267aSFredrik Holmqvist /*******************************************************************************
4080174267aSFredrik Holmqvist *
4090174267aSFredrik Holmqvist * FUNCTION: AcpiSetCurrentResources
4100174267aSFredrik Holmqvist *
4110174267aSFredrik Holmqvist * PARAMETERS: DeviceHandle - Handle to the device object for the
4120174267aSFredrik Holmqvist * device we are setting resources
4130174267aSFredrik Holmqvist * InBuffer - Pointer to a buffer containing the
4140174267aSFredrik Holmqvist * resources to be set for the device
4150174267aSFredrik Holmqvist *
4160174267aSFredrik Holmqvist * RETURN: Status
4170174267aSFredrik Holmqvist *
4180174267aSFredrik Holmqvist * DESCRIPTION: This function is called to set the current resources for a
4190174267aSFredrik Holmqvist * specific device. The caller must first acquire a handle for
4200174267aSFredrik Holmqvist * the desired device. The resource data is passed to the routine
4210174267aSFredrik Holmqvist * the buffer pointed to by the InBuffer variable.
4220174267aSFredrik Holmqvist *
4230174267aSFredrik Holmqvist ******************************************************************************/
4240174267aSFredrik Holmqvist
4250174267aSFredrik Holmqvist ACPI_STATUS
4260174267aSFredrik Holmqvist AcpiSetCurrentResources (
4270174267aSFredrik Holmqvist ACPI_HANDLE DeviceHandle,
4280174267aSFredrik Holmqvist ACPI_BUFFER *InBuffer)
4290174267aSFredrik Holmqvist {
4300174267aSFredrik Holmqvist ACPI_STATUS Status;
4310174267aSFredrik Holmqvist ACPI_NAMESPACE_NODE *Node;
4320174267aSFredrik Holmqvist
4330174267aSFredrik Holmqvist
4340174267aSFredrik Holmqvist ACPI_FUNCTION_TRACE (AcpiSetCurrentResources);
4350174267aSFredrik Holmqvist
4360174267aSFredrik Holmqvist
4370174267aSFredrik Holmqvist /* Validate the buffer, don't allow zero length */
4380174267aSFredrik Holmqvist
4390174267aSFredrik Holmqvist if ((!InBuffer) ||
4400174267aSFredrik Holmqvist (!InBuffer->Pointer) ||
4410174267aSFredrik Holmqvist (!InBuffer->Length))
4420174267aSFredrik Holmqvist {
4430174267aSFredrik Holmqvist return_ACPI_STATUS (AE_BAD_PARAMETER);
4440174267aSFredrik Holmqvist }
4450174267aSFredrik Holmqvist
4460174267aSFredrik Holmqvist /* Validate parameters then dispatch to internal routine */
4470174267aSFredrik Holmqvist
4480174267aSFredrik Holmqvist Status = AcpiRsValidateParameters (DeviceHandle, InBuffer, &Node);
4490174267aSFredrik Holmqvist if (ACPI_FAILURE (Status))
4500174267aSFredrik Holmqvist {
4510174267aSFredrik Holmqvist return_ACPI_STATUS (Status);
4520174267aSFredrik Holmqvist }
4530174267aSFredrik Holmqvist
4540174267aSFredrik Holmqvist Status = AcpiRsSetSrsMethodData (Node, InBuffer);
4550174267aSFredrik Holmqvist return_ACPI_STATUS (Status);
4560174267aSFredrik Holmqvist }
4570174267aSFredrik Holmqvist
ACPI_EXPORT_SYMBOL(AcpiSetCurrentResources)4580174267aSFredrik Holmqvist ACPI_EXPORT_SYMBOL (AcpiSetCurrentResources)
4590174267aSFredrik Holmqvist
4600174267aSFredrik Holmqvist
4616822cda0SFredrik Holmqvist /*******************************************************************************
4626822cda0SFredrik Holmqvist *
4636822cda0SFredrik Holmqvist * FUNCTION: AcpiGetEventResources
4646822cda0SFredrik Holmqvist *
4656822cda0SFredrik Holmqvist * PARAMETERS: DeviceHandle - Handle to the device object for the
4666822cda0SFredrik Holmqvist * device we are getting resources
4676822cda0SFredrik Holmqvist * InBuffer - Pointer to a buffer containing the
4686822cda0SFredrik Holmqvist * resources to be set for the device
4696822cda0SFredrik Holmqvist *
4706822cda0SFredrik Holmqvist * RETURN: Status
4716822cda0SFredrik Holmqvist *
4726822cda0SFredrik Holmqvist * DESCRIPTION: This function is called to get the event resources for a
4736822cda0SFredrik Holmqvist * specific device. The caller must first acquire a handle for
4746822cda0SFredrik Holmqvist * the desired device. The resource data is passed to the routine
4756822cda0SFredrik Holmqvist * the buffer pointed to by the InBuffer variable. Uses the
4766822cda0SFredrik Holmqvist * _AEI method.
4776822cda0SFredrik Holmqvist *
4786822cda0SFredrik Holmqvist ******************************************************************************/
4796822cda0SFredrik Holmqvist
4806822cda0SFredrik Holmqvist ACPI_STATUS
4816822cda0SFredrik Holmqvist AcpiGetEventResources (
4826822cda0SFredrik Holmqvist ACPI_HANDLE DeviceHandle,
4836822cda0SFredrik Holmqvist ACPI_BUFFER *RetBuffer)
4846822cda0SFredrik Holmqvist {
4856822cda0SFredrik Holmqvist ACPI_STATUS Status;
4866822cda0SFredrik Holmqvist ACPI_NAMESPACE_NODE *Node;
4876822cda0SFredrik Holmqvist
4886822cda0SFredrik Holmqvist
4896822cda0SFredrik Holmqvist ACPI_FUNCTION_TRACE (AcpiGetEventResources);
4906822cda0SFredrik Holmqvist
4916822cda0SFredrik Holmqvist
4926822cda0SFredrik Holmqvist /* Validate parameters then dispatch to internal routine */
4936822cda0SFredrik Holmqvist
4946822cda0SFredrik Holmqvist Status = AcpiRsValidateParameters (DeviceHandle, RetBuffer, &Node);
4956822cda0SFredrik Holmqvist if (ACPI_FAILURE (Status))
4966822cda0SFredrik Holmqvist {
4976822cda0SFredrik Holmqvist return_ACPI_STATUS (Status);
4986822cda0SFredrik Holmqvist }
4996822cda0SFredrik Holmqvist
5006822cda0SFredrik Holmqvist Status = AcpiRsGetAeiMethodData (Node, RetBuffer);
5016822cda0SFredrik Holmqvist return_ACPI_STATUS (Status);
5026822cda0SFredrik Holmqvist }
5036822cda0SFredrik Holmqvist
ACPI_EXPORT_SYMBOL(AcpiGetEventResources)5046822cda0SFredrik Holmqvist ACPI_EXPORT_SYMBOL (AcpiGetEventResources)
5056822cda0SFredrik Holmqvist
5066822cda0SFredrik Holmqvist
5070174267aSFredrik Holmqvist /******************************************************************************
5080174267aSFredrik Holmqvist *
5090174267aSFredrik Holmqvist * FUNCTION: AcpiResourceToAddress64
5100174267aSFredrik Holmqvist *
5110174267aSFredrik Holmqvist * PARAMETERS: Resource - Pointer to a resource
5120174267aSFredrik Holmqvist * Out - Pointer to the users's return buffer
5130174267aSFredrik Holmqvist * (a struct acpi_resource_address64)
5140174267aSFredrik Holmqvist *
5150174267aSFredrik Holmqvist * RETURN: Status
5160174267aSFredrik Holmqvist *
5170174267aSFredrik Holmqvist * DESCRIPTION: If the resource is an address16, address32, or address64,
5180174267aSFredrik Holmqvist * copy it to the address64 return buffer. This saves the
5190174267aSFredrik Holmqvist * caller from having to duplicate code for different-sized
5200174267aSFredrik Holmqvist * addresses.
5210174267aSFredrik Holmqvist *
5220174267aSFredrik Holmqvist ******************************************************************************/
5230174267aSFredrik Holmqvist
5240174267aSFredrik Holmqvist ACPI_STATUS
5250174267aSFredrik Holmqvist AcpiResourceToAddress64 (
5260174267aSFredrik Holmqvist ACPI_RESOURCE *Resource,
5270174267aSFredrik Holmqvist ACPI_RESOURCE_ADDRESS64 *Out)
5280174267aSFredrik Holmqvist {
5290174267aSFredrik Holmqvist ACPI_RESOURCE_ADDRESS16 *Address16;
5300174267aSFredrik Holmqvist ACPI_RESOURCE_ADDRESS32 *Address32;
5310174267aSFredrik Holmqvist
5320174267aSFredrik Holmqvist
5330174267aSFredrik Holmqvist if (!Resource || !Out)
5340174267aSFredrik Holmqvist {
5350174267aSFredrik Holmqvist return (AE_BAD_PARAMETER);
5360174267aSFredrik Holmqvist }
5370174267aSFredrik Holmqvist
5380174267aSFredrik Holmqvist /* Convert 16 or 32 address descriptor to 64 */
5390174267aSFredrik Holmqvist
5400174267aSFredrik Holmqvist switch (Resource->Type)
5410174267aSFredrik Holmqvist {
5420174267aSFredrik Holmqvist case ACPI_RESOURCE_TYPE_ADDRESS16:
5430174267aSFredrik Holmqvist
544b64e8511SFredrik Holmqvist Address16 = ACPI_CAST_PTR (
545b64e8511SFredrik Holmqvist ACPI_RESOURCE_ADDRESS16, &Resource->Data);
5460174267aSFredrik Holmqvist ACPI_COPY_ADDRESS (Out, Address16);
5470174267aSFredrik Holmqvist break;
5480174267aSFredrik Holmqvist
5490174267aSFredrik Holmqvist case ACPI_RESOURCE_TYPE_ADDRESS32:
5500174267aSFredrik Holmqvist
551b64e8511SFredrik Holmqvist Address32 = ACPI_CAST_PTR (
552b64e8511SFredrik Holmqvist ACPI_RESOURCE_ADDRESS32, &Resource->Data);
5530174267aSFredrik Holmqvist ACPI_COPY_ADDRESS (Out, Address32);
5540174267aSFredrik Holmqvist break;
5550174267aSFredrik Holmqvist
5560174267aSFredrik Holmqvist case ACPI_RESOURCE_TYPE_ADDRESS64:
5570174267aSFredrik Holmqvist
5580174267aSFredrik Holmqvist /* Simple copy for 64 bit source */
5590174267aSFredrik Holmqvist
560e226d1d0SFredrik Holmqvist memcpy (Out, &Resource->Data, sizeof (ACPI_RESOURCE_ADDRESS64));
5610174267aSFredrik Holmqvist break;
5620174267aSFredrik Holmqvist
5630174267aSFredrik Holmqvist default:
564c70258b7SJérôme Duval
5650174267aSFredrik Holmqvist return (AE_BAD_PARAMETER);
5660174267aSFredrik Holmqvist }
5670174267aSFredrik Holmqvist
5680174267aSFredrik Holmqvist return (AE_OK);
5690174267aSFredrik Holmqvist }
5700174267aSFredrik Holmqvist
ACPI_EXPORT_SYMBOL(AcpiResourceToAddress64)5710174267aSFredrik Holmqvist ACPI_EXPORT_SYMBOL (AcpiResourceToAddress64)
5720174267aSFredrik Holmqvist
5730174267aSFredrik Holmqvist
5740174267aSFredrik Holmqvist /*******************************************************************************
5750174267aSFredrik Holmqvist *
5760174267aSFredrik Holmqvist * FUNCTION: AcpiGetVendorResource
5770174267aSFredrik Holmqvist *
5780174267aSFredrik Holmqvist * PARAMETERS: DeviceHandle - Handle for the parent device object
5790174267aSFredrik Holmqvist * Name - Method name for the parent resource
5800174267aSFredrik Holmqvist * (METHOD_NAME__CRS or METHOD_NAME__PRS)
5810174267aSFredrik Holmqvist * Uuid - Pointer to the UUID to be matched.
5820174267aSFredrik Holmqvist * includes both subtype and 16-byte UUID
5830174267aSFredrik Holmqvist * RetBuffer - Where the vendor resource is returned
5840174267aSFredrik Holmqvist *
5850174267aSFredrik Holmqvist * RETURN: Status
5860174267aSFredrik Holmqvist *
587c70258b7SJérôme Duval * DESCRIPTION: Walk a resource template for the specified device to find a
5880174267aSFredrik Holmqvist * vendor-defined resource that matches the supplied UUID and
5890174267aSFredrik Holmqvist * UUID subtype. Returns a ACPI_RESOURCE of type Vendor.
5900174267aSFredrik Holmqvist *
5910174267aSFredrik Holmqvist ******************************************************************************/
5920174267aSFredrik Holmqvist
5930174267aSFredrik Holmqvist ACPI_STATUS
5940174267aSFredrik Holmqvist AcpiGetVendorResource (
5950174267aSFredrik Holmqvist ACPI_HANDLE DeviceHandle,
5960174267aSFredrik Holmqvist char *Name,
5970174267aSFredrik Holmqvist ACPI_VENDOR_UUID *Uuid,
5980174267aSFredrik Holmqvist ACPI_BUFFER *RetBuffer)
5990174267aSFredrik Holmqvist {
6000174267aSFredrik Holmqvist ACPI_VENDOR_WALK_INFO Info;
6010174267aSFredrik Holmqvist ACPI_STATUS Status;
6020174267aSFredrik Holmqvist
6030174267aSFredrik Holmqvist
6040174267aSFredrik Holmqvist /* Other parameters are validated by AcpiWalkResources */
6050174267aSFredrik Holmqvist
6060174267aSFredrik Holmqvist if (!Uuid || !RetBuffer)
6070174267aSFredrik Holmqvist {
6080174267aSFredrik Holmqvist return (AE_BAD_PARAMETER);
6090174267aSFredrik Holmqvist }
6100174267aSFredrik Holmqvist
6110174267aSFredrik Holmqvist Info.Uuid = Uuid;
6120174267aSFredrik Holmqvist Info.Buffer = RetBuffer;
6130174267aSFredrik Holmqvist Info.Status = AE_NOT_EXIST;
6140174267aSFredrik Holmqvist
6150174267aSFredrik Holmqvist /* Walk the _CRS or _PRS resource list for this device */
6160174267aSFredrik Holmqvist
617b64e8511SFredrik Holmqvist Status = AcpiWalkResources (
618b64e8511SFredrik Holmqvist DeviceHandle, Name, AcpiRsMatchVendorResource, &Info);
6190174267aSFredrik Holmqvist if (ACPI_FAILURE (Status))
6200174267aSFredrik Holmqvist {
6210174267aSFredrik Holmqvist return (Status);
6220174267aSFredrik Holmqvist }
6230174267aSFredrik Holmqvist
6240174267aSFredrik Holmqvist return (Info.Status);
6250174267aSFredrik Holmqvist }
6260174267aSFredrik Holmqvist
ACPI_EXPORT_SYMBOL(AcpiGetVendorResource)6270174267aSFredrik Holmqvist ACPI_EXPORT_SYMBOL (AcpiGetVendorResource)
6280174267aSFredrik Holmqvist
6290174267aSFredrik Holmqvist
6300174267aSFredrik Holmqvist /*******************************************************************************
6310174267aSFredrik Holmqvist *
6320174267aSFredrik Holmqvist * FUNCTION: AcpiRsMatchVendorResource
6330174267aSFredrik Holmqvist *
6340174267aSFredrik Holmqvist * PARAMETERS: ACPI_WALK_RESOURCE_CALLBACK
6350174267aSFredrik Holmqvist *
6360174267aSFredrik Holmqvist * RETURN: Status
6370174267aSFredrik Holmqvist *
6380174267aSFredrik Holmqvist * DESCRIPTION: Match a vendor resource via the ACPI 3.0 UUID
6390174267aSFredrik Holmqvist *
6400174267aSFredrik Holmqvist ******************************************************************************/
6410174267aSFredrik Holmqvist
6420174267aSFredrik Holmqvist static ACPI_STATUS
6430174267aSFredrik Holmqvist AcpiRsMatchVendorResource (
6440174267aSFredrik Holmqvist ACPI_RESOURCE *Resource,
6450174267aSFredrik Holmqvist void *Context)
6460174267aSFredrik Holmqvist {
6470174267aSFredrik Holmqvist ACPI_VENDOR_WALK_INFO *Info = Context;
6480174267aSFredrik Holmqvist ACPI_RESOURCE_VENDOR_TYPED *Vendor;
6490174267aSFredrik Holmqvist ACPI_BUFFER *Buffer;
6500174267aSFredrik Holmqvist ACPI_STATUS Status;
6510174267aSFredrik Holmqvist
6520174267aSFredrik Holmqvist
6530174267aSFredrik Holmqvist /* Ignore all descriptors except Vendor */
6540174267aSFredrik Holmqvist
6550174267aSFredrik Holmqvist if (Resource->Type != ACPI_RESOURCE_TYPE_VENDOR)
6560174267aSFredrik Holmqvist {
6570174267aSFredrik Holmqvist return (AE_OK);
6580174267aSFredrik Holmqvist }
6590174267aSFredrik Holmqvist
6600174267aSFredrik Holmqvist Vendor = &Resource->Data.VendorTyped;
6610174267aSFredrik Holmqvist
6620174267aSFredrik Holmqvist /*
6630174267aSFredrik Holmqvist * For a valid match, these conditions must hold:
6640174267aSFredrik Holmqvist *
6650174267aSFredrik Holmqvist * 1) Length of descriptor data must be at least as long as a UUID struct
6660174267aSFredrik Holmqvist * 2) The UUID subtypes must match
6670174267aSFredrik Holmqvist * 3) The UUID data must match
6680174267aSFredrik Holmqvist */
6690174267aSFredrik Holmqvist if ((Vendor->ByteLength < (ACPI_UUID_LENGTH + 1)) ||
6700174267aSFredrik Holmqvist (Vendor->UuidSubtype != Info->Uuid->Subtype) ||
671e226d1d0SFredrik Holmqvist (memcmp (Vendor->Uuid, Info->Uuid->Data, ACPI_UUID_LENGTH)))
6720174267aSFredrik Holmqvist {
6730174267aSFredrik Holmqvist return (AE_OK);
6740174267aSFredrik Holmqvist }
6750174267aSFredrik Holmqvist
6760174267aSFredrik Holmqvist /* Validate/Allocate/Clear caller buffer */
6770174267aSFredrik Holmqvist
6780174267aSFredrik Holmqvist Buffer = Info->Buffer;
6790174267aSFredrik Holmqvist Status = AcpiUtInitializeBuffer (Buffer, Resource->Length);
6800174267aSFredrik Holmqvist if (ACPI_FAILURE (Status))
6810174267aSFredrik Holmqvist {
6820174267aSFredrik Holmqvist return (Status);
6830174267aSFredrik Holmqvist }
6840174267aSFredrik Holmqvist
6850174267aSFredrik Holmqvist /* Found the correct resource, copy and return it */
6860174267aSFredrik Holmqvist
687e226d1d0SFredrik Holmqvist memcpy (Buffer->Pointer, Resource, Resource->Length);
6880174267aSFredrik Holmqvist Buffer->Length = Resource->Length;
6890174267aSFredrik Holmqvist
6900174267aSFredrik Holmqvist /* Found the desired descriptor, terminate resource walk */
6910174267aSFredrik Holmqvist
6920174267aSFredrik Holmqvist Info->Status = AE_OK;
6930174267aSFredrik Holmqvist return (AE_CTRL_TERMINATE);
6940174267aSFredrik Holmqvist }
6950174267aSFredrik Holmqvist
6960174267aSFredrik Holmqvist
6970174267aSFredrik Holmqvist /*******************************************************************************
6980174267aSFredrik Holmqvist *
699c70258b7SJérôme Duval * FUNCTION: AcpiWalkResourceBuffer
700c70258b7SJérôme Duval *
701c70258b7SJérôme Duval * PARAMETERS: Buffer - Formatted buffer returned by one of the
702c70258b7SJérôme Duval * various Get*Resource functions
703c70258b7SJérôme Duval * UserFunction - Called for each resource
704c70258b7SJérôme Duval * Context - Passed to UserFunction
705c70258b7SJérôme Duval *
706c70258b7SJérôme Duval * RETURN: Status
707c70258b7SJérôme Duval *
708c70258b7SJérôme Duval * DESCRIPTION: Walks the input resource template. The UserFunction is called
709c70258b7SJérôme Duval * once for each resource in the list.
710c70258b7SJérôme Duval *
711c70258b7SJérôme Duval ******************************************************************************/
712c70258b7SJérôme Duval
713c70258b7SJérôme Duval ACPI_STATUS
AcpiWalkResourceBuffer(ACPI_BUFFER * Buffer,ACPI_WALK_RESOURCE_CALLBACK UserFunction,void * Context)714c70258b7SJérôme Duval AcpiWalkResourceBuffer (
715c70258b7SJérôme Duval ACPI_BUFFER *Buffer,
716c70258b7SJérôme Duval ACPI_WALK_RESOURCE_CALLBACK UserFunction,
717c70258b7SJérôme Duval void *Context)
718c70258b7SJérôme Duval {
719c70258b7SJérôme Duval ACPI_STATUS Status = AE_OK;
720c70258b7SJérôme Duval ACPI_RESOURCE *Resource;
721c70258b7SJérôme Duval ACPI_RESOURCE *ResourceEnd;
722c70258b7SJérôme Duval
723c70258b7SJérôme Duval
724c70258b7SJérôme Duval ACPI_FUNCTION_TRACE (AcpiWalkResourceBuffer);
725c70258b7SJérôme Duval
726c70258b7SJérôme Duval
727c70258b7SJérôme Duval /* Parameter validation */
728c70258b7SJérôme Duval
729c70258b7SJérôme Duval if (!Buffer || !Buffer->Pointer || !UserFunction)
730c70258b7SJérôme Duval {
731c70258b7SJérôme Duval return_ACPI_STATUS (AE_BAD_PARAMETER);
732c70258b7SJérôme Duval }
733c70258b7SJérôme Duval
734c70258b7SJérôme Duval /* Buffer contains the resource list and length */
735c70258b7SJérôme Duval
736c70258b7SJérôme Duval Resource = ACPI_CAST_PTR (ACPI_RESOURCE, Buffer->Pointer);
737b64e8511SFredrik Holmqvist ResourceEnd = ACPI_ADD_PTR (
738b64e8511SFredrik Holmqvist ACPI_RESOURCE, Buffer->Pointer, Buffer->Length);
739c70258b7SJérôme Duval
740c70258b7SJérôme Duval /* Walk the resource list until the EndTag is found (or buffer end) */
741c70258b7SJérôme Duval
742c70258b7SJérôme Duval while (Resource < ResourceEnd)
743c70258b7SJérôme Duval {
744c70258b7SJérôme Duval /* Sanity check the resource type */
745c70258b7SJérôme Duval
746c70258b7SJérôme Duval if (Resource->Type > ACPI_RESOURCE_TYPE_MAX)
747c70258b7SJérôme Duval {
748c70258b7SJérôme Duval Status = AE_AML_INVALID_RESOURCE_TYPE;
749c70258b7SJérôme Duval break;
750c70258b7SJérôme Duval }
751c70258b7SJérôme Duval
752c70258b7SJérôme Duval /* Sanity check the length. It must not be zero, or we loop forever */
753c70258b7SJérôme Duval
754c70258b7SJérôme Duval if (!Resource->Length)
755c70258b7SJérôme Duval {
756c70258b7SJérôme Duval return_ACPI_STATUS (AE_AML_BAD_RESOURCE_LENGTH);
757c70258b7SJérôme Duval }
758c70258b7SJérôme Duval
759c70258b7SJérôme Duval /* Invoke the user function, abort on any error returned */
760c70258b7SJérôme Duval
761c70258b7SJérôme Duval Status = UserFunction (Resource, Context);
762c70258b7SJérôme Duval if (ACPI_FAILURE (Status))
763c70258b7SJérôme Duval {
764c70258b7SJérôme Duval if (Status == AE_CTRL_TERMINATE)
765c70258b7SJérôme Duval {
766c70258b7SJérôme Duval /* This is an OK termination by the user function */
767c70258b7SJérôme Duval
768c70258b7SJérôme Duval Status = AE_OK;
769c70258b7SJérôme Duval }
770c70258b7SJérôme Duval break;
771c70258b7SJérôme Duval }
772c70258b7SJérôme Duval
773c70258b7SJérôme Duval /* EndTag indicates end-of-list */
774c70258b7SJérôme Duval
775c70258b7SJérôme Duval if (Resource->Type == ACPI_RESOURCE_TYPE_END_TAG)
776c70258b7SJérôme Duval {
777c70258b7SJérôme Duval break;
778c70258b7SJérôme Duval }
779c70258b7SJérôme Duval
780c70258b7SJérôme Duval /* Get the next resource descriptor */
781c70258b7SJérôme Duval
782c70258b7SJérôme Duval Resource = ACPI_NEXT_RESOURCE (Resource);
783c70258b7SJérôme Duval }
784c70258b7SJérôme Duval
785c70258b7SJérôme Duval return_ACPI_STATUS (Status);
786c70258b7SJérôme Duval }
787c70258b7SJérôme Duval
ACPI_EXPORT_SYMBOL(AcpiWalkResourceBuffer)788c70258b7SJérôme Duval ACPI_EXPORT_SYMBOL (AcpiWalkResourceBuffer)
789c70258b7SJérôme Duval
790c70258b7SJérôme Duval
791c70258b7SJérôme Duval /*******************************************************************************
792c70258b7SJérôme Duval *
7930174267aSFredrik Holmqvist * FUNCTION: AcpiWalkResources
7940174267aSFredrik Holmqvist *
7950174267aSFredrik Holmqvist * PARAMETERS: DeviceHandle - Handle to the device object for the
7960174267aSFredrik Holmqvist * device we are querying
7976822cda0SFredrik Holmqvist * Name - Method name of the resources we want.
7986822cda0SFredrik Holmqvist * (METHOD_NAME__CRS, METHOD_NAME__PRS, or
799ff2e2f81SFredrik Holmqvist * METHOD_NAME__AEI or METHOD_NAME__DMA)
8000174267aSFredrik Holmqvist * UserFunction - Called for each resource
8010174267aSFredrik Holmqvist * Context - Passed to UserFunction
8020174267aSFredrik Holmqvist *
8030174267aSFredrik Holmqvist * RETURN: Status
8040174267aSFredrik Holmqvist *
8050174267aSFredrik Holmqvist * DESCRIPTION: Retrieves the current or possible resource list for the
8060174267aSFredrik Holmqvist * specified device. The UserFunction is called once for
8070174267aSFredrik Holmqvist * each resource in the list.
8080174267aSFredrik Holmqvist *
8090174267aSFredrik Holmqvist ******************************************************************************/
8100174267aSFredrik Holmqvist
8110174267aSFredrik Holmqvist ACPI_STATUS
8120174267aSFredrik Holmqvist AcpiWalkResources (
8130174267aSFredrik Holmqvist ACPI_HANDLE DeviceHandle,
8140174267aSFredrik Holmqvist char *Name,
8150174267aSFredrik Holmqvist ACPI_WALK_RESOURCE_CALLBACK UserFunction,
8160174267aSFredrik Holmqvist void *Context)
8170174267aSFredrik Holmqvist {
8180174267aSFredrik Holmqvist ACPI_STATUS Status;
8190174267aSFredrik Holmqvist ACPI_BUFFER Buffer;
8200174267aSFredrik Holmqvist
8210174267aSFredrik Holmqvist
8220174267aSFredrik Holmqvist ACPI_FUNCTION_TRACE (AcpiWalkResources);
8230174267aSFredrik Holmqvist
8240174267aSFredrik Holmqvist
8250174267aSFredrik Holmqvist /* Parameter validation */
8260174267aSFredrik Holmqvist
8270174267aSFredrik Holmqvist if (!DeviceHandle || !UserFunction || !Name ||
8280ffed378SFredrik Holmqvist (!ACPI_COMPARE_NAMESEG (Name, METHOD_NAME__CRS) &&
8290ffed378SFredrik Holmqvist !ACPI_COMPARE_NAMESEG (Name, METHOD_NAME__PRS) &&
8300ffed378SFredrik Holmqvist !ACPI_COMPARE_NAMESEG (Name, METHOD_NAME__AEI) &&
8310ffed378SFredrik Holmqvist !ACPI_COMPARE_NAMESEG (Name, METHOD_NAME__DMA)))
8320174267aSFredrik Holmqvist {
8330174267aSFredrik Holmqvist return_ACPI_STATUS (AE_BAD_PARAMETER);
8340174267aSFredrik Holmqvist }
8350174267aSFredrik Holmqvist
836ff2e2f81SFredrik Holmqvist /* Get the _CRS/_PRS/_AEI/_DMA resource list */
8370174267aSFredrik Holmqvist
8380174267aSFredrik Holmqvist Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
8390174267aSFredrik Holmqvist Status = AcpiRsGetMethodData (DeviceHandle, Name, &Buffer);
8400174267aSFredrik Holmqvist if (ACPI_FAILURE (Status))
8410174267aSFredrik Holmqvist {
8420174267aSFredrik Holmqvist return_ACPI_STATUS (Status);
8430174267aSFredrik Holmqvist }
8440174267aSFredrik Holmqvist
845c70258b7SJérôme Duval /* Walk the resource list and cleanup */
8460174267aSFredrik Holmqvist
847c70258b7SJérôme Duval Status = AcpiWalkResourceBuffer (&Buffer, UserFunction, Context);
8480174267aSFredrik Holmqvist ACPI_FREE (Buffer.Pointer);
8490174267aSFredrik Holmqvist return_ACPI_STATUS (Status);
8500174267aSFredrik Holmqvist }
8510174267aSFredrik Holmqvist
8520174267aSFredrik Holmqvist ACPI_EXPORT_SYMBOL (AcpiWalkResources)
853