Deleted Added
full compact
fdt_ic_if.m (45107) fdt_ic_if.m (45720)
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.5 1998/11/14 21:58:51 wollman Exp $
26# $Id: bus_if.m,v 1.6 1999/03/29 08:54:19 dfr Exp $
27#
28
29INTERFACE bus;
30
31#
32# This is called from system code which prints out a description of a
33# device. It should describe the attachment that the child has with
34# the parent. For instance the TurboLaser bus prints which node the
35# device is attached to.
36#
37METHOD void print_child {
38 device_t dev;
39 device_t child;
40};
41
42#
43# These two methods manage a bus specific set of instance variables of
44# a child device. The intention is that each different type of bus
45# defines a set of appropriate instance variables (such as ports and
46# irqs for ISA bus etc.)
47#
48# This information could be given to the child device as a struct but
49# that makes it hard for a bus to add or remove variables without
50# forcing an edit and recompile for all drivers which may not be
51# possible for vendor supplied binary drivers.
52
53#
54# Read an instance variable. Return 0 on success.
55#
56METHOD int read_ivar {
57 device_t dev;
58 device_t child;
59 int index;
60 uintptr_t *result;
61};
62
63#
64# Write an instance variable. Return 0 on success.
65#
66METHOD int write_ivar {
67 device_t dev;
68 device_t child;
69 int index;
70 uintptr_t value;
71};
72
73#
74# Called after the child's DEVICE_DETACH method to allow the parent
75# to reclaim any resources allocated on behalf of the child.
76#
77METHOD void child_detached {
78 device_t dev;
79 device_t child;
80};
81
82#
27#
28
29INTERFACE bus;
30
31#
32# This is called from system code which prints out a description of a
33# device. It should describe the attachment that the child has with
34# the parent. For instance the TurboLaser bus prints which node the
35# device is attached to.
36#
37METHOD void print_child {
38 device_t dev;
39 device_t child;
40};
41
42#
43# These two methods manage a bus specific set of instance variables of
44# a child device. The intention is that each different type of bus
45# defines a set of appropriate instance variables (such as ports and
46# irqs for ISA bus etc.)
47#
48# This information could be given to the child device as a struct but
49# that makes it hard for a bus to add or remove variables without
50# forcing an edit and recompile for all drivers which may not be
51# possible for vendor supplied binary drivers.
52
53#
54# Read an instance variable. Return 0 on success.
55#
56METHOD int read_ivar {
57 device_t dev;
58 device_t child;
59 int index;
60 uintptr_t *result;
61};
62
63#
64# Write an instance variable. Return 0 on success.
65#
66METHOD int write_ivar {
67 device_t dev;
68 device_t child;
69 int index;
70 uintptr_t value;
71};
72
73#
74# Called after the child's DEVICE_DETACH method to allow the parent
75# to reclaim any resources allocated on behalf of the child.
76#
77METHOD void child_detached {
78 device_t dev;
79 device_t child;
80};
81
82#
83# Called when a new driver is added to the devclass which owns this
84# bus. The generic implementation of this method attempts to probe and
85# attach any un-matched children of the bus.
86#
87METHOD void driver_added {
88 device_t dev;
89 driver_t *driver;
90}
91
92#
83# Allocate a system resource attached to `dev' on behalf of `child'.
84# The types are defined in <machine/resource.h>; the meaning of the
85# resource-ID field varies from bus to bus (but *rid == 0 is always
86# valid if the resource type is). start and end reflect the allowable
87# range, and should be passed as `0UL' and `~0UL', respectively, if
88# the client has no range restriction. count is the number of consecutive
89# indices in the resource required. flags is a set of sharing flags
90# as defined in <sys/rman.h>.
91#
92# Returns a resource or a null pointer on failure. The caller is
93# responsible for calling rman_activate_resource() when it actually
94# uses the resource.
95#
96METHOD struct resource * alloc_resource {
97 device_t dev;
98 device_t child;
99 int type;
100 int *rid;
101 u_long start;
102 u_long end;
103 u_long count;
104 u_int flags;
105};
106
107METHOD int activate_resource {
108 device_t dev;
109 device_t child;
110 int type;
111 int rid;
112 struct resource *r;
113};
114
115METHOD int deactivate_resource {
116 device_t dev;
117 device_t child;
118 int type;
119 int rid;
120 struct resource *r;
121};
122
123#
124# Free a resource allocated by the preceding method. The `rid' value
125# must be the same as the one returned by BUS_ALLOC_RESOURCE (which
126# is not necessarily the same as the one the client passed).
127#
128METHOD int release_resource {
129 device_t dev;
130 device_t child;
131 int type;
132 int rid;
133 struct resource *res;
134};
135
136METHOD int setup_intr {
137 device_t dev;
138 device_t child;
139 struct resource *irq;
140 driver_intr_t *intr;
141 void *arg;
142 void **cookiep;
143};
144
145METHOD int teardown_intr {
146 device_t dev;
147 device_t child;
148 struct resource *irq;
149 void *cookie;
150};
93# Allocate a system resource attached to `dev' on behalf of `child'.
94# The types are defined in <machine/resource.h>; the meaning of the
95# resource-ID field varies from bus to bus (but *rid == 0 is always
96# valid if the resource type is). start and end reflect the allowable
97# range, and should be passed as `0UL' and `~0UL', respectively, if
98# the client has no range restriction. count is the number of consecutive
99# indices in the resource required. flags is a set of sharing flags
100# as defined in <sys/rman.h>.
101#
102# Returns a resource or a null pointer on failure. The caller is
103# responsible for calling rman_activate_resource() when it actually
104# uses the resource.
105#
106METHOD struct resource * alloc_resource {
107 device_t dev;
108 device_t child;
109 int type;
110 int *rid;
111 u_long start;
112 u_long end;
113 u_long count;
114 u_int flags;
115};
116
117METHOD int activate_resource {
118 device_t dev;
119 device_t child;
120 int type;
121 int rid;
122 struct resource *r;
123};
124
125METHOD int deactivate_resource {
126 device_t dev;
127 device_t child;
128 int type;
129 int rid;
130 struct resource *r;
131};
132
133#
134# Free a resource allocated by the preceding method. The `rid' value
135# must be the same as the one returned by BUS_ALLOC_RESOURCE (which
136# is not necessarily the same as the one the client passed).
137#
138METHOD int release_resource {
139 device_t dev;
140 device_t child;
141 int type;
142 int rid;
143 struct resource *res;
144};
145
146METHOD int setup_intr {
147 device_t dev;
148 device_t child;
149 struct resource *irq;
150 driver_intr_t *intr;
151 void *arg;
152 void **cookiep;
153};
154
155METHOD int teardown_intr {
156 device_t dev;
157 device_t child;
158 struct resource *irq;
159 void *cookie;
160};