Home | History | Annotate | Line # | Download | only in acpi
acpi_resource.c revision 1.26.4.4
      1  1.26.4.4      yamt /*	$NetBSD: acpi_resource.c,v 1.26.4.4 2010/03/11 15:03:22 yamt 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.26.4.4      yamt __KERNEL_RCSID(0, "$NetBSD: acpi_resource.c,v 1.26.4.4 2010/03/11 15:03:22 yamt Exp $");
     71       1.1   thorpej 
     72       1.1   thorpej #include <sys/param.h>
     73       1.1   thorpej #include <sys/device.h>
     74  1.26.4.4      yamt #include <sys/systm.h>
     75       1.1   thorpej 
     76       1.1   thorpej #include <dev/acpi/acpireg.h>
     77       1.1   thorpej #include <dev/acpi/acpivar.h>
     78       1.1   thorpej 
     79       1.4   thorpej #define	_COMPONENT	ACPI_RESOURCE_COMPONENT
     80       1.4   thorpej ACPI_MODULE_NAME("RESOURCE")
     81       1.1   thorpej 
     82      1.13     kochi static ACPI_STATUS acpi_resource_parse_callback(ACPI_RESOURCE *, void *);
     83      1.13     kochi 
     84      1.12     kochi struct resource_parse_callback_arg {
     85      1.12     kochi 	const struct acpi_resource_parse_ops *ops;
     86  1.26.4.2      yamt 	device_t dev;
     87      1.12     kochi 	void *context;
     88      1.12     kochi };
     89      1.12     kochi 
     90      1.12     kochi static ACPI_STATUS
     91      1.12     kochi acpi_resource_parse_callback(ACPI_RESOURCE *res, void *context)
     92       1.1   thorpej {
     93      1.12     kochi 	struct resource_parse_callback_arg *arg = context;
     94      1.12     kochi 	const struct acpi_resource_parse_ops *ops;
     95       1.1   thorpej 	int i;
     96       1.1   thorpej 
     97      1.24     perry 	ACPI_FUNCTION_TRACE(__func__);
     98      1.15     kochi 
     99      1.12     kochi 	ops = arg->ops;
    100       1.1   thorpej 
    101      1.19     kochi 	switch (res->Type) {
    102      1.19     kochi 	case ACPI_RESOURCE_TYPE_FIXED_IO:
    103      1.12     kochi 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    104  1.26.4.4      yamt 				     "FixedIo 0x%x/%u\n",
    105      1.19     kochi 				     res->Data.FixedIo.Address,
    106      1.19     kochi 				     res->Data.FixedIo.AddressLength));
    107      1.13     kochi 		if (ops->ioport)
    108      1.13     kochi 			(*ops->ioport)(arg->dev, arg->context,
    109      1.19     kochi 			    res->Data.FixedIo.Address,
    110      1.19     kochi 			    res->Data.FixedIo.AddressLength);
    111      1.12     kochi 		break;
    112       1.1   thorpej 
    113      1.19     kochi 	case ACPI_RESOURCE_TYPE_IO:
    114      1.19     kochi 		if (res->Data.Io.Minimum ==
    115      1.22     njoly 		    res->Data.Io.Maximum) {
    116       1.1   thorpej 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    117  1.26.4.4      yamt 					     "Io 0x%x/%u\n",
    118      1.19     kochi 					     res->Data.Io.Minimum,
    119      1.19     kochi 					     res->Data.Io.AddressLength));
    120      1.13     kochi 			if (ops->ioport)
    121      1.13     kochi 				(*ops->ioport)(arg->dev, arg->context,
    122      1.19     kochi 				    res->Data.Io.Minimum,
    123      1.19     kochi 				    res->Data.Io.AddressLength);
    124      1.12     kochi 		} else {
    125       1.1   thorpej 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    126  1.26.4.4      yamt 					     "Io 0x%x-0x%x/%u\n",
    127      1.19     kochi 					     res->Data.Io.Minimum,
    128      1.19     kochi 					     res->Data.Io.Maximum,
    129      1.19     kochi 					     res->Data.Io.AddressLength));
    130      1.22     njoly 			if (ops->iorange)
    131      1.13     kochi 				(*ops->iorange)(arg->dev, arg->context,
    132      1.19     kochi 				    res->Data.Io.Minimum,
    133      1.19     kochi 				    res->Data.Io.Maximum,
    134      1.19     kochi 				    res->Data.Io.AddressLength,
    135      1.13     kochi 				    res->Data.Io.Alignment);
    136      1.12     kochi 		}
    137      1.12     kochi 		break;
    138       1.1   thorpej 
    139      1.19     kochi 	case ACPI_RESOURCE_TYPE_FIXED_MEMORY32:
    140      1.12     kochi 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    141  1.26.4.4      yamt 				     "FixedMemory32 0x%x/%u\n",
    142      1.19     kochi 				     res->Data.FixedMemory32.Address,
    143      1.19     kochi 				     res->Data.FixedMemory32.AddressLength));
    144      1.13     kochi 		if (ops->memory)
    145      1.13     kochi 			(*ops->memory)(arg->dev, arg->context,
    146      1.19     kochi 			    res->Data.FixedMemory32.Address,
    147      1.19     kochi 			    res->Data.FixedMemory32.AddressLength);
    148      1.12     kochi 		break;
    149      1.12     kochi 
    150      1.19     kochi 	case ACPI_RESOURCE_TYPE_MEMORY32:
    151      1.19     kochi 		if (res->Data.Memory32.Minimum ==
    152      1.19     kochi 		    res->Data.Memory32.Maximum) {
    153       1.1   thorpej 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    154  1.26.4.4      yamt 					     "Memory32 0x%x/%u\n",
    155      1.19     kochi 					     res->Data.Memory32.Minimum,
    156      1.19     kochi 					     res->Data.Memory32.AddressLength));
    157      1.13     kochi 			if (ops->memory)
    158      1.13     kochi 				(*ops->memory)(arg->dev, arg->context,
    159      1.19     kochi 				    res->Data.Memory32.Minimum,
    160      1.19     kochi 				    res->Data.Memory32.AddressLength);
    161      1.12     kochi 		} else {
    162       1.1   thorpej 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    163  1.26.4.4      yamt 					     "Memory32 0x%x-0x%x/%u\n",
    164      1.19     kochi 					     res->Data.Memory32.Minimum,
    165      1.19     kochi 					     res->Data.Memory32.Maximum,
    166      1.19     kochi 					     res->Data.Memory32.AddressLength));
    167      1.13     kochi 			if (ops->memrange)
    168      1.13     kochi 				(*ops->memrange)(arg->dev, arg->context,
    169      1.19     kochi 				    res->Data.Memory32.Minimum,
    170      1.19     kochi 				    res->Data.Memory32.Maximum,
    171      1.19     kochi 				    res->Data.Memory32.AddressLength,
    172      1.13     kochi 				    res->Data.Memory32.Alignment);
    173      1.12     kochi 		}
    174      1.12     kochi 		break;
    175       1.1   thorpej 
    176      1.19     kochi 	case ACPI_RESOURCE_TYPE_MEMORY24:
    177      1.19     kochi 		if (res->Data.Memory24.Minimum ==
    178      1.19     kochi 		    res->Data.Memory24.Maximum) {
    179       1.1   thorpej 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    180  1.26.4.4      yamt 					     "Memory24 0x%x/%u\n",
    181      1.19     kochi 					     res->Data.Memory24.Minimum,
    182      1.19     kochi 					     res->Data.Memory24.AddressLength));
    183      1.13     kochi 			if (ops->memory)
    184      1.13     kochi 				(*ops->memory)(arg->dev, arg->context,
    185      1.19     kochi 				    res->Data.Memory24.Minimum,
    186      1.19     kochi 				    res->Data.Memory24.AddressLength);
    187      1.12     kochi 		} else {
    188       1.1   thorpej 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    189  1.26.4.4      yamt 					     "Memory24 0x%x-0x%x/%u\n",
    190      1.19     kochi 					     res->Data.Memory24.Minimum,
    191      1.19     kochi 					     res->Data.Memory24.Maximum,
    192      1.19     kochi 					     res->Data.Memory24.AddressLength));
    193      1.13     kochi 			if (ops->memrange)
    194      1.13     kochi 				(*ops->memrange)(arg->dev, arg->context,
    195      1.19     kochi 				    res->Data.Memory24.Minimum,
    196      1.19     kochi 				    res->Data.Memory24.Maximum,
    197      1.19     kochi 				    res->Data.Memory24.AddressLength,
    198      1.13     kochi 				    res->Data.Memory24.Alignment);
    199      1.12     kochi 		}
    200      1.12     kochi 		break;
    201       1.1   thorpej 
    202      1.19     kochi 	case ACPI_RESOURCE_TYPE_IRQ:
    203      1.19     kochi 		for (i = 0; i < res->Data.Irq.InterruptCount; i++) {
    204       1.1   thorpej 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    205  1.26.4.4      yamt 					     "IRQ %u\n",
    206      1.12     kochi 					     res->Data.Irq.Interrupts[i]));
    207      1.13     kochi 			if (ops->irq)
    208      1.13     kochi 				(*ops->irq)(arg->dev, arg->context,
    209      1.13     kochi 				    res->Data.Irq.Interrupts[i],
    210      1.19     kochi 				    res->Data.Irq.Triggering);
    211      1.12     kochi 		}
    212      1.12     kochi 		break;
    213       1.1   thorpej 
    214      1.19     kochi 	case ACPI_RESOURCE_TYPE_DMA:
    215      1.19     kochi 		for (i = 0; i < res->Data.Dma.ChannelCount; i++) {
    216       1.1   thorpej 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    217  1.26.4.4      yamt 					     "DRQ %u\n",
    218      1.12     kochi 					     res->Data.Dma.Channels[i]));
    219      1.13     kochi 			if (ops->drq)
    220      1.13     kochi 				(*ops->drq)(arg->dev, arg->context,
    221      1.13     kochi 				    res->Data.Dma.Channels[i]);
    222       1.1   thorpej 		}
    223      1.12     kochi 		break;
    224      1.12     kochi 
    225      1.19     kochi 	case ACPI_RESOURCE_TYPE_START_DEPENDENT:
    226      1.12     kochi 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    227  1.26.4.4      yamt 				     "Start dependant functions: %u\n",
    228      1.12     kochi 				     res->Data.StartDpf.CompatibilityPriority));
    229      1.13     kochi 		if (ops->start_dep)
    230      1.13     kochi 			(*ops->start_dep)(arg->dev, arg->context,
    231      1.13     kochi 			    res->Data.StartDpf.CompatibilityPriority);
    232      1.12     kochi 		break;
    233      1.12     kochi 
    234      1.19     kochi 	case ACPI_RESOURCE_TYPE_END_DEPENDENT:
    235      1.12     kochi 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    236      1.12     kochi 				     "End dependant functions\n"));
    237      1.13     kochi 		if (ops->end_dep)
    238      1.13     kochi 			(*ops->end_dep)(arg->dev, arg->context);
    239      1.22     njoly 		break;
    240      1.12     kochi 
    241      1.19     kochi 	case ACPI_RESOURCE_TYPE_ADDRESS32:
    242      1.22     njoly 		/* XXX Only fixed size supported for now */
    243      1.22     njoly 		if (res->Data.Address32.AddressLength == 0 ||
    244      1.22     njoly 		    res->Data.Address32.ProducerConsumer != ACPI_CONSUMER)
    245      1.22     njoly 			break;
    246      1.22     njoly #define ADRRESS32_FIXED2(r)						\
    247      1.22     njoly 	((r)->Data.Address32.MinAddressFixed == ACPI_ADDRESS_FIXED &&	\
    248      1.22     njoly 	 (r)->Data.Address32.MaxAddressFixed == ACPI_ADDRESS_FIXED)
    249      1.22     njoly 		switch (res->Data.Address32.ResourceType) {
    250      1.22     njoly 		case ACPI_MEMORY_RANGE:
    251      1.22     njoly 			if (ADRRESS32_FIXED2(res)) {
    252      1.22     njoly 				if (ops->memory)
    253      1.22     njoly 					(*ops->memory)(arg->dev, arg->context,
    254      1.22     njoly 					    res->Data.Address32.Minimum,
    255      1.22     njoly 					    res->Data.Address32.AddressLength);
    256      1.22     njoly 			} else {
    257      1.22     njoly 				if (ops->memrange)
    258      1.22     njoly 					(*ops->memrange)(arg->dev, arg->context,
    259      1.22     njoly 					    res->Data.Address32.Minimum,
    260      1.22     njoly 					    res->Data.Address32.Maximum,
    261      1.22     njoly 					    res->Data.Address32.AddressLength,
    262      1.22     njoly 					    res->Data.Address32.Granularity);
    263      1.22     njoly 			}
    264      1.22     njoly 			break;
    265      1.22     njoly 		case ACPI_IO_RANGE:
    266      1.22     njoly 			if (ADRRESS32_FIXED2(res)) {
    267      1.22     njoly 				if (ops->ioport)
    268      1.22     njoly 					(*ops->ioport)(arg->dev, arg->context,
    269      1.22     njoly 					    res->Data.Address32.Minimum,
    270      1.22     njoly 					    res->Data.Address32.AddressLength);
    271      1.22     njoly 			} else {
    272      1.22     njoly 				if (ops->iorange)
    273      1.22     njoly 					(*ops->iorange)(arg->dev, arg->context,
    274      1.22     njoly 					    res->Data.Address32.Minimum,
    275      1.22     njoly 					    res->Data.Address32.Maximum,
    276      1.22     njoly 					    res->Data.Address32.AddressLength,
    277      1.22     njoly 					    res->Data.Address32.Granularity);
    278      1.22     njoly 			}
    279      1.22     njoly 			break;
    280      1.22     njoly 		case ACPI_BUS_NUMBER_RANGE:
    281      1.22     njoly 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    282      1.22     njoly 				      "Address32/BusNumber unimplemented\n"));
    283      1.22     njoly 			break;
    284      1.22     njoly 		}
    285      1.22     njoly #undef ADRRESS32_FIXED2
    286      1.12     kochi 		break;
    287      1.12     kochi 
    288      1.19     kochi 	case ACPI_RESOURCE_TYPE_ADDRESS16:
    289      1.12     kochi 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    290      1.12     kochi 				     "Address16 unimplemented\n"));
    291      1.12     kochi 		break;
    292      1.12     kochi 
    293      1.19     kochi 	case ACPI_RESOURCE_TYPE_EXTENDED_ADDRESS64:
    294      1.19     kochi 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    295      1.19     kochi 				     "Extended address64 unimplemented\n"));
    296      1.19     kochi 		break;
    297      1.19     kochi 
    298      1.19     kochi 	case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
    299  1.26.4.3      yamt 		if (res->Data.ExtendedIrq.ProducerConsumer != ACPI_CONSUMER) {
    300  1.26.4.3      yamt 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    301  1.26.4.3      yamt 			    "ignored ExtIRQ producer\n"));
    302  1.26.4.3      yamt 			break;
    303  1.26.4.3      yamt 		}
    304  1.26.4.3      yamt 		for (i = 0; i < res->Data.ExtendedIrq.InterruptCount; i++) {
    305  1.26.4.3      yamt 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    306  1.26.4.4      yamt 				     "ExtIRQ %u\n",
    307  1.26.4.3      yamt 				     res->Data.ExtendedIrq.Interrupts[i]));
    308  1.26.4.3      yamt 			if (ops->irq)
    309  1.26.4.3      yamt 				(*ops->irq)(arg->dev, arg->context,
    310  1.26.4.3      yamt 				    res->Data.ExtendedIrq.Interrupts[i],
    311  1.26.4.3      yamt 				    res->Data.ExtendedIrq.Triggering);
    312  1.26.4.3      yamt 		}
    313      1.19     kochi 		break;
    314      1.19     kochi 
    315      1.19     kochi 	case ACPI_RESOURCE_TYPE_GENERIC_REGISTER:
    316      1.12     kochi 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    317      1.22     njoly 				     "GenericRegister unimplemented\n"));
    318      1.12     kochi 		break;
    319      1.12     kochi 
    320      1.19     kochi 	case ACPI_RESOURCE_TYPE_VENDOR:
    321      1.12     kochi 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    322      1.12     kochi 				     "VendorSpecific unimplemented\n"));
    323      1.12     kochi 		break;
    324      1.12     kochi 
    325      1.12     kochi 	default:
    326      1.12     kochi 		ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    327  1.26.4.4      yamt 				     "Unknown resource type: %u\n", res->Type));
    328      1.12     kochi 		break;
    329      1.12     kochi 	}
    330      1.12     kochi 
    331      1.15     kochi 	return_ACPI_STATUS(AE_OK);
    332      1.12     kochi }
    333      1.12     kochi 
    334      1.12     kochi 
    335      1.12     kochi /*
    336      1.12     kochi  * acpi_resource_parse:
    337      1.12     kochi  *
    338      1.12     kochi  *	Parse a device node's resources and fill them in for the
    339      1.12     kochi  *	client.
    340      1.12     kochi  *
    341      1.12     kochi  *	This API supports _CRS (current resources) and
    342      1.12     kochi  *	_PRS (possible resources).
    343      1.12     kochi  *
    344      1.12     kochi  *	Note that it might be nice to also locate ACPI-specific resource
    345      1.12     kochi  *	items, such as GPE bits.
    346      1.12     kochi  */
    347      1.12     kochi ACPI_STATUS
    348  1.26.4.2      yamt acpi_resource_parse(device_t dev, ACPI_HANDLE handle, const char *path,
    349      1.12     kochi     void *arg, const struct acpi_resource_parse_ops *ops)
    350      1.12     kochi {
    351      1.12     kochi 	struct resource_parse_callback_arg cbarg;
    352      1.12     kochi 	ACPI_STATUS rv;
    353      1.12     kochi 
    354      1.24     perry 	ACPI_FUNCTION_TRACE(__func__);
    355      1.12     kochi 
    356      1.13     kochi 	if (ops->init)
    357      1.13     kochi 		(*ops->init)(dev, arg, &cbarg.context);
    358      1.13     kochi 	else
    359      1.13     kochi 		cbarg.context = arg;
    360      1.12     kochi 	cbarg.ops = ops;
    361      1.12     kochi 	cbarg.dev = dev;
    362      1.12     kochi 
    363      1.17  christos 	rv = AcpiWalkResources(handle, path, acpi_resource_parse_callback,
    364      1.12     kochi 	    &cbarg);
    365      1.12     kochi 	if (ACPI_FAILURE(rv)) {
    366      1.23  jmcneill 		aprint_error_dev(dev, "ACPI: unable to get %s resources: %s\n",
    367      1.23  jmcneill 		    path, AcpiFormatException(rv));
    368      1.12     kochi 		return_ACPI_STATUS(rv);
    369       1.1   thorpej 	}
    370       1.1   thorpej 
    371      1.13     kochi 	if (ops->fini)
    372      1.13     kochi 		(*ops->fini)(dev, cbarg.context);
    373       1.1   thorpej 
    374       1.1   thorpej 	return_ACPI_STATUS(AE_OK);
    375       1.1   thorpej }
    376       1.1   thorpej 
    377       1.1   thorpej /*
    378       1.1   thorpej  * acpi_resource_print:
    379       1.1   thorpej  *
    380       1.1   thorpej  *	Print the resources assigned to a device.
    381       1.1   thorpej  */
    382       1.1   thorpej void
    383  1.26.4.2      yamt acpi_resource_print(device_t dev, struct acpi_resources *res)
    384       1.1   thorpej {
    385       1.1   thorpej 	const char *sep;
    386       1.1   thorpej 
    387       1.1   thorpej 	if (SIMPLEQ_EMPTY(&res->ar_io) &&
    388       1.1   thorpej 	    SIMPLEQ_EMPTY(&res->ar_iorange) &&
    389       1.1   thorpej 	    SIMPLEQ_EMPTY(&res->ar_mem) &&
    390       1.1   thorpej 	    SIMPLEQ_EMPTY(&res->ar_memrange) &&
    391       1.1   thorpej 	    SIMPLEQ_EMPTY(&res->ar_irq) &&
    392       1.1   thorpej 	    SIMPLEQ_EMPTY(&res->ar_drq))
    393       1.1   thorpej 		return;
    394       1.1   thorpej 
    395  1.26.4.1      yamt 	aprint_normal(":");
    396       1.1   thorpej 
    397       1.1   thorpej 	if (SIMPLEQ_EMPTY(&res->ar_io) == 0) {
    398       1.1   thorpej 		struct acpi_io *ar;
    399       1.1   thorpej 
    400       1.1   thorpej 		sep = "";
    401      1.23  jmcneill 		aprint_normal(" io ");
    402       1.3     lukem 		SIMPLEQ_FOREACH(ar, &res->ar_io, ar_list) {
    403      1.23  jmcneill 			aprint_normal("%s0x%x", sep, ar->ar_base);
    404       1.1   thorpej 			if (ar->ar_length > 1)
    405      1.23  jmcneill 				aprint_normal("-0x%x", ar->ar_base +
    406       1.1   thorpej 				    ar->ar_length - 1);
    407       1.1   thorpej 			sep = ",";
    408       1.1   thorpej 		}
    409       1.1   thorpej 	}
    410       1.1   thorpej 
    411       1.1   thorpej 	/* XXX iorange */
    412       1.1   thorpej 
    413       1.1   thorpej 	if (SIMPLEQ_EMPTY(&res->ar_mem) == 0) {
    414       1.1   thorpej 		struct acpi_mem *ar;
    415       1.1   thorpej 
    416       1.1   thorpej 		sep = "";
    417      1.23  jmcneill 		aprint_normal(" mem ");
    418       1.3     lukem 		SIMPLEQ_FOREACH(ar, &res->ar_mem, ar_list) {
    419      1.23  jmcneill 			aprint_normal("%s0x%x", sep, ar->ar_base);
    420       1.1   thorpej 			if (ar->ar_length > 1)
    421      1.23  jmcneill 				aprint_normal("-0x%x", ar->ar_base +
    422       1.1   thorpej 				    ar->ar_length - 1);
    423       1.1   thorpej 			sep = ",";
    424       1.1   thorpej 		}
    425       1.1   thorpej 	}
    426       1.1   thorpej 
    427       1.1   thorpej 	/* XXX memrange */
    428       1.1   thorpej 
    429       1.1   thorpej 	if (SIMPLEQ_EMPTY(&res->ar_irq) == 0) {
    430       1.1   thorpej 		struct acpi_irq *ar;
    431       1.1   thorpej 
    432       1.1   thorpej 		sep = "";
    433      1.23  jmcneill 		aprint_normal(" irq ");
    434       1.3     lukem 		SIMPLEQ_FOREACH(ar, &res->ar_irq, ar_list) {
    435      1.23  jmcneill 			aprint_normal("%s%d", sep, ar->ar_irq);
    436       1.1   thorpej 			sep = ",";
    437       1.1   thorpej 		}
    438       1.1   thorpej 	}
    439       1.1   thorpej 
    440       1.1   thorpej 	if (SIMPLEQ_EMPTY(&res->ar_drq) == 0) {
    441       1.1   thorpej 		struct acpi_drq *ar;
    442       1.1   thorpej 
    443       1.1   thorpej 		sep = "";
    444      1.23  jmcneill 		aprint_normal(" drq ");
    445       1.3     lukem 		SIMPLEQ_FOREACH(ar, &res->ar_drq, ar_list) {
    446      1.23  jmcneill 			aprint_normal("%s%d", sep, ar->ar_drq);
    447       1.1   thorpej 			sep = ",";
    448       1.1   thorpej 		}
    449       1.1   thorpej 	}
    450       1.1   thorpej 
    451      1.23  jmcneill 	aprint_normal("\n");
    452  1.26.4.1      yamt 	aprint_naive("\n");
    453       1.1   thorpej }
    454       1.1   thorpej 
    455      1.14     kochi /*
    456      1.14     kochi  * acpi_resource_cleanup:
    457      1.14     kochi  *
    458      1.14     kochi  *	Free all allocated buffers
    459      1.14     kochi  */
    460      1.14     kochi void
    461      1.14     kochi acpi_resource_cleanup(struct acpi_resources *res)
    462      1.14     kochi {
    463      1.14     kochi 	while (!SIMPLEQ_EMPTY(&res->ar_io)) {
    464      1.14     kochi 		struct acpi_io *ar;
    465      1.14     kochi 		ar = SIMPLEQ_FIRST(&res->ar_io);
    466      1.14     kochi 		SIMPLEQ_REMOVE_HEAD(&res->ar_io, ar_list);
    467  1.26.4.4      yamt 		ACPI_FREE(ar);
    468      1.14     kochi 	}
    469      1.14     kochi 
    470      1.14     kochi 	while (!SIMPLEQ_EMPTY(&res->ar_iorange)) {
    471      1.14     kochi 		struct acpi_iorange *ar;
    472      1.14     kochi 		ar = SIMPLEQ_FIRST(&res->ar_iorange);
    473      1.14     kochi 		SIMPLEQ_REMOVE_HEAD(&res->ar_iorange, ar_list);
    474  1.26.4.4      yamt 		ACPI_FREE(ar);
    475      1.14     kochi 	}
    476      1.14     kochi 
    477      1.14     kochi 	while (!SIMPLEQ_EMPTY(&res->ar_mem)) {
    478      1.14     kochi 		struct acpi_mem *ar;
    479      1.14     kochi 		ar = SIMPLEQ_FIRST(&res->ar_mem);
    480      1.14     kochi 		SIMPLEQ_REMOVE_HEAD(&res->ar_mem, ar_list);
    481  1.26.4.4      yamt 		ACPI_FREE(ar);
    482      1.14     kochi 	}
    483      1.14     kochi 
    484      1.14     kochi 	while (!SIMPLEQ_EMPTY(&res->ar_memrange)) {
    485      1.14     kochi 		struct acpi_memrange *ar;
    486      1.14     kochi 		ar = SIMPLEQ_FIRST(&res->ar_memrange);
    487      1.14     kochi 		SIMPLEQ_REMOVE_HEAD(&res->ar_memrange, ar_list);
    488  1.26.4.4      yamt 		ACPI_FREE(ar);
    489      1.14     kochi 	}
    490      1.14     kochi 
    491      1.14     kochi 	while (!SIMPLEQ_EMPTY(&res->ar_irq)) {
    492      1.14     kochi 		struct acpi_irq *ar;
    493      1.14     kochi 		ar = SIMPLEQ_FIRST(&res->ar_irq);
    494      1.14     kochi 		SIMPLEQ_REMOVE_HEAD(&res->ar_irq, ar_list);
    495  1.26.4.4      yamt 		ACPI_FREE(ar);
    496      1.14     kochi 	}
    497      1.14     kochi 
    498      1.14     kochi 	while (!SIMPLEQ_EMPTY(&res->ar_drq)) {
    499      1.14     kochi 		struct acpi_drq *ar;
    500      1.14     kochi 		ar = SIMPLEQ_FIRST(&res->ar_drq);
    501      1.14     kochi 		SIMPLEQ_REMOVE_HEAD(&res->ar_drq, ar_list);
    502  1.26.4.4      yamt 		ACPI_FREE(ar);
    503      1.14     kochi 	}
    504      1.14     kochi 
    505      1.16     perry 	res->ar_nio = res->ar_niorange = res->ar_nmem =
    506      1.14     kochi 	    res->ar_nmemrange = res->ar_nirq = res->ar_ndrq = 0;
    507      1.14     kochi }
    508      1.14     kochi 
    509       1.1   thorpej struct acpi_io *
    510       1.1   thorpej acpi_res_io(struct acpi_resources *res, int idx)
    511       1.1   thorpej {
    512       1.1   thorpej 	struct acpi_io *ar;
    513       1.1   thorpej 
    514       1.1   thorpej 	SIMPLEQ_FOREACH(ar, &res->ar_io, 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_iorange *
    522       1.1   thorpej acpi_res_iorange(struct acpi_resources *res, int idx)
    523       1.1   thorpej {
    524       1.1   thorpej 	struct acpi_iorange *ar;
    525       1.1   thorpej 
    526       1.1   thorpej 	SIMPLEQ_FOREACH(ar, &res->ar_iorange, 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_mem *
    534       1.1   thorpej acpi_res_mem(struct acpi_resources *res, int idx)
    535       1.1   thorpej {
    536       1.1   thorpej 	struct acpi_mem *ar;
    537       1.1   thorpej 
    538       1.1   thorpej 	SIMPLEQ_FOREACH(ar, &res->ar_mem, 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_memrange *
    546       1.1   thorpej acpi_res_memrange(struct acpi_resources *res, int idx)
    547       1.1   thorpej {
    548       1.1   thorpej 	struct acpi_memrange *ar;
    549       1.1   thorpej 
    550       1.1   thorpej 	SIMPLEQ_FOREACH(ar, &res->ar_memrange, 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_irq *
    558       1.1   thorpej acpi_res_irq(struct acpi_resources *res, int idx)
    559       1.1   thorpej {
    560       1.1   thorpej 	struct acpi_irq *ar;
    561       1.1   thorpej 
    562       1.1   thorpej 	SIMPLEQ_FOREACH(ar, &res->ar_irq, 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 struct acpi_drq *
    570       1.1   thorpej acpi_res_drq(struct acpi_resources *res, int idx)
    571       1.1   thorpej {
    572       1.1   thorpej 	struct acpi_drq *ar;
    573       1.1   thorpej 
    574       1.1   thorpej 	SIMPLEQ_FOREACH(ar, &res->ar_drq, ar_list) {
    575       1.1   thorpej 		if (ar->ar_index == idx)
    576      1.11     kochi 			return ar;
    577       1.1   thorpej 	}
    578      1.11     kochi 	return NULL;
    579       1.1   thorpej }
    580       1.1   thorpej 
    581       1.1   thorpej /*****************************************************************************
    582       1.1   thorpej  * Default ACPI resource parse operations.
    583       1.1   thorpej  *****************************************************************************/
    584       1.1   thorpej 
    585  1.26.4.2      yamt static void	acpi_res_parse_init(device_t, void *, void **);
    586  1.26.4.2      yamt static void	acpi_res_parse_fini(device_t, void *);
    587       1.1   thorpej 
    588  1.26.4.2      yamt static void	acpi_res_parse_ioport(device_t, void *, uint32_t,
    589       1.1   thorpej 		    uint32_t);
    590  1.26.4.2      yamt static void	acpi_res_parse_iorange(device_t, void *, uint32_t,
    591       1.1   thorpej 		    uint32_t, uint32_t, uint32_t);
    592       1.1   thorpej 
    593  1.26.4.2      yamt static void	acpi_res_parse_memory(device_t, void *, uint32_t,
    594       1.1   thorpej 		    uint32_t);
    595  1.26.4.2      yamt static void	acpi_res_parse_memrange(device_t, void *, uint32_t,
    596       1.1   thorpej 		    uint32_t, uint32_t, uint32_t);
    597       1.1   thorpej 
    598  1.26.4.2      yamt static void	acpi_res_parse_irq(device_t, void *, uint32_t, uint32_t);
    599  1.26.4.2      yamt static void	acpi_res_parse_drq(device_t, void *, uint32_t);
    600       1.1   thorpej 
    601  1.26.4.2      yamt static void	acpi_res_parse_start_dep(device_t, void *, int);
    602  1.26.4.2      yamt static void	acpi_res_parse_end_dep(device_t, void *);
    603       1.1   thorpej 
    604       1.1   thorpej const struct acpi_resource_parse_ops acpi_resource_parse_ops_default = {
    605      1.13     kochi 	.init = acpi_res_parse_init,
    606      1.13     kochi 	.fini = acpi_res_parse_fini,
    607       1.1   thorpej 
    608      1.13     kochi 	.ioport = acpi_res_parse_ioport,
    609      1.13     kochi 	.iorange = acpi_res_parse_iorange,
    610       1.1   thorpej 
    611      1.13     kochi 	.memory = acpi_res_parse_memory,
    612      1.13     kochi 	.memrange = acpi_res_parse_memrange,
    613       1.1   thorpej 
    614      1.13     kochi 	.irq = acpi_res_parse_irq,
    615      1.13     kochi 	.drq = acpi_res_parse_drq,
    616       1.1   thorpej 
    617      1.13     kochi 	.start_dep = acpi_res_parse_start_dep,
    618      1.13     kochi 	.end_dep = acpi_res_parse_end_dep,
    619       1.1   thorpej };
    620       1.1   thorpej 
    621       1.1   thorpej static void
    622  1.26.4.2      yamt acpi_res_parse_init(device_t dev, void *arg, void **contextp)
    623       1.1   thorpej {
    624       1.1   thorpej 	struct acpi_resources *res = arg;
    625       1.1   thorpej 
    626       1.1   thorpej 	SIMPLEQ_INIT(&res->ar_io);
    627       1.1   thorpej 	res->ar_nio = 0;
    628       1.1   thorpej 
    629       1.1   thorpej 	SIMPLEQ_INIT(&res->ar_iorange);
    630       1.1   thorpej 	res->ar_niorange = 0;
    631       1.1   thorpej 
    632       1.1   thorpej 	SIMPLEQ_INIT(&res->ar_mem);
    633       1.1   thorpej 	res->ar_nmem = 0;
    634       1.1   thorpej 
    635       1.1   thorpej 	SIMPLEQ_INIT(&res->ar_memrange);
    636       1.1   thorpej 	res->ar_nmemrange = 0;
    637       1.1   thorpej 
    638       1.1   thorpej 	SIMPLEQ_INIT(&res->ar_irq);
    639       1.1   thorpej 	res->ar_nirq = 0;
    640       1.1   thorpej 
    641       1.1   thorpej 	SIMPLEQ_INIT(&res->ar_drq);
    642       1.1   thorpej 	res->ar_ndrq = 0;
    643       1.1   thorpej 
    644       1.1   thorpej 	*contextp = res;
    645       1.1   thorpej }
    646       1.1   thorpej 
    647       1.1   thorpej static void
    648  1.26.4.2      yamt acpi_res_parse_fini(device_t dev, void *context)
    649       1.1   thorpej {
    650       1.1   thorpej 	struct acpi_resources *res = context;
    651       1.1   thorpej 
    652       1.1   thorpej 	/* Print the resources we're using. */
    653       1.1   thorpej 	acpi_resource_print(dev, res);
    654       1.1   thorpej }
    655       1.1   thorpej 
    656       1.1   thorpej static void
    657  1.26.4.2      yamt acpi_res_parse_ioport(device_t dev, void *context, uint32_t base,
    658       1.1   thorpej     uint32_t length)
    659       1.1   thorpej {
    660       1.1   thorpej 	struct acpi_resources *res = context;
    661       1.1   thorpej 	struct acpi_io *ar;
    662       1.7  jdolecek 
    663       1.7  jdolecek 	/*
    664       1.7  jdolecek 	 * Check if there is another I/O port directly below/under
    665       1.7  jdolecek 	 * this one.
    666       1.7  jdolecek 	 */
    667       1.7  jdolecek 	SIMPLEQ_FOREACH(ar, &res->ar_io, ar_list) {
    668       1.7  jdolecek 		if (ar->ar_base == base + length ) {
    669       1.7  jdolecek 			/*
    670       1.7  jdolecek 			 * Entry just below existing entry - adjust
    671       1.7  jdolecek 			 * the entry and return.
    672       1.7  jdolecek 			 */
    673       1.7  jdolecek 			ar->ar_base = base;
    674       1.7  jdolecek 			ar->ar_length += length;
    675       1.7  jdolecek 			return;
    676       1.7  jdolecek 		} else if (ar->ar_base + ar->ar_length == base) {
    677       1.7  jdolecek 			/*
    678       1.7  jdolecek 			 * Entry just above existing entry - adjust
    679       1.7  jdolecek 			 * the entry and return.
    680       1.7  jdolecek 			 */
    681       1.7  jdolecek 			ar->ar_length += length;
    682       1.7  jdolecek 			return;
    683       1.7  jdolecek 		}
    684       1.7  jdolecek 	}
    685       1.1   thorpej 
    686  1.26.4.4      yamt 	ar = ACPI_ALLOCATE(sizeof(*ar));
    687       1.1   thorpej 	if (ar == NULL) {
    688      1.23  jmcneill 		aprint_error_dev(dev, "ACPI: unable to allocate I/O resource %d\n",
    689      1.23  jmcneill 		    res->ar_nio);
    690       1.1   thorpej 		res->ar_nio++;
    691       1.1   thorpej 		return;
    692       1.1   thorpej 	}
    693       1.1   thorpej 
    694       1.1   thorpej 	ar->ar_index = res->ar_nio++;
    695       1.1   thorpej 	ar->ar_base = base;
    696       1.1   thorpej 	ar->ar_length = length;
    697       1.1   thorpej 
    698       1.1   thorpej 	SIMPLEQ_INSERT_TAIL(&res->ar_io, ar, ar_list);
    699       1.1   thorpej }
    700       1.1   thorpej 
    701       1.1   thorpej static void
    702  1.26.4.2      yamt acpi_res_parse_iorange(device_t dev, void *context, uint32_t low,
    703       1.1   thorpej     uint32_t high, uint32_t length, uint32_t align)
    704       1.1   thorpej {
    705       1.1   thorpej 	struct acpi_resources *res = context;
    706       1.1   thorpej 	struct acpi_iorange *ar;
    707       1.1   thorpej 
    708  1.26.4.4      yamt 	ar = ACPI_ALLOCATE(sizeof(*ar));
    709       1.1   thorpej 	if (ar == NULL) {
    710      1.23  jmcneill 		aprint_error_dev(dev, "ACPI: unable to allocate I/O range resource %d\n",
    711      1.23  jmcneill 		    res->ar_niorange);
    712       1.1   thorpej 		res->ar_niorange++;
    713       1.1   thorpej 		return;
    714       1.1   thorpej 	}
    715       1.1   thorpej 
    716       1.1   thorpej 	ar->ar_index = res->ar_niorange++;
    717       1.1   thorpej 	ar->ar_low = low;
    718       1.1   thorpej 	ar->ar_high = high;
    719       1.1   thorpej 	ar->ar_length = length;
    720       1.1   thorpej 	ar->ar_align = align;
    721       1.1   thorpej 
    722       1.1   thorpej 	SIMPLEQ_INSERT_TAIL(&res->ar_iorange, ar, ar_list);
    723       1.1   thorpej }
    724       1.1   thorpej 
    725       1.1   thorpej static void
    726  1.26.4.2      yamt acpi_res_parse_memory(device_t dev, void *context, uint32_t base,
    727       1.1   thorpej     uint32_t length)
    728       1.1   thorpej {
    729       1.1   thorpej 	struct acpi_resources *res = context;
    730       1.1   thorpej 	struct acpi_mem *ar;
    731       1.1   thorpej 
    732  1.26.4.4      yamt 	ar = ACPI_ALLOCATE(sizeof(*ar));
    733       1.1   thorpej 	if (ar == NULL) {
    734      1.23  jmcneill 		aprint_error_dev(dev, "ACPI: unable to allocate Memory resource %d\n",
    735      1.23  jmcneill 		    res->ar_nmem);
    736       1.1   thorpej 		res->ar_nmem++;
    737       1.1   thorpej 		return;
    738       1.1   thorpej 	}
    739       1.1   thorpej 
    740       1.1   thorpej 	ar->ar_index = res->ar_nmem++;
    741       1.1   thorpej 	ar->ar_base = base;
    742       1.1   thorpej 	ar->ar_length = length;
    743       1.1   thorpej 
    744       1.1   thorpej 	SIMPLEQ_INSERT_TAIL(&res->ar_mem, ar, ar_list);
    745       1.1   thorpej }
    746       1.1   thorpej 
    747       1.1   thorpej static void
    748  1.26.4.2      yamt acpi_res_parse_memrange(device_t dev, void *context, uint32_t low,
    749       1.1   thorpej     uint32_t high, uint32_t length, uint32_t align)
    750       1.1   thorpej {
    751       1.1   thorpej 	struct acpi_resources *res = context;
    752       1.1   thorpej 	struct acpi_memrange *ar;
    753       1.1   thorpej 
    754  1.26.4.4      yamt 	ar = ACPI_ALLOCATE(sizeof(*ar));
    755       1.1   thorpej 	if (ar == NULL) {
    756      1.23  jmcneill 		aprint_error_dev(dev, "ACPI: unable to allocate Memory range resource %d\n",
    757      1.23  jmcneill 		    res->ar_nmemrange);
    758       1.1   thorpej 		res->ar_nmemrange++;
    759       1.1   thorpej 		return;
    760       1.1   thorpej 	}
    761       1.1   thorpej 
    762       1.1   thorpej 	ar->ar_index = res->ar_nmemrange++;
    763       1.1   thorpej 	ar->ar_low = low;
    764       1.1   thorpej 	ar->ar_high = high;
    765       1.1   thorpej 	ar->ar_length = length;
    766       1.1   thorpej 	ar->ar_align = align;
    767       1.1   thorpej 
    768       1.1   thorpej 	SIMPLEQ_INSERT_TAIL(&res->ar_memrange, ar, ar_list);
    769       1.1   thorpej }
    770       1.1   thorpej 
    771       1.1   thorpej static void
    772  1.26.4.2      yamt acpi_res_parse_irq(device_t dev, void *context, uint32_t irq, uint32_t type)
    773       1.1   thorpej {
    774       1.1   thorpej 	struct acpi_resources *res = context;
    775       1.1   thorpej 	struct acpi_irq *ar;
    776       1.1   thorpej 
    777  1.26.4.4      yamt 	ar = ACPI_ALLOCATE(sizeof(*ar));
    778       1.1   thorpej 	if (ar == NULL) {
    779      1.23  jmcneill 		aprint_error_dev(dev, "ACPI: unable to allocate IRQ resource %d\n",
    780      1.23  jmcneill 		    res->ar_nirq);
    781       1.1   thorpej 		res->ar_nirq++;
    782       1.1   thorpej 		return;
    783       1.1   thorpej 	}
    784       1.1   thorpej 
    785       1.1   thorpej 	ar->ar_index = res->ar_nirq++;
    786       1.1   thorpej 	ar->ar_irq = irq;
    787       1.5      matt 	ar->ar_type = type;
    788       1.1   thorpej 
    789       1.1   thorpej 	SIMPLEQ_INSERT_TAIL(&res->ar_irq, ar, ar_list);
    790       1.1   thorpej }
    791       1.1   thorpej 
    792       1.1   thorpej static void
    793  1.26.4.2      yamt acpi_res_parse_drq(device_t dev, void *context, uint32_t drq)
    794       1.1   thorpej {
    795       1.1   thorpej 	struct acpi_resources *res = context;
    796       1.1   thorpej 	struct acpi_drq *ar;
    797       1.1   thorpej 
    798  1.26.4.4      yamt 	ar = ACPI_ALLOCATE(sizeof(*ar));
    799       1.1   thorpej 	if (ar == NULL) {
    800      1.23  jmcneill 		aprint_error_dev(dev, "ACPI: unable to allocate DRQ resource %d\n",
    801      1.23  jmcneill 		    res->ar_ndrq);
    802       1.1   thorpej 		res->ar_ndrq++;
    803       1.1   thorpej 		return;
    804       1.1   thorpej 	}
    805       1.1   thorpej 
    806       1.1   thorpej 	ar->ar_index = res->ar_ndrq++;
    807       1.1   thorpej 	ar->ar_drq = drq;
    808       1.1   thorpej 
    809       1.1   thorpej 	SIMPLEQ_INSERT_TAIL(&res->ar_drq, ar, ar_list);
    810       1.1   thorpej }
    811       1.1   thorpej 
    812       1.1   thorpej static void
    813  1.26.4.2      yamt acpi_res_parse_start_dep(device_t dev, void *context,
    814      1.21  christos     int preference)
    815       1.1   thorpej {
    816      1.10     kochi 
    817      1.23  jmcneill 	aprint_error_dev(dev, "ACPI: dependant functions not supported\n");
    818       1.1   thorpej }
    819       1.1   thorpej 
    820       1.1   thorpej static void
    821  1.26.4.2      yamt acpi_res_parse_end_dep(device_t dev, void *context)
    822       1.1   thorpej {
    823       1.1   thorpej 
    824       1.1   thorpej 	/* Nothing to do. */
    825       1.1   thorpej }
    826