summaryrefslogtreecommitdiff
path: root/sys/arch/mips/include/cache_r5900.h
blob: f2e334c463fc054770b944ff0c30cd65b2cc2e05 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/*	$NetBSD: cache_r5900.h,v 1.10 2020/07/26 08:08:41 simonb Exp $	*/

/*-
 * Copyright (c) 2001 The NetBSD Foundation, Inc.
 * All rights reserved.
 *
 * This code is derived from software contributed to The NetBSD Foundation
 * by UCHIYAMA Yasushi.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#define	CACHE_R5900_SIZE_I		16384
#define	CACHE_R5900_SIZE_D		8192

#define	CACHE_R5900_LSIZE_I		64
#define	CACHE_R5900_LSIZE_D		64

#define	CACHEOP_R5900_IINV_I		0x07	/* INDEX INVALIDATE */
#define	CACHEOP_R5900_HINV_I		0x0b	/* HIT INVALIDATE */
#define	CACHEOP_R5900_IWBINV_D		0x14
					/* INDEX WRITE BACK INVALIDATE */
#define	CACHEOP_R5900_ILTG_D		0x10	/* INDEX LOAD TAG */
#define	CACHEOP_R5900_ISTG_D		0x12	/* INDEX STORE TAG */
#define	CACHEOP_R5900_IINV_D		0x16	/* INDEX INVALIDATE */
#define	CACHEOP_R5900_HINV_D		0x1a	/* HIT INVALIDATE */
#define	CACHEOP_R5900_HWBINV_D		0x18	/* HIT WRITEBACK INVALIDATE */
#define	CACHEOP_R5900_ILDT_D		0x11	/* INDEX LOAD DATA */
#define	CACHEOP_R5900_ISDT_D		0x13	/* INDEX STORE DATA */
#define	CACHEOP_R5900_HWB_D		0x1c
					/* HIT WRITEBACK W/O INVALIDATE */

#if !defined(_LOCORE)

#define	cache_op_r5900_line_64(va, op)					\
do {									\
	__asm volatile(						\
		".set noreorder					\n\t"	\
		"sync.l						\n\t"	\
		"sync.p						\n\t"	\
		"cache %1, 0(%0)				\n\t"	\
		"sync.l						\n\t"	\
		"sync.p						\n\t"	\
		".set reorder"						\
	    :								\
	    : "r" (va), "i" (op)					\
	    : "memory");						\
} while (/*CONSTCOND*/0)

#define	cache_r5900_op_4lines_64(va, op)				\
do {									\
	__asm volatile(						\
		".set noreorder					\n\t"	\
		"sync.l						\n\t"	\
		"sync.p						\n\t"	\
		"cache %1,   0(%0)				\n\t"	\
		"sync.l						\n\t"	\
		"sync.p						\n\t"	\
		"cache %1,  64(%0)				\n\t"	\
		"sync.l						\n\t"	\
		"sync.p						\n\t"	\
		"cache %1, 128(%0)				\n\t"	\
		"sync.l						\n\t"	\
		"sync.p						\n\t"	\
		"cache %1, 192(%0)				\n\t"	\
		"sync.l						\n\t"	\
		"sync.p						\n\t"	\
		".set reorder"						\
	    :								\
	    : "r" (va), "i" (op)					\
	    : "memory");						\
} while (/*CONSTCOND*/0)

#define	cache_r5900_op_4lines_64_2way(va, op)				\
do {									\
	__asm volatile(						\
		".set noreorder					\n\t"	\
		"sync.l						\n\t"	\
		"sync.p						\n\t"	\
		"cache %1,   0(%0)				\n\t"	\
		"sync.l						\n\t"	\
		"sync.p						\n\t"	\
		"cache %1,   1(%0)				\n\t"	\
		"sync.l						\n\t"	\
		"sync.p						\n\t"	\
		"cache %1,  64(%0)				\n\t"	\
		"sync.l						\n\t"	\
		"sync.p						\n\t"	\
		"cache %1,  65(%0)				\n\t"	\
		"sync.l						\n\t"	\
		"sync.p						\n\t"	\
		"cache %1, 128(%0)				\n\t"	\
		"sync.l						\n\t"	\
		"sync.p						\n\t"	\
		"cache %1, 129(%0)				\n\t"	\
		"sync.l						\n\t"	\
		"sync.p						\n\t"	\
		"cache %1, 192(%0)				\n\t"	\
		"sync.l						\n\t"	\
		"sync.p						\n\t"	\
		"cache %1, 193(%0)				\n\t"	\
		"sync.l						\n\t"	\
		"sync.p						\n\t"	\
		".set reorder"						\
	    :								\
	    : "r" (va), "i" (op)					\
	    : "memory");						\
} while (/*CONSTCOND*/0)

void	r5900_icache_sync_all_64(void);
void	r5900_icache_sync_range_64(register_t, vsize_t);
void	r5900_icache_sync_range_index_64(vaddr_t, vsize_t);

void	r5900_pdcache_wbinv_all_64(void);
void	r5900_pdcache_wbinv_range_64(register_t, vsize_t);
void	r5900_pdcache_wbinv_range_index_64(vaddr_t, vsize_t);

void	r5900_pdcache_inv_range_64(register_t, vsize_t);
void	r5900_pdcache_wb_range_64(register_t, vsize_t);

#endif /* !_LOCORE */