xref: /netbsd-src/sys/arch/hp300/include/cacheops_machdep.h (revision 91a4cc8a7c26f30e8b1dcbe87a804159028de40d)
1*91a4cc8aSthorpej /*	$NetBSD: cacheops_machdep.h,v 1.8 2023/12/27 17:35:34 thorpej Exp $	*/
2aad01611Sagc 
3aad01611Sagc /*
4aad01611Sagc  * Copyright (c) 1980, 1990, 1993
5aad01611Sagc  *	The Regents of the University of California.  All rights reserved.
6aad01611Sagc  *
7aad01611Sagc  * This code is derived from software contributed to Berkeley by
8aad01611Sagc  * the Systems Programming Group of the University of Utah Computer
9aad01611Sagc  * Science Department.
10aad01611Sagc  *
11aad01611Sagc  * Redistribution and use in source and binary forms, with or without
12aad01611Sagc  * modification, are permitted provided that the following conditions
13aad01611Sagc  * are met:
14aad01611Sagc  * 1. Redistributions of source code must retain the above copyright
15aad01611Sagc  *    notice, this list of conditions and the following disclaimer.
16aad01611Sagc  * 2. Redistributions in binary form must reproduce the above copyright
17aad01611Sagc  *    notice, this list of conditions and the following disclaimer in the
18aad01611Sagc  *    documentation and/or other materials provided with the distribution.
19aad01611Sagc  * 3. Neither the name of the University nor the names of its contributors
20aad01611Sagc  *    may be used to endorse or promote products derived from this software
21aad01611Sagc  *    without specific prior written permission.
22aad01611Sagc  *
23aad01611Sagc  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24aad01611Sagc  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25aad01611Sagc  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26aad01611Sagc  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27aad01611Sagc  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28aad01611Sagc  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29aad01611Sagc  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30aad01611Sagc  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31aad01611Sagc  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32aad01611Sagc  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33aad01611Sagc  * SUCH DAMAGE.
34aad01611Sagc  */
3540e5b839Schs 
3640e5b839Schs /*
3740e5b839Schs  * Copyright (c) 1994, 1995 Gordon W. Ross
3840e5b839Schs  * Copyright (c) 1988 University of Utah.
3940e5b839Schs  *
4040e5b839Schs  * This code is derived from software contributed to Berkeley by
4140e5b839Schs  * the Systems Programming Group of the University of Utah Computer
4240e5b839Schs  * Science Department.
4340e5b839Schs  *
4440e5b839Schs  * Redistribution and use in source and binary forms, with or without
4540e5b839Schs  * modification, are permitted provided that the following conditions
4640e5b839Schs  * are met:
4740e5b839Schs  * 1. Redistributions of source code must retain the above copyright
4840e5b839Schs  *    notice, this list of conditions and the following disclaimer.
4940e5b839Schs  * 2. Redistributions in binary form must reproduce the above copyright
5040e5b839Schs  *    notice, this list of conditions and the following disclaimer in the
5140e5b839Schs  *    documentation and/or other materials provided with the distribution.
5240e5b839Schs  * 3. All advertising materials mentioning features or use of this software
5340e5b839Schs  *    must display the following acknowledgement:
5440e5b839Schs  *	This product includes software developed by the University of
5540e5b839Schs  *	California, Berkeley and its contributors.
5640e5b839Schs  * 4. Neither the name of the University nor the names of its contributors
5740e5b839Schs  *    may be used to endorse or promote products derived from this software
5840e5b839Schs  *    without specific prior written permission.
5940e5b839Schs  *
6040e5b839Schs  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
6140e5b839Schs  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
6240e5b839Schs  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
6340e5b839Schs  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
6440e5b839Schs  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
6540e5b839Schs  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
6640e5b839Schs  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
6740e5b839Schs  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
6840e5b839Schs  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
6940e5b839Schs  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
7040e5b839Schs  * SUCH DAMAGE.
7140e5b839Schs  */
7240e5b839Schs 
7340e5b839Schs #ifndef _HP300_CACHEOPS_MACHDEP_H_
7440e5b839Schs #define	_HP300_CACHEOPS_MACHDEP_H_
7540e5b839Schs 
76*91a4cc8aSthorpej #include <machine/fcode.h>
77*91a4cc8aSthorpej 
7840e5b839Schs extern vaddr_t MMUbase;
7940e5b839Schs 
80fbae48b9Sperry static __inline int __attribute__((__unused__))
DCIA_md(void)8140e5b839Schs DCIA_md(void)
8240e5b839Schs {
8340e5b839Schs 	volatile int *ip = (void *)(MMUbase + MMUCMD);
8440e5b839Schs 
8540e5b839Schs 	if (ectype != EC_VIRT) {
8640e5b839Schs 		return 0;
8740e5b839Schs 	}
8840e5b839Schs 
8940e5b839Schs 	*ip &= ~MMU_CEN;
9040e5b839Schs 	*ip |= MMU_CEN;
9140e5b839Schs 	return 1;
9240e5b839Schs }
9340e5b839Schs 
94fbae48b9Sperry static __inline int __attribute__((__unused__))
DCIS_md(void)9540e5b839Schs DCIS_md(void)
9640e5b839Schs {
9740e5b839Schs 	volatile int *ip = (void *)(MMUbase + MMUSSTP);
9840e5b839Schs 
9940e5b839Schs 	if (ectype != EC_VIRT) {
10040e5b839Schs 		return 0;
10140e5b839Schs 	}
10240e5b839Schs 
10340e5b839Schs 	*ip = *ip;
10440e5b839Schs 	return 1;
10540e5b839Schs }
10640e5b839Schs 
107fbae48b9Sperry static __inline int __attribute__((__unused__))
DCIU_md(void)10840e5b839Schs DCIU_md(void)
10940e5b839Schs {
11040e5b839Schs 	volatile int *ip = (void *)(MMUbase + MMUUSTP);
11140e5b839Schs 
11240e5b839Schs 	if (ectype != EC_VIRT) {
11340e5b839Schs 		return 0;
11440e5b839Schs 	}
11540e5b839Schs 
11640e5b839Schs 	*ip = *ip;
11740e5b839Schs 	return 1;
11840e5b839Schs }
11940e5b839Schs 
120fbae48b9Sperry static __inline int __attribute__((__unused__))
PCIA_md(void)12140e5b839Schs PCIA_md(void)
12240e5b839Schs {
12340e5b839Schs 	volatile int *ip = (void *)(MMUbase + MMUCMD);
12440e5b839Schs 
12540e5b839Schs 	if (ectype != EC_PHYS || cputype != CPU_68030) {
12640e5b839Schs 		return 0;
12740e5b839Schs 	}
12840e5b839Schs 
12940e5b839Schs 	*ip &= ~MMU_CEN;
13040e5b839Schs 	*ip |= MMU_CEN;
13140e5b839Schs 
13240e5b839Schs 	/*
13340e5b839Schs 	 * only some '030 models (345/370/375/400) have external PAC,
13440e5b839Schs 	 * so we need to do the standard flushing as well.
13540e5b839Schs 	 */
13640e5b839Schs 
13740e5b839Schs 	return 0;
13840e5b839Schs }
13940e5b839Schs 
140fbae48b9Sperry static __inline int __attribute__((__unused__))
TBIA_md(void)14140e5b839Schs TBIA_md(void)
14240e5b839Schs {
14340e5b839Schs 	volatile int *ip = (void *)(MMUbase + MMUTBINVAL);
14440e5b839Schs 
14540e5b839Schs 	if (mmutype != MMU_HP) {
14640e5b839Schs 		return 0;
14740e5b839Schs 	}
14840e5b839Schs 
14940e5b839Schs 	(void) *ip;
15040e5b839Schs 	return 1;
15140e5b839Schs }
15240e5b839Schs 
153fbae48b9Sperry static __inline int __attribute__((__unused__))
TBIS_md(vaddr_t va)15440e5b839Schs TBIS_md(vaddr_t va)
15540e5b839Schs {
1560dcee00dScl 	register vaddr_t r_va __asm("%a1") = va;
15740e5b839Schs 	int s;
15840e5b839Schs 
15940e5b839Schs 	if (mmutype != MMU_HP) {
16040e5b839Schs 		return 0;
16140e5b839Schs 	}
16240e5b839Schs 
16340e5b839Schs 	s = splhigh();
1645f1c88d7Sperry 	__asm volatile (" movc   %0, %%dfc;"	/* select purge space */
16540e5b839Schs 			  " movsl  %3, %1@;"	/* purge it */
16640e5b839Schs 			  " movc   %2, %%dfc;"
16740e5b839Schs 			  : : "r" (FC_PURGE), "a" (r_va), "r" (FC_USERD),
16840e5b839Schs 			  "r" (0));
16940e5b839Schs 	splx(s);
17040e5b839Schs 	return 1;
17140e5b839Schs }
17240e5b839Schs 
173fbae48b9Sperry static __inline int __attribute__((__unused__))
TBIAS_md(void)17440e5b839Schs TBIAS_md(void)
17540e5b839Schs {
17640e5b839Schs 	volatile int *ip = (void *)(MMUbase + MMUTBINVAL);
17740e5b839Schs 
17840e5b839Schs 	if (mmutype != MMU_HP) {
17940e5b839Schs 		return 0;
18040e5b839Schs 	}
18140e5b839Schs 
18240e5b839Schs 	*ip = 0x8000;
18340e5b839Schs 	return 1;
18440e5b839Schs }
18540e5b839Schs 
186fbae48b9Sperry static __inline int __attribute__((__unused__))
TBIAU_md(void)18740e5b839Schs TBIAU_md(void)
18840e5b839Schs {
18940e5b839Schs 	volatile int *ip = (void *)(MMUbase + MMUTBINVAL);
19040e5b839Schs 
19140e5b839Schs 	if (mmutype != MMU_HP) {
19240e5b839Schs 		return 0;
19340e5b839Schs 	}
19440e5b839Schs 
19540e5b839Schs 	*ip = 0;
19640e5b839Schs 	return 1;
19740e5b839Schs }
19840e5b839Schs #endif /* _HP300_CACHEOPS_MACHDEP_H_ */
199