xref: /freebsd/sys/kern/bus_if.m (revision 77013d11e6483b970af25e13c9b892075742f7e5)
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, appended to @p _sb
658 *
659 * The string must be formatted as a space-separated list of
660 * name=value pairs.  Names may only contain alphanumeric characters,
661 * underscores ('_') and hyphens ('-').  Values can contain any
662 * non-whitespace characters.  Values containing whitespace can be
663 * quoted with double quotes ('"').  Double quotes and backslashes in
664 * quoted values can be escaped with backslashes ('\').
665 *
666 * @param _dev		the parent device of @p _child
667 * @param _child	the device which is being examined
668 * @param _sb		sbuf for results string
669 */
670METHOD int child_pnpinfo {
671	device_t	_dev;
672	device_t	_child;
673	struct sbuf	*_sb;
674} DEFAULT bus_generic_child_pnpinfo;
675
676/**
677 * @brief Returns the location for this device.
678 *
679 * Return it as a string, appended to @p _sb
680 *
681 * The string must be formatted as a space-separated list of
682 * name=value pairs.  Names may only contain alphanumeric characters,
683 * underscores ('_') and hyphens ('-').  Values can contain any
684 * non-whitespace characters.  Values containing whitespace can be
685 * quoted with double quotes ('"').  Double quotes and backslashes in
686 * quoted values can be escaped with backslashes ('\').
687 *
688 * @param _dev		the parent device of @p _child
689 * @param _child	the device which is being examined
690 * @param _sb		sbuf for results string
691 */
692METHOD int child_location {
693	device_t	_dev;
694	device_t	_child;
695	struct sbuf	*_sb;
696} DEFAULT bus_generic_child_location;
697
698/**
699 * @brief Allow drivers to request that an interrupt be bound to a specific
700 * CPU.
701 *
702 * @param _dev		the parent device of @p _child
703 * @param _child	the device which allocated the resource
704 * @param _irq		the resource representing the interrupt
705 * @param _cpu		the CPU to bind the interrupt to
706 */
707METHOD int bind_intr {
708	device_t	_dev;
709	device_t	_child;
710	struct resource *_irq;
711	int		_cpu;
712} DEFAULT bus_generic_bind_intr;
713
714/**
715 * @brief Allow (bus) drivers to specify the trigger mode and polarity
716 * of the specified interrupt.
717 *
718 * @param _dev		the bus device
719 * @param _irq		the interrupt number to modify
720 * @param _trig		the trigger mode required
721 * @param _pol		the interrupt polarity required
722 */
723METHOD int config_intr {
724	device_t	_dev;
725	int		_irq;
726	enum intr_trigger _trig;
727	enum intr_polarity _pol;
728} DEFAULT bus_generic_config_intr;
729
730/**
731 * @brief Allow drivers to associate a description with an active
732 * interrupt handler.
733 *
734 * @param _dev		the parent device of @p _child
735 * @param _child	the device which allocated the resource
736 * @param _irq		the resource representing the interrupt
737 * @param _cookie	the cookie value returned when the interrupt
738 *			was originally registered
739 * @param _descr	the description to associate with the interrupt
740 */
741METHOD int describe_intr {
742	device_t	_dev;
743	device_t	_child;
744	struct resource *_irq;
745	void		*_cookie;
746	const char	*_descr;
747} DEFAULT bus_generic_describe_intr;
748
749/**
750 * @brief Notify a (bus) driver about a child that the hints mechanism
751 * believes it has discovered.
752 *
753 * The bus is responsible for then adding the child in the right order
754 * and discovering other things about the child.  The bus driver is
755 * free to ignore this hint, to do special things, etc.  It is all up
756 * to the bus driver to interpret.
757 *
758 * This method is only called in response to the parent bus asking for
759 * hinted devices to be enumerated.
760 *
761 * @param _dev		the bus device
762 * @param _dname	the name of the device w/o unit numbers
763 * @param _dunit	the unit number of the device
764 */
765METHOD void hinted_child {
766	device_t	_dev;
767	const char	*_dname;
768	int		_dunit;
769};
770
771/**
772 * @brief Returns bus_dma_tag_t for use w/ devices on the bus.
773 *
774 * @param _dev		the parent device of @p _child
775 * @param _child	the device to which the tag will belong
776 */
777METHOD bus_dma_tag_t get_dma_tag {
778	device_t	_dev;
779	device_t	_child;
780} DEFAULT bus_generic_get_dma_tag;
781
782/**
783 * @brief Returns bus_space_tag_t for use w/ devices on the bus.
784 *
785 * @param _dev		the parent device of @p _child
786 * @param _child	the device to which the tag will belong
787 */
788METHOD bus_space_tag_t get_bus_tag {
789	device_t	_dev;
790	device_t	_child;
791} DEFAULT bus_generic_get_bus_tag;
792
793/**
794 * @brief Allow the bus to determine the unit number of a device.
795 *
796 * @param _dev		the parent device of @p _child
797 * @param _child	the device whose unit is to be wired
798 * @param _name		the name of the device's new devclass
799 * @param _unitp	a pointer to the device's new unit value
800 */
801METHOD void hint_device_unit {
802	device_t	_dev;
803	device_t	_child;
804	const char	*_name;
805	int		*_unitp;
806};
807
808/**
809 * @brief Notify a bus that the bus pass level has been changed
810 *
811 * @param _dev		the bus device
812 */
813METHOD void new_pass {
814	device_t	_dev;
815} DEFAULT bus_generic_new_pass;
816
817/**
818 * @brief Notify a bus that specified child's IRQ should be remapped.
819 *
820 * @param _dev		the bus device
821 * @param _child	the child device
822 * @param _irq		the irq number
823 */
824METHOD int remap_intr {
825	device_t	_dev;
826	device_t	_child;
827	u_int		_irq;
828} DEFAULT null_remap_intr;
829
830/**
831 * @brief Suspend a given child
832 *
833 * @param _dev		the parent device of @p _child
834 * @param _child	the device to suspend
835 */
836METHOD int suspend_child {
837	device_t	_dev;
838	device_t	_child;
839} DEFAULT bus_generic_suspend_child;
840
841/**
842 * @brief Resume a given child
843 *
844 * @param _dev		the parent device of @p _child
845 * @param _child	the device to resume
846 */
847METHOD int resume_child {
848	device_t	_dev;
849	device_t	_child;
850} DEFAULT bus_generic_resume_child;
851
852/**
853 * @brief Get the VM domain handle for the given bus and child.
854 *
855 * @param _dev		the bus device
856 * @param _child	the child device
857 * @param _domain	a pointer to the bus's domain handle identifier
858 */
859METHOD int get_domain {
860	device_t	_dev;
861	device_t	_child;
862	int		*_domain;
863} DEFAULT bus_generic_get_domain;
864
865/**
866 * @brief Request a set of CPUs
867 *
868 * @param _dev		the bus device
869 * @param _child	the child device
870 * @param _op		type of CPUs to request
871 * @param _setsize	the size of the set passed in _cpuset
872 * @param _cpuset	a pointer to a cpuset to receive the requested
873 *			set of CPUs
874 */
875METHOD int get_cpus {
876	device_t	_dev;
877	device_t	_child;
878	enum cpu_sets	_op;
879	size_t		_setsize;
880	struct _cpuset	*_cpuset;
881} DEFAULT bus_generic_get_cpus;
882
883/**
884 * @brief Prepares the given child of the bus for reset
885 *
886 * Typically bus detaches or suspends children' drivers, and then
887 * calls this method to save bus-specific information, for instance,
888 * PCI config space, which is damaged by reset.
889 *
890 * The bus_helper_reset_prepare() helper is provided to ease
891 * implementing bus reset methods.
892 *
893 * @param _dev		the bus device
894 * @param _child	the child device
895 */
896METHOD int reset_prepare {
897	device_t _dev;
898	device_t _child;
899} DEFAULT null_reset_prepare;
900
901/**
902 * @brief Restores the child operations after the reset
903 *
904 * The bus_helper_reset_post() helper is provided to ease
905 * implementing bus reset methods.
906 *
907 * @param _dev		the bus device
908 * @param _child	the child device
909 */
910METHOD int reset_post {
911	device_t _dev;
912	device_t _child;
913} DEFAULT null_reset_post;
914
915/**
916 * @brief Performs reset of the child
917 *
918 * @param _dev		the bus device
919 * @param _child	the child device
920 * @param _flags	DEVF_RESET_ flags
921 */
922METHOD int reset_child {
923	device_t _dev;
924	device_t _child;
925	int _flags;
926};
927