Home | History | Annotate | Line # | Download | only in acpi
acpi_resource.c revision 1.21.8.1
      1  1.21.8.1        ad /*	$NetBSD: acpi_resource.c,v 1.21.8.1 2007/10/09 13:41:13 ad Exp $	*/
      2       1.1   thorpej 
      3       1.1   thorpej /*
      4       1.1   thorpej  * Copyright 2001 Wasabi Systems, Inc.
      5       1.1   thorpej  * All rights reserved.
      6       1.1   thorpej  *
      7       1.1   thorpej  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
      8       1.1   thorpej  *
      9       1.1   thorpej  * Redistribution and use in source and binary forms, with or without
     10       1.1   thorpej  * modification, are permitted provided that the following conditions
     11       1.1   thorpej  * are met:
     12       1.1   thorpej  * 1. Redistributions of source code must retain the above copyright
     13       1.1   thorpej  *    notice, this list of conditions and the following disclaimer.
     14       1.1   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     15       1.1   thorpej  *    notice, this list of conditions and the following disclaimer in the
     16       1.1   thorpej  *    documentation and/or other materials provided with the distribution.
     17       1.1   thorpej  * 3. All advertising materials mentioning features or use of this software
     18       1.1   thorpej  *    must display the following acknowledgement:
     19       1.1   thorpej  *	This product includes software developed for the NetBSD Project by
     20       1.1   thorpej  *	Wasabi Systems, Inc.
     21       1.1   thorpej  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     22       1.1   thorpej  *    or promote products derived from this software without specific prior
     23       1.1   thorpej  *    written permission.
     24       1.1   thorpej  *
     25       1.1   thorpej  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     26       1.1   thorpej  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27       1.1   thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28       1.1   thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     29       1.1   thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30       1.1   thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31       1.1   thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32       1.1   thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33       1.1   thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34       1.1   thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35       1.1   thorpej  * POSSIBILITY OF SUCH DAMAGE.
     36       1.1   thorpej  */
     37       1.1   thorpej 
     38       1.1   thorpej /*-
     39       1.1   thorpej  * Copyright (c) 2000 Michael Smith
     40       1.1   thorpej  * Copyright (c) 2000 BSDi
     41       1.1   thorpej  * All rights reserved.
     42       1.1   thorpej  *
     43       1.1   thorpej  * Redistribution and use in source and binary forms, with or without
     44       1.1   thorpej  * modification, are permitted provided that the following conditions
     45       1.1   thorpej  * are met:
     46       1.1   thorpej  * 1. Redistributions of source code must retain the above copyright
     47       1.1   thorpej  *    notice, this list of conditions and the following disclaimer.
     48       1.1   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     49       1.1   thorpej  *    notice, this list of conditions and the following disclaimer in the
     50       1.1   thorpej  *    documentation and/or other materials provided with the distribution.
     51      1.10     kochi  *
     52       1.1   thorpej  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     53       1.1   thorpej  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     54       1.1   thorpej  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     55      1.10     kochi  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     56       1.1   thorpej  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     57       1.1   thorpej  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     58       1.1   thorpej  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     59       1.1   thorpej  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     60       1.1   thorpej  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     61       1.1   thorpej  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     62      1.10     kochi  * SUCH DAMAGE.
     63       1.1   thorpej  */
     64       1.1   thorpej 
     65       1.1   thorpej /*
     66       1.1   thorpej  * ACPI resource parsing.
     67       1.1   thorpej  */
     68       1.2     lukem 
     69       1.2     lukem #include <sys/cdefs.h>
     70  1.21.8.1        ad __KERNEL_RCSID(0, "$NetBSD: acpi_resource.c,v 1.21.8.1 2007/10/09 13:41:13 ad Exp $");
     71       1.1   thorpej 
     72       1.1   thorpej #include <sys/param.h>
     73       1.1   thorpej #include <sys/systm.h>
     74       1.1   thorpej #include <sys/device.h>
     75       1.1   thorpej 
     76       1.1   thorpej #include <dev/acpi/acpica.h>
     77       1.1   thorpej #include <dev/acpi/acpireg.h>
     78       1.1   thorpej #include <dev/acpi/acpivar.h>
     79       1.1   thorpej 
     80       1.4   thorpej #define	_COMPONENT	ACPI_RESOURCE_COMPONENT
     81       1.4   thorpej ACPI_MODULE_NAME("RESOURCE")
     82       1.1   thorpej 
     83      1.13     kochi static ACPI_STATUS acpi_resource_parse_callback(ACPI_RESOURCE *, void *);
     84      1.13     kochi 
     85      1.12     kochi struct resource_parse_callback_arg {
     86      1.12     kochi 	const struct acpi_resource_parse_ops *ops;
     87      1.12     kochi 	struct device *dev;
     88      1.12     kochi 	void *context;
     89      1.12     kochi };
     90      1.12     kochi 
     91      1.12     kochi static ACPI_STATUS
     92      1.12     kochi acpi_resource_parse_callback(ACPI_RESOURCE *res, void *context)
     93       1.1   thorpej {
     94      1.12     kochi 	struct resource_parse_callback_arg *arg = context;
     95      1.12     kochi 	const struct acpi_resource_parse_ops *ops;
     96       1.1   thorpej 	int i;
     97       1.1   thorpej 
     98      1.15     kochi 	ACPI_FUNCTION_TRACE(__FUNCTION__);
     99      1.15     kochi 
    100      1.12     kochi 	ops = arg->ops;
    101       1.1   thorpej 
    102      1.19     kochi 	switch (res->Type) {
    103      1.19     kochi 	case ACPI_RESOURCE_TYPE_FIXED_IO:
    104      1.12     kochi 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    105      1.12     kochi 				     "FixedIo 0x%x/%d\n",
    106      1.19     kochi 				     res->Data.FixedIo.Address,
    107      1.19     kochi 				     res->Data.FixedIo.AddressLength));
    108      1.13     kochi 		if (ops->ioport)
    109      1.13     kochi 			(*ops->ioport)(arg->dev, arg->context,
    110      1.19     kochi 			    res->Data.FixedIo.Address,
    111      1.19     kochi 			    res->Data.FixedIo.AddressLength);
    112      1.12     kochi 		break;
    113       1.1   thorpej 
    114      1.19     kochi 	case ACPI_RESOURCE_TYPE_IO:
    115      1.19     kochi 		if (res->Data.Io.Minimum ==
    116  1.21.8.1        ad 		    res->Data.Io.Maximum) {
    117       1.1   thorpej 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    118      1.12     kochi 					     "Io 0x%x/%d\n",
    119      1.19     kochi 					     res->Data.Io.Minimum,
    120      1.19     kochi 					     res->Data.Io.AddressLength));
    121      1.13     kochi 			if (ops->ioport)
    122      1.13     kochi 				(*ops->ioport)(arg->dev, arg->context,
    123      1.19     kochi 				    res->Data.Io.Minimum,
    124      1.19     kochi 				    res->Data.Io.AddressLength);
    125      1.12     kochi 		} else {
    126       1.1   thorpej 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    127      1.12     kochi 					     "Io 0x%x-0x%x/%d\n",
    128      1.19     kochi 					     res->Data.Io.Minimum,
    129      1.19     kochi 					     res->Data.Io.Maximum,
    130      1.19     kochi 					     res->Data.Io.AddressLength));
    131  1.21.8.1        ad 			if (ops->iorange)
    132      1.13     kochi 				(*ops->iorange)(arg->dev, arg->context,
    133      1.19     kochi 				    res->Data.Io.Minimum,
    134      1.19     kochi 				    res->Data.Io.Maximum,
    135      1.19     kochi 				    res->Data.Io.AddressLength,
    136      1.13     kochi 				    res->Data.Io.Alignment);
    137      1.12     kochi 		}
    138      1.12     kochi 		break;
    139       1.1   thorpej 
    140      1.19     kochi 	case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
    141      1.12     kochi 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    142      1.12     kochi 				     "FixedMemory32 0x%x/%d\n",
    143      1.19     kochi 				     res->Data.FixedMemory32.Address,
    144      1.19     kochi 				     res->Data.FixedMemory32.AddressLength));
    145      1.13     kochi 		if (ops->memory)
    146      1.13     kochi 			(*ops->memory)(arg->dev, arg->context,
    147      1.19     kochi 			    res->Data.FixedMemory32.Address,
    148      1.19     kochi 			    res->Data.FixedMemory32.AddressLength);
    149      1.12     kochi 		break;
    150      1.12     kochi 
    151      1.19     kochi 	case ACPI_RESOURCE_TYPE_MEMORY32:
    152      1.19     kochi 		if (res->Data.Memory32.Minimum ==
    153      1.19     kochi 		    res->Data.Memory32.Maximum) {
    154       1.1   thorpej 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    155      1.12     kochi 					     "Memory32 0x%x/%d\n",
    156      1.19     kochi 					     res->Data.Memory32.Minimum,
    157      1.19     kochi 					     res->Data.Memory32.AddressLength));
    158      1.13     kochi 			if (ops->memory)
    159      1.13     kochi 				(*ops->memory)(arg->dev, arg->context,
    160      1.19     kochi 				    res->Data.Memory32.Minimum,
    161      1.19     kochi 				    res->Data.Memory32.AddressLength);
    162      1.12     kochi 		} else {
    163       1.1   thorpej 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    164      1.12     kochi 					     "Memory32 0x%x-0x%x/%d\n",
    165      1.19     kochi 					     res->Data.Memory32.Minimum,
    166      1.19     kochi 					     res->Data.Memory32.Maximum,
    167      1.19     kochi 					     res->Data.Memory32.AddressLength));
    168      1.13     kochi 			if (ops->memrange)
    169      1.13     kochi 				(*ops->memrange)(arg->dev, arg->context,
    170      1.19     kochi 				    res->Data.Memory32.Minimum,
    171      1.19     kochi 				    res->Data.Memory32.Maximum,
    172      1.19     kochi 				    res->Data.Memory32.AddressLength,
    173      1.13     kochi 				    res->Data.Memory32.Alignment);
    174      1.12     kochi 		}
    175      1.12     kochi 		break;
    176       1.1   thorpej 
    177      1.19     kochi 	case ACPI_RESOURCE_TYPE_MEMORY24:
    178      1.19     kochi 		if (res->Data.Memory24.Minimum ==
    179      1.19     kochi 		    res->Data.Memory24.Maximum) {
    180       1.1   thorpej 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    181      1.12     kochi 					     "Memory24 0x%x/%d\n",
    182      1.19     kochi 					     res->Data.Memory24.Minimum,
    183      1.19     kochi 					     res->Data.Memory24.AddressLength));
    184      1.13     kochi 			if (ops->memory)
    185      1.13     kochi 				(*ops->memory)(arg->dev, arg->context,
    186      1.19     kochi 				    res->Data.Memory24.Minimum,
    187      1.19     kochi 				    res->Data.Memory24.AddressLength);
    188      1.12     kochi 		} else {
    189       1.1   thorpej 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    190      1.12     kochi 					     "Memory24 0x%x-0x%x/%d\n",
    191      1.19     kochi 					     res->Data.Memory24.Minimum,
    192      1.19     kochi 					     res->Data.Memory24.Maximum,
    193      1.19     kochi 					     res->Data.Memory24.AddressLength));
    194      1.13     kochi 			if (ops->memrange)
    195      1.13     kochi 				(*ops->memrange)(arg->dev, arg->context,
    196      1.19     kochi 				    res->Data.Memory24.Minimum,
    197      1.19     kochi 				    res->Data.Memory24.Maximum,
    198      1.19     kochi 				    res->Data.Memory24.AddressLength,
    199      1.13     kochi 				    res->Data.Memory24.Alignment);
    200      1.12     kochi 		}
    201      1.12     kochi 		break;
    202       1.1   thorpej 
    203      1.19     kochi 	case ACPI_RESOURCE_TYPE_IRQ:
    204      1.19     kochi 		for (i = 0; i < res->Data.Irq.InterruptCount; i++) {
    205       1.1   thorpej 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    206      1.12     kochi 					     "IRQ %d\n",
    207      1.12     kochi 					     res->Data.Irq.Interrupts[i]));
    208      1.13     kochi 			if (ops->irq)
    209      1.13     kochi 				(*ops->irq)(arg->dev, arg->context,
    210      1.13     kochi 				    res->Data.Irq.Interrupts[i],
    211      1.19     kochi 				    res->Data.Irq.Triggering);
    212      1.12     kochi 		}
    213      1.12     kochi 		break;
    214       1.1   thorpej 
    215      1.19     kochi 	case ACPI_RESOURCE_TYPE_DMA:
    216      1.19     kochi 		for (i = 0; i < res->Data.Dma.ChannelCount; i++) {
    217       1.1   thorpej 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    218      1.12     kochi 					     "DRQ %d\n",
    219      1.12     kochi 					     res->Data.Dma.Channels[i]));
    220      1.13     kochi 			if (ops->drq)
    221      1.13     kochi 				(*ops->drq)(arg->dev, arg->context,
    222      1.13     kochi 				    res->Data.Dma.Channels[i]);
    223       1.1   thorpej 		}
    224      1.12     kochi 		break;
    225      1.12     kochi 
    226      1.19     kochi 	case ACPI_RESOURCE_TYPE_START_DEPENDENT:
    227      1.12     kochi 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    228      1.12     kochi 				     "Start dependant functions: %d\n",
    229      1.12     kochi 				     res->Data.StartDpf.CompatibilityPriority));
    230      1.13     kochi 		if (ops->start_dep)
    231      1.13     kochi 			(*ops->start_dep)(arg->dev, arg->context,
    232      1.13     kochi 			    res->Data.StartDpf.CompatibilityPriority);
    233      1.12     kochi 		break;
    234      1.12     kochi 
    235      1.19     kochi 	case ACPI_RESOURCE_TYPE_END_DEPENDENT:
    236      1.12     kochi 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    237      1.12     kochi 				     "End dependant functions\n"));
    238      1.13     kochi 		if (ops->end_dep)
    239      1.13     kochi 			(*ops->end_dep)(arg->dev, arg->context);
    240  1.21.8.1        ad 		break;
    241      1.12     kochi 
    242      1.19     kochi 	case ACPI_RESOURCE_TYPE_ADDRESS32:
    243  1.21.8.1        ad 		/* XXX Only fixed size supported for now */
    244  1.21.8.1        ad 		if (res->Data.Address32.AddressLength == 0 ||
    245  1.21.8.1        ad 		    res->Data.Address32.ProducerConsumer != ACPI_CONSUMER)
    246  1.21.8.1        ad 			break;
    247  1.21.8.1        ad #define ADRRESS32_FIXED2(r)						\
    248  1.21.8.1        ad 	((r)->Data.Address32.MinAddressFixed == ACPI_ADDRESS_FIXED &&	\
    249  1.21.8.1        ad 	 (r)->Data.Address32.MaxAddressFixed == ACPI_ADDRESS_FIXED)
    250  1.21.8.1        ad 		switch (res->Data.Address32.ResourceType) {
    251  1.21.8.1        ad 		case ACPI_MEMORY_RANGE:
    252  1.21.8.1        ad 			if (ADRRESS32_FIXED2(res)) {
    253  1.21.8.1        ad 				if (ops->memory)
    254  1.21.8.1        ad 					(*ops->memory)(arg->dev, arg->context,
    255  1.21.8.1        ad 					    res->Data.Address32.Minimum,
    256  1.21.8.1        ad 					    res->Data.Address32.AddressLength);
    257  1.21.8.1        ad 			} else {
    258  1.21.8.1        ad 				if (ops->memrange)
    259  1.21.8.1        ad 					(*ops->memrange)(arg->dev, arg->context,
    260  1.21.8.1        ad 					    res->Data.Address32.Minimum,
    261  1.21.8.1        ad 					    res->Data.Address32.Maximum,
    262  1.21.8.1        ad 					    res->Data.Address32.AddressLength,
    263  1.21.8.1        ad 					    res->Data.Address32.Granularity);
    264  1.21.8.1        ad 			}
    265  1.21.8.1        ad 			break;
    266  1.21.8.1        ad 		case ACPI_IO_RANGE:
    267  1.21.8.1        ad 			if (ADRRESS32_FIXED2(res)) {
    268  1.21.8.1        ad 				if (ops->ioport)
    269  1.21.8.1        ad 					(*ops->ioport)(arg->dev, arg->context,
    270  1.21.8.1        ad 					    res->Data.Address32.Minimum,
    271  1.21.8.1        ad 					    res->Data.Address32.AddressLength);
    272  1.21.8.1        ad 			} else {
    273  1.21.8.1        ad 				if (ops->iorange)
    274  1.21.8.1        ad 					(*ops->iorange)(arg->dev, arg->context,
    275  1.21.8.1        ad 					    res->Data.Address32.Minimum,
    276  1.21.8.1        ad 					    res->Data.Address32.Maximum,
    277  1.21.8.1        ad 					    res->Data.Address32.AddressLength,
    278  1.21.8.1        ad 					    res->Data.Address32.Granularity);
    279  1.21.8.1        ad 			}
    280  1.21.8.1        ad 			break;
    281  1.21.8.1        ad 		case ACPI_BUS_NUMBER_RANGE:
    282  1.21.8.1        ad 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    283  1.21.8.1        ad 				      "Address32/BusNumber unimplemented\n"));
    284  1.21.8.1        ad 			break;
    285  1.21.8.1        ad 		}
    286  1.21.8.1        ad #undef ADRRESS32_FIXED2
    287      1.12     kochi 		break;
    288      1.12     kochi 
    289      1.19     kochi 	case ACPI_RESOURCE_TYPE_ADDRESS16:
    290      1.12     kochi 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    291      1.12     kochi 				     "Address16 unimplemented\n"));
    292      1.12     kochi 		break;
    293      1.12     kochi 
    294      1.19     kochi 	case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
    295      1.19     kochi 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    296      1.19     kochi 				     "Extended address64 unimplemented\n"));
    297      1.19     kochi 		break;
    298      1.19     kochi 
    299      1.19     kochi 	case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
    300      1.19     kochi 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    301      1.19     kochi 				     "ExtendedIrq unimplemented\n"));
    302      1.19     kochi 		break;
    303      1.19     kochi 
    304      1.19     kochi 	case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
    305      1.12     kochi 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    306  1.21.8.1        ad 				     "GenericRegister unimplemented\n"));
    307      1.12     kochi 		break;
    308      1.12     kochi 
    309      1.19     kochi 	case ACPI_RESOURCE_TYPE_VENDOR:
    310      1.12     kochi 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    311      1.12     kochi 				     "VendorSpecific unimplemented\n"));
    312      1.12     kochi 		break;
    313      1.12     kochi 
    314      1.12     kochi 	default:
    315      1.12     kochi 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    316      1.19     kochi 				     "Unknown resource type: %d\n", res->Type));
    317      1.12     kochi 		break;
    318      1.12     kochi 	}
    319      1.12     kochi 
    320      1.15     kochi 	return_ACPI_STATUS(AE_OK);
    321      1.12     kochi }
    322      1.12     kochi 
    323      1.12     kochi 
    324      1.12     kochi /*
    325      1.12     kochi  * acpi_resource_parse:
    326      1.12     kochi  *
    327      1.12     kochi  *	Parse a device node's resources and fill them in for the
    328      1.12     kochi  *	client.
    329      1.12     kochi  *
    330      1.12     kochi  *	This API supports _CRS (current resources) and
    331      1.12     kochi  *	_PRS (possible resources).
    332      1.12     kochi  *
    333      1.12     kochi  *	Note that it might be nice to also locate ACPI-specific resource
    334      1.12     kochi  *	items, such as GPE bits.
    335      1.12     kochi  */
    336      1.12     kochi ACPI_STATUS
    337      1.17  christos acpi_resource_parse(struct device *dev, ACPI_HANDLE handle, const char *path,
    338      1.12     kochi     void *arg, const struct acpi_resource_parse_ops *ops)
    339      1.12     kochi {
    340      1.12     kochi 	struct resource_parse_callback_arg cbarg;
    341      1.12     kochi 	ACPI_STATUS rv;
    342      1.12     kochi 
    343      1.12     kochi 	ACPI_FUNCTION_TRACE(__FUNCTION__);
    344      1.12     kochi 
    345      1.13     kochi 	if (ops->init)
    346      1.13     kochi 		(*ops->init)(dev, arg, &cbarg.context);
    347      1.13     kochi 	else
    348      1.13     kochi 		cbarg.context = arg;
    349      1.12     kochi 	cbarg.ops = ops;
    350      1.12     kochi 	cbarg.dev = dev;
    351      1.12     kochi 
    352      1.17  christos 	rv = AcpiWalkResources(handle, path, acpi_resource_parse_callback,
    353      1.12     kochi 	    &cbarg);
    354      1.12     kochi 	if (ACPI_FAILURE(rv)) {
    355      1.12     kochi 		printf("%s: ACPI: unable to get %s resources: %s\n",
    356      1.12     kochi 		    dev->dv_xname, path, AcpiFormatException(rv));
    357      1.12     kochi 		return_ACPI_STATUS(rv);
    358       1.1   thorpej 	}
    359       1.1   thorpej 
    360      1.13     kochi 	if (ops->fini)
    361      1.13     kochi 		(*ops->fini)(dev, cbarg.context);
    362       1.1   thorpej 
    363       1.1   thorpej 	return_ACPI_STATUS(AE_OK);
    364       1.1   thorpej }
    365       1.1   thorpej 
    366       1.1   thorpej /*
    367       1.1   thorpej  * acpi_resource_print:
    368       1.1   thorpej  *
    369       1.1   thorpej  *	Print the resources assigned to a device.
    370       1.1   thorpej  */
    371       1.1   thorpej void
    372       1.1   thorpej acpi_resource_print(struct device *dev, struct acpi_resources *res)
    373       1.1   thorpej {
    374       1.1   thorpej 	const char *sep;
    375       1.1   thorpej 
    376       1.1   thorpej 	if (SIMPLEQ_EMPTY(&res->ar_io) &&
    377       1.1   thorpej 	    SIMPLEQ_EMPTY(&res->ar_iorange) &&
    378       1.1   thorpej 	    SIMPLEQ_EMPTY(&res->ar_mem) &&
    379       1.1   thorpej 	    SIMPLEQ_EMPTY(&res->ar_memrange) &&
    380       1.1   thorpej 	    SIMPLEQ_EMPTY(&res->ar_irq) &&
    381       1.1   thorpej 	    SIMPLEQ_EMPTY(&res->ar_drq))
    382       1.1   thorpej 		return;
    383       1.1   thorpej 
    384       1.1   thorpej 	printf("%s:", dev->dv_xname);
    385       1.1   thorpej 
    386       1.1   thorpej 	if (SIMPLEQ_EMPTY(&res->ar_io) == 0) {
    387       1.1   thorpej 		struct acpi_io *ar;
    388       1.1   thorpej 
    389       1.1   thorpej 		sep = "";
    390       1.1   thorpej 		printf(" io ");
    391       1.3     lukem 		SIMPLEQ_FOREACH(ar, &res->ar_io, ar_list) {
    392       1.1   thorpej 			printf("%s0x%x", sep, ar->ar_base);
    393       1.1   thorpej 			if (ar->ar_length > 1)
    394       1.1   thorpej 				printf("-0x%x", ar->ar_base +
    395       1.1   thorpej 				    ar->ar_length - 1);
    396       1.1   thorpej 			sep = ",";
    397       1.1   thorpej 		}
    398       1.1   thorpej 	}
    399       1.1   thorpej 
    400       1.1   thorpej 	/* XXX iorange */
    401       1.1   thorpej 
    402       1.1   thorpej 	if (SIMPLEQ_EMPTY(&res->ar_mem) == 0) {
    403       1.1   thorpej 		struct acpi_mem *ar;
    404       1.1   thorpej 
    405       1.1   thorpej 		sep = "";
    406       1.1   thorpej 		printf(" mem ");
    407       1.3     lukem 		SIMPLEQ_FOREACH(ar, &res->ar_mem, ar_list) {
    408       1.1   thorpej 			printf("%s0x%x", sep, ar->ar_base);
    409       1.1   thorpej 			if (ar->ar_length > 1)
    410       1.1   thorpej 				printf("-0x%x", ar->ar_base +
    411       1.1   thorpej 				    ar->ar_length - 1);
    412       1.1   thorpej 			sep = ",";
    413       1.1   thorpej 		}
    414       1.1   thorpej 	}
    415       1.1   thorpej 
    416       1.1   thorpej 	/* XXX memrange */
    417       1.1   thorpej 
    418       1.1   thorpej 	if (SIMPLEQ_EMPTY(&res->ar_irq) == 0) {
    419       1.1   thorpej 		struct acpi_irq *ar;
    420       1.1   thorpej 
    421       1.1   thorpej 		sep = "";
    422       1.1   thorpej 		printf(" irq ");
    423       1.3     lukem 		SIMPLEQ_FOREACH(ar, &res->ar_irq, ar_list) {
    424       1.1   thorpej 			printf("%s%d", sep, ar->ar_irq);
    425       1.1   thorpej 			sep = ",";
    426       1.1   thorpej 		}
    427       1.1   thorpej 	}
    428       1.1   thorpej 
    429       1.1   thorpej 	if (SIMPLEQ_EMPTY(&res->ar_drq) == 0) {
    430       1.1   thorpej 		struct acpi_drq *ar;
    431       1.1   thorpej 
    432       1.1   thorpej 		sep = "";
    433       1.1   thorpej 		printf(" drq ");
    434       1.3     lukem 		SIMPLEQ_FOREACH(ar, &res->ar_drq, ar_list) {
    435       1.1   thorpej 			printf("%s%d", sep, ar->ar_drq);
    436       1.1   thorpej 			sep = ",";
    437       1.1   thorpej 		}
    438       1.1   thorpej 	}
    439       1.1   thorpej 
    440       1.1   thorpej 	printf("\n");
    441       1.1   thorpej }
    442       1.1   thorpej 
    443      1.14     kochi /*
    444      1.14     kochi  * acpi_resource_cleanup:
    445      1.14     kochi  *
    446      1.14     kochi  *	Free all allocated buffers
    447      1.14     kochi  */
    448      1.14     kochi void
    449      1.14     kochi acpi_resource_cleanup(struct acpi_resources *res)
    450      1.14     kochi {
    451      1.14     kochi 	while (!SIMPLEQ_EMPTY(&res->ar_io)) {
    452      1.14     kochi 		struct acpi_io *ar;
    453      1.14     kochi 		ar = SIMPLEQ_FIRST(&res->ar_io);
    454      1.14     kochi 		SIMPLEQ_REMOVE_HEAD(&res->ar_io, ar_list);
    455      1.14     kochi 		AcpiOsFree(ar);
    456      1.14     kochi 	}
    457      1.14     kochi 
    458      1.14     kochi 	while (!SIMPLEQ_EMPTY(&res->ar_iorange)) {
    459      1.14     kochi 		struct acpi_iorange *ar;
    460      1.14     kochi 		ar = SIMPLEQ_FIRST(&res->ar_iorange);
    461      1.14     kochi 		SIMPLEQ_REMOVE_HEAD(&res->ar_iorange, ar_list);
    462      1.14     kochi 		AcpiOsFree(ar);
    463      1.14     kochi 	}
    464      1.14     kochi 
    465      1.14     kochi 	while (!SIMPLEQ_EMPTY(&res->ar_mem)) {
    466      1.14     kochi 		struct acpi_mem *ar;
    467      1.14     kochi 		ar = SIMPLEQ_FIRST(&res->ar_mem);
    468      1.14     kochi 		SIMPLEQ_REMOVE_HEAD(&res->ar_mem, ar_list);
    469      1.14     kochi 		AcpiOsFree(ar);
    470      1.14     kochi 	}
    471      1.14     kochi 
    472      1.14     kochi 	while (!SIMPLEQ_EMPTY(&res->ar_memrange)) {
    473      1.14     kochi 		struct acpi_memrange *ar;
    474      1.14     kochi 		ar = SIMPLEQ_FIRST(&res->ar_memrange);
    475      1.14     kochi 		SIMPLEQ_REMOVE_HEAD(&res->ar_memrange, ar_list);
    476      1.14     kochi 		AcpiOsFree(ar);
    477      1.14     kochi 	}
    478      1.14     kochi 
    479      1.14     kochi 	while (!SIMPLEQ_EMPTY(&res->ar_irq)) {
    480      1.14     kochi 		struct acpi_irq *ar;
    481      1.14     kochi 		ar = SIMPLEQ_FIRST(&res->ar_irq);
    482      1.14     kochi 		SIMPLEQ_REMOVE_HEAD(&res->ar_irq, ar_list);
    483      1.14     kochi 		AcpiOsFree(ar);
    484      1.14     kochi 	}
    485      1.14     kochi 
    486      1.14     kochi 	while (!SIMPLEQ_EMPTY(&res->ar_drq)) {
    487      1.14     kochi 		struct acpi_drq *ar;
    488      1.14     kochi 		ar = SIMPLEQ_FIRST(&res->ar_drq);
    489      1.14     kochi 		SIMPLEQ_REMOVE_HEAD(&res->ar_drq, ar_list);
    490      1.14     kochi 		AcpiOsFree(ar);
    491      1.14     kochi 	}
    492      1.14     kochi 
    493      1.16     perry 	res->ar_nio = res->ar_niorange = res->ar_nmem =
    494      1.14     kochi 	    res->ar_nmemrange = res->ar_nirq = res->ar_ndrq = 0;
    495      1.14     kochi }
    496      1.14     kochi 
    497       1.1   thorpej struct acpi_io *
    498       1.1   thorpej acpi_res_io(struct acpi_resources *res, int idx)
    499       1.1   thorpej {
    500       1.1   thorpej 	struct acpi_io *ar;
    501       1.1   thorpej 
    502       1.1   thorpej 	SIMPLEQ_FOREACH(ar, &res->ar_io, ar_list) {
    503       1.1   thorpej 		if (ar->ar_index == idx)
    504      1.11     kochi 			return ar;
    505       1.1   thorpej 	}
    506      1.11     kochi 	return NULL;
    507       1.1   thorpej }
    508       1.1   thorpej 
    509       1.1   thorpej struct acpi_iorange *
    510       1.1   thorpej acpi_res_iorange(struct acpi_resources *res, int idx)
    511       1.1   thorpej {
    512       1.1   thorpej 	struct acpi_iorange *ar;
    513       1.1   thorpej 
    514       1.1   thorpej 	SIMPLEQ_FOREACH(ar, &res->ar_iorange, ar_list) {
    515       1.1   thorpej 		if (ar->ar_index == idx)
    516      1.11     kochi 			return ar;
    517       1.1   thorpej 	}
    518      1.11     kochi 	return NULL;
    519       1.1   thorpej }
    520       1.1   thorpej 
    521       1.1   thorpej struct acpi_mem *
    522       1.1   thorpej acpi_res_mem(struct acpi_resources *res, int idx)
    523       1.1   thorpej {
    524       1.1   thorpej 	struct acpi_mem *ar;
    525       1.1   thorpej 
    526       1.1   thorpej 	SIMPLEQ_FOREACH(ar, &res->ar_mem, ar_list) {
    527       1.1   thorpej 		if (ar->ar_index == idx)
    528      1.11     kochi 			return ar;
    529       1.1   thorpej 	}
    530      1.11     kochi 	return NULL;
    531       1.1   thorpej }
    532       1.1   thorpej 
    533       1.1   thorpej struct acpi_memrange *
    534       1.1   thorpej acpi_res_memrange(struct acpi_resources *res, int idx)
    535       1.1   thorpej {
    536       1.1   thorpej 	struct acpi_memrange *ar;
    537       1.1   thorpej 
    538       1.1   thorpej 	SIMPLEQ_FOREACH(ar, &res->ar_memrange, ar_list) {
    539       1.1   thorpej 		if (ar->ar_index == idx)
    540      1.11     kochi 			return ar;
    541       1.1   thorpej 	}
    542      1.11     kochi 	return NULL;
    543       1.1   thorpej }
    544       1.1   thorpej 
    545       1.1   thorpej struct acpi_irq *
    546       1.1   thorpej acpi_res_irq(struct acpi_resources *res, int idx)
    547       1.1   thorpej {
    548       1.1   thorpej 	struct acpi_irq *ar;
    549       1.1   thorpej 
    550       1.1   thorpej 	SIMPLEQ_FOREACH(ar, &res->ar_irq, ar_list) {
    551       1.1   thorpej 		if (ar->ar_index == idx)
    552      1.11     kochi 			return ar;
    553       1.1   thorpej 	}
    554      1.11     kochi 	return NULL;
    555       1.1   thorpej }
    556       1.1   thorpej 
    557       1.1   thorpej struct acpi_drq *
    558       1.1   thorpej acpi_res_drq(struct acpi_resources *res, int idx)
    559       1.1   thorpej {
    560       1.1   thorpej 	struct acpi_drq *ar;
    561       1.1   thorpej 
    562       1.1   thorpej 	SIMPLEQ_FOREACH(ar, &res->ar_drq, ar_list) {
    563       1.1   thorpej 		if (ar->ar_index == idx)
    564      1.11     kochi 			return ar;
    565       1.1   thorpej 	}
    566      1.11     kochi 	return NULL;
    567       1.1   thorpej }
    568       1.1   thorpej 
    569       1.1   thorpej /*****************************************************************************
    570       1.1   thorpej  * Default ACPI resource parse operations.
    571       1.1   thorpej  *****************************************************************************/
    572       1.1   thorpej 
    573       1.1   thorpej static void	acpi_res_parse_init(struct device *, void *, void **);
    574       1.1   thorpej static void	acpi_res_parse_fini(struct device *, void *);
    575       1.1   thorpej 
    576       1.1   thorpej static void	acpi_res_parse_ioport(struct device *, void *, uint32_t,
    577       1.1   thorpej 		    uint32_t);
    578       1.1   thorpej static void	acpi_res_parse_iorange(struct device *, void *, uint32_t,
    579       1.1   thorpej 		    uint32_t, uint32_t, uint32_t);
    580       1.1   thorpej 
    581       1.1   thorpej static void	acpi_res_parse_memory(struct device *, void *, uint32_t,
    582       1.1   thorpej 		    uint32_t);
    583       1.1   thorpej static void	acpi_res_parse_memrange(struct device *, void *, uint32_t,
    584       1.1   thorpej 		    uint32_t, uint32_t, uint32_t);
    585       1.1   thorpej 
    586       1.5      matt static void	acpi_res_parse_irq(struct device *, void *, uint32_t, uint32_t);
    587       1.1   thorpej static void	acpi_res_parse_drq(struct device *, void *, uint32_t);
    588       1.1   thorpej 
    589       1.1   thorpej static void	acpi_res_parse_start_dep(struct device *, void *, int);
    590       1.1   thorpej static void	acpi_res_parse_end_dep(struct device *, void *);
    591       1.1   thorpej 
    592       1.1   thorpej const struct acpi_resource_parse_ops acpi_resource_parse_ops_default = {
    593      1.13     kochi 	.init = acpi_res_parse_init,
    594      1.13     kochi 	.fini = acpi_res_parse_fini,
    595       1.1   thorpej 
    596      1.13     kochi 	.ioport = acpi_res_parse_ioport,
    597      1.13     kochi 	.iorange = acpi_res_parse_iorange,
    598       1.1   thorpej 
    599      1.13     kochi 	.memory = acpi_res_parse_memory,
    600      1.13     kochi 	.memrange = acpi_res_parse_memrange,
    601       1.1   thorpej 
    602      1.13     kochi 	.irq = acpi_res_parse_irq,
    603      1.13     kochi 	.drq = acpi_res_parse_drq,
    604       1.1   thorpej 
    605      1.13     kochi 	.start_dep = acpi_res_parse_start_dep,
    606      1.13     kochi 	.end_dep = acpi_res_parse_end_dep,
    607       1.1   thorpej };
    608       1.1   thorpej 
    609       1.1   thorpej static void
    610      1.21  christos acpi_res_parse_init(struct device *dev, void *arg, void **contextp)
    611       1.1   thorpej {
    612       1.1   thorpej 	struct acpi_resources *res = arg;
    613       1.1   thorpej 
    614       1.1   thorpej 	SIMPLEQ_INIT(&res->ar_io);
    615       1.1   thorpej 	res->ar_nio = 0;
    616       1.1   thorpej 
    617       1.1   thorpej 	SIMPLEQ_INIT(&res->ar_iorange);
    618       1.1   thorpej 	res->ar_niorange = 0;
    619       1.1   thorpej 
    620       1.1   thorpej 	SIMPLEQ_INIT(&res->ar_mem);
    621       1.1   thorpej 	res->ar_nmem = 0;
    622       1.1   thorpej 
    623       1.1   thorpej 	SIMPLEQ_INIT(&res->ar_memrange);
    624       1.1   thorpej 	res->ar_nmemrange = 0;
    625       1.1   thorpej 
    626       1.1   thorpej 	SIMPLEQ_INIT(&res->ar_irq);
    627       1.1   thorpej 	res->ar_nirq = 0;
    628       1.1   thorpej 
    629       1.1   thorpej 	SIMPLEQ_INIT(&res->ar_drq);
    630       1.1   thorpej 	res->ar_ndrq = 0;
    631       1.1   thorpej 
    632       1.1   thorpej 	*contextp = res;
    633       1.1   thorpej }
    634       1.1   thorpej 
    635       1.1   thorpej static void
    636       1.1   thorpej acpi_res_parse_fini(struct device *dev, void *context)
    637       1.1   thorpej {
    638       1.1   thorpej 	struct acpi_resources *res = context;
    639       1.1   thorpej 
    640       1.1   thorpej 	/* Print the resources we're using. */
    641       1.1   thorpej 	acpi_resource_print(dev, res);
    642       1.1   thorpej }
    643       1.1   thorpej 
    644       1.1   thorpej static void
    645       1.1   thorpej acpi_res_parse_ioport(struct device *dev, void *context, uint32_t base,
    646       1.1   thorpej     uint32_t length)
    647       1.1   thorpej {
    648       1.1   thorpej 	struct acpi_resources *res = context;
    649       1.1   thorpej 	struct acpi_io *ar;
    650       1.7  jdolecek 
    651       1.7  jdolecek 	/*
    652       1.7  jdolecek 	 * Check if there is another I/O port directly below/under
    653       1.7  jdolecek 	 * this one.
    654       1.7  jdolecek 	 */
    655       1.7  jdolecek 	SIMPLEQ_FOREACH(ar, &res->ar_io, ar_list) {
    656       1.7  jdolecek 		if (ar->ar_base == base + length ) {
    657       1.7  jdolecek 			/*
    658       1.7  jdolecek 			 * Entry just below existing entry - adjust
    659       1.7  jdolecek 			 * the entry and return.
    660       1.7  jdolecek 			 */
    661       1.7  jdolecek 			ar->ar_base = base;
    662       1.7  jdolecek 			ar->ar_length += length;
    663       1.7  jdolecek 			return;
    664       1.7  jdolecek 		} else if (ar->ar_base + ar->ar_length == base) {
    665       1.7  jdolecek 			/*
    666       1.7  jdolecek 			 * Entry just above existing entry - adjust
    667       1.7  jdolecek 			 * the entry and return.
    668       1.7  jdolecek 			 */
    669       1.7  jdolecek 			ar->ar_length += length;
    670       1.7  jdolecek 			return;
    671       1.7  jdolecek 		}
    672       1.7  jdolecek 	}
    673       1.1   thorpej 
    674       1.1   thorpej 	ar = AcpiOsAllocate(sizeof(*ar));
    675       1.1   thorpej 	if (ar == NULL) {
    676       1.1   thorpej 		printf("%s: ACPI: unable to allocate I/O resource %d\n",
    677       1.1   thorpej 		    dev->dv_xname, res->ar_nio);
    678       1.1   thorpej 		res->ar_nio++;
    679       1.1   thorpej 		return;
    680       1.1   thorpej 	}
    681       1.1   thorpej 
    682       1.1   thorpej 	ar->ar_index = res->ar_nio++;
    683       1.1   thorpej 	ar->ar_base = base;
    684       1.1   thorpej 	ar->ar_length = length;
    685       1.1   thorpej 
    686       1.1   thorpej 	SIMPLEQ_INSERT_TAIL(&res->ar_io, ar, ar_list);
    687       1.1   thorpej }
    688       1.1   thorpej 
    689       1.1   thorpej static void
    690       1.1   thorpej acpi_res_parse_iorange(struct device *dev, void *context, uint32_t low,
    691       1.1   thorpej     uint32_t high, uint32_t length, uint32_t align)
    692       1.1   thorpej {
    693       1.1   thorpej 	struct acpi_resources *res = context;
    694       1.1   thorpej 	struct acpi_iorange *ar;
    695       1.1   thorpej 
    696       1.1   thorpej 	ar = AcpiOsAllocate(sizeof(*ar));
    697       1.1   thorpej 	if (ar == NULL) {
    698       1.1   thorpej 		printf("%s: ACPI: unable to allocate I/O range resource %d\n",
    699       1.1   thorpej 		    dev->dv_xname, res->ar_niorange);
    700       1.1   thorpej 		res->ar_niorange++;
    701       1.1   thorpej 		return;
    702       1.1   thorpej 	}
    703       1.1   thorpej 
    704       1.1   thorpej 	ar->ar_index = res->ar_niorange++;
    705       1.1   thorpej 	ar->ar_low = low;
    706       1.1   thorpej 	ar->ar_high = high;
    707       1.1   thorpej 	ar->ar_length = length;
    708       1.1   thorpej 	ar->ar_align = align;
    709       1.1   thorpej 
    710       1.1   thorpej 	SIMPLEQ_INSERT_TAIL(&res->ar_iorange, ar, ar_list);
    711       1.1   thorpej }
    712       1.1   thorpej 
    713       1.1   thorpej static void
    714       1.1   thorpej acpi_res_parse_memory(struct device *dev, void *context, uint32_t base,
    715       1.1   thorpej     uint32_t length)
    716       1.1   thorpej {
    717       1.1   thorpej 	struct acpi_resources *res = context;
    718       1.1   thorpej 	struct acpi_mem *ar;
    719       1.1   thorpej 
    720       1.1   thorpej 	ar = AcpiOsAllocate(sizeof(*ar));
    721       1.1   thorpej 	if (ar == NULL) {
    722       1.1   thorpej 		printf("%s: ACPI: unable to allocate Memory resource %d\n",
    723       1.1   thorpej 		    dev->dv_xname, res->ar_nmem);
    724       1.1   thorpej 		res->ar_nmem++;
    725       1.1   thorpej 		return;
    726       1.1   thorpej 	}
    727       1.1   thorpej 
    728       1.1   thorpej 	ar->ar_index = res->ar_nmem++;
    729       1.1   thorpej 	ar->ar_base = base;
    730       1.1   thorpej 	ar->ar_length = length;
    731       1.1   thorpej 
    732       1.1   thorpej 	SIMPLEQ_INSERT_TAIL(&res->ar_mem, ar, ar_list);
    733       1.1   thorpej }
    734       1.1   thorpej 
    735       1.1   thorpej static void
    736       1.1   thorpej acpi_res_parse_memrange(struct device *dev, void *context, uint32_t low,
    737       1.1   thorpej     uint32_t high, uint32_t length, uint32_t align)
    738       1.1   thorpej {
    739       1.1   thorpej 	struct acpi_resources *res = context;
    740       1.1   thorpej 	struct acpi_memrange *ar;
    741       1.1   thorpej 
    742       1.1   thorpej 	ar = AcpiOsAllocate(sizeof(*ar));
    743       1.1   thorpej 	if (ar == NULL) {
    744       1.1   thorpej 		printf("%s: ACPI: unable to allocate Memory range resource "
    745       1.1   thorpej 		    "%d\n", dev->dv_xname, res->ar_nmemrange);
    746       1.1   thorpej 		res->ar_nmemrange++;
    747       1.1   thorpej 		return;
    748       1.1   thorpej 	}
    749       1.1   thorpej 
    750       1.1   thorpej 	ar->ar_index = res->ar_nmemrange++;
    751       1.1   thorpej 	ar->ar_low = low;
    752       1.1   thorpej 	ar->ar_high = high;
    753       1.1   thorpej 	ar->ar_length = length;
    754       1.1   thorpej 	ar->ar_align = align;
    755       1.1   thorpej 
    756       1.1   thorpej 	SIMPLEQ_INSERT_TAIL(&res->ar_memrange, ar, ar_list);
    757       1.1   thorpej }
    758       1.1   thorpej 
    759       1.1   thorpej static void
    760       1.5      matt acpi_res_parse_irq(struct device *dev, void *context, uint32_t irq, uint32_t type)
    761       1.1   thorpej {
    762       1.1   thorpej 	struct acpi_resources *res = context;
    763       1.1   thorpej 	struct acpi_irq *ar;
    764       1.1   thorpej 
    765       1.1   thorpej 	ar = AcpiOsAllocate(sizeof(*ar));
    766       1.1   thorpej 	if (ar == NULL) {
    767       1.1   thorpej 		printf("%s: ACPI: unable to allocate IRQ resource %d\n",
    768       1.1   thorpej 		    dev->dv_xname, res->ar_nirq);
    769       1.1   thorpej 		res->ar_nirq++;
    770       1.1   thorpej 		return;
    771       1.1   thorpej 	}
    772       1.1   thorpej 
    773       1.1   thorpej 	ar->ar_index = res->ar_nirq++;
    774       1.1   thorpej 	ar->ar_irq = irq;
    775       1.5      matt 	ar->ar_type = type;
    776       1.1   thorpej 
    777       1.1   thorpej 	SIMPLEQ_INSERT_TAIL(&res->ar_irq, ar, ar_list);
    778       1.1   thorpej }
    779       1.1   thorpej 
    780       1.1   thorpej static void
    781       1.1   thorpej acpi_res_parse_drq(struct device *dev, void *context, uint32_t drq)
    782       1.1   thorpej {
    783       1.1   thorpej 	struct acpi_resources *res = context;
    784       1.1   thorpej 	struct acpi_drq *ar;
    785       1.1   thorpej 
    786       1.1   thorpej 	ar = AcpiOsAllocate(sizeof(*ar));
    787       1.1   thorpej 	if (ar == NULL) {
    788       1.1   thorpej 		printf("%s: ACPI: unable to allocate DRQ resource %d\n",
    789       1.1   thorpej 		    dev->dv_xname, res->ar_ndrq);
    790       1.1   thorpej 		res->ar_ndrq++;
    791       1.1   thorpej 		return;
    792       1.1   thorpej 	}
    793       1.1   thorpej 
    794       1.1   thorpej 	ar->ar_index = res->ar_ndrq++;
    795       1.1   thorpej 	ar->ar_drq = drq;
    796       1.1   thorpej 
    797       1.1   thorpej 	SIMPLEQ_INSERT_TAIL(&res->ar_drq, ar, ar_list);
    798       1.1   thorpej }
    799       1.1   thorpej 
    800       1.1   thorpej static void
    801      1.21  christos acpi_res_parse_start_dep(struct device *dev, void *context,
    802      1.21  christos     int preference)
    803       1.1   thorpej {
    804      1.10     kochi 
    805       1.1   thorpej 	printf("%s: ACPI: dependant functions not supported\n",
    806       1.1   thorpej 	    dev->dv_xname);
    807       1.1   thorpej }
    808       1.1   thorpej 
    809       1.1   thorpej static void
    810      1.21  christos acpi_res_parse_end_dep(struct device *dev, void *context)
    811       1.1   thorpej {
    812       1.1   thorpej 
    813       1.1   thorpej 	/* Nothing to do. */
    814       1.1   thorpej }
    815