xref: /freebsd/sys/kern/bus_if.m (revision dd41de95a84d979615a2ef11df6850622bf6184e)
1#-
2# Copyright (c) 1998-2004 Doug Rabson
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8# 1. Redistributions of source code must retain the above copyright
9#    notice, this list of conditions and the following disclaimer.
10# 2. Redistributions in binary form must reproduce the above copyright
11#    notice, this list of conditions and the following disclaimer in the
12#    documentation and/or other materials provided with the distribution.
13#
14# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24# SUCH DAMAGE.
25#
26# $FreeBSD$
27#
28
29#include <sys/types.h>
30#include <sys/systm.h>
31#include <sys/bus.h>
32
33/**
34 * @defgroup BUS bus - KObj methods for drivers of devices with children
35 * @brief A set of methods required device drivers that support
36 * child devices.
37 * @{
38 */
39INTERFACE bus;
40
41#
42# Default implementations of some methods.
43#
44CODE {
45	static struct resource *
46	null_alloc_resource(device_t dev, device_t child,
47	    int type, int *rid, rman_res_t start, rman_res_t end,
48	    rman_res_t count, u_int flags)
49	{
50	    return (0);
51	}
52
53	static int
54	null_remap_intr(device_t bus, device_t dev, u_int irq)
55	{
56
57		if (dev != NULL)
58			return (BUS_REMAP_INTR(dev, NULL, irq));
59		return (ENXIO);
60	}
61
62	static device_t
63	null_add_child(device_t bus, int order, const char *name,
64	    int unit)
65	{
66
67		panic("bus_add_child is not implemented");
68	}
69
70	static int null_reset_post(device_t bus, device_t dev)
71	{
72		return (0);
73	}
74
75	static int null_reset_prepare(device_t bus, device_t dev)
76	{
77		return (0);
78	}
79
80	static int
81	null_translate_resource(device_t bus, int type, rman_res_t start,
82		rman_res_t *newstart)
83	{
84		if (device_get_parent(bus) != NULL)
85			return (BUS_TRANSLATE_RESOURCE(device_get_parent(bus),
86			    type, start, newstart));
87
88		*newstart = start;
89		return (0);
90	}
91};
92
93/**
94 * @brief Print a description of a child device
95 *
96 * This is called from system code which prints out a description of a
97 * device. It should describe the attachment that the child has with
98 * the parent. For instance the TurboLaser bus prints which node the
99 * device is attached to. See bus_generic_print_child() for more
100 * information.
101 *
102 * @param _dev		the device whose child is being printed
103 * @param _child	the child device to describe
104 *
105 * @returns		the number of characters output.
106 */
107METHOD int print_child {
108	device_t _dev;
109	device_t _child;
110} DEFAULT bus_generic_print_child;
111
112/**
113 * @brief Print a notification about an unprobed child device.
114 *
115 * Called for each child device that did not succeed in probing for a
116 * driver.
117 *
118 * @param _dev		the device whose child was being probed
119 * @param _child	the child device which failed to probe
120 */
121METHOD void probe_nomatch {
122        device_t _dev;
123        device_t _child;
124};
125
126/**
127 * @brief Read the value of a bus-specific attribute of a device
128 *
129 * This method, along with BUS_WRITE_IVAR() manages a bus-specific set
130 * of instance variables of a child device.  The intention is that
131 * each different type of bus defines a set of appropriate instance
132 * variables (such as ports and irqs for ISA bus etc.)
133 *
134 * This information could be given to the child device as a struct but
135 * that makes it hard for a bus to add or remove variables without
136 * forcing an edit and recompile for all drivers which may not be
137 * possible for vendor supplied binary drivers.
138 *
139 * This method copies the value of an instance variable to the
140 * location specified by @p *_result.
141 *
142 * @param _dev		the device whose child was being examined
143 * @param _child	the child device whose instance variable is
144 *			being read
145 * @param _index	the instance variable to read
146 * @param _result	a location to receive the instance variable
147 *			value
148 *
149 * @retval 0		success
150 * @retval ENOENT	no such instance variable is supported by @p
151 *			_dev
152 */
153METHOD int read_ivar {
154	device_t _dev;
155	device_t _child;
156	int _index;
157	uintptr_t *_result;
158};
159
160/**
161 * @brief Write the value of a bus-specific attribute of a device
162 *
163 * This method sets the value of an instance variable to @p _value.
164 *
165 * @param _dev		the device whose child was being updated
166 * @param _child	the child device whose instance variable is
167 *			being written
168 * @param _index	the instance variable to write
169 * @param _value	the value to write to that instance variable
170 *
171 * @retval 0		success
172 * @retval ENOENT	no such instance variable is supported by @p
173 *			_dev
174 * @retval EINVAL	the instance variable was recognised but
175 *			contains a read-only value
176 */
177METHOD int write_ivar {
178	device_t _dev;
179	device_t _child;
180	int _indx;
181	uintptr_t _value;
182};
183
184/**
185 * @brief Notify a bus that a child was deleted
186 *
187 * Called at the beginning of device_delete_child() to allow the parent
188 * to teardown any bus-specific state for the child.
189 *
190 * @param _dev		the device whose child is being deleted
191 * @param _child	the child device which is being deleted
192 */
193METHOD void child_deleted {
194	device_t _dev;
195	device_t _child;
196};
197
198/**
199 * @brief Notify a bus that a child was detached
200 *
201 * Called after the child's DEVICE_DETACH() method to allow the parent
202 * to reclaim any resources allocated on behalf of the child.
203 *
204 * @param _dev		the device whose child changed state
205 * @param _child	the child device which changed state
206 */
207METHOD void child_detached {
208	device_t _dev;
209	device_t _child;
210};
211
212/**
213 * @brief Notify a bus that a new driver was added
214 *
215 * Called when a new driver is added to the devclass which owns this
216 * bus. The generic implementation of this method attempts to probe and
217 * attach any un-matched children of the bus.
218 *
219 * @param _dev		the device whose devclass had a new driver
220 *			added to it
221 * @param _driver	the new driver which was added
222 */
223METHOD void driver_added {
224	device_t _dev;
225	driver_t *_driver;
226} DEFAULT bus_generic_driver_added;
227
228/**
229 * @brief Create a new child device
230 *
231 * For buses which use use drivers supporting DEVICE_IDENTIFY() to
232 * enumerate their devices, this method is used to create new
233 * device instances. The new device will be added after the last
234 * existing child with the same order. Implementations of bus_add_child
235 * call device_add_child_ordered to add the child and often add
236 * a suitable ivar to the device specific to that bus.
237 *
238 * @param _dev		the bus device which will be the parent of the
239 *			new child device
240 * @param _order	a value which is used to partially sort the
241 *			children of @p _dev - devices created using
242 *			lower values of @p _order appear first in @p
243 *			_dev's list of children
244 * @param _name		devclass name for new device or @c NULL if not
245 *			specified
246 * @param _unit		unit number for new device or @c -1 if not
247 *			specified
248 */
249METHOD device_t add_child {
250	device_t _dev;
251	u_int _order;
252	const char *_name;
253	int _unit;
254} DEFAULT null_add_child;
255
256/**
257 * @brief Rescan the bus
258 *
259 * This method is called by a parent bridge or devctl to trigger a bus
260 * rescan.  The rescan should delete devices no longer present and
261 * enumerate devices that have newly arrived.
262 *
263 * @param _dev		the bus device
264 */
265METHOD int rescan {
266	device_t _dev;
267}
268
269/**
270 * @brief Allocate a system resource
271 *
272 * This method is called by child devices of a bus to allocate resources.
273 * The types are defined in <machine/resource.h>; the meaning of the
274 * resource-ID field varies from bus to bus (but @p *rid == 0 is always
275 * valid if the resource type is). If a resource was allocated and the
276 * caller did not use the RF_ACTIVE to specify that it should be
277 * activated immediately, the caller is responsible for calling
278 * BUS_ACTIVATE_RESOURCE() when it actually uses the resource.
279 *
280 * @param _dev		the parent device of @p _child
281 * @param _child	the device which is requesting an allocation
282 * @param _type		the type of resource to allocate
283 * @param _rid		a pointer to the resource identifier
284 * @param _start	hint at the start of the resource range - pass
285 *			@c 0 for any start address
286 * @param _end		hint at the end of the resource range - pass
287 *			@c ~0 for any end address
288 * @param _count	hint at the size of range required - pass @c 1
289 *			for any size
290 * @param _flags	any extra flags to control the resource
291 *			allocation - see @c RF_XXX flags in
292 *			<sys/rman.h> for details
293 *
294 * @returns		the resource which was allocated or @c NULL if no
295 *			resource could be allocated
296 */
297METHOD struct resource * alloc_resource {
298	device_t	_dev;
299	device_t	_child;
300	int		_type;
301	int	       *_rid;
302	rman_res_t	_start;
303	rman_res_t	_end;
304	rman_res_t	_count;
305	u_int		_flags;
306} DEFAULT null_alloc_resource;
307
308/**
309 * @brief Activate a resource
310 *
311 * Activate a resource previously allocated with
312 * BUS_ALLOC_RESOURCE().  This may enable decoding of this resource in a
313 * device for instance.  It will also establish a mapping for the resource
314 * unless RF_UNMAPPED was set when allocating the resource.
315 *
316 * @param _dev		the parent device of @p _child
317 * @param _child	the device which allocated the resource
318 * @param _type		the type of resource
319 * @param _rid		the resource identifier
320 * @param _r		the resource to activate
321 */
322METHOD int activate_resource {
323	device_t	_dev;
324	device_t	_child;
325	int		_type;
326	int		_rid;
327	struct resource *_r;
328};
329
330
331/**
332 * @brief Map a resource
333 *
334 * Allocate a mapping for a range of an active resource.  The mapping
335 * is described by a struct resource_map object.  This may for instance
336 * map a memory region into the kernel's virtual address space.
337 *
338 * @param _dev		the parent device of @p _child
339 * @param _child	the device which allocated the resource
340 * @param _type		the type of resource
341 * @param _r		the resource to map
342 * @param _args		optional attributes of the mapping
343 * @param _map		the mapping
344 */
345METHOD int map_resource {
346	device_t	_dev;
347	device_t	_child;
348	int		_type;
349	struct resource *_r;
350	struct resource_map_request *_args;
351	struct resource_map *_map;
352} DEFAULT bus_generic_map_resource;
353
354
355/**
356 * @brief Unmap a resource
357 *
358 * Release a mapping previously allocated with
359 * BUS_MAP_RESOURCE(). This may for instance unmap a memory region
360 * from the kernel's virtual address space.
361 *
362 * @param _dev		the parent device of @p _child
363 * @param _child	the device which allocated the resource
364 * @param _type		the type of resource
365 * @param _r		the resource
366 * @param _map		the mapping to release
367 */
368METHOD int unmap_resource {
369	device_t	_dev;
370	device_t	_child;
371	int		_type;
372	struct resource *_r;
373	struct resource_map *_map;
374} DEFAULT bus_generic_unmap_resource;
375
376
377/**
378 * @brief Deactivate a resource
379 *
380 * Deactivate a resource previously allocated with
381 * BUS_ALLOC_RESOURCE().
382 *
383 * @param _dev		the parent device of @p _child
384 * @param _child	the device which allocated the resource
385 * @param _type		the type of resource
386 * @param _rid		the resource identifier
387 * @param _r		the resource to deactivate
388 */
389METHOD int deactivate_resource {
390	device_t	_dev;
391	device_t	_child;
392	int		_type;
393	int		_rid;
394	struct resource *_r;
395};
396
397/**
398 * @brief Adjust a resource
399 *
400 * Adjust the start and/or end of a resource allocated by
401 * BUS_ALLOC_RESOURCE.  At least part of the new address range must overlap
402 * with the existing address range.  If the successful, the resource's range
403 * will be adjusted to [start, end] on return.
404 *
405 * @param _dev		the parent device of @p _child
406 * @param _child	the device which allocated the resource
407 * @param _type		the type of resource
408 * @param _res		the resource to adjust
409 * @param _start	the new starting address of the resource range
410 * @param _end		the new ending address of the resource range
411 */
412METHOD int adjust_resource {
413	device_t	_dev;
414	device_t	_child;
415	int		_type;
416	struct resource *_res;
417	rman_res_t	_start;
418	rman_res_t	_end;
419};
420
421
422/**
423 * @brief translate a resource value
424 *
425 *
426 * @param _dev		the device associated with the resource
427 * @param _type		the type of resource
428 * @param _start	the starting address of the resource range
429 * @param _newstart	the new starting address of the resource range
430 */
431METHOD int translate_resource {
432	device_t	_dev;
433	int		_type;
434	rman_res_t	_start;
435	rman_res_t	*_newstart;
436} DEFAULT null_translate_resource;
437
438/**
439 * @brief Release a resource
440 *
441 * Free a resource allocated by the BUS_ALLOC_RESOURCE.  The @p _rid
442 * value must be the same as the one returned by BUS_ALLOC_RESOURCE()
443 * (which is not necessarily the same as the one the client passed).
444 *
445 * @param _dev		the parent device of @p _child
446 * @param _child	the device which allocated the resource
447 * @param _type		the type of resource
448 * @param _rid		the resource identifier
449 * @param _r		the resource to release
450 */
451METHOD int release_resource {
452	device_t	_dev;
453	device_t	_child;
454	int		_type;
455	int		_rid;
456	struct resource *_res;
457};
458
459/**
460 * @brief Install an interrupt handler
461 *
462 * This method is used to associate an interrupt handler function with
463 * an irq resource. When the interrupt triggers, the function @p _intr
464 * will be called with the value of @p _arg as its single
465 * argument. The value returned in @p *_cookiep is used to cancel the
466 * interrupt handler - the caller should save this value to use in a
467 * future call to BUS_TEARDOWN_INTR().
468 *
469 * @param _dev		the parent device of @p _child
470 * @param _child	the device which allocated the resource
471 * @param _irq		the resource representing the interrupt
472 * @param _flags	a set of bits from enum intr_type specifying
473 *			the class of interrupt
474 * @param _intr		the function to call when the interrupt
475 *			triggers
476 * @param _arg		a value to use as the single argument in calls
477 *			to @p _intr
478 * @param _cookiep	a pointer to a location to receive a cookie
479 *			value that may be used to remove the interrupt
480 *			handler
481 */
482METHOD int setup_intr {
483	device_t	_dev;
484	device_t	_child;
485	struct resource *_irq;
486	int		_flags;
487	driver_filter_t	*_filter;
488	driver_intr_t	*_intr;
489	void		*_arg;
490	void		**_cookiep;
491};
492
493/**
494 * @brief Uninstall an interrupt handler
495 *
496 * This method is used to disassociate an interrupt handler function
497 * with an irq resource. The value of @p _cookie must be the value
498 * returned from a previous call to BUS_SETUP_INTR().
499 *
500 * @param _dev		the parent device of @p _child
501 * @param _child	the device which allocated the resource
502 * @param _irq		the resource representing the interrupt
503 * @param _cookie	the cookie value returned when the interrupt
504 *			was originally registered
505 */
506METHOD int teardown_intr {
507	device_t	_dev;
508	device_t	_child;
509	struct resource	*_irq;
510	void		*_cookie;
511};
512
513/**
514 * @brief Suspend an interrupt handler
515 *
516 * This method is used to mark a handler as suspended in the case
517 * that the associated device is powered down and cannot be a source
518 * for the, typically shared, interrupt.
519 * The value of @p _irq must be the interrupt resource passed
520 * to a previous call to BUS_SETUP_INTR().
521 *
522 * @param _dev		the parent device of @p _child
523 * @param _child	the device which allocated the resource
524 * @param _irq		the resource representing the interrupt
525 */
526METHOD int suspend_intr {
527	device_t	_dev;
528	device_t	_child;
529	struct resource *_irq;
530} DEFAULT bus_generic_suspend_intr;
531
532/**
533 * @brief Resume an interrupt handler
534 *
535 * This method is used to clear suspended state of a handler when
536 * the associated device is powered up and can be an interrupt source
537 * again.
538 * The value of @p _irq must be the interrupt resource passed
539 * to a previous call to BUS_SETUP_INTR().
540 *
541 * @param _dev		the parent device of @p _child
542 * @param _child	the device which allocated the resource
543 * @param _irq		the resource representing the interrupt
544 */
545METHOD int resume_intr {
546	device_t	_dev;
547	device_t	_child;
548	struct resource *_irq;
549} DEFAULT bus_generic_resume_intr;
550
551/**
552 * @brief Define a resource which can be allocated with
553 * BUS_ALLOC_RESOURCE().
554 *
555 * This method is used by some buses (typically ISA) to allow a
556 * driver to describe a resource range that it would like to
557 * allocate. The resource defined by @p _type and @p _rid is defined
558 * to start at @p _start and to include @p _count indices in its
559 * range.
560 *
561 * @param _dev		the parent device of @p _child
562 * @param _child	the device which owns the resource
563 * @param _type		the type of resource
564 * @param _rid		the resource identifier
565 * @param _start	the start of the resource range
566 * @param _count	the size of the resource range
567 */
568METHOD int set_resource {
569	device_t	_dev;
570	device_t	_child;
571	int		_type;
572	int		_rid;
573	rman_res_t	_start;
574	rman_res_t	_count;
575};
576
577/**
578 * @brief Describe a resource
579 *
580 * This method allows a driver to examine the range used for a given
581 * resource without actually allocating it.
582 *
583 * @param _dev		the parent device of @p _child
584 * @param _child	the device which owns the resource
585 * @param _type		the type of resource
586 * @param _rid		the resource identifier
587 * @param _start	the address of a location to receive the start
588 *			index of the resource range
589 * @param _count	the address of a location to receive the size
590 *			of the resource range
591 */
592METHOD int get_resource {
593	device_t	_dev;
594	device_t	_child;
595	int		_type;
596	int		_rid;
597	rman_res_t	*_startp;
598	rman_res_t	*_countp;
599};
600
601/**
602 * @brief Delete a resource.
603 *
604 * Use this to delete a resource (possibly one previously added with
605 * BUS_SET_RESOURCE()).
606 *
607 * @param _dev		the parent device of @p _child
608 * @param _child	the device which owns the resource
609 * @param _type		the type of resource
610 * @param _rid		the resource identifier
611 */
612METHOD void delete_resource {
613	device_t	_dev;
614	device_t	_child;
615	int		_type;
616	int		_rid;
617};
618
619/**
620 * @brief Return a struct resource_list.
621 *
622 * Used by drivers which use bus_generic_rl_alloc_resource() etc. to
623 * implement their resource handling. It should return the resource
624 * list of the given child device.
625 *
626 * @param _dev		the parent device of @p _child
627 * @param _child	the device which owns the resource list
628 */
629METHOD struct resource_list * get_resource_list {
630	device_t	_dev;
631	device_t	_child;
632} DEFAULT bus_generic_get_resource_list;
633
634/**
635 * @brief Is the hardware described by @p _child still attached to the
636 * system?
637 *
638 * This method should return 0 if the device is not present.  It
639 * should return -1 if it is present.  Any errors in determining
640 * should be returned as a normal errno value.  Client drivers are to
641 * assume that the device is present, even if there is an error
642 * determining if it is there.  Buses are to try to avoid returning
643 * errors, but newcard will return an error if the device fails to
644 * implement this method.
645 *
646 * @param _dev		the parent device of @p _child
647 * @param _child	the device which is being examined
648 */
649METHOD int child_present {
650	device_t	_dev;
651	device_t	_child;
652} DEFAULT bus_generic_child_present;
653
654/**
655 * @brief Returns the pnp info for this device.
656 *
657 * Return it as a string.  If the storage is insufficient for the
658 * string, then return EOVERFLOW.
659 *
660 * The string must be formatted as a space-separated list of
661 * name=value pairs.  Names may only contain alphanumeric characters,
662 * underscores ('_') and hyphens ('-').  Values can contain any
663 * non-whitespace characters.  Values containing whitespace can be
664 * quoted with double quotes ('"').  Double quotes and backslashes in
665 * quoted values can be escaped with backslashes ('\').
666 *
667 * @param _dev		the parent device of @p _child
668 * @param _child	the device which is being examined
669 * @param _buf		the address of a buffer to receive the pnp
670 *			string
671 * @param _buflen	the size of the buffer pointed to by @p _buf
672 */
673METHOD int child_pnpinfo_str {
674	device_t	_dev;
675	device_t	_child;
676	char		*_buf;
677	size_t		_buflen;
678};
679
680/**
681 * @brief Returns the location for this device.
682 *
683 * Return it as a string.  If the storage is insufficient for the
684 * string, then return EOVERFLOW.
685 *
686 * The string must be formatted as a space-separated list of
687 * name=value pairs.  Names may only contain alphanumeric characters,
688 * underscores ('_') and hyphens ('-').  Values can contain any
689 * non-whitespace characters.  Values containing whitespace can be
690 * quoted with double quotes ('"').  Double quotes and backslashes in
691 * quoted values can be escaped with backslashes ('\').
692 *
693 * @param _dev		the parent device of @p _child
694 * @param _child	the device which is being examined
695 * @param _buf		the address of a buffer to receive the location
696 *			string
697 * @param _buflen	the size of the buffer pointed to by @p _buf
698 */
699METHOD int child_location_str {
700	device_t	_dev;
701	device_t	_child;
702	char		*_buf;
703	size_t		_buflen;
704};
705
706/**
707 * @brief Allow drivers to request that an interrupt be bound to a specific
708 * CPU.
709 *
710 * @param _dev		the parent device of @p _child
711 * @param _child	the device which allocated the resource
712 * @param _irq		the resource representing the interrupt
713 * @param _cpu		the CPU to bind the interrupt to
714 */
715METHOD int bind_intr {
716	device_t	_dev;
717	device_t	_child;
718	struct resource *_irq;
719	int		_cpu;
720} DEFAULT bus_generic_bind_intr;
721
722/**
723 * @brief Allow (bus) drivers to specify the trigger mode and polarity
724 * of the specified interrupt.
725 *
726 * @param _dev		the bus device
727 * @param _irq		the interrupt number to modify
728 * @param _trig		the trigger mode required
729 * @param _pol		the interrupt polarity required
730 */
731METHOD int config_intr {
732	device_t	_dev;
733	int		_irq;
734	enum intr_trigger _trig;
735	enum intr_polarity _pol;
736} DEFAULT bus_generic_config_intr;
737
738/**
739 * @brief Allow drivers to associate a description with an active
740 * interrupt handler.
741 *
742 * @param _dev		the parent device of @p _child
743 * @param _child	the device which allocated the resource
744 * @param _irq		the resource representing the interrupt
745 * @param _cookie	the cookie value returned when the interrupt
746 *			was originally registered
747 * @param _descr	the description to associate with the interrupt
748 */
749METHOD int describe_intr {
750	device_t	_dev;
751	device_t	_child;
752	struct resource *_irq;
753	void		*_cookie;
754	const char	*_descr;
755} DEFAULT bus_generic_describe_intr;
756
757/**
758 * @brief Notify a (bus) driver about a child that the hints mechanism
759 * believes it has discovered.
760 *
761 * The bus is responsible for then adding the child in the right order
762 * and discovering other things about the child.  The bus driver is
763 * free to ignore this hint, to do special things, etc.  It is all up
764 * to the bus driver to interpret.
765 *
766 * This method is only called in response to the parent bus asking for
767 * hinted devices to be enumerated.
768 *
769 * @param _dev		the bus device
770 * @param _dname	the name of the device w/o unit numbers
771 * @param _dunit	the unit number of the device
772 */
773METHOD void hinted_child {
774	device_t	_dev;
775	const char	*_dname;
776	int		_dunit;
777};
778
779/**
780 * @brief Returns bus_dma_tag_t for use w/ devices on the bus.
781 *
782 * @param _dev		the parent device of @p _child
783 * @param _child	the device to which the tag will belong
784 */
785METHOD bus_dma_tag_t get_dma_tag {
786	device_t	_dev;
787	device_t	_child;
788} DEFAULT bus_generic_get_dma_tag;
789
790/**
791 * @brief Returns bus_space_tag_t for use w/ devices on the bus.
792 *
793 * @param _dev		the parent device of @p _child
794 * @param _child	the device to which the tag will belong
795 */
796METHOD bus_space_tag_t get_bus_tag {
797	device_t	_dev;
798	device_t	_child;
799} DEFAULT bus_generic_get_bus_tag;
800
801/**
802 * @brief Allow the bus to determine the unit number of a device.
803 *
804 * @param _dev		the parent device of @p _child
805 * @param _child	the device whose unit is to be wired
806 * @param _name		the name of the device's new devclass
807 * @param _unitp	a pointer to the device's new unit value
808 */
809METHOD void hint_device_unit {
810	device_t	_dev;
811	device_t	_child;
812	const char	*_name;
813	int		*_unitp;
814};
815
816/**
817 * @brief Notify a bus that the bus pass level has been changed
818 *
819 * @param _dev		the bus device
820 */
821METHOD void new_pass {
822	device_t	_dev;
823} DEFAULT bus_generic_new_pass;
824
825/**
826 * @brief Notify a bus that specified child's IRQ should be remapped.
827 *
828 * @param _dev		the bus device
829 * @param _child	the child device
830 * @param _irq		the irq number
831 */
832METHOD int remap_intr {
833	device_t	_dev;
834	device_t	_child;
835	u_int		_irq;
836} DEFAULT null_remap_intr;
837
838/**
839 * @brief Suspend a given child
840 *
841 * @param _dev		the parent device of @p _child
842 * @param _child	the device to suspend
843 */
844METHOD int suspend_child {
845	device_t	_dev;
846	device_t	_child;
847} DEFAULT bus_generic_suspend_child;
848
849/**
850 * @brief Resume a given child
851 *
852 * @param _dev		the parent device of @p _child
853 * @param _child	the device to resume
854 */
855METHOD int resume_child {
856	device_t	_dev;
857	device_t	_child;
858} DEFAULT bus_generic_resume_child;
859
860/**
861 * @brief Get the VM domain handle for the given bus and child.
862 *
863 * @param _dev		the bus device
864 * @param _child	the child device
865 * @param _domain	a pointer to the bus's domain handle identifier
866 */
867METHOD int get_domain {
868	device_t	_dev;
869	device_t	_child;
870	int		*_domain;
871} DEFAULT bus_generic_get_domain;
872
873/**
874 * @brief Request a set of CPUs
875 *
876 * @param _dev		the bus device
877 * @param _child	the child device
878 * @param _op		type of CPUs to request
879 * @param _setsize	the size of the set passed in _cpuset
880 * @param _cpuset	a pointer to a cpuset to receive the requested
881 *			set of CPUs
882 */
883METHOD int get_cpus {
884	device_t	_dev;
885	device_t	_child;
886	enum cpu_sets	_op;
887	size_t		_setsize;
888	struct _cpuset	*_cpuset;
889} DEFAULT bus_generic_get_cpus;
890
891/**
892 * @brief Prepares the given child of the bus for reset
893 *
894 * Typically bus detaches or suspends children' drivers, and then
895 * calls this method to save bus-specific information, for instance,
896 * PCI config space, which is damaged by reset.
897 *
898 * The bus_helper_reset_prepare() helper is provided to ease
899 * implementing bus reset methods.
900 *
901 * @param _dev		the bus device
902 * @param _child	the child device
903 */
904METHOD int reset_prepare {
905	device_t _dev;
906	device_t _child;
907} DEFAULT null_reset_prepare;
908
909/**
910 * @brief Restores the child operations after the reset
911 *
912 * The bus_helper_reset_post() helper is provided to ease
913 * implementing bus reset methods.
914 *
915 * @param _dev		the bus device
916 * @param _child	the child device
917 */
918METHOD int reset_post {
919	device_t _dev;
920	device_t _child;
921} DEFAULT null_reset_post;
922
923/**
924 * @brief Performs reset of the child
925 *
926 * @param _dev		the bus device
927 * @param _child	the child device
928 * @param _flags	DEVF_RESET_ flags
929 */
930METHOD int reset_child {
931	device_t _dev;
932	device_t _child;
933	int _flags;
934};
935