xref: /netbsd/sys/dev/acpi/acpi_resource.c (revision c4a72b64)
1 /*	$NetBSD: acpi_resource.c,v 1.4 2002/06/15 18:03:42 thorpej 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/cdefs.h>
70 __KERNEL_RCSID(0, "$NetBSD: acpi_resource.c,v 1.4 2002/06/15 18:03:42 thorpej Exp $");
71 
72 #include <sys/param.h>
73 #include <sys/systm.h>
74 #include <sys/device.h>
75 #include <sys/malloc.h>
76 
77 #include <dev/acpi/acpica.h>
78 #include <dev/acpi/acpireg.h>
79 #include <dev/acpi/acpivar.h>
80 
81 #define	_COMPONENT	ACPI_RESOURCE_COMPONENT
82 ACPI_MODULE_NAME("RESOURCE")
83 
84 /*
85  * acpi_resource_parse:
86  *
87  *	Parse a device node's resources and fill them in for the
88  *	client.
89  *
90  *	Note that it might be nice to also locate ACPI-specific resource
91  *	items, such as GPE bits.
92  */
93 ACPI_STATUS
94 acpi_resource_parse(struct device *dev, struct acpi_devnode *ad,
95     void *arg, const struct acpi_resource_parse_ops *ops)
96 {
97 	ACPI_BUFFER buf;
98 	ACPI_RESOURCE *res;
99 	char *cur, *last;
100 	ACPI_STATUS status;
101 	void *context;
102 	int i;
103 
104 	ACPI_FUNCTION_TRACE(__FUNCTION__);
105 
106 	/*
107 	 * XXX Note, this means we only get devices that are currently
108 	 * decoding their address space.  This might not be what we
109 	 * want, in the long term.
110 	 */
111 
112 	status = acpi_get(ad->ad_handle, &buf, AcpiGetCurrentResources);
113 	if (status != AE_OK) {
114 		printf("%s: ACPI: unable to get Current Resources: %d\n",
115 		    dev->dv_xname, status);
116 		return_ACPI_STATUS(status);
117 	}
118 
119 	ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "got %d bytes of _CRS\n",
120 	    buf.Length));
121 
122 	(*ops->init)(dev, arg, &context);
123 
124 	cur = buf.Pointer;
125 	last = cur + buf.Length;
126 	while (cur < last) {
127 		res = (ACPI_RESOURCE *) cur;
128 		cur += res->Length;
129 
130 		switch (res->Id) {
131 		case ACPI_RSTYPE_END_TAG:
132 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES, "EndTag\n"));
133 			cur = last;
134 			break;
135 
136 		case ACPI_RSTYPE_FIXED_IO:
137 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
138 			    "FixedIo 0x%x/%d\n",
139 			    res->Data.FixedIo.BaseAddress,
140 			    res->Data.FixedIo.RangeLength));
141 			(*ops->ioport)(dev, context,
142 			    res->Data.FixedIo.BaseAddress,
143 			    res->Data.FixedIo.RangeLength);
144 			break;
145 
146 		case ACPI_RSTYPE_IO:
147 			if (res->Data.Io.MinBaseAddress ==
148 			    res->Data.Io.MaxBaseAddress) {
149 				ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
150 				    "Io 0x%x/%d\n",
151 				    res->Data.Io.MinBaseAddress,
152 				    res->Data.Io.RangeLength));
153 				(*ops->ioport)(dev, context,
154 				    res->Data.Io.MinBaseAddress,
155 				    res->Data.Io.RangeLength);
156 			} else {
157 				ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
158 				    "Io 0x%x-0x%x/%d\n",
159 				    res->Data.Io.MinBaseAddress,
160 				    res->Data.Io.MaxBaseAddress,
161 				    res->Data.Io.RangeLength));
162 				(*ops->iorange)(dev, context,
163 				    res->Data.Io.MinBaseAddress,
164 				    res->Data.Io.MaxBaseAddress,
165 				    res->Data.Io.RangeLength,
166 				    res->Data.Io.Alignment);
167 			}
168 			break;
169 
170 		case ACPI_RSTYPE_FIXED_MEM32:
171 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
172 			    "FixedMemory32 0x%x/%d\n",
173 			    res->Data.FixedMemory32.RangeBaseAddress,
174 			    res->Data.FixedMemory32.RangeLength));
175 			(*ops->memory)(dev, context,
176 			    res->Data.FixedMemory32.RangeBaseAddress,
177 			    res->Data.FixedMemory32.RangeLength);
178 			break;
179 
180 		case ACPI_RSTYPE_MEM32:
181 			if (res->Data.Memory32.MinBaseAddress ==
182 			    res->Data.Memory32.MaxBaseAddress) {
183 				ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
184 				    "Memory32 0x%x/%d\n",
185 				    res->Data.Memory32.MinBaseAddress,
186 				    res->Data.Memory32.RangeLength));
187 				(*ops->memory)(dev, context,
188 				    res->Data.Memory32.MinBaseAddress,
189 				    res->Data.Memory32.RangeLength);
190 			} else {
191 				ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
192 				    "Memory32 0x%x-0x%x/%d\n",
193 				    res->Data.Memory32.MinBaseAddress,
194 				    res->Data.Memory32.MaxBaseAddress,
195 				    res->Data.Memory32.RangeLength));
196 				(*ops->memrange)(dev, context,
197 				    res->Data.Memory32.MinBaseAddress,
198 				    res->Data.Memory32.MaxBaseAddress,
199 				    res->Data.Memory32.RangeLength,
200 				    res->Data.Memory32.Alignment);
201 			}
202 			break;
203 
204 		case ACPI_RSTYPE_MEM24:
205 			if (res->Data.Memory24.MinBaseAddress ==
206 			    res->Data.Memory24.MaxBaseAddress) {
207 				ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
208 				    "Memory24 0x%x/%d\n",
209 				    res->Data.Memory24.MinBaseAddress,
210 				    res->Data.Memory24.RangeLength));
211 				(*ops->memory)(dev, context,
212 				    res->Data.Memory24.MinBaseAddress,
213 				    res->Data.Memory24.RangeLength);
214 			} else {
215 				ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
216 				    "Memory24 0x%x-0x%x/%d\n",
217 				    res->Data.Memory24.MinBaseAddress,
218 				    res->Data.Memory24.MaxBaseAddress,
219 				    res->Data.Memory24.RangeLength));
220 				(*ops->memrange)(dev, context,
221 				    res->Data.Memory24.MinBaseAddress,
222 				    res->Data.Memory24.MaxBaseAddress,
223 				    res->Data.Memory24.RangeLength,
224 				    res->Data.Memory24.Alignment);
225 			}
226 			break;
227 
228 		case ACPI_RSTYPE_IRQ:
229 			for (i = 0; i < res->Data.Irq.NumberOfInterrupts; i++) {
230 				ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
231 				    "IRQ %d\n", res->Data.Irq.Interrupts[i]));
232 				(*ops->irq)(dev, context,
233 				    res->Data.Irq.Interrupts[i]);
234 			}
235 			break;
236 
237 		case ACPI_RSTYPE_DMA:
238 			for (i = 0; i < res->Data.Dma.NumberOfChannels; i++) {
239 				ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
240 				    "DRQ %d\n", res->Data.Dma.Channels[i]));
241 				(*ops->drq)(dev, context,
242 				    res->Data.Dma.Channels[i]);
243 			}
244 			break;
245 
246 		case ACPI_RSTYPE_START_DPF:
247 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
248 			    "Start dependant functions: %d\n",
249 			     res->Data.StartDpf.CompatibilityPriority));
250 			(*ops->start_dep)(dev, context,
251 			    res->Data.StartDpf.CompatibilityPriority);
252 			break;
253 
254 		case ACPI_RSTYPE_END_DPF:
255 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
256 			    "End dependant functions\n"));
257 			(*ops->end_dep)(dev, context);
258 
259 		case ACPI_RSTYPE_ADDRESS32:
260 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
261 			    "Address32 unimplemented\n"));
262 			break;
263 
264 		case ACPI_RSTYPE_ADDRESS16:
265 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
266 			    "Address16 unimplemented\n"));
267 			break;
268 
269 		case ACPI_RSTYPE_EXT_IRQ:
270 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
271 			    "ExtendedIrq unimplemented\n"));
272 			break;
273 
274 		case ACPI_RSTYPE_VENDOR:
275 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
276 			    "VendorSpecific unimplemented\n"));
277 			break;
278 
279 		default:
280 			ACPI_DEBUG_PRINT((ACPI_DB_RESOURCES,
281 			    "Unknown resource type: %d\n", res->Id));
282 			break;
283 		}
284 	}
285 
286 	AcpiOsFree(buf.Pointer);
287 	(*ops->fini)(dev, context);
288 
289 	return_ACPI_STATUS(AE_OK);
290 }
291 
292 /*
293  * acpi_resource_print:
294  *
295  *	Print the resources assigned to a device.
296  */
297 void
298 acpi_resource_print(struct device *dev, struct acpi_resources *res)
299 {
300 	const char *sep;
301 
302 	if (SIMPLEQ_EMPTY(&res->ar_io) &&
303 	    SIMPLEQ_EMPTY(&res->ar_iorange) &&
304 	    SIMPLEQ_EMPTY(&res->ar_mem) &&
305 	    SIMPLEQ_EMPTY(&res->ar_memrange) &&
306 	    SIMPLEQ_EMPTY(&res->ar_irq) &&
307 	    SIMPLEQ_EMPTY(&res->ar_drq))
308 		return;
309 
310 	printf("%s:", dev->dv_xname);
311 
312 	if (SIMPLEQ_EMPTY(&res->ar_io) == 0) {
313 		struct acpi_io *ar;
314 
315 		sep = "";
316 		printf(" io ");
317 		SIMPLEQ_FOREACH(ar, &res->ar_io, ar_list) {
318 			printf("%s0x%x", sep, ar->ar_base);
319 			if (ar->ar_length > 1)
320 				printf("-0x%x", ar->ar_base +
321 				    ar->ar_length - 1);
322 			sep = ",";
323 		}
324 	}
325 
326 	/* XXX iorange */
327 
328 	if (SIMPLEQ_EMPTY(&res->ar_mem) == 0) {
329 		struct acpi_mem *ar;
330 
331 		sep = "";
332 		printf(" mem ");
333 		SIMPLEQ_FOREACH(ar, &res->ar_mem, ar_list) {
334 			printf("%s0x%x", sep, ar->ar_base);
335 			if (ar->ar_length > 1)
336 				printf("-0x%x", ar->ar_base +
337 				    ar->ar_length - 1);
338 			sep = ",";
339 		}
340 	}
341 
342 	/* XXX memrange */
343 
344 	if (SIMPLEQ_EMPTY(&res->ar_irq) == 0) {
345 		struct acpi_irq *ar;
346 
347 		sep = "";
348 		printf(" irq ");
349 		SIMPLEQ_FOREACH(ar, &res->ar_irq, 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 		SIMPLEQ_FOREACH(ar, &res->ar_drq, ar_list) {
361 			printf("%s%d", sep, ar->ar_drq);
362 			sep = ",";
363 		}
364 	}
365 
366 	printf("\n");
367 }
368 
369 struct acpi_io *
370 acpi_res_io(struct acpi_resources *res, int idx)
371 {
372 	struct acpi_io *ar;
373 
374 	SIMPLEQ_FOREACH(ar, &res->ar_io, ar_list) {
375 		if (ar->ar_index == idx)
376 			return (ar);
377 	}
378 	return (NULL);
379 }
380 
381 struct acpi_iorange *
382 acpi_res_iorange(struct acpi_resources *res, int idx)
383 {
384 	struct acpi_iorange *ar;
385 
386 	SIMPLEQ_FOREACH(ar, &res->ar_iorange, ar_list) {
387 		if (ar->ar_index == idx)
388 			return (ar);
389 	}
390 	return (NULL);
391 }
392 
393 struct acpi_mem *
394 acpi_res_mem(struct acpi_resources *res, int idx)
395 {
396 	struct acpi_mem *ar;
397 
398 	SIMPLEQ_FOREACH(ar, &res->ar_mem, ar_list) {
399 		if (ar->ar_index == idx)
400 			return (ar);
401 	}
402 	return (NULL);
403 }
404 
405 struct acpi_memrange *
406 acpi_res_memrange(struct acpi_resources *res, int idx)
407 {
408 	struct acpi_memrange *ar;
409 
410 	SIMPLEQ_FOREACH(ar, &res->ar_memrange, ar_list) {
411 		if (ar->ar_index == idx)
412 			return (ar);
413 	}
414 	return (NULL);
415 }
416 
417 struct acpi_irq *
418 acpi_res_irq(struct acpi_resources *res, int idx)
419 {
420 	struct acpi_irq *ar;
421 
422 	SIMPLEQ_FOREACH(ar, &res->ar_irq, ar_list) {
423 		if (ar->ar_index == idx)
424 			return (ar);
425 	}
426 	return (NULL);
427 }
428 
429 struct acpi_drq *
430 acpi_res_drq(struct acpi_resources *res, int idx)
431 {
432 	struct acpi_drq *ar;
433 
434 	SIMPLEQ_FOREACH(ar, &res->ar_drq, ar_list) {
435 		if (ar->ar_index == idx)
436 			return (ar);
437 	}
438 	return (NULL);
439 }
440 
441 /*****************************************************************************
442  * Default ACPI resource parse operations.
443  *****************************************************************************/
444 
445 static void	acpi_res_parse_init(struct device *, void *, void **);
446 static void	acpi_res_parse_fini(struct device *, void *);
447 
448 static void	acpi_res_parse_ioport(struct device *, void *, uint32_t,
449 		    uint32_t);
450 static void	acpi_res_parse_iorange(struct device *, void *, uint32_t,
451 		    uint32_t, uint32_t, uint32_t);
452 
453 static void	acpi_res_parse_memory(struct device *, void *, uint32_t,
454 		    uint32_t);
455 static void	acpi_res_parse_memrange(struct device *, void *, uint32_t,
456 		    uint32_t, uint32_t, uint32_t);
457 
458 static void	acpi_res_parse_irq(struct device *, void *, uint32_t);
459 static void	acpi_res_parse_drq(struct device *, void *, uint32_t);
460 
461 static void	acpi_res_parse_start_dep(struct device *, void *, int);
462 static void	acpi_res_parse_end_dep(struct device *, void *);
463 
464 const struct acpi_resource_parse_ops acpi_resource_parse_ops_default = {
465 	acpi_res_parse_init,
466 	acpi_res_parse_fini,
467 
468 	acpi_res_parse_ioport,
469 	acpi_res_parse_iorange,
470 
471 	acpi_res_parse_memory,
472 	acpi_res_parse_memrange,
473 
474 	acpi_res_parse_irq,
475 	acpi_res_parse_drq,
476 
477 	acpi_res_parse_start_dep,
478 	acpi_res_parse_end_dep,
479 };
480 
481 static void
482 acpi_res_parse_init(struct device *dev, void *arg, void **contextp)
483 {
484 	struct acpi_resources *res = arg;
485 
486 	SIMPLEQ_INIT(&res->ar_io);
487 	res->ar_nio = 0;
488 
489 	SIMPLEQ_INIT(&res->ar_iorange);
490 	res->ar_niorange = 0;
491 
492 	SIMPLEQ_INIT(&res->ar_mem);
493 	res->ar_nmem = 0;
494 
495 	SIMPLEQ_INIT(&res->ar_memrange);
496 	res->ar_nmemrange = 0;
497 
498 	SIMPLEQ_INIT(&res->ar_irq);
499 	res->ar_nirq = 0;
500 
501 	SIMPLEQ_INIT(&res->ar_drq);
502 	res->ar_ndrq = 0;
503 
504 	*contextp = res;
505 }
506 
507 static void
508 acpi_res_parse_fini(struct device *dev, void *context)
509 {
510 	struct acpi_resources *res = context;
511 
512 	/* Print the resources we're using. */
513 	acpi_resource_print(dev, res);
514 }
515 
516 static void
517 acpi_res_parse_ioport(struct device *dev, void *context, uint32_t base,
518     uint32_t length)
519 {
520 	struct acpi_resources *res = context;
521 	struct acpi_io *ar;
522 
523 	ar = AcpiOsAllocate(sizeof(*ar));
524 	if (ar == NULL) {
525 		printf("%s: ACPI: unable to allocate I/O resource %d\n",
526 		    dev->dv_xname, res->ar_nio);
527 		res->ar_nio++;
528 		return;
529 	}
530 
531 	ar->ar_index = res->ar_nio++;
532 	ar->ar_base = base;
533 	ar->ar_length = length;
534 
535 	SIMPLEQ_INSERT_TAIL(&res->ar_io, ar, ar_list);
536 }
537 
538 static void
539 acpi_res_parse_iorange(struct device *dev, void *context, uint32_t low,
540     uint32_t high, uint32_t length, uint32_t align)
541 {
542 	struct acpi_resources *res = context;
543 	struct acpi_iorange *ar;
544 
545 	ar = AcpiOsAllocate(sizeof(*ar));
546 	if (ar == NULL) {
547 		printf("%s: ACPI: unable to allocate I/O range resource %d\n",
548 		    dev->dv_xname, res->ar_niorange);
549 		res->ar_niorange++;
550 		return;
551 	}
552 
553 	ar->ar_index = res->ar_niorange++;
554 	ar->ar_low = low;
555 	ar->ar_high = high;
556 	ar->ar_length = length;
557 	ar->ar_align = align;
558 
559 	SIMPLEQ_INSERT_TAIL(&res->ar_iorange, ar, ar_list);
560 }
561 
562 static void
563 acpi_res_parse_memory(struct device *dev, void *context, uint32_t base,
564     uint32_t length)
565 {
566 	struct acpi_resources *res = context;
567 	struct acpi_mem *ar;
568 
569 	ar = AcpiOsAllocate(sizeof(*ar));
570 	if (ar == NULL) {
571 		printf("%s: ACPI: unable to allocate Memory resource %d\n",
572 		    dev->dv_xname, res->ar_nmem);
573 		res->ar_nmem++;
574 		return;
575 	}
576 
577 	ar->ar_index = res->ar_nmem++;
578 	ar->ar_base = base;
579 	ar->ar_length = length;
580 
581 	SIMPLEQ_INSERT_TAIL(&res->ar_mem, ar, ar_list);
582 }
583 
584 static void
585 acpi_res_parse_memrange(struct device *dev, void *context, uint32_t low,
586     uint32_t high, uint32_t length, uint32_t align)
587 {
588 	struct acpi_resources *res = context;
589 	struct acpi_memrange *ar;
590 
591 	ar = AcpiOsAllocate(sizeof(*ar));
592 	if (ar == NULL) {
593 		printf("%s: ACPI: unable to allocate Memory range resource "
594 		    "%d\n", dev->dv_xname, res->ar_nmemrange);
595 		res->ar_nmemrange++;
596 		return;
597 	}
598 
599 	ar->ar_index = res->ar_nmemrange++;
600 	ar->ar_low = low;
601 	ar->ar_high = high;
602 	ar->ar_length = length;
603 	ar->ar_align = align;
604 
605 	SIMPLEQ_INSERT_TAIL(&res->ar_memrange, ar, ar_list);
606 }
607 
608 static void
609 acpi_res_parse_irq(struct device *dev, void *context, uint32_t irq)
610 {
611 	struct acpi_resources *res = context;
612 	struct acpi_irq *ar;
613 
614 	ar = AcpiOsAllocate(sizeof(*ar));
615 	if (ar == NULL) {
616 		printf("%s: ACPI: unable to allocate IRQ resource %d\n",
617 		    dev->dv_xname, res->ar_nirq);
618 		res->ar_nirq++;
619 		return;
620 	}
621 
622 	ar->ar_index = res->ar_nirq++;
623 	ar->ar_irq = irq;
624 
625 	SIMPLEQ_INSERT_TAIL(&res->ar_irq, ar, ar_list);
626 }
627 
628 static void
629 acpi_res_parse_drq(struct device *dev, void *context, uint32_t drq)
630 {
631 	struct acpi_resources *res = context;
632 	struct acpi_drq *ar;
633 
634 	ar = AcpiOsAllocate(sizeof(*ar));
635 	if (ar == NULL) {
636 		printf("%s: ACPI: unable to allocate DRQ resource %d\n",
637 		    dev->dv_xname, res->ar_ndrq);
638 		res->ar_ndrq++;
639 		return;
640 	}
641 
642 	ar->ar_index = res->ar_ndrq++;
643 	ar->ar_drq = drq;
644 
645 	SIMPLEQ_INSERT_TAIL(&res->ar_drq, ar, ar_list);
646 }
647 
648 static void
649 acpi_res_parse_start_dep(struct device *dev, void *context, int preference)
650 {
651 
652 	printf("%s: ACPI: dependant functions not supported\n",
653 	    dev->dv_xname);
654 }
655 
656 static void
657 acpi_res_parse_end_dep(struct device *dev, void *context)
658 {
659 
660 	/* Nothing to do. */
661 }
662