podulebus_io.c revision 1.2 1 /* $NetBSD: podulebus_io.c,v 1.2 2002/09/27 15:35:31 provos Exp $ */
2
3 /*
4 * Copyright (c) 1997 Mark Brinicombe.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Mark Brinicombe.
18 * 4. The name of the company nor the name of the author may be used to
19 * endorse or promote products derived from this software without specific
20 * prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
23 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
24 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
26 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 */
34
35 /*
36 * bus_space I/O functions for podulebus
37 */
38
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <machine/bus.h>
42
43 /* Proto types for all the bus_space structure functions */
44
45 bs_protos(podulebus);
46 bs_protos(bs_notimpl);
47
48 /* Declare the podulebus bus space tag */
49
50 struct bus_space podulebus_bs_tag = {
51 /* cookie */
52 (void *) 2, /* Shift to apply to registers */
53
54 /* mapping/unmapping */
55 podulebus_bs_map,
56 podulebus_bs_unmap,
57 podulebus_bs_subregion,
58
59 /* allocation/deallocation */
60 podulebus_bs_alloc,
61 podulebus_bs_free,
62
63 /* get kernel virtual address */
64 0, /* there is no linear mapping */
65
66 /* mmap bus space for userland */
67 bs_notimpl_bs_mmap, /* there is no bus mapping ... well maybe EASI space? */
68
69 /* barrier */
70 podulebus_bs_barrier,
71
72 /* read (single) */
73 podulebus_bs_r_1,
74 podulebus_bs_r_2,
75 podulebus_bs_r_4,
76 bs_notimpl_bs_r_8,
77
78 /* read multiple */
79 podulebus_bs_rm_1,
80 podulebus_bs_rm_2,
81 bs_notimpl_bs_rm_4,
82 bs_notimpl_bs_rm_8,
83
84 /* read region */
85 podulebus_bs_rr_1,
86 podulebus_bs_rr_2,
87 bs_notimpl_bs_rr_4,
88 bs_notimpl_bs_rr_8,
89
90 /* write (single) */
91 podulebus_bs_w_1,
92 podulebus_bs_w_2,
93 podulebus_bs_w_4,
94 bs_notimpl_bs_w_8,
95
96 /* write multiple */
97 podulebus_bs_wm_1,
98 podulebus_bs_wm_2,
99 bs_notimpl_bs_wm_4,
100 bs_notimpl_bs_wm_8,
101
102 /* write region */
103 podulebus_bs_wr_1,
104 podulebus_bs_wr_2,
105 bs_notimpl_bs_wr_4,
106 bs_notimpl_bs_wr_8,
107
108 /* set multiple */
109 bs_notimpl_bs_sm_1,
110 bs_notimpl_bs_sm_2,
111 bs_notimpl_bs_sm_4,
112 bs_notimpl_bs_sm_8,
113
114 /* set region */
115 podulebus_bs_sr_1,
116 podulebus_bs_sr_2,
117 bs_notimpl_bs_sr_4,
118 bs_notimpl_bs_sr_8,
119
120 /* copy */
121 bs_notimpl_bs_c_1,
122 bs_notimpl_bs_c_2,
123 bs_notimpl_bs_c_4,
124 bs_notimpl_bs_c_8,
125 };
126
127 /* bus space functions */
128
129 int
130 podulebus_bs_map(t, bpa, size, cacheable, bshp)
131 void *t;
132 bus_addr_t bpa;
133 bus_size_t size;
134 int cacheable;
135 bus_space_handle_t *bshp;
136 {
137 /*
138 * Temporary implementation as all I/O is already mapped etc.
139 *
140 * Eventually this function will do the mapping check for multiple maps
141 */
142 *bshp = bpa;
143 return(0);
144 }
145
146 int
147 podulebus_bs_alloc(t, rstart, rend, size, alignment, boundary, cacheable,
148 bpap, bshp)
149 void *t;
150 bus_addr_t rstart, rend;
151 bus_size_t size, alignment, boundary;
152 int cacheable;
153 bus_addr_t *bpap;
154 bus_space_handle_t *bshp;
155 {
156 panic("podulebus_bs_alloc(): Help!");
157 }
158
159
160 void
161 podulebus_bs_unmap(t, bsh, size)
162 void *t;
163 bus_space_handle_t bsh;
164 bus_size_t size;
165 {
166 /*
167 * Temporary implementation
168 */
169 }
170
171 void
172 podulebus_bs_free(t, bsh, size)
173 void *t;
174 bus_space_handle_t bsh;
175 bus_size_t size;
176 {
177
178 panic("podulebus_bs_free(): Help!");
179 /* podulebus_bs_unmap() does all that we need to do. */
180 /* podulebus_bs_unmap(t, bsh, size);*/
181 }
182
183 int
184 podulebus_bs_subregion(t, bsh, offset, size, nbshp)
185 void *t;
186 bus_space_handle_t bsh;
187 bus_size_t offset, size;
188 bus_space_handle_t *nbshp;
189 {
190
191 *nbshp = bsh + (offset << ((int)t));
192 return (0);
193 }
194
195 void
196 podulebus_bs_barrier(t, bsh, offset, len, flags)
197 void *t;
198 bus_space_handle_t bsh;
199 bus_size_t offset, len;
200 int flags;
201 {
202 }
203
204 /* Rough-and-ready implementations from arm26 */
205
206 void
207 podulebus_bs_rr_1(void *cookie, bus_space_handle_t bsh,
208 bus_size_t offset, u_int8_t *datap, bus_size_t count)
209 {
210 int i;
211
212 for (i = 0; i < count; i++)
213 datap[i] = podulebus_bs_r_1(cookie, bsh, offset + i);
214 }
215
216 void
217 podulebus_bs_rr_2(void *cookie, bus_space_handle_t bsh,
218 bus_size_t offset, u_int16_t *datap, bus_size_t count)
219 {
220 int i;
221
222 for (i = 0; i < count; i++)
223 datap[i] = podulebus_bs_r_2(cookie, bsh, offset + i);
224 }
225
226 void
227 podulebus_bs_wr_1(void *cookie, bus_space_handle_t bsh,
228 bus_size_t offset, u_int8_t const *datap,
229 bus_size_t count)
230 {
231 int i;
232
233 for (i = 0; i < count; i++)
234 podulebus_bs_w_1(cookie, bsh, offset + i, datap[i]);
235 }
236
237 void
238 podulebus_bs_wr_2(void *cookie, bus_space_handle_t bsh,
239 bus_size_t offset, u_int16_t const *datap,
240 bus_size_t count)
241 {
242 int i;
243
244 for (i = 0; i < count; i++)
245 podulebus_bs_w_2(cookie, bsh, offset + i, datap[i]);
246 }
247
248 void
249 podulebus_bs_sr_1(void *cookie, bus_space_handle_t bsh,
250 bus_size_t offset, u_int8_t value, bus_size_t count)
251 {
252 int i;
253
254 for (i = 0; i < count; i++)
255 podulebus_bs_w_1(cookie, bsh, offset + i, value);
256 }
257
258 void
259 podulebus_bs_sr_2(void *cookie, bus_space_handle_t bsh,
260 bus_size_t offset, u_int16_t value, bus_size_t count)
261 {
262 int i;
263
264 for (i = 0; i < count; i++)
265 podulebus_bs_w_2(cookie, bsh, offset + i, value);
266 }
267