1 /* $NetBSD: gemini_space.c,v 1.1 2008/10/24 04:23:18 matt Exp $ */
4 * NetBSD: pxa2x0_space.c,v 1.8 2005/11/24 13:08:32 yamt Exp
8 * Copyright (c) 2001, 2002 Wasabi Systems, Inc.
11 * Written by Jason R. Thorpe for Wasabi Systems, Inc.
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
21 * 3. All advertising materials mentioning features or use of this software
22 * must display the following acknowledgement:
23 * This product includes software developed for the NetBSD Project by
24 * Wasabi Systems, Inc.
25 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
26 * or promote products derived from this software without specific prior
29 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
30 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
31 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
32 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
33 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
36 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
37 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
38 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
39 * POSSIBILITY OF SUCH DAMAGE.
42 * Copyright (c) 1997 Mark Brinicombe.
43 * Copyright (c) 1997 Causality Limited.
44 * All rights reserved.
46 * This code is derived from software contributed to The NetBSD Foundation
49 * Redistribution and use in source and binary forms, with or without
50 * modification, are permitted provided that the following conditions
52 * 1. Redistributions of source code must retain the above copyright
53 * notice, this list of conditions and the following disclaimer.
54 * 2. Redistributions in binary form must reproduce the above copyright
55 * notice, this list of conditions and the following disclaimer in the
56 * documentation and/or other materials provided with the distribution.
57 * 3. All advertising materials mentioning features or use of this software
58 * must display the following acknowledgement:
59 * This product includes software developed by Mark Brinicombe.
60 * 4. The name of the company nor the name of the author may be used to
61 * endorse or promote products derived from this software without specific
62 * prior written permission.
64 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
65 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
66 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
67 * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
68 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
69 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
70 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
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
73 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
78 * bus_space functions for Gemini processor.
81 #include <sys/cdefs.h>
82 __KERNEL_RCSID(0, "$NetBSD: gemini_space.c,v 1.1 2008/10/24 04:23:18 matt Exp $");
84 #include <sys/param.h>
85 #include <sys/systm.h>
87 #include <uvm/uvm_extern.h>
89 #include <machine/bus.h>
91 /* Prototypes for all the bus_space structure functions */
94 bs_protos(generic_armv4
);
95 bs_protos(bs_notimpl
);
97 struct bus_space gemini_bs_tag
= {
101 /* mapping/unmapping */
106 /* allocation/deallocation */
107 gemini_bs_alloc
, /* not implemented */
108 gemini_bs_free
, /* not implemented */
110 /* get kernel virtual address */
121 generic_armv4_bs_r_2
,
127 generic_armv4_bs_rm_2
,
133 generic_armv4_bs_rr_2
,
139 generic_armv4_bs_w_2
,
145 generic_armv4_bs_wm_2
,
151 generic_armv4_bs_wr_2
,
163 generic_armv4_bs_sr_2
,
169 generic_armv4_bs_c_2
,
175 gemini_bs_map(void *t
, bus_addr_t bpa
, bus_size_t size
,
176 int flag
, bus_space_handle_t
*bshp
)
178 u_long startpa
, endpa
, pa
;
181 const struct pmap_devmap
*pd
;
183 if ((pd
= pmap_devmap_find_pa(bpa
, size
)) != NULL
) {
184 /* Device was statically mapped. */
185 *bshp
= pd
->pd_va
+ (bpa
- pd
->pd_pa
);
189 startpa
= trunc_page(bpa
);
190 endpa
= round_page(bpa
+ size
);
192 /* XXX use extent manager to check duplicate mapping */
194 va
= uvm_km_alloc(kernel_map
, endpa
- startpa
, 0,
195 UVM_KMF_VAONLY
| UVM_KMF_NOWAIT
);
199 *bshp
= (bus_space_handle_t
)(va
+ (bpa
- startpa
));
201 for (pa
= startpa
; pa
< endpa
; pa
+= PAGE_SIZE
, va
+= PAGE_SIZE
) {
202 pmap_kenter_pa(va
, pa
, VM_PROT_READ
| VM_PROT_WRITE
, 0);
203 if ((flag
& BUS_SPACE_MAP_CACHEABLE
) == 0) {
205 *pte
&= ~L2_S_CACHE_MASK
;
207 /* XXX: pmap_kenter_pa() also does PTE_SYNC(). a bit of
212 pmap_update(pmap_kernel());
218 gemini_bs_unmap(void *t
, bus_space_handle_t bsh
, bus_size_t size
)
223 if (pmap_devmap_find_va(bsh
, size
) != NULL
) {
224 /* Device was statically mapped; nothing to do. */
228 va
= trunc_page(bsh
);
229 sz
= round_page(bsh
+ size
) - va
;
231 pmap_kremove(va
, sz
);
232 pmap_update(pmap_kernel());
233 uvm_km_free(kernel_map
, va
, sz
, UVM_KMF_VAONLY
);
238 gemini_bs_subregion(void *t
, bus_space_handle_t bsh
, bus_size_t offset
,
239 bus_size_t size
, bus_space_handle_t
*nbshp
)
242 *nbshp
= bsh
+ offset
;
247 gemini_bs_barrier(void *t
, bus_space_handle_t bsh
, bus_size_t offset
,
248 bus_size_t len
, int flags
)
255 gemini_bs_vaddr(void *t
, bus_space_handle_t bsh
)
258 return ((void *)bsh
);
263 gemini_bs_alloc(void *t
, bus_addr_t rstart
, bus_addr_t rend
,
264 bus_size_t size
, bus_size_t alignment
, bus_size_t boundary
, int flags
,
265 bus_addr_t
*bpap
, bus_space_handle_t
*bshp
)
268 panic("gemini_io_bs_alloc(): not implemented\n");
272 gemini_bs_free(void *t
, bus_space_handle_t bsh
, bus_size_t size
)
275 panic("gemini_io_bs_free(): not implemented\n");