2005-05-30 00:56:02 +04:00
|
|
|
/* $NetBSD: acpi_resource.c,v 1.17 2005/05/29 20:56:02 christos Exp $ */
|
2001-09-29 09:34:00 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2001 Wasabi Systems, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed for the NetBSD Project by
|
|
|
|
* Wasabi Systems, Inc.
|
|
|
|
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
|
|
|
|
* or promote products derived from this software without specific prior
|
|
|
|
* written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 2000 Michael Smith
|
|
|
|
* Copyright (c) 2000 BSDi
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2004-04-10 15:48:10 +04:00
|
|
|
*
|
2001-09-29 09:34:00 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
2004-04-10 15:48:10 +04:00
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
2001-09-29 09:34:00 +04:00
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
2004-04-10 15:48:10 +04:00
|
|
|
* SUCH DAMAGE.
|
2001-09-29 09:34:00 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ACPI resource parsing.
|
|
|
|
*/
|
|
|
|
|
2001-11-13 16:01:57 +03:00
|
|
|
#include <sys/cdefs.h>
|
2005-05-30 00:56:02 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: acpi_resource.c,v 1.17 2005/05/29 20:56:02 christos Exp $");
|
2001-11-13 16:01:57 +03:00
|
|
|
|
2001-09-29 09:34:00 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
|
|
|
|
#include <dev/acpi/acpica.h>
|
|
|
|
#include <dev/acpi/acpireg.h>
|
|
|
|
#include <dev/acpi/acpivar.h>
|
|
|
|
|
2002-06-15 22:01:05 +04:00
|
|
|
#define _COMPONENT ACPI_RESOURCE_COMPONENT
|
|
|
|
ACPI_MODULE_NAME("RESOURCE")
|
2001-09-29 09:34:00 +04:00
|
|
|
|
2004-04-11 13:25:28 +04:00
|
|
|
static ACPI_STATUS acpi_resource_parse_callback(ACPI_RESOURCE *, void *);
|
|
|
|
|
2004-04-11 12:36:19 +04:00
|
|
|
struct resource_parse_callback_arg {
|
|
|
|
const struct acpi_resource_parse_ops *ops;
|
|
|
|
struct device *dev;
|
2001-09-29 09:34:00 +04:00
|
|
|
void *context;
|
2004-04-11 12:36:19 +04:00
|
|
|
};
|
2001-09-29 09:34:00 +04:00
|
|
|
|
2004-04-11 12:36:19 +04:00
|
|
|
static ACPI_STATUS
|
|
|
|
acpi_resource_parse_callback(ACPI_RESOURCE *res, void *context)
|
|
|
|
{
|
|
|
|
struct resource_parse_callback_arg *arg = context;
|
|
|
|
const struct acpi_resource_parse_ops *ops;
|
|
|
|
int i;
|
2001-09-29 09:34:00 +04:00
|
|
|
|
2004-04-12 19:11:04 +04:00
|
|
|
ACPI_FUNCTION_TRACE(__FUNCTION__);
|
|
|
|
|
2004-04-11 12:36:19 +04:00
|
|
|
ops = arg->ops;
|
|
|
|
|
|
|
|
switch (res->Id) {
|
|
|
|
case ACPI_RSTYPE_FIXED_IO:
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
|
|
|
|
"FixedIo 0x%x/%d\n",
|
|
|
|
res->Data.FixedIo.BaseAddress,
|
|
|
|
res->Data.FixedIo.RangeLength));
|
2004-04-11 13:25:28 +04:00
|
|
|
if (ops->ioport)
|
|
|
|
(*ops->ioport)(arg->dev, arg->context,
|
|
|
|
res->Data.FixedIo.BaseAddress,
|
|
|
|
res->Data.FixedIo.RangeLength);
|
2004-04-11 12:36:19 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_RSTYPE_IO:
|
|
|
|
if (res->Data.Io.MinBaseAddress ==
|
2001-09-29 09:34:00 +04:00
|
|
|
res->Data.Io.MaxBaseAddress) {
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
|
2004-04-11 12:36:19 +04:00
|
|
|
"Io 0x%x/%d\n",
|
|
|
|
res->Data.Io.MinBaseAddress,
|
|
|
|
res->Data.Io.RangeLength));
|
2004-04-11 13:25:28 +04:00
|
|
|
if (ops->ioport)
|
|
|
|
(*ops->ioport)(arg->dev, arg->context,
|
|
|
|
res->Data.Io.MinBaseAddress,
|
|
|
|
res->Data.Io.RangeLength);
|
2004-04-11 12:36:19 +04:00
|
|
|
} else {
|
2001-09-29 09:34:00 +04:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
|
2004-04-11 12:36:19 +04:00
|
|
|
"Io 0x%x-0x%x/%d\n",
|
|
|
|
res->Data.Io.MinBaseAddress,
|
|
|
|
res->Data.Io.MaxBaseAddress,
|
|
|
|
res->Data.Io.RangeLength));
|
2004-04-11 13:25:28 +04:00
|
|
|
if (ops->ioport)
|
|
|
|
(*ops->iorange)(arg->dev, arg->context,
|
|
|
|
res->Data.Io.MinBaseAddress,
|
|
|
|
res->Data.Io.MaxBaseAddress,
|
|
|
|
res->Data.Io.RangeLength,
|
|
|
|
res->Data.Io.Alignment);
|
2004-04-11 12:36:19 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_RSTYPE_FIXED_MEM32:
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
|
|
|
|
"FixedMemory32 0x%x/%d\n",
|
|
|
|
res->Data.FixedMemory32.RangeBaseAddress,
|
|
|
|
res->Data.FixedMemory32.RangeLength));
|
2004-04-11 13:25:28 +04:00
|
|
|
if (ops->memory)
|
|
|
|
(*ops->memory)(arg->dev, arg->context,
|
|
|
|
res->Data.FixedMemory32.RangeBaseAddress,
|
|
|
|
res->Data.FixedMemory32.RangeLength);
|
2004-04-11 12:36:19 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_RSTYPE_MEM32:
|
|
|
|
if (res->Data.Memory32.MinBaseAddress ==
|
|
|
|
res->Data.Memory32.MaxBaseAddress) {
|
2001-09-29 09:34:00 +04:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
|
2004-04-11 12:36:19 +04:00
|
|
|
"Memory32 0x%x/%d\n",
|
|
|
|
res->Data.Memory32.MinBaseAddress,
|
|
|
|
res->Data.Memory32.RangeLength));
|
2004-04-11 13:25:28 +04:00
|
|
|
if (ops->memory)
|
|
|
|
(*ops->memory)(arg->dev, arg->context,
|
|
|
|
res->Data.Memory32.MinBaseAddress,
|
|
|
|
res->Data.Memory32.RangeLength);
|
2004-04-11 12:36:19 +04:00
|
|
|
} else {
|
2001-09-29 09:34:00 +04:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
|
2004-04-11 12:36:19 +04:00
|
|
|
"Memory32 0x%x-0x%x/%d\n",
|
|
|
|
res->Data.Memory32.MinBaseAddress,
|
|
|
|
res->Data.Memory32.MaxBaseAddress,
|
|
|
|
res->Data.Memory32.RangeLength));
|
2004-04-11 13:25:28 +04:00
|
|
|
if (ops->memrange)
|
|
|
|
(*ops->memrange)(arg->dev, arg->context,
|
|
|
|
res->Data.Memory32.MinBaseAddress,
|
|
|
|
res->Data.Memory32.MaxBaseAddress,
|
|
|
|
res->Data.Memory32.RangeLength,
|
|
|
|
res->Data.Memory32.Alignment);
|
2004-04-11 12:36:19 +04:00
|
|
|
}
|
|
|
|
break;
|
2001-09-29 09:34:00 +04:00
|
|
|
|
2004-04-11 12:36:19 +04:00
|
|
|
case ACPI_RSTYPE_MEM24:
|
|
|
|
if (res->Data.Memory24.MinBaseAddress ==
|
|
|
|
res->Data.Memory24.MaxBaseAddress) {
|
2001-09-29 09:34:00 +04:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
|
2004-04-11 12:36:19 +04:00
|
|
|
"Memory24 0x%x/%d\n",
|
|
|
|
res->Data.Memory24.MinBaseAddress,
|
|
|
|
res->Data.Memory24.RangeLength));
|
2004-04-11 13:25:28 +04:00
|
|
|
if (ops->memory)
|
|
|
|
(*ops->memory)(arg->dev, arg->context,
|
|
|
|
res->Data.Memory24.MinBaseAddress,
|
|
|
|
res->Data.Memory24.RangeLength);
|
2004-04-11 12:36:19 +04:00
|
|
|
} else {
|
2001-09-29 09:34:00 +04:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
|
2004-04-11 12:36:19 +04:00
|
|
|
"Memory24 0x%x-0x%x/%d\n",
|
|
|
|
res->Data.Memory24.MinBaseAddress,
|
|
|
|
res->Data.Memory24.MaxBaseAddress,
|
|
|
|
res->Data.Memory24.RangeLength));
|
2004-04-11 13:25:28 +04:00
|
|
|
if (ops->memrange)
|
|
|
|
(*ops->memrange)(arg->dev, arg->context,
|
|
|
|
res->Data.Memory24.MinBaseAddress,
|
|
|
|
res->Data.Memory24.MaxBaseAddress,
|
|
|
|
res->Data.Memory24.RangeLength,
|
|
|
|
res->Data.Memory24.Alignment);
|
2004-04-11 12:36:19 +04:00
|
|
|
}
|
|
|
|
break;
|
2001-09-29 09:34:00 +04:00
|
|
|
|
2004-04-11 12:36:19 +04:00
|
|
|
case ACPI_RSTYPE_IRQ:
|
|
|
|
for (i = 0; i < res->Data.Irq.NumberOfInterrupts; i++) {
|
2001-09-29 09:34:00 +04:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
|
2004-04-11 12:36:19 +04:00
|
|
|
"IRQ %d\n",
|
|
|
|
res->Data.Irq.Interrupts[i]));
|
2004-04-11 13:25:28 +04:00
|
|
|
if (ops->irq)
|
|
|
|
(*ops->irq)(arg->dev, arg->context,
|
|
|
|
res->Data.Irq.Interrupts[i],
|
|
|
|
res->Data.Irq.EdgeLevel);
|
2004-04-11 12:36:19 +04:00
|
|
|
}
|
|
|
|
break;
|
2001-09-29 09:34:00 +04:00
|
|
|
|
2004-04-11 12:36:19 +04:00
|
|
|
case ACPI_RSTYPE_DMA:
|
|
|
|
for (i = 0; i < res->Data.Dma.NumberOfChannels; i++) {
|
2001-09-29 09:34:00 +04:00
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
|
2004-04-11 12:36:19 +04:00
|
|
|
"DRQ %d\n",
|
|
|
|
res->Data.Dma.Channels[i]));
|
2004-04-11 13:25:28 +04:00
|
|
|
if (ops->drq)
|
|
|
|
(*ops->drq)(arg->dev, arg->context,
|
|
|
|
res->Data.Dma.Channels[i]);
|
2001-09-29 09:34:00 +04:00
|
|
|
}
|
2004-04-11 12:36:19 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_RSTYPE_START_DPF:
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
|
|
|
|
"Start dependant functions: %d\n",
|
|
|
|
res->Data.StartDpf.CompatibilityPriority));
|
2004-04-11 13:25:28 +04:00
|
|
|
if (ops->start_dep)
|
|
|
|
(*ops->start_dep)(arg->dev, arg->context,
|
|
|
|
res->Data.StartDpf.CompatibilityPriority);
|
2004-04-11 12:36:19 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_RSTYPE_END_DPF:
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
|
|
|
|
"End dependant functions\n"));
|
2004-04-11 13:25:28 +04:00
|
|
|
if (ops->end_dep)
|
|
|
|
(*ops->end_dep)(arg->dev, arg->context);
|
2004-04-11 12:36:19 +04:00
|
|
|
|
|
|
|
case ACPI_RSTYPE_ADDRESS32:
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
|
|
|
|
"Address32 unimplemented\n"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_RSTYPE_ADDRESS16:
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
|
|
|
|
"Address16 unimplemented\n"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_RSTYPE_EXT_IRQ:
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
|
|
|
|
"ExtendedIrq unimplemented\n"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ACPI_RSTYPE_VENDOR:
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
|
|
|
|
"VendorSpecific unimplemented\n"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
|
|
|
|
"Unknown resource type: %d\n", res->Id));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-04-12 19:11:04 +04:00
|
|
|
return_ACPI_STATUS(AE_OK);
|
2004-04-11 12:36:19 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* acpi_resource_parse:
|
|
|
|
*
|
|
|
|
* Parse a device node's resources and fill them in for the
|
|
|
|
* client.
|
|
|
|
*
|
|
|
|
* This API supports _CRS (current resources) and
|
|
|
|
* _PRS (possible resources).
|
|
|
|
*
|
|
|
|
* Note that it might be nice to also locate ACPI-specific resource
|
|
|
|
* items, such as GPE bits.
|
|
|
|
*/
|
|
|
|
ACPI_STATUS
|
2005-05-30 00:56:02 +04:00
|
|
|
acpi_resource_parse(struct device *dev, ACPI_HANDLE handle, const char *path,
|
2004-04-11 12:36:19 +04:00
|
|
|
void *arg, const struct acpi_resource_parse_ops *ops)
|
|
|
|
{
|
|
|
|
struct resource_parse_callback_arg cbarg;
|
|
|
|
ACPI_STATUS rv;
|
|
|
|
|
|
|
|
ACPI_FUNCTION_TRACE(__FUNCTION__);
|
|
|
|
|
2004-04-11 13:25:28 +04:00
|
|
|
if (ops->init)
|
|
|
|
(*ops->init)(dev, arg, &cbarg.context);
|
|
|
|
else
|
|
|
|
cbarg.context = arg;
|
2004-04-11 12:36:19 +04:00
|
|
|
cbarg.ops = ops;
|
|
|
|
cbarg.dev = dev;
|
|
|
|
|
2005-05-30 00:56:02 +04:00
|
|
|
rv = AcpiWalkResources(handle, path, acpi_resource_parse_callback,
|
2004-04-11 12:36:19 +04:00
|
|
|
&cbarg);
|
|
|
|
if (ACPI_FAILURE(rv)) {
|
|
|
|
printf("%s: ACPI: unable to get %s resources: %s\n",
|
|
|
|
dev->dv_xname, path, AcpiFormatException(rv));
|
|
|
|
return_ACPI_STATUS(rv);
|
2001-09-29 09:34:00 +04:00
|
|
|
}
|
|
|
|
|
2004-04-11 13:25:28 +04:00
|
|
|
if (ops->fini)
|
|
|
|
(*ops->fini)(dev, cbarg.context);
|
2001-09-29 09:34:00 +04:00
|
|
|
|
|
|
|
return_ACPI_STATUS(AE_OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* acpi_resource_print:
|
|
|
|
*
|
|
|
|
* Print the resources assigned to a device.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
acpi_resource_print(struct device *dev, struct acpi_resources *res)
|
|
|
|
{
|
|
|
|
const char *sep;
|
|
|
|
|
|
|
|
if (SIMPLEQ_EMPTY(&res->ar_io) &&
|
|
|
|
SIMPLEQ_EMPTY(&res->ar_iorange) &&
|
|
|
|
SIMPLEQ_EMPTY(&res->ar_mem) &&
|
|
|
|
SIMPLEQ_EMPTY(&res->ar_memrange) &&
|
|
|
|
SIMPLEQ_EMPTY(&res->ar_irq) &&
|
|
|
|
SIMPLEQ_EMPTY(&res->ar_drq))
|
|
|
|
return;
|
|
|
|
|
|
|
|
printf("%s:", dev->dv_xname);
|
|
|
|
|
|
|
|
if (SIMPLEQ_EMPTY(&res->ar_io) == 0) {
|
|
|
|
struct acpi_io *ar;
|
|
|
|
|
|
|
|
sep = "";
|
|
|
|
printf(" io ");
|
2002-06-02 03:50:52 +04:00
|
|
|
SIMPLEQ_FOREACH(ar, &res->ar_io, ar_list) {
|
2001-09-29 09:34:00 +04:00
|
|
|
printf("%s0x%x", sep, ar->ar_base);
|
|
|
|
if (ar->ar_length > 1)
|
|
|
|
printf("-0x%x", ar->ar_base +
|
|
|
|
ar->ar_length - 1);
|
|
|
|
sep = ",";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX iorange */
|
|
|
|
|
|
|
|
if (SIMPLEQ_EMPTY(&res->ar_mem) == 0) {
|
|
|
|
struct acpi_mem *ar;
|
|
|
|
|
|
|
|
sep = "";
|
|
|
|
printf(" mem ");
|
2002-06-02 03:50:52 +04:00
|
|
|
SIMPLEQ_FOREACH(ar, &res->ar_mem, ar_list) {
|
2001-09-29 09:34:00 +04:00
|
|
|
printf("%s0x%x", sep, ar->ar_base);
|
|
|
|
if (ar->ar_length > 1)
|
|
|
|
printf("-0x%x", ar->ar_base +
|
|
|
|
ar->ar_length - 1);
|
|
|
|
sep = ",";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXX memrange */
|
|
|
|
|
|
|
|
if (SIMPLEQ_EMPTY(&res->ar_irq) == 0) {
|
|
|
|
struct acpi_irq *ar;
|
|
|
|
|
|
|
|
sep = "";
|
|
|
|
printf(" irq ");
|
2002-06-02 03:50:52 +04:00
|
|
|
SIMPLEQ_FOREACH(ar, &res->ar_irq, ar_list) {
|
2001-09-29 09:34:00 +04:00
|
|
|
printf("%s%d", sep, ar->ar_irq);
|
|
|
|
sep = ",";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SIMPLEQ_EMPTY(&res->ar_drq) == 0) {
|
|
|
|
struct acpi_drq *ar;
|
|
|
|
|
|
|
|
sep = "";
|
|
|
|
printf(" drq ");
|
2002-06-02 03:50:52 +04:00
|
|
|
SIMPLEQ_FOREACH(ar, &res->ar_drq, ar_list) {
|
2001-09-29 09:34:00 +04:00
|
|
|
printf("%s%d", sep, ar->ar_drq);
|
|
|
|
sep = ",";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
2004-04-11 14:36:35 +04:00
|
|
|
/*
|
|
|
|
* acpi_resource_cleanup:
|
|
|
|
*
|
|
|
|
* Free all allocated buffers
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
acpi_resource_cleanup(struct acpi_resources *res)
|
|
|
|
{
|
|
|
|
while (!SIMPLEQ_EMPTY(&res->ar_io)) {
|
|
|
|
struct acpi_io *ar;
|
|
|
|
ar = SIMPLEQ_FIRST(&res->ar_io);
|
|
|
|
SIMPLEQ_REMOVE_HEAD(&res->ar_io, ar_list);
|
|
|
|
AcpiOsFree(ar);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!SIMPLEQ_EMPTY(&res->ar_iorange)) {
|
|
|
|
struct acpi_iorange *ar;
|
|
|
|
ar = SIMPLEQ_FIRST(&res->ar_iorange);
|
|
|
|
SIMPLEQ_REMOVE_HEAD(&res->ar_iorange, ar_list);
|
|
|
|
AcpiOsFree(ar);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!SIMPLEQ_EMPTY(&res->ar_mem)) {
|
|
|
|
struct acpi_mem *ar;
|
|
|
|
ar = SIMPLEQ_FIRST(&res->ar_mem);
|
|
|
|
SIMPLEQ_REMOVE_HEAD(&res->ar_mem, ar_list);
|
|
|
|
AcpiOsFree(ar);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!SIMPLEQ_EMPTY(&res->ar_memrange)) {
|
|
|
|
struct acpi_memrange *ar;
|
|
|
|
ar = SIMPLEQ_FIRST(&res->ar_memrange);
|
|
|
|
SIMPLEQ_REMOVE_HEAD(&res->ar_memrange, ar_list);
|
|
|
|
AcpiOsFree(ar);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!SIMPLEQ_EMPTY(&res->ar_irq)) {
|
|
|
|
struct acpi_irq *ar;
|
|
|
|
ar = SIMPLEQ_FIRST(&res->ar_irq);
|
|
|
|
SIMPLEQ_REMOVE_HEAD(&res->ar_irq, ar_list);
|
|
|
|
AcpiOsFree(ar);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!SIMPLEQ_EMPTY(&res->ar_drq)) {
|
|
|
|
struct acpi_drq *ar;
|
|
|
|
ar = SIMPLEQ_FIRST(&res->ar_drq);
|
|
|
|
SIMPLEQ_REMOVE_HEAD(&res->ar_drq, ar_list);
|
|
|
|
AcpiOsFree(ar);
|
|
|
|
}
|
|
|
|
|
2005-02-27 03:26:58 +03:00
|
|
|
res->ar_nio = res->ar_niorange = res->ar_nmem =
|
2004-04-11 14:36:35 +04:00
|
|
|
res->ar_nmemrange = res->ar_nirq = res->ar_ndrq = 0;
|
|
|
|
}
|
|
|
|
|
2001-09-29 09:34:00 +04:00
|
|
|
struct acpi_io *
|
|
|
|
acpi_res_io(struct acpi_resources *res, int idx)
|
|
|
|
{
|
|
|
|
struct acpi_io *ar;
|
|
|
|
|
|
|
|
SIMPLEQ_FOREACH(ar, &res->ar_io, ar_list) {
|
|
|
|
if (ar->ar_index == idx)
|
2004-04-11 10:48:25 +04:00
|
|
|
return ar;
|
2001-09-29 09:34:00 +04:00
|
|
|
}
|
2004-04-11 10:48:25 +04:00
|
|
|
return NULL;
|
2001-09-29 09:34:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
struct acpi_iorange *
|
|
|
|
acpi_res_iorange(struct acpi_resources *res, int idx)
|
|
|
|
{
|
|
|
|
struct acpi_iorange *ar;
|
|
|
|
|
|
|
|
SIMPLEQ_FOREACH(ar, &res->ar_iorange, ar_list) {
|
|
|
|
if (ar->ar_index == idx)
|
2004-04-11 10:48:25 +04:00
|
|
|
return ar;
|
2001-09-29 09:34:00 +04:00
|
|
|
}
|
2004-04-11 10:48:25 +04:00
|
|
|
return NULL;
|
2001-09-29 09:34:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
struct acpi_mem *
|
|
|
|
acpi_res_mem(struct acpi_resources *res, int idx)
|
|
|
|
{
|
|
|
|
struct acpi_mem *ar;
|
|
|
|
|
|
|
|
SIMPLEQ_FOREACH(ar, &res->ar_mem, ar_list) {
|
|
|
|
if (ar->ar_index == idx)
|
2004-04-11 10:48:25 +04:00
|
|
|
return ar;
|
2001-09-29 09:34:00 +04:00
|
|
|
}
|
2004-04-11 10:48:25 +04:00
|
|
|
return NULL;
|
2001-09-29 09:34:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
struct acpi_memrange *
|
|
|
|
acpi_res_memrange(struct acpi_resources *res, int idx)
|
|
|
|
{
|
|
|
|
struct acpi_memrange *ar;
|
|
|
|
|
|
|
|
SIMPLEQ_FOREACH(ar, &res->ar_memrange, ar_list) {
|
|
|
|
if (ar->ar_index == idx)
|
2004-04-11 10:48:25 +04:00
|
|
|
return ar;
|
2001-09-29 09:34:00 +04:00
|
|
|
}
|
2004-04-11 10:48:25 +04:00
|
|
|
return NULL;
|
2001-09-29 09:34:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
struct acpi_irq *
|
|
|
|
acpi_res_irq(struct acpi_resources *res, int idx)
|
|
|
|
{
|
|
|
|
struct acpi_irq *ar;
|
|
|
|
|
|
|
|
SIMPLEQ_FOREACH(ar, &res->ar_irq, ar_list) {
|
|
|
|
if (ar->ar_index == idx)
|
2004-04-11 10:48:25 +04:00
|
|
|
return ar;
|
2001-09-29 09:34:00 +04:00
|
|
|
}
|
2004-04-11 10:48:25 +04:00
|
|
|
return NULL;
|
2001-09-29 09:34:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
struct acpi_drq *
|
|
|
|
acpi_res_drq(struct acpi_resources *res, int idx)
|
|
|
|
{
|
|
|
|
struct acpi_drq *ar;
|
|
|
|
|
|
|
|
SIMPLEQ_FOREACH(ar, &res->ar_drq, ar_list) {
|
|
|
|
if (ar->ar_index == idx)
|
2004-04-11 10:48:25 +04:00
|
|
|
return ar;
|
2001-09-29 09:34:00 +04:00
|
|
|
}
|
2004-04-11 10:48:25 +04:00
|
|
|
return NULL;
|
2001-09-29 09:34:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Default ACPI resource parse operations.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
static void acpi_res_parse_init(struct device *, void *, void **);
|
|
|
|
static void acpi_res_parse_fini(struct device *, void *);
|
|
|
|
|
|
|
|
static void acpi_res_parse_ioport(struct device *, void *, uint32_t,
|
|
|
|
uint32_t);
|
|
|
|
static void acpi_res_parse_iorange(struct device *, void *, uint32_t,
|
|
|
|
uint32_t, uint32_t, uint32_t);
|
|
|
|
|
|
|
|
static void acpi_res_parse_memory(struct device *, void *, uint32_t,
|
|
|
|
uint32_t);
|
|
|
|
static void acpi_res_parse_memrange(struct device *, void *, uint32_t,
|
|
|
|
uint32_t, uint32_t, uint32_t);
|
|
|
|
|
2002-12-28 11:44:43 +03:00
|
|
|
static void acpi_res_parse_irq(struct device *, void *, uint32_t, uint32_t);
|
2001-09-29 09:34:00 +04:00
|
|
|
static void acpi_res_parse_drq(struct device *, void *, uint32_t);
|
|
|
|
|
|
|
|
static void acpi_res_parse_start_dep(struct device *, void *, int);
|
|
|
|
static void acpi_res_parse_end_dep(struct device *, void *);
|
|
|
|
|
|
|
|
const struct acpi_resource_parse_ops acpi_resource_parse_ops_default = {
|
2004-04-11 13:25:28 +04:00
|
|
|
.init = acpi_res_parse_init,
|
|
|
|
.fini = acpi_res_parse_fini,
|
2001-09-29 09:34:00 +04:00
|
|
|
|
2004-04-11 13:25:28 +04:00
|
|
|
.ioport = acpi_res_parse_ioport,
|
|
|
|
.iorange = acpi_res_parse_iorange,
|
2001-09-29 09:34:00 +04:00
|
|
|
|
2004-04-11 13:25:28 +04:00
|
|
|
.memory = acpi_res_parse_memory,
|
|
|
|
.memrange = acpi_res_parse_memrange,
|
2001-09-29 09:34:00 +04:00
|
|
|
|
2004-04-11 13:25:28 +04:00
|
|
|
.irq = acpi_res_parse_irq,
|
|
|
|
.drq = acpi_res_parse_drq,
|
2001-09-29 09:34:00 +04:00
|
|
|
|
2004-04-11 13:25:28 +04:00
|
|
|
.start_dep = acpi_res_parse_start_dep,
|
|
|
|
.end_dep = acpi_res_parse_end_dep,
|
2001-09-29 09:34:00 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
acpi_res_parse_init(struct device *dev, void *arg, void **contextp)
|
|
|
|
{
|
|
|
|
struct acpi_resources *res = arg;
|
|
|
|
|
|
|
|
SIMPLEQ_INIT(&res->ar_io);
|
|
|
|
res->ar_nio = 0;
|
|
|
|
|
|
|
|
SIMPLEQ_INIT(&res->ar_iorange);
|
|
|
|
res->ar_niorange = 0;
|
|
|
|
|
|
|
|
SIMPLEQ_INIT(&res->ar_mem);
|
|
|
|
res->ar_nmem = 0;
|
|
|
|
|
|
|
|
SIMPLEQ_INIT(&res->ar_memrange);
|
|
|
|
res->ar_nmemrange = 0;
|
|
|
|
|
|
|
|
SIMPLEQ_INIT(&res->ar_irq);
|
|
|
|
res->ar_nirq = 0;
|
|
|
|
|
|
|
|
SIMPLEQ_INIT(&res->ar_drq);
|
|
|
|
res->ar_ndrq = 0;
|
|
|
|
|
|
|
|
*contextp = res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
acpi_res_parse_fini(struct device *dev, void *context)
|
|
|
|
{
|
|
|
|
struct acpi_resources *res = context;
|
|
|
|
|
|
|
|
/* Print the resources we're using. */
|
|
|
|
acpi_resource_print(dev, res);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
acpi_res_parse_ioport(struct device *dev, void *context, uint32_t base,
|
|
|
|
uint32_t length)
|
|
|
|
{
|
|
|
|
struct acpi_resources *res = context;
|
|
|
|
struct acpi_io *ar;
|
|
|
|
|
2003-11-02 14:12:53 +03:00
|
|
|
/*
|
|
|
|
* Check if there is another I/O port directly below/under
|
|
|
|
* this one.
|
|
|
|
*/
|
|
|
|
SIMPLEQ_FOREACH(ar, &res->ar_io, ar_list) {
|
|
|
|
if (ar->ar_base == base + length ) {
|
|
|
|
/*
|
|
|
|
* Entry just below existing entry - adjust
|
|
|
|
* the entry and return.
|
|
|
|
*/
|
|
|
|
ar->ar_base = base;
|
|
|
|
ar->ar_length += length;
|
|
|
|
return;
|
|
|
|
} else if (ar->ar_base + ar->ar_length == base) {
|
|
|
|
/*
|
|
|
|
* Entry just above existing entry - adjust
|
|
|
|
* the entry and return.
|
|
|
|
*/
|
|
|
|
ar->ar_length += length;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-29 09:34:00 +04:00
|
|
|
ar = AcpiOsAllocate(sizeof(*ar));
|
|
|
|
if (ar == NULL) {
|
|
|
|
printf("%s: ACPI: unable to allocate I/O resource %d\n",
|
|
|
|
dev->dv_xname, res->ar_nio);
|
|
|
|
res->ar_nio++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ar->ar_index = res->ar_nio++;
|
|
|
|
ar->ar_base = base;
|
|
|
|
ar->ar_length = length;
|
|
|
|
|
|
|
|
SIMPLEQ_INSERT_TAIL(&res->ar_io, ar, ar_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
acpi_res_parse_iorange(struct device *dev, void *context, uint32_t low,
|
|
|
|
uint32_t high, uint32_t length, uint32_t align)
|
|
|
|
{
|
|
|
|
struct acpi_resources *res = context;
|
|
|
|
struct acpi_iorange *ar;
|
|
|
|
|
|
|
|
ar = AcpiOsAllocate(sizeof(*ar));
|
|
|
|
if (ar == NULL) {
|
|
|
|
printf("%s: ACPI: unable to allocate I/O range resource %d\n",
|
|
|
|
dev->dv_xname, res->ar_niorange);
|
|
|
|
res->ar_niorange++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ar->ar_index = res->ar_niorange++;
|
|
|
|
ar->ar_low = low;
|
|
|
|
ar->ar_high = high;
|
|
|
|
ar->ar_length = length;
|
|
|
|
ar->ar_align = align;
|
|
|
|
|
|
|
|
SIMPLEQ_INSERT_TAIL(&res->ar_iorange, ar, ar_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
acpi_res_parse_memory(struct device *dev, void *context, uint32_t base,
|
|
|
|
uint32_t length)
|
|
|
|
{
|
|
|
|
struct acpi_resources *res = context;
|
|
|
|
struct acpi_mem *ar;
|
|
|
|
|
|
|
|
ar = AcpiOsAllocate(sizeof(*ar));
|
|
|
|
if (ar == NULL) {
|
|
|
|
printf("%s: ACPI: unable to allocate Memory resource %d\n",
|
|
|
|
dev->dv_xname, res->ar_nmem);
|
|
|
|
res->ar_nmem++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ar->ar_index = res->ar_nmem++;
|
|
|
|
ar->ar_base = base;
|
|
|
|
ar->ar_length = length;
|
|
|
|
|
|
|
|
SIMPLEQ_INSERT_TAIL(&res->ar_mem, ar, ar_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
acpi_res_parse_memrange(struct device *dev, void *context, uint32_t low,
|
|
|
|
uint32_t high, uint32_t length, uint32_t align)
|
|
|
|
{
|
|
|
|
struct acpi_resources *res = context;
|
|
|
|
struct acpi_memrange *ar;
|
|
|
|
|
|
|
|
ar = AcpiOsAllocate(sizeof(*ar));
|
|
|
|
if (ar == NULL) {
|
|
|
|
printf("%s: ACPI: unable to allocate Memory range resource "
|
|
|
|
"%d\n", dev->dv_xname, res->ar_nmemrange);
|
|
|
|
res->ar_nmemrange++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ar->ar_index = res->ar_nmemrange++;
|
|
|
|
ar->ar_low = low;
|
|
|
|
ar->ar_high = high;
|
|
|
|
ar->ar_length = length;
|
|
|
|
ar->ar_align = align;
|
|
|
|
|
|
|
|
SIMPLEQ_INSERT_TAIL(&res->ar_memrange, ar, ar_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-12-28 11:44:43 +03:00
|
|
|
acpi_res_parse_irq(struct device *dev, void *context, uint32_t irq, uint32_t type)
|
2001-09-29 09:34:00 +04:00
|
|
|
{
|
|
|
|
struct acpi_resources *res = context;
|
|
|
|
struct acpi_irq *ar;
|
|
|
|
|
|
|
|
ar = AcpiOsAllocate(sizeof(*ar));
|
|
|
|
if (ar == NULL) {
|
|
|
|
printf("%s: ACPI: unable to allocate IRQ resource %d\n",
|
|
|
|
dev->dv_xname, res->ar_nirq);
|
|
|
|
res->ar_nirq++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ar->ar_index = res->ar_nirq++;
|
|
|
|
ar->ar_irq = irq;
|
2002-12-28 11:44:43 +03:00
|
|
|
ar->ar_type = type;
|
2001-09-29 09:34:00 +04:00
|
|
|
|
|
|
|
SIMPLEQ_INSERT_TAIL(&res->ar_irq, ar, ar_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
acpi_res_parse_drq(struct device *dev, void *context, uint32_t drq)
|
|
|
|
{
|
|
|
|
struct acpi_resources *res = context;
|
|
|
|
struct acpi_drq *ar;
|
|
|
|
|
|
|
|
ar = AcpiOsAllocate(sizeof(*ar));
|
|
|
|
if (ar == NULL) {
|
|
|
|
printf("%s: ACPI: unable to allocate DRQ resource %d\n",
|
|
|
|
dev->dv_xname, res->ar_ndrq);
|
|
|
|
res->ar_ndrq++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ar->ar_index = res->ar_ndrq++;
|
|
|
|
ar->ar_drq = drq;
|
|
|
|
|
|
|
|
SIMPLEQ_INSERT_TAIL(&res->ar_drq, ar, ar_list);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
acpi_res_parse_start_dep(struct device *dev, void *context, int preference)
|
|
|
|
{
|
2004-04-10 15:48:10 +04:00
|
|
|
|
2001-09-29 09:34:00 +04:00
|
|
|
printf("%s: ACPI: dependant functions not supported\n",
|
|
|
|
dev->dv_xname);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
acpi_res_parse_end_dep(struct device *dev, void *context)
|
|
|
|
{
|
|
|
|
|
|
|
|
/* Nothing to do. */
|
|
|
|
}
|