footbridge_machdep.c revision 1.3.6.3 1 1.3.6.3 nathanw /* $NetBSD: footbridge_machdep.c,v 1.3.6.3 2002/01/11 23:38:03 nathanw Exp $ */
2 1.3.6.2 nathanw
3 1.3.6.2 nathanw /*
4 1.3.6.2 nathanw * Copyright (c) 1997 Mark Brinicombe.
5 1.3.6.2 nathanw * Copyright (c) 1997 Causality Limited
6 1.3.6.2 nathanw * All rights reserved.
7 1.3.6.2 nathanw *
8 1.3.6.2 nathanw * Redistribution and use in source and binary forms, with or without
9 1.3.6.2 nathanw * modification, are permitted provided that the following conditions
10 1.3.6.2 nathanw * are met:
11 1.3.6.2 nathanw * 1. Redistributions of source code must retain the above copyright
12 1.3.6.2 nathanw * notice, this list of conditions and the following disclaimer.
13 1.3.6.2 nathanw * 2. Redistributions in binary form must reproduce the above copyright
14 1.3.6.2 nathanw * notice, this list of conditions and the following disclaimer in the
15 1.3.6.2 nathanw * documentation and/or other materials provided with the distribution.
16 1.3.6.2 nathanw * 3. All advertising materials mentioning features or use of this software
17 1.3.6.2 nathanw * must display the following acknowledgement:
18 1.3.6.2 nathanw * This product includes software developed by Mark Brinicombe
19 1.3.6.2 nathanw * for the NetBSD Project.
20 1.3.6.2 nathanw * 4. The name of the company nor the name of the author may be used to
21 1.3.6.2 nathanw * endorse or promote products derived from this software without specific
22 1.3.6.2 nathanw * prior written permission.
23 1.3.6.2 nathanw *
24 1.3.6.2 nathanw * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
25 1.3.6.2 nathanw * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 1.3.6.2 nathanw * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27 1.3.6.2 nathanw * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
28 1.3.6.2 nathanw * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 1.3.6.2 nathanw * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 1.3.6.2 nathanw * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 1.3.6.2 nathanw * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 1.3.6.2 nathanw * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 1.3.6.2 nathanw * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 1.3.6.2 nathanw * SUCH DAMAGE.
35 1.3.6.2 nathanw */
36 1.3.6.2 nathanw
37 1.3.6.2 nathanw #include <sys/param.h>
38 1.3.6.2 nathanw #include <sys/systm.h>
39 1.3.6.2 nathanw #include <uvm/uvm_extern.h>
40 1.3.6.2 nathanw #include <machine/pmap.h>
41 1.3.6.3 nathanw #include <arm/footbridge/footbridge.h>
42 1.3.6.2 nathanw #include <arm/footbridge/dc21285mem.h>
43 1.3.6.2 nathanw
44 1.3.6.2 nathanw extern pt_entry_t *pmap_pte __P((pmap_t pmap, vm_offset_t va));
45 1.3.6.2 nathanw
46 1.3.6.2 nathanw /*
47 1.3.6.2 nathanw * For optimal cache cleaning we need two 16K banks of
48 1.3.6.2 nathanw * virtual address space that NOTHING else will access
49 1.3.6.2 nathanw * and then we alternate the cache cleaning between the
50 1.3.6.2 nathanw * two banks.
51 1.3.6.2 nathanw * The cache cleaning code requires requires 2 banks aligned
52 1.3.6.2 nathanw * on total size boundry so the banks can be alternated by
53 1.3.6.2 nathanw * eorring the size bit (assumes the bank size is a power of 2)
54 1.3.6.2 nathanw *
55 1.3.6.2 nathanw * On the DC21285 we have a special cache clean area so we will
56 1.3.6.2 nathanw * use it.
57 1.3.6.2 nathanw */
58 1.3.6.2 nathanw
59 1.3.6.2 nathanw extern unsigned int sa110_cache_clean_addr;
60 1.3.6.2 nathanw extern unsigned int sa110_cache_clean_size;
61 1.3.6.2 nathanw
62 1.3.6.2 nathanw #if 0
63 1.3.6.2 nathanw void
64 1.3.6.2 nathanw footbridge_sa110_cc_setup(void)
65 1.3.6.2 nathanw {
66 1.3.6.2 nathanw vm_offset_t vaddr;
67 1.3.6.2 nathanw vm_offset_t addr;
68 1.3.6.2 nathanw int cleanarea;
69 1.3.6.2 nathanw int loop;
70 1.3.6.2 nathanw pt_entry_t *pte;
71 1.3.6.2 nathanw
72 1.3.6.2 nathanw cleanarea = (NBPG * 4) * 2;
73 1.3.6.2 nathanw vaddr = uvm_km_valloc(kernel_map, cleanarea + (NBPG * 4));
74 1.3.6.2 nathanw addr = (vaddr + (cleanarea - 1)) & ~(cleanarea - 1);
75 1.3.6.2 nathanw
76 1.3.6.2 nathanw /* printf("vaddr=%x addr=%x\n", vaddr, addr);*/
77 1.3.6.2 nathanw
78 1.3.6.2 nathanw for (loop = 0; loop < cleanarea; loop += NBPG) {
79 1.3.6.2 nathanw pte = pmap_pte(pmap_kernel(), (addr + loop));
80 1.3.6.2 nathanw *pte = L2_PTE(DC21285_SA_CACHE_FLUSH_BASE + loop, AP_KR);
81 1.3.6.2 nathanw }
82 1.3.6.2 nathanw sa110_cache_clean_addr = addr;
83 1.3.6.2 nathanw sa110_cache_clean_size = cleanarea / 2;
84 1.3.6.2 nathanw }
85 1.3.6.2 nathanw #else
86 1.3.6.2 nathanw void
87 1.3.6.2 nathanw footbridge_sa110_cc_setup(void)
88 1.3.6.2 nathanw {
89 1.3.6.2 nathanw sa110_cache_clean_addr = DC21285_CACHE_FLUSH_VBASE;
90 1.3.6.2 nathanw sa110_cache_clean_size = (NBPG * 4);
91 1.3.6.2 nathanw }
92 1.3.6.2 nathanw #endif
93