xref: /netbsd-src/sys/arch/hp300/include/cacheops_machdep.h (revision 91a4cc8a7c26f30e8b1dcbe87a804159028de40d)
1 /*	$NetBSD: cacheops_machdep.h,v 1.8 2023/12/27 17:35:34 thorpej Exp $	*/
2 
3 /*
4  * Copyright (c) 1980, 1990, 1993
5  *	The Regents of the University of California.  All rights reserved.
6  *
7  * This code is derived from software contributed to Berkeley by
8  * the Systems Programming Group of the University of Utah Computer
9  * Science Department.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions and the following disclaimer.
16  * 2. Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the
18  *    documentation and/or other materials provided with the distribution.
19  * 3. Neither the name of the University nor the names of its contributors
20  *    may be used to endorse or promote products derived from this software
21  *    without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  */
35 
36 /*
37  * Copyright (c) 1994, 1995 Gordon W. Ross
38  * Copyright (c) 1988 University of Utah.
39  *
40  * This code is derived from software contributed to Berkeley by
41  * the Systems Programming Group of the University of Utah Computer
42  * Science Department.
43  *
44  * Redistribution and use in source and binary forms, with or without
45  * modification, are permitted provided that the following conditions
46  * are met:
47  * 1. Redistributions of source code must retain the above copyright
48  *    notice, this list of conditions and the following disclaimer.
49  * 2. Redistributions in binary form must reproduce the above copyright
50  *    notice, this list of conditions and the following disclaimer in the
51  *    documentation and/or other materials provided with the distribution.
52  * 3. All advertising materials mentioning features or use of this software
53  *    must display the following acknowledgement:
54  *	This product includes software developed by the University of
55  *	California, Berkeley and its contributors.
56  * 4. Neither the name of the University nor the names of its contributors
57  *    may be used to endorse or promote products derived from this software
58  *    without specific prior written permission.
59  *
60  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
61  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
62  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
63  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
64  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
65  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
66  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
68  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
69  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
70  * SUCH DAMAGE.
71  */
72 
73 #ifndef _HP300_CACHEOPS_MACHDEP_H_
74 #define	_HP300_CACHEOPS_MACHDEP_H_
75 
76 #include <machine/fcode.h>
77 
78 extern vaddr_t MMUbase;
79 
80 static __inline int __attribute__((__unused__))
DCIA_md(void)81 DCIA_md(void)
82 {
83 	volatile int *ip = (void *)(MMUbase + MMUCMD);
84 
85 	if (ectype != EC_VIRT) {
86 		return 0;
87 	}
88 
89 	*ip &= ~MMU_CEN;
90 	*ip |= MMU_CEN;
91 	return 1;
92 }
93 
94 static __inline int __attribute__((__unused__))
DCIS_md(void)95 DCIS_md(void)
96 {
97 	volatile int *ip = (void *)(MMUbase + MMUSSTP);
98 
99 	if (ectype != EC_VIRT) {
100 		return 0;
101 	}
102 
103 	*ip = *ip;
104 	return 1;
105 }
106 
107 static __inline int __attribute__((__unused__))
DCIU_md(void)108 DCIU_md(void)
109 {
110 	volatile int *ip = (void *)(MMUbase + MMUUSTP);
111 
112 	if (ectype != EC_VIRT) {
113 		return 0;
114 	}
115 
116 	*ip = *ip;
117 	return 1;
118 }
119 
120 static __inline int __attribute__((__unused__))
PCIA_md(void)121 PCIA_md(void)
122 {
123 	volatile int *ip = (void *)(MMUbase + MMUCMD);
124 
125 	if (ectype != EC_PHYS || cputype != CPU_68030) {
126 		return 0;
127 	}
128 
129 	*ip &= ~MMU_CEN;
130 	*ip |= MMU_CEN;
131 
132 	/*
133 	 * only some '030 models (345/370/375/400) have external PAC,
134 	 * so we need to do the standard flushing as well.
135 	 */
136 
137 	return 0;
138 }
139 
140 static __inline int __attribute__((__unused__))
TBIA_md(void)141 TBIA_md(void)
142 {
143 	volatile int *ip = (void *)(MMUbase + MMUTBINVAL);
144 
145 	if (mmutype != MMU_HP) {
146 		return 0;
147 	}
148 
149 	(void) *ip;
150 	return 1;
151 }
152 
153 static __inline int __attribute__((__unused__))
TBIS_md(vaddr_t va)154 TBIS_md(vaddr_t va)
155 {
156 	register vaddr_t r_va __asm("%a1") = va;
157 	int s;
158 
159 	if (mmutype != MMU_HP) {
160 		return 0;
161 	}
162 
163 	s = splhigh();
164 	__asm volatile (" movc   %0, %%dfc;"	/* select purge space */
165 			  " movsl  %3, %1@;"	/* purge it */
166 			  " movc   %2, %%dfc;"
167 			  : : "r" (FC_PURGE), "a" (r_va), "r" (FC_USERD),
168 			  "r" (0));
169 	splx(s);
170 	return 1;
171 }
172 
173 static __inline int __attribute__((__unused__))
TBIAS_md(void)174 TBIAS_md(void)
175 {
176 	volatile int *ip = (void *)(MMUbase + MMUTBINVAL);
177 
178 	if (mmutype != MMU_HP) {
179 		return 0;
180 	}
181 
182 	*ip = 0x8000;
183 	return 1;
184 }
185 
186 static __inline int __attribute__((__unused__))
TBIAU_md(void)187 TBIAU_md(void)
188 {
189 	volatile int *ip = (void *)(MMUbase + MMUTBINVAL);
190 
191 	if (mmutype != MMU_HP) {
192 		return 0;
193 	}
194 
195 	*ip = 0;
196 	return 1;
197 }
198 #endif /* _HP300_CACHEOPS_MACHDEP_H_ */
199