bus_if.m revision 295755
1139804Simp#-
2133588Simp# Copyright (c) 1998-2004 Doug Rabson
336973Sdfr# All rights reserved.
436973Sdfr#
536973Sdfr# Redistribution and use in source and binary forms, with or without
636973Sdfr# modification, are permitted provided that the following conditions
736973Sdfr# are met:
836973Sdfr# 1. Redistributions of source code must retain the above copyright
936973Sdfr#    notice, this list of conditions and the following disclaimer.
1036973Sdfr# 2. Redistributions in binary form must reproduce the above copyright
1136973Sdfr#    notice, this list of conditions and the following disclaimer in the
1236973Sdfr#    documentation and/or other materials provided with the distribution.
1336973Sdfr#
1436973Sdfr# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1536973Sdfr# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1636973Sdfr# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1736973Sdfr# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1836973Sdfr# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1936973Sdfr# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2036973Sdfr# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2136973Sdfr# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2236973Sdfr# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2336973Sdfr# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2436973Sdfr# SUCH DAMAGE.
2536973Sdfr#
2650477Speter# $FreeBSD: head/sys/kern/bus_if.m 295755 2016-02-18 13:00:04Z zbb $
2736973Sdfr#
2836973Sdfr
29212544Savg#include <sys/types.h>
30212544Savg#include <sys/systm.h>
3159093Sdfr#include <sys/bus.h>
3259093Sdfr
33132354Sdfr/**
34132354Sdfr * @defgroup BUS bus - KObj methods for drivers of devices with children
35132354Sdfr * @brief A set of methods required device drivers that support
36132354Sdfr * child devices.
37132354Sdfr * @{
38132354Sdfr */
3941017SnsouchINTERFACE bus;
4036973Sdfr
4136973Sdfr#
4246913Sdfr# Default implementations of some methods.
4346913Sdfr#
4446913SdfrCODE {
4546913Sdfr	static struct resource *
4646913Sdfr	null_alloc_resource(device_t dev, device_t child,
47294883Sjhibbits	    int type, int *rid, rman_res_t start, rman_res_t end,
48294883Sjhibbits	    rman_res_t count, u_int flags)
4946913Sdfr	{
50100421Simp	    return (0);
5146913Sdfr	}
52209154Smav
53209154Smav	static int
54209154Smav	null_remap_intr(device_t bus, device_t dev, u_int irq)
55209154Smav	{
56209154Smav
57209154Smav		if (dev != NULL)
58209154Smav			return (BUS_REMAP_INTR(dev, NULL, irq));
59209154Smav		return (ENXIO);
60209154Smav	}
61212544Savg
62212544Savg	static device_t
63212544Savg	null_add_child(device_t bus, int order, const char *name,
64212544Savg	    int unit)
65212544Savg	{
66212544Savg
67212544Savg		panic("bus_add_child is not implemented");
68212544Savg	}
6946913Sdfr};
7046913Sdfr
71132354Sdfr/**
72132354Sdfr * @brief Print a description of a child device
73132354Sdfr *
74132354Sdfr * This is called from system code which prints out a description of a
75132354Sdfr * device. It should describe the attachment that the child has with
76132354Sdfr * the parent. For instance the TurboLaser bus prints which node the
77132354Sdfr * device is attached to. See bus_generic_print_child() for more 
78132354Sdfr * information.
79132354Sdfr *
80132354Sdfr * @param _dev		the device whose child is being printed
81132354Sdfr * @param _child	the child device to describe
82132354Sdfr *
83132354Sdfr * @returns		the number of characters output.
84132354Sdfr */
8549195SmdoddMETHOD int print_child {
86132354Sdfr	device_t _dev;
87132354Sdfr	device_t _child;
88112588Smdodd} DEFAULT bus_generic_print_child;
8936973Sdfr
90132354Sdfr/**
91132354Sdfr * @brief Print a notification about an unprobed child device.
92132354Sdfr *
93132354Sdfr * Called for each child device that did not succeed in probing for a
94132354Sdfr * driver.
95132354Sdfr *
96132354Sdfr * @param _dev		the device whose child was being probed
97132354Sdfr * @param _child	the child device which failed to probe
98132354Sdfr */   
9948754SdfrMETHOD void probe_nomatch {
100132354Sdfr        device_t _dev;
101132354Sdfr        device_t _child;
10248754Sdfr};
10348754Sdfr
104132354Sdfr/**
105132354Sdfr * @brief Read the value of a bus-specific attribute of a device
106132354Sdfr *
107132354Sdfr * This method, along with BUS_WRITE_IVAR() manages a bus-specific set
108132354Sdfr * of instance variables of a child device.  The intention is that
109132354Sdfr * each different type of bus defines a set of appropriate instance
110132354Sdfr * variables (such as ports and irqs for ISA bus etc.)
111132354Sdfr *
112132354Sdfr * This information could be given to the child device as a struct but
113132354Sdfr * that makes it hard for a bus to add or remove variables without
114132354Sdfr * forcing an edit and recompile for all drivers which may not be
115132354Sdfr * possible for vendor supplied binary drivers.
116132354Sdfr *
117132354Sdfr * This method copies the value of an instance variable to the
118132354Sdfr * location specified by @p *_result.
119132354Sdfr * 
120132354Sdfr * @param _dev		the device whose child was being examined
121132354Sdfr * @param _child	the child device whose instance variable is
122132354Sdfr *			being read
123132354Sdfr * @param _index	the instance variable to read
124132354Sdfr * @param _result	a loction to recieve the instance variable
125132354Sdfr *			value
126132354Sdfr * 
127132354Sdfr * @retval 0		success
128132354Sdfr * @retval ENOENT	no such instance variable is supported by @p
129132354Sdfr *			_dev 
130132354Sdfr */
13136973SdfrMETHOD int read_ivar {
13295201Smarkm	device_t _dev;
13395201Smarkm	device_t _child;
134132354Sdfr	int _index;
13595201Smarkm	uintptr_t *_result;
13636973Sdfr};
13736973Sdfr
138132354Sdfr/**
139132354Sdfr * @brief Write the value of a bus-specific attribute of a device
140132354Sdfr * 
141132354Sdfr * This method sets the value of an instance variable to @p _value.
142132354Sdfr * 
143132354Sdfr * @param _dev		the device whose child was being updated
144132354Sdfr * @param _child	the child device whose instance variable is
145132354Sdfr *			being written
146132354Sdfr * @param _index	the instance variable to write
147132354Sdfr * @param _value	the value to write to that instance variable
148132354Sdfr * 
149132354Sdfr * @retval 0		success
150132354Sdfr * @retval ENOENT	no such instance variable is supported by @p
151132354Sdfr *			_dev 
152132354Sdfr * @retval EINVAL	the instance variable was recognised but
153132354Sdfr *			contains a read-only value
154132354Sdfr */
15536973SdfrMETHOD int write_ivar {
15695201Smarkm	device_t _dev;
15795201Smarkm	device_t _child;
15895201Smarkm	int _indx;
15995201Smarkm	uintptr_t _value;
16036973Sdfr};
16136973Sdfr
162132354Sdfr/**
163239512Sjhb * @brief Notify a bus that a child was deleted
164239512Sjhb *
165239512Sjhb * Called at the beginning of device_delete_child() to allow the parent
166239512Sjhb * to teardown any bus-specific state for the child.
167239512Sjhb * 
168239512Sjhb * @param _dev		the device whose child is being deleted
169239512Sjhb * @param _child	the child device which is being deleted
170239512Sjhb */
171239512SjhbMETHOD void child_deleted {
172239512Sjhb	device_t _dev;
173239512Sjhb	device_t _child;
174239512Sjhb};
175239512Sjhb
176239512Sjhb/**
177132354Sdfr * @brief Notify a bus that a child was detached
178132354Sdfr *
179132354Sdfr * Called after the child's DEVICE_DETACH() method to allow the parent
180132354Sdfr * to reclaim any resources allocated on behalf of the child.
181132354Sdfr * 
182132354Sdfr * @param _dev		the device whose child changed state
183132354Sdfr * @param _child	the child device which changed state
184132354Sdfr */
18545107SdfrMETHOD void child_detached {
18695201Smarkm	device_t _dev;
18795201Smarkm	device_t _child;
18845107Sdfr};
18945107Sdfr
190132354Sdfr/**
191132354Sdfr * @brief Notify a bus that a new driver was added
192132354Sdfr * 
193132354Sdfr * Called when a new driver is added to the devclass which owns this
194132354Sdfr * bus. The generic implementation of this method attempts to probe and
195132354Sdfr * attach any un-matched children of the bus.
196132354Sdfr * 
197132354Sdfr * @param _dev		the device whose devclass had a new driver
198132354Sdfr *			added to it
199132354Sdfr * @param _driver	the new driver which was added
200132354Sdfr */
20145720SpeterMETHOD void driver_added {
20295201Smarkm	device_t _dev;
20395201Smarkm	driver_t *_driver;
20452045Simp} DEFAULT bus_generic_driver_added;
20545720Speter
206132354Sdfr/**
207132354Sdfr * @brief Create a new child device
208132354Sdfr *
209132354Sdfr * For busses which use use drivers supporting DEVICE_IDENTIFY() to
210132354Sdfr * enumerate their devices, this method is used to create new
211132354Sdfr * device instances. The new device will be added after the last
212290117Simp * existing child with the same order. Implementations of bus_add_child
213290117Simp * call device_add_child_ordered to add the child and often add
214290117Simp * a suitable ivar to the device specific to that bus.
215132354Sdfr * 
216132354Sdfr * @param _dev		the bus device which will be the parent of the
217132354Sdfr *			new child device
218132354Sdfr * @param _order	a value which is used to partially sort the
219132354Sdfr *			children of @p _dev - devices created using
220132354Sdfr *			lower values of @p _order appear first in @p
221132354Sdfr *			_dev's list of children
222132354Sdfr * @param _name		devclass name for new device or @c NULL if not
223132354Sdfr *			specified
224132354Sdfr * @param _unit		unit number for new device or @c -1 if not
225132354Sdfr *			specified
226132354Sdfr */
22747178SdfrMETHOD device_t add_child {
22895201Smarkm	device_t _dev;
229212413Savg	u_int _order;
23095201Smarkm	const char *_name;
23195201Smarkm	int _unit;
232212544Savg} DEFAULT null_add_child;
23347178Sdfr
234132354Sdfr/**
235132354Sdfr * @brief Allocate a system resource
236132354Sdfr *
237132354Sdfr * This method is called by child devices of a bus to allocate resources.
238132354Sdfr * The types are defined in <machine/resource.h>; the meaning of the
239132354Sdfr * resource-ID field varies from bus to bus (but @p *rid == 0 is always
240132354Sdfr * valid if the resource type is). If a resource was allocated and the
241132354Sdfr * caller did not use the RF_ACTIVE to specify that it should be
242132354Sdfr * activated immediately, the caller is responsible for calling
243132354Sdfr * BUS_ACTIVATE_RESOURCE() when it actually uses the resource.
244132354Sdfr *
245132354Sdfr * @param _dev		the parent device of @p _child
246132354Sdfr * @param _child	the device which is requesting an allocation
247132354Sdfr * @param _type		the type of resource to allocate
248132354Sdfr * @param _rid		a pointer to the resource identifier
249132354Sdfr * @param _start	hint at the start of the resource range - pass
250132354Sdfr *			@c 0UL for any start address
251132354Sdfr * @param _end		hint at the end of the resource range - pass
252132354Sdfr *			@c ~0UL for any end address
253132354Sdfr * @param _count	hint at the size of range required - pass @c 1
254132354Sdfr *			for any size
255132354Sdfr * @param _flags	any extra flags to control the resource
256132354Sdfr *			allocation - see @c RF_XXX flags in
257132354Sdfr *			<sys/rman.h> for details
258132354Sdfr * 
259132354Sdfr * @returns		the resource which was allocated or @c NULL if no
260132354Sdfr *			resource could be allocated
261132354Sdfr */
26241153SwollmanMETHOD struct resource * alloc_resource {
26395201Smarkm	device_t	_dev;
26495201Smarkm	device_t	_child;
26595201Smarkm	int		_type;
26695201Smarkm	int	       *_rid;
267294883Sjhibbits	rman_res_t	_start;
268294883Sjhibbits	rman_res_t	_end;
269294883Sjhibbits	rman_res_t	_count;
27095201Smarkm	u_int		_flags;
27146913Sdfr} DEFAULT null_alloc_resource;
27237592Sdfr
273132354Sdfr/**
274132354Sdfr * @brief Activate a resource
275132354Sdfr *
276132354Sdfr * Activate a resource previously allocated with
277132354Sdfr * BUS_ALLOC_RESOURCE(). This may for instance map a memory region
278132354Sdfr * into the kernel's virtual address space.
279132354Sdfr *
280132354Sdfr * @param _dev		the parent device of @p _child
281132354Sdfr * @param _child	the device which allocated the resource
282132354Sdfr * @param _type		the type of resource
283132354Sdfr * @param _rid		the resource identifier
284132354Sdfr * @param _r		the resource to activate
285132354Sdfr */
28641153SwollmanMETHOD int activate_resource {
28795201Smarkm	device_t	_dev;
28895201Smarkm	device_t	_child;
28995201Smarkm	int		_type;
29095201Smarkm	int		_rid;
29195201Smarkm	struct resource *_r;
29241153Swollman};
29341153Swollman
294132354Sdfr/**
295132354Sdfr * @brief Deactivate a resource
296132354Sdfr *
297132354Sdfr * Deactivate a resource previously allocated with
298132354Sdfr * BUS_ALLOC_RESOURCE(). This may for instance unmap a memory region
299132354Sdfr * from the kernel's virtual address space.
300132354Sdfr *
301132354Sdfr * @param _dev		the parent device of @p _child
302132354Sdfr * @param _child	the device which allocated the resource
303132354Sdfr * @param _type		the type of resource
304132354Sdfr * @param _rid		the resource identifier
305132354Sdfr * @param _r		the resource to deactivate
306132354Sdfr */
30741153SwollmanMETHOD int deactivate_resource {
30895201Smarkm	device_t	_dev;
30995201Smarkm	device_t	_child;
31095201Smarkm	int		_type;
31195201Smarkm	int		_rid;
31295201Smarkm	struct resource *_r;
31341153Swollman};
31441153Swollman
315132354Sdfr/**
316221231Sjhb * @brief Adjust a resource
317221231Sjhb *
318221231Sjhb * Adjust the start and/or end of a resource allocated by
319221231Sjhb * BUS_ALLOC_RESOURCE.  At least part of the new address range must overlap
320221231Sjhb * with the existing address range.  If the successful, the resource's range
321221231Sjhb * will be adjusted to [start, end] on return.
322221231Sjhb *
323221231Sjhb * @param _dev		the parent device of @p _child
324221231Sjhb * @param _child	the device which allocated the resource
325221231Sjhb * @param _type		the type of resource
326221231Sjhb * @param _res		the resource to adjust
327221231Sjhb * @param _start	the new starting address of the resource range
328221231Sjhb * @param _end		the new ending address of the resource range
329221231Sjhb */
330221231SjhbMETHOD int adjust_resource {
331221231Sjhb	device_t	_dev;
332221231Sjhb	device_t	_child;
333221231Sjhb	int		_type;
334221231Sjhb	struct resource *_res;
335294883Sjhibbits	rman_res_t	_start;
336294883Sjhibbits	rman_res_t	_end;
337221231Sjhb};
338221231Sjhb
339221231Sjhb/**
340132354Sdfr * @brief Release a resource
341132354Sdfr *
342132354Sdfr * Free a resource allocated by the BUS_ALLOC_RESOURCE.  The @p _rid
343132354Sdfr * value must be the same as the one returned by BUS_ALLOC_RESOURCE()
344132354Sdfr * (which is not necessarily the same as the one the client passed).
345132354Sdfr *
346132354Sdfr * @param _dev		the parent device of @p _child
347132354Sdfr * @param _child	the device which allocated the resource
348132354Sdfr * @param _type		the type of resource
349132354Sdfr * @param _rid		the resource identifier
350132354Sdfr * @param _r		the resource to release
351132354Sdfr */
35241153SwollmanMETHOD int release_resource {
35395201Smarkm	device_t	_dev;
35495201Smarkm	device_t	_child;
35595201Smarkm	int		_type;
35695201Smarkm	int		_rid;
35795201Smarkm	struct resource *_res;
35837592Sdfr};
35941153Swollman
360132354Sdfr/**
361132354Sdfr * @brief Install an interrupt handler
362132354Sdfr *
363132354Sdfr * This method is used to associate an interrupt handler function with
364132354Sdfr * an irq resource. When the interrupt triggers, the function @p _intr
365132354Sdfr * will be called with the value of @p _arg as its single
366132354Sdfr * argument. The value returned in @p *_cookiep is used to cancel the
367132354Sdfr * interrupt handler - the caller should save this value to use in a
368132354Sdfr * future call to BUS_TEARDOWN_INTR().
369132354Sdfr * 
370132354Sdfr * @param _dev		the parent device of @p _child
371132354Sdfr * @param _child	the device which allocated the resource
372132354Sdfr * @param _irq		the resource representing the interrupt
373132354Sdfr * @param _flags	a set of bits from enum intr_type specifying
374132354Sdfr *			the class of interrupt
375132354Sdfr * @param _intr		the function to call when the interrupt
376132354Sdfr *			triggers
377132354Sdfr * @param _arg		a value to use as the single argument in calls
378132354Sdfr *			to @p _intr
379132354Sdfr * @param _cookiep	a pointer to a location to recieve a cookie
380132354Sdfr *			value that may be used to remove the interrupt
381132354Sdfr *			handler
382132354Sdfr */
38341153SwollmanMETHOD int setup_intr {
38495201Smarkm	device_t	_dev;
38595201Smarkm	device_t	_child;
38695201Smarkm	struct resource *_irq;
38795201Smarkm	int		_flags;
388166901Spiso	driver_filter_t	*_filter;
38995201Smarkm	driver_intr_t	*_intr;
39095201Smarkm	void		*_arg;
39195201Smarkm	void		**_cookiep;
39241153Swollman};
39341153Swollman
394132354Sdfr/**
395132354Sdfr * @brief Uninstall an interrupt handler
396132354Sdfr *
397132354Sdfr * This method is used to disassociate an interrupt handler function
398132354Sdfr * with an irq resource. The value of @p _cookie must be the value
399132354Sdfr * returned from a previous call to BUS_SETUP_INTR().
400132354Sdfr * 
401132354Sdfr * @param _dev		the parent device of @p _child
402132354Sdfr * @param _child	the device which allocated the resource
403132354Sdfr * @param _irq		the resource representing the interrupt
404132354Sdfr * @param _cookie	the cookie value returned when the interrupt
405132354Sdfr *			was originally registered
406132354Sdfr */
40741153SwollmanMETHOD int teardown_intr {
40895201Smarkm	device_t	_dev;
40995201Smarkm	device_t	_child;
41095201Smarkm	struct resource	*_irq;
41195201Smarkm	void		*_cookie;
41241153Swollman};
41352174Sdfr
414132354Sdfr/**
415132354Sdfr * @brief Define a resource which can be allocated with
416132354Sdfr * BUS_ALLOC_RESOURCE().
417132354Sdfr *
418132354Sdfr * This method is used by some busses (typically ISA) to allow a
419132354Sdfr * driver to describe a resource range that it would like to
420132354Sdfr * allocate. The resource defined by @p _type and @p _rid is defined
421132354Sdfr * to start at @p _start and to include @p _count indices in its
422132354Sdfr * range.
423132354Sdfr * 
424132354Sdfr * @param _dev		the parent device of @p _child
425132354Sdfr * @param _child	the device which owns the resource
426132354Sdfr * @param _type		the type of resource
427132354Sdfr * @param _rid		the resource identifier
428132354Sdfr * @param _start	the start of the resource range
429132354Sdfr * @param _count	the size of the resource range
430132354Sdfr */
43152174SdfrMETHOD int set_resource {
43295201Smarkm	device_t	_dev;
43395201Smarkm	device_t	_child;
43495201Smarkm	int		_type;
43595201Smarkm	int		_rid;
436294883Sjhibbits	rman_res_t	_start;
437294883Sjhibbits	rman_res_t	_count;
43852174Sdfr};
43952174Sdfr
440132354Sdfr/**
441132354Sdfr * @brief Describe a resource
442132354Sdfr *
443132354Sdfr * This method allows a driver to examine the range used for a given
444132354Sdfr * resource without actually allocating it.
445132354Sdfr * 
446132354Sdfr * @param _dev		the parent device of @p _child
447132354Sdfr * @param _child	the device which owns the resource
448132354Sdfr * @param _type		the type of resource
449132354Sdfr * @param _rid		the resource identifier
450132354Sdfr * @param _start	the address of a location to recieve the start
451132354Sdfr *			index of the resource range
452132354Sdfr * @param _count	the address of a location to recieve the size
453132354Sdfr *			of the resource range
454132354Sdfr */
45552174SdfrMETHOD int get_resource {
45695201Smarkm	device_t	_dev;
45795201Smarkm	device_t	_child;
45895201Smarkm	int		_type;
45995201Smarkm	int		_rid;
460294883Sjhibbits	rman_res_t	*_startp;
461294883Sjhibbits	rman_res_t	*_countp;
46252174Sdfr};
46352174Sdfr
464132354Sdfr/**
465132354Sdfr * @brief Delete a resource.
466132354Sdfr * 
467132354Sdfr * Use this to delete a resource (possibly one previously added with
468132354Sdfr * BUS_SET_RESOURCE()).
469132354Sdfr * 
470132354Sdfr * @param _dev		the parent device of @p _child
471132354Sdfr * @param _child	the device which owns the resource
472132354Sdfr * @param _type		the type of resource
473132354Sdfr * @param _rid		the resource identifier
474132354Sdfr */
47552174SdfrMETHOD void delete_resource {
47695201Smarkm	device_t	_dev;
47795201Smarkm	device_t	_child;
47895201Smarkm	int		_type;
47995201Smarkm	int		_rid;
48052174Sdfr};
48167278Smdodd
482132354Sdfr/**
483132354Sdfr * @brief Return a struct resource_list.
484132354Sdfr *
485132354Sdfr * Used by drivers which use bus_generic_rl_alloc_resource() etc. to
486132354Sdfr * implement their resource handling. It should return the resource
487132354Sdfr * list of the given child device.
488132354Sdfr * 
489132354Sdfr * @param _dev		the parent device of @p _child
490132354Sdfr * @param _child	the device which owns the resource list
491132354Sdfr */
49269294SmdoddMETHOD struct resource_list * get_resource_list {
49395201Smarkm	device_t	_dev;
49495201Smarkm	device_t	_child;
49567278Smdodd} DEFAULT bus_generic_get_resource_list;
496100421Simp
497132354Sdfr/**
498132354Sdfr * @brief Is the hardware described by @p _child still attached to the
499132354Sdfr * system?
500132354Sdfr *
501133588Simp * This method should return 0 if the device is not present.  It
502133588Simp * should return -1 if it is present.  Any errors in determining
503133588Simp * should be returned as a normal errno value.  Client drivers are to
504133588Simp * assume that the device is present, even if there is an error
505133588Simp * determining if it is there.  Busses are to try to avoid returning
506133588Simp * errors, but newcard will return an error if the device fails to
507133588Simp * implement this method.
508132354Sdfr * 
509132354Sdfr * @param _dev		the parent device of @p _child
510132354Sdfr * @param _child	the device which is being examined
511132354Sdfr */
512100421SimpMETHOD int child_present {
513100421Simp	device_t	_dev;
514100421Simp	device_t	_child;
515100421Simp} DEFAULT bus_generic_child_present;
516104597Simp
517132354Sdfr/**
518132354Sdfr * @brief Returns the pnp info for this device.
519132354Sdfr *
520132354Sdfr * Return it as a string.  If the string is insufficient for the
521132354Sdfr * storage, then return EOVERFLOW.
522132354Sdfr * 
523132354Sdfr * @param _dev		the parent device of @p _child
524132354Sdfr * @param _child	the device which is being examined
525132354Sdfr * @param _buf		the address of a buffer to receive the pnp
526132354Sdfr *			string
527132354Sdfr * @param _buflen	the size of the buffer pointed to by @p _buf
528132354Sdfr */
529104597SimpMETHOD int child_pnpinfo_str {
530104597Simp	device_t	_dev;
531104597Simp	device_t	_child;
532104597Simp	char		*_buf;
533104597Simp	size_t		_buflen;
534104597Simp};
535104597Simp
536132354Sdfr/**
537132354Sdfr * @brief Returns the location for this device.
538132354Sdfr *
539132354Sdfr * Return it as a string.  If the string is insufficient for the
540132354Sdfr * storage, then return EOVERFLOW.
541132354Sdfr * 
542132354Sdfr * @param _dev		the parent device of @p _child
543132354Sdfr * @param _child	the device which is being examined
544132354Sdfr * @param _buf		the address of a buffer to receive the location
545132354Sdfr *			string
546132354Sdfr * @param _buflen	the size of the buffer pointed to by @p _buf
547132354Sdfr */
548104597SimpMETHOD int child_location_str {
549104597Simp	device_t	_dev;
550104597Simp	device_t	_child;
551104597Simp	char		*_buf;
552104597Simp	size_t		_buflen;
553104597Simp};
554119967Smarcel
555132354Sdfr/**
556177467Sjhb * @brief Allow drivers to request that an interrupt be bound to a specific
557177467Sjhb * CPU.
558177467Sjhb * 
559177467Sjhb * @param _dev		the parent device of @p _child
560177467Sjhb * @param _child	the device which allocated the resource
561177467Sjhb * @param _irq		the resource representing the interrupt
562177467Sjhb * @param _cpu		the CPU to bind the interrupt to
563177467Sjhb */
564177467SjhbMETHOD int bind_intr {
565177467Sjhb	device_t	_dev;
566177467Sjhb	device_t	_child;
567177467Sjhb	struct resource *_irq;
568177467Sjhb	int		_cpu;
569177467Sjhb} DEFAULT bus_generic_bind_intr;
570177467Sjhb
571177467Sjhb/**
572132354Sdfr * @brief Allow (bus) drivers to specify the trigger mode and polarity
573132354Sdfr * of the specified interrupt.
574132354Sdfr * 
575132354Sdfr * @param _dev		the bus device
576132354Sdfr * @param _irq		the interrupt number to modify
577132354Sdfr * @param _trig		the trigger mode required
578132354Sdfr * @param _pol		the interrupt polarity required
579132354Sdfr */
580119967SmarcelMETHOD int config_intr {
581119967Smarcel	device_t	_dev;
582119967Smarcel	int		_irq;
583119967Smarcel	enum intr_trigger _trig;
584119967Smarcel	enum intr_polarity _pol;
585119967Smarcel} DEFAULT bus_generic_config_intr;
586160186Simp
587160186Simp/**
588198134Sjhb * @brief Allow drivers to associate a description with an active
589198134Sjhb * interrupt handler.
590198134Sjhb *
591198134Sjhb * @param _dev		the parent device of @p _child
592198134Sjhb * @param _child	the device which allocated the resource
593198134Sjhb * @param _irq		the resource representing the interrupt
594198134Sjhb * @param _cookie	the cookie value returned when the interrupt
595198134Sjhb *			was originally registered
596198134Sjhb * @param _descr	the description to associate with the interrupt
597198134Sjhb */
598198134SjhbMETHOD int describe_intr {
599198134Sjhb	device_t	_dev;
600198134Sjhb	device_t	_child;
601198134Sjhb	struct resource *_irq;
602198134Sjhb	void		*_cookie;
603198134Sjhb	const char	*_descr;
604198134Sjhb} DEFAULT bus_generic_describe_intr;
605198134Sjhb
606198134Sjhb/**
607160186Simp * @brief Notify a (bus) driver about a child that the hints mechanism
608160186Simp * believes it has discovered.
609160186Simp *
610160186Simp * The bus is responsible for then adding the child in the right order
611160186Simp * and discovering other things about the child.  The bus driver is
612160186Simp * free to ignore this hint, to do special things, etc.  It is all up
613160186Simp * to the bus driver to interpret.
614160186Simp *
615160186Simp * This method is only called in response to the parent bus asking for
616160186Simp * hinted devices to be enumerated.
617160186Simp *
618160186Simp * @param _dev		the bus device
619160186Simp * @param _dname	the name of the device w/o unit numbers
620160186Simp * @param _dunit	the unit number of the device
621160186Simp */
622160186SimpMETHOD void hinted_child {
623160186Simp	device_t	_dev;
624185059Sjhb	const char	*_dname;
625160186Simp	int		_dunit;
626160186Simp};
627161928Sjmg
628161928Sjmg/**
629161928Sjmg * @brief Returns bus_dma_tag_t for use w/ devices on the bus.
630161928Sjmg *
631161928Sjmg * @param _dev		the parent device of @p _child
632161928Sjmg * @param _child	the device to which the tag will belong
633161928Sjmg */
634161928SjmgMETHOD bus_dma_tag_t get_dma_tag {
635161928Sjmg	device_t	_dev;
636161928Sjmg	device_t	_child;
637161928Sjmg} DEFAULT bus_generic_get_dma_tag;
638185059Sjhb
639185059Sjhb/**
640295755Szbb * @brief Returns bus_space_tag_t for use w/ devices on the bus.
641295755Szbb *
642295755Szbb * @param _dev		the parent device of @p _child
643295755Szbb * @param _child	the device to which the tag will belong
644295755Szbb */
645295755SzbbMETHOD bus_space_tag_t get_bus_tag {
646295755Szbb	device_t	_dev;
647295755Szbb	device_t	_child;
648295755Szbb} DEFAULT bus_generic_get_bus_tag;
649295755Szbb
650295755Szbb/**
651185059Sjhb * @brief Allow the bus to determine the unit number of a device.
652185059Sjhb *
653185059Sjhb * @param _dev		the parent device of @p _child
654185059Sjhb * @param _child	the device whose unit is to be wired
655185059Sjhb * @param _name		the name of the device's new devclass
656185059Sjhb * @param _unitp	a pointer to the device's new unit value
657185059Sjhb */
658185059SjhbMETHOD void hint_device_unit {
659185059Sjhb	device_t	_dev;
660185059Sjhb	device_t	_child;
661185059Sjhb	const char	*_name;
662185059Sjhb	int		*_unitp;
663185059Sjhb};
664185059Sjhb
665193833Sjhb/**
666193833Sjhb * @brief Notify a bus that the bus pass level has been changed
667193833Sjhb *
668193833Sjhb * @param _dev		the bus device
669193833Sjhb */
670193833SjhbMETHOD void new_pass {
671193833Sjhb	device_t	_dev;
672193833Sjhb} DEFAULT bus_generic_new_pass;
673209154Smav
674209154Smav/**
675209154Smav * @brief Notify a bus that specified child's IRQ should be remapped.
676209154Smav *
677209154Smav * @param _dev		the bus device
678209154Smav * @param _child	the child device
679209154Smav * @param _irq		the irq number
680209154Smav */
681209154SmavMETHOD int remap_intr {
682209154Smav	device_t	_dev;
683209154Smav	device_t	_child;
684209154Smav	u_int		_irq;
685209154Smav} DEFAULT null_remap_intr;
686272013Sjhibbits
687272013Sjhibbits/**
688272013Sjhibbits * @brief Suspend a given child
689272013Sjhibbits *
690272013Sjhibbits * @param _dev		the parent device of @p _child
691272013Sjhibbits * @param _child	the device to suspend
692272013Sjhibbits */
693272013SjhibbitsMETHOD int suspend_child {
694272013Sjhibbits	device_t	_dev;
695272013Sjhibbits	device_t	_child;
696272013Sjhibbits} DEFAULT bus_generic_suspend_child;
697272013Sjhibbits
698272013Sjhibbits/**
699272013Sjhibbits * @brief Resume a given child
700272013Sjhibbits *
701272013Sjhibbits * @param _dev		the parent device of @p _child
702272013Sjhibbits * @param _child	the device to resume
703272013Sjhibbits */
704272013SjhibbitsMETHOD int resume_child {
705272013Sjhibbits	device_t	_dev;
706272013Sjhibbits	device_t	_child;
707272013Sjhibbits} DEFAULT bus_generic_resume_child;
708272799Sadrian
709272799Sadrian/**
710272799Sadrian * @brief Get the VM domain handle for the given bus and child.
711272799Sadrian *
712272799Sadrian * @param _dev		the bus device
713272799Sadrian * @param _child	the child device
714272799Sadrian * @param _domain	a pointer to the bus's domain handle identifier
715272799Sadrian */
716272799SadrianMETHOD int get_domain {
717272799Sadrian	device_t	_dev;
718272799Sadrian	device_t	_child;
719272799Sadrian	int		*_domain;
720272799Sadrian} DEFAULT bus_generic_get_domain;
721