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