bus_if.m revision 212413
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 212413 2010-09-10 11:19:03Z avg $
2736973Sdfr#
2836973Sdfr
2959093Sdfr#include <sys/bus.h>
3059093Sdfr
31132354Sdfr/**
32132354Sdfr * @defgroup BUS bus - KObj methods for drivers of devices with children
33132354Sdfr * @brief A set of methods required device drivers that support
34132354Sdfr * child devices.
35132354Sdfr * @{
36132354Sdfr */
3741017SnsouchINTERFACE bus;
3836973Sdfr
3936973Sdfr#
4046913Sdfr# Default implementations of some methods.
4146913Sdfr#
4246913SdfrCODE {
4346913Sdfr	static struct resource *
4446913Sdfr	null_alloc_resource(device_t dev, device_t child,
45100421Simp	    int type, int *rid, u_long start, u_long end,
46100421Simp	    u_long count, u_int flags)
4746913Sdfr	{
48100421Simp	    return (0);
4946913Sdfr	}
50209154Smav
51209154Smav	static int
52209154Smav	null_remap_intr(device_t bus, device_t dev, u_int irq)
53209154Smav	{
54209154Smav
55209154Smav		if (dev != NULL)
56209154Smav			return (BUS_REMAP_INTR(dev, NULL, irq));
57209154Smav		return (ENXIO);
58209154Smav	}
5946913Sdfr};
6046913Sdfr
61132354Sdfr/**
62132354Sdfr * @brief Print a description of a child device
63132354Sdfr *
64132354Sdfr * This is called from system code which prints out a description of a
65132354Sdfr * device. It should describe the attachment that the child has with
66132354Sdfr * the parent. For instance the TurboLaser bus prints which node the
67132354Sdfr * device is attached to. See bus_generic_print_child() for more 
68132354Sdfr * information.
69132354Sdfr *
70132354Sdfr * @param _dev		the device whose child is being printed
71132354Sdfr * @param _child	the child device to describe
72132354Sdfr *
73132354Sdfr * @returns		the number of characters output.
74132354Sdfr */
7549195SmdoddMETHOD int print_child {
76132354Sdfr	device_t _dev;
77132354Sdfr	device_t _child;
78112588Smdodd} DEFAULT bus_generic_print_child;
7936973Sdfr
80132354Sdfr/**
81132354Sdfr * @brief Print a notification about an unprobed child device.
82132354Sdfr *
83132354Sdfr * Called for each child device that did not succeed in probing for a
84132354Sdfr * driver.
85132354Sdfr *
86132354Sdfr * @param _dev		the device whose child was being probed
87132354Sdfr * @param _child	the child device which failed to probe
88132354Sdfr */   
8948754SdfrMETHOD void probe_nomatch {
90132354Sdfr        device_t _dev;
91132354Sdfr        device_t _child;
9248754Sdfr};
9348754Sdfr
94132354Sdfr/**
95132354Sdfr * @brief Read the value of a bus-specific attribute of a device
96132354Sdfr *
97132354Sdfr * This method, along with BUS_WRITE_IVAR() manages a bus-specific set
98132354Sdfr * of instance variables of a child device.  The intention is that
99132354Sdfr * each different type of bus defines a set of appropriate instance
100132354Sdfr * variables (such as ports and irqs for ISA bus etc.)
101132354Sdfr *
102132354Sdfr * This information could be given to the child device as a struct but
103132354Sdfr * that makes it hard for a bus to add or remove variables without
104132354Sdfr * forcing an edit and recompile for all drivers which may not be
105132354Sdfr * possible for vendor supplied binary drivers.
106132354Sdfr *
107132354Sdfr * This method copies the value of an instance variable to the
108132354Sdfr * location specified by @p *_result.
109132354Sdfr * 
110132354Sdfr * @param _dev		the device whose child was being examined
111132354Sdfr * @param _child	the child device whose instance variable is
112132354Sdfr *			being read
113132354Sdfr * @param _index	the instance variable to read
114132354Sdfr * @param _result	a loction to recieve the instance variable
115132354Sdfr *			value
116132354Sdfr * 
117132354Sdfr * @retval 0		success
118132354Sdfr * @retval ENOENT	no such instance variable is supported by @p
119132354Sdfr *			_dev 
120132354Sdfr */
12136973SdfrMETHOD int read_ivar {
12295201Smarkm	device_t _dev;
12395201Smarkm	device_t _child;
124132354Sdfr	int _index;
12595201Smarkm	uintptr_t *_result;
12636973Sdfr};
12736973Sdfr
128132354Sdfr/**
129132354Sdfr * @brief Write the value of a bus-specific attribute of a device
130132354Sdfr * 
131132354Sdfr * This method sets the value of an instance variable to @p _value.
132132354Sdfr * 
133132354Sdfr * @param _dev		the device whose child was being updated
134132354Sdfr * @param _child	the child device whose instance variable is
135132354Sdfr *			being written
136132354Sdfr * @param _index	the instance variable to write
137132354Sdfr * @param _value	the value to write to that instance variable
138132354Sdfr * 
139132354Sdfr * @retval 0		success
140132354Sdfr * @retval ENOENT	no such instance variable is supported by @p
141132354Sdfr *			_dev 
142132354Sdfr * @retval EINVAL	the instance variable was recognised but
143132354Sdfr *			contains a read-only value
144132354Sdfr */
14536973SdfrMETHOD int write_ivar {
14695201Smarkm	device_t _dev;
14795201Smarkm	device_t _child;
14895201Smarkm	int _indx;
14995201Smarkm	uintptr_t _value;
15036973Sdfr};
15136973Sdfr
152132354Sdfr/**
153132354Sdfr * @brief Notify a bus that a child was detached
154132354Sdfr *
155132354Sdfr * Called after the child's DEVICE_DETACH() method to allow the parent
156132354Sdfr * to reclaim any resources allocated on behalf of the child.
157132354Sdfr * 
158132354Sdfr * @param _dev		the device whose child changed state
159132354Sdfr * @param _child	the child device which changed state
160132354Sdfr */
16145107SdfrMETHOD void child_detached {
16295201Smarkm	device_t _dev;
16395201Smarkm	device_t _child;
16445107Sdfr};
16545107Sdfr
166132354Sdfr/**
167132354Sdfr * @brief Notify a bus that a new driver was added
168132354Sdfr * 
169132354Sdfr * Called when a new driver is added to the devclass which owns this
170132354Sdfr * bus. The generic implementation of this method attempts to probe and
171132354Sdfr * attach any un-matched children of the bus.
172132354Sdfr * 
173132354Sdfr * @param _dev		the device whose devclass had a new driver
174132354Sdfr *			added to it
175132354Sdfr * @param _driver	the new driver which was added
176132354Sdfr */
17745720SpeterMETHOD void driver_added {
17895201Smarkm	device_t _dev;
17995201Smarkm	driver_t *_driver;
18052045Simp} DEFAULT bus_generic_driver_added;
18145720Speter
182132354Sdfr/**
183132354Sdfr * @brief Create a new child device
184132354Sdfr *
185132354Sdfr * For busses which use use drivers supporting DEVICE_IDENTIFY() to
186132354Sdfr * enumerate their devices, this method is used to create new
187132354Sdfr * device instances. The new device will be added after the last
188132354Sdfr * existing child with the same order.
189132354Sdfr * 
190132354Sdfr * @param _dev		the bus device which will be the parent of the
191132354Sdfr *			new child device
192132354Sdfr * @param _order	a value which is used to partially sort the
193132354Sdfr *			children of @p _dev - devices created using
194132354Sdfr *			lower values of @p _order appear first in @p
195132354Sdfr *			_dev's list of children
196132354Sdfr * @param _name		devclass name for new device or @c NULL if not
197132354Sdfr *			specified
198132354Sdfr * @param _unit		unit number for new device or @c -1 if not
199132354Sdfr *			specified
200132354Sdfr */
20147178SdfrMETHOD device_t add_child {
20295201Smarkm	device_t _dev;
203212413Savg	u_int _order;
20495201Smarkm	const char *_name;
20595201Smarkm	int _unit;
206162237Sjhb};
20747178Sdfr
208132354Sdfr/**
209132354Sdfr * @brief Allocate a system resource
210132354Sdfr *
211132354Sdfr * This method is called by child devices of a bus to allocate resources.
212132354Sdfr * The types are defined in <machine/resource.h>; the meaning of the
213132354Sdfr * resource-ID field varies from bus to bus (but @p *rid == 0 is always
214132354Sdfr * valid if the resource type is). If a resource was allocated and the
215132354Sdfr * caller did not use the RF_ACTIVE to specify that it should be
216132354Sdfr * activated immediately, the caller is responsible for calling
217132354Sdfr * BUS_ACTIVATE_RESOURCE() when it actually uses the resource.
218132354Sdfr *
219132354Sdfr * @param _dev		the parent device of @p _child
220132354Sdfr * @param _child	the device which is requesting an allocation
221132354Sdfr * @param _type		the type of resource to allocate
222132354Sdfr * @param _rid		a pointer to the resource identifier
223132354Sdfr * @param _start	hint at the start of the resource range - pass
224132354Sdfr *			@c 0UL for any start address
225132354Sdfr * @param _end		hint at the end of the resource range - pass
226132354Sdfr *			@c ~0UL for any end address
227132354Sdfr * @param _count	hint at the size of range required - pass @c 1
228132354Sdfr *			for any size
229132354Sdfr * @param _flags	any extra flags to control the resource
230132354Sdfr *			allocation - see @c RF_XXX flags in
231132354Sdfr *			<sys/rman.h> for details
232132354Sdfr * 
233132354Sdfr * @returns		the resource which was allocated or @c NULL if no
234132354Sdfr *			resource could be allocated
235132354Sdfr */
23641153SwollmanMETHOD struct resource * alloc_resource {
23795201Smarkm	device_t	_dev;
23895201Smarkm	device_t	_child;
23995201Smarkm	int		_type;
24095201Smarkm	int	       *_rid;
24195201Smarkm	u_long		_start;
24295201Smarkm	u_long		_end;
24395201Smarkm	u_long		_count;
24495201Smarkm	u_int		_flags;
24546913Sdfr} DEFAULT null_alloc_resource;
24637592Sdfr
247132354Sdfr/**
248132354Sdfr * @brief Activate a resource
249132354Sdfr *
250132354Sdfr * Activate a resource previously allocated with
251132354Sdfr * BUS_ALLOC_RESOURCE(). This may for instance map a memory region
252132354Sdfr * into the kernel's virtual address space.
253132354Sdfr *
254132354Sdfr * @param _dev		the parent device of @p _child
255132354Sdfr * @param _child	the device which allocated the resource
256132354Sdfr * @param _type		the type of resource
257132354Sdfr * @param _rid		the resource identifier
258132354Sdfr * @param _r		the resource to activate
259132354Sdfr */
26041153SwollmanMETHOD int activate_resource {
26195201Smarkm	device_t	_dev;
26295201Smarkm	device_t	_child;
26395201Smarkm	int		_type;
26495201Smarkm	int		_rid;
26595201Smarkm	struct resource *_r;
26641153Swollman};
26741153Swollman
268132354Sdfr/**
269132354Sdfr * @brief Deactivate a resource
270132354Sdfr *
271132354Sdfr * Deactivate a resource previously allocated with
272132354Sdfr * BUS_ALLOC_RESOURCE(). This may for instance unmap a memory region
273132354Sdfr * from the kernel's virtual address space.
274132354Sdfr *
275132354Sdfr * @param _dev		the parent device of @p _child
276132354Sdfr * @param _child	the device which allocated the resource
277132354Sdfr * @param _type		the type of resource
278132354Sdfr * @param _rid		the resource identifier
279132354Sdfr * @param _r		the resource to deactivate
280132354Sdfr */
28141153SwollmanMETHOD int deactivate_resource {
28295201Smarkm	device_t	_dev;
28395201Smarkm	device_t	_child;
28495201Smarkm	int		_type;
28595201Smarkm	int		_rid;
28695201Smarkm	struct resource *_r;
28741153Swollman};
28841153Swollman
289132354Sdfr/**
290132354Sdfr * @brief Release a resource
291132354Sdfr *
292132354Sdfr * Free a resource allocated by the BUS_ALLOC_RESOURCE.  The @p _rid
293132354Sdfr * value must be the same as the one returned by BUS_ALLOC_RESOURCE()
294132354Sdfr * (which is not necessarily the same as the one the client passed).
295132354Sdfr *
296132354Sdfr * @param _dev		the parent device of @p _child
297132354Sdfr * @param _child	the device which allocated the resource
298132354Sdfr * @param _type		the type of resource
299132354Sdfr * @param _rid		the resource identifier
300132354Sdfr * @param _r		the resource to release
301132354Sdfr */
30241153SwollmanMETHOD int release_resource {
30395201Smarkm	device_t	_dev;
30495201Smarkm	device_t	_child;
30595201Smarkm	int		_type;
30695201Smarkm	int		_rid;
30795201Smarkm	struct resource *_res;
30837592Sdfr};
30941153Swollman
310132354Sdfr/**
311132354Sdfr * @brief Install an interrupt handler
312132354Sdfr *
313132354Sdfr * This method is used to associate an interrupt handler function with
314132354Sdfr * an irq resource. When the interrupt triggers, the function @p _intr
315132354Sdfr * will be called with the value of @p _arg as its single
316132354Sdfr * argument. The value returned in @p *_cookiep is used to cancel the
317132354Sdfr * interrupt handler - the caller should save this value to use in a
318132354Sdfr * future call to BUS_TEARDOWN_INTR().
319132354Sdfr * 
320132354Sdfr * @param _dev		the parent device of @p _child
321132354Sdfr * @param _child	the device which allocated the resource
322132354Sdfr * @param _irq		the resource representing the interrupt
323132354Sdfr * @param _flags	a set of bits from enum intr_type specifying
324132354Sdfr *			the class of interrupt
325132354Sdfr * @param _intr		the function to call when the interrupt
326132354Sdfr *			triggers
327132354Sdfr * @param _arg		a value to use as the single argument in calls
328132354Sdfr *			to @p _intr
329132354Sdfr * @param _cookiep	a pointer to a location to recieve a cookie
330132354Sdfr *			value that may be used to remove the interrupt
331132354Sdfr *			handler
332132354Sdfr */
33341153SwollmanMETHOD int setup_intr {
33495201Smarkm	device_t	_dev;
33595201Smarkm	device_t	_child;
33695201Smarkm	struct resource *_irq;
33795201Smarkm	int		_flags;
338166901Spiso	driver_filter_t	*_filter;
33995201Smarkm	driver_intr_t	*_intr;
34095201Smarkm	void		*_arg;
34195201Smarkm	void		**_cookiep;
34241153Swollman};
34341153Swollman
344132354Sdfr/**
345132354Sdfr * @brief Uninstall an interrupt handler
346132354Sdfr *
347132354Sdfr * This method is used to disassociate an interrupt handler function
348132354Sdfr * with an irq resource. The value of @p _cookie must be the value
349132354Sdfr * returned from a previous call to BUS_SETUP_INTR().
350132354Sdfr * 
351132354Sdfr * @param _dev		the parent device of @p _child
352132354Sdfr * @param _child	the device which allocated the resource
353132354Sdfr * @param _irq		the resource representing the interrupt
354132354Sdfr * @param _cookie	the cookie value returned when the interrupt
355132354Sdfr *			was originally registered
356132354Sdfr */
35741153SwollmanMETHOD int teardown_intr {
35895201Smarkm	device_t	_dev;
35995201Smarkm	device_t	_child;
36095201Smarkm	struct resource	*_irq;
36195201Smarkm	void		*_cookie;
36241153Swollman};
36352174Sdfr
364132354Sdfr/**
365132354Sdfr * @brief Define a resource which can be allocated with
366132354Sdfr * BUS_ALLOC_RESOURCE().
367132354Sdfr *
368132354Sdfr * This method is used by some busses (typically ISA) to allow a
369132354Sdfr * driver to describe a resource range that it would like to
370132354Sdfr * allocate. The resource defined by @p _type and @p _rid is defined
371132354Sdfr * to start at @p _start and to include @p _count indices in its
372132354Sdfr * range.
373132354Sdfr * 
374132354Sdfr * @param _dev		the parent device of @p _child
375132354Sdfr * @param _child	the device which owns the resource
376132354Sdfr * @param _type		the type of resource
377132354Sdfr * @param _rid		the resource identifier
378132354Sdfr * @param _start	the start of the resource range
379132354Sdfr * @param _count	the size of the resource range
380132354Sdfr */
38152174SdfrMETHOD int set_resource {
38295201Smarkm	device_t	_dev;
38395201Smarkm	device_t	_child;
38495201Smarkm	int		_type;
38595201Smarkm	int		_rid;
38695201Smarkm	u_long		_start;
38795201Smarkm	u_long		_count;
38852174Sdfr};
38952174Sdfr
390132354Sdfr/**
391132354Sdfr * @brief Describe a resource
392132354Sdfr *
393132354Sdfr * This method allows a driver to examine the range used for a given
394132354Sdfr * resource without actually allocating it.
395132354Sdfr * 
396132354Sdfr * @param _dev		the parent device of @p _child
397132354Sdfr * @param _child	the device which owns the resource
398132354Sdfr * @param _type		the type of resource
399132354Sdfr * @param _rid		the resource identifier
400132354Sdfr * @param _start	the address of a location to recieve the start
401132354Sdfr *			index of the resource range
402132354Sdfr * @param _count	the address of a location to recieve the size
403132354Sdfr *			of the resource range
404132354Sdfr */
40552174SdfrMETHOD int get_resource {
40695201Smarkm	device_t	_dev;
40795201Smarkm	device_t	_child;
40895201Smarkm	int		_type;
40995201Smarkm	int		_rid;
41095201Smarkm	u_long		*_startp;
41195201Smarkm	u_long		*_countp;
41252174Sdfr};
41352174Sdfr
414132354Sdfr/**
415132354Sdfr * @brief Delete a resource.
416132354Sdfr * 
417132354Sdfr * Use this to delete a resource (possibly one previously added with
418132354Sdfr * BUS_SET_RESOURCE()).
419132354Sdfr * 
420132354Sdfr * @param _dev		the parent device of @p _child
421132354Sdfr * @param _child	the device which owns the resource
422132354Sdfr * @param _type		the type of resource
423132354Sdfr * @param _rid		the resource identifier
424132354Sdfr */
42552174SdfrMETHOD void delete_resource {
42695201Smarkm	device_t	_dev;
42795201Smarkm	device_t	_child;
42895201Smarkm	int		_type;
42995201Smarkm	int		_rid;
43052174Sdfr};
43167278Smdodd
432132354Sdfr/**
433132354Sdfr * @brief Return a struct resource_list.
434132354Sdfr *
435132354Sdfr * Used by drivers which use bus_generic_rl_alloc_resource() etc. to
436132354Sdfr * implement their resource handling. It should return the resource
437132354Sdfr * list of the given child device.
438132354Sdfr * 
439132354Sdfr * @param _dev		the parent device of @p _child
440132354Sdfr * @param _child	the device which owns the resource list
441132354Sdfr */
44269294SmdoddMETHOD struct resource_list * get_resource_list {
44395201Smarkm	device_t	_dev;
44495201Smarkm	device_t	_child;
44567278Smdodd} DEFAULT bus_generic_get_resource_list;
446100421Simp
447132354Sdfr/**
448132354Sdfr * @brief Is the hardware described by @p _child still attached to the
449132354Sdfr * system?
450132354Sdfr *
451133588Simp * This method should return 0 if the device is not present.  It
452133588Simp * should return -1 if it is present.  Any errors in determining
453133588Simp * should be returned as a normal errno value.  Client drivers are to
454133588Simp * assume that the device is present, even if there is an error
455133588Simp * determining if it is there.  Busses are to try to avoid returning
456133588Simp * errors, but newcard will return an error if the device fails to
457133588Simp * implement this method.
458132354Sdfr * 
459132354Sdfr * @param _dev		the parent device of @p _child
460132354Sdfr * @param _child	the device which is being examined
461132354Sdfr */
462100421SimpMETHOD int child_present {
463100421Simp	device_t	_dev;
464100421Simp	device_t	_child;
465100421Simp} DEFAULT bus_generic_child_present;
466104597Simp
467132354Sdfr/**
468132354Sdfr * @brief Returns the pnp info for this device.
469132354Sdfr *
470132354Sdfr * Return it as a string.  If the string is insufficient for the
471132354Sdfr * storage, then return EOVERFLOW.
472132354Sdfr * 
473132354Sdfr * @param _dev		the parent device of @p _child
474132354Sdfr * @param _child	the device which is being examined
475132354Sdfr * @param _buf		the address of a buffer to receive the pnp
476132354Sdfr *			string
477132354Sdfr * @param _buflen	the size of the buffer pointed to by @p _buf
478132354Sdfr */
479104597SimpMETHOD int child_pnpinfo_str {
480104597Simp	device_t	_dev;
481104597Simp	device_t	_child;
482104597Simp	char		*_buf;
483104597Simp	size_t		_buflen;
484104597Simp};
485104597Simp
486132354Sdfr/**
487132354Sdfr * @brief Returns the location for this device.
488132354Sdfr *
489132354Sdfr * Return it as a string.  If the string is insufficient for the
490132354Sdfr * storage, then return EOVERFLOW.
491132354Sdfr * 
492132354Sdfr * @param _dev		the parent device of @p _child
493132354Sdfr * @param _child	the device which is being examined
494132354Sdfr * @param _buf		the address of a buffer to receive the location
495132354Sdfr *			string
496132354Sdfr * @param _buflen	the size of the buffer pointed to by @p _buf
497132354Sdfr */
498104597SimpMETHOD int child_location_str {
499104597Simp	device_t	_dev;
500104597Simp	device_t	_child;
501104597Simp	char		*_buf;
502104597Simp	size_t		_buflen;
503104597Simp};
504119967Smarcel
505132354Sdfr/**
506177467Sjhb * @brief Allow drivers to request that an interrupt be bound to a specific
507177467Sjhb * CPU.
508177467Sjhb * 
509177467Sjhb * @param _dev		the parent device of @p _child
510177467Sjhb * @param _child	the device which allocated the resource
511177467Sjhb * @param _irq		the resource representing the interrupt
512177467Sjhb * @param _cpu		the CPU to bind the interrupt to
513177467Sjhb */
514177467SjhbMETHOD int bind_intr {
515177467Sjhb	device_t	_dev;
516177467Sjhb	device_t	_child;
517177467Sjhb	struct resource *_irq;
518177467Sjhb	int		_cpu;
519177467Sjhb} DEFAULT bus_generic_bind_intr;
520177467Sjhb
521177467Sjhb/**
522132354Sdfr * @brief Allow (bus) drivers to specify the trigger mode and polarity
523132354Sdfr * of the specified interrupt.
524132354Sdfr * 
525132354Sdfr * @param _dev		the bus device
526132354Sdfr * @param _irq		the interrupt number to modify
527132354Sdfr * @param _trig		the trigger mode required
528132354Sdfr * @param _pol		the interrupt polarity required
529132354Sdfr */
530119967SmarcelMETHOD int config_intr {
531119967Smarcel	device_t	_dev;
532119967Smarcel	int		_irq;
533119967Smarcel	enum intr_trigger _trig;
534119967Smarcel	enum intr_polarity _pol;
535119967Smarcel} DEFAULT bus_generic_config_intr;
536160186Simp
537160186Simp/**
538198134Sjhb * @brief Allow drivers to associate a description with an active
539198134Sjhb * interrupt handler.
540198134Sjhb *
541198134Sjhb * @param _dev		the parent device of @p _child
542198134Sjhb * @param _child	the device which allocated the resource
543198134Sjhb * @param _irq		the resource representing the interrupt
544198134Sjhb * @param _cookie	the cookie value returned when the interrupt
545198134Sjhb *			was originally registered
546198134Sjhb * @param _descr	the description to associate with the interrupt
547198134Sjhb */
548198134SjhbMETHOD int describe_intr {
549198134Sjhb	device_t	_dev;
550198134Sjhb	device_t	_child;
551198134Sjhb	struct resource *_irq;
552198134Sjhb	void		*_cookie;
553198134Sjhb	const char	*_descr;
554198134Sjhb} DEFAULT bus_generic_describe_intr;
555198134Sjhb
556198134Sjhb/**
557160186Simp * @brief Notify a (bus) driver about a child that the hints mechanism
558160186Simp * believes it has discovered.
559160186Simp *
560160186Simp * The bus is responsible for then adding the child in the right order
561160186Simp * and discovering other things about the child.  The bus driver is
562160186Simp * free to ignore this hint, to do special things, etc.  It is all up
563160186Simp * to the bus driver to interpret.
564160186Simp *
565160186Simp * This method is only called in response to the parent bus asking for
566160186Simp * hinted devices to be enumerated.
567160186Simp *
568160186Simp * @param _dev		the bus device
569160186Simp * @param _dname	the name of the device w/o unit numbers
570160186Simp * @param _dunit	the unit number of the device
571160186Simp */
572160186SimpMETHOD void hinted_child {
573160186Simp	device_t	_dev;
574185059Sjhb	const char	*_dname;
575160186Simp	int		_dunit;
576160186Simp};
577161928Sjmg
578161928Sjmg/**
579161928Sjmg * @brief Returns bus_dma_tag_t for use w/ devices on the bus.
580161928Sjmg *
581161928Sjmg * @param _dev		the parent device of @p _child
582161928Sjmg * @param _child	the device to which the tag will belong
583161928Sjmg */
584161928SjmgMETHOD bus_dma_tag_t get_dma_tag {
585161928Sjmg	device_t	_dev;
586161928Sjmg	device_t	_child;
587161928Sjmg} DEFAULT bus_generic_get_dma_tag;
588185059Sjhb
589185059Sjhb/**
590185059Sjhb * @brief Allow the bus to determine the unit number of a device.
591185059Sjhb *
592185059Sjhb * @param _dev		the parent device of @p _child
593185059Sjhb * @param _child	the device whose unit is to be wired
594185059Sjhb * @param _name		the name of the device's new devclass
595185059Sjhb * @param _unitp	a pointer to the device's new unit value
596185059Sjhb */
597185059SjhbMETHOD void hint_device_unit {
598185059Sjhb	device_t	_dev;
599185059Sjhb	device_t	_child;
600185059Sjhb	const char	*_name;
601185059Sjhb	int		*_unitp;
602185059Sjhb};
603185059Sjhb
604193833Sjhb/**
605193833Sjhb * @brief Notify a bus that the bus pass level has been changed
606193833Sjhb *
607193833Sjhb * @param _dev		the bus device
608193833Sjhb */
609193833SjhbMETHOD void new_pass {
610193833Sjhb	device_t	_dev;
611193833Sjhb} DEFAULT bus_generic_new_pass;
612209154Smav
613209154Smav/**
614209154Smav * @brief Notify a bus that specified child's IRQ should be remapped.
615209154Smav *
616209154Smav * @param _dev		the bus device
617209154Smav * @param _child	the child device
618209154Smav * @param _irq		the irq number
619209154Smav */
620209154SmavMETHOD int remap_intr {
621209154Smav	device_t	_dev;
622209154Smav	device_t	_child;
623209154Smav	u_int		_irq;
624209154Smav} DEFAULT null_remap_intr;
625