Deleted Added
full compact
sa11x0_io.c (164440) sa11x0_io.c (177887)
1/* $NetBSD: sa11x0_io.c,v 1.12 2003/07/15 00:24:51 lukem Exp $ */
2
3/*-
4 * Copyright (c) 1997 Mark Brinicombe.
5 * Copyright (c) 1997 Causality Limited.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation

--- 27 unchanged lines hidden (view full) ---

36 * SUCH DAMAGE.
37 */
38
39/*
40 * bus_space I/O functions for sa11x0
41 */
42
43#include <sys/cdefs.h>
1/* $NetBSD: sa11x0_io.c,v 1.12 2003/07/15 00:24:51 lukem Exp $ */
2
3/*-
4 * Copyright (c) 1997 Mark Brinicombe.
5 * Copyright (c) 1997 Causality Limited.
6 * All rights reserved.
7 *
8 * This code is derived from software contributed to The NetBSD Foundation

--- 27 unchanged lines hidden (view full) ---

36 * SUCH DAMAGE.
37 */
38
39/*
40 * bus_space I/O functions for sa11x0
41 */
42
43#include <sys/cdefs.h>
44__FBSDID("$FreeBSD: head/sys/arm/sa11x0/sa11x0_io.c 164440 2006-11-20 13:21:02Z kevlo $");
44__FBSDID("$FreeBSD: head/sys/arm/sa11x0/sa11x0_io.c 177887 2008-04-03 18:22:08Z raj $");
45#include <sys/param.h>
46#include <sys/systm.h>
47#include <sys/queue.h>
48#include <sys/lock.h>
49#include <sys/mutex.h>
50
51#include <vm/vm.h>
52#include <vm/pmap.h>
53#include <vm/vm_extern.h>
54#include <vm/vm_kern.h>
55
56#include <machine/bus.h>
57#include <machine/pmap.h>
58
59/* Proto types for all the bus_space structure functions */
60
45#include <sys/param.h>
46#include <sys/systm.h>
47#include <sys/queue.h>
48#include <sys/lock.h>
49#include <sys/mutex.h>
50
51#include <vm/vm.h>
52#include <vm/pmap.h>
53#include <vm/vm_extern.h>
54#include <vm/vm_kern.h>
55
56#include <machine/bus.h>
57#include <machine/pmap.h>
58
59/* Proto types for all the bus_space structure functions */
60
61bs_protos(generic);
61bs_protos(sa11x0);
62
63/* Declare the sa11x0 bus space tag */
64
65struct bus_space sa11x0_bs_tag = {
66 /* cookie */
67 NULL,
68
69 /* mapping/unmapping */
62bs_protos(sa11x0);
63
64/* Declare the sa11x0 bus space tag */
65
66struct bus_space sa11x0_bs_tag = {
67 /* cookie */
68 NULL,
69
70 /* mapping/unmapping */
70 sa11x0_bs_map,
71 sa11x0_bs_unmap,
72 sa11x0_bs_subregion,
71 generic_bs_map,
72 generic_bs_unmap,
73 generic_bs_subregion,
73
74 /* allocation/deallocation */
74
75 /* allocation/deallocation */
75 sa11x0_bs_alloc,
76 sa11x0_bs_free,
76 generic_bs_alloc,
77 generic_bs_free,
77
78 /* barrier */
78
79 /* barrier */
79 sa11x0_bs_barrier,
80 generic_bs_barrier,
80
81 /* read (single) */
82 sa11x0_bs_r_1,
83 sa11x0_bs_r_2,
84 sa11x0_bs_r_4,
85 NULL,
86
87 /* read multiple */

--- 39 unchanged lines hidden (view full) ---

127
128 /* copy */
129 NULL,
130 sa11x0_bs_c_2,
131 NULL,
132 NULL,
133};
134
81
82 /* read (single) */
83 sa11x0_bs_r_1,
84 sa11x0_bs_r_2,
85 sa11x0_bs_r_4,
86 NULL,
87
88 /* read multiple */

--- 39 unchanged lines hidden (view full) ---

128
129 /* copy */
130 NULL,
131 sa11x0_bs_c_2,
132 NULL,
133 NULL,
134};
135
135/* bus space functions */
136
137int
138sa11x0_bs_map(t, bpa, size, cacheable, bshp)
139 void *t;
140 bus_addr_t bpa;
141 bus_size_t size;
142 int cacheable;
143 bus_space_handle_t *bshp;
144{
145 u_long startpa, endpa, pa;
146 vm_offset_t va;
147 pt_entry_t *pte;
148 const struct pmap_devmap *pd;
149
150 if ((pd = pmap_devmap_find_pa(bpa, size)) != NULL) {
151 /* Device was statically mapped. */
152 *bshp = pd->pd_va + (bpa - pd->pd_pa);
153 return 0;
154 }
155
156 startpa = trunc_page(bpa);
157 endpa = round_page(bpa + size);
158
159 /* XXX use extent manager to check duplicate mapping */
160
161 va = kmem_alloc(kernel_map, endpa - startpa);
162 if (! va)
163 return(ENOMEM);
164
165 *bshp = (bus_space_handle_t)(va + (bpa - startpa));
166
167 for(pa = startpa; pa < endpa; pa += PAGE_SIZE, va += PAGE_SIZE) {
168 pmap_kenter(va, pa);
169 pte = vtopte(va);
170 if (cacheable == 0) {
171 *pte &= ~L2_S_CACHE_MASK;
172 PTE_SYNC(pte);
173 }
174 }
175 return(0);
176}
177
178int
179sa11x0_bs_alloc(t, rstart, rend, size, alignment, boundary, cacheable,
180 bpap, bshp)
181 void *t;
182 bus_addr_t rstart, rend;
183 bus_size_t size, alignment, boundary;
184 int cacheable;
185 bus_addr_t *bpap;
186 bus_space_handle_t *bshp;
187{
188 panic("sa11x0_alloc(): Help!");
189}
190
191
192void
193sa11x0_bs_unmap(t, h, size)
194 void *t;
195 bus_space_handle_t h;
196 bus_size_t size;
197{
198 vm_offset_t va, endva;
199
200 if (pmap_devmap_find_va((vm_offset_t)t, size) != NULL) {
201 /* Device was statically mapped; nothing to do. */
202 return;
203 }
204
205 va = trunc_page((vm_offset_t)t);
206 endva = round_page((vm_offset_t)t + size);
207
208 while (va < endva) {
209 pmap_kremove(va);
210 va += PAGE_SIZE;
211 }
212 kmem_free(kernel_map, va, endva - va);
213}
214
215void
216sa11x0_bs_free(t, bsh, size)
217 void *t;
218 bus_space_handle_t bsh;
219 bus_size_t size;
220{
221
222 panic("sa11x0_free(): Help!");
223 /* sa11x0_unmap() does all that we need to do. */
224/* sa11x0_unmap(t, bsh, size);*/
225}
226
227int
228sa11x0_bs_subregion(t, bsh, offset, size, nbshp)
229 void *t;
230 bus_space_handle_t bsh;
231 bus_size_t offset, size;
232 bus_space_handle_t *nbshp;
233{
234
235 *nbshp = bsh + offset;
236 return (0);
237}
238
239void
240sa11x0_bs_barrier(t, bsh, offset, len, flags)
241 void *t;
242 bus_space_handle_t bsh;
243 bus_size_t offset, len;
244 int flags;
245{
246/* NULL */
247}
248
249/* End of sa11x0_io.c */
136/* End of sa11x0_io.c */