Don't manipulate the pte to get uncached memory, use PMAP_NOCACHE instead. Convert footbring to kenter_pa/kremovediff -r1.21 -r1.22 src/sys/arch/arm/footbridge/footbridge_io.c
(matt)
--- src/sys/arch/arm/footbridge/footbridge_io.c 2012/02/12 16:34:07 1.21
+++ src/sys/arch/arm/footbridge/footbridge_io.c 2014/02/22 20:33:00 1.22
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: footbridge_io.c,v 1.21 2012/02/12 16:34:07 matt Exp $ */ | 1 | /* $NetBSD: footbridge_io.c,v 1.22 2014/02/22 20:33:00 matt Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1997 Causality Limited | 4 | * Copyright (c) 1997 Causality Limited | |
5 | * Copyright (c) 1997 Mark Brinicombe. | 5 | * Copyright (c) 1997 Mark Brinicombe. | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
@@ -29,27 +29,27 @@ | @@ -29,27 +29,27 @@ | |||
29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
34 | * SUCH DAMAGE. | 34 | * SUCH DAMAGE. | |
35 | */ | 35 | */ | |
36 | 36 | |||
37 | /* | 37 | /* | |
38 | * bus_space I/O functions for footbridge | 38 | * bus_space I/O functions for footbridge | |
39 | */ | 39 | */ | |
40 | 40 | |||
41 | #include <sys/cdefs.h> | 41 | #include <sys/cdefs.h> | |
42 | __KERNEL_RCSID(0, "$NetBSD: footbridge_io.c,v 1.21 2012/02/12 16:34:07 matt Exp $"); | 42 | __KERNEL_RCSID(0, "$NetBSD: footbridge_io.c,v 1.22 2014/02/22 20:33:00 matt Exp $"); | |
43 | 43 | |||
44 | #include <sys/param.h> | 44 | #include <sys/param.h> | |
45 | #include <sys/systm.h> | 45 | #include <sys/systm.h> | |
46 | #include <sys/bus.h> | 46 | #include <sys/bus.h> | |
47 | #include <arm/footbridge/footbridge.h> | 47 | #include <arm/footbridge/footbridge.h> | |
48 | #include <arm/footbridge/dc21285mem.h> | 48 | #include <arm/footbridge/dc21285mem.h> | |
49 | #include <uvm/uvm_extern.h> | 49 | #include <uvm/uvm_extern.h> | |
50 | 50 | |||
51 | /* Proto types for all the bus_space structure functions */ | 51 | /* Proto types for all the bus_space structure functions */ | |
52 | 52 | |||
53 | bs_protos(footbridge); | 53 | bs_protos(footbridge); | |
54 | bs_protos(generic); | 54 | bs_protos(generic); | |
55 | bs_protos(generic_armv4); | 55 | bs_protos(generic_armv4); | |
@@ -169,27 +169,28 @@ footbridge_bs_map(void *t, bus_addr_t bp | @@ -169,27 +169,28 @@ footbridge_bs_map(void *t, bus_addr_t bp | |||
169 | * The whole 64K of PCI space is always completely mapped during | 169 | * The whole 64K of PCI space is always completely mapped during | |
170 | * boot. | 170 | * boot. | |
171 | * | 171 | * | |
172 | * Eventually this function will do the mapping check overlapping / | 172 | * Eventually this function will do the mapping check overlapping / | |
173 | * multiple mappings. | 173 | * multiple mappings. | |
174 | */ | 174 | */ | |
175 | 175 | |||
176 | /* The cookie is the base address for the I/O area */ | 176 | /* The cookie is the base address for the I/O area */ | |
177 | *bshp = bpa + (bus_addr_t)t; | 177 | *bshp = bpa + (bus_addr_t)t; | |
178 | return(0); | 178 | return(0); | |
179 | } | 179 | } | |
180 | 180 | |||
181 | int | 181 | int | |
182 | footbridge_mem_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flags, bus_space_handle_t *bshp) | 182 | footbridge_mem_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flags, | |
183 | bus_space_handle_t *bshp) | |||
183 | { | 184 | { | |
184 | bus_addr_t startpa, endpa, pa; | 185 | bus_addr_t startpa, endpa, pa; | |
185 | vaddr_t va; | 186 | vaddr_t va; | |
186 | 187 | |||
187 | /* Round the allocation to page boundries */ | 188 | /* Round the allocation to page boundries */ | |
188 | startpa = trunc_page(bpa); | 189 | startpa = trunc_page(bpa); | |
189 | endpa = round_page(bpa + size); | 190 | endpa = round_page(bpa + size); | |
190 | 191 | |||
191 | /* | 192 | /* | |
192 | * Check for mappings below 1MB as we have this space already | 193 | * Check for mappings below 1MB as we have this space already | |
193 | * mapped. In practice it is only the VGA hole that takes | 194 | * mapped. In practice it is only the VGA hole that takes | |
194 | * advantage of this. | 195 | * advantage of this. | |
195 | */ | 196 | */ | |
@@ -204,35 +205,34 @@ footbridge_mem_bs_map(void *t, bus_addr_ | @@ -204,35 +205,34 @@ footbridge_mem_bs_map(void *t, bus_addr_ | |||
204 | * multiple mappings | 205 | * multiple mappings | |
205 | */ | 206 | */ | |
206 | 207 | |||
207 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | 208 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | |
208 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | 209 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | |
209 | if (va == 0) | 210 | if (va == 0) | |
210 | return ENOMEM; | 211 | return ENOMEM; | |
211 | 212 | |||
212 | /* Store the bus space handle */ | 213 | /* Store the bus space handle */ | |
213 | *bshp = va + (bpa & PGOFSET); | 214 | *bshp = va + (bpa & PGOFSET); | |
214 | 215 | |||
215 | /* Now map the pages */ | 216 | /* Now map the pages */ | |
216 | /* The cookie is the physical base address for the I/O area */ | 217 | /* The cookie is the physical base address for the I/O area */ | |
217 | for (pa = startpa; pa < endpa; pa+=PAGE_SIZE, va += PAGE_SIZE) { | 218 | const int pmapflags = | |
218 | pmap_enter(pmap_kernel(), va, (bus_addr_t)t + pa, VM_PROT_READ | VM_PROT_WRITE, | 219 | (flags & (BUS_SPACE_MAP_CACHEABLE|BUS_SPACE_MAP_PREFETCHABLE)) | |
219 | VM_PROT_READ | VM_PROT_WRITE| PMAP_WIRED); | 220 | ? 0 | |
220 | if ((flags & BUS_SPACE_MAP_CACHEABLE) == 0) { | 221 | : PMAP_NOCACHE; | |
221 | pt_entry_t *pte; | 222 | ||
222 | pte = vtopte(va); | 223 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | |
223 | *pte &= ~L2_S_CACHE_MASK; | 224 | pmap_kenter_pa(va, (bus_addr_t)t + pa, | |
224 | PTE_SYNC(pte); | 225 | VM_PROT_READ | VM_PROT_WRITE, pmapflags); | |
225 | } | |||
226 | } | 226 | } | |
227 | pmap_update(pmap_kernel()); | 227 | pmap_update(pmap_kernel()); | |
228 | 228 | |||
229 | /* if (bpa >= DC21285_PCI_MEM_VSIZE && bpa != DC21285_ARMCSR_VBASE) | 229 | /* if (bpa >= DC21285_PCI_MEM_VSIZE && bpa != DC21285_ARMCSR_VBASE) | |
230 | panic("footbridge_bs_map: Address out of range (%08lx)", bpa); | 230 | panic("footbridge_bs_map: Address out of range (%08lx)", bpa); | |
231 | */ | 231 | */ | |
232 | return(0); | 232 | return(0); | |
233 | } | 233 | } | |
234 | 234 | |||
235 | int | 235 | int | |
236 | footbridge_bs_alloc( | 236 | footbridge_bs_alloc( | |
237 | void *t, | 237 | void *t, | |
238 | bus_addr_t rstart, | 238 | bus_addr_t rstart, | |
@@ -264,27 +264,27 @@ footbridge_mem_bs_unmap(void *t, bus_spa | @@ -264,27 +264,27 @@ footbridge_mem_bs_unmap(void *t, bus_spa | |||
264 | /* | 264 | /* | |
265 | * Check for mappings below 1MB as we have this space permenantly | 265 | * Check for mappings below 1MB as we have this space permenantly | |
266 | * mapped. In practice it is only the VGA hole that takes | 266 | * mapped. In practice it is only the VGA hole that takes | |
267 | * advantage of this. | 267 | * advantage of this. | |
268 | */ | 268 | */ | |
269 | if (bsh >= DC21285_PCI_ISA_MEM_VBASE | 269 | if (bsh >= DC21285_PCI_ISA_MEM_VBASE | |
270 | && bsh < (DC21285_PCI_ISA_MEM_VBASE + DC21285_PCI_ISA_MEM_VSIZE)) { | 270 | && bsh < (DC21285_PCI_ISA_MEM_VBASE + DC21285_PCI_ISA_MEM_VSIZE)) { | |
271 | return; | 271 | return; | |
272 | } | 272 | } | |
273 | 273 | |||
274 | startva = trunc_page(bsh); | 274 | startva = trunc_page(bsh); | |
275 | endva = round_page(bsh + size); | 275 | endva = round_page(bsh + size); | |
276 | 276 | |||
277 | pmap_remove(pmap_kernel(), startva, endva); | 277 | pmap_kremove(startva, endva); | |
278 | pmap_update(pmap_kernel()); | 278 | pmap_update(pmap_kernel()); | |
279 | uvm_km_free(kernel_map, startva, endva - startva, UVM_KMF_VAONLY); | 279 | uvm_km_free(kernel_map, startva, endva - startva, UVM_KMF_VAONLY); | |
280 | } | 280 | } | |
281 | 281 | |||
282 | void | 282 | void | |
283 | footbridge_bs_free(void *t, bus_space_handle_t bsh, bus_size_t size) | 283 | footbridge_bs_free(void *t, bus_space_handle_t bsh, bus_size_t size) | |
284 | { | 284 | { | |
285 | 285 | |||
286 | panic("footbridge_free(): Help!"); | 286 | panic("footbridge_free(): Help!"); | |
287 | /* footbridge_bs_unmap() does all that we need to do. */ | 287 | /* footbridge_bs_unmap() does all that we need to do. */ | |
288 | /* footbridge_bs_unmap(t, bsh, size);*/ | 288 | /* footbridge_bs_unmap(t, bsh, size);*/ | |
289 | } | 289 | } | |
290 | 290 |
--- src/sys/arch/arm/gemini/gemini_space.c 2011/07/01 19:32:28 1.3
+++ src/sys/arch/arm/gemini/gemini_space.c 2014/02/22 20:33:00 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: gemini_space.c,v 1.3 2011/07/01 19:32:28 dyoung Exp $ */ | 1 | /* $NetBSD: gemini_space.c,v 1.4 2014/02/22 20:33:00 matt Exp $ */ | |
2 | 2 | |||
3 | /* adapted from: | 3 | /* adapted from: | |
4 | * NetBSD: pxa2x0_space.c,v 1.8 2005/11/24 13:08:32 yamt Exp | 4 | * NetBSD: pxa2x0_space.c,v 1.8 2005/11/24 13:08:32 yamt Exp | |
5 | */ | 5 | */ | |
6 | 6 | |||
7 | /* | 7 | /* | |
8 | * Copyright (c) 2001, 2002 Wasabi Systems, Inc. | 8 | * Copyright (c) 2001, 2002 Wasabi Systems, Inc. | |
9 | * All rights reserved. | 9 | * All rights reserved. | |
10 | * | 10 | * | |
11 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | 11 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | |
12 | * | 12 | * | |
13 | * Redistribution and use in source and binary forms, with or without | 13 | * Redistribution and use in source and binary forms, with or without | |
14 | * modification, are permitted provided that the following conditions | 14 | * modification, are permitted provided that the following conditions | |
@@ -69,27 +69,27 @@ | @@ -69,27 +69,27 @@ | |||
69 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 69 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
70 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 70 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
71 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 71 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
72 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 72 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
73 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 73 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
74 | * SUCH DAMAGE. | 74 | * SUCH DAMAGE. | |
75 | */ | 75 | */ | |
76 | 76 | |||
77 | /* | 77 | /* | |
78 | * bus_space functions for Gemini processor. | 78 | * bus_space functions for Gemini processor. | |
79 | */ | 79 | */ | |
80 | 80 | |||
81 | #include <sys/cdefs.h> | 81 | #include <sys/cdefs.h> | |
82 | __KERNEL_RCSID(0, "$NetBSD: gemini_space.c,v 1.3 2011/07/01 19:32:28 dyoung Exp $"); | 82 | __KERNEL_RCSID(0, "$NetBSD: gemini_space.c,v 1.4 2014/02/22 20:33:00 matt Exp $"); | |
83 | 83 | |||
84 | #include <sys/param.h> | 84 | #include <sys/param.h> | |
85 | #include <sys/systm.h> | 85 | #include <sys/systm.h> | |
86 | 86 | |||
87 | #include <uvm/uvm_extern.h> | 87 | #include <uvm/uvm_extern.h> | |
88 | 88 | |||
89 | #include <sys/bus.h> | 89 | #include <sys/bus.h> | |
90 | 90 | |||
91 | /* Prototypes for all the bus_space structure functions */ | 91 | /* Prototypes for all the bus_space structure functions */ | |
92 | bs_protos(gemini); | 92 | bs_protos(gemini); | |
93 | bs_protos(generic); | 93 | bs_protos(generic); | |
94 | bs_protos(generic_armv4); | 94 | bs_protos(generic_armv4); | |
95 | bs_protos(bs_notimpl); | 95 | bs_protos(bs_notimpl); | |
@@ -165,59 +165,52 @@ struct bus_space gemini_bs_tag = { | @@ -165,59 +165,52 @@ struct bus_space gemini_bs_tag = { | |||
165 | bs_notimpl_bs_sr_8, | 165 | bs_notimpl_bs_sr_8, | |
166 | 166 | |||
167 | /* copy */ | 167 | /* copy */ | |
168 | bs_notimpl_bs_c_1, | 168 | bs_notimpl_bs_c_1, | |
169 | generic_armv4_bs_c_2, | 169 | generic_armv4_bs_c_2, | |
170 | bs_notimpl_bs_c_4, | 170 | bs_notimpl_bs_c_4, | |
171 | bs_notimpl_bs_c_8, | 171 | bs_notimpl_bs_c_8, | |
172 | }; | 172 | }; | |
173 | 173 | |||
174 | int | 174 | int | |
175 | gemini_bs_map(void *t, bus_addr_t bpa, bus_size_t size, | 175 | gemini_bs_map(void *t, bus_addr_t bpa, bus_size_t size, | |
176 | int flag, bus_space_handle_t *bshp) | 176 | int flag, bus_space_handle_t *bshp) | |
177 | { | 177 | { | |
178 | u_long startpa, endpa, pa; | 178 | const struct pmap_devmap *pd; | |
179 | vaddr_t va; | |||
180 | pt_entry_t *pte; | |||
181 | const struct pmap_devmap *pd; | |||
182 | 179 | |||
183 | if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) { | 180 | if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) { | |
184 | /* Device was statically mapped. */ | 181 | /* Device was statically mapped. */ | |
185 | *bshp = pd->pd_va + (bpa - pd->pd_pa); | 182 | *bshp = pd->pd_va + (bpa - pd->pd_pa); | |
186 | return 0; | 183 | return 0; | |
187 | } | 184 | } | |
188 | 185 | |||
189 | startpa = trunc_page(bpa); | 186 | paddr_t startpa = trunc_page(bpa); | |
190 | endpa = round_page(bpa + size); | 187 | paddr_t endpa = round_page(bpa + size); | |
191 | 188 | |||
192 | /* XXX use extent manager to check duplicate mapping */ | 189 | /* XXX use extent manager to check duplicate mapping */ | |
193 | 190 | |||
194 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | 191 | vaddr_t va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | |
195 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | 192 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | |
196 | if (! va) | 193 | if (! va) | |
197 | return(ENOMEM); | 194 | return(ENOMEM); | |
198 | 195 | |||
199 | *bshp = (bus_space_handle_t)(va + (bpa - startpa)); | 196 | *bshp = (bus_space_handle_t)(va + (bpa - startpa)); | |
200 | 197 | |||
201 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | 198 | const int pmapflags = | |
202 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, 0); | 199 | (flag & (BUS_SPACE_MAP_CACHEABLE|BUS_SPACE_MAP_PREFETCHABLE)) | |
203 | if ((flag & BUS_SPACE_MAP_CACHEABLE) == 0) { | 200 | ? 0 | |
204 | pte = vtopte(va); | 201 | : PMAP_NOCACHE; | |
205 | *pte &= ~L2_S_CACHE_MASK; | 202 | for (paddr_t pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | |
206 | PTE_SYNC(pte); | 203 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, pmapflags); | |
207 | /* XXX: pmap_kenter_pa() also does PTE_SYNC(). a bit of | |||
208 | * waste. | |||
209 | */ | |||
210 | } | |||
211 | } | 204 | } | |
212 | pmap_update(pmap_kernel()); | 205 | pmap_update(pmap_kernel()); | |
213 | 206 | |||
214 | return(0); | 207 | return(0); | |
215 | } | 208 | } | |
216 | 209 | |||
217 | void | 210 | void | |
218 | gemini_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size) | 211 | gemini_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size) | |
219 | { | 212 | { | |
220 | vaddr_t va; | 213 | vaddr_t va; | |
221 | vsize_t sz; | 214 | vsize_t sz; | |
222 | 215 | |||
223 | if (pmap_devmap_find_va(bsh, size) != NULL) { | 216 | if (pmap_devmap_find_va(bsh, size) != NULL) { |
--- src/sys/arch/arm/ixp12x0/ixp12x0_io.c 2011/07/01 20:27:50 1.15
+++ src/sys/arch/arm/ixp12x0/ixp12x0_io.c 2014/02/22 20:33:00 1.16
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ixp12x0_io.c,v 1.15 2011/07/01 20:27:50 dyoung Exp $ */ | 1 | /* $NetBSD: ixp12x0_io.c,v 1.16 2014/02/22 20:33:00 matt Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2002, 2003 | 4 | * Copyright (c) 2002, 2003 | |
5 | * Ichiro FUKUHARA <ichiro@ichiro.org>. | 5 | * Ichiro FUKUHARA <ichiro@ichiro.org>. | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
@@ -18,27 +18,27 @@ | @@ -18,27 +18,27 @@ | |||
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
20 | * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR | 20 | * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR | |
21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
27 | * SUCH DAMAGE. | 27 | * SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #include <sys/cdefs.h> | 30 | #include <sys/cdefs.h> | |
31 | __KERNEL_RCSID(0, "$NetBSD: ixp12x0_io.c,v 1.15 2011/07/01 20:27:50 dyoung Exp $"); | 31 | __KERNEL_RCSID(0, "$NetBSD: ixp12x0_io.c,v 1.16 2014/02/22 20:33:00 matt Exp $"); | |
32 | 32 | |||
33 | /* | 33 | /* | |
34 | * bus_space I/O functions for ixp12x0 | 34 | * bus_space I/O functions for ixp12x0 | |
35 | */ | 35 | */ | |
36 | 36 | |||
37 | #include <sys/param.h> | 37 | #include <sys/param.h> | |
38 | #include <sys/systm.h> | 38 | #include <sys/systm.h> | |
39 | #include <sys/queue.h> | 39 | #include <sys/queue.h> | |
40 | 40 | |||
41 | #include <uvm/uvm.h> | 41 | #include <uvm/uvm.h> | |
42 | 42 | |||
43 | #include <sys/bus.h> | 43 | #include <sys/bus.h> | |
44 | 44 | |||
@@ -131,50 +131,50 @@ struct bus_space ixp12x0_bs_tag = { | @@ -131,50 +131,50 @@ struct bus_space ixp12x0_bs_tag = { | |||
131 | /* Common routines */ | 131 | /* Common routines */ | |
132 | 132 | |||
133 | int | 133 | int | |
134 | ixp12x0_bs_map(void *t, bus_addr_t bpa, bus_size_t size, | 134 | ixp12x0_bs_map(void *t, bus_addr_t bpa, bus_size_t size, | |
135 | int flags, bus_space_handle_t *bshp) | 135 | int flags, bus_space_handle_t *bshp) | |
136 | { | 136 | { | |
137 | const struct pmap_devmap *pd; | 137 | const struct pmap_devmap *pd; | |
138 | 138 | |||
139 | paddr_t startpa; | 139 | paddr_t startpa; | |
140 | paddr_t endpa; | 140 | paddr_t endpa; | |
141 | paddr_t pa; | 141 | paddr_t pa; | |
142 | paddr_t offset; | 142 | paddr_t offset; | |
143 | vaddr_t va; | 143 | vaddr_t va; | |
144 | pt_entry_t *pte; | |||
145 | 144 | |||
146 | if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) { | 145 | if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) { | |
147 | /* Device was statically mapped. */ | 146 | /* Device was statically mapped. */ | |
148 | *bshp = pd->pd_va + (bpa - pd->pd_pa); | 147 | *bshp = pd->pd_va + (bpa - pd->pd_pa); | |
149 | return 0; | 148 | return 0; | |
150 | } | 149 | } | |
151 | 150 | |||
152 | endpa = round_page(bpa + size); | 151 | endpa = round_page(bpa + size); | |
153 | offset = bpa & PAGE_MASK; | 152 | offset = bpa & PAGE_MASK; | |
154 | startpa = trunc_page(bpa); | 153 | startpa = trunc_page(bpa); | |
155 | 154 | |||
156 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | 155 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | |
157 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | 156 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | |
158 | if (va == 0) | 157 | if (va == 0) | |
159 | return ENOMEM; | 158 | return ENOMEM; | |
160 | 159 | |||
161 | *bshp = va + offset; | 160 | *bshp = va + offset; | |
162 | 161 | |||
162 | const int pmapflags = | |||
163 | (flag & (BUS_SPACE_MAP_CACHEABLE|BUS_SPACE_MAP_PREFETCHABLE)) | |||
164 | ? 0 | |||
165 | : PMAP_NOCACHE; | |||
163 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | 166 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | |
164 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, 0); | 167 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, pmapflags); | |
165 | pte = vtopte(va); | |||
166 | *pte &= ~L2_S_CACHE_MASK; | |||
167 | PTE_SYNC(pte); | |||
168 | } | 168 | } | |
169 | pmap_update(pmap_kernel()); | 169 | pmap_update(pmap_kernel()); | |
170 | 170 | |||
171 | return 0; | 171 | return 0; | |
172 | } | 172 | } | |
173 | 173 | |||
174 | void | 174 | void | |
175 | ixp12x0_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size) | 175 | ixp12x0_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size) | |
176 | { | 176 | { | |
177 | vaddr_t va; | 177 | vaddr_t va; | |
178 | vaddr_t endva; | 178 | vaddr_t endva; | |
179 | 179 | |||
180 | if (pmap_devmap_find_va(bsh, size) != NULL) { | 180 | if (pmap_devmap_find_va(bsh, size) != NULL) { |
--- src/sys/arch/arm/mainbus/mainbus_io.c 2012/07/15 20:53:23 1.22
+++ src/sys/arch/arm/mainbus/mainbus_io.c 2014/02/22 20:33:00 1.23
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: mainbus_io.c,v 1.22 2012/07/15 20:53:23 matt Exp $ */ | 1 | /* $NetBSD: mainbus_io.c,v 1.23 2014/02/22 20:33:00 matt Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1997 Mark Brinicombe. | 4 | * Copyright (c) 1997 Mark Brinicombe. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Redistribution and use in source and binary forms, with or without | 7 | * Redistribution and use in source and binary forms, with or without | |
8 | * modification, are permitted provided that the following conditions | 8 | * modification, are permitted provided that the following conditions | |
9 | * are met: | 9 | * are met: | |
10 | * 1. Redistributions of source code must retain the above copyright | 10 | * 1. Redistributions of source code must retain the above copyright | |
11 | * notice, this list of conditions and the following disclaimer. | 11 | * notice, this list of conditions and the following disclaimer. | |
12 | * 2. Redistributions in binary form must reproduce the above copyright | 12 | * 2. Redistributions in binary form must reproduce the above copyright | |
13 | * notice, this list of conditions and the following disclaimer in the | 13 | * notice, this list of conditions and the following disclaimer in the | |
14 | * documentation and/or other materials provided with the distribution. | 14 | * documentation and/or other materials provided with the distribution. | |
@@ -27,27 +27,27 @@ | @@ -27,27 +27,27 @@ | |||
27 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 27 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 28 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 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 | 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 | 31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
32 | * SUCH DAMAGE. | 32 | * SUCH DAMAGE. | |
33 | */ | 33 | */ | |
34 | 34 | |||
35 | /* | 35 | /* | |
36 | * bus_space I/O functions for mainbus | 36 | * bus_space I/O functions for mainbus | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | #include <sys/cdefs.h> | 39 | #include <sys/cdefs.h> | |
40 | __KERNEL_RCSID(0, "$NetBSD: mainbus_io.c,v 1.22 2012/07/15 20:53:23 matt Exp $"); | 40 | __KERNEL_RCSID(0, "$NetBSD: mainbus_io.c,v 1.23 2014/02/22 20:33:00 matt Exp $"); | |
41 | 41 | |||
42 | #include <sys/param.h> | 42 | #include <sys/param.h> | |
43 | #include <sys/systm.h> | 43 | #include <sys/systm.h> | |
44 | #include <sys/queue.h> | 44 | #include <sys/queue.h> | |
45 | 45 | |||
46 | #include <uvm/uvm.h> | 46 | #include <uvm/uvm.h> | |
47 | 47 | |||
48 | #include <sys/bus.h> | 48 | #include <sys/bus.h> | |
49 | #include <machine/pmap.h> | 49 | #include <machine/pmap.h> | |
50 | 50 | |||
51 | /* Proto types for all the bus_space structure functions */ | 51 | /* Proto types for all the bus_space structure functions */ | |
52 | 52 | |||
53 | bs_protos(mainbus); | 53 | bs_protos(mainbus); | |
@@ -167,53 +167,51 @@ struct bus_space mainbus_bs_tag = { | @@ -167,53 +167,51 @@ struct bus_space mainbus_bs_tag = { | |||
167 | bs_notimpl_bs_wr_2, | 167 | bs_notimpl_bs_wr_2, | |
168 | bs_notimpl_bs_wr_4, | 168 | bs_notimpl_bs_wr_4, | |
169 | bs_notimpl_bs_wr_8, | 169 | bs_notimpl_bs_wr_8, | |
170 | #endif | 170 | #endif | |
171 | }; | 171 | }; | |
172 | 172 | |||
173 | /* bus space functions */ | 173 | /* bus space functions */ | |
174 | 174 | |||
175 | int | 175 | int | |
176 | mainbus_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flags, bus_space_handle_t *bshp) | 176 | mainbus_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flags, bus_space_handle_t *bshp) | |
177 | { | 177 | { | |
178 | u_long startpa, endpa, pa; | 178 | u_long startpa, endpa, pa; | |
179 | vaddr_t va; | 179 | vaddr_t va; | |
180 | pt_entry_t *pte; | |||
181 | 180 | |||
182 | if ((u_long)bpa > (u_long)KERNEL_BASE) { | 181 | if ((u_long)bpa > (u_long)KERNEL_BASE) { | |
183 | /* XXX This is a temporary hack to aid transition. */ | 182 | /* XXX This is a temporary hack to aid transition. */ | |
184 | *bshp = bpa; | 183 | *bshp = bpa; | |
185 | return(0); | 184 | return(0); | |
186 | } | 185 | } | |
187 | 186 | |||
188 | startpa = trunc_page(bpa); | 187 | startpa = trunc_page(bpa); | |
189 | endpa = round_page(bpa + size); | 188 | endpa = round_page(bpa + size); | |
190 | 189 | |||
191 | /* XXX use extent manager to check duplicate mapping */ | 190 | /* XXX use extent manager to check duplicate mapping */ | |
192 | 191 | |||
193 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | 192 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | |
194 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | 193 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | |
195 | if (! va) | 194 | if (! va) | |
196 | return(ENOMEM); | 195 | return(ENOMEM); | |
197 | 196 | |||
198 | *bshp = (bus_space_handle_t)(va + (bpa - startpa)); | 197 | *bshp = (bus_space_handle_t)(va + (bpa - startpa)); | |
199 | 198 | |||
200 | for(pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | 199 | const int pmapflags = | |
201 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, 0); | 200 | (flags & (BUS_SPACE_MAP_CACHEABLE|BUS_SPACE_MAP_PREFETCHABLE)) | |
202 | if ((flags & BUS_SPACE_MAP_CACHEABLE) == 0) { | 201 | ? 0 | |
203 | pte = vtopte(va); | 202 | : PMAP_NOCACHE; | |
204 | *pte &= ~L2_S_CACHE_MASK; | 203 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | |
205 | PTE_SYNC(pte); | 204 | pmap_kenter_pa(va, pa, VM_PROT_READ|VM_PROT_WRITE, pmapflags); | |
206 | } | |||
207 | } | 205 | } | |
208 | pmap_update(pmap_kernel()); | 206 | pmap_update(pmap_kernel()); | |
209 | 207 | |||
210 | return(0); | 208 | return(0); | |
211 | } | 209 | } | |
212 | 210 | |||
213 | int | 211 | int | |
214 | mainbus_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, | 212 | mainbus_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, | |
215 | bus_size_t size, bus_size_t alignment, bus_size_t boundary, | 213 | bus_size_t size, bus_size_t alignment, bus_size_t boundary, | |
216 | int cacheable, | 214 | int cacheable, | |
217 | bus_addr_t *bpap, bus_space_handle_t *bshp) | 215 | bus_addr_t *bpap, bus_space_handle_t *bshp) | |
218 | { | 216 | { | |
219 | panic("mainbus_bs_alloc(): Help!"); | 217 | panic("mainbus_bs_alloc(): Help!"); |
--- src/sys/arch/arm/marvell/mvsoc_space.c 2013/05/29 20:47:14 1.6
+++ src/sys/arch/arm/marvell/mvsoc_space.c 2014/02/22 20:33:00 1.7
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: mvsoc_space.c,v 1.6 2013/05/29 20:47:14 rkujawa Exp $ */ | 1 | /* $NetBSD: mvsoc_space.c,v 1.7 2014/02/22 20:33:00 matt Exp $ */ | |
2 | /* | 2 | /* | |
3 | * Copyright (c) 2007 KIYOHARA Takashi | 3 | * Copyright (c) 2007 KIYOHARA Takashi | |
4 | * All rights reserved. | 4 | * All rights reserved. | |
5 | * | 5 | * | |
6 | * Redistribution and use in source and binary forms, with or without | 6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | 7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | 8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | 9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | 10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | 11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | 12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | 13 | * documentation and/or other materials provided with the distribution. | |
14 | * | 14 | * | |
@@ -16,27 +16,27 @@ | @@ -16,27 +16,27 @@ | |||
16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 16 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 17 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
18 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | 18 | * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, | |
19 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 19 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 20 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
21 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 21 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 22 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
23 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | 23 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | |
24 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 24 | * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
25 | * POSSIBILITY OF SUCH DAMAGE. | 25 | * POSSIBILITY OF SUCH DAMAGE. | |
26 | */ | 26 | */ | |
27 | 27 | |||
28 | #include <sys/cdefs.h> | 28 | #include <sys/cdefs.h> | |
29 | __KERNEL_RCSID(0, "$NetBSD: mvsoc_space.c,v 1.6 2013/05/29 20:47:14 rkujawa Exp $"); | 29 | __KERNEL_RCSID(0, "$NetBSD: mvsoc_space.c,v 1.7 2014/02/22 20:33:00 matt Exp $"); | |
30 | 30 | |||
31 | #include "opt_mvsoc.h" | 31 | #include "opt_mvsoc.h" | |
32 | #include "mvpex.h" | 32 | #include "mvpex.h" | |
33 | #include "gtpci.h" | 33 | #include "gtpci.h" | |
34 | 34 | |||
35 | #include <sys/param.h> | 35 | #include <sys/param.h> | |
36 | #include <sys/systm.h> | 36 | #include <sys/systm.h> | |
37 | 37 | |||
38 | #include <uvm/uvm_extern.h> | 38 | #include <uvm/uvm_extern.h> | |
39 | 39 | |||
40 | #include <sys/bus.h> | 40 | #include <sys/bus.h> | |
41 | 41 | |||
42 | #include <arm/marvell/mvsocreg.h> | 42 | #include <arm/marvell/mvsocreg.h> | |
@@ -311,27 +311,26 @@ struct bus_space orion_pci_io_bs_tag = { | @@ -311,27 +311,26 @@ struct bus_space orion_pci_io_bs_tag = { | |||
311 | MVSOC_BUS_SPACE_NORMAL_FUNCS, | 311 | MVSOC_BUS_SPACE_NORMAL_FUNCS, | |
312 | #endif | 312 | #endif | |
313 | }; | 313 | }; | |
314 | #endif | 314 | #endif | |
315 | #endif | 315 | #endif | |
316 | 316 | |||
317 | 317 | |||
318 | int | 318 | int | |
319 | mvsoc_bs_map(void *space, bus_addr_t address, bus_size_t size, int flags, | 319 | mvsoc_bs_map(void *space, bus_addr_t address, bus_size_t size, int flags, | |
320 | bus_space_handle_t *handlep) | 320 | bus_space_handle_t *handlep) | |
321 | { | 321 | { | |
322 | const struct pmap_devmap *pd; | 322 | const struct pmap_devmap *pd; | |
323 | paddr_t startpa, endpa, offset, pa; | 323 | paddr_t startpa, endpa, offset, pa; | |
324 | pt_entry_t *pte; | |||
325 | vaddr_t va; | 324 | vaddr_t va; | |
326 | 325 | |||
327 | /* | 326 | /* | |
328 | * XXX: We are not configuring any decode windows for Armada XP | 327 | * XXX: We are not configuring any decode windows for Armada XP | |
329 | * at the moment. We rely on those that have been set by u-boot. | 328 | * at the moment. We rely on those that have been set by u-boot. | |
330 | * Hence we don't want to mess around with decode windows, | 329 | * Hence we don't want to mess around with decode windows, | |
331 | * till we get full controll over them. | 330 | * till we get full controll over them. | |
332 | */ | 331 | */ | |
333 | 332 | |||
334 | int tag = (int)space; | 333 | int tag = (int)space; | |
335 | 334 | |||
336 | if (tag != 0) { | 335 | if (tag != 0) { | |
337 | bus_addr_t remap; | 336 | bus_addr_t remap; | |
@@ -359,38 +358,34 @@ mvsoc_bs_map(void *space, bus_addr_t add | @@ -359,38 +358,34 @@ mvsoc_bs_map(void *space, bus_addr_t add | |||
359 | startpa = trunc_page(address); | 358 | startpa = trunc_page(address); | |
360 | endpa = round_page(address + size); | 359 | endpa = round_page(address + size); | |
361 | offset = address & PAGE_MASK; | 360 | offset = address & PAGE_MASK; | |
362 | 361 | |||
363 | /* XXX use extent manager to check duplicate mapping */ | 362 | /* XXX use extent manager to check duplicate mapping */ | |
364 | 363 | |||
365 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | 364 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | |
366 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | 365 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | |
367 | if (va == 0x00000000) | 366 | if (va == 0x00000000) | |
368 | return ENOMEM; | 367 | return ENOMEM; | |
369 | 368 | |||
370 | *handlep = va + offset; | 369 | *handlep = va + offset; | |
371 | 370 | |||
371 | const int pmapflags = | |||
372 | (flags & (BUS_SPACE_MAP_CACHEABLE|BUS_SPACE_MAP_PREFETCHABLE)) | |||
373 | ? 0 | |||
374 | : PMAP_NOCACHE; | |||
375 | ||||
372 | /* Now map the pages */ | 376 | /* Now map the pages */ | |
373 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | 377 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | |
374 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, 0); | 378 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, pmapflags); | |
375 | if ((flags & BUS_SPACE_MAP_CACHEABLE) == 0) { | |||
376 | pte = vtopte(va); | |||
377 | *pte &= ~L2_S_CACHE_MASK; | |||
378 | PTE_SYNC(pte); | |||
379 | /* | |||
380 | * XXX: pmap_kenter_pa() also does PTE_SYNC(). a bit of | |||
381 | * waste. | |||
382 | */ | |||
383 | } | |||
384 | } | 379 | } | |
385 | pmap_update(pmap_kernel()); | 380 | pmap_update(pmap_kernel()); | |
386 | 381 | |||
387 | return 0; | 382 | return 0; | |
388 | } | 383 | } | |
389 | 384 | |||
390 | void | 385 | void | |
391 | mvsoc_bs_unmap(void *space, bus_space_handle_t handle, bus_size_t size) | 386 | mvsoc_bs_unmap(void *space, bus_space_handle_t handle, bus_size_t size) | |
392 | { | 387 | { | |
393 | vaddr_t va, sz; | 388 | vaddr_t va, sz; | |
394 | 389 | |||
395 | if (pmap_devmap_find_va(handle, size) != NULL) | 390 | if (pmap_devmap_find_va(handle, size) != NULL) | |
396 | /* Device was statically mapped; nothing to do. */ | 391 | /* Device was statically mapped; nothing to do. */ |
--- src/sys/arch/arm/mpcore/Attic/mpcore_space.c 2011/07/01 20:30:21 1.2
+++ src/sys/arch/arm/mpcore/Attic/mpcore_space.c 2014/02/22 20:33:00 1.3
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: mpcore_space.c,v 1.2 2011/07/01 20:30:21 dyoung Exp $ */ | 1 | /* $NetBSD: mpcore_space.c,v 1.3 2014/02/22 20:33:00 matt Exp $ */ | |
2 | 2 | |||
3 | /* derived from: */ | 3 | /* derived from: */ | |
4 | /* NetBSD: imx_space.c,v 1.2 2010/11/13 05:00:31 bsh Exp */ | 4 | /* NetBSD: imx_space.c,v 1.2 2010/11/13 05:00:31 bsh Exp */ | |
5 | 5 | |||
6 | /* | 6 | /* | |
7 | * Copyright (c) 2001, 2002 Wasabi Systems, Inc. | 7 | * Copyright (c) 2001, 2002 Wasabi Systems, Inc. | |
8 | * All rights reserved. | 8 | * All rights reserved. | |
9 | * | 9 | * | |
10 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | 10 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | |
11 | * | 11 | * | |
12 | * Redistribution and use in source and binary forms, with or without | 12 | * Redistribution and use in source and binary forms, with or without | |
13 | * modification, are permitted provided that the following conditions | 13 | * modification, are permitted provided that the following conditions | |
14 | * are met: | 14 | * are met: | |
@@ -160,57 +160,52 @@ struct bus_space mpcore_bs_tag = { | @@ -160,57 +160,52 @@ struct bus_space mpcore_bs_tag = { | |||
160 | /* copy */ | 160 | /* copy */ | |
161 | bs_notimpl_bs_c_1, | 161 | bs_notimpl_bs_c_1, | |
162 | generic_armv4_bs_c_2, | 162 | generic_armv4_bs_c_2, | |
163 | bs_notimpl_bs_c_4, | 163 | bs_notimpl_bs_c_4, | |
164 | bs_notimpl_bs_c_8, | 164 | bs_notimpl_bs_c_8, | |
165 | }; | 165 | }; | |
166 | 166 | |||
167 | int | 167 | int | |
168 | mpcore_bs_map(void *t, bus_addr_t bpa, bus_size_t size, | 168 | mpcore_bs_map(void *t, bus_addr_t bpa, bus_size_t size, | |
169 | int flag, bus_space_handle_t *bshp) | 169 | int flag, bus_space_handle_t *bshp) | |
170 | { | 170 | { | |
171 | u_long startpa, endpa, pa; | 171 | u_long startpa, endpa, pa; | |
172 | vaddr_t va; | 172 | vaddr_t va; | |
173 | pt_entry_t *pte; | |||
174 | const struct pmap_devmap *pd; | 173 | const struct pmap_devmap *pd; | |
175 | 174 | |||
176 | if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) { | 175 | if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) { | |
177 | /* Device was statically mapped. */ | 176 | /* Device was statically mapped. */ | |
178 | *bshp = pd->pd_va + (bpa - pd->pd_pa); | 177 | *bshp = pd->pd_va + (bpa - pd->pd_pa); | |
179 | return 0; | 178 | return 0; | |
180 | } | 179 | } | |
181 | 180 | |||
182 | startpa = trunc_page(bpa); | 181 | startpa = trunc_page(bpa); | |
183 | endpa = round_page(bpa + size); | 182 | endpa = round_page(bpa + size); | |
184 | 183 | |||
185 | /* XXX use extent manager to check duplicate mapping */ | 184 | /* XXX use extent manager to check duplicate mapping */ | |
186 | 185 | |||
187 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | 186 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | |
188 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | 187 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | |
189 | if (! va) | 188 | if (! va) | |
190 | return(ENOMEM); | 189 | return(ENOMEM); | |
191 | 190 | |||
192 | *bshp = (bus_space_handle_t)(va + (bpa - startpa)); | 191 | *bshp = (bus_space_handle_t)(va + (bpa - startpa)); | |
193 | 192 | |||
193 | const int pmapflags = | |||
194 | (flag & (BUS_SPACE_MAP_CACHEABLE|BUS_SPACE_MAP_PREFETCHABLE)) | |||
195 | ? 0 | |||
196 | : PMAP_NOCACHE; | |||
194 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | 197 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | |
195 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, 0); | 198 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, pmapflags); | |
196 | if ((flag & BUS_SPACE_MAP_CACHEABLE) == 0) { | |||
197 | pte = vtopte(va); | |||
198 | *pte &= ~L2_S_CACHE_MASK; | |||
199 | PTE_SYNC(pte); | |||
200 | /* XXX: pmap_kenter_pa() also does PTE_SYNC(). a bit of | |||
201 | * waste. | |||
202 | */ | |||
203 | } | |||
204 | } | 199 | } | |
205 | pmap_update(pmap_kernel()); | 200 | pmap_update(pmap_kernel()); | |
206 | 201 | |||
207 | return(0); | 202 | return(0); | |
208 | } | 203 | } | |
209 | 204 | |||
210 | void | 205 | void | |
211 | mpcore_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size) | 206 | mpcore_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size) | |
212 | { | 207 | { | |
213 | vaddr_t va; | 208 | vaddr_t va; | |
214 | vsize_t sz; | 209 | vsize_t sz; | |
215 | 210 | |||
216 | if (pmap_devmap_find_va(bsh, size) != NULL) { | 211 | if (pmap_devmap_find_va(bsh, size) != NULL) { |
--- src/sys/arch/arm/sa11x0/sa11x0_io.c 2011/07/01 20:31:39 1.19
+++ src/sys/arch/arm/sa11x0/sa11x0_io.c 2014/02/22 20:33:00 1.20
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: sa11x0_io.c,v 1.19 2011/07/01 20:31:39 dyoung Exp $ */ | 1 | /* $NetBSD: sa11x0_io.c,v 1.20 2014/02/22 20:33:00 matt Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 1997 Mark Brinicombe. | 4 | * Copyright (c) 1997 Mark Brinicombe. | |
5 | * Copyright (c) 1997 Causality Limited. | 5 | * Copyright (c) 1997 Causality Limited. | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * This code is derived from software contributed to The NetBSD Foundation | 8 | * This code is derived from software contributed to The NetBSD Foundation | |
9 | * by Ichiro FUKUHARA. | 9 | * by Ichiro FUKUHARA. | |
10 | * | 10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | 11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | 12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | 13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | 14 | * 1. Redistributions of source code must retain the above copyright | |
@@ -31,27 +31,27 @@ | @@ -31,27 +31,27 @@ | |||
31 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 31 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 32 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 33 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
34 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 34 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
35 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 35 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
36 | * SUCH DAMAGE. | 36 | * SUCH DAMAGE. | |
37 | */ | 37 | */ | |
38 | 38 | |||
39 | /* | 39 | /* | |
40 | * bus_space I/O functions for sa11x0 | 40 | * bus_space I/O functions for sa11x0 | |
41 | */ | 41 | */ | |
42 | 42 | |||
43 | #include <sys/cdefs.h> | 43 | #include <sys/cdefs.h> | |
44 | __KERNEL_RCSID(0, "$NetBSD: sa11x0_io.c,v 1.19 2011/07/01 20:31:39 dyoung Exp $"); | 44 | __KERNEL_RCSID(0, "$NetBSD: sa11x0_io.c,v 1.20 2014/02/22 20:33:00 matt Exp $"); | |
45 | 45 | |||
46 | #include <sys/param.h> | 46 | #include <sys/param.h> | |
47 | #include <sys/systm.h> | 47 | #include <sys/systm.h> | |
48 | #include <sys/queue.h> | 48 | #include <sys/queue.h> | |
49 | 49 | |||
50 | #include <uvm/uvm.h> | 50 | #include <uvm/uvm.h> | |
51 | 51 | |||
52 | #include <sys/bus.h> | 52 | #include <sys/bus.h> | |
53 | #include <machine/pmap.h> | 53 | #include <machine/pmap.h> | |
54 | 54 | |||
55 | /* Prototypes for all the bus_space structure functions */ | 55 | /* Prototypes for all the bus_space structure functions */ | |
56 | 56 | |||
57 | bs_protos(sa11x0); | 57 | bs_protos(sa11x0); | |
@@ -129,59 +129,58 @@ struct bus_space sa11x0_bs_tag = { | @@ -129,59 +129,58 @@ struct bus_space sa11x0_bs_tag = { | |||
129 | bs_notimpl_bs_sr_4, | 129 | bs_notimpl_bs_sr_4, | |
130 | bs_notimpl_bs_sr_8, | 130 | bs_notimpl_bs_sr_8, | |
131 | 131 | |||
132 | /* copy */ | 132 | /* copy */ | |
133 | bs_notimpl_bs_c_1, | 133 | bs_notimpl_bs_c_1, | |
134 | sa11x0_bs_c_2, | 134 | sa11x0_bs_c_2, | |
135 | bs_notimpl_bs_c_4, | 135 | bs_notimpl_bs_c_4, | |
136 | bs_notimpl_bs_c_8, | 136 | bs_notimpl_bs_c_8, | |
137 | }; | 137 | }; | |
138 | 138 | |||
139 | /* bus space functions */ | 139 | /* bus space functions */ | |
140 | 140 | |||
141 | int | 141 | int | |
142 | sa11x0_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int cacheable, | 142 | sa11x0_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flags, | |
143 | bus_space_handle_t *bshp) | 143 | bus_space_handle_t *bshp) | |
144 | { | 144 | { | |
145 | u_long startpa, endpa, pa; | 145 | u_long startpa, endpa, pa; | |
146 | vaddr_t va; | 146 | vaddr_t va; | |
147 | pt_entry_t *pte; | |||
148 | const struct pmap_devmap *pd; | 147 | const struct pmap_devmap *pd; | |
149 | 148 | |||
150 | if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) { | 149 | if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) { | |
151 | /* Device was statically mapped. */ | 150 | /* Device was statically mapped. */ | |
152 | *bshp = pd->pd_va + (bpa - pd->pd_pa); | 151 | *bshp = pd->pd_va + (bpa - pd->pd_pa); | |
153 | return 0; | 152 | return 0; | |
154 | } | 153 | } | |
155 | 154 | |||
156 | startpa = trunc_page(bpa); | 155 | startpa = trunc_page(bpa); | |
157 | endpa = round_page(bpa + size); | 156 | endpa = round_page(bpa + size); | |
158 | 157 | |||
159 | /* XXX use extent manager to check duplicate mapping */ | 158 | /* XXX use extent manager to check duplicate mapping */ | |
160 | 159 | |||
161 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | 160 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | |
162 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | 161 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | |
163 | if (!va) | 162 | if (!va) | |
164 | return ENOMEM; | 163 | return ENOMEM; | |
165 | 164 | |||
166 | *bshp = (bus_space_handle_t)(va + (bpa - startpa)); | 165 | *bshp = (bus_space_handle_t)(va + (bpa - startpa)); | |
167 | 166 | |||
167 | const int pmapflags = | |||
168 | (flags & (BUS_SPACE_MAP_CACHEABLE|BUS_SPACE_MAP_PREFETCHABLE)) | |||
169 | ? 0 | |||
170 | : PMAP_NOCACHE; | |||
171 | ||||
168 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | 172 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | |
169 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, 0); | 173 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, pmapflags); | |
170 | pte = vtopte(va); | |||
171 | if (cacheable == 0) { | |||
172 | *pte &= ~L2_S_CACHE_MASK; | |||
173 | PTE_SYNC(pte); | |||
174 | } | |||
175 | } | 174 | } | |
176 | pmap_update(pmap_kernel()); | 175 | pmap_update(pmap_kernel()); | |
177 | 176 | |||
178 | return 0; | 177 | return 0; | |
179 | } | 178 | } | |
180 | 179 | |||
181 | int | 180 | int | |
182 | sa11x0_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, bus_size_t size, | 181 | sa11x0_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, bus_size_t size, | |
183 | bus_size_t alignment, bus_size_t boundary, int cacheable, | 182 | bus_size_t alignment, bus_size_t boundary, int cacheable, | |
184 | bus_addr_t *bpap, bus_space_handle_t *bshp) | 183 | bus_addr_t *bpap, bus_space_handle_t *bshp) | |
185 | { | 184 | { | |
186 | 185 | |||
187 | panic("sa11x0_bs_alloc(): Help!"); | 186 | panic("sa11x0_bs_alloc(): Help!"); |
--- src/sys/arch/arm/xscale/ixp425_pci_space.c 2012/11/12 18:00:38 1.11
+++ src/sys/arch/arm/xscale/ixp425_pci_space.c 2014/02/22 20:33:00 1.12
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: ixp425_pci_space.c,v 1.11 2012/11/12 18:00:38 skrll Exp $ */ | 1 | /* $NetBSD: ixp425_pci_space.c,v 1.12 2014/02/22 20:33:00 matt Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2003 | 4 | * Copyright (c) 2003 | |
5 | * Ichiro FUKUHARA <ichiro@ichiro.org>. | 5 | * Ichiro FUKUHARA <ichiro@ichiro.org>. | |
6 | * All rights reserved. | 6 | * All rights reserved. | |
7 | * | 7 | * | |
8 | * Redistribution and use in source and binary forms, with or without | 8 | * Redistribution and use in source and binary forms, with or without | |
9 | * modification, are permitted provided that the following conditions | 9 | * modification, are permitted provided that the following conditions | |
10 | * are met: | 10 | * are met: | |
11 | * 1. Redistributions of source code must retain the above copyright | 11 | * 1. Redistributions of source code must retain the above copyright | |
12 | * notice, this list of conditions and the following disclaimer. | 12 | * notice, this list of conditions and the following disclaimer. | |
13 | * 2. Redistributions in binary form must reproduce the above copyright | 13 | * 2. Redistributions in binary form must reproduce the above copyright | |
14 | * notice, this list of conditions and the following disclaimer in the | 14 | * notice, this list of conditions and the following disclaimer in the | |
@@ -18,27 +18,27 @@ | @@ -18,27 +18,27 @@ | |||
18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
20 | * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR | 20 | * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR | |
21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 21 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
27 | * SUCH DAMAGE. | 27 | * SUCH DAMAGE. | |
28 | */ | 28 | */ | |
29 | 29 | |||
30 | #include <sys/cdefs.h> | 30 | #include <sys/cdefs.h> | |
31 | __KERNEL_RCSID(0, "$NetBSD: ixp425_pci_space.c,v 1.11 2012/11/12 18:00:38 skrll Exp $"); | 31 | __KERNEL_RCSID(0, "$NetBSD: ixp425_pci_space.c,v 1.12 2014/02/22 20:33:00 matt Exp $"); | |
32 | 32 | |||
33 | /* | 33 | /* | |
34 | * bus_space PCI functions for ixp425 | 34 | * bus_space PCI functions for ixp425 | |
35 | */ | 35 | */ | |
36 | 36 | |||
37 | #include <sys/param.h> | 37 | #include <sys/param.h> | |
38 | #include <sys/systm.h> | 38 | #include <sys/systm.h> | |
39 | #include <sys/queue.h> | 39 | #include <sys/queue.h> | |
40 | 40 | |||
41 | #include <uvm/uvm.h> | 41 | #include <uvm/uvm.h> | |
42 | 42 | |||
43 | #include <sys/bus.h> | 43 | #include <sys/bus.h> | |
44 | 44 | |||
@@ -372,53 +372,54 @@ _pci_io_bs_w_4(void *v, bus_space_handle | @@ -372,53 +372,54 @@ _pci_io_bs_w_4(void *v, bus_space_handle | |||
372 | 372 | |||
373 | /* mem bs */ | 373 | /* mem bs */ | |
374 | int | 374 | int | |
375 | ixp425_pci_mem_bs_map(void *t, bus_addr_t bpa, bus_size_t size, | 375 | ixp425_pci_mem_bs_map(void *t, bus_addr_t bpa, bus_size_t size, | |
376 | int cacheable, bus_space_handle_t *bshp) | 376 | int cacheable, bus_space_handle_t *bshp) | |
377 | { | 377 | { | |
378 | const struct pmap_devmap *pd; | 378 | const struct pmap_devmap *pd; | |
379 | 379 | |||
380 | paddr_t startpa; | 380 | paddr_t startpa; | |
381 | paddr_t endpa; | 381 | paddr_t endpa; | |
382 | paddr_t pa; | 382 | paddr_t pa; | |
383 | paddr_t offset; | 383 | paddr_t offset; | |
384 | vaddr_t va; | 384 | vaddr_t va; | |
385 | pt_entry_t *pte; | |||
386 | 385 | |||
387 | if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) { | 386 | if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) { | |
388 | /* Device was statically mapped. */ | 387 | /* Device was statically mapped. */ | |
389 | *bshp = pd->pd_va + (bpa - pd->pd_pa); | 388 | *bshp = pd->pd_va + (bpa - pd->pd_pa); | |
390 | return 0; | 389 | return 0; | |
391 | } | 390 | } | |
392 | 391 | |||
393 | endpa = round_page(bpa + size); | 392 | endpa = round_page(bpa + size); | |
394 | offset = bpa & PAGE_MASK; | 393 | offset = bpa & PAGE_MASK; | |
395 | startpa = trunc_page(bpa); | 394 | startpa = trunc_page(bpa); | |
396 | 395 | |||
397 | /* Get some VM. */ | 396 | /* Get some VM. */ | |
398 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | 397 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | |
399 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | 398 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | |
400 | if (va == 0) | 399 | if (va == 0) | |
401 | return ENOMEM; | 400 | return ENOMEM; | |
402 | 401 | |||
403 | /* Store the bus space handle */ | 402 | /* Store the bus space handle */ | |
404 | *bshp = va + offset; | 403 | *bshp = va + offset; | |
405 | 404 | |||
405 | const int pmapflags = | |||
406 | (flag & (BUS_SPACE_MAP_CACHEABLE|BUS_SPACE_MAP_PREFETCHABLE)) | |||
407 | ? 0 | |||
408 | : PMAP_NOCACHE; | |||
409 | ||||
406 | /* Now map the pages */ | 410 | /* Now map the pages */ | |
407 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | 411 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | |
408 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, 0); | 412 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, pmapflags); | |
409 | pte = vtopte(va); | |||
410 | *pte &= ~L2_S_CACHE_MASK; | |||
411 | PTE_SYNC(pte); | |||
412 | } | 413 | } | |
413 | pmap_update(pmap_kernel()); | 414 | pmap_update(pmap_kernel()); | |
414 | 415 | |||
415 | return(0); | 416 | return(0); | |
416 | } | 417 | } | |
417 | 418 | |||
418 | void | 419 | void | |
419 | ixp425_pci_mem_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size) | 420 | ixp425_pci_mem_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size) | |
420 | { | 421 | { | |
421 | vaddr_t va; | 422 | vaddr_t va; | |
422 | vaddr_t endva; | 423 | vaddr_t endva; | |
423 | 424 | |||
424 | if (pmap_devmap_find_va(bsh, size) != NULL) { | 425 | if (pmap_devmap_find_va(bsh, size) != NULL) { |
--- src/sys/arch/arm/xscale/pxa2x0_space.c 2011/07/01 20:32:51 1.10
+++ src/sys/arch/arm/xscale/pxa2x0_space.c 2014/02/22 20:33:00 1.11
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: pxa2x0_space.c,v 1.10 2011/07/01 20:32:51 dyoung Exp $ */ | 1 | /* $NetBSD: pxa2x0_space.c,v 1.11 2014/02/22 20:33:00 matt Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2001, 2002 Wasabi Systems, Inc. | 4 | * Copyright (c) 2001, 2002 Wasabi Systems, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | 7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -66,27 +66,27 @@ | @@ -66,27 +66,27 @@ | |||
66 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 66 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
67 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | 67 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
68 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | 68 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
69 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | 69 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
70 | * SUCH DAMAGE. | 70 | * SUCH DAMAGE. | |
71 | */ | 71 | */ | |
72 | 72 | |||
73 | /* | 73 | /* | |
74 | * bus_space functions for Intel PXA2[51]0 application processor. | 74 | * bus_space functions for Intel PXA2[51]0 application processor. | |
75 | * Derived from i80321_space.c. | 75 | * Derived from i80321_space.c. | |
76 | */ | 76 | */ | |
77 | 77 | |||
78 | #include <sys/cdefs.h> | 78 | #include <sys/cdefs.h> | |
79 | __KERNEL_RCSID(0, "$NetBSD: pxa2x0_space.c,v 1.10 2011/07/01 20:32:51 dyoung Exp $"); | 79 | __KERNEL_RCSID(0, "$NetBSD: pxa2x0_space.c,v 1.11 2014/02/22 20:33:00 matt Exp $"); | |
80 | 80 | |||
81 | #include <sys/param.h> | 81 | #include <sys/param.h> | |
82 | #include <sys/systm.h> | 82 | #include <sys/systm.h> | |
83 | 83 | |||
84 | #include <uvm/uvm_extern.h> | 84 | #include <uvm/uvm_extern.h> | |
85 | 85 | |||
86 | #include <sys/bus.h> | 86 | #include <sys/bus.h> | |
87 | 87 | |||
88 | /* Prototypes for all the bus_space structure functions */ | 88 | /* Prototypes for all the bus_space structure functions */ | |
89 | bs_protos(pxa2x0); | 89 | bs_protos(pxa2x0); | |
90 | bs_protos(generic); | 90 | bs_protos(generic); | |
91 | bs_protos(generic_armv4); | 91 | bs_protos(generic_armv4); | |
92 | bs_protos(bs_notimpl); | 92 | bs_protos(bs_notimpl); | |
@@ -185,36 +185,33 @@ pxa2x0_bs_map(void *t, bus_addr_t bpa, b | @@ -185,36 +185,33 @@ pxa2x0_bs_map(void *t, bus_addr_t bpa, b | |||
185 | 185 | |||
186 | startpa = trunc_page(bpa); | 186 | startpa = trunc_page(bpa); | |
187 | endpa = round_page(bpa + size); | 187 | endpa = round_page(bpa + size); | |
188 | 188 | |||
189 | /* XXX use extent manager to check duplicate mapping */ | 189 | /* XXX use extent manager to check duplicate mapping */ | |
190 | 190 | |||
191 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | 191 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | |
192 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | 192 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | |
193 | if (! va) | 193 | if (! va) | |
194 | return(ENOMEM); | 194 | return(ENOMEM); | |
195 | 195 | |||
196 | *bshp = (bus_space_handle_t)(va + (bpa - startpa)); | 196 | *bshp = (bus_space_handle_t)(va + (bpa - startpa)); | |
197 | 197 | |||
198 | const int pmapflags = | |||
199 | (flag & (BUS_SPACE_MAP_CACHEABLE|BUS_SPACE_MAP_PREFETCHABLE)) | |||
200 | ? 0 | |||
201 | : PMAP_NOCACHE; | |||
202 | ||||
198 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | 203 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | |
199 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, 0); | 204 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, pmapflags); | |
200 | if ((flag & BUS_SPACE_MAP_CACHEABLE) == 0) { | |||
201 | pte = vtopte(va); | |||
202 | *pte &= ~L2_S_CACHE_MASK; | |||
203 | PTE_SYNC(pte); | |||
204 | /* XXX: pmap_kenter_pa() also does PTE_SYNC(). a bit of | |||
205 | * waste. | |||
206 | */ | |||
207 | } | |||
208 | } | 205 | } | |
209 | pmap_update(pmap_kernel()); | 206 | pmap_update(pmap_kernel()); | |
210 | 207 | |||
211 | return(0); | 208 | return(0); | |
212 | } | 209 | } | |
213 | 210 | |||
214 | void | 211 | void | |
215 | pxa2x0_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size) | 212 | pxa2x0_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size) | |
216 | { | 213 | { | |
217 | vaddr_t va; | 214 | vaddr_t va; | |
218 | vsize_t sz; | 215 | vsize_t sz; | |
219 | 216 | |||
220 | if (pmap_devmap_find_va(bsh, size) != NULL) { | 217 | if (pmap_devmap_find_va(bsh, size) != NULL) { |
--- src/sys/arch/evbarm/adi_brh/obio_space.c 2011/07/01 20:38:16 1.7
+++ src/sys/arch/evbarm/adi_brh/obio_space.c 2014/02/22 20:33:00 1.8
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: obio_space.c,v 1.7 2011/07/01 20:38:16 dyoung Exp $ */ | 1 | /* $NetBSD: obio_space.c,v 1.8 2014/02/22 20:33:00 matt Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc. | 4 | * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | 7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -30,27 +30,27 @@ | @@ -30,27 +30,27 @@ | |||
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
35 | * POSSIBILITY OF SUCH DAMAGE. | 35 | * POSSIBILITY OF SUCH DAMAGE. | |
36 | */ | 36 | */ | |
37 | 37 | |||
38 | /* | 38 | /* | |
39 | * bus_space functions for ADI BRH on-board devices | 39 | * bus_space functions for ADI BRH on-board devices | |
40 | */ | 40 | */ | |
41 | 41 | |||
42 | #include <sys/cdefs.h> | 42 | #include <sys/cdefs.h> | |
43 | __KERNEL_RCSID(0, "$NetBSD: obio_space.c,v 1.7 2011/07/01 20:38:16 dyoung Exp $"); | 43 | __KERNEL_RCSID(0, "$NetBSD: obio_space.c,v 1.8 2014/02/22 20:33:00 matt Exp $"); | |
44 | 44 | |||
45 | #include <sys/param.h> | 45 | #include <sys/param.h> | |
46 | #include <sys/systm.h> | 46 | #include <sys/systm.h> | |
47 | 47 | |||
48 | #include <uvm/uvm_extern.h> | 48 | #include <uvm/uvm_extern.h> | |
49 | 49 | |||
50 | #include <sys/bus.h> | 50 | #include <sys/bus.h> | |
51 | 51 | |||
52 | /* Prototypes for all the bus_space structure functions */ | 52 | /* Prototypes for all the bus_space structure functions */ | |
53 | bs_protos(obio); | 53 | bs_protos(obio); | |
54 | bs_protos(generic); | 54 | bs_protos(generic); | |
55 | bs_protos(generic_armv4); | 55 | bs_protos(generic_armv4); | |
56 | bs_protos(bs_notimpl); | 56 | bs_protos(bs_notimpl); | |
@@ -127,56 +127,57 @@ struct bus_space obio_bs_tag = { | @@ -127,56 +127,57 @@ struct bus_space obio_bs_tag = { | |||
127 | bs_notimpl_bs_sr_1, | 127 | bs_notimpl_bs_sr_1, | |
128 | bs_notimpl_bs_sr_2, | 128 | bs_notimpl_bs_sr_2, | |
129 | bs_notimpl_bs_sr_4, | 129 | bs_notimpl_bs_sr_4, | |
130 | bs_notimpl_bs_sr_8, | 130 | bs_notimpl_bs_sr_8, | |
131 | 131 | |||
132 | /* copy */ | 132 | /* copy */ | |
133 | bs_notimpl_bs_c_1, | 133 | bs_notimpl_bs_c_1, | |
134 | bs_notimpl_bs_c_2, | 134 | bs_notimpl_bs_c_2, | |
135 | bs_notimpl_bs_c_4, | 135 | bs_notimpl_bs_c_4, | |
136 | bs_notimpl_bs_c_8, | 136 | bs_notimpl_bs_c_8, | |
137 | }; | 137 | }; | |
138 | 138 | |||
139 | int | 139 | int | |
140 | obio_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flags, | 140 | obio_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flag, | |
141 | bus_space_handle_t *bshp) | 141 | bus_space_handle_t *bshp) | |
142 | { | 142 | { | |
143 | const struct pmap_devmap *pd; | 143 | const struct pmap_devmap *pd; | |
144 | paddr_t startpa, endpa, pa, offset; | 144 | paddr_t startpa, endpa, pa, offset; | |
145 | vaddr_t va; | 145 | vaddr_t va; | |
146 | pt_entry_t *pte; | |||
147 | 146 | |||
148 | if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) { | 147 | if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) { | |
149 | /* Device was statically mapped. */ | 148 | /* Device was statically mapped. */ | |
150 | *bshp = pd->pd_va + (bpa - pd->pd_pa); | 149 | *bshp = pd->pd_va + (bpa - pd->pd_pa); | |
151 | return (0); | 150 | return (0); | |
152 | } | 151 | } | |
153 | 152 | |||
154 | endpa = round_page(bpa + size); | 153 | endpa = round_page(bpa + size); | |
155 | offset = bpa & PAGE_MASK; | 154 | offset = bpa & PAGE_MASK; | |
156 | startpa = trunc_page(bpa); | 155 | startpa = trunc_page(bpa); | |
157 | 156 | |||
158 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | 157 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | |
159 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | 158 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | |
160 | if (va == 0) | 159 | if (va == 0) | |
161 | return ENOMEM; | 160 | return ENOMEM; | |
162 | 161 | |||
163 | *bshp = va + offset; | 162 | *bshp = va + offset; | |
164 | 163 | |||
164 | const int pmapflags = | |||
165 | (flag & (BUS_SPACE_MAP_CACHEABLE|BUS_SPACE_MAP_PREFETCHABLE)) | |||
166 | ? 0 | |||
167 | : PMAP_NOCACHE; | |||
168 | ||||
165 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | 169 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | |
166 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, 0); | 170 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, pmapflags); | |
167 | pte = vtopte(va); | |||
168 | *pte &= ~L2_S_CACHE_MASK; | |||
169 | PTE_SYNC(pte); | |||
170 | } | 171 | } | |
171 | pmap_update(pmap_kernel()); | 172 | pmap_update(pmap_kernel()); | |
172 | 173 | |||
173 | return (0); | 174 | return (0); | |
174 | } | 175 | } | |
175 | 176 | |||
176 | int | 177 | int | |
177 | obio_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, bus_size_t size, | 178 | obio_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, bus_size_t size, | |
178 | bus_size_t alignment, bus_size_t boundary, int flags, bus_addr_t *bpap, | 179 | bus_size_t alignment, bus_size_t boundary, int flags, bus_addr_t *bpap, | |
179 | bus_space_handle_t *bshp) | 180 | bus_space_handle_t *bshp) | |
180 | { | 181 | { | |
181 | 182 | |||
182 | panic("obio_bs_alloc(): not implemented\n"); | 183 | panic("obio_bs_alloc(): not implemented\n"); |
--- src/sys/arch/evbarm/hdl_g/obio_space.c 2011/07/01 20:39:34 1.3
+++ src/sys/arch/evbarm/hdl_g/obio_space.c 2014/02/22 20:33:00 1.4
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: obio_space.c,v 1.3 2011/07/01 20:39:34 dyoung Exp $ */ | 1 | /* $NetBSD: obio_space.c,v 1.4 2014/02/22 20:33:00 matt Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc. | 4 | * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | 7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -30,27 +30,27 @@ | @@ -30,27 +30,27 @@ | |||
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
35 | * POSSIBILITY OF SUCH DAMAGE. | 35 | * POSSIBILITY OF SUCH DAMAGE. | |
36 | */ | 36 | */ | |
37 | 37 | |||
38 | /* | 38 | /* | |
39 | * bus_space functions for IQ80321 on-board devices | 39 | * bus_space functions for IQ80321 on-board devices | |
40 | */ | 40 | */ | |
41 | 41 | |||
42 | #include <sys/cdefs.h> | 42 | #include <sys/cdefs.h> | |
43 | __KERNEL_RCSID(0, "$NetBSD: obio_space.c,v 1.3 2011/07/01 20:39:34 dyoung Exp $"); | 43 | __KERNEL_RCSID(0, "$NetBSD: obio_space.c,v 1.4 2014/02/22 20:33:00 matt Exp $"); | |
44 | 44 | |||
45 | #include <sys/param.h> | 45 | #include <sys/param.h> | |
46 | #include <sys/systm.h> | 46 | #include <sys/systm.h> | |
47 | 47 | |||
48 | #include <uvm/uvm_extern.h> | 48 | #include <uvm/uvm_extern.h> | |
49 | 49 | |||
50 | #include <sys/bus.h> | 50 | #include <sys/bus.h> | |
51 | 51 | |||
52 | /* Prototypes for all the bus_space structure functions */ | 52 | /* Prototypes for all the bus_space structure functions */ | |
53 | bs_protos(obio); | 53 | bs_protos(obio); | |
54 | bs_protos(generic); | 54 | bs_protos(generic); | |
55 | bs_protos(generic_armv4); | 55 | bs_protos(generic_armv4); | |
56 | bs_protos(bs_notimpl); | 56 | bs_protos(bs_notimpl); | |
@@ -127,56 +127,57 @@ struct bus_space obio_bs_tag = { | @@ -127,56 +127,57 @@ struct bus_space obio_bs_tag = { | |||
127 | bs_notimpl_bs_sr_1, | 127 | bs_notimpl_bs_sr_1, | |
128 | bs_notimpl_bs_sr_2, | 128 | bs_notimpl_bs_sr_2, | |
129 | bs_notimpl_bs_sr_4, | 129 | bs_notimpl_bs_sr_4, | |
130 | bs_notimpl_bs_sr_8, | 130 | bs_notimpl_bs_sr_8, | |
131 | 131 | |||
132 | /* copy */ | 132 | /* copy */ | |
133 | bs_notimpl_bs_c_1, | 133 | bs_notimpl_bs_c_1, | |
134 | bs_notimpl_bs_c_2, | 134 | bs_notimpl_bs_c_2, | |
135 | bs_notimpl_bs_c_4, | 135 | bs_notimpl_bs_c_4, | |
136 | bs_notimpl_bs_c_8, | 136 | bs_notimpl_bs_c_8, | |
137 | }; | 137 | }; | |
138 | 138 | |||
139 | int | 139 | int | |
140 | obio_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flags, | 140 | obio_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flag, | |
141 | bus_space_handle_t *bshp) | 141 | bus_space_handle_t *bshp) | |
142 | { | 142 | { | |
143 | const struct pmap_devmap *pd; | 143 | const struct pmap_devmap *pd; | |
144 | paddr_t startpa, endpa, pa, offset; | 144 | paddr_t startpa, endpa, pa, offset; | |
145 | vaddr_t va; | 145 | vaddr_t va; | |
146 | pt_entry_t *pte; | |||
147 | 146 | |||
148 | if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) { | 147 | if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) { | |
149 | /* Device was statically mapped. */ | 148 | /* Device was statically mapped. */ | |
150 | *bshp = pd->pd_va + (bpa - pd->pd_pa); | 149 | *bshp = pd->pd_va + (bpa - pd->pd_pa); | |
151 | return 0; | 150 | return 0; | |
152 | } | 151 | } | |
153 | 152 | |||
154 | endpa = round_page(bpa + size); | 153 | endpa = round_page(bpa + size); | |
155 | offset = bpa & PAGE_MASK; | 154 | offset = bpa & PAGE_MASK; | |
156 | startpa = trunc_page(bpa); | 155 | startpa = trunc_page(bpa); | |
157 | 156 | |||
158 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | 157 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | |
159 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | 158 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | |
160 | if (va == 0) | 159 | if (va == 0) | |
161 | return ENOMEM; | 160 | return ENOMEM; | |
162 | 161 | |||
163 | *bshp = va + offset; | 162 | *bshp = va + offset; | |
164 | 163 | |||
164 | const int pmapflags = | |||
165 | (flag & (BUS_SPACE_MAP_CACHEABLE|BUS_SPACE_MAP_PREFETCHABLE)) | |||
166 | ? 0 | |||
167 | : PMAP_NOCACHE; | |||
168 | ||||
165 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | 169 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | |
166 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, 0); | 170 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, pmapflags); | |
167 | pte = vtopte(va); | |||
168 | *pte &= ~L2_S_CACHE_MASK; | |||
169 | PTE_SYNC(pte); | |||
170 | } | 171 | } | |
171 | pmap_update(pmap_kernel()); | 172 | pmap_update(pmap_kernel()); | |
172 | 173 | |||
173 | return 0; | 174 | return 0; | |
174 | } | 175 | } | |
175 | 176 | |||
176 | int | 177 | int | |
177 | obio_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, bus_size_t size, | 178 | obio_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, bus_size_t size, | |
178 | bus_size_t alignment, bus_size_t boundary, int flags, bus_addr_t *bpap, | 179 | bus_size_t alignment, bus_size_t boundary, int flags, bus_addr_t *bpap, | |
179 | bus_space_handle_t *bshp) | 180 | bus_space_handle_t *bshp) | |
180 | { | 181 | { | |
181 | 182 | |||
182 | panic("obio_bs_alloc(): not implemented"); | 183 | panic("obio_bs_alloc(): not implemented"); |
--- src/sys/arch/evbarm/iq80310/obio_space.c 2011/07/01 20:41:16 1.14
+++ src/sys/arch/evbarm/iq80310/obio_space.c 2014/02/22 20:33:00 1.15
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: obio_space.c,v 1.14 2011/07/01 20:41:16 dyoung Exp $ */ | 1 | /* $NetBSD: obio_space.c,v 1.15 2014/02/22 20:33:00 matt Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc. | 4 | * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | 7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -30,27 +30,27 @@ | @@ -30,27 +30,27 @@ | |||
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
35 | * POSSIBILITY OF SUCH DAMAGE. | 35 | * POSSIBILITY OF SUCH DAMAGE. | |
36 | */ | 36 | */ | |
37 | 37 | |||
38 | /* | 38 | /* | |
39 | * bus_space functions for IQ80310 on-board devices | 39 | * bus_space functions for IQ80310 on-board devices | |
40 | */ | 40 | */ | |
41 | 41 | |||
42 | #include <sys/cdefs.h> | 42 | #include <sys/cdefs.h> | |
43 | __KERNEL_RCSID(0, "$NetBSD: obio_space.c,v 1.14 2011/07/01 20:41:16 dyoung Exp $"); | 43 | __KERNEL_RCSID(0, "$NetBSD: obio_space.c,v 1.15 2014/02/22 20:33:00 matt Exp $"); | |
44 | 44 | |||
45 | #include <sys/param.h> | 45 | #include <sys/param.h> | |
46 | #include <sys/systm.h> | 46 | #include <sys/systm.h> | |
47 | 47 | |||
48 | #include <uvm/uvm_extern.h> | 48 | #include <uvm/uvm_extern.h> | |
49 | 49 | |||
50 | #include <sys/bus.h> | 50 | #include <sys/bus.h> | |
51 | 51 | |||
52 | /* Prototypes for all the bus_space structure functions */ | 52 | /* Prototypes for all the bus_space structure functions */ | |
53 | bs_protos(obio); | 53 | bs_protos(obio); | |
54 | bs_protos(generic); | 54 | bs_protos(generic); | |
55 | bs_protos(bs_notimpl); | 55 | bs_protos(bs_notimpl); | |
56 | 56 | |||
@@ -126,56 +126,56 @@ struct bus_space obio_bs_tag = { | @@ -126,56 +126,56 @@ struct bus_space obio_bs_tag = { | |||
126 | bs_notimpl_bs_sr_1, | 126 | bs_notimpl_bs_sr_1, | |
127 | bs_notimpl_bs_sr_2, | 127 | bs_notimpl_bs_sr_2, | |
128 | bs_notimpl_bs_sr_4, | 128 | bs_notimpl_bs_sr_4, | |
129 | bs_notimpl_bs_sr_8, | 129 | bs_notimpl_bs_sr_8, | |
130 | 130 | |||
131 | /* copy */ | 131 | /* copy */ | |
132 | bs_notimpl_bs_c_1, | 132 | bs_notimpl_bs_c_1, | |
133 | bs_notimpl_bs_c_2, | 133 | bs_notimpl_bs_c_2, | |
134 | bs_notimpl_bs_c_4, | 134 | bs_notimpl_bs_c_4, | |
135 | bs_notimpl_bs_c_8, | 135 | bs_notimpl_bs_c_8, | |
136 | }; | 136 | }; | |
137 | 137 | |||
138 | int | 138 | int | |
139 | obio_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flags, | 139 | obio_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flag, | |
140 | bus_space_handle_t *bshp) | 140 | bus_space_handle_t *bshp) | |
141 | { | 141 | { | |
142 | const struct pmap_devmap *pd; | 142 | const struct pmap_devmap *pd; | |
143 | paddr_t startpa, endpa, pa, offset; | 143 | paddr_t startpa, endpa, pa, offset; | |
144 | vaddr_t va; | 144 | vaddr_t va; | |
145 | pt_entry_t *pte; | |||
146 | 145 | |||
147 | if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) { | 146 | if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) { | |
148 | /* Device was statically mapped. */ | 147 | /* Device was statically mapped. */ | |
149 | *bshp = pd->pd_va + (bpa - pd->pd_pa); | 148 | *bshp = pd->pd_va + (bpa - pd->pd_pa); | |
150 | return (0); | 149 | return (0); | |
151 | } | 150 | } | |
152 | 151 | |||
153 | endpa = round_page(bpa + size); | 152 | endpa = round_page(bpa + size); | |
154 | offset = bpa & PAGE_MASK; | 153 | offset = bpa & PAGE_MASK; | |
155 | startpa = trunc_page(bpa); | 154 | startpa = trunc_page(bpa); | |
156 | 155 | |||
157 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | 156 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | |
158 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | 157 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | |
159 | if (va == 0) | 158 | if (va == 0) | |
160 | return(ENOMEM); | 159 | return(ENOMEM); | |
161 | 160 | |||
162 | *bshp = va + offset; | 161 | *bshp = va + offset; | |
163 | 162 | |||
163 | const int pmapflags = | |||
164 | (flag & (BUS_SPACE_MAP_CACHEABLE|BUS_SPACE_MAP_PREFETCHABLE)) | |||
165 | ? 0 | |||
166 | : PMAP_NOCACHE; | |||
164 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | 167 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | |
165 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, 0); | 168 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, pmapflags); | |
166 | pte = vtopte(va); | |||
167 | *pte &= ~L2_S_CACHE_MASK; | |||
168 | PTE_SYNC(pte); | |||
169 | } | 169 | } | |
170 | pmap_update(pmap_kernel()); | 170 | pmap_update(pmap_kernel()); | |
171 | 171 | |||
172 | return (0); | 172 | return (0); | |
173 | } | 173 | } | |
174 | 174 | |||
175 | int | 175 | int | |
176 | obio_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, bus_size_t size, | 176 | obio_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, bus_size_t size, | |
177 | bus_size_t alignment, bus_size_t boundary, int flags, bus_addr_t *bpap, | 177 | bus_size_t alignment, bus_size_t boundary, int flags, bus_addr_t *bpap, | |
178 | bus_space_handle_t *bshp) | 178 | bus_space_handle_t *bshp) | |
179 | { | 179 | { | |
180 | 180 | |||
181 | panic("obio_bs_alloc(): not implemented"); | 181 | panic("obio_bs_alloc(): not implemented"); |
--- src/sys/arch/evbarm/iq80321/obio_space.c 2011/07/01 20:41:16 1.11
+++ src/sys/arch/evbarm/iq80321/obio_space.c 2014/02/22 20:33:00 1.12
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: obio_space.c,v 1.11 2011/07/01 20:41:16 dyoung Exp $ */ | 1 | /* $NetBSD: obio_space.c,v 1.12 2014/02/22 20:33:00 matt Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc. | 4 | * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | 7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -30,27 +30,27 @@ | @@ -30,27 +30,27 @@ | |||
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
35 | * POSSIBILITY OF SUCH DAMAGE. | 35 | * POSSIBILITY OF SUCH DAMAGE. | |
36 | */ | 36 | */ | |
37 | 37 | |||
38 | /* | 38 | /* | |
39 | * bus_space functions for IQ80321 on-board devices | 39 | * bus_space functions for IQ80321 on-board devices | |
40 | */ | 40 | */ | |
41 | 41 | |||
42 | #include <sys/cdefs.h> | 42 | #include <sys/cdefs.h> | |
43 | __KERNEL_RCSID(0, "$NetBSD: obio_space.c,v 1.11 2011/07/01 20:41:16 dyoung Exp $"); | 43 | __KERNEL_RCSID(0, "$NetBSD: obio_space.c,v 1.12 2014/02/22 20:33:00 matt Exp $"); | |
44 | 44 | |||
45 | #include <sys/param.h> | 45 | #include <sys/param.h> | |
46 | #include <sys/systm.h> | 46 | #include <sys/systm.h> | |
47 | 47 | |||
48 | #include <uvm/uvm_extern.h> | 48 | #include <uvm/uvm_extern.h> | |
49 | 49 | |||
50 | #include <sys/bus.h> | 50 | #include <sys/bus.h> | |
51 | 51 | |||
52 | /* Prototypes for all the bus_space structure functions */ | 52 | /* Prototypes for all the bus_space structure functions */ | |
53 | bs_protos(obio); | 53 | bs_protos(obio); | |
54 | bs_protos(generic); | 54 | bs_protos(generic); | |
55 | bs_protos(generic_armv4); | 55 | bs_protos(generic_armv4); | |
56 | bs_protos(bs_notimpl); | 56 | bs_protos(bs_notimpl); | |
@@ -127,56 +127,57 @@ struct bus_space obio_bs_tag = { | @@ -127,56 +127,57 @@ struct bus_space obio_bs_tag = { | |||
127 | bs_notimpl_bs_sr_1, | 127 | bs_notimpl_bs_sr_1, | |
128 | bs_notimpl_bs_sr_2, | 128 | bs_notimpl_bs_sr_2, | |
129 | bs_notimpl_bs_sr_4, | 129 | bs_notimpl_bs_sr_4, | |
130 | bs_notimpl_bs_sr_8, | 130 | bs_notimpl_bs_sr_8, | |
131 | 131 | |||
132 | /* copy */ | 132 | /* copy */ | |
133 | bs_notimpl_bs_c_1, | 133 | bs_notimpl_bs_c_1, | |
134 | bs_notimpl_bs_c_2, | 134 | bs_notimpl_bs_c_2, | |
135 | bs_notimpl_bs_c_4, | 135 | bs_notimpl_bs_c_4, | |
136 | bs_notimpl_bs_c_8, | 136 | bs_notimpl_bs_c_8, | |
137 | }; | 137 | }; | |
138 | 138 | |||
139 | int | 139 | int | |
140 | obio_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flags, | 140 | obio_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flag, | |
141 | bus_space_handle_t *bshp) | 141 | bus_space_handle_t *bshp) | |
142 | { | 142 | { | |
143 | const struct pmap_devmap *pd; | 143 | const struct pmap_devmap *pd; | |
144 | paddr_t startpa, endpa, pa, offset; | 144 | paddr_t startpa, endpa, pa, offset; | |
145 | vaddr_t va; | 145 | vaddr_t va; | |
146 | pt_entry_t *pte; | |||
147 | 146 | |||
148 | if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) { | 147 | if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) { | |
149 | /* Device was statically mapped. */ | 148 | /* Device was statically mapped. */ | |
150 | *bshp = pd->pd_va + (bpa - pd->pd_pa); | 149 | *bshp = pd->pd_va + (bpa - pd->pd_pa); | |
151 | return (0); | 150 | return (0); | |
152 | } | 151 | } | |
153 | 152 | |||
154 | endpa = round_page(bpa + size); | 153 | endpa = round_page(bpa + size); | |
155 | offset = bpa & PAGE_MASK; | 154 | offset = bpa & PAGE_MASK; | |
156 | startpa = trunc_page(bpa); | 155 | startpa = trunc_page(bpa); | |
157 | 156 | |||
158 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | 157 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | |
159 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | 158 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | |
160 | if (va == 0) | 159 | if (va == 0) | |
161 | return (ENOMEM); | 160 | return (ENOMEM); | |
162 | 161 | |||
163 | *bshp = va + offset; | 162 | *bshp = va + offset; | |
164 | 163 | |||
164 | const int pmapflags = | |||
165 | (flag & (BUS_SPACE_MAP_CACHEABLE|BUS_SPACE_MAP_PREFETCHABLE)) | |||
166 | ? 0 | |||
167 | : PMAP_NOCACHE; | |||
168 | ||||
165 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | 169 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | |
166 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, 0); | 170 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, pmapflags); | |
167 | pte = vtopte(va); | |||
168 | *pte &= ~L2_S_CACHE_MASK; | |||
169 | PTE_SYNC(pte); | |||
170 | } | 171 | } | |
171 | pmap_update(pmap_kernel()); | 172 | pmap_update(pmap_kernel()); | |
172 | 173 | |||
173 | return (0); | 174 | return (0); | |
174 | } | 175 | } | |
175 | 176 | |||
176 | int | 177 | int | |
177 | obio_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, bus_size_t size, | 178 | obio_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, bus_size_t size, | |
178 | bus_size_t alignment, bus_size_t boundary, int flags, bus_addr_t *bpap, | 179 | bus_size_t alignment, bus_size_t boundary, int flags, bus_addr_t *bpap, | |
179 | bus_space_handle_t *bshp) | 180 | bus_space_handle_t *bshp) | |
180 | { | 181 | { | |
181 | 182 | |||
182 | panic("obio_bs_alloc(): not implemented"); | 183 | panic("obio_bs_alloc(): not implemented"); |
--- src/sys/arch/iyonix/iyonix/obio_space.c 2011/07/01 20:48:23 1.5
+++ src/sys/arch/iyonix/iyonix/obio_space.c 2014/02/22 20:33:00 1.6
@@ -1,14 +1,14 @@ | @@ -1,14 +1,14 @@ | |||
1 | /* $NetBSD: obio_space.c,v 1.5 2011/07/01 20:48:23 dyoung Exp $ */ | 1 | /* $NetBSD: obio_space.c,v 1.6 2014/02/22 20:33:00 matt Exp $ */ | |
2 | 2 | |||
3 | /* | 3 | /* | |
4 | * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc. | 4 | * Copyright (c) 2001, 2002, 2003 Wasabi Systems, Inc. | |
5 | * All rights reserved. | 5 | * All rights reserved. | |
6 | * | 6 | * | |
7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | 7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | |
8 | * | 8 | * | |
9 | * Redistribution and use in source and binary forms, with or without | 9 | * Redistribution and use in source and binary forms, with or without | |
10 | * modification, are permitted provided that the following conditions | 10 | * modification, are permitted provided that the following conditions | |
11 | * are met: | 11 | * are met: | |
12 | * 1. Redistributions of source code must retain the above copyright | 12 | * 1. Redistributions of source code must retain the above copyright | |
13 | * notice, this list of conditions and the following disclaimer. | 13 | * notice, this list of conditions and the following disclaimer. | |
14 | * 2. Redistributions in binary form must reproduce the above copyright | 14 | * 2. Redistributions in binary form must reproduce the above copyright | |
@@ -30,27 +30,27 @@ | @@ -30,27 +30,27 @@ | |||
30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 30 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 31 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | 32 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
35 | * POSSIBILITY OF SUCH DAMAGE. | 35 | * POSSIBILITY OF SUCH DAMAGE. | |
36 | */ | 36 | */ | |
37 | 37 | |||
38 | /* | 38 | /* | |
39 | * bus_space functions for Tungsten on-board devices | 39 | * bus_space functions for Tungsten on-board devices | |
40 | */ | 40 | */ | |
41 | 41 | |||
42 | #include <sys/cdefs.h> | 42 | #include <sys/cdefs.h> | |
43 | __KERNEL_RCSID(0, "$NetBSD: obio_space.c,v 1.5 2011/07/01 20:48:23 dyoung Exp $"); | 43 | __KERNEL_RCSID(0, "$NetBSD: obio_space.c,v 1.6 2014/02/22 20:33:00 matt Exp $"); | |
44 | 44 | |||
45 | #include <sys/param.h> | 45 | #include <sys/param.h> | |
46 | #include <sys/systm.h> | 46 | #include <sys/systm.h> | |
47 | 47 | |||
48 | #include <uvm/uvm_extern.h> | 48 | #include <uvm/uvm_extern.h> | |
49 | 49 | |||
50 | #include <sys/bus.h> | 50 | #include <sys/bus.h> | |
51 | 51 | |||
52 | /* Prototypes for all the bus_space structure functions */ | 52 | /* Prototypes for all the bus_space structure functions */ | |
53 | bs_protos(obio); | 53 | bs_protos(obio); | |
54 | bs_protos(generic); | 54 | bs_protos(generic); | |
55 | bs_protos(generic_armv4); | 55 | bs_protos(generic_armv4); | |
56 | bs_protos(bs_notimpl); | 56 | bs_protos(bs_notimpl); | |
@@ -127,56 +127,57 @@ struct bus_space obio_bs_tag = { | @@ -127,56 +127,57 @@ struct bus_space obio_bs_tag = { | |||
127 | bs_notimpl_bs_sr_1, | 127 | bs_notimpl_bs_sr_1, | |
128 | bs_notimpl_bs_sr_2, | 128 | bs_notimpl_bs_sr_2, | |
129 | bs_notimpl_bs_sr_4, | 129 | bs_notimpl_bs_sr_4, | |
130 | bs_notimpl_bs_sr_8, | 130 | bs_notimpl_bs_sr_8, | |
131 | 131 | |||
132 | /* copy */ | 132 | /* copy */ | |
133 | bs_notimpl_bs_c_1, | 133 | bs_notimpl_bs_c_1, | |
134 | bs_notimpl_bs_c_2, | 134 | bs_notimpl_bs_c_2, | |
135 | bs_notimpl_bs_c_4, | 135 | bs_notimpl_bs_c_4, | |
136 | bs_notimpl_bs_c_8, | 136 | bs_notimpl_bs_c_8, | |
137 | }; | 137 | }; | |
138 | 138 | |||
139 | int | 139 | int | |
140 | obio_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flags, | 140 | obio_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flag, | |
141 | bus_space_handle_t *bshp) | 141 | bus_space_handle_t *bshp) | |
142 | { | 142 | { | |
143 | const struct pmap_devmap *pd; | 143 | const struct pmap_devmap *pd; | |
144 | paddr_t startpa, endpa, pa, offset; | 144 | paddr_t startpa, endpa, pa, offset; | |
145 | vaddr_t va; | 145 | vaddr_t va; | |
146 | pt_entry_t *pte; | |||
147 | 146 | |||
148 | if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) { | 147 | if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) { | |
149 | /* Device was statically mapped. */ | 148 | /* Device was statically mapped. */ | |
150 | *bshp = pd->pd_va + (bpa - pd->pd_pa); | 149 | *bshp = pd->pd_va + (bpa - pd->pd_pa); | |
151 | return (0); | 150 | return (0); | |
152 | } | 151 | } | |
153 | 152 | |||
154 | endpa = round_page(bpa + size); | 153 | endpa = round_page(bpa + size); | |
155 | offset = bpa & PAGE_MASK; | 154 | offset = bpa & PAGE_MASK; | |
156 | startpa = trunc_page(bpa); | 155 | startpa = trunc_page(bpa); | |
157 | 156 | |||
158 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | 157 | va = uvm_km_alloc(kernel_map, endpa - startpa, 0, | |
159 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | 158 | UVM_KMF_VAONLY | UVM_KMF_NOWAIT); | |
160 | if (va == 0) | 159 | if (va == 0) | |
161 | return (ENOMEM); | 160 | return (ENOMEM); | |
162 | 161 | |||
163 | *bshp = va + offset; | 162 | *bshp = va + offset; | |
164 | 163 | |||
164 | const int pmapflags = | |||
165 | (flag & (BUS_SPACE_MAP_CACHEABLE|BUS_SPACE_MAP_PREFETCHABLE)) | |||
166 | ? 0 | |||
167 | : PMAP_NOCACHE; | |||
168 | ||||
165 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | 169 | for (pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) { | |
166 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, 0); | 170 | pmap_kenter_pa(va, pa, VM_PROT_READ | VM_PROT_WRITE, pmapflags); | |
167 | pte = vtopte(va); | |||
168 | *pte &= ~L2_S_CACHE_MASK; | |||
169 | PTE_SYNC(pte); | |||
170 | } | 171 | } | |
171 | pmap_update(pmap_kernel()); | 172 | pmap_update(pmap_kernel()); | |
172 | 173 | |||
173 | return (0); | 174 | return (0); | |
174 | } | 175 | } | |
175 | 176 | |||
176 | int | 177 | int | |
177 | obio_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, bus_size_t size, | 178 | obio_bs_alloc(void *t, bus_addr_t rstart, bus_addr_t rend, bus_size_t size, | |
178 | bus_size_t alignment, bus_size_t boundary, int flags, bus_addr_t *bpap, | 179 | bus_size_t alignment, bus_size_t boundary, int flags, bus_addr_t *bpap, | |
179 | bus_space_handle_t *bshp) | 180 | bus_space_handle_t *bshp) | |
180 | { | 181 | { | |
181 | 182 | |||
182 | panic("obio_bs_alloc(): not implemented"); | 183 | panic("obio_bs_alloc(): not implemented"); |