Home | History | Annotate | Line # | Download | only in acpi
acpi_resource.c revision 1.1.2.2
      1 /*	$NetBSD: acpi_resource.c,v 1.1.2.2 2001/10/01 12:44:16 fvdl Exp $	*/
      2 
      3 /*
      4  * Copyright 2001 Wasabi Systems, Inc.
      5  * All rights reserved.
      6  *
      7  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  * 3. All advertising materials mentioning features or use of this software
     18  *    must display the following acknowledgement:
     19  *	This product includes software developed for the NetBSD Project by
     20  *	Wasabi Systems, Inc.
     21  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     22  *    or promote products derived from this software without specific prior
     23  *    written permission.
     24  *
     25  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35  * POSSIBILITY OF SUCH DAMAGE.
     36  */
     37 
     38 /*-
     39  * Copyright (c) 2000 Michael Smith
     40  * Copyright (c) 2000 BSDi
     41  * All rights reserved.
     42  *
     43  * Redistribution and use in source and binary forms, with or without
     44  * modification, are permitted provided that the following conditions
     45  * are met:
     46  * 1. Redistributions of source code must retain the above copyright
     47  *    notice, this list of conditions and the following disclaimer.
     48  * 2. Redistributions in binary form must reproduce the above copyright
     49  *    notice, this list of conditions and the following disclaimer in the
     50  *    documentation and/or other materials provided with the distribution.
     51  *
     52  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     53  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     54  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     55  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     56  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     57  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     58  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     59  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     60  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     61  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     62  * SUCH DAMAGE.
     63  */
     64 
     65 /*
     66  * ACPI resource parsing.
     67  */
     68 
     69 #include <sys/param.h>
     70 #include <sys/systm.h>
     71 #include <sys/device.h>
     72 #include <sys/malloc.h>
     73 
     74 #include <dev/acpi/acpica.h>
     75 #include <dev/acpi/acpireg.h>
     76 #include <dev/acpi/acpivar.h>
     77 
     78 #define	_COMPONENT	ACPI_BUS
     79 MODULE_NAME("RESOURCE")
     80 
     81 /*
     82  * acpi_resource_parse:
     83  *
     84  *	Parse a device node's resources and fill them in for the
     85  *	client.
     86  *
     87  *	Note that it might be nice to also locate ACPI-specific resource
     88  *	items, such as GPE bits.
     89  */
     90 ACPI_STATUS
     91 acpi_resource_parse(struct device *dev, struct acpi_devnode *ad,
     92     void *arg, const struct acpi_resource_parse_ops *ops)
     93 {
     94 	ACPI_BUFFER buf;
     95 	ACPI_RESOURCE *res;
     96 	char *cur, *last;
     97 	ACPI_STATUS status;
     98 	void *context;
     99 	int i;
    100 
    101 	FUNCTION_TRACE(__FUNCTION__);
    102 
    103 	/*
    104 	 * XXX Note, this means we only get devices that are currently
    105 	 * decoding their address space.  This might not be what we
    106 	 * want, in the long term.
    107 	 */
    108 
    109 	status = acpi_get(ad->ad_handle, &buf, AcpiGetCurrentResources);
    110 	if (status != AE_OK) {
    111 		printf("%s: ACPI: unable to get Current Resources: %d\n",
    112 		    dev->dv_xname, status);
    113 		return_ACPI_STATUS(status);
    114 	}
    115 
    116 	ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "got %d bytes of _CRS\n",
    117 	    buf.Length));
    118 
    119 	(*ops->init)(dev, arg, &context);
    120 
    121 	cur = buf.Pointer;
    122 	last = cur + buf.Length;
    123 	while (cur < last) {
    124 		res = (ACPI_RESOURCE *) cur;
    125 		cur += res->Length;
    126 
    127 		switch (res->Id) {
    128 		case ACPI_RSTYPE_END_TAG:
    129 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "EndTag\n"));
    130 			cur = last;
    131 			break;
    132 
    133 		case ACPI_RSTYPE_FIXED_IO:
    134 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    135 			    "FixedIo 0x%x/%d\n",
    136 			    res->Data.FixedIo.BaseAddress,
    137 			    res->Data.FixedIo.RangeLength));
    138 			(*ops->ioport)(dev, context,
    139 			    res->Data.FixedIo.BaseAddress,
    140 			    res->Data.FixedIo.RangeLength);
    141 			break;
    142 
    143 		case ACPI_RSTYPE_IO:
    144 			if (res->Data.Io.MinBaseAddress ==
    145 			    res->Data.Io.MaxBaseAddress) {
    146 				ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    147 				    "Io 0x%x/%d\n",
    148 				    res->Data.Io.MinBaseAddress,
    149 				    res->Data.Io.RangeLength));
    150 				(*ops->ioport)(dev, context,
    151 				    res->Data.Io.MinBaseAddress,
    152 				    res->Data.Io.RangeLength);
    153 			} else {
    154 				ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    155 				    "Io 0x%x-0x%x/%d\n",
    156 				    res->Data.Io.MinBaseAddress,
    157 				    res->Data.Io.MaxBaseAddress,
    158 				    res->Data.Io.RangeLength));
    159 				(*ops->iorange)(dev, context,
    160 				    res->Data.Io.MinBaseAddress,
    161 				    res->Data.Io.MaxBaseAddress,
    162 				    res->Data.Io.RangeLength,
    163 				    res->Data.Io.Alignment);
    164 			}
    165 			break;
    166 
    167 		case ACPI_RSTYPE_FIXED_MEM32:
    168 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    169 			    "FixedMemory32 0x%x/%d\n",
    170 			    res->Data.FixedMemory32.RangeBaseAddress,
    171 			    res->Data.FixedMemory32.RangeLength));
    172 			(*ops->memory)(dev, context,
    173 			    res->Data.FixedMemory32.RangeBaseAddress,
    174 			    res->Data.FixedMemory32.RangeLength);
    175 			break;
    176 
    177 		case ACPI_RSTYPE_MEM32:
    178 			if (res->Data.Memory32.MinBaseAddress ==
    179 			    res->Data.Memory32.MaxBaseAddress) {
    180 				ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    181 				    "Memory32 0x%x/%d\n",
    182 				    res->Data.Memory32.MinBaseAddress,
    183 				    res->Data.Memory32.RangeLength));
    184 				(*ops->memory)(dev, context,
    185 				    res->Data.Memory32.MinBaseAddress,
    186 				    res->Data.Memory32.RangeLength);
    187 			} else {
    188 				ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    189 				    "Memory32 0x%x-0x%x/%d\n",
    190 				    res->Data.Memory32.MinBaseAddress,
    191 				    res->Data.Memory32.MaxBaseAddress,
    192 				    res->Data.Memory32.RangeLength));
    193 				(*ops->memrange)(dev, context,
    194 				    res->Data.Memory32.MinBaseAddress,
    195 				    res->Data.Memory32.MaxBaseAddress,
    196 				    res->Data.Memory32.RangeLength,
    197 				    res->Data.Memory32.Alignment);
    198 			}
    199 			break;
    200 
    201 		case ACPI_RSTYPE_MEM24:
    202 			if (res->Data.Memory24.MinBaseAddress ==
    203 			    res->Data.Memory24.MaxBaseAddress) {
    204 				ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    205 				    "Memory24 0x%x/%d\n",
    206 				    res->Data.Memory24.MinBaseAddress,
    207 				    res->Data.Memory24.RangeLength));
    208 				(*ops->memory)(dev, context,
    209 				    res->Data.Memory24.MinBaseAddress,
    210 				    res->Data.Memory24.RangeLength);
    211 			} else {
    212 				ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    213 				    "Memory24 0x%x-0x%x/%d\n",
    214 				    res->Data.Memory24.MinBaseAddress,
    215 				    res->Data.Memory24.MaxBaseAddress,
    216 				    res->Data.Memory24.RangeLength));
    217 				(*ops->memrange)(dev, context,
    218 				    res->Data.Memory24.MinBaseAddress,
    219 				    res->Data.Memory24.MaxBaseAddress,
    220 				    res->Data.Memory24.RangeLength,
    221 				    res->Data.Memory24.Alignment);
    222 			}
    223 			break;
    224 
    225 		case ACPI_RSTYPE_IRQ:
    226 			for (i = 0; i < res->Data.Irq.NumberOfInterrupts; i++) {
    227 				ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    228 				    "IRQ %d\n", res->Data.Irq.Interrupts[i]));
    229 				(*ops->irq)(dev, context,
    230 				    res->Data.Irq.Interrupts[i]);
    231 			}
    232 			break;
    233 
    234 		case ACPI_RSTYPE_DMA:
    235 			for (i = 0; i < res->Data.Dma.NumberOfChannels; i++) {
    236 				ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    237 				    "DRQ %d\n", res->Data.Dma.Channels[i]));
    238 				(*ops->drq)(dev, context,
    239 				    res->Data.Dma.Channels[i]);
    240 			}
    241 			break;
    242 
    243 		case ACPI_RSTYPE_START_DPF:
    244 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    245 			    "Start dependant functions: %d\n",
    246 			     res->Data.StartDpf.CompatibilityPriority));
    247 			(*ops->start_dep)(dev, context,
    248 			    res->Data.StartDpf.CompatibilityPriority);
    249 			break;
    250 
    251 		case ACPI_RSTYPE_END_DPF:
    252 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    253 			    "End dependant functions\n"));
    254 			(*ops->end_dep)(dev, context);
    255 
    256 		case ACPI_RSTYPE_ADDRESS32:
    257 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    258 			    "Address32 unimplemented\n"));
    259 			break;
    260 
    261 		case ACPI_RSTYPE_ADDRESS16:
    262 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    263 			    "Address16 unimplemented\n"));
    264 			break;
    265 
    266 		case ACPI_RSTYPE_EXT_IRQ:
    267 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    268 			    "ExtendedIrq unimplemented\n"));
    269 			break;
    270 
    271 		case ACPI_RSTYPE_VENDOR:
    272 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    273 			    "VendorSpecific unimplemented\n"));
    274 			break;
    275 
    276 		default:
    277 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
    278 			    "Unknown resource type: %d\n", res->Id));
    279 			break;
    280 		}
    281 	}
    282 
    283 	AcpiOsFree(buf.Pointer);
    284 	(*ops->fini)(dev, context);
    285 
    286 	return_ACPI_STATUS(AE_OK);
    287 }
    288 
    289 /*
    290  * acpi_resource_print:
    291  *
    292  *	Print the resources assigned to a device.
    293  */
    294 void
    295 acpi_resource_print(struct device *dev, struct acpi_resources *res)
    296 {
    297 	const char *sep;
    298 
    299 	if (SIMPLEQ_EMPTY(&res->ar_io) &&
    300 	    SIMPLEQ_EMPTY(&res->ar_iorange) &&
    301 	    SIMPLEQ_EMPTY(&res->ar_mem) &&
    302 	    SIMPLEQ_EMPTY(&res->ar_memrange) &&
    303 	    SIMPLEQ_EMPTY(&res->ar_irq) &&
    304 	    SIMPLEQ_EMPTY(&res->ar_drq))
    305 		return;
    306 
    307 	printf("%s:", dev->dv_xname);
    308 
    309 	if (SIMPLEQ_EMPTY(&res->ar_io) == 0) {
    310 		struct acpi_io *ar;
    311 
    312 		sep = "";
    313 		printf(" io ");
    314 		for (ar = SIMPLEQ_FIRST(&res->ar_io); ar != NULL;
    315 		     ar = SIMPLEQ_NEXT(ar, ar_list)) {
    316 			printf("%s0x%x", sep, ar->ar_base);
    317 			if (ar->ar_length > 1)
    318 				printf("-0x%x", ar->ar_base +
    319 				    ar->ar_length - 1);
    320 			sep = ",";
    321 		}
    322 	}
    323 
    324 	/* XXX iorange */
    325 
    326 	if (SIMPLEQ_EMPTY(&res->ar_mem) == 0) {
    327 		struct acpi_mem *ar;
    328 
    329 		sep = "";
    330 		printf(" mem ");
    331 		for (ar = SIMPLEQ_FIRST(&res->ar_mem); ar != NULL;
    332 		     ar = SIMPLEQ_NEXT(ar, ar_list)) {
    333 			printf("%s0x%x", sep, ar->ar_base);
    334 			if (ar->ar_length > 1)
    335 				printf("-0x%x", ar->ar_base +
    336 				    ar->ar_length - 1);
    337 			sep = ",";
    338 		}
    339 	}
    340 
    341 	/* XXX memrange */
    342 
    343 	if (SIMPLEQ_EMPTY(&res->ar_irq) == 0) {
    344 		struct acpi_irq *ar;
    345 
    346 		sep = "";
    347 		printf(" irq ");
    348 		for (ar = SIMPLEQ_FIRST(&res->ar_irq); ar != NULL;
    349 		     ar = SIMPLEQ_NEXT(ar, ar_list)) {
    350 			printf("%s%d", sep, ar->ar_irq);
    351 			sep = ",";
    352 		}
    353 	}
    354 
    355 	if (SIMPLEQ_EMPTY(&res->ar_drq) == 0) {
    356 		struct acpi_drq *ar;
    357 
    358 		sep = "";
    359 		printf(" drq ");
    360 		for (ar = SIMPLEQ_FIRST(&res->ar_drq); ar != NULL;
    361 		     ar = SIMPLEQ_NEXT(ar, ar_list)) {
    362 			printf("%s%d", sep, ar->ar_drq);
    363 			sep = ",";
    364 		}
    365 	}
    366 
    367 	printf("\n");
    368 }
    369 
    370 struct acpi_io *
    371 acpi_res_io(struct acpi_resources *res, int idx)
    372 {
    373 	struct acpi_io *ar;
    374 
    375 	SIMPLEQ_FOREACH(ar, &res->ar_io, ar_list) {
    376 		if (ar->ar_index == idx)
    377 			return (ar);
    378 	}
    379 	return (NULL);
    380 }
    381 
    382 struct acpi_iorange *
    383 acpi_res_iorange(struct acpi_resources *res, int idx)
    384 {
    385 	struct acpi_iorange *ar;
    386 
    387 	SIMPLEQ_FOREACH(ar, &res->ar_iorange, ar_list) {
    388 		if (ar->ar_index == idx)
    389 			return (ar);
    390 	}
    391 	return (NULL);
    392 }
    393 
    394 struct acpi_mem *
    395 acpi_res_mem(struct acpi_resources *res, int idx)
    396 {
    397 	struct acpi_mem *ar;
    398 
    399 	SIMPLEQ_FOREACH(ar, &res->ar_mem, ar_list) {
    400 		if (ar->ar_index == idx)
    401 			return (ar);
    402 	}
    403 	return (NULL);
    404 }
    405 
    406 struct acpi_memrange *
    407 acpi_res_memrange(struct acpi_resources *res, int idx)
    408 {
    409 	struct acpi_memrange *ar;
    410 
    411 	SIMPLEQ_FOREACH(ar, &res->ar_memrange, ar_list) {
    412 		if (ar->ar_index == idx)
    413 			return (ar);
    414 	}
    415 	return (NULL);
    416 }
    417 
    418 struct acpi_irq *
    419 acpi_res_irq(struct acpi_resources *res, int idx)
    420 {
    421 	struct acpi_irq *ar;
    422 
    423 	SIMPLEQ_FOREACH(ar, &res->ar_irq, ar_list) {
    424 		if (ar->ar_index == idx)
    425 			return (ar);
    426 	}
    427 	return (NULL);
    428 }
    429 
    430 struct acpi_drq *
    431 acpi_res_drq(struct acpi_resources *res, int idx)
    432 {
    433 	struct acpi_drq *ar;
    434 
    435 	SIMPLEQ_FOREACH(ar, &res->ar_drq, ar_list) {
    436 		if (ar->ar_index == idx)
    437 			return (ar);
    438 	}
    439 	return (NULL);
    440 }
    441 
    442 /*****************************************************************************
    443  * Default ACPI resource parse operations.
    444  *****************************************************************************/
    445 
    446 static void	acpi_res_parse_init(struct device *, void *, void **);
    447 static void	acpi_res_parse_fini(struct device *, void *);
    448 
    449 static void	acpi_res_parse_ioport(struct device *, void *, uint32_t,
    450 		    uint32_t);
    451 static void	acpi_res_parse_iorange(struct device *, void *, uint32_t,
    452 		    uint32_t, uint32_t, uint32_t);
    453 
    454 static void	acpi_res_parse_memory(struct device *, void *, uint32_t,
    455 		    uint32_t);
    456 static void	acpi_res_parse_memrange(struct device *, void *, uint32_t,
    457 		    uint32_t, uint32_t, uint32_t);
    458 
    459 static void	acpi_res_parse_irq(struct device *, void *, uint32_t);
    460 static void	acpi_res_parse_drq(struct device *, void *, uint32_t);
    461 
    462 static void	acpi_res_parse_start_dep(struct device *, void *, int);
    463 static void	acpi_res_parse_end_dep(struct device *, void *);
    464 
    465 const struct acpi_resource_parse_ops acpi_resource_parse_ops_default = {
    466 	acpi_res_parse_init,
    467 	acpi_res_parse_fini,
    468 
    469 	acpi_res_parse_ioport,
    470 	acpi_res_parse_iorange,
    471 
    472 	acpi_res_parse_memory,
    473 	acpi_res_parse_memrange,
    474 
    475 	acpi_res_parse_irq,
    476 	acpi_res_parse_drq,
    477 
    478 	acpi_res_parse_start_dep,
    479 	acpi_res_parse_end_dep,
    480 };
    481 
    482 static void
    483 acpi_res_parse_init(struct device *dev, void *arg, void **contextp)
    484 {
    485 	struct acpi_resources *res = arg;
    486 
    487 	SIMPLEQ_INIT(&res->ar_io);
    488 	res->ar_nio = 0;
    489 
    490 	SIMPLEQ_INIT(&res->ar_iorange);
    491 	res->ar_niorange = 0;
    492 
    493 	SIMPLEQ_INIT(&res->ar_mem);
    494 	res->ar_nmem = 0;
    495 
    496 	SIMPLEQ_INIT(&res->ar_memrange);
    497 	res->ar_nmemrange = 0;
    498 
    499 	SIMPLEQ_INIT(&res->ar_irq);
    500 	res->ar_nirq = 0;
    501 
    502 	SIMPLEQ_INIT(&res->ar_drq);
    503 	res->ar_ndrq = 0;
    504 
    505 	*contextp = res;
    506 }
    507 
    508 static void
    509 acpi_res_parse_fini(struct device *dev, void *context)
    510 {
    511 	struct acpi_resources *res = context;
    512 
    513 	/* Print the resources we're using. */
    514 	acpi_resource_print(dev, res);
    515 }
    516 
    517 static void
    518 acpi_res_parse_ioport(struct device *dev, void *context, uint32_t base,
    519     uint32_t length)
    520 {
    521 	struct acpi_resources *res = context;
    522 	struct acpi_io *ar;
    523 
    524 	ar = AcpiOsAllocate(sizeof(*ar));
    525 	if (ar == NULL) {
    526 		printf("%s: ACPI: unable to allocate I/O resource %d\n",
    527 		    dev->dv_xname, res->ar_nio);
    528 		res->ar_nio++;
    529 		return;
    530 	}
    531 
    532 	ar->ar_index = res->ar_nio++;
    533 	ar->ar_base = base;
    534 	ar->ar_length = length;
    535 
    536 	SIMPLEQ_INSERT_TAIL(&res->ar_io, ar, ar_list);
    537 }
    538 
    539 static void
    540 acpi_res_parse_iorange(struct device *dev, void *context, uint32_t low,
    541     uint32_t high, uint32_t length, uint32_t align)
    542 {
    543 	struct acpi_resources *res = context;
    544 	struct acpi_iorange *ar;
    545 
    546 	ar = AcpiOsAllocate(sizeof(*ar));
    547 	if (ar == NULL) {
    548 		printf("%s: ACPI: unable to allocate I/O range resource %d\n",
    549 		    dev->dv_xname, res->ar_niorange);
    550 		res->ar_niorange++;
    551 		return;
    552 	}
    553 
    554 	ar->ar_index = res->ar_niorange++;
    555 	ar->ar_low = low;
    556 	ar->ar_high = high;
    557 	ar->ar_length = length;
    558 	ar->ar_align = align;
    559 
    560 	SIMPLEQ_INSERT_TAIL(&res->ar_iorange, ar, ar_list);
    561 }
    562 
    563 static void
    564 acpi_res_parse_memory(struct device *dev, void *context, uint32_t base,
    565     uint32_t length)
    566 {
    567 	struct acpi_resources *res = context;
    568 	struct acpi_mem *ar;
    569 
    570 	ar = AcpiOsAllocate(sizeof(*ar));
    571 	if (ar == NULL) {
    572 		printf("%s: ACPI: unable to allocate Memory resource %d\n",
    573 		    dev->dv_xname, res->ar_nmem);
    574 		res->ar_nmem++;
    575 		return;
    576 	}
    577 
    578 	ar->ar_index = res->ar_nmem++;
    579 	ar->ar_base = base;
    580 	ar->ar_length = length;
    581 
    582 	SIMPLEQ_INSERT_TAIL(&res->ar_mem, ar, ar_list);
    583 }
    584 
    585 static void
    586 acpi_res_parse_memrange(struct device *dev, void *context, uint32_t low,
    587     uint32_t high, uint32_t length, uint32_t align)
    588 {
    589 	struct acpi_resources *res = context;
    590 	struct acpi_memrange *ar;
    591 
    592 	ar = AcpiOsAllocate(sizeof(*ar));
    593 	if (ar == NULL) {
    594 		printf("%s: ACPI: unable to allocate Memory range resource "
    595 		    "%d\n", dev->dv_xname, res->ar_nmemrange);
    596 		res->ar_nmemrange++;
    597 		return;
    598 	}
    599 
    600 	ar->ar_index = res->ar_nmemrange++;
    601 	ar->ar_low = low;
    602 	ar->ar_high = high;
    603 	ar->ar_length = length;
    604 	ar->ar_align = align;
    605 
    606 	SIMPLEQ_INSERT_TAIL(&res->ar_memrange, ar, ar_list);
    607 }
    608 
    609 static void
    610 acpi_res_parse_irq(struct device *dev, void *context, uint32_t irq)
    611 {
    612 	struct acpi_resources *res = context;
    613 	struct acpi_irq *ar;
    614 
    615 	ar = AcpiOsAllocate(sizeof(*ar));
    616 	if (ar == NULL) {
    617 		printf("%s: ACPI: unable to allocate IRQ resource %d\n",
    618 		    dev->dv_xname, res->ar_nirq);
    619 		res->ar_nirq++;
    620 		return;
    621 	}
    622 
    623 	ar->ar_index = res->ar_nirq++;
    624 	ar->ar_irq = irq;
    625 
    626 	SIMPLEQ_INSERT_TAIL(&res->ar_irq, ar, ar_list);
    627 }
    628 
    629 static void
    630 acpi_res_parse_drq(struct device *dev, void *context, uint32_t drq)
    631 {
    632 	struct acpi_resources *res = context;
    633 	struct acpi_drq *ar;
    634 
    635 	ar = AcpiOsAllocate(sizeof(*ar));
    636 	if (ar == NULL) {
    637 		printf("%s: ACPI: unable to allocate DRQ resource %d\n",
    638 		    dev->dv_xname, res->ar_ndrq);
    639 		res->ar_ndrq++;
    640 		return;
    641 	}
    642 
    643 	ar->ar_index = res->ar_ndrq++;
    644 	ar->ar_drq = drq;
    645 
    646 	SIMPLEQ_INSERT_TAIL(&res->ar_drq, ar, ar_list);
    647 }
    648 
    649 static void
    650 acpi_res_parse_start_dep(struct device *dev, void *context, int preference)
    651 {
    652 
    653 	printf("%s: ACPI: dependant functions not supported\n",
    654 	    dev->dv_xname);
    655 }
    656 
    657 static void
    658 acpi_res_parse_end_dep(struct device *dev, void *context)
    659 {
    660 
    661 	/* Nothing to do. */
    662 }
    663