2 # Copyright (c) 1998 Doug Rabson
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
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.
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
26 # $FreeBSD: src/sys/kern/bus_if.m,v 1.16 1999/10/12 21:35:50 dfr Exp $
32 # Default implementations of some methods.
35 static struct resource *
36 null_alloc_resource(device_t dev, device_t child,
38 u_long start, u_long end,
39 u_long count, u_int flags)
46 # This is called from system code which prints out a description of a
47 # device. It should describe the attachment that the child has with
48 # the parent. For instance the TurboLaser bus prints which node the
49 # device is attached to. See bus_generic_print_child.9 for more
51 # This method returns the number of characters output.
53 METHOD int print_child {
59 # Called for each child device that
60 # did not succeed in probing for a
63 METHOD void probe_nomatch {
69 # These two methods manage a bus specific set of instance variables of
70 # a child device. The intention is that each different type of bus
71 # defines a set of appropriate instance variables (such as ports and
72 # irqs for ISA bus etc.)
74 # This information could be given to the child device as a struct but
75 # that makes it hard for a bus to add or remove variables without
76 # forcing an edit and recompile for all drivers which may not be
77 # possible for vendor supplied binary drivers.
80 # Read an instance variable. Return 0 on success.
82 METHOD int read_ivar {
90 # Write an instance variable. Return 0 on success.
92 METHOD int write_ivar {
100 # Called after the child's DEVICE_DETACH method to allow the parent
101 # to reclaim any resources allocated on behalf of the child.
103 METHOD void child_detached {
109 # Called when a new driver is added to the devclass which owns this
110 # bus. The generic implementation of this method attempts to probe and
111 # attach any un-matched children of the bus.
113 METHOD void driver_added {
116 } DEFAULT bus_generic_driver_added;
119 # For busses which use use drivers supporting DEVICE_IDENTIFY to
120 # enumerate their devices, these methods are used to create new
121 # device instances. If place is non-NULL, the new device will be
122 # added after the last existing child with the same order.
124 METHOD device_t add_child {
132 # Allocate a system resource attached to `dev' on behalf of `child'.
133 # The types are defined in <machine/resource.h>; the meaning of the
134 # resource-ID field varies from bus to bus (but *rid == 0 is always
135 # valid if the resource type is). start and end reflect the allowable
136 # range, and should be passed as `0UL' and `~0UL', respectively, if
137 # the client has no range restriction. count is the number of consecutive
138 # indices in the resource required. flags is a set of sharing flags
139 # as defined in <sys/rman.h>.
141 # Returns a resource or a null pointer on failure. The caller is
142 # responsible for calling rman_activate_resource() when it actually
145 METHOD struct resource * alloc_resource {
154 } DEFAULT null_alloc_resource;
156 METHOD int activate_resource {
164 METHOD int deactivate_resource {
173 # Free a resource allocated by the preceding method. The `rid' value
174 # must be the same as the one returned by BUS_ALLOC_RESOURCE (which
175 # is not necessarily the same as the one the client passed).
177 METHOD int release_resource {
182 struct resource *res;
185 METHOD int setup_intr {
188 struct resource *irq;
195 METHOD int teardown_intr {
198 struct resource *irq;
203 # Set the range used for a particular resource. Return EINVAL if
204 # the type or rid are out of range.
206 METHOD int set_resource {
216 # Get the range for a resource. Return ENOENT if the type or rid are
217 # out of range or have not been set.
219 METHOD int get_resource {
231 METHOD void delete_resource {