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