Mon Nov 27 17:27:37 2017 UTC ()
KNF


(skrll)
diff -r1.11 -r1.12 src/sys/arch/arm/broadcom/bcm2835_space.c

cvs diff -r1.11 -r1.12 src/sys/arch/arm/broadcom/Attic/bcm2835_space.c (switch to unified diff)

--- src/sys/arch/arm/broadcom/Attic/bcm2835_space.c 2017/11/09 21:37:52 1.11
+++ src/sys/arch/arm/broadcom/Attic/bcm2835_space.c 2017/11/27 17:27:37 1.12
@@ -1,413 +1,413 @@ @@ -1,413 +1,413 @@
1/* $NetBSD: bcm2835_space.c,v 1.11 2017/11/09 21:37:52 skrll Exp $ */ 1/* $NetBSD: bcm2835_space.c,v 1.12 2017/11/27 17:27:37 skrll Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2012 The NetBSD Foundation, Inc. 4 * Copyright (c) 2012 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Nick Hudson 8 * by Nick Hudson
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32 32
33#include <sys/cdefs.h> 33#include <sys/cdefs.h>
34__KERNEL_RCSID(0, "$NetBSD: bcm2835_space.c,v 1.11 2017/11/09 21:37:52 skrll Exp $"); 34__KERNEL_RCSID(0, "$NetBSD: bcm2835_space.c,v 1.12 2017/11/27 17:27:37 skrll Exp $");
35 35
36#include <sys/param.h> 36#include <sys/param.h>
37#include <sys/systm.h> 37#include <sys/systm.h>
38 38
39#include <uvm/uvm_extern.h> 39#include <uvm/uvm_extern.h>
40 40
41#include <sys/bus.h> 41#include <sys/bus.h>
42 42
43#include <arm/locore.h> 43#include <arm/locore.h>
44#include <arm/broadcom/bcm2835reg.h> 44#include <arm/broadcom/bcm2835reg.h>
45 45
46/* Prototypes for all the bus_space structure functions */ 46/* Prototypes for all the bus_space structure functions */
47bs_protos(bcm2835); 47bs_protos(bcm2835);
48bs_protos(bcm2835_a4x); 48bs_protos(bcm2835_a4x);
49bs_protos(generic); 49bs_protos(generic);
50bs_protos(generic_armv4); 50bs_protos(generic_armv4);
51bs_protos(a4x); 51bs_protos(a4x);
52bs_protos(bs_notimpl); 52bs_protos(bs_notimpl);
53 53
54struct bus_space bcm2835_bs_tag = { 54struct bus_space bcm2835_bs_tag = {
55 /* cookie */ 55 /* cookie */
56 (void *) 0, 56 (void *) 0,
57 57
58 /* mapping/unmapping */ 58 /* mapping/unmapping */
59 bcm2835_bs_map, 59 bcm2835_bs_map,
60 bcm2835_bs_unmap, 60 bcm2835_bs_unmap,
61 bcm2835_bs_subregion, 61 bcm2835_bs_subregion,
62 62
63 /* allocation/deallocation */ 63 /* allocation/deallocation */
64 bcm2835_bs_alloc, /* not implemented */ 64 bcm2835_bs_alloc, /* not implemented */
65 bcm2835_bs_free, /* not implemented */ 65 bcm2835_bs_free, /* not implemented */
66 66
67 /* get kernel virtual address */ 67 /* get kernel virtual address */
68 bcm2835_bs_vaddr, 68 bcm2835_bs_vaddr,
69 69
70 /* mmap */ 70 /* mmap */
71 bcm2835_bs_mmap, 71 bcm2835_bs_mmap,
72 72
73 /* barrier */ 73 /* barrier */
74 bcm2835_bs_barrier, 74 bcm2835_bs_barrier,
75 75
76 /* read (single) */ 76 /* read (single) */
77 generic_bs_r_1, 77 generic_bs_r_1,
78 generic_armv4_bs_r_2, 78 generic_armv4_bs_r_2,
79 generic_bs_r_4, 79 generic_bs_r_4,
80 bs_notimpl_bs_r_8, 80 bs_notimpl_bs_r_8,
81 81
82 /* read multiple */ 82 /* read multiple */
83 generic_bs_rm_1, 83 generic_bs_rm_1,
84 generic_armv4_bs_rm_2, 84 generic_armv4_bs_rm_2,
85 generic_bs_rm_4, 85 generic_bs_rm_4,
86 bs_notimpl_bs_rm_8, 86 bs_notimpl_bs_rm_8,
87 87
88 /* read region */ 88 /* read region */
89 generic_bs_rr_1, 89 generic_bs_rr_1,
90 generic_armv4_bs_rr_2, 90 generic_armv4_bs_rr_2,
91 generic_bs_rr_4, 91 generic_bs_rr_4,
92 bs_notimpl_bs_rr_8, 92 bs_notimpl_bs_rr_8,
93 93
94 /* write (single) */ 94 /* write (single) */
95 generic_bs_w_1, 95 generic_bs_w_1,
96 generic_armv4_bs_w_2, 96 generic_armv4_bs_w_2,
97 generic_bs_w_4, 97 generic_bs_w_4,
98 bs_notimpl_bs_w_8, 98 bs_notimpl_bs_w_8,
99 99
100 /* write multiple */ 100 /* write multiple */
101 generic_bs_wm_1, 101 generic_bs_wm_1,
102 generic_armv4_bs_wm_2, 102 generic_armv4_bs_wm_2,
103 generic_bs_wm_4, 103 generic_bs_wm_4,
104 bs_notimpl_bs_wm_8, 104 bs_notimpl_bs_wm_8,
105 105
106 /* write region */ 106 /* write region */
107 generic_bs_wr_1, 107 generic_bs_wr_1,
108 generic_armv4_bs_wr_2, 108 generic_armv4_bs_wr_2,
109 generic_bs_wr_4, 109 generic_bs_wr_4,
110 bs_notimpl_bs_wr_8, 110 bs_notimpl_bs_wr_8,
111 111
112 /* set multiple */ 112 /* set multiple */
113 bs_notimpl_bs_sm_1, 113 bs_notimpl_bs_sm_1,
114 bs_notimpl_bs_sm_2, 114 bs_notimpl_bs_sm_2,
115 bs_notimpl_bs_sm_4, 115 bs_notimpl_bs_sm_4,
116 bs_notimpl_bs_sm_8, 116 bs_notimpl_bs_sm_8,
117 117
118 /* set region */ 118 /* set region */
119 generic_bs_sr_1, 119 generic_bs_sr_1,
120 generic_armv4_bs_sr_2, 120 generic_armv4_bs_sr_2,
121 bs_notimpl_bs_sr_4, 121 bs_notimpl_bs_sr_4,
122 bs_notimpl_bs_sr_8, 122 bs_notimpl_bs_sr_8,
123 123
124 /* copy */ 124 /* copy */
125 bs_notimpl_bs_c_1, 125 bs_notimpl_bs_c_1,
126 generic_armv4_bs_c_2, 126 generic_armv4_bs_c_2,
127 bs_notimpl_bs_c_4, 127 bs_notimpl_bs_c_4,
128 bs_notimpl_bs_c_8, 128 bs_notimpl_bs_c_8,
129 129
130#ifdef __BUS_SPACE_HAS_STREAM_METHODS 130#ifdef __BUS_SPACE_HAS_STREAM_METHODS
131 /* read (single) */ 131 /* read (single) */
132 generic_bs_r_1, 132 generic_bs_r_1,
133 generic_armv4_bs_r_2, 133 generic_armv4_bs_r_2,
134 generic_bs_r_4, 134 generic_bs_r_4,
135 bs_notimpl_bs_r_8, 135 bs_notimpl_bs_r_8,
136 136
137 /* read multiple */ 137 /* read multiple */
138 generic_bs_rm_1, 138 generic_bs_rm_1,
139 generic_armv4_bs_rm_2, 139 generic_armv4_bs_rm_2,
140 generic_bs_rm_4, 140 generic_bs_rm_4,
141 bs_notimpl_bs_rm_8, 141 bs_notimpl_bs_rm_8,
142 142
143 /* read region */ 143 /* read region */
144 generic_bs_rr_1, 144 generic_bs_rr_1,
145 generic_armv4_bs_rr_2, 145 generic_armv4_bs_rr_2,
146 generic_bs_rr_4, 146 generic_bs_rr_4,
147 bs_notimpl_bs_rr_8, 147 bs_notimpl_bs_rr_8,
148 148
149 /* write (single) */ 149 /* write (single) */
150 generic_bs_w_1, 150 generic_bs_w_1,
151 generic_armv4_bs_w_2, 151 generic_armv4_bs_w_2,
152 generic_bs_w_4, 152 generic_bs_w_4,
153 bs_notimpl_bs_w_8, 153 bs_notimpl_bs_w_8,
154 154
155 /* write multiple */ 155 /* write multiple */
156 generic_bs_wm_1, 156 generic_bs_wm_1,
157 generic_armv4_bs_wm_2, 157 generic_armv4_bs_wm_2,
158 generic_bs_wm_4, 158 generic_bs_wm_4,
159 bs_notimpl_bs_wm_8, 159 bs_notimpl_bs_wm_8,
160 160
161 /* write region */ 161 /* write region */
162 generic_bs_wr_1, 162 generic_bs_wr_1,
163 generic_armv4_bs_wr_2, 163 generic_armv4_bs_wr_2,
164 generic_bs_wr_4, 164 generic_bs_wr_4,
165 bs_notimpl_bs_wr_8, 165 bs_notimpl_bs_wr_8,
166#endif 166#endif
167}; 167};
168 168
169struct bus_space bcm2835_a4x_bs_tag = { 169struct bus_space bcm2835_a4x_bs_tag = {
170 /* cookie */ 170 /* cookie */
171 (void *) 0, 171 (void *) 0,
172 172
173 /* mapping/unmapping */ 173 /* mapping/unmapping */
174 bcm2835_bs_map, 174 bcm2835_bs_map,
175 bcm2835_bs_unmap, 175 bcm2835_bs_unmap,
176 bcm2835_bs_subregion, 176 bcm2835_bs_subregion,
177 177
178 /* allocation/deallocation */ 178 /* allocation/deallocation */
179 bcm2835_bs_alloc, /* not implemented */ 179 bcm2835_bs_alloc, /* not implemented */
180 bcm2835_bs_free, /* not implemented */ 180 bcm2835_bs_free, /* not implemented */
181 181
182 /* get kernel virtual address */ 182 /* get kernel virtual address */
183 bcm2835_bs_vaddr, 183 bcm2835_bs_vaddr,
184 184
185 /* mmap */ 185 /* mmap */
186 bs_notimpl_bs_mmap, 186 bs_notimpl_bs_mmap,
187 187
188 /* barrier */ 188 /* barrier */
189 bcm2835_bs_barrier, 189 bcm2835_bs_barrier,
190 190
191 /* read (single) */ 191 /* read (single) */
192 a4x_bs_r_1, 192 a4x_bs_r_1,
193 a4x_bs_r_2, 193 a4x_bs_r_2,
194 a4x_bs_r_4, 194 a4x_bs_r_4,
195 bs_notimpl_bs_r_8, 195 bs_notimpl_bs_r_8,
196 196
197 /* read multiple */ 197 /* read multiple */
198 a4x_bs_rm_1, 198 a4x_bs_rm_1,
199 a4x_bs_rm_2, 199 a4x_bs_rm_2,
200 a4x_bs_rm_4, 200 a4x_bs_rm_4,
201 bs_notimpl_bs_rm_8, 201 bs_notimpl_bs_rm_8,
202 202
203 /* read region */ 203 /* read region */
204 bs_notimpl_bs_rr_1, 204 bs_notimpl_bs_rr_1,
205 bs_notimpl_bs_rr_2, 205 bs_notimpl_bs_rr_2,
206 bs_notimpl_bs_rr_4, 206 bs_notimpl_bs_rr_4,
207 bs_notimpl_bs_rr_8, 207 bs_notimpl_bs_rr_8,
208 208
209 /* write (single) */ 209 /* write (single) */
210 a4x_bs_w_1, 210 a4x_bs_w_1,
211 a4x_bs_w_2, 211 a4x_bs_w_2,
212 a4x_bs_w_4, 212 a4x_bs_w_4,
213 bs_notimpl_bs_w_8, 213 bs_notimpl_bs_w_8,
214 214
215 /* write multiple */ 215 /* write multiple */
216 a4x_bs_wm_1, 216 a4x_bs_wm_1,
217 a4x_bs_wm_2, 217 a4x_bs_wm_2,
218 a4x_bs_wm_4, 218 a4x_bs_wm_4,
219 bs_notimpl_bs_wm_8, 219 bs_notimpl_bs_wm_8,
220 /* write region */ 220 /* write region */
221 bs_notimpl_bs_wr_1, 221 bs_notimpl_bs_wr_1,
222 bs_notimpl_bs_wr_2, 222 bs_notimpl_bs_wr_2,
223 bs_notimpl_bs_wr_4, 223 bs_notimpl_bs_wr_4,
224 bs_notimpl_bs_wr_8, 224 bs_notimpl_bs_wr_8,
225 225
226 /* set multiple */ 226 /* set multiple */
227 bs_notimpl_bs_sm_1, 227 bs_notimpl_bs_sm_1,
228 bs_notimpl_bs_sm_2, 228 bs_notimpl_bs_sm_2,
229 bs_notimpl_bs_sm_4, 229 bs_notimpl_bs_sm_4,
230 bs_notimpl_bs_sm_8, 230 bs_notimpl_bs_sm_8,
231 231
232 /* set region */ 232 /* set region */
233 bs_notimpl_bs_sr_1, 233 bs_notimpl_bs_sr_1,
234 bs_notimpl_bs_sr_2, 234 bs_notimpl_bs_sr_2,
235 bs_notimpl_bs_sr_4, 235 bs_notimpl_bs_sr_4,
236 bs_notimpl_bs_sr_8, 236 bs_notimpl_bs_sr_8,
237 237
238 /* copy */ 238 /* copy */
239 bs_notimpl_bs_c_1, 239 bs_notimpl_bs_c_1,
240 bs_notimpl_bs_c_2, 240 bs_notimpl_bs_c_2,
241 bs_notimpl_bs_c_4, 241 bs_notimpl_bs_c_4,
242 bs_notimpl_bs_c_8, 242 bs_notimpl_bs_c_8,
243 243
244#ifdef __BUS_SPACE_HAS_STREAM_METHODS 244#ifdef __BUS_SPACE_HAS_STREAM_METHODS
245 /* read (single) */ 245 /* read (single) */
246 generic_bs_r_1, 246 generic_bs_r_1,
247 generic_armv4_bs_r_2, 247 generic_armv4_bs_r_2,
248 generic_bs_r_4, 248 generic_bs_r_4,
249 bs_notimpl_bs_r_8, 249 bs_notimpl_bs_r_8,
250 250
251 /* read multiple */ 251 /* read multiple */
252 generic_bs_rm_1, 252 generic_bs_rm_1,
253 generic_armv4_bs_rm_2, 253 generic_armv4_bs_rm_2,
254 generic_bs_rm_4, 254 generic_bs_rm_4,
255 bs_notimpl_bs_rm_8, 255 bs_notimpl_bs_rm_8,
256 256
257 /* read region */ 257 /* read region */
258 generic_bs_rr_1, 258 generic_bs_rr_1,
259 generic_armv4_bs_rr_2, 259 generic_armv4_bs_rr_2,
260 generic_bs_rr_4, 260 generic_bs_rr_4,
261 bs_notimpl_bs_rr_8, 261 bs_notimpl_bs_rr_8,
262 262
263 /* write (single) */ 263 /* write (single) */
264 generic_bs_w_1, 264 generic_bs_w_1,
265 generic_armv4_bs_w_2, 265 generic_armv4_bs_w_2,
266 generic_bs_w_4, 266 generic_bs_w_4,
267 bs_notimpl_bs_w_8, 267 bs_notimpl_bs_w_8,
268 268
269 /* write multiple */ 269 /* write multiple */
270 generic_bs_wm_1, 270 generic_bs_wm_1,
271 generic_armv4_bs_wm_2, 271 generic_armv4_bs_wm_2,
272 generic_bs_wm_4, 272 generic_bs_wm_4,
273 bs_notimpl_bs_wm_8, 273 bs_notimpl_bs_wm_8,
274 274
275 /* write region */ 275 /* write region */
276 generic_bs_wr_1, 276 generic_bs_wr_1,
277 generic_armv4_bs_wr_2, 277 generic_armv4_bs_wr_2,
278 generic_bs_wr_4, 278 generic_bs_wr_4,
279 bs_notimpl_bs_wr_8, 279 bs_notimpl_bs_wr_8,
280#endif 280#endif
281 281
282}; 282};
283 283
284 284
285int 285int
286bcm2835_bs_map(void *t, bus_addr_t ba, bus_size_t size, int flag, 286bcm2835_bs_map(void *t, bus_addr_t ba, bus_size_t size, int flag,
287 bus_space_handle_t *bshp) 287 bus_space_handle_t *bshp)
288{ 288{
289 u_long startpa, endpa, pa; 289 u_long startpa, endpa, pa;
290 vaddr_t va; 290 vaddr_t va;
291 const struct pmap_devmap *pd; 291 const struct pmap_devmap *pd;
292 int pmap_flags; 292 int pmap_flags;
293 bool match = false; 293 bool match = false;
294 294
295 /* Attempt to find the PA device mapping */ 295 /* Attempt to find the PA device mapping */
296 if (ba >= BCM2835_PERIPHERALS_BASE_BUS && 296 if (ba >= BCM2835_PERIPHERALS_BASE_BUS &&
297 ba < BCM2835_PERIPHERALS_BASE_BUS + BCM2835_PERIPHERALS_SIZE) { 297 ba < BCM2835_PERIPHERALS_BASE_BUS + BCM2835_PERIPHERALS_SIZE) {
298 match = true; 298 match = true;
299 pa = BCM2835_PERIPHERALS_BUS_TO_PHYS(ba); 299 pa = BCM2835_PERIPHERALS_BUS_TO_PHYS(ba);
300 300
301 } 301 }
302#ifdef BCM2836 302#ifdef BCM2836
303 if (ba >= BCM2836_ARM_LOCAL_BASE && 303 if (ba >= BCM2836_ARM_LOCAL_BASE &&
304 ba < BCM2836_ARM_LOCAL_BASE + BCM2836_ARM_LOCAL_SIZE) { 304 ba < BCM2836_ARM_LOCAL_BASE + BCM2836_ARM_LOCAL_SIZE) {
305 match = true; 305 match = true;
306 pa = ba; 306 pa = ba;
307 } 307 }
308#endif 308#endif
309 309
310 if (match && (pd = pmap_devmap_find_pa(pa, size)) != NULL) { 310 if (match && (pd = pmap_devmap_find_pa(pa, size)) != NULL) {
311 /* Device was statically mapped. */ 311 /* Device was statically mapped. */
312 *bshp = pd->pd_va + (pa - pd->pd_pa); 312 *bshp = pd->pd_va + (pa - pd->pd_pa);
313 return 0; 313 return 0;
314 } 314 }
315 315
316 /* Now assume bus address so convert to PA */ 316 /* Now assume bus address so convert to PA */
317 pa = ba & ~BCM2835_BUSADDR_CACHE_MASK; 317 pa = ba & ~BCM2835_BUSADDR_CACHE_MASK;
318 318
319 startpa = trunc_page(pa); 319 startpa = trunc_page(pa);
320 endpa = round_page(pa + size); 320 endpa = round_page(pa + size);
321 321
322 /* XXX use extent manager to check duplicate mapping */ 322 /* XXX use extent manager to check duplicate mapping */
323 323
324 va = uvm_km_alloc(kernel_map, endpa - startpa, 0, 324 va = uvm_km_alloc(kernel_map, endpa - startpa, 0,
325 UVM_KMF_VAONLY | UVM_KMF_NOWAIT); 325 UVM_KMF_VAONLY | UVM_KMF_NOWAIT);
326 if (!va) 326 if (!va)
327 return ENOMEM; 327 return ENOMEM;
328 328
329 *bshp = (bus_space_handle_t)(va + (pa - startpa)); 329 *bshp = (bus_space_handle_t)(va + (pa - startpa));
330 330
331 pmap_flags = (flag & BUS_SPACE_MAP_CACHEABLE) ? 0 : PMAP_NOCACHE; 331 pmap_flags = (flag & BUS_SPACE_MAP_CACHEABLE) ? 0 : PMAP_NOCACHE;
332 for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { 332 for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) {
333 pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, 333 pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE,
334 pmap_flags); 334 pmap_flags);
335 } 335 }
336 pmap_update(pmap_kernel()); 336 pmap_update(pmap_kernel());
337 337
338 return 0; 338 return 0;
339} 339}
340 340
341void 341void
342bcm2835_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size) 342bcm2835_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size)
343{ 343{
344 vaddr_t va; 344 vaddr_t va;
345 vsize_t sz; 345 vsize_t sz;
346 346
347 if (pmap_devmap_find_va(bsh, size) != NULL) { 347 if (pmap_devmap_find_va(bsh, size) != NULL) {
348 /* Device was statically mapped; nothing to do. */ 348 /* Device was statically mapped; nothing to do. */
349 return; 349 return;
350 } 350 }
351 351
352 va = trunc_page(bsh); 352 va = trunc_page(bsh);
353 sz = round_page(bsh + size) - va; 353 sz = round_page(bsh + size) - va;
354 354
355 pmap_kremove(va, sz); 355 pmap_kremove(va, sz);
356 pmap_update(pmap_kernel()); 356 pmap_update(pmap_kernel());
357 uvm_km_free(kernel_map, va, sz, UVM_KMF_VAONLY); 357 uvm_km_free(kernel_map, va, sz, UVM_KMF_VAONLY);
358} 358}
359 359
360 360
361int 361int
362bcm2835_bs_subregion(void *t, bus_space_handle_t bsh, bus_size_t offset, 362bcm2835_bs_subregion(void *t, bus_space_handle_t bsh, bus_size_t offset,
363 bus_size_t size, bus_space_handle_t *nbshp) 363 bus_size_t size, bus_space_handle_t *nbshp)
364{ 364{
365 365
366 *nbshp = bsh + offset; 366 *nbshp = bsh + offset;
367 return (0); 367 return 0;
368} 368}
369 369
370void 370void
371bcm2835_bs_barrier(void *t, bus_space_handle_t bsh, bus_size_t offset, 371bcm2835_bs_barrier(void *t, bus_space_handle_t bsh, bus_size_t offset,
372 bus_size_t len, int flags) 372 bus_size_t len, int flags)
373{ 373{
374 flags &= BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE; 374 flags &= BUS_SPACE_BARRIER_READ|BUS_SPACE_BARRIER_WRITE;
375 375
376 if (flags) 376 if (flags)
377 arm_dsb(); 377 arm_dsb();
378} 378}
379 379
380void * 380void *
381bcm2835_bs_vaddr(void *t, bus_space_handle_t bsh) 381bcm2835_bs_vaddr(void *t, bus_space_handle_t bsh)
382{ 382{
383 383
384 return (void *)bsh; 384 return (void *)bsh;
385} 385}
386 386
387paddr_t 387paddr_t
388bcm2835_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags) 388bcm2835_bs_mmap(void *t, bus_addr_t ba, off_t offset, int prot, int flags)
389{ 389{
390 paddr_t pa = ba & ~BCM2835_BUSADDR_CACHE_MASK; 390 paddr_t pa = ba & ~BCM2835_BUSADDR_CACHE_MASK;
391 paddr_t bus_flags = 0; 391 paddr_t bus_flags = 0;
392 392
393 if (flags & BUS_SPACE_MAP_PREFETCHABLE) 393 if (flags & BUS_SPACE_MAP_PREFETCHABLE)
394 bus_flags |= ARM32_MMAP_WRITECOMBINE; 394 bus_flags |= ARM32_MMAP_WRITECOMBINE;
395 395
396 return (arm_btop(pa + offset) | bus_flags); 396 return arm_btop(pa + offset) | bus_flags;
397} 397}
398 398
399int 399int
400bcm2835_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, 400bcm2835_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend,
401 bus_size_t size, bus_size_t alignment, bus_size_t boundary, int flags, 401 bus_size_t size, bus_size_t alignment, bus_size_t boundary, int flags,
402 bus_addr_t *bpap, bus_space_handle_t *bshp) 402 bus_addr_t *bpap, bus_space_handle_t *bshp)
403{ 403{
404 404
405 panic("%s(): not implemented\n", __func__); 405 panic("%s(): not implemented\n", __func__);
406} 406}
407 407
408void 408void
409bcm2835_bs_free(void *t, bus_space_handle_t bsh, bus_size_t size) 409bcm2835_bs_free(void *t, bus_space_handle_t bsh, bus_size_t size)
410{ 410{
411 411
412 panic("%s(): not implemented\n", __func__); 412 panic("%s(): not implemented\n", __func__);
413} 413}