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