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