cache_r4k.c revision 1.14 1 1.14 matt /* $NetBSD: cache_r4k.c,v 1.14 2016/07/11 23:06:54 matt Exp $ */
2 1.2 thorpej
3 1.2 thorpej /*
4 1.2 thorpej * Copyright 2001 Wasabi Systems, Inc.
5 1.2 thorpej * All rights reserved.
6 1.2 thorpej *
7 1.2 thorpej * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8 1.2 thorpej *
9 1.2 thorpej * Redistribution and use in source and binary forms, with or without
10 1.2 thorpej * modification, are permitted provided that the following conditions
11 1.2 thorpej * are met:
12 1.2 thorpej * 1. Redistributions of source code must retain the above copyright
13 1.2 thorpej * notice, this list of conditions and the following disclaimer.
14 1.2 thorpej * 2. Redistributions in binary form must reproduce the above copyright
15 1.2 thorpej * notice, this list of conditions and the following disclaimer in the
16 1.2 thorpej * documentation and/or other materials provided with the distribution.
17 1.2 thorpej * 3. All advertising materials mentioning features or use of this software
18 1.2 thorpej * must display the following acknowledgement:
19 1.2 thorpej * This product includes software developed for the NetBSD Project by
20 1.2 thorpej * Wasabi Systems, Inc.
21 1.2 thorpej * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 1.2 thorpej * or promote products derived from this software without specific prior
23 1.2 thorpej * written permission.
24 1.2 thorpej *
25 1.2 thorpej * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 1.2 thorpej * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 1.2 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 1.2 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 1.2 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 1.2 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 1.2 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 1.2 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 1.2 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 1.2 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 1.2 thorpej * POSSIBILITY OF SUCH DAMAGE.
36 1.2 thorpej */
37 1.8 lukem
38 1.8 lukem #include <sys/cdefs.h>
39 1.14 matt __KERNEL_RCSID(0, "$NetBSD: cache_r4k.c,v 1.14 2016/07/11 23:06:54 matt Exp $");
40 1.2 thorpej
41 1.2 thorpej #include <sys/param.h>
42 1.2 thorpej
43 1.12 macallan #include <mips/cpuregs.h>
44 1.2 thorpej #include <mips/cache.h>
45 1.2 thorpej #include <mips/cache_r4k.h>
46 1.2 thorpej
47 1.2 thorpej /*
48 1.2 thorpej * Cache operations for R4000/R4400-style caches:
49 1.2 thorpej *
50 1.2 thorpej * - Direct-mapped
51 1.2 thorpej * - Write-back
52 1.2 thorpej * - Virtually indexed, physically tagged
53 1.2 thorpej *
54 1.2 thorpej * XXX Does not handle split secondary caches.
55 1.2 thorpej */
56 1.2 thorpej
57 1.6 tsutsui void
58 1.14 matt r4k_icache_sync_all_generic(void)
59 1.6 tsutsui {
60 1.6 tsutsui mips_dcache_wbinv_all();
61 1.6 tsutsui
62 1.14 matt mips_intern_icache_sync_range_index(MIPS_PHYS_TO_KSEG0(0),
63 1.14 matt mips_cache_info.mci_picache_size);
64 1.6 tsutsui }
65 1.6 tsutsui
66 1.6 tsutsui void
67 1.14 matt r4k_icache_sync_range_generic(register_t va, vsize_t size)
68 1.6 tsutsui {
69 1.14 matt mips_dcache_wb_range(va, size);
70 1.6 tsutsui
71 1.14 matt mips_intern_icache_sync_range_index(va, size);
72 1.6 tsutsui }
73 1.6 tsutsui
74 1.6 tsutsui void
75 1.14 matt r4k_icache_sync_range_index_generic(vaddr_t va, vsize_t size)
76 1.6 tsutsui {
77 1.14 matt mips_dcache_wbinv_range_index(va, size);
78 1.6 tsutsui
79 1.6 tsutsui /*
80 1.6 tsutsui * Since we're doing Index ops, we expect to not be able
81 1.6 tsutsui * to access the address we've been given. So, get the
82 1.6 tsutsui * bits that determine the cache index, and make a KSEG0
83 1.6 tsutsui * address out of them.
84 1.6 tsutsui */
85 1.11 matt va = MIPS_PHYS_TO_KSEG0(va & mips_cache_info.mci_picache_way_mask);
86 1.14 matt size &= mips_cache_info.mci_picache_way_mask;
87 1.6 tsutsui
88 1.14 matt mips_intern_icache_sync_range_index(va, size);
89 1.3 thorpej }
90 1.3 thorpej
91 1.3 thorpej void
92 1.14 matt r4k_pdcache_wbinv_all_generic(void)
93 1.3 thorpej {
94 1.14 matt mips_intern_pdcache_wbinv_range_index(MIPS_PHYS_TO_KSEG0(0),
95 1.14 matt mips_cache_info.mci_pdcache_size);
96 1.2 thorpej }
97 1.2 thorpej
98 1.2 thorpej void
99 1.2 thorpej r4k_sdcache_wbinv_all_generic(void)
100 1.2 thorpej {
101 1.14 matt mips_intern_sdcache_wbinv_range_index(MIPS_PHYS_TO_KSEG0(0),
102 1.14 matt mips_cache_info.mci_sdcache_size);
103 1.2 thorpej }
104