rsxface.c revision 117521
160484Sobrien/*******************************************************************************
2130561Sobrien *
3218822Sdim * Module Name: rsxface - Public interfaces to the resource manager
460484Sobrien *              $Revision: 27 $
560484Sobrien *
6130561Sobrien ******************************************************************************/
760484Sobrien
8130561Sobrien/******************************************************************************
9130561Sobrien *
10130561Sobrien * 1. Copyright Notice
11130561Sobrien *
1260484Sobrien * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
13130561Sobrien * All rights reserved.
14130561Sobrien *
15130561Sobrien * 2. License
16130561Sobrien *
1760484Sobrien * 2.1. This is your license from Intel Corp. under its intellectual property
18130561Sobrien * rights.  You may have additional license terms from the party that provided
19130561Sobrien * you this software, covering your right to use that party's intellectual
20218822Sdim * property rights.
21218822Sdim *
2260484Sobrien * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
2360484Sobrien * copy of the source code appearing in this file ("Covered Code") an
2460484Sobrien * irrevocable, perpetual, worldwide license under Intel's copyrights in the
2560484Sobrien * base code distributed originally by Intel ("Original Intel Code") to copy,
2660484Sobrien * make derivatives, distribute, use and display any portion of the Covered
2760484Sobrien * Code in any form, with the right to sublicense such rights; and
28218822Sdim *
29218822Sdim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
3060484Sobrien * license (with the right to sublicense), under only those claims of Intel
3160484Sobrien * patents that are infringed by the Original Intel Code, to make, use, sell,
3260484Sobrien * offer to sell, and import the Covered Code and derivative works thereof
3360484Sobrien * solely to the minimum extent necessary to exercise the above copyright
3460484Sobrien * license, and in no event shall the patent license extend to any additions
35130561Sobrien * to or modifications of the Original Intel Code.  No other license or right
36218822Sdim * is granted directly or by implication, estoppel or otherwise;
3760484Sobrien *
38130561Sobrien * The above copyright and patent license is granted only if the following
3960484Sobrien * conditions are met:
4060484Sobrien *
41130561Sobrien * 3. Conditions
42130561Sobrien *
43130561Sobrien * 3.1. Redistribution of Source with Rights to Further Distribute Source.
4460484Sobrien * Redistribution of source code of any substantial portion of the Covered
45130561Sobrien * Code or modification with rights to further distribute source must include
46130561Sobrien * the above Copyright Notice, the above License, this list of Conditions,
47130561Sobrien * and the following Disclaimer and Export Compliance provision.  In addition,
48130561Sobrien * Licensee must cause all Covered Code to which Licensee contributes to
49130561Sobrien * contain a file documenting the changes Licensee made to create that Covered
50130561Sobrien * Code and the date of any change.  Licensee must include in that file the
5160484Sobrien * documentation of any changes made by any predecessor Licensee.  Licensee
52130561Sobrien * must include a prominent statement that the modification is derived,
53130561Sobrien * directly or indirectly, from Original Intel Code.
54130561Sobrien *
5560484Sobrien * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56218822Sdim * Redistribution of source code of any substantial portion of the Covered
57130561Sobrien * Code or modification without rights to further distribute source must
58130561Sobrien * include the following Disclaimer and Export Compliance provision in the
5960484Sobrien * documentation and/or other materials provided with distribution.  In
60218822Sdim * addition, Licensee may not authorize further sublicense of source of any
61218822Sdim * portion of the Covered Code, and must include terms to the effect that the
62218822Sdim * license from Licensee to its licensee is limited to the intellectual
6360484Sobrien * property embodied in the software Licensee provides to its licensee, and
64218822Sdim * not to intellectual property embodied in modifications its licensee may
6560484Sobrien * make.
66218822Sdim *
67218822Sdim * 3.3. Redistribution of Executable. Redistribution in executable form of any
68218822Sdim * substantial portion of the Covered Code or modification must reproduce the
69218822Sdim * above Copyright Notice, and the following Disclaimer and Export Compliance
70218822Sdim * provision in the documentation and/or other materials provided with the
71218822Sdim * distribution.
72218822Sdim *
73218822Sdim * 3.4. Intel retains all right, title, and interest in and to the Original
74218822Sdim * Intel Code.
75218822Sdim *
76218822Sdim * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77218822Sdim * Intel shall be used in advertising or otherwise to promote the sale, use or
78218822Sdim * other dealings in products derived from or relating to the Covered Code
79218822Sdim * without prior written authorization from Intel.
80218822Sdim *
81218822Sdim * 4. Disclaimer and Export Compliance
82218822Sdim *
83218822Sdim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84218822Sdim * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85218822Sdim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86218822Sdim * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87218822Sdim * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88218822Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89218822Sdim * PARTICULAR PURPOSE.
90218822Sdim *
91218822Sdim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
9260484Sobrien * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93218822Sdim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94218822Sdim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95218822Sdim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96218822Sdim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97218822Sdim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98218822Sdim * LIMITED REMEDY.
99218822Sdim *
100218822Sdim * 4.3. Licensee shall not export, either directly or indirectly, any of this
101218822Sdim * software or system incorporating such software without first obtaining any
102218822Sdim * required license or other approval from the U. S. Department of Commerce or
103218822Sdim * any other agency or department of the United States Government.  In the
104218822Sdim * event Licensee exports any such software from the United States or
105218822Sdim * re-exports any such software from a foreign destination, Licensee shall
106218822Sdim * ensure that the distribution and export/re-export of the software is in
107218822Sdim * compliance with all laws, regulations, orders, or other restrictions of the
108218822Sdim * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109218822Sdim * any of its subsidiaries will export/re-export any technical data, process,
110218822Sdim * software, or service, directly or indirectly, to any country for which the
111218822Sdim * United States government or any agency thereof requires an export license,
112218822Sdim * other governmental approval, or letter of assurance, without first obtaining
113218822Sdim * such license, approval or letter.
114218822Sdim *
115218822Sdim *****************************************************************************/
116218822Sdim
117218822Sdim
118218822Sdim#define __RSXFACE_C__
11960484Sobrien
120218822Sdim#include "acpi.h"
121218822Sdim#include "acresrc.h"
12260484Sobrien
123218822Sdim#define _COMPONENT          ACPI_RESOURCES
124218822Sdim        ACPI_MODULE_NAME    ("rsxface")
125218822Sdim
126218822Sdim
127218822Sdim/*******************************************************************************
128218822Sdim *
129218822Sdim * FUNCTION:    AcpiGetIrqRoutingTable
13060484Sobrien *
131218822Sdim * PARAMETERS:  DeviceHandle    - a handle to the Bus device we are querying
132218822Sdim *              RetBuffer       - a pointer to a buffer to receive the
133218822Sdim *                                current resources for the device
134218822Sdim *
135218822Sdim * RETURN:      Status
136218822Sdim *
137218822Sdim * DESCRIPTION: This function is called to get the IRQ routing table for a
138218822Sdim *              specific bus.  The caller must first acquire a handle for the
139218822Sdim *              desired bus.  The routine table is placed in the buffer pointed
140218822Sdim *              to by the RetBuffer variable parameter.
141218822Sdim *
142218822Sdim *              If the function fails an appropriate status will be returned
143218822Sdim *              and the value of RetBuffer is undefined.
144218822Sdim *
145218822Sdim *              This function attempts to execute the _PRT method contained in
146218822Sdim *              the object indicated by the passed DeviceHandle.
147218822Sdim *
148218822Sdim ******************************************************************************/
149218822Sdim
150218822SdimACPI_STATUS
151218822SdimAcpiGetIrqRoutingTable  (
152218822Sdim    ACPI_HANDLE             DeviceHandle,
153218822Sdim    ACPI_BUFFER             *RetBuffer)
154218822Sdim{
15560484Sobrien    ACPI_STATUS             Status;
156218822Sdim
157218822Sdim
158218822Sdim    ACPI_FUNCTION_TRACE ("AcpiGetIrqRoutingTable ");
15960484Sobrien
160130561Sobrien
16160484Sobrien    /*
16277298Sobrien     * Must have a valid handle and buffer, So we have to have a handle
16360484Sobrien     * and a return buffer structure, and if there is a non-zero buffer length
16460484Sobrien     * we also need a valid pointer in the buffer. If it's a zero buffer length,
16560484Sobrien     * we'll be returning the needed buffer size, so keep going.
16660484Sobrien     */
16760484Sobrien    if (!DeviceHandle)
168130561Sobrien    {
16960484Sobrien        return_ACPI_STATUS (AE_BAD_PARAMETER);
17060484Sobrien    }
17160484Sobrien
17260484Sobrien    Status = AcpiUtValidateBuffer (RetBuffer);
173130561Sobrien    if (ACPI_FAILURE (Status))
17460484Sobrien    {
17560484Sobrien        return_ACPI_STATUS (Status);
176130561Sobrien    }
17760484Sobrien
17860484Sobrien    Status = AcpiRsGetPrtMethodData (DeviceHandle, RetBuffer);
17960484Sobrien    return_ACPI_STATUS (Status);
18060484Sobrien}
18160484Sobrien
18260484Sobrien
183130561Sobrien/*******************************************************************************
18460484Sobrien *
18560484Sobrien * FUNCTION:    AcpiGetCurrentResources
18660484Sobrien *
18760484Sobrien * PARAMETERS:  DeviceHandle    - a handle to the device object for the
188130561Sobrien *                                device we are querying
18960484Sobrien *              RetBuffer       - a pointer to a buffer to receive the
19060484Sobrien *                                current resources for the device
191130561Sobrien *
19260484Sobrien * RETURN:      Status
19360484Sobrien *
19460484Sobrien * DESCRIPTION: This function is called to get the current resources for a
19560484Sobrien *              specific device.  The caller must first acquire a handle for
19660484Sobrien *              the desired device.  The resource data is placed in the buffer
19760484Sobrien *              pointed to by the RetBuffer variable parameter.
19860484Sobrien *
199130561Sobrien *              If the function fails an appropriate status will be returned
20060484Sobrien *              and the value of RetBuffer is undefined.
20160484Sobrien *
20260484Sobrien *              This function attempts to execute the _CRS method contained in
20360484Sobrien *              the object indicated by the passed DeviceHandle.
204130561Sobrien *
20560484Sobrien ******************************************************************************/
20660484Sobrien
207130561SobrienACPI_STATUS
20860484SobrienAcpiGetCurrentResources (
20960484Sobrien    ACPI_HANDLE             DeviceHandle,
21060484Sobrien    ACPI_BUFFER             *RetBuffer)
21160484Sobrien{
21260484Sobrien    ACPI_STATUS             Status;
21360484Sobrien
214130561Sobrien
21560484Sobrien    ACPI_FUNCTION_TRACE ("AcpiGetCurrentResources");
21660484Sobrien
21760484Sobrien
21860484Sobrien    /*
219130561Sobrien     * Must have a valid handle and buffer, So we have to have a handle
22060484Sobrien     * and a return buffer structure, and if there is a non-zero buffer length
22160484Sobrien     * we also need a valid pointer in the buffer. If it's a zero buffer length,
222130561Sobrien     * we'll be returning the needed buffer size, so keep going.
22360484Sobrien     */
22460484Sobrien    if (!DeviceHandle)
22560484Sobrien    {
22660484Sobrien        return_ACPI_STATUS (AE_BAD_PARAMETER);
22760484Sobrien    }
22860484Sobrien
229130561Sobrien    Status = AcpiUtValidateBuffer (RetBuffer);
23060484Sobrien    if (ACPI_FAILURE (Status))
23160484Sobrien    {
23260484Sobrien        return_ACPI_STATUS (Status);
23360484Sobrien    }
234130561Sobrien
23560484Sobrien    Status = AcpiRsGetCrsMethodData (DeviceHandle, RetBuffer);
23660484Sobrien    return_ACPI_STATUS (Status);
237130561Sobrien}
23860484Sobrien
23960484Sobrien
24060484Sobrien/*******************************************************************************
24160484Sobrien *
24260484Sobrien * FUNCTION:    AcpiGetPossibleResources
24360484Sobrien *
244130561Sobrien * PARAMETERS:  DeviceHandle    - a handle to the device object for the
24560484Sobrien *                                device we are querying
24660484Sobrien *              RetBuffer       - a pointer to a buffer to receive the
24760484Sobrien *                                resources for the device
24860484Sobrien *
249130561Sobrien * RETURN:      Status
25060484Sobrien *
25160484Sobrien * DESCRIPTION: This function is called to get a list of the possible resources
252130561Sobrien *              for a specific device.  The caller must first acquire a handle
25360484Sobrien *              for the desired device.  The resource data is placed in the
25460484Sobrien *              buffer pointed to by the RetBuffer variable.
25577298Sobrien *
25660484Sobrien *              If the function fails an appropriate status will be returned
25760484Sobrien *              and the value of RetBuffer is undefined.
25860484Sobrien *
25960484Sobrien ******************************************************************************/
260130561Sobrien
26160484SobrienACPI_STATUS
26260484SobrienAcpiGetPossibleResources (
26360484Sobrien    ACPI_HANDLE             DeviceHandle,
26460484Sobrien    ACPI_BUFFER             *RetBuffer)
265130561Sobrien{
26660484Sobrien    ACPI_STATUS             Status;
26760484Sobrien
268130561Sobrien
26960484Sobrien    ACPI_FUNCTION_TRACE ("AcpiGetPossibleResources");
27060484Sobrien
27160484Sobrien
27260484Sobrien    /*
27360484Sobrien     * Must have a valid handle and buffer, So we have to have a handle
27460484Sobrien     * and a return buffer structure, and if there is a non-zero buffer length
27560484Sobrien     * we also need a valid pointer in the buffer. If it's a zero buffer length,
276130561Sobrien     * we'll be returning the needed buffer size, so keep going.
27760484Sobrien     */
27860484Sobrien    if (!DeviceHandle)
27960484Sobrien    {
28060484Sobrien        return_ACPI_STATUS (AE_BAD_PARAMETER);
281130561Sobrien    }
28260484Sobrien
28360484Sobrien    Status = AcpiUtValidateBuffer (RetBuffer);
284130561Sobrien    if (ACPI_FAILURE (Status))
28560484Sobrien    {
28660484Sobrien        return_ACPI_STATUS (Status);
28760484Sobrien    }
28877298Sobrien
28960484Sobrien    Status = AcpiRsGetPrsMethodData (DeviceHandle, RetBuffer);
29060484Sobrien    return_ACPI_STATUS (Status);
29160484Sobrien}
29260484Sobrien
293130561Sobrien
29460484Sobrien/*******************************************************************************
29560484Sobrien *
29660484Sobrien * FUNCTION:    AcpiWalkResources
29760484Sobrien *
298130561Sobrien * PARAMETERS:  DeviceHandle    - a handle to the device object for the
29960484Sobrien *                                device we are querying
30060484Sobrien *              Path            - method name of the resources we want
301130561Sobrien *                                (METHOD_NAME__CRS or METHOD_NAME__PRS)
30260484Sobrien *              UserFunction    - called for each resource
30360484Sobrien *              Context         - passed to UserFunction
30460484Sobrien *
30560484Sobrien * RETURN:      Status
30660484Sobrien *
30760484Sobrien * DESCRIPTION: Retrieves the current or possible resource list for the
30860484Sobrien *              specified device.  The UserFunction is called once for
30960484Sobrien *              each resource in the list.
310130561Sobrien *
31160484Sobrien ******************************************************************************/
31260484Sobrien
31360484SobrienACPI_STATUS
31460484SobrienAcpiWalkResources (
315130561Sobrien    ACPI_HANDLE                     DeviceHandle,
31660484Sobrien    char                            *Path,
31760484Sobrien    ACPI_WALK_RESOURCE_CALLBACK     UserFunction,
318130561Sobrien    void                            *Context)
31960484Sobrien{
32077298Sobrien    ACPI_STATUS                 Status;
32160484Sobrien    ACPI_BUFFER                 Buffer = {ACPI_ALLOCATE_BUFFER, NULL};
32260484Sobrien    ACPI_RESOURCE               *Resource;
32360484Sobrien
32460484Sobrien
325130561Sobrien    ACPI_FUNCTION_TRACE ("AcpiWalkResources");
32660484Sobrien
32760484Sobrien
32860484Sobrien    if (!DeviceHandle ||
32960484Sobrien        (ACPI_STRNCMP (Path, METHOD_NAME__CRS, sizeof (METHOD_NAME__CRS)) &&
330130561Sobrien         ACPI_STRNCMP (Path, METHOD_NAME__PRS, sizeof (METHOD_NAME__PRS))))
33160484Sobrien    {
33260484Sobrien        return_ACPI_STATUS (AE_BAD_PARAMETER);
333130561Sobrien    }
33460484Sobrien
33577298Sobrien    Status = AcpiRsGetMethodData (DeviceHandle, Path, &Buffer);
33660484Sobrien    if (ACPI_FAILURE (Status))
33760484Sobrien    {
33860484Sobrien        return_ACPI_STATUS (Status);
33960484Sobrien    }
340130561Sobrien
34160484Sobrien    Resource = (ACPI_RESOURCE *) Buffer.Pointer;
34260484Sobrien    for (;;)
34360484Sobrien    {
34460484Sobrien        if (!Resource || Resource->Id == ACPI_RSTYPE_END_TAG)
345130561Sobrien        {
34660484Sobrien            break;
34760484Sobrien        }
348130561Sobrien
34960484Sobrien        Status = UserFunction (Resource, Context);
35077298Sobrien
35160484Sobrien        switch (Status)
35260484Sobrien        {
35360484Sobrien        case AE_OK:
35460484Sobrien        case AE_CTRL_DEPTH:
35560484Sobrien
35660484Sobrien            /* Just keep going */
357130561Sobrien            Status = AE_OK;
35860484Sobrien            break;
35960484Sobrien
36060484Sobrien        case AE_CTRL_TERMINATE:
36160484Sobrien
362130561Sobrien            /* Exit now, with OK stats */
36360484Sobrien
36460484Sobrien            Status = AE_OK;
365130561Sobrien            goto Cleanup;
36660484Sobrien
36777298Sobrien        default:
36860484Sobrien
36960484Sobrien            /* All others are valid exceptions */
37060484Sobrien
37160484Sobrien            goto Cleanup;
37260484Sobrien        }
37360484Sobrien
374130561Sobrien        Resource = ACPI_NEXT_RESOURCE (Resource);
37560484Sobrien    }
37660484Sobrien
37760484SobrienCleanup:
37860484Sobrien
379130561Sobrien    AcpiOsFree (Buffer.Pointer);
38060484Sobrien    return_ACPI_STATUS (Status);
38160484Sobrien}
382130561Sobrien
38360484Sobrien
38460484Sobrien/*******************************************************************************
38560484Sobrien *
38660484Sobrien * FUNCTION:    AcpiSetCurrentResources
38760484Sobrien *
38860484Sobrien * PARAMETERS:  DeviceHandle    - a handle to the device object for the
38960484Sobrien *                                device we are changing the resources of
390130561Sobrien *              InBuffer        - a pointer to a buffer containing the
39160484Sobrien *                                resources to be set for the device
39260484Sobrien *
39360484Sobrien * RETURN:      Status
39460484Sobrien *
395130561Sobrien * DESCRIPTION: This function is called to set the current resources for a
39660484Sobrien *              specific device.  The caller must first acquire a handle for
39760484Sobrien *              the desired device.  The resource data is passed to the routine
398130561Sobrien *              the buffer pointed to by the InBuffer variable.
39960484Sobrien *
40060484Sobrien ******************************************************************************/
40160484Sobrien
40260484SobrienACPI_STATUS
40360484SobrienAcpiSetCurrentResources (
40460484Sobrien    ACPI_HANDLE             DeviceHandle,
40560484Sobrien    ACPI_BUFFER             *InBuffer)
406130561Sobrien{
40760484Sobrien    ACPI_STATUS             Status;
40860484Sobrien
40960484Sobrien
41060484Sobrien    ACPI_FUNCTION_TRACE ("AcpiSetCurrentResources");
411130561Sobrien
41260484Sobrien
41360484Sobrien    /*
414130561Sobrien     * Must have a valid handle and buffer
41560484Sobrien     */
41660484Sobrien    if ((!DeviceHandle)       ||
41760484Sobrien        (!InBuffer)           ||
41860484Sobrien        (!InBuffer->Pointer)  ||
41960484Sobrien        (!InBuffer->Length))
42060484Sobrien    {
42160484Sobrien        return_ACPI_STATUS (AE_BAD_PARAMETER);
422130561Sobrien    }
42360484Sobrien
42460484Sobrien    Status = AcpiRsSetSrsMethodData (DeviceHandle, InBuffer);
42560484Sobrien    return_ACPI_STATUS (Status);
42660484Sobrien}
427130561Sobrien
42860484Sobrien
42960484Sobrien#define ACPI_COPY_FIELD(Out, In, Field)  ((Out)->Field = (In)->Field)
430130561Sobrien#define ACPI_COPY_ADDRESS(Out, In)                      \
43160484Sobrien    ACPI_COPY_FIELD(Out, In, ResourceType);              \
43260484Sobrien    ACPI_COPY_FIELD(Out, In, ProducerConsumer);          \
43360484Sobrien    ACPI_COPY_FIELD(Out, In, Decode);                    \
43460484Sobrien    ACPI_COPY_FIELD(Out, In, MinAddressFixed);           \
43560484Sobrien    ACPI_COPY_FIELD(Out, In, MaxAddressFixed);           \
43660484Sobrien    ACPI_COPY_FIELD(Out, In, Attribute);                 \
43760484Sobrien    ACPI_COPY_FIELD(Out, In, Granularity);               \
438130561Sobrien    ACPI_COPY_FIELD(Out, In, MinAddressRange);           \
43960484Sobrien    ACPI_COPY_FIELD(Out, In, MaxAddressRange);           \
44060484Sobrien    ACPI_COPY_FIELD(Out, In, AddressTranslationOffset);  \
44160484Sobrien    ACPI_COPY_FIELD(Out, In, AddressLength);             \
44260484Sobrien    ACPI_COPY_FIELD(Out, In, ResourceSource);
443130561Sobrien
44460484Sobrien/******************************************************************************
44560484Sobrien *
446130561Sobrien * FUNCTION:    AcpiResourceToAddress64
44760484Sobrien *
44860484Sobrien * PARAMETERS:  resource                - Pointer to a resource
44960484Sobrien *              out                     - Pointer to the users's return
45060484Sobrien *                                        buffer (a struct
45160484Sobrien *                                        acpi_resource_address64)
45260484Sobrien *
45360484Sobrien * RETURN:      Status
454130561Sobrien *
45560484Sobrien * DESCRIPTION: If the resource is an address16, address32, or address64,
45660484Sobrien *              copy it to the address64 return buffer.  This saves the
45760484Sobrien *              caller from having to duplicate code for different-sized
45860484Sobrien *              addresses.
459130561Sobrien *
46060484Sobrien ******************************************************************************/
46160484Sobrien
462130561SobrienACPI_STATUS
46360484SobrienAcpiResourceToAddress64 (
46460484Sobrien    ACPI_RESOURCE               *Resource,
46560484Sobrien    ACPI_RESOURCE_ADDRESS64     *Out)
46660484Sobrien{
46760484Sobrien    ACPI_RESOURCE_ADDRESS16     *Address16;
46860484Sobrien    ACPI_RESOURCE_ADDRESS32     *Address32;
46960484Sobrien
47060484Sobrien
47160484Sobrien    switch (Resource->Id) {
47260484Sobrien    case ACPI_RSTYPE_ADDRESS16:
473130561Sobrien
47460484Sobrien        Address16 = (ACPI_RESOURCE_ADDRESS16 *) &Resource->Data;
47560484Sobrien        ACPI_COPY_ADDRESS(Out, Address16);
47660484Sobrien        break;
47760484Sobrien
478130561Sobrien
47960484Sobrien    case ACPI_RSTYPE_ADDRESS32:
48060484Sobrien
481130561Sobrien        Address32 = (ACPI_RESOURCE_ADDRESS32 *) &Resource->Data;
48260484Sobrien        ACPI_COPY_ADDRESS(Out, Address32);
48360484Sobrien        break;
48460484Sobrien
48560484Sobrien
48660484Sobrien    case ACPI_RSTYPE_ADDRESS64:
48760484Sobrien
48860484Sobrien        /* Simple copy for 64 bit source */
489130561Sobrien
49060484Sobrien        ACPI_MEMCPY (Out, &Resource->Data, sizeof (ACPI_RESOURCE_ADDRESS64));
49160484Sobrien        break;
49260484Sobrien
49360484Sobrien
494130561Sobrien    default:
49560484Sobrien        return (AE_BAD_PARAMETER);
49660484Sobrien    }
497130561Sobrien
49860484Sobrien    return (AE_OK);
49960484Sobrien}
50060484Sobrien