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