rsxface.c revision 91116
119304Speter/*******************************************************************************
219304Speter *
319304Speter * Module Name: rsxface - Public interfaces to the resource manager
419304Speter *              $Revision: 18 $
519304Speter *
619304Speter ******************************************************************************/
719304Speter
819304Speter/******************************************************************************
919304Speter *
1019304Speter * 1. Copyright Notice
1119304Speter *
1219304Speter * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
1319304Speter * All rights reserved.
1419304Speter *
1519304Speter * 2. License
1619304Speter *
1719304Speter * 2.1. This is your license from Intel Corp. under its intellectual property
1819304Speter * rights.  You may have additional license terms from the party that provided
1919304Speter * you this software, covering your right to use that party's intellectual
2019304Speter * property rights.
2119304Speter *
2219304Speter * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
2319304Speter * copy of the source code appearing in this file ("Covered Code") an
2419304Speter * irrevocable, perpetual, worldwide license under Intel's copyrights in the
2519304Speter * base code distributed originally by Intel ("Original Intel Code") to copy,
2619304Speter * make derivatives, distribute, use and display any portion of the Covered
2719304Speter * Code in any form, with the right to sublicense such rights; and
2819304Speter *
2919304Speter * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
3019304Speter * license (with the right to sublicense), under only those claims of Intel
3119304Speter * patents that are infringed by the Original Intel Code, to make, use, sell,
3219304Speter * offer to sell, and import the Covered Code and derivative works thereof
3319304Speter * solely to the minimum extent necessary to exercise the above copyright
3419304Speter * license, and in no event shall the patent license extend to any additions
3519304Speter * to or modifications of the Original Intel Code.  No other license or right
3619304Speter * is granted directly or by implication, estoppel or otherwise;
3719304Speter *
3819304Speter * The above copyright and patent license is granted only if the following
3919304Speter * conditions are met:
4019304Speter *
4119304Speter * 3. Conditions
4219304Speter *
4319304Speter * 3.1. Redistribution of Source with Rights to Further Distribute Source.
4419304Speter * Redistribution of source code of any substantial portion of the Covered
4519304Speter * Code or modification with rights to further distribute source must include
4619304Speter * the above Copyright Notice, the above License, this list of Conditions,
4719304Speter * and the following Disclaimer and Export Compliance provision.  In addition,
4819304Speter * Licensee must cause all Covered Code to which Licensee contributes to
4919304Speter * contain a file documenting the changes Licensee made to create that Covered
5019304Speter * Code and the date of any change.  Licensee must include in that file the
5119304Speter * documentation of any changes made by any predecessor Licensee.  Licensee
5219304Speter * must include a prominent statement that the modification is derived,
5319304Speter * directly or indirectly, from Original Intel Code.
5419304Speter *
5519304Speter * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
5619304Speter * Redistribution of source code of any substantial portion of the Covered
5719304Speter * Code or modification without rights to further distribute source must
5819304Speter * include the following Disclaimer and Export Compliance provision in the
5919304Speter * documentation and/or other materials provided with distribution.  In
6019304Speter * addition, Licensee may not authorize further sublicense of source of any
6119304Speter * portion of the Covered Code, and must include terms to the effect that the
6219304Speter * license from Licensee to its licensee is limited to the intellectual
6319304Speter * property embodied in the software Licensee provides to its licensee, and
6419304Speter * not to intellectual property embodied in modifications its licensee may
6519304Speter * make.
6619304Speter *
6719304Speter * 3.3. Redistribution of Executable. Redistribution in executable form of any
6819304Speter * substantial portion of the Covered Code or modification must reproduce the
6919304Speter * above Copyright Notice, and the following Disclaimer and Export Compliance
7019304Speter * provision in the documentation and/or other materials provided with the
7119304Speter * distribution.
7219304Speter *
7319304Speter * 3.4. Intel retains all right, title, and interest in and to the Original
7419304Speter * Intel Code.
7519304Speter *
7619304Speter * 3.5. Neither the name Intel nor any other trademark owned or controlled by
7719304Speter * Intel shall be used in advertising or otherwise to promote the sale, use or
7819304Speter * other dealings in products derived from or relating to the Covered Code
7919304Speter * without prior written authorization from Intel.
8019304Speter *
8119304Speter * 4. Disclaimer and Export Compliance
8219304Speter *
8319304Speter * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
8419304Speter * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
8519304Speter * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
8619304Speter * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
8719304Speter * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
8819304Speter * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
8919304Speter * PARTICULAR PURPOSE.
9019304Speter *
9119304Speter * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
9219304Speter * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
9319304Speter * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
9419304Speter * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
9519304Speter * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
9619304Speter * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
9719304Speter * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
9819304Speter * LIMITED REMEDY.
9919304Speter *
10019304Speter * 4.3. Licensee shall not export, either directly or indirectly, any of this
10119304Speter * software or system incorporating such software without first obtaining any
10219304Speter * required license or other approval from the U. S. Department of Commerce or
10319304Speter * any other agency or department of the United States Government.  In the
10419304Speter * event Licensee exports any such software from the United States or
10519304Speter * re-exports any such software from a foreign destination, Licensee shall
10619304Speter * ensure that the distribution and export/re-export of the software is in
10719304Speter * compliance with all laws, regulations, orders, or other restrictions of the
10819304Speter * U.S. Export Administration Regulations. Licensee agrees that neither it nor
10919304Speter * any of its subsidiaries will export/re-export any technical data, process,
11019304Speter * software, or service, directly or indirectly, to any country for which the
11119304Speter * United States government or any agency thereof requires an export license,
11219304Speter * other governmental approval, or letter of assurance, without first obtaining
11319304Speter * such license, approval or letter.
11419304Speter *
11519304Speter *****************************************************************************/
11619304Speter
11719304Speter
11819304Speter#define __RSXFACE_C__
11919304Speter
12019304Speter#include "acpi.h"
12119304Speter#include "acinterp.h"
12219304Speter#include "acnamesp.h"
12319304Speter#include "acresrc.h"
12419304Speter
12519304Speter#define _COMPONENT          ACPI_RESOURCES
12619304Speter        ACPI_MODULE_NAME    ("rsxface")
12719304Speter
12819304Speter
12919304Speter/*******************************************************************************
13019304Speter *
13119304Speter * FUNCTION:    AcpiGetIrqRoutingTable
13219304Speter *
13319304Speter * PARAMETERS:  DeviceHandle    - a handle to the Bus device we are querying
13419304Speter *              RetBuffer       - a pointer to a buffer to receive the
13519304Speter *                                current resources for the device
13619304Speter *
13719304Speter * RETURN:      Status
13819304Speter *
13919304Speter * DESCRIPTION: This function is called to get the IRQ routing table for a
14019304Speter *              specific bus.  The caller must first acquire a handle for the
14119304Speter *              desired bus.  The routine table is placed in the buffer pointed
14219304Speter *              to by the RetBuffer variable parameter.
14319304Speter *
14419304Speter *              If the function fails an appropriate status will be returned
14519304Speter *              and the value of RetBuffer is undefined.
14619304Speter *
14719304Speter *              This function attempts to execute the _PRT method contained in
14819304Speter *              the object indicated by the passed DeviceHandle.
14919304Speter *
15019304Speter ******************************************************************************/
15119304Speter
15219304SpeterACPI_STATUS
15319304SpeterAcpiGetIrqRoutingTable  (
15419304Speter    ACPI_HANDLE             DeviceHandle,
15519304Speter    ACPI_BUFFER             *RetBuffer)
15619304Speter{
15719304Speter    ACPI_STATUS             Status;
15819304Speter
15919304Speter
16019304Speter    ACPI_FUNCTION_TRACE ("AcpiGetIrqRoutingTable ");
16119304Speter
16219304Speter
16319304Speter    /*
16419304Speter     * Must have a valid handle and buffer, So we have to have a handle
16519304Speter     * and a return buffer structure, and if there is a non-zero buffer length
16619304Speter     * we also need a valid pointer in the buffer. If it's a zero buffer length,
16719304Speter     * we'll be returning the needed buffer size, so keep going.
16819304Speter     */
16919304Speter    if (!DeviceHandle)
17019304Speter    {
17119304Speter        return_ACPI_STATUS (AE_BAD_PARAMETER);
17219304Speter    }
17319304Speter
17419304Speter    Status = AcpiUtValidateBuffer (RetBuffer);
17519304Speter    if (ACPI_FAILURE (Status))
17619304Speter    {
17719304Speter        return_ACPI_STATUS (Status);
17819304Speter    }
17919304Speter
18019304Speter    Status = AcpiRsGetPrtMethodData (DeviceHandle, RetBuffer);
18119304Speter    return_ACPI_STATUS (Status);
18219304Speter}
18319304Speter
18419304Speter
18519304Speter/*******************************************************************************
18619304Speter *
18719304Speter * FUNCTION:    AcpiGetCurrentResources
18819304Speter *
18919304Speter * PARAMETERS:  DeviceHandle    - a handle to the device object for the
19019304Speter *                                device we are querying
19119304Speter *              RetBuffer       - a pointer to a buffer to receive the
19219304Speter *                                current resources for the device
19319304Speter *
19419304Speter * RETURN:      Status
19519304Speter *
19619304Speter * DESCRIPTION: This function is called to get the current resources for a
19719304Speter *              specific device.  The caller must first acquire a handle for
19819304Speter *              the desired device.  The resource data is placed in the buffer
19919304Speter *              pointed to by the RetBuffer variable parameter.
20019304Speter *
20119304Speter *              If the function fails an appropriate status will be returned
20219304Speter *              and the value of RetBuffer is undefined.
20319304Speter *
20419304Speter *              This function attempts to execute the _CRS method contained in
20519304Speter *              the object indicated by the passed DeviceHandle.
20619304Speter *
20719304Speter ******************************************************************************/
20819304Speter
20919304SpeterACPI_STATUS
21019304SpeterAcpiGetCurrentResources (
21119304Speter    ACPI_HANDLE             DeviceHandle,
21219304Speter    ACPI_BUFFER             *RetBuffer)
21319304Speter{
21419304Speter    ACPI_STATUS             Status;
21519304Speter
21619304Speter
21719304Speter    ACPI_FUNCTION_TRACE ("AcpiGetCurrentResources");
21819304Speter
21919304Speter
22019304Speter    /*
22119304Speter     * Must have a valid handle and buffer, So we have to have a handle
22219304Speter     * and a return buffer structure, and if there is a non-zero buffer length
22319304Speter     * we also need a valid pointer in the buffer. If it's a zero buffer length,
22419304Speter     * we'll be returning the needed buffer size, so keep going.
22519304Speter     */
22619304Speter    if (!DeviceHandle)
22719304Speter    {
22819304Speter        return_ACPI_STATUS (AE_BAD_PARAMETER);
22919304Speter    }
23019304Speter
23119304Speter    Status = AcpiUtValidateBuffer (RetBuffer);
23219304Speter    if (ACPI_FAILURE (Status))
23319304Speter    {
234        return_ACPI_STATUS (Status);
235    }
236
237    Status = AcpiRsGetCrsMethodData (DeviceHandle, RetBuffer);
238    return_ACPI_STATUS (Status);
239}
240
241
242/*******************************************************************************
243 *
244 * FUNCTION:    AcpiGetPossibleResources
245 *
246 * PARAMETERS:  DeviceHandle    - a handle to the device object for the
247 *                                device we are querying
248 *              RetBuffer       - a pointer to a buffer to receive the
249 *                                resources for the device
250 *
251 * RETURN:      Status
252 *
253 * DESCRIPTION: This function is called to get a list of the possible resources
254 *              for a specific device.  The caller must first acquire a handle
255 *              for the desired device.  The resource data is placed in the
256 *              buffer pointed to by the RetBuffer variable.
257 *
258 *              If the function fails an appropriate status will be returned
259 *              and the value of RetBuffer is undefined.
260 *
261 ******************************************************************************/
262
263ACPI_STATUS
264AcpiGetPossibleResources (
265    ACPI_HANDLE             DeviceHandle,
266    ACPI_BUFFER             *RetBuffer)
267{
268    ACPI_STATUS             Status;
269
270
271    ACPI_FUNCTION_TRACE ("AcpiGetPossibleResources");
272
273
274    /*
275     * Must have a valid handle and buffer, So we have to have a handle
276     * and a return buffer structure, and if there is a non-zero buffer length
277     * we also need a valid pointer in the buffer. If it's a zero buffer length,
278     * we'll be returning the needed buffer size, so keep going.
279     */
280    if (!DeviceHandle)
281    {
282        return_ACPI_STATUS (AE_BAD_PARAMETER);
283    }
284
285    Status = AcpiUtValidateBuffer (RetBuffer);
286    if (ACPI_FAILURE (Status))
287    {
288        return_ACPI_STATUS (Status);
289    }
290
291    Status = AcpiRsGetPrsMethodData (DeviceHandle, RetBuffer);
292    return_ACPI_STATUS (Status);
293}
294
295
296/*******************************************************************************
297 *
298 * FUNCTION:    AcpiSetCurrentResources
299 *
300 * PARAMETERS:  DeviceHandle    - a handle to the device object for the
301 *                                device we are changing the resources of
302 *              InBuffer        - a pointer to a buffer containing the
303 *                                resources to be set for the device
304 *
305 * RETURN:      Status
306 *
307 * DESCRIPTION: This function is called to set the current resources for a
308 *              specific device.  The caller must first acquire a handle for
309 *              the desired device.  The resource data is passed to the routine
310 *              the buffer pointed to by the InBuffer variable.
311 *
312 ******************************************************************************/
313
314ACPI_STATUS
315AcpiSetCurrentResources (
316    ACPI_HANDLE             DeviceHandle,
317    ACPI_BUFFER             *InBuffer)
318{
319    ACPI_STATUS             Status;
320
321
322    ACPI_FUNCTION_TRACE ("AcpiSetCurrentResources");
323
324
325    /*
326     * Must have a valid handle and buffer
327     */
328    if ((!DeviceHandle)       ||
329        (!InBuffer)           ||
330        (!InBuffer->Pointer)  ||
331        (!InBuffer->Length))
332    {
333        return_ACPI_STATUS (AE_BAD_PARAMETER);
334    }
335
336    Status = AcpiRsSetSrsMethodData (DeviceHandle, InBuffer);
337    return_ACPI_STATUS (Status);
338}
339