Home | History | Annotate | Line # | Download | only in boot
cache.c revision 1.2.14.2
      1 /*	$NetBSD: cache.c,v 1.2.14.2 2007/12/03 19:03:07 ad Exp $	*/
      2 
      3 /*
      4  * Copyright 2001 Wasabi Systems, Inc.
      5  * All rights reserved.
      6  *
      7  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  * 3. All advertising materials mentioning features or use of this software
     18  *    must display the following acknowledgement:
     19  *      This product includes software developed for the NetBSD Project by
     20  *      Wasabi Systems, Inc.
     21  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     22  *    or promote products derived from this software without specific prior
     23  *    written permission.
     24  *
     25  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     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
     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
     35  * POSSIBILITY OF SUCH DAMAGE.
     36  */
     37 
     38 #include <lib/libsa/stand.h>
     39 #include <lib/libkern/libkern.h>
     40 
     41 #include <mips/cpuregs.h>
     42 #include <mips/cache_r4k.h>
     43 
     44 #include "boot.h"
     45 
     46 #define round_line(x)	(((x) + (CACHELINESIZE - 1)) & ~(CACHELINESIZE - 1))
     47 #define trunc_line(x)	((x) & ~(CACHELINESIZE - 1))
     48 
     49 __asm(".set mips3");
     50 
     51 void
     52 pdcache_inv(uint32_t va, u_int size)
     53 {
     54 	uint32_t eva;
     55 
     56 	eva = round_line(va + size);
     57 	va  = trunc_line(va);
     58 
     59 	while (va < eva) {
     60 		cache_op_r4k_line(va, CACHE_R4K_D|CACHEOP_R4K_HIT_INV);
     61 		va += CACHELINESIZE;
     62 	}
     63 }
     64 
     65 void
     66 pdcache_wb(uint32_t va, u_int size)
     67 {
     68 	uint32_t eva;
     69 
     70 	eva = round_line(va + size);
     71 	va  = trunc_line(va);
     72 
     73 	while (va < eva) {
     74 		cache_op_r4k_line(va, CACHE_R4K_D|CACHEOP_R4K_HIT_WB);
     75 		va += CACHELINESIZE;
     76 	}
     77 }
     78 
     79 void
     80 pdcache_wbinv(uint32_t va, u_int size)
     81 {
     82 	uint32_t eva;
     83 
     84 	eva = round_line(va + size);
     85 	va  = trunc_line(va);
     86 
     87 	while (va < eva) {
     88 		cache_op_r4k_line(va, CACHE_R4K_D|CACHEOP_R4K_HIT_WB_INV);
     89 		va += CACHELINESIZE;
     90 	}
     91 }
     92 /*	$NetBSD: cache.c,v 1.2.14.2 2007/12/03 19:03:07 ad Exp $	*/
     93 
     94 /*
     95  * Copyright 2001 Wasabi Systems, Inc.
     96  * All rights reserved.
     97  *
     98  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
     99  *
    100  * Redistribution and use in source and binary forms, with or without
    101  * modification, are permitted provided that the following conditions
    102  * are met:
    103  * 1. Redistributions of source code must retain the above copyright
    104  *    notice, this list of conditions and the following disclaimer.
    105  * 2. Redistributions in binary form must reproduce the above copyright
    106  *    notice, this list of conditions and the following disclaimer in the
    107  *    documentation and/or other materials provided with the distribution.
    108  * 3. All advertising materials mentioning features or use of this software
    109  *    must display the following acknowledgement:
    110  *      This product includes software developed for the NetBSD Project by
    111  *      Wasabi Systems, Inc.
    112  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
    113  *    or promote products derived from this software without specific prior
    114  *    written permission.
    115  *
    116  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
    117  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
    118  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    119  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
    120  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    121  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    122  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    123  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    124  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    125  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    126  * POSSIBILITY OF SUCH DAMAGE.
    127  */
    128 
    129 #include <lib/libsa/stand.h>
    130 #include <lib/libkern/libkern.h>
    131 
    132 #include <mips/cpuregs.h>
    133 #include <mips/cache_r4k.h>
    134 
    135 #include "boot.h"
    136 
    137 #define round_line(x)	(((x) + (CACHELINESIZE - 1)) & ~(CACHELINESIZE - 1))
    138 #define trunc_line(x)	((x) & ~(CACHELINESIZE - 1))
    139 
    140 __asm(".set mips3");
    141 
    142 void
    143 pdcache_inv(uint32_t va, u_int size)
    144 {
    145 	uint32_t eva;
    146 
    147 	eva = round_line(va + size);
    148 	va  = trunc_line(va);
    149 
    150 	while (va < eva) {
    151 		cache_op_r4k_line(va, CACHE_R4K_D|CACHEOP_R4K_HIT_INV);
    152 		va += CACHELINESIZE;
    153 	}
    154 }
    155 
    156 void
    157 pdcache_wb(uint32_t va, u_int size)
    158 {
    159 	uint32_t eva;
    160 
    161 	eva = round_line(va + size);
    162 	va  = trunc_line(va);
    163 
    164 	while (va < eva) {
    165 		cache_op_r4k_line(va, CACHE_R4K_D|CACHEOP_R4K_HIT_WB);
    166 		va += CACHELINESIZE;
    167 	}
    168 }
    169 
    170 void
    171 pdcache_wbinv(uint32_t va, u_int size)
    172 {
    173 	uint32_t eva;
    174 
    175 	eva = round_line(va + size);
    176 	va  = trunc_line(va);
    177 
    178 	while (va < eva) {
    179 		cache_op_r4k_line(va, CACHE_R4K_D|CACHEOP_R4K_HIT_WB_INV);
    180 		va += CACHELINESIZE;
    181 	}
    182 }
    183 /*	$NetBSD: cache.c,v 1.2.14.2 2007/12/03 19:03:07 ad Exp $	*/
    184 
    185 /*
    186  * Copyright 2001 Wasabi Systems, Inc.
    187  * All rights reserved.
    188  *
    189  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
    190  *
    191  * Redistribution and use in source and binary forms, with or without
    192  * modification, are permitted provided that the following conditions
    193  * are met:
    194  * 1. Redistributions of source code must retain the above copyright
    195  *    notice, this list of conditions and the following disclaimer.
    196  * 2. Redistributions in binary form must reproduce the above copyright
    197  *    notice, this list of conditions and the following disclaimer in the
    198  *    documentation and/or other materials provided with the distribution.
    199  * 3. All advertising materials mentioning features or use of this software
    200  *    must display the following acknowledgement:
    201  *      This product includes software developed for the NetBSD Project by
    202  *      Wasabi Systems, Inc.
    203  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
    204  *    or promote products derived from this software without specific prior
    205  *    written permission.
    206  *
    207  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
    208  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
    209  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    210  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
    211  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    212  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    213  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    214  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    215  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    216  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    217  * POSSIBILITY OF SUCH DAMAGE.
    218  */
    219 
    220 #include <lib/libsa/stand.h>
    221 #include <lib/libkern/libkern.h>
    222 
    223 #include <mips/cpuregs.h>
    224 #include <mips/cache_r4k.h>
    225 
    226 #include "boot.h"
    227 
    228 #define round_line(x)	(((x) + (CACHELINESIZE - 1)) & ~(CACHELINESIZE - 1))
    229 #define trunc_line(x)	((x) & ~(CACHELINESIZE - 1))
    230 
    231 __asm(".set mips3");
    232 
    233 void
    234 pdcache_inv(uint32_t va, u_int size)
    235 {
    236 	uint32_t eva;
    237 
    238 	eva = round_line(va + size);
    239 	va  = trunc_line(va);
    240 
    241 	while (va < eva) {
    242 		cache_op_r4k_line(va, CACHE_R4K_D|CACHEOP_R4K_HIT_INV);
    243 		va += CACHELINESIZE;
    244 	}
    245 }
    246 
    247 void
    248 pdcache_wb(uint32_t va, u_int size)
    249 {
    250 	uint32_t eva;
    251 
    252 	eva = round_line(va + size);
    253 	va  = trunc_line(va);
    254 
    255 	while (va < eva) {
    256 		cache_op_r4k_line(va, CACHE_R4K_D|CACHEOP_R4K_HIT_WB);
    257 		va += CACHELINESIZE;
    258 	}
    259 }
    260 
    261 void
    262 pdcache_wbinv(uint32_t va, u_int size)
    263 {
    264 	uint32_t eva;
    265 
    266 	eva = round_line(va + size);
    267 	va  = trunc_line(va);
    268 
    269 	while (va < eva) {
    270 		cache_op_r4k_line(va, CACHE_R4K_D|CACHEOP_R4K_HIT_WB_INV);
    271 		va += CACHELINESIZE;
    272 	}
    273 }
    274