xref: /netbsd-src/sys/arch/m68k/m68k/mmu_subr.s (revision 219483d9ac8b4beb5e84ee761625f29ac41f0242)
1/*	$NetBSD: mmu_subr.s,v 1.2 2024/01/09 07:28:26 thorpej Exp $	*/
2
3/*-
4 * Copyright (c) 2023 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 *    notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 *    notice, this list of conditions and the following disclaimer in the
17 *    documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32/*
33 * Copyright (c) 1980, 1990, 1993
34 *      The Regents of the University of California.  All rights reserved.
35 *
36 * This code is derived from software contributed to Berkeley by
37 * the Systems Programming Group of the University of Utah Computer
38 * Science Department.
39 *
40 * Redistribution and use in source and binary forms, with or without
41 * modification, are permitted provided that the following conditions
42 * are met:
43 * 1. Redistributions of source code must retain the above copyright
44 *    notice, this list of conditions and the following disclaimer.
45 * 2. Redistributions in binary form must reproduce the above copyright
46 *    notice, this list of conditions and the following disclaimer in the
47 *    documentation and/or other materials provided with the distribution.
48 * 3. Neither the name of the University nor the names of its contributors
49 *    may be used to endorse or promote products derived from this software
50 *    without specific prior written permission.
51 *
52 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
53 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
54 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
55 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
56 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
57 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
58 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
59 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
60 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
61 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
62 * SUCH DAMAGE.
63 *
64 * from: Utah $Hdr: locore.s 1.66 92/12/22$
65 *
66 *	@(#)locore.s	8.6 (Berkeley) 5/27/94
67 */
68
69/*
70 * void mmu_load_urp(paddr_t urp);
71 *
72 *	Load the user root pointer into the MMU.  A version is provided
73 *	for each supported MMU type.
74 *
75 *	We keep the HP MMU versions of these routines here, as well,
76 *	even though they'll only ever be used on the hp300.
77 */
78
79#include "opt_m68k_arch.h"
80
81#include <machine/asm.h>
82
83#include "assym.h"
84
85	.file	"mmu_subr.s"
86	.text
87
88#if defined(M68K_MMU_MOTOROLA)
89#if defined(M68020) || defined(M68030)
90	.data
91/*
92 * protorp is set up to initialize the Supervisor Root Pointer.
93 * pmap_init() will re-configure it to load the CPU Root Pointer.
94 */
95GLOBAL(protorp)
96	.long	MMU51_SRP_BITS,0	| prototype CPU root pointer
97
98	.text
99ENTRY_NOPROFILE(mmu_load_urp51)
100	movl	%sp@(4),%d0		| get root table PA argument
101	lea	_C_LABEL(protorp),%a0	| CRP prototype
102	movl	%d0,%a0@(4)		| set new root table PA
103	pflusha				| flush ATC
104	pmove	%a0@,%crp		| load CRP register
105	movl	#CACHE_CLR,%d0
106	movc	%d0,%cacr		| invalidate caches
107	rts
108#endif /* M68020 || M68030 */
109
110#if defined(M68040) || defined(M68060)
111#if defined(M68060)
112ENTRY_NOPROFILE(mmu_load_urp60)
113	movc	%cacr,%d0
114	orl	#IC60_CUBC,%d0		| clear user branch cache entries
115	movc	%d0,%cacr
116	/* FALLTHROUGH */
117#endif /* M68060 */
118ENTRY_NOPROFILE(mmu_load_urp40)
119	movl	%sp@(4),%d0		| get root table PA argument
120	.word 0xf518	 |pflusha	| flush ATC
121	.long 0x4e7b0806 |movc %d0,%urp	| load the URP register
122	rts
123#endif /* M68040 || M68060 */
124#endif /* M68K_MMU_MOTOROLA */
125
126#if defined(M68K_MMU_HP)
127ENTRY_NOPROFILE(mmu_load_urp20hp)
128	movl	#CACHE_CLR,%d0
129	movc	%d0,%cacr		| invalidate caches
130	movl	_C_LABEL(MMUbase),%a0
131	movl	%a0@(MMUTBINVAL),%d1	| invalidate TLB
132	tstl	_C_LABEL(ectype)	| have an external VAC?
133	jle	1f			| no, skip
134	andl	#~MMU_CEN,%a0@(MMUCMD)	| toggle cache enable
135	orl	#MMU_CEN,%a0@(MMUCMD)	| to clear data cache
1361:	movl	%sp@(4),%d0		| get root table PA argument
137	moveq	#PGSHIFT,%d1
138	lsrl	%d1,%d0			| convert to page frame number
139	movl	%d0,%a0@(MMUUSTP)	| load to USTP register
140	rts
141#endif /* M68K_MMU_HP */
142