Deleted Added
full compact
fdt_ic_if.m (48754) fdt_ic_if.m (49195)
1#
2# Copyright (c) 1998 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#
1#
2# Copyright (c) 1998 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# $Id: bus_if.m,v 1.11 1999/05/28 09:25:08 dfr Exp $
26# $Id: bus_if.m,v 1.12 1999/07/11 13:42:36 dfr Exp $
27#
28
29INTERFACE bus;
30
31#
32# Default implementations of some methods.
33#
34CODE {
35 static struct resource *
36 null_alloc_resource(device_t dev, device_t child,
37 int type, int *rid,
38 u_long start, u_long end,
39 u_long count, u_int flags)
40 {
41 return 0;
42 }
43};
44
45#
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
27#
28
29INTERFACE bus;
30
31#
32# Default implementations of some methods.
33#
34CODE {
35 static struct resource *
36 null_alloc_resource(device_t dev, device_t child,
37 int type, int *rid,
38 u_long start, u_long end,
39 u_long count, u_int flags)
40 {
41 return 0;
42 }
43};
44
45#
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.
49# device is attached to. See bus_generic_print_child.9 for more
50# information.
51# This method returns the number of characters output.
50#
52#
51METHOD void print_child {
53METHOD int print_child {
52 device_t dev;
53 device_t child;
54};
55
56#
57# Called for each child device that
58# did not succeed in probing for a
59# driver.
60#
61METHOD void probe_nomatch {
62 device_t dev;
63 device_t child;
64};
65
66#
67# These two methods manage a bus specific set of instance variables of
68# a child device. The intention is that each different type of bus
69# defines a set of appropriate instance variables (such as ports and
70# irqs for ISA bus etc.)
71#
72# This information could be given to the child device as a struct but
73# that makes it hard for a bus to add or remove variables without
74# forcing an edit and recompile for all drivers which may not be
75# possible for vendor supplied binary drivers.
76
77#
78# Read an instance variable. Return 0 on success.
79#
80METHOD int read_ivar {
81 device_t dev;
82 device_t child;
83 int index;
84 uintptr_t *result;
85};
86
87#
88# Write an instance variable. Return 0 on success.
89#
90METHOD int write_ivar {
91 device_t dev;
92 device_t child;
93 int index;
94 uintptr_t value;
95};
96
97#
98# Called after the child's DEVICE_DETACH method to allow the parent
99# to reclaim any resources allocated on behalf of the child.
100#
101METHOD void child_detached {
102 device_t dev;
103 device_t child;
104};
105
106#
107# Called when a new driver is added to the devclass which owns this
108# bus. The generic implementation of this method attempts to probe and
109# attach any un-matched children of the bus.
110#
111METHOD void driver_added {
112 device_t dev;
113 driver_t *driver;
114}
115
116#
117# For busses which use use drivers supporting DEVICE_IDENTIFY to
118# enumerate their devices, these methods are used to create new
119# device instances. If place is non-NULL, the new device will be
120# added after the last existing child with the same order.
121#
122METHOD device_t add_child {
123 device_t dev;
124 int order;
125 const char *name;
126 int unit;
127};
128
129#
130# Allocate a system resource attached to `dev' on behalf of `child'.
131# The types are defined in <machine/resource.h>; the meaning of the
132# resource-ID field varies from bus to bus (but *rid == 0 is always
133# valid if the resource type is). start and end reflect the allowable
134# range, and should be passed as `0UL' and `~0UL', respectively, if
135# the client has no range restriction. count is the number of consecutive
136# indices in the resource required. flags is a set of sharing flags
137# as defined in <sys/rman.h>.
138#
139# Returns a resource or a null pointer on failure. The caller is
140# responsible for calling rman_activate_resource() when it actually
141# uses the resource.
142#
143METHOD struct resource * alloc_resource {
144 device_t dev;
145 device_t child;
146 int type;
147 int *rid;
148 u_long start;
149 u_long end;
150 u_long count;
151 u_int flags;
152} DEFAULT null_alloc_resource;
153
154METHOD int activate_resource {
155 device_t dev;
156 device_t child;
157 int type;
158 int rid;
159 struct resource *r;
160};
161
162METHOD int deactivate_resource {
163 device_t dev;
164 device_t child;
165 int type;
166 int rid;
167 struct resource *r;
168};
169
170#
171# Free a resource allocated by the preceding method. The `rid' value
172# must be the same as the one returned by BUS_ALLOC_RESOURCE (which
173# is not necessarily the same as the one the client passed).
174#
175METHOD int release_resource {
176 device_t dev;
177 device_t child;
178 int type;
179 int rid;
180 struct resource *res;
181};
182
183METHOD int setup_intr {
184 device_t dev;
185 device_t child;
186 struct resource *irq;
187 int flags;
188 driver_intr_t *intr;
189 void *arg;
190 void **cookiep;
191};
192
193METHOD int teardown_intr {
194 device_t dev;
195 device_t child;
196 struct resource *irq;
197 void *cookie;
198};
54 device_t dev;
55 device_t child;
56};
57
58#
59# Called for each child device that
60# did not succeed in probing for a
61# driver.
62#
63METHOD void probe_nomatch {
64 device_t dev;
65 device_t child;
66};
67
68#
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.)
73#
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.
78
79#
80# Read an instance variable. Return 0 on success.
81#
82METHOD int read_ivar {
83 device_t dev;
84 device_t child;
85 int index;
86 uintptr_t *result;
87};
88
89#
90# Write an instance variable. Return 0 on success.
91#
92METHOD int write_ivar {
93 device_t dev;
94 device_t child;
95 int index;
96 uintptr_t value;
97};
98
99#
100# Called after the child's DEVICE_DETACH method to allow the parent
101# to reclaim any resources allocated on behalf of the child.
102#
103METHOD void child_detached {
104 device_t dev;
105 device_t child;
106};
107
108#
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.
112#
113METHOD void driver_added {
114 device_t dev;
115 driver_t *driver;
116}
117
118#
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.
123#
124METHOD device_t add_child {
125 device_t dev;
126 int order;
127 const char *name;
128 int unit;
129};
130
131#
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>.
140#
141# Returns a resource or a null pointer on failure. The caller is
142# responsible for calling rman_activate_resource() when it actually
143# uses the resource.
144#
145METHOD struct resource * alloc_resource {
146 device_t dev;
147 device_t child;
148 int type;
149 int *rid;
150 u_long start;
151 u_long end;
152 u_long count;
153 u_int flags;
154} DEFAULT null_alloc_resource;
155
156METHOD int activate_resource {
157 device_t dev;
158 device_t child;
159 int type;
160 int rid;
161 struct resource *r;
162};
163
164METHOD int deactivate_resource {
165 device_t dev;
166 device_t child;
167 int type;
168 int rid;
169 struct resource *r;
170};
171
172#
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).
176#
177METHOD int release_resource {
178 device_t dev;
179 device_t child;
180 int type;
181 int rid;
182 struct resource *res;
183};
184
185METHOD int setup_intr {
186 device_t dev;
187 device_t child;
188 struct resource *irq;
189 int flags;
190 driver_intr_t *intr;
191 void *arg;
192 void **cookiep;
193};
194
195METHOD int teardown_intr {
196 device_t dev;
197 device_t child;
198 struct resource *irq;
199 void *cookie;
200};