Wed Sep 2 01:33:27 2020 UTC ()
Octeon CN70XX CPUs have a COP0 config5 register.
XXX: The presense of these are defined by the MIPS architecture, should probe.


(simonb)
diff -r1.299 -r1.300 src/sys/arch/mips/mips/mips_machdep.c

cvs diff -r1.299 -r1.300 src/sys/arch/mips/mips/mips_machdep.c (switch to unified diff)

--- src/sys/arch/mips/mips/mips_machdep.c 2020/08/17 03:22:13 1.299
+++ src/sys/arch/mips/mips/mips_machdep.c 2020/09/02 01:33:27 1.300
@@ -1,1677 +1,1677 @@ @@ -1,1677 +1,1677 @@
1/* $NetBSD: mips_machdep.c,v 1.299 2020/08/17 03:22:13 mrg Exp $ */ 1/* $NetBSD: mips_machdep.c,v 1.300 2020/09/02 01:33:27 simonb Exp $ */
2 2
3/* 3/*
4 * Copyright 2002 Wasabi Systems, Inc. 4 * Copyright 2002 Wasabi Systems, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Written by Simon Burge for Wasabi Systems, Inc. 7 * Written by Simon Burge for Wasabi Systems, Inc.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the 15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution. 16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software 17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement: 18 * must display the following acknowledgement:
19 * This product includes software developed for the NetBSD Project by 19 * This product includes software developed for the NetBSD Project by
20 * Wasabi Systems, Inc. 20 * Wasabi Systems, Inc.
21 * 4. The name of Wasabi Systems, Inc. may not be used to endorse 21 * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 * or promote products derived from this software without specific prior 22 * or promote products derived from this software without specific prior
23 * written permission. 23 * written permission.
24 * 24 *
25 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 25 * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE. 35 * POSSIBILITY OF SUCH DAMAGE.
36 */ 36 */
37 37
38/* 38/*
39 * Copyright 2000, 2001 39 * Copyright 2000, 2001
40 * Broadcom Corporation. All rights reserved. 40 * Broadcom Corporation. All rights reserved.
41 * 41 *
42 * This software is furnished under license and may be used and copied only 42 * This software is furnished under license and may be used and copied only
43 * in accordance with the following terms and conditions. Subject to these 43 * in accordance with the following terms and conditions. Subject to these
44 * conditions, you may download, copy, install, use, modify and distribute 44 * conditions, you may download, copy, install, use, modify and distribute
45 * modified or unmodified copies of this software in source and/or binary 45 * modified or unmodified copies of this software in source and/or binary
46 * form. No title or ownership is transferred hereby. 46 * form. No title or ownership is transferred hereby.
47 * 47 *
48 * 1) Any source code used, modified or distributed must reproduce and 48 * 1) Any source code used, modified or distributed must reproduce and
49 * retain this copyright notice and list of conditions as they appear in 49 * retain this copyright notice and list of conditions as they appear in
50 * the source file. 50 * the source file.
51 * 51 *
52 * 2) No right is granted to use any trade name, trademark, or logo of 52 * 2) No right is granted to use any trade name, trademark, or logo of
53 * Broadcom Corporation. The "Broadcom Corporation" name may not be 53 * Broadcom Corporation. The "Broadcom Corporation" name may not be
54 * used to endorse or promote products derived from this software 54 * used to endorse or promote products derived from this software
55 * without the prior written permission of Broadcom Corporation. 55 * without the prior written permission of Broadcom Corporation.
56 * 56 *
57 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED 57 * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
58 * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF 58 * WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
59 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR 59 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
60 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE 60 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
61 * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE 61 * FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
62 * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 62 * LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
63 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 63 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
64 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 64 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
65 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 65 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
66 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 66 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
67 * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 67 * OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
68 */ 68 */
69 69
70/*- 70/*-
71 * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc. 71 * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
72 * All rights reserved. 72 * All rights reserved.
73 * 73 *
74 * This code is derived from software contributed to The NetBSD Foundation 74 * This code is derived from software contributed to The NetBSD Foundation
75 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, 75 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
76 * NASA Ames Research Center and by Chris Demetriou. 76 * NASA Ames Research Center and by Chris Demetriou.
77 * 77 *
78 * Redistribution and use in source and binary forms, with or without 78 * Redistribution and use in source and binary forms, with or without
79 * modification, are permitted provided that the following conditions 79 * modification, are permitted provided that the following conditions
80 * are met: 80 * are met:
81 * 1. Redistributions of source code must retain the above copyright 81 * 1. Redistributions of source code must retain the above copyright
82 * notice, this list of conditions and the following disclaimer. 82 * notice, this list of conditions and the following disclaimer.
83 * 2. Redistributions in binary form must reproduce the above copyright 83 * 2. Redistributions in binary form must reproduce the above copyright
84 * notice, this list of conditions and the following disclaimer in the 84 * notice, this list of conditions and the following disclaimer in the
85 * documentation and/or other materials provided with the distribution. 85 * documentation and/or other materials provided with the distribution.
86 * 86 *
87 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 87 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
88 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 88 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
89 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 89 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
90 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 90 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
91 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 91 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
92 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 92 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
93 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 93 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
94 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 94 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
95 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 95 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
96 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 96 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
97 * POSSIBILITY OF SUCH DAMAGE. 97 * POSSIBILITY OF SUCH DAMAGE.
98 */ 98 */
99 99
100/* 100/*
101 * Copyright 1996 The Board of Trustees of The Leland Stanford 101 * Copyright 1996 The Board of Trustees of The Leland Stanford
102 * Junior University. All Rights Reserved. 102 * Junior University. All Rights Reserved.
103 * 103 *
104 * Permission to use, copy, modify, and distribute this 104 * Permission to use, copy, modify, and distribute this
105 * software and its documentation for any purpose and without 105 * software and its documentation for any purpose and without
106 * fee is hereby granted, provided that the above copyright 106 * fee is hereby granted, provided that the above copyright
107 * notice appear in all copies. Stanford University 107 * notice appear in all copies. Stanford University
108 * makes no representations about the suitability of this 108 * makes no representations about the suitability of this
109 * software for any purpose. It is provided "as is" without 109 * software for any purpose. It is provided "as is" without
110 * express or implied warranty. 110 * express or implied warranty.
111 */ 111 */
112 112
113#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ 113#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
114__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.299 2020/08/17 03:22:13 mrg Exp $"); 114__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.300 2020/09/02 01:33:27 simonb Exp $");
115 115
116#define __INTR_PRIVATE 116#define __INTR_PRIVATE
117#include "opt_cputype.h" 117#include "opt_cputype.h"
118#include "opt_compat_netbsd32.h" 118#include "opt_compat_netbsd32.h"
119#include "opt_multiprocessor.h" 119#include "opt_multiprocessor.h"
120 120
121#include <sys/param.h> 121#include <sys/param.h>
122#include <sys/systm.h> 122#include <sys/systm.h>
123#include <sys/proc.h> 123#include <sys/proc.h>
124#include <sys/intr.h> 124#include <sys/intr.h>
125#include <sys/exec.h> 125#include <sys/exec.h>
126#include <sys/reboot.h> 126#include <sys/reboot.h>
127#include <sys/mount.h> /* fsid_t for syscallargs */ 127#include <sys/mount.h> /* fsid_t for syscallargs */
128#include <sys/lwp.h> 128#include <sys/lwp.h>
129#include <sys/sysctl.h> 129#include <sys/sysctl.h>
130#include <sys/msgbuf.h> 130#include <sys/msgbuf.h>
131#include <sys/conf.h> 131#include <sys/conf.h>
132#include <sys/core.h> 132#include <sys/core.h>
133#include <sys/device.h> 133#include <sys/device.h>
134#include <sys/kcore.h> 134#include <sys/kcore.h>
135#include <sys/kmem.h> 135#include <sys/kmem.h>
136#include <sys/ras.h> 136#include <sys/ras.h>
137#include <sys/cpu.h> 137#include <sys/cpu.h>
138#include <sys/atomic.h> 138#include <sys/atomic.h>
139#include <sys/ucontext.h> 139#include <sys/ucontext.h>
140#include <sys/bitops.h> 140#include <sys/bitops.h>
141 141
142#include <mips/kcore.h> 142#include <mips/kcore.h>
143 143
144#ifdef COMPAT_NETBSD32 144#ifdef COMPAT_NETBSD32
145#include <compat/netbsd32/netbsd32.h> 145#include <compat/netbsd32/netbsd32.h>
146#endif 146#endif
147 147
148#include <uvm/uvm.h> 148#include <uvm/uvm.h>
149#include <uvm/uvm_physseg.h> 149#include <uvm/uvm_physseg.h>
150 150
151#include <dev/cons.h> 151#include <dev/cons.h>
152#include <dev/mm.h> 152#include <dev/mm.h>
153 153
154#include <mips/pcb.h> 154#include <mips/pcb.h>
155#include <mips/cache.h> 155#include <mips/cache.h>
156#include <mips/frame.h> 156#include <mips/frame.h>
157#include <mips/regnum.h> 157#include <mips/regnum.h>
158#include <mips/mips_opcode.h> 158#include <mips/mips_opcode.h>
159 159
160#include <mips/cpu.h> 160#include <mips/cpu.h>
161#include <mips/locore.h> 161#include <mips/locore.h>
162#include <mips/psl.h> 162#include <mips/psl.h>
163#include <mips/pte.h> 163#include <mips/pte.h>
164#include <mips/userret.h> 164#include <mips/userret.h>
165 165
166#ifdef __HAVE_BOOTINFO_H 166#ifdef __HAVE_BOOTINFO_H
167#include <machine/bootinfo.h> 167#include <machine/bootinfo.h>
168#endif 168#endif
169 169
170#ifdef MIPS64_OCTEON 170#ifdef MIPS64_OCTEON
171#include <mips/cavium/octeonvar.h> 171#include <mips/cavium/octeonvar.h>
172#endif 172#endif
173 173
174#if (MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0 174#if (MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0
175#include <mips/mipsNN.h> /* MIPS32/MIPS64 registers */ 175#include <mips/mipsNN.h> /* MIPS32/MIPS64 registers */
176 176
177#define _MKINSN(a,b,c,d,e) ((uint32_t)(((a) << 26)|((b) << 21)|((c) << 16)|((d) << 11)|(e))) 177#define _MKINSN(a,b,c,d,e) ((uint32_t)(((a) << 26)|((b) << 21)|((c) << 16)|((d) << 11)|(e)))
178 178
179#ifdef _LP64 179#ifdef _LP64
180#define _LOAD_V0_L_PRIVATE_A0 _MKINSN(OP_LD, _R_A0, _R_V0, 0, offsetof(lwp_t, l_private)) 180#define _LOAD_V0_L_PRIVATE_A0 _MKINSN(OP_LD, _R_A0, _R_V0, 0, offsetof(lwp_t, l_private))
181#define _MTC0_V0_USERLOCAL _MKINSN(OP_COP0, OP_DMT, _R_V0, MIPS_COP_0_TLB_CONTEXT, 2) 181#define _MTC0_V0_USERLOCAL _MKINSN(OP_COP0, OP_DMT, _R_V0, MIPS_COP_0_TLB_CONTEXT, 2)
182#else 182#else
183#define _LOAD_V0_L_PRIVATE_A0 _MKINSN(OP_LW, _R_A0, _R_V0, 0, offsetof(lwp_t, l_private)) 183#define _LOAD_V0_L_PRIVATE_A0 _MKINSN(OP_LW, _R_A0, _R_V0, 0, offsetof(lwp_t, l_private))
184#define _MTC0_V0_USERLOCAL _MKINSN(OP_COP0, OP_MT, _R_V0, MIPS_COP_0_TLB_CONTEXT, 2) 184#define _MTC0_V0_USERLOCAL _MKINSN(OP_COP0, OP_MT, _R_V0, MIPS_COP_0_TLB_CONTEXT, 2)
185#endif 185#endif
186#define JR_RA _MKINSN(OP_SPECIAL, _R_RA, 0, 0, OP_JR) 186#define JR_RA _MKINSN(OP_SPECIAL, _R_RA, 0, 0, OP_JR)
187 187
188#endif 188#endif
189 189
190/* Internal routines. */ 190/* Internal routines. */
191int cpu_dumpsize(void); 191int cpu_dumpsize(void);
192u_long cpu_dump_mempagecnt(void); 192u_long cpu_dump_mempagecnt(void);
193int cpu_dump(void); 193int cpu_dump(void);
194 194
195#if (MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0 195#if (MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0
196static void mips_watchpoint_init(void); 196static void mips_watchpoint_init(void);
197#endif 197#endif
198 198
199#if defined(_LP64) && defined(ENABLE_MIPS_16KB_PAGE) 199#if defined(_LP64) && defined(ENABLE_MIPS_16KB_PAGE)
200vaddr_t mips_vm_maxuser_address = MIPS_VM_MAXUSER_ADDRESS; 200vaddr_t mips_vm_maxuser_address = MIPS_VM_MAXUSER_ADDRESS;
201#endif 201#endif
202 202
203#if defined(MIPS3_PLUS) 203#if defined(MIPS3_PLUS)
204uint32_t mips3_cp0_tlb_page_mask_probe(void); 204uint32_t mips3_cp0_tlb_page_mask_probe(void);
205uint64_t mips3_cp0_tlb_entry_hi_probe(void); 205uint64_t mips3_cp0_tlb_entry_hi_probe(void);
206uint64_t mips3_cp0_tlb_entry_lo_probe(void); 206uint64_t mips3_cp0_tlb_entry_lo_probe(void);
207 207
208static void mips3_tlb_probe(void); 208static void mips3_tlb_probe(void);
209#endif 209#endif
210 210
211#if defined(MIPS1) 211#if defined(MIPS1)
212static void mips1_vector_init(const struct splsw *); 212static void mips1_vector_init(const struct splsw *);
213extern const struct locoresw mips1_locoresw; 213extern const struct locoresw mips1_locoresw;
214extern const mips_locore_jumpvec_t mips1_locore_vec; 214extern const mips_locore_jumpvec_t mips1_locore_vec;
215#endif 215#endif
216 216
217#if defined(MIPS3) 217#if defined(MIPS3)
218static void mips3_vector_init(const struct splsw *); 218static void mips3_vector_init(const struct splsw *);
219extern const struct locoresw mips3_locoresw; 219extern const struct locoresw mips3_locoresw;
220extern const mips_locore_jumpvec_t mips3_locore_vec; 220extern const mips_locore_jumpvec_t mips3_locore_vec;
221#endif 221#endif
222 222
223#if defined(MIPS3_LOONGSON2) 223#if defined(MIPS3_LOONGSON2)
224static void loongson2_vector_init(const struct splsw *); 224static void loongson2_vector_init(const struct splsw *);
225extern const struct locoresw loongson2_locoresw; 225extern const struct locoresw loongson2_locoresw;
226extern const mips_locore_jumpvec_t loongson2_locore_vec; 226extern const mips_locore_jumpvec_t loongson2_locore_vec;
227#endif 227#endif
228 228
229#if defined(MIPS32) 229#if defined(MIPS32)
230static void mips32_vector_init(const struct splsw *); 230static void mips32_vector_init(const struct splsw *);
231extern const struct locoresw mips32_locoresw; 231extern const struct locoresw mips32_locoresw;
232extern const mips_locore_jumpvec_t mips32_locore_vec; 232extern const mips_locore_jumpvec_t mips32_locore_vec;
233#endif 233#endif
234 234
235#if defined(MIPS32R2) 235#if defined(MIPS32R2)
236static void mips32r2_vector_init(const struct splsw *); 236static void mips32r2_vector_init(const struct splsw *);
237extern const struct locoresw mips32r2_locoresw; 237extern const struct locoresw mips32r2_locoresw;
238extern const mips_locore_jumpvec_t mips32r2_locore_vec; 238extern const mips_locore_jumpvec_t mips32r2_locore_vec;
239#endif 239#endif
240 240
241#if defined(MIPS64) 241#if defined(MIPS64)
242static void mips64_vector_init(const struct splsw *); 242static void mips64_vector_init(const struct splsw *);
243extern const struct locoresw mips64_locoresw; 243extern const struct locoresw mips64_locoresw;
244extern const mips_locore_jumpvec_t mips64_locore_vec; 244extern const mips_locore_jumpvec_t mips64_locore_vec;
245#endif 245#endif
246 246
247#if defined(MIPS64R2) 247#if defined(MIPS64R2)
248extern const struct locoresw mips64r2_locoresw; 248extern const struct locoresw mips64r2_locoresw;
249extern const mips_locore_jumpvec_t mips64r2_locore_vec; 249extern const mips_locore_jumpvec_t mips64r2_locore_vec;
250#endif 250#endif
251 251
252#if defined(PARANOIA) 252#if defined(PARANOIA)
253void std_splsw_test(void); 253void std_splsw_test(void);
254#endif 254#endif
255 255
256mips_locore_jumpvec_t mips_locore_jumpvec; 256mips_locore_jumpvec_t mips_locore_jumpvec;
257 257
258struct locoresw mips_locoresw; 258struct locoresw mips_locoresw;
259 259
260extern const struct splsw std_splsw; 260extern const struct splsw std_splsw;
261struct splsw mips_splsw; 261struct splsw mips_splsw;
262 262
263struct mips_options mips_options = { 263struct mips_options mips_options = {
264 .mips_cpu_id = 0xffffffff, 264 .mips_cpu_id = 0xffffffff,
265 .mips_fpu_id = 0xffffffff, 265 .mips_fpu_id = 0xffffffff,
266}; 266};
267 267
268void * msgbufaddr; 268void * msgbufaddr;
269 269
270/* the following is used by DDB to reset the system */ 270/* the following is used by DDB to reset the system */
271void (*cpu_reset_address)(void); 271void (*cpu_reset_address)(void);
272 272
273/* the following is used externally (sysctl_hw) */ 273/* the following is used externally (sysctl_hw) */
274char machine[] = MACHINE; /* from <machine/param.h> */ 274char machine[] = MACHINE; /* from <machine/param.h> */
275char machine_arch[] = MACHINE_ARCH; /* from <machine/param.h> */ 275char machine_arch[] = MACHINE_ARCH; /* from <machine/param.h> */
276 276
277/* 277/*
278 * Assumptions: 278 * Assumptions:
279 * - All MIPS3+ have an r4k-style MMU. _Many_ assumptions throughout 279 * - All MIPS3+ have an r4k-style MMU. _Many_ assumptions throughout
280 * much of the mips code about this. Includes overloaded usage of 280 * much of the mips code about this. Includes overloaded usage of
281 * MIPS3_PLUS. 281 * MIPS3_PLUS.
282 * - All MIPS3+ use the same exception model (cp0 status, cause bits, 282 * - All MIPS3+ use the same exception model (cp0 status, cause bits,
283 * etc). _Many_ assumptions throughout much of the mips code about 283 * etc). _Many_ assumptions throughout much of the mips code about
284 * this. Includes overloaded usage of MIPS3_PLUS. 284 * this. Includes overloaded usage of MIPS3_PLUS.
285 * - All MIPS3+ have a count register. MIPS_HAS_CLOCK in <mips/cpu.h> 285 * - All MIPS3+ have a count register. MIPS_HAS_CLOCK in <mips/cpu.h>
286 * will need to be revised if this is false. 286 * will need to be revised if this is false.
287 */ 287 */
288#define MIPS32_FLAGS CPU_MIPS_R4K_MMU | CPU_MIPS_CAUSE_IV | CPU_MIPS_USE_WAIT 288#define MIPS32_FLAGS CPU_MIPS_R4K_MMU | CPU_MIPS_CAUSE_IV | CPU_MIPS_USE_WAIT
289#define MIPS64_FLAGS MIPS32_FLAGS /* same as MIPS32 flags (for now) */ 289#define MIPS64_FLAGS MIPS32_FLAGS /* same as MIPS32 flags (for now) */
290 290
291static const struct pridtab cputab[] = { 291static const struct pridtab cputab[] = {
292 { 0, MIPS_R2000, -1, -1, CPU_ARCH_MIPS1, 64, 292 { 0, MIPS_R2000, -1, -1, CPU_ARCH_MIPS1, 64,
293 CPU_MIPS_NO_LLSC, 0, 0, "MIPS R2000 CPU" }, 293 CPU_MIPS_NO_LLSC, 0, 0, "MIPS R2000 CPU" },
294 { 0, MIPS_R3000, MIPS_REV_R2000A, -1, CPU_ARCH_MIPS1, 64, 294 { 0, MIPS_R3000, MIPS_REV_R2000A, -1, CPU_ARCH_MIPS1, 64,
295 CPU_MIPS_NO_LLSC, 0, 0, "MIPS R2000A CPU" }, 295 CPU_MIPS_NO_LLSC, 0, 0, "MIPS R2000A CPU" },
296 { 0, MIPS_R3000, MIPS_REV_R3000, -1, CPU_ARCH_MIPS1, 64, 296 { 0, MIPS_R3000, MIPS_REV_R3000, -1, CPU_ARCH_MIPS1, 64,
297 CPU_MIPS_NO_LLSC, 0, 0, "MIPS R3000 CPU" }, 297 CPU_MIPS_NO_LLSC, 0, 0, "MIPS R3000 CPU" },
298 { 0, MIPS_R3000, MIPS_REV_R3000A, -1, CPU_ARCH_MIPS1, 64, 298 { 0, MIPS_R3000, MIPS_REV_R3000A, -1, CPU_ARCH_MIPS1, 64,
299 CPU_MIPS_NO_LLSC, 0, 0, "MIPS R3000A CPU" }, 299 CPU_MIPS_NO_LLSC, 0, 0, "MIPS R3000A CPU" },
300 { 0, MIPS_R6000, -1, -1, CPU_ARCH_MIPS2, 32, 300 { 0, MIPS_R6000, -1, -1, CPU_ARCH_MIPS2, 32,
301 MIPS_NOT_SUPP, 0, 0, "MIPS R6000 CPU" }, 301 MIPS_NOT_SUPP, 0, 0, "MIPS R6000 CPU" },
302 302
303 /* 303 /*
304 * rev 0x00, 0x22 and 0x30 are R4000, 0x40, 0x50 and 0x60 are R4400. 304 * rev 0x00, 0x22 and 0x30 are R4000, 0x40, 0x50 and 0x60 are R4400.
305 * should we allow ranges and use 0x00 - 0x3f for R4000 and 305 * should we allow ranges and use 0x00 - 0x3f for R4000 and
306 * 0x40 - 0xff for R4400? 306 * 0x40 - 0xff for R4400?
307 */ 307 */
308 { 0, MIPS_R4000, MIPS_REV_R4000_A, -1, CPU_ARCH_MIPS3, 48, 308 { 0, MIPS_R4000, MIPS_REV_R4000_A, -1, CPU_ARCH_MIPS3, 48,
309 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0, 309 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0,
310 "MIPS R4000 CPU" }, 310 "MIPS R4000 CPU" },
311 { 0, MIPS_R4000, MIPS_REV_R4000_B, -1, CPU_ARCH_MIPS3, 48, 311 { 0, MIPS_R4000, MIPS_REV_R4000_B, -1, CPU_ARCH_MIPS3, 48,
312 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0, 312 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0,
313 "MIPS R4000 CPU" }, 313 "MIPS R4000 CPU" },
314 { 0, MIPS_R4000, MIPS_REV_R4000_C, -1, CPU_ARCH_MIPS3, 48, 314 { 0, MIPS_R4000, MIPS_REV_R4000_C, -1, CPU_ARCH_MIPS3, 48,
315 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0, 315 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0,
316 "MIPS R4000 CPU" }, 316 "MIPS R4000 CPU" },
317 { 0, MIPS_R4000, MIPS_REV_R4400_A, -1, CPU_ARCH_MIPS3, 48, 317 { 0, MIPS_R4000, MIPS_REV_R4400_A, -1, CPU_ARCH_MIPS3, 48,
318 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0, 318 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0,
319 "MIPS R4400 CPU" }, 319 "MIPS R4400 CPU" },
320 { 0, MIPS_R4000, MIPS_REV_R4400_B, -1, CPU_ARCH_MIPS3, 48, 320 { 0, MIPS_R4000, MIPS_REV_R4400_B, -1, CPU_ARCH_MIPS3, 48,
321 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0, 321 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0,
322 "MIPS R4400 CPU" }, 322 "MIPS R4400 CPU" },
323 { 0, MIPS_R4000, MIPS_REV_R4400_C, -1, CPU_ARCH_MIPS3, 48, 323 { 0, MIPS_R4000, MIPS_REV_R4400_C, -1, CPU_ARCH_MIPS3, 48,
324 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0, 324 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0,
325 "MIPS R4400 CPU" }, 325 "MIPS R4400 CPU" },
326 326
327 { 0, MIPS_R3LSI, -1, -1, CPU_ARCH_MIPS1, -1, 327 { 0, MIPS_R3LSI, -1, -1, CPU_ARCH_MIPS1, -1,
328 MIPS_NOT_SUPP, 0, 0, "LSI Logic R3000 derivative" }, 328 MIPS_NOT_SUPP, 0, 0, "LSI Logic R3000 derivative" },
329 { 0, MIPS_R6000A, -1, -1, CPU_ARCH_MIPS2, 32, 329 { 0, MIPS_R6000A, -1, -1, CPU_ARCH_MIPS2, 32,
330 MIPS_NOT_SUPP, 0, 0, "MIPS R6000A CPU" }, 330 MIPS_NOT_SUPP, 0, 0, "MIPS R6000A CPU" },
331 { 0, MIPS_R3IDT, -1, -1, CPU_ARCH_MIPS1, -1, 331 { 0, MIPS_R3IDT, -1, -1, CPU_ARCH_MIPS1, -1,
332 MIPS_NOT_SUPP, 0, 0, "IDT R3041 or RC36100 CPU" }, 332 MIPS_NOT_SUPP, 0, 0, "IDT R3041 or RC36100 CPU" },
333 { 0, MIPS_R4100, -1, -1, CPU_ARCH_MIPS3, 32, 333 { 0, MIPS_R4100, -1, -1, CPU_ARCH_MIPS3, 32,
334 CPU_MIPS_R4K_MMU | CPU_MIPS_NO_LLSC, 0, 0, 334 CPU_MIPS_R4K_MMU | CPU_MIPS_NO_LLSC, 0, 0,
335 "NEC VR4100 CPU" }, 335 "NEC VR4100 CPU" },
336 { 0, MIPS_R4200, -1, -1, CPU_ARCH_MIPS3, -1, 336 { 0, MIPS_R4200, -1, -1, CPU_ARCH_MIPS3, -1,
337 MIPS_NOT_SUPP | CPU_MIPS_R4K_MMU, 0, 0, 337 MIPS_NOT_SUPP | CPU_MIPS_R4K_MMU, 0, 0,
338 "NEC VR4200 CPU" }, 338 "NEC VR4200 CPU" },
339 { 0, MIPS_R4300, -1, -1, CPU_ARCH_MIPS3, 32, 339 { 0, MIPS_R4300, -1, -1, CPU_ARCH_MIPS3, 32,
340 CPU_MIPS_R4K_MMU, 0, 0, "NEC VR4300 CPU" }, 340 CPU_MIPS_R4K_MMU, 0, 0, "NEC VR4300 CPU" },
341 { 0, MIPS_R4600, -1, -1, CPU_ARCH_MIPS3, 48, 341 { 0, MIPS_R4600, -1, -1, CPU_ARCH_MIPS3, 48,
342 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0, 342 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0,
343 "QED R4600 Orion CPU" }, 343 "QED R4600 Orion CPU" },
344 { 0, MIPS_R4700, -1, -1, CPU_ARCH_MIPS3, 48, 344 { 0, MIPS_R4700, -1, -1, CPU_ARCH_MIPS3, 48,
345 CPU_MIPS_R4K_MMU, 0, 0, "QED R4700 Orion CPU" }, 345 CPU_MIPS_R4K_MMU, 0, 0, "QED R4700 Orion CPU" },
346 346
347 { 0, MIPS_R8000, -1, -1, CPU_ARCH_MIPS4, 384, 347 { 0, MIPS_R8000, -1, -1, CPU_ARCH_MIPS4, 384,
348 MIPS_NOT_SUPP | CPU_MIPS_R4K_MMU, 0, 0, 348 MIPS_NOT_SUPP | CPU_MIPS_R4K_MMU, 0, 0,
349 "MIPS R8000 Blackbird/TFP CPU" }, 349 "MIPS R8000 Blackbird/TFP CPU" },
350 { 0, MIPS_R10000, -1, -1, CPU_ARCH_MIPS4, 64, 350 { 0, MIPS_R10000, -1, -1, CPU_ARCH_MIPS4, 64,
351 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0, 351 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0,
352 "MIPS R10000 CPU" }, 352 "MIPS R10000 CPU" },
353 { 0, MIPS_R12000, -1, -1, CPU_ARCH_MIPS4, 64, 353 { 0, MIPS_R12000, -1, -1, CPU_ARCH_MIPS4, 64,
354 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0, 354 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0,
355 "MIPS R12000 CPU" }, 355 "MIPS R12000 CPU" },
356 { 0, MIPS_R14000, -1, -1, CPU_ARCH_MIPS4, 64, 356 { 0, MIPS_R14000, -1, -1, CPU_ARCH_MIPS4, 64,
357 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0, 357 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0,
358 "MIPS R14000 CPU" }, 358 "MIPS R14000 CPU" },
359 359
360 /* XXX 360 /* XXX
361 * If the Processor Revision ID of the 4650 isn't 0, the following 361 * If the Processor Revision ID of the 4650 isn't 0, the following
362 * entry needs to be adjusted. Can't use a wildcard match because 362 * entry needs to be adjusted. Can't use a wildcard match because
363 * the TX39 series processors share the same Processor ID value. 363 * the TX39 series processors share the same Processor ID value.
364 * Or maybe put TX39 CPUs first if the revid doesn't overlap with 364 * Or maybe put TX39 CPUs first if the revid doesn't overlap with
365 * the 4650... 365 * the 4650...
366 */ 366 */
367 { 0, MIPS_R4650, 0, -1, CPU_ARCH_MIPS3, -1, 367 { 0, MIPS_R4650, 0, -1, CPU_ARCH_MIPS3, -1,
368 MIPS_NOT_SUPP /* no MMU! */, 0, 0, "QED R4650 CPU" }, 368 MIPS_NOT_SUPP /* no MMU! */, 0, 0, "QED R4650 CPU" },
369 { 0, MIPS_TX3900, MIPS_REV_TX3912, -1, CPU_ARCH_MIPS1, 32, 369 { 0, MIPS_TX3900, MIPS_REV_TX3912, -1, CPU_ARCH_MIPS1, 32,
370 CPU_MIPS_NO_LLSC, 0, 0, "Toshiba TX3912 CPU" }, 370 CPU_MIPS_NO_LLSC, 0, 0, "Toshiba TX3912 CPU" },
371 { 0, MIPS_TX3900, MIPS_REV_TX3922, -1, CPU_ARCH_MIPS1, 64, 371 { 0, MIPS_TX3900, MIPS_REV_TX3922, -1, CPU_ARCH_MIPS1, 64,
372 CPU_MIPS_NO_LLSC, 0, 0, "Toshiba TX3922 CPU" }, 372 CPU_MIPS_NO_LLSC, 0, 0, "Toshiba TX3922 CPU" },
373 { 0, MIPS_TX3900, MIPS_REV_TX3927, -1, CPU_ARCH_MIPS1, 64, 373 { 0, MIPS_TX3900, MIPS_REV_TX3927, -1, CPU_ARCH_MIPS1, 64,
374 CPU_MIPS_NO_LLSC, 0, 0, "Toshiba TX3927 CPU" }, 374 CPU_MIPS_NO_LLSC, 0, 0, "Toshiba TX3927 CPU" },
375 { 0, MIPS_R5000, -1, -1, CPU_ARCH_MIPS4, 48, 375 { 0, MIPS_R5000, -1, -1, CPU_ARCH_MIPS4, 48,
376 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0, 376 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0,
377 "MIPS R5000 CPU" }, 377 "MIPS R5000 CPU" },
378 { 0, MIPS_RM5200, -1, -1, CPU_ARCH_MIPS4, 48, 378 { 0, MIPS_RM5200, -1, -1, CPU_ARCH_MIPS4, 48,
379 CPU_MIPS_R4K_MMU | CPU_MIPS_CAUSE_IV | CPU_MIPS_DOUBLE_COUNT | 379 CPU_MIPS_R4K_MMU | CPU_MIPS_CAUSE_IV | CPU_MIPS_DOUBLE_COUNT |
380 CPU_MIPS_USE_WAIT, 0, 0, "QED RM5200 CPU" }, 380 CPU_MIPS_USE_WAIT, 0, 0, "QED RM5200 CPU" },
381 381
382 /* XXX 382 /* XXX
383 * The rm7000 rev 2.0 can have 64 tlbs, and has 6 extra interrupts. See 383 * The rm7000 rev 2.0 can have 64 tlbs, and has 6 extra interrupts. See
384 * "Migrating to the RM7000 from other MIPS Microprocessors" 384 * "Migrating to the RM7000 from other MIPS Microprocessors"
385 * for more details. 385 * for more details.
386 */ 386 */
387 { 0, MIPS_RM7000, -1, -1, CPU_ARCH_MIPS4, 48, 387 { 0, MIPS_RM7000, -1, -1, CPU_ARCH_MIPS4, 48,
388 MIPS_NOT_SUPP | CPU_MIPS_CAUSE_IV | CPU_MIPS_DOUBLE_COUNT | 388 MIPS_NOT_SUPP | CPU_MIPS_CAUSE_IV | CPU_MIPS_DOUBLE_COUNT |
389 CPU_MIPS_USE_WAIT, 0, 0, "QED RM7000 CPU" }, 389 CPU_MIPS_USE_WAIT, 0, 0, "QED RM7000 CPU" },
390 390
391 /* 391 /*
392 * IDT RC32300 core is a 32 bit MIPS2 processor with 392 * IDT RC32300 core is a 32 bit MIPS2 processor with
393 * MIPS3/MIPS4 extensions. It has an R4000-style TLB, 393 * MIPS3/MIPS4 extensions. It has an R4000-style TLB,
394 * while all registers are 32 bits and any 64 bit 394 * while all registers are 32 bits and any 64 bit
395 * instructions like ld/sd/dmfc0/dmtc0 are not allowed. 395 * instructions like ld/sd/dmfc0/dmtc0 are not allowed.
396 * 396 *
397 * note that the Config register has a non-standard base 397 * note that the Config register has a non-standard base
398 * for IC and DC (2^9 instead of 2^12). 398 * for IC and DC (2^9 instead of 2^12).
399 * 399 *
400 */ 400 */
401 { 0, MIPS_RC32300, -1, -1, CPU_ARCH_MIPS3, 16, 401 { 0, MIPS_RC32300, -1, -1, CPU_ARCH_MIPS3, 16,
402 MIPS_NOT_SUPP | CPU_MIPS_R4K_MMU, 0, 0, 402 MIPS_NOT_SUPP | CPU_MIPS_R4K_MMU, 0, 0,
403 "IDT RC32300 CPU" }, 403 "IDT RC32300 CPU" },
404 { 0, MIPS_RC32364, -1, -1, CPU_ARCH_MIPS3, 16, 404 { 0, MIPS_RC32364, -1, -1, CPU_ARCH_MIPS3, 16,
405 MIPS_NOT_SUPP | CPU_MIPS_R4K_MMU, 0, 0, 405 MIPS_NOT_SUPP | CPU_MIPS_R4K_MMU, 0, 0,
406 "IDT RC32364 CPU" }, 406 "IDT RC32364 CPU" },
407 { 0, MIPS_RC64470, -1, -1, CPU_ARCH_MIPSx, -1, 407 { 0, MIPS_RC64470, -1, -1, CPU_ARCH_MIPSx, -1,
408 MIPS_NOT_SUPP | CPU_MIPS_R4K_MMU, 0, 0, 408 MIPS_NOT_SUPP | CPU_MIPS_R4K_MMU, 0, 0,
409 "IDT RC64474/RC64475 CPU" }, 409 "IDT RC64474/RC64475 CPU" },
410 410
411 { 0, MIPS_R5400, -1, -1, CPU_ARCH_MIPSx, -1, 411 { 0, MIPS_R5400, -1, -1, CPU_ARCH_MIPSx, -1,
412 MIPS_NOT_SUPP | CPU_MIPS_R4K_MMU, 0, 0, 412 MIPS_NOT_SUPP | CPU_MIPS_R4K_MMU, 0, 0,
413 "NEC VR5400 CPU" }, 413 "NEC VR5400 CPU" },
414 { 0, MIPS_R5900, -1, -1, CPU_ARCH_MIPS3, 48, 414 { 0, MIPS_R5900, -1, -1, CPU_ARCH_MIPS3, 48,
415 CPU_MIPS_NO_LLSC | CPU_MIPS_R4K_MMU, 0, 0, 415 CPU_MIPS_NO_LLSC | CPU_MIPS_R4K_MMU, 0, 0,
416 "Toshiba R5900 CPU" }, 416 "Toshiba R5900 CPU" },
417 417
418 { 0, MIPS_TX4900, MIPS_REV_TX4927, -1, CPU_ARCH_MIPS3, 48, 418 { 0, MIPS_TX4900, MIPS_REV_TX4927, -1, CPU_ARCH_MIPS3, 48,
419 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0, 419 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0,
420 "Toshiba TX4927 CPU" }, 420 "Toshiba TX4927 CPU" },
421 421
422 { 0, MIPS_TX4900, -1, -1, CPU_ARCH_MIPS3, 48, 422 { 0, MIPS_TX4900, -1, -1, CPU_ARCH_MIPS3, 48,
423 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0, 423 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT, 0, 0,
424 "Toshiba TX4900 CPU" }, 424 "Toshiba TX4900 CPU" },
425 425
426 /* 426 /*
427 * ICT Loongson2 is a MIPS64 CPU with a few quirks. For some reason 427 * ICT Loongson2 is a MIPS64 CPU with a few quirks. For some reason
428 * the virtual aliases present with 4KB pages make the caches misbehave 428 * the virtual aliases present with 4KB pages make the caches misbehave
429 * so we make all accesses uncached. With 16KB pages, no virtual 429 * so we make all accesses uncached. With 16KB pages, no virtual
430 * aliases are possible so we can use caching. 430 * aliases are possible so we can use caching.
431 */ 431 */
432#ifdef ENABLE_MIPS_16KB_PAGE 432#ifdef ENABLE_MIPS_16KB_PAGE
433#define MIPS_LOONGSON2_CCA 0 433#define MIPS_LOONGSON2_CCA 0
434#else 434#else
435#define MIPS_LOONGSON2_CCA (CPU_MIPS_HAVE_SPECIAL_CCA | \ 435#define MIPS_LOONGSON2_CCA (CPU_MIPS_HAVE_SPECIAL_CCA | \
436 (2 << CPU_MIPS_CACHED_CCA_SHIFT)) 436 (2 << CPU_MIPS_CACHED_CCA_SHIFT))
437#endif 437#endif
438 { 0, MIPS_LOONGSON2, MIPS_REV_LOONGSON2E, -1, CPU_ARCH_MIPS3, 64, 438 { 0, MIPS_LOONGSON2, MIPS_REV_LOONGSON2E, -1, CPU_ARCH_MIPS3, 64,
439 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT | CPU_MIPS_LOONGSON2 439 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT | CPU_MIPS_LOONGSON2
440 | MIPS_LOONGSON2_CCA, 0, 0, "ICT Loongson 2E CPU" }, 440 | MIPS_LOONGSON2_CCA, 0, 0, "ICT Loongson 2E CPU" },
441 { 0, MIPS_LOONGSON2, MIPS_REV_LOONGSON2F, -1, CPU_ARCH_MIPS3, 64, 441 { 0, MIPS_LOONGSON2, MIPS_REV_LOONGSON2F, -1, CPU_ARCH_MIPS3, 64,
442 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT | CPU_MIPS_LOONGSON2 442 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT | CPU_MIPS_LOONGSON2
443 | MIPS_LOONGSON2_CCA, 0, 0, "ICT Loongson 2F CPU" }, 443 | MIPS_LOONGSON2_CCA, 0, 0, "ICT Loongson 2F CPU" },
444 444
445#if 0 /* ID collisions : can we use a CU1 test or similar? */ 445#if 0 /* ID collisions : can we use a CU1 test or similar? */
446 { 0, MIPS_R3SONY, -1, -1, CPU_ARCH_MIPS1, -1, 446 { 0, MIPS_R3SONY, -1, -1, CPU_ARCH_MIPS1, -1,
447 MIPS_NOT_SUPP, 0, 0, "SONY R3000 derivative" }, /* 0x21; crash R4700? */ 447 MIPS_NOT_SUPP, 0, 0, "SONY R3000 derivative" }, /* 0x21; crash R4700? */
448 { 0, MIPS_R3NKK, -1, -1, CPU_ARCH_MIPS1, -1, 448 { 0, MIPS_R3NKK, -1, -1, CPU_ARCH_MIPS1, -1,
449 MIPS_NOT_SUPP, 0, 0, "NKK R3000 derivative" }, /* 0x23; crash R5000? */ 449 MIPS_NOT_SUPP, 0, 0, "NKK R3000 derivative" }, /* 0x23; crash R5000? */
450#endif 450#endif
451 451
452 { MIPS_PRID_CID_MTI, MIPS_4Kc, -1, -1, -1, 0, 452 { MIPS_PRID_CID_MTI, MIPS_4Kc, -1, -1, -1, 0,
453 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 0, 0, "4Kc" }, 453 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 0, 0, "4Kc" },
454 { MIPS_PRID_CID_MTI, MIPS_4KEc, -1, -1, -1, 0, 454 { MIPS_PRID_CID_MTI, MIPS_4KEc, -1, -1, -1, 0,
455 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 0, 0, "4KEc" }, 455 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 0, 0, "4KEc" },
456 { MIPS_PRID_CID_MTI, MIPS_4KEc_R2, -1, -1, -1, 0, 456 { MIPS_PRID_CID_MTI, MIPS_4KEc_R2, -1, -1, -1, 0,
457 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 0, 0, "4KEc (Rev 2)" }, 457 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 0, 0, "4KEc (Rev 2)" },
458 { MIPS_PRID_CID_MTI, MIPS_4KSc, -1, -1, -1, 0, 458 { MIPS_PRID_CID_MTI, MIPS_4KSc, -1, -1, -1, 0,
459 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 0, 0, "4KSc" }, 459 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 0, 0, "4KSc" },
460 { MIPS_PRID_CID_MTI, MIPS_5Kc, -1, -1, -1, 0, 460 { MIPS_PRID_CID_MTI, MIPS_5Kc, -1, -1, -1, 0,
461 MIPS64_FLAGS | CPU_MIPS_DOUBLE_COUNT, 0, 0, "5Kc" }, 461 MIPS64_FLAGS | CPU_MIPS_DOUBLE_COUNT, 0, 0, "5Kc" },
462 { MIPS_PRID_CID_MTI, MIPS_20Kc, -1, -1, -1, 0, 462 { MIPS_PRID_CID_MTI, MIPS_20Kc, -1, -1, -1, 0,
463 MIPS64_FLAGS, 0, 0, "20Kc" }, 463 MIPS64_FLAGS, 0, 0, "20Kc" },
464 { MIPS_PRID_CID_MTI, MIPS_25Kf, -1, -1, -1, 0, 464 { MIPS_PRID_CID_MTI, MIPS_25Kf, -1, -1, -1, 0,
465 MIPS64_FLAGS, 0, 0, "25Kf" }, 465 MIPS64_FLAGS, 0, 0, "25Kf" },
466 { MIPS_PRID_CID_MTI, MIPS_24K, -1, -1, -1, 0, 466 { MIPS_PRID_CID_MTI, MIPS_24K, -1, -1, -1, 0,
467 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 467 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT,
468 MIPS_CP0FL_USE | 468 MIPS_CP0FL_USE |
469 MIPS_CP0FL_EBASE | 469 MIPS_CP0FL_EBASE |
470 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 | 470 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 |
471 MIPS_CP0FL_CONFIG3 | MIPS_CP0FL_CONFIG7, 471 MIPS_CP0FL_CONFIG3 | MIPS_CP0FL_CONFIG7,
472 0, "24K" }, 472 0, "24K" },
473 { MIPS_PRID_CID_MTI, MIPS_24KE, -1, -1, -1, 0, 473 { MIPS_PRID_CID_MTI, MIPS_24KE, -1, -1, -1, 0,
474 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 474 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT,
475 MIPS_CP0FL_USE | 475 MIPS_CP0FL_USE |
476 MIPS_CP0FL_EBASE | 476 MIPS_CP0FL_EBASE |
477 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 | 477 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 |
478 MIPS_CP0FL_CONFIG3 | MIPS_CP0FL_CONFIG7, 478 MIPS_CP0FL_CONFIG3 | MIPS_CP0FL_CONFIG7,
479 0, "24KE" }, 479 0, "24KE" },
480 { MIPS_PRID_CID_MTI, MIPS_34K, -1, -1, -1, 0, 480 { MIPS_PRID_CID_MTI, MIPS_34K, -1, -1, -1, 0,
481 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 481 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT,
482 MIPS_CP0FL_USE | 482 MIPS_CP0FL_USE |
483 MIPS_CP0FL_EBASE | 483 MIPS_CP0FL_EBASE |
484 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 | 484 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 |
485 MIPS_CP0FL_CONFIG3 | MIPS_CP0FL_CONFIG7, 485 MIPS_CP0FL_CONFIG3 | MIPS_CP0FL_CONFIG7,
486 0, "34K" }, 486 0, "34K" },
487 { MIPS_PRID_CID_MTI, MIPS_74K, -1, -1, -1, 0, 487 { MIPS_PRID_CID_MTI, MIPS_74K, -1, -1, -1, 0,
488 CPU_MIPS_HAVE_SPECIAL_CCA | (0 << CPU_MIPS_CACHED_CCA_SHIFT) | 488 CPU_MIPS_HAVE_SPECIAL_CCA | (0 << CPU_MIPS_CACHED_CCA_SHIFT) |
489 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 489 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT,
490 MIPS_CP0FL_USE | 490 MIPS_CP0FL_USE |
491 MIPS_CP0FL_EBASE | 491 MIPS_CP0FL_EBASE |
492 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 | 492 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 |
493 MIPS_CP0FL_CONFIG3 | MIPS_CP0FL_CONFIG6 | MIPS_CP0FL_CONFIG7, 493 MIPS_CP0FL_CONFIG3 | MIPS_CP0FL_CONFIG6 | MIPS_CP0FL_CONFIG7,
494 0, "74K" }, 494 0, "74K" },
495 { MIPS_PRID_CID_MTI, MIPS_1004K, -1, -1, -1, 0, 495 { MIPS_PRID_CID_MTI, MIPS_1004K, -1, -1, -1, 0,
496 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 496 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT,
497 MIPS_CP0FL_USE | 497 MIPS_CP0FL_USE |
498 MIPS_CP0FL_EBASE | 498 MIPS_CP0FL_EBASE |
499 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 | 499 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 |
500 MIPS_CP0FL_CONFIG3 | MIPS_CP0FL_CONFIG6 | MIPS_CP0FL_CONFIG7, 500 MIPS_CP0FL_CONFIG3 | MIPS_CP0FL_CONFIG6 | MIPS_CP0FL_CONFIG7,
501 0, "1004K" }, 501 0, "1004K" },
502 { MIPS_PRID_CID_MTI, MIPS_1074K, -1, -1, -1, 0, 502 { MIPS_PRID_CID_MTI, MIPS_1074K, -1, -1, -1, 0,
503 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 503 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT,
504 MIPS_CP0FL_USE | 504 MIPS_CP0FL_USE |
505 MIPS_CP0FL_EBASE | 505 MIPS_CP0FL_EBASE |
506 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 | 506 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 |
507 MIPS_CP0FL_CONFIG3 | MIPS_CP0FL_CONFIG6 | MIPS_CP0FL_CONFIG7, 507 MIPS_CP0FL_CONFIG3 | MIPS_CP0FL_CONFIG6 | MIPS_CP0FL_CONFIG7,
508 0, "1074K" }, 508 0, "1074K" },
509 509
510 { MIPS_PRID_CID_BROADCOM, MIPS_BCM3302, -1, -1, -1, 0, 510 { MIPS_PRID_CID_BROADCOM, MIPS_BCM3302, -1, -1, -1, 0,
511 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 0, 0, "BCM3302" }, 511 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 0, 0, "BCM3302" },
512 512
513 { MIPS_PRID_CID_ALCHEMY, MIPS_AU_REV1, -1, MIPS_AU1000, -1, 0, 513 { MIPS_PRID_CID_ALCHEMY, MIPS_AU_REV1, -1, MIPS_AU1000, -1, 0,
514 MIPS32_FLAGS | CPU_MIPS_NO_WAIT | CPU_MIPS_I_D_CACHE_COHERENT, 0, 0, 514 MIPS32_FLAGS | CPU_MIPS_NO_WAIT | CPU_MIPS_I_D_CACHE_COHERENT, 0, 0,
515 "Au1000 (Rev 1 core)" }, 515 "Au1000 (Rev 1 core)" },
516 { MIPS_PRID_CID_ALCHEMY, MIPS_AU_REV2, -1, MIPS_AU1000, -1, 0, 516 { MIPS_PRID_CID_ALCHEMY, MIPS_AU_REV2, -1, MIPS_AU1000, -1, 0,
517 MIPS32_FLAGS | CPU_MIPS_NO_WAIT | CPU_MIPS_I_D_CACHE_COHERENT, 0, 0, 517 MIPS32_FLAGS | CPU_MIPS_NO_WAIT | CPU_MIPS_I_D_CACHE_COHERENT, 0, 0,
518 "Au1000 (Rev 2 core)" }, 518 "Au1000 (Rev 2 core)" },
519 519
520 { MIPS_PRID_CID_ALCHEMY, MIPS_AU_REV1, -1, MIPS_AU1100, -1, 0, 520 { MIPS_PRID_CID_ALCHEMY, MIPS_AU_REV1, -1, MIPS_AU1100, -1, 0,
521 MIPS32_FLAGS | CPU_MIPS_NO_WAIT | CPU_MIPS_I_D_CACHE_COHERENT, 0, 0, 521 MIPS32_FLAGS | CPU_MIPS_NO_WAIT | CPU_MIPS_I_D_CACHE_COHERENT, 0, 0,
522 "Au1100 (Rev 1 core)" }, 522 "Au1100 (Rev 1 core)" },
523 { MIPS_PRID_CID_ALCHEMY, MIPS_AU_REV2, -1, MIPS_AU1100, -1, 0, 523 { MIPS_PRID_CID_ALCHEMY, MIPS_AU_REV2, -1, MIPS_AU1100, -1, 0,
524 MIPS32_FLAGS | CPU_MIPS_NO_WAIT | CPU_MIPS_I_D_CACHE_COHERENT, 0, 0, 524 MIPS32_FLAGS | CPU_MIPS_NO_WAIT | CPU_MIPS_I_D_CACHE_COHERENT, 0, 0,
525 "Au1100 (Rev 2 core)" }, 525 "Au1100 (Rev 2 core)" },
526 526
527 { MIPS_PRID_CID_ALCHEMY, MIPS_AU_REV1, -1, MIPS_AU1500, -1, 0, 527 { MIPS_PRID_CID_ALCHEMY, MIPS_AU_REV1, -1, MIPS_AU1500, -1, 0,
528 MIPS32_FLAGS | CPU_MIPS_NO_WAIT | CPU_MIPS_I_D_CACHE_COHERENT, 0, 0, 528 MIPS32_FLAGS | CPU_MIPS_NO_WAIT | CPU_MIPS_I_D_CACHE_COHERENT, 0, 0,
529 "Au1500 (Rev 1 core)" }, 529 "Au1500 (Rev 1 core)" },
530 { MIPS_PRID_CID_ALCHEMY, MIPS_AU_REV2, -1, MIPS_AU1500, -1, 0, 530 { MIPS_PRID_CID_ALCHEMY, MIPS_AU_REV2, -1, MIPS_AU1500, -1, 0,
531 MIPS32_FLAGS | CPU_MIPS_NO_WAIT | CPU_MIPS_I_D_CACHE_COHERENT, 0, 0, 531 MIPS32_FLAGS | CPU_MIPS_NO_WAIT | CPU_MIPS_I_D_CACHE_COHERENT, 0, 0,
532 "Au1500 (Rev 2 core)" }, 532 "Au1500 (Rev 2 core)" },
533 533
534 { MIPS_PRID_CID_ALCHEMY, MIPS_AU_REV2, -1, MIPS_AU1550, -1, 0, 534 { MIPS_PRID_CID_ALCHEMY, MIPS_AU_REV2, -1, MIPS_AU1550, -1, 0,
535 MIPS32_FLAGS | CPU_MIPS_NO_WAIT | CPU_MIPS_I_D_CACHE_COHERENT, 0, 0, 535 MIPS32_FLAGS | CPU_MIPS_NO_WAIT | CPU_MIPS_I_D_CACHE_COHERENT, 0, 0,
536 "Au1550 (Rev 2 core)" }, 536 "Au1550 (Rev 2 core)" },
537 537
538 /* The SB-1 CPU uses a CCA of 5 - "Cacheable Coherent Shareable" */ 538 /* The SB-1 CPU uses a CCA of 5 - "Cacheable Coherent Shareable" */
539 { MIPS_PRID_CID_SIBYTE, MIPS_SB1, -1, -1, -1, 0, 539 { MIPS_PRID_CID_SIBYTE, MIPS_SB1, -1, -1, -1, 0,
540 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | 540 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT |
541 CPU_MIPS_HAVE_SPECIAL_CCA | 541 CPU_MIPS_HAVE_SPECIAL_CCA |
542 (CCA_SB_CACHEABLE_COHERENT << CPU_MIPS_CACHED_CCA_SHIFT), 0, 0, 542 (CCA_SB_CACHEABLE_COHERENT << CPU_MIPS_CACHED_CCA_SHIFT), 0, 0,
543 "SB-1" }, 543 "SB-1" },
544 { MIPS_PRID_CID_SIBYTE, MIPS_SB1_11, -1, -1, -1, 0, 544 { MIPS_PRID_CID_SIBYTE, MIPS_SB1_11, -1, -1, -1, 0,
545 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | 545 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT |
546 CPU_MIPS_HAVE_SPECIAL_CCA | 546 CPU_MIPS_HAVE_SPECIAL_CCA |
547 (CCA_SB_CACHEABLE_COHERENT << CPU_MIPS_CACHED_CCA_SHIFT), 0, 0, 547 (CCA_SB_CACHEABLE_COHERENT << CPU_MIPS_CACHED_CCA_SHIFT), 0, 0,
548 "SB-1 (0x11)" }, 548 "SB-1 (0x11)" },
549 549
550 { MIPS_PRID_CID_RMI, MIPS_XLR732B, -1, -1, -1, 0, 550 { MIPS_PRID_CID_RMI, MIPS_XLR732B, -1, -1, -1, 0,
551 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR | 551 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR |
552 CPU_MIPS_I_D_CACHE_COHERENT | CPU_MIPS_HAVE_MxCR, 552 CPU_MIPS_I_D_CACHE_COHERENT | CPU_MIPS_HAVE_MxCR,
553 MIPS_CP0FL_USE | 553 MIPS_CP0FL_USE |
554 MIPS_CP0FL_EIRR | MIPS_CP0FL_EIMR | MIPS_CP0FL_EBASE | 554 MIPS_CP0FL_EIRR | MIPS_CP0FL_EIMR | MIPS_CP0FL_EBASE |
555 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG7, 555 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG7,
556 CIDFL_RMI_TYPE_XLR|MIPS_CIDFL_RMI_CPUS(8,4)|MIPS_CIDFL_RMI_L2(2MB), 556 CIDFL_RMI_TYPE_XLR|MIPS_CIDFL_RMI_CPUS(8,4)|MIPS_CIDFL_RMI_L2(2MB),
557 "XLR732B" }, 557 "XLR732B" },
558 558
559 { MIPS_PRID_CID_RMI, MIPS_XLR732C, -1, -1, -1, 0, 559 { MIPS_PRID_CID_RMI, MIPS_XLR732C, -1, -1, -1, 0,
560 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR | 560 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR |
561 CPU_MIPS_I_D_CACHE_COHERENT | CPU_MIPS_HAVE_MxCR, 561 CPU_MIPS_I_D_CACHE_COHERENT | CPU_MIPS_HAVE_MxCR,
562 MIPS_CP0FL_USE | 562 MIPS_CP0FL_USE |
563 MIPS_CP0FL_EIRR | MIPS_CP0FL_EIMR | MIPS_CP0FL_EBASE | 563 MIPS_CP0FL_EIRR | MIPS_CP0FL_EIMR | MIPS_CP0FL_EBASE |
564 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG7, 564 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG7,
565 CIDFL_RMI_TYPE_XLR|MIPS_CIDFL_RMI_CPUS(8,4)|MIPS_CIDFL_RMI_L2(2MB), 565 CIDFL_RMI_TYPE_XLR|MIPS_CIDFL_RMI_CPUS(8,4)|MIPS_CIDFL_RMI_L2(2MB),
566 "XLR732C" }, 566 "XLR732C" },
567 567
568 { MIPS_PRID_CID_RMI, MIPS_XLS616, -1, -1, -1, 0, 568 { MIPS_PRID_CID_RMI, MIPS_XLS616, -1, -1, -1, 0,
569 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR | 569 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR |
570 CPU_MIPS_I_D_CACHE_COHERENT | CPU_MIPS_HAVE_MxCR, 570 CPU_MIPS_I_D_CACHE_COHERENT | CPU_MIPS_HAVE_MxCR,
571 MIPS_CP0FL_USE | 571 MIPS_CP0FL_USE |
572 MIPS_CP0FL_EIRR | MIPS_CP0FL_EIMR | MIPS_CP0FL_EBASE | 572 MIPS_CP0FL_EIRR | MIPS_CP0FL_EIMR | MIPS_CP0FL_EBASE |
573 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG7, 573 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG7,
574 CIDFL_RMI_TYPE_XLS|MIPS_CIDFL_RMI_CPUS(4,4)|MIPS_CIDFL_RMI_L2(1MB), 574 CIDFL_RMI_TYPE_XLS|MIPS_CIDFL_RMI_CPUS(4,4)|MIPS_CIDFL_RMI_L2(1MB),
575 "XLS616" }, 575 "XLS616" },
576 576
577 { MIPS_PRID_CID_RMI, MIPS_XLS416, -1, -1, -1, 0, 577 { MIPS_PRID_CID_RMI, MIPS_XLS416, -1, -1, -1, 0,
578 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR | 578 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR |
579 CPU_MIPS_I_D_CACHE_COHERENT | CPU_MIPS_HAVE_MxCR, 579 CPU_MIPS_I_D_CACHE_COHERENT | CPU_MIPS_HAVE_MxCR,
580 MIPS_CP0FL_USE | 580 MIPS_CP0FL_USE |
581 MIPS_CP0FL_EIRR | MIPS_CP0FL_EIMR | MIPS_CP0FL_EBASE | 581 MIPS_CP0FL_EIRR | MIPS_CP0FL_EIMR | MIPS_CP0FL_EBASE |
582 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG7, 582 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG7,
583 CIDFL_RMI_TYPE_XLS|MIPS_CIDFL_RMI_CPUS(4,4)|MIPS_CIDFL_RMI_L2(1MB), 583 CIDFL_RMI_TYPE_XLS|MIPS_CIDFL_RMI_CPUS(4,4)|MIPS_CIDFL_RMI_L2(1MB),
584 "XLS416" }, 584 "XLS416" },
585 585
586 { MIPS_PRID_CID_RMI, MIPS_XLS408, -1, -1, -1, 0, 586 { MIPS_PRID_CID_RMI, MIPS_XLS408, -1, -1, -1, 0,
587 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR | 587 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR |
588 CPU_MIPS_I_D_CACHE_COHERENT | CPU_MIPS_HAVE_MxCR, 588 CPU_MIPS_I_D_CACHE_COHERENT | CPU_MIPS_HAVE_MxCR,
589 MIPS_CP0FL_USE | 589 MIPS_CP0FL_USE |
590 MIPS_CP0FL_EIRR | MIPS_CP0FL_EIMR | MIPS_CP0FL_EBASE | 590 MIPS_CP0FL_EIRR | MIPS_CP0FL_EIMR | MIPS_CP0FL_EBASE |
591 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG7, 591 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG7,
592 CIDFL_RMI_TYPE_XLS|MIPS_CIDFL_RMI_CPUS(2,4)|MIPS_CIDFL_RMI_L2(1MB), 592 CIDFL_RMI_TYPE_XLS|MIPS_CIDFL_RMI_CPUS(2,4)|MIPS_CIDFL_RMI_L2(1MB),
593 "XLS408" }, 593 "XLS408" },
594 594
595 { MIPS_PRID_CID_RMI, MIPS_XLS408LITE, -1, -1, -1, 0, 595 { MIPS_PRID_CID_RMI, MIPS_XLS408LITE, -1, -1, -1, 0,
596 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR | 596 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR |
597 CPU_MIPS_I_D_CACHE_COHERENT | CPU_MIPS_HAVE_MxCR, 597 CPU_MIPS_I_D_CACHE_COHERENT | CPU_MIPS_HAVE_MxCR,
598 MIPS_CP0FL_USE | 598 MIPS_CP0FL_USE |
599 MIPS_CP0FL_EIRR | MIPS_CP0FL_EIMR | MIPS_CP0FL_EBASE | 599 MIPS_CP0FL_EIRR | MIPS_CP0FL_EIMR | MIPS_CP0FL_EBASE |
600 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG7, 600 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG7,
601 CIDFL_RMI_TYPE_XLS|MIPS_CIDFL_RMI_CPUS(2,4)|MIPS_CIDFL_RMI_L2(1MB), 601 CIDFL_RMI_TYPE_XLS|MIPS_CIDFL_RMI_CPUS(2,4)|MIPS_CIDFL_RMI_L2(1MB),
602 "XLS408lite" }, 602 "XLS408lite" },
603 603
604 { MIPS_PRID_CID_RMI, MIPS_XLS404LITE, -1, -1, -1, 0, 604 { MIPS_PRID_CID_RMI, MIPS_XLS404LITE, -1, -1, -1, 0,
605 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR | 605 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR |
606 CPU_MIPS_I_D_CACHE_COHERENT | CPU_MIPS_HAVE_MxCR, 606 CPU_MIPS_I_D_CACHE_COHERENT | CPU_MIPS_HAVE_MxCR,
607 MIPS_CP0FL_USE | 607 MIPS_CP0FL_USE |
608 MIPS_CP0FL_EIRR | MIPS_CP0FL_EIMR | MIPS_CP0FL_EBASE | 608 MIPS_CP0FL_EIRR | MIPS_CP0FL_EIMR | MIPS_CP0FL_EBASE |
609 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG7, 609 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG7,
610 CIDFL_RMI_TYPE_XLS|MIPS_CIDFL_RMI_CPUS(1,4)|MIPS_CIDFL_RMI_L2(512KB), 610 CIDFL_RMI_TYPE_XLS|MIPS_CIDFL_RMI_CPUS(1,4)|MIPS_CIDFL_RMI_L2(512KB),
611 "XLS404lite" }, 611 "XLS404lite" },
612 612
613 { MIPS_PRID_CID_RMI, MIPS_XLS208, -1, -1, -1, 0, 613 { MIPS_PRID_CID_RMI, MIPS_XLS208, -1, -1, -1, 0,
614 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR | 614 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR |
615 CPU_MIPS_I_D_CACHE_COHERENT | CPU_MIPS_HAVE_MxCR, 615 CPU_MIPS_I_D_CACHE_COHERENT | CPU_MIPS_HAVE_MxCR,
616 MIPS_CP0FL_USE | 616 MIPS_CP0FL_USE |
617 MIPS_CP0FL_EIRR | MIPS_CP0FL_EIMR | MIPS_CP0FL_EBASE | 617 MIPS_CP0FL_EIRR | MIPS_CP0FL_EIMR | MIPS_CP0FL_EBASE |
618 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG7, 618 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG7,
619 CIDFL_RMI_TYPE_XLS|MIPS_CIDFL_RMI_CPUS(2,4)|MIPS_CIDFL_RMI_L2(512KB), 619 CIDFL_RMI_TYPE_XLS|MIPS_CIDFL_RMI_CPUS(2,4)|MIPS_CIDFL_RMI_L2(512KB),
620 "XLS208" }, 620 "XLS208" },
621 621
622 { MIPS_PRID_CID_RMI, MIPS_XLS204, -1, -1, -1, 0, 622 { MIPS_PRID_CID_RMI, MIPS_XLS204, -1, -1, -1, 0,
623 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR | 623 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR |
624 CPU_MIPS_I_D_CACHE_COHERENT | CPU_MIPS_HAVE_MxCR, 624 CPU_MIPS_I_D_CACHE_COHERENT | CPU_MIPS_HAVE_MxCR,
625 MIPS_CP0FL_USE | 625 MIPS_CP0FL_USE |
626 MIPS_CP0FL_EIRR | MIPS_CP0FL_EIMR | MIPS_CP0FL_EBASE | 626 MIPS_CP0FL_EIRR | MIPS_CP0FL_EIMR | MIPS_CP0FL_EBASE |
627 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG7, 627 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG7,
628 CIDFL_RMI_TYPE_XLS|MIPS_CIDFL_RMI_CPUS(1,4)|MIPS_CIDFL_RMI_L2(256KB), 628 CIDFL_RMI_TYPE_XLS|MIPS_CIDFL_RMI_CPUS(1,4)|MIPS_CIDFL_RMI_L2(256KB),
629 "XLS204" }, 629 "XLS204" },
630 630
631 { MIPS_PRID_CID_RMI, MIPS_XLS108, -1, -1, -1, 0, 631 { MIPS_PRID_CID_RMI, MIPS_XLS108, -1, -1, -1, 0,
632 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR | 632 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR |
633 CPU_MIPS_I_D_CACHE_COHERENT | CPU_MIPS_HAVE_MxCR, 633 CPU_MIPS_I_D_CACHE_COHERENT | CPU_MIPS_HAVE_MxCR,
634 MIPS_CP0FL_USE | 634 MIPS_CP0FL_USE |
635 MIPS_CP0FL_EIRR | MIPS_CP0FL_EIMR | MIPS_CP0FL_EBASE | 635 MIPS_CP0FL_EIRR | MIPS_CP0FL_EIMR | MIPS_CP0FL_EBASE |
636 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG7, 636 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG7,
637 CIDFL_RMI_TYPE_XLS|MIPS_CIDFL_RMI_CPUS(2,4)|MIPS_CIDFL_RMI_L2(512KB), 637 CIDFL_RMI_TYPE_XLS|MIPS_CIDFL_RMI_CPUS(2,4)|MIPS_CIDFL_RMI_L2(512KB),
638 "XLS108" }, 638 "XLS108" },
639 639
640 { MIPS_PRID_CID_RMI, MIPS_XLS104, -1, -1, -1, 0, 640 { MIPS_PRID_CID_RMI, MIPS_XLS104, -1, -1, -1, 0,
641 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR | 641 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR |
642 CPU_MIPS_I_D_CACHE_COHERENT | CPU_MIPS_HAVE_MxCR, 642 CPU_MIPS_I_D_CACHE_COHERENT | CPU_MIPS_HAVE_MxCR,
643 MIPS_CP0FL_USE | 643 MIPS_CP0FL_USE |
644 MIPS_CP0FL_EIRR | MIPS_CP0FL_EIMR | MIPS_CP0FL_EBASE | 644 MIPS_CP0FL_EIRR | MIPS_CP0FL_EIMR | MIPS_CP0FL_EBASE |
645 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG7, 645 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG7,
646 CIDFL_RMI_TYPE_XLS|MIPS_CIDFL_RMI_CPUS(1,4)|MIPS_CIDFL_RMI_L2(256KB), 646 CIDFL_RMI_TYPE_XLS|MIPS_CIDFL_RMI_CPUS(1,4)|MIPS_CIDFL_RMI_L2(256KB),
647 "XLS104" }, 647 "XLS104" },
648 648
649 { MIPS_PRID_CID_CAVIUM, MIPS_CN31XX, -1, -1, -1, 0, 649 { MIPS_PRID_CID_CAVIUM, MIPS_CN31XX, -1, -1, -1, 0,
650 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR, 650 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR,
651 MIPS_CP0FL_USE | 651 MIPS_CP0FL_USE |
652 MIPS_CP0FL_EBASE | MIPS_CP0FL_CONFIG | 652 MIPS_CP0FL_EBASE | MIPS_CP0FL_CONFIG |
653 MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 | MIPS_CP0FL_CONFIG3, 653 MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 | MIPS_CP0FL_CONFIG3,
654 0, 654 0,
655 "CN31xx" }, 655 "CN31xx" },
656 656
657 { MIPS_PRID_CID_CAVIUM, MIPS_CN30XX, -1, -1, -1, 0, 657 { MIPS_PRID_CID_CAVIUM, MIPS_CN30XX, -1, -1, -1, 0,
658 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR, 658 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR,
659 MIPS_CP0FL_USE | 659 MIPS_CP0FL_USE |
660 MIPS_CP0FL_EBASE | MIPS_CP0FL_CONFIG | 660 MIPS_CP0FL_EBASE | MIPS_CP0FL_CONFIG |
661 MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 | MIPS_CP0FL_CONFIG3, 661 MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 | MIPS_CP0FL_CONFIG3,
662 0, 662 0,
663 "CN30xx" }, 663 "CN30xx" },
664 664
665 { MIPS_PRID_CID_CAVIUM, MIPS_CN50XX, -1, -1, -1, 0, 665 { MIPS_PRID_CID_CAVIUM, MIPS_CN50XX, -1, -1, -1, 0,
666 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR, 666 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR,
667 MIPS_CP0FL_USE | 667 MIPS_CP0FL_USE |
668 MIPS_CP0FL_EBASE | MIPS_CP0FL_CONFIG | 668 MIPS_CP0FL_EBASE | MIPS_CP0FL_CONFIG |
669 MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 | MIPS_CP0FL_CONFIG3, 669 MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 | MIPS_CP0FL_CONFIG3,
670 0, 670 0,
671 "CN50xx" }, 671 "CN50xx" },
672 672
673 { MIPS_PRID_CID_CAVIUM, MIPS_CN70XX, -1, -1, -1, 0, 673 { MIPS_PRID_CID_CAVIUM, MIPS_CN70XX, -1, -1, -1, 0,
674 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR, 674 MIPS64_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_NO_LLADDR,
675 MIPS_CP0FL_USE | 675 MIPS_CP0FL_USE | MIPS_CP0FL_EBASE |
676 MIPS_CP0FL_EBASE | MIPS_CP0FL_CONFIG | 676 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 |
677 MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 | MIPS_CP0FL_CONFIG3 | 677 MIPS_CP0FL_CONFIG3 | MIPS_CP0FL_CONFIG4 | MIPS_CP0FL_CONFIG5 |
678 MIPS_CP0FL_CONFIG4 | MIPS_CP0FL_CONFIG6 | MIPS_CP0FL_CONFIG7, 678 MIPS_CP0FL_CONFIG6 | MIPS_CP0FL_CONFIG7,
679 0, 679 0,
680 "CN70xx/CN71xx" }, 680 "CN70xx/CN71xx" },
681 681
682 /* Microsoft Research' extensible MIPS */ 682 /* Microsoft Research' extensible MIPS */
683 { MIPS_PRID_CID_MICROSOFT, MIPS_eMIPS, 1, -1, CPU_ARCH_MIPS1, 64, 683 { MIPS_PRID_CID_MICROSOFT, MIPS_eMIPS, 1, -1, CPU_ARCH_MIPS1, 64,
684 CPU_MIPS_NO_WAIT, 0, 0, "eMIPS CPU" }, 684 CPU_MIPS_NO_WAIT, 0, 0, "eMIPS CPU" },
685 685
686 /* Ingenic XBurst */ 686 /* Ingenic XBurst */
687 { MIPS_PRID_CID_INGENIC, MIPS_XBURST, -1, -1, -1, 0, 687 { MIPS_PRID_CID_INGENIC, MIPS_XBURST, -1, -1, -1, 0,
688 MIPS32_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_DOUBLE_COUNT, 688 MIPS32_FLAGS | CPU_MIPS_D_CACHE_COHERENT | CPU_MIPS_DOUBLE_COUNT,
689 0, 0, "XBurst" }, 689 0, 0, "XBurst" },
690 690
691 { 0, 0, 0, 0, 0, 0, 691 { 0, 0, 0, 0, 0, 0,
692 0, 0, 0, NULL } 692 0, 0, 0, NULL }
693}; 693};
694 694
695static const struct pridtab fputab[] = { 695static const struct pridtab fputab[] = {
696 { 0, MIPS_SOFT, -1, 0, 0, 0, 0, 0, 0, "software emulated floating point" }, 696 { 0, MIPS_SOFT, -1, 0, 0, 0, 0, 0, 0, "software emulated floating point" },
697 { 0, MIPS_R2360, -1, 0, 0, 0, 0, 0, 0, "MIPS R2360 Floating Point Board" }, 697 { 0, MIPS_R2360, -1, 0, 0, 0, 0, 0, 0, "MIPS R2360 Floating Point Board" },
698 { 0, MIPS_R2010, -1, 0, 0, 0, 0, 0, 0, "MIPS R2010 FPC" }, 698 { 0, MIPS_R2010, -1, 0, 0, 0, 0, 0, 0, "MIPS R2010 FPC" },
699 { 0, MIPS_R3010, -1, 0, 0, 0, 0, 0, 0, "MIPS R3010 FPC" }, 699 { 0, MIPS_R3010, -1, 0, 0, 0, 0, 0, 0, "MIPS R3010 FPC" },
700 { 0, MIPS_R6010, -1, 0, 0, 0, 0, 0, 0, "MIPS R6010 FPC" }, 700 { 0, MIPS_R6010, -1, 0, 0, 0, 0, 0, 0, "MIPS R6010 FPC" },
701 { 0, MIPS_R4010, -1, 0, 0, 0, 0, 0, 0, "MIPS R4010 FPC" }, 701 { 0, MIPS_R4010, -1, 0, 0, 0, 0, 0, 0, "MIPS R4010 FPC" },
702}; 702};
703 703
704/* 704/*
705 * Company ID's are not sparse (yet), this array is indexed directly 705 * Company ID's are not sparse (yet), this array is indexed directly
706 * by pridtab->cpu_cid. 706 * by pridtab->cpu_cid.
707 */ 707 */
708static const char * const cidnames[] = { 708static const char * const cidnames[] = {
709 "Prehistoric", 709 "Prehistoric",
710 "MIPS", /* or "MIPS Technologies, Inc. */ 710 "MIPS", /* or "MIPS Technologies, Inc. */
711 "Broadcom", /* or "Broadcom Corp." */ 711 "Broadcom", /* or "Broadcom Corp." */
712 "Alchemy", /* or "Alchemy Semiconductor" */ 712 "Alchemy", /* or "Alchemy Semiconductor" */
713 "SiByte", /* or "Broadcom Corp. (SiByte)" */ 713 "SiByte", /* or "Broadcom Corp. (SiByte)" */
714 "SandCraft", 714 "SandCraft",
715 "Phillips", 715 "Phillips",
716 "Toshiba or Microsoft", 716 "Toshiba or Microsoft",
717 "LSI", 717 "LSI",
718 "(unannounced)", 718 "(unannounced)",
719 "(unannounced)", 719 "(unannounced)",
720 "Lexra", 720 "Lexra",
721 "RMI", 721 "RMI",
722 "Cavium", 722 "Cavium",
723}; 723};
724#define ncidnames __arraycount(cidnames) 724#define ncidnames __arraycount(cidnames)
725 725
726#if defined(MIPS1) 726#if defined(MIPS1)
727/* 727/*
728 * MIPS-I locore function vector 728 * MIPS-I locore function vector
729 */ 729 */
730 730
731static void 731static void
732mips1_vector_init(const struct splsw *splsw) 732mips1_vector_init(const struct splsw *splsw)
733{ 733{
734 extern char mips1_utlb_miss[], mips1_utlb_miss_end[]; 734 extern char mips1_utlb_miss[], mips1_utlb_miss_end[];
735 extern char mips1_exception[], mips1_exception_end[]; 735 extern char mips1_exception[], mips1_exception_end[];
736 736
737 /* 737 /*
738 * Copy down exception vector code. 738 * Copy down exception vector code.
739 */ 739 */
740 if (mips1_utlb_miss_end - mips1_utlb_miss > 0x80) 740 if (mips1_utlb_miss_end - mips1_utlb_miss > 0x80)
741 panic("startup: UTLB vector code too large"); 741 panic("startup: UTLB vector code too large");
742 if (mips1_exception_end - mips1_exception > 0x80) 742 if (mips1_exception_end - mips1_exception > 0x80)
743 panic("startup: general exception vector code too large"); 743 panic("startup: general exception vector code too large");
744 memcpy((void *)MIPS_UTLB_MISS_EXC_VEC, mips1_utlb_miss, 744 memcpy((void *)MIPS_UTLB_MISS_EXC_VEC, mips1_utlb_miss,
745 mips1_exception_end - mips1_utlb_miss); 745 mips1_exception_end - mips1_utlb_miss);
746 746
747 /* 747 /*
748 * Copy locore-function vector. 748 * Copy locore-function vector.
749 */ 749 */
750 mips_locore_jumpvec = mips1_locore_vec; 750 mips_locore_jumpvec = mips1_locore_vec;
751 751
752 /* 752 /*
753 * Clear out the I and D caches. 753 * Clear out the I and D caches.
754 */ 754 */
755 mips_icache_sync_all(); 755 mips_icache_sync_all();
756 mips_dcache_wbinv_all(); 756 mips_dcache_wbinv_all();
757} 757}
758#endif /* MIPS1 */ 758#endif /* MIPS1 */
759 759
760#if defined(MIPS3) 760#if defined(MIPS3)
761static void 761static void
762mips3_vector_init(const struct splsw *splsw) 762mips3_vector_init(const struct splsw *splsw)
763{ 763{
764 /* r4000 exception handler address and end */ 764 /* r4000 exception handler address and end */
765 extern char mips3_exception[], mips3_exception_end[]; 765 extern char mips3_exception[], mips3_exception_end[];
766 766
767 /* TLB miss handler address and end */ 767 /* TLB miss handler address and end */
768 extern char mips3_tlb_miss[]; 768 extern char mips3_tlb_miss[];
769 extern char mips3_xtlb_miss[]; 769 extern char mips3_xtlb_miss[];
770 770
771 /* Cache error handler */ 771 /* Cache error handler */
772 extern char mips3_cache[]; 772 extern char mips3_cache[];
773 /* 773 /*
774 * Copy down exception vector code. 774 * Copy down exception vector code.
775 */ 775 */
776 776
777 if (mips3_xtlb_miss - mips3_tlb_miss != 0x80) 777 if (mips3_xtlb_miss - mips3_tlb_miss != 0x80)
778 panic("startup: %s vector code not 128 bytes in length", 778 panic("startup: %s vector code not 128 bytes in length",
779 "UTLB"); 779 "UTLB");
780 if (mips3_cache - mips3_xtlb_miss != 0x80) 780 if (mips3_cache - mips3_xtlb_miss != 0x80)
781 panic("startup: %s vector code not 128 bytes in length", 781 panic("startup: %s vector code not 128 bytes in length",
782 "XTLB"); 782 "XTLB");
783 if (mips3_exception - mips3_cache != 0x80) 783 if (mips3_exception - mips3_cache != 0x80)
784 panic("startup: %s vector code not 128 bytes in length", 784 panic("startup: %s vector code not 128 bytes in length",
785 "Cache error"); 785 "Cache error");
786 if (mips3_exception_end - mips3_exception > 0x80) 786 if (mips3_exception_end - mips3_exception > 0x80)
787 panic("startup: %s vector code too large", 787 panic("startup: %s vector code too large",
788 "General exception"); 788 "General exception");
789 789
790 memcpy((void *)MIPS_UTLB_MISS_EXC_VEC, mips3_tlb_miss, 790 memcpy((void *)MIPS_UTLB_MISS_EXC_VEC, mips3_tlb_miss,
791 mips3_exception_end - mips3_tlb_miss); 791 mips3_exception_end - mips3_tlb_miss);
792 792
793 /* 793 /*
794 * Copy locore-function vector. 794 * Copy locore-function vector.
795 */ 795 */
796 mips_locore_jumpvec = mips3_locore_vec; 796 mips_locore_jumpvec = mips3_locore_vec;
797 797
798 mips_icache_sync_all(); 798 mips_icache_sync_all();
799 mips_dcache_wbinv_all(); 799 mips_dcache_wbinv_all();
800 800
801 /* Clear BEV in SR so we start handling our own exceptions */ 801 /* Clear BEV in SR so we start handling our own exceptions */
802 mips_cp0_status_write(mips_cp0_status_read() & ~MIPS_SR_BEV); 802 mips_cp0_status_write(mips_cp0_status_read() & ~MIPS_SR_BEV);
803} 803}
804#endif /* MIPS3 */ 804#endif /* MIPS3 */
805 805
806#if defined(MIPS3_LOONGSON2) 806#if defined(MIPS3_LOONGSON2)
807static void 807static void
808loongson2_vector_init(const struct splsw *splsw) 808loongson2_vector_init(const struct splsw *splsw)
809{ 809{
810 /* r4000 exception handler address and end */ 810 /* r4000 exception handler address and end */
811 extern char loongson2_exception[], loongson2_exception_end[]; 811 extern char loongson2_exception[], loongson2_exception_end[];
812 812
813 /* TLB miss handler address and end */ 813 /* TLB miss handler address and end */
814 extern char loongson2_tlb_miss[]; 814 extern char loongson2_tlb_miss[];
815 extern char loongson2_xtlb_miss[]; 815 extern char loongson2_xtlb_miss[];
816 816
817 /* Cache error handler */ 817 /* Cache error handler */
818 extern char loongson2_cache[]; 818 extern char loongson2_cache[];
819 819
820 /* 820 /*
821 * Copy down exception vector code. 821 * Copy down exception vector code.
822 */ 822 */
823 823
824 if (loongson2_xtlb_miss - loongson2_tlb_miss != 0x80) 824 if (loongson2_xtlb_miss - loongson2_tlb_miss != 0x80)
825 panic("startup: %s vector code not 128 bytes in length", 825 panic("startup: %s vector code not 128 bytes in length",
826 "UTLB"); 826 "UTLB");
827 if (loongson2_cache - loongson2_xtlb_miss != 0x80) 827 if (loongson2_cache - loongson2_xtlb_miss != 0x80)
828 panic("startup: %s vector code not 128 bytes in length", 828 panic("startup: %s vector code not 128 bytes in length",
829 "XTLB"); 829 "XTLB");
830 if (loongson2_exception - loongson2_cache != 0x80) 830 if (loongson2_exception - loongson2_cache != 0x80)
831 panic("startup: %s vector code not 128 bytes in length", 831 panic("startup: %s vector code not 128 bytes in length",
832 "Cache error"); 832 "Cache error");
833 if (loongson2_exception_end - loongson2_exception > 0x80) 833 if (loongson2_exception_end - loongson2_exception > 0x80)
834 panic("startup: %s vector code too large", 834 panic("startup: %s vector code too large",
835 "General exception"); 835 "General exception");
836 836
837 memcpy((void *)MIPS_UTLB_MISS_EXC_VEC, loongson2_tlb_miss, 837 memcpy((void *)MIPS_UTLB_MISS_EXC_VEC, loongson2_tlb_miss,
838 loongson2_exception_end - loongson2_tlb_miss); 838 loongson2_exception_end - loongson2_tlb_miss);
839 839
840 /* 840 /*
841 * Copy locore-function vector. 841 * Copy locore-function vector.
842 */ 842 */
843 mips_locore_jumpvec = loongson2_locore_vec; 843 mips_locore_jumpvec = loongson2_locore_vec;
844 844
845 mips_icache_sync_all(); 845 mips_icache_sync_all();
846 mips_dcache_wbinv_all(); 846 mips_dcache_wbinv_all();
847 847
848 /* Clear BEV in SR so we start handling our own exceptions */ 848 /* Clear BEV in SR so we start handling our own exceptions */
849 mips_cp0_status_write(mips_cp0_status_read() & ~MIPS_SR_BEV); 849 mips_cp0_status_write(mips_cp0_status_read() & ~MIPS_SR_BEV);
850} 850}
851#endif /* MIPS3_LOONGSON2 */ 851#endif /* MIPS3_LOONGSON2 */
852 852
853#if defined(MIPS32) 853#if defined(MIPS32)
854static void 854static void
855mips32_vector_init(const struct splsw *splsw) 855mips32_vector_init(const struct splsw *splsw)
856{ 856{
857 /* r4000 exception handler address */ 857 /* r4000 exception handler address */
858 extern char mips32_exception[]; 858 extern char mips32_exception[];
859 859
860 /* TLB miss handler addresses */ 860 /* TLB miss handler addresses */
861 extern char mips32_tlb_miss[]; 861 extern char mips32_tlb_miss[];
862 862
863 /* Cache error handler */ 863 /* Cache error handler */
864 extern char mips32_cache[]; 864 extern char mips32_cache[];
865 865
866 /* MIPS32 interrupt exception handler */ 866 /* MIPS32 interrupt exception handler */
867 extern char mips32_intr[], mips32_intr_end[]; 867 extern char mips32_intr[], mips32_intr_end[];
868 868
869 /* 869 /*
870 * Copy down exception vector code. 870 * Copy down exception vector code.
871 */ 871 */
872 872
873 if (mips32_cache - mips32_tlb_miss != 0x100) 873 if (mips32_cache - mips32_tlb_miss != 0x100)
874 panic("startup: %s vector code not 128 bytes in length", 874 panic("startup: %s vector code not 128 bytes in length",
875 "UTLB"); 875 "UTLB");
876 if (mips32_exception - mips32_cache != 0x80) 876 if (mips32_exception - mips32_cache != 0x80)
877 panic("startup: %s vector code not 128 bytes in length", 877 panic("startup: %s vector code not 128 bytes in length",
878 "Cache error"); 878 "Cache error");
879 if (mips32_intr - mips32_exception != 0x80) 879 if (mips32_intr - mips32_exception != 0x80)
880 panic("startup: %s vector code not 128 bytes in length", 880 panic("startup: %s vector code not 128 bytes in length",
881 "General exception"); 881 "General exception");
882 if (mips32_intr_end - mips32_intr > 0x80) 882 if (mips32_intr_end - mips32_intr > 0x80)
883 panic("startup: %s vector code too large", 883 panic("startup: %s vector code too large",
884 "interrupt exception"); 884 "interrupt exception");
885 885
886 memcpy((void *)MIPS_UTLB_MISS_EXC_VEC, mips32_tlb_miss, 886 memcpy((void *)MIPS_UTLB_MISS_EXC_VEC, mips32_tlb_miss,
887 mips32_intr_end - mips32_tlb_miss); 887 mips32_intr_end - mips32_tlb_miss);
888 888
889 /* 889 /*
890 * Copy locore-function vector. 890 * Copy locore-function vector.
891 */ 891 */
892 mips_locore_jumpvec = mips32_locore_vec; 892 mips_locore_jumpvec = mips32_locore_vec;
893 893
894 mips_icache_sync_all(); 894 mips_icache_sync_all();
895 mips_dcache_wbinv_all(); 895 mips_dcache_wbinv_all();
896 896
897 /* Clear BEV in SR so we start handling our own exceptions */ 897 /* Clear BEV in SR so we start handling our own exceptions */
898 mips_cp0_status_write(mips_cp0_status_read() & ~MIPS_SR_BEV); 898 mips_cp0_status_write(mips_cp0_status_read() & ~MIPS_SR_BEV);
899 899
900 mips_watchpoint_init(); 900 mips_watchpoint_init();
901} 901}
902#endif /* MIPS32 */ 902#endif /* MIPS32 */
903 903
904#if defined(MIPS32R2) 904#if defined(MIPS32R2)
905static void 905static void
906mips32r2_vector_init(const struct splsw *splsw) 906mips32r2_vector_init(const struct splsw *splsw)
907{ 907{
908 /* r4000 exception handler address */ 908 /* r4000 exception handler address */
909 extern char mips32r2_exception[]; 909 extern char mips32r2_exception[];
910 910
911 /* TLB miss handler addresses */ 911 /* TLB miss handler addresses */
912 extern char mips32r2_tlb_miss[]; 912 extern char mips32r2_tlb_miss[];
913 913
914 /* Cache error handler */ 914 /* Cache error handler */
915 extern char mips32r2_cache[]; 915 extern char mips32r2_cache[];
916 916
917 /* MIPS32 interrupt exception handler */ 917 /* MIPS32 interrupt exception handler */
918 extern char mips32r2_intr[], mips32r2_intr_end[]; 918 extern char mips32r2_intr[], mips32r2_intr_end[];
919 919
920 /* 920 /*
921 * Copy down exception vector code. 921 * Copy down exception vector code.
922 */ 922 */
923 if (mips32r2_cache - mips32r2_tlb_miss != 0x100) 923 if (mips32r2_cache - mips32r2_tlb_miss != 0x100)
924 panic("startup: %s vector code not 128 bytes in length", 924 panic("startup: %s vector code not 128 bytes in length",
925 "UTLB"); 925 "UTLB");
926 if (mips32r2_exception - mips32r2_cache != 0x80) 926 if (mips32r2_exception - mips32r2_cache != 0x80)
927 panic("startup: %s vector code not 128 bytes in length", 927 panic("startup: %s vector code not 128 bytes in length",
928 "Cache error"); 928 "Cache error");
929 if (mips32r2_intr - mips32r2_exception != 0x80) 929 if (mips32r2_intr - mips32r2_exception != 0x80)
930 panic("startup: %s vector code not 128 bytes in length", 930 panic("startup: %s vector code not 128 bytes in length",
931 "General exception"); 931 "General exception");
932 if (mips32r2_intr_end - mips32r2_intr > 0x80) 932 if (mips32r2_intr_end - mips32r2_intr > 0x80)
933 panic("startup: %s vector code too large", 933 panic("startup: %s vector code too large",
934 "interrupt exception"); 934 "interrupt exception");
935 935
936 memcpy((void *)MIPS_UTLB_MISS_EXC_VEC, mips32r2_tlb_miss, 936 memcpy((void *)MIPS_UTLB_MISS_EXC_VEC, mips32r2_tlb_miss,
937 mips32r2_intr_end - mips32r2_tlb_miss); 937 mips32r2_intr_end - mips32r2_tlb_miss);
938 938
939 /* 939 /*
940 * Let's see if this cpu has USERLOCAL or DSP V2 ASE... 940 * Let's see if this cpu has USERLOCAL or DSP V2 ASE...
941 */ 941 */
942 if (mipsNN_cp0_config2_read() & MIPSNN_CFG2_M) { 942 if (mipsNN_cp0_config2_read() & MIPSNN_CFG2_M) {
943 const uint32_t cfg3 = mipsNN_cp0_config3_read(); 943 const uint32_t cfg3 = mipsNN_cp0_config3_read();
944 if (cfg3 & MIPSNN_CFG3_ULRI) { 944 if (cfg3 & MIPSNN_CFG3_ULRI) {
945 mips_options.mips_cpu_flags |= CPU_MIPS_HAVE_USERLOCAL; 945 mips_options.mips_cpu_flags |= CPU_MIPS_HAVE_USERLOCAL;
946 } 946 }
947 if (cfg3 & MIPSNN_CFG3_DSP2P) { 947 if (cfg3 & MIPSNN_CFG3_DSP2P) {
948 mips_options.mips_cpu_flags |= CPU_MIPS_HAVE_DSP; 948 mips_options.mips_cpu_flags |= CPU_MIPS_HAVE_DSP;
949 } 949 }
950 } 950 }
951 951
952 /* 952 /*
953 * If this CPU doesn't have a COP0 USERLOCAL register, at the end 953 * If this CPU doesn't have a COP0 USERLOCAL register, at the end
954 * of cpu_switch resume overwrite the instructions which update it. 954 * of cpu_switch resume overwrite the instructions which update it.
955 */ 955 */
956 if (!MIPS_HAS_USERLOCAL) { 956 if (!MIPS_HAS_USERLOCAL) {
957 extern uint32_t mips32r2_cpu_switch_resume[]; 957 extern uint32_t mips32r2_cpu_switch_resume[];
958 for (uint32_t *insnp = mips32r2_cpu_switch_resume;; insnp++) { 958 for (uint32_t *insnp = mips32r2_cpu_switch_resume;; insnp++) {
959 KASSERT(insnp[0] != JR_RA); 959 KASSERT(insnp[0] != JR_RA);
960 if (insnp[0] == _LOAD_V0_L_PRIVATE_A0 960 if (insnp[0] == _LOAD_V0_L_PRIVATE_A0
961 && insnp[1] == _MTC0_V0_USERLOCAL) { 961 && insnp[1] == _MTC0_V0_USERLOCAL) {
962 insnp[0] = JR_RA; 962 insnp[0] = JR_RA;
963 insnp[1] = 0; /* NOP */ 963 insnp[1] = 0; /* NOP */
964 break; 964 break;
965 } 965 }
966 } 966 }
967 } 967 }
968 968
969 /* 969 /*
970 * Copy locore-function vector. 970 * Copy locore-function vector.
971 */ 971 */
972 mips_locore_jumpvec = mips32r2_locore_vec; 972 mips_locore_jumpvec = mips32r2_locore_vec;
973 973
974 mips_icache_sync_all(); 974 mips_icache_sync_all();
975 mips_dcache_wbinv_all(); 975 mips_dcache_wbinv_all();
976 976
977 /* Clear BEV in SR so we start handling our own exceptions */ 977 /* Clear BEV in SR so we start handling our own exceptions */
978 mips_cp0_status_write(mips_cp0_status_read() & ~MIPS_SR_BEV); 978 mips_cp0_status_write(mips_cp0_status_read() & ~MIPS_SR_BEV);
979 979
980 mips_watchpoint_init(); 980 mips_watchpoint_init();
981} 981}
982#endif /* MIPS32R2 */ 982#endif /* MIPS32R2 */
983 983
984#if defined(MIPS64) 984#if defined(MIPS64)
985static void 985static void
986mips64_vector_init(const struct splsw *splsw) 986mips64_vector_init(const struct splsw *splsw)
987{ 987{
988 /* r4000 exception handler address */ 988 /* r4000 exception handler address */
989 extern char mips64_exception[]; 989 extern char mips64_exception[];
990 990
991 /* TLB miss handler addresses */ 991 /* TLB miss handler addresses */
992 extern char mips64_tlb_miss[]; 992 extern char mips64_tlb_miss[];
993 extern char mips64_xtlb_miss[]; 993 extern char mips64_xtlb_miss[];
994 994
995 /* Cache error handler */ 995 /* Cache error handler */
996 extern char mips64_cache[]; 996 extern char mips64_cache[];
997 997
998 /* MIPS64 interrupt exception handler */ 998 /* MIPS64 interrupt exception handler */
999 extern char mips64_intr[], mips64_intr_end[]; 999 extern char mips64_intr[], mips64_intr_end[];
1000 1000
1001 /* 1001 /*
1002 * Copy down exception vector code. 1002 * Copy down exception vector code.
1003 */ 1003 */
1004 1004
1005 if (mips64_xtlb_miss - mips64_tlb_miss != 0x80) 1005 if (mips64_xtlb_miss - mips64_tlb_miss != 0x80)
1006 panic("startup: %s vector code not 128 bytes in length", 1006 panic("startup: %s vector code not 128 bytes in length",
1007 "UTLB"); 1007 "UTLB");
1008 if (mips64_cache - mips64_xtlb_miss != 0x80) 1008 if (mips64_cache - mips64_xtlb_miss != 0x80)
1009 panic("startup: %s vector code not 128 bytes in length", 1009 panic("startup: %s vector code not 128 bytes in length",
1010 "XTLB"); 1010 "XTLB");
1011 if (mips64_exception - mips64_cache != 0x80) 1011 if (mips64_exception - mips64_cache != 0x80)
1012 panic("startup: %s vector code not 128 bytes in length", 1012 panic("startup: %s vector code not 128 bytes in length",
1013 "Cache error"); 1013 "Cache error");
1014 if (mips64_intr - mips64_exception != 0x80) 1014 if (mips64_intr - mips64_exception != 0x80)
1015 panic("startup: %s vector code not 128 bytes in length", 1015 panic("startup: %s vector code not 128 bytes in length",
1016 "General exception"); 1016 "General exception");
1017 if (mips64_intr_end - mips64_intr > 0x80) 1017 if (mips64_intr_end - mips64_intr > 0x80)
1018 panic("startup: %s vector code too large", 1018 panic("startup: %s vector code too large",
1019 "interrupt exception"); 1019 "interrupt exception");
1020 1020
1021 memcpy((void *)MIPS_UTLB_MISS_EXC_VEC, mips64_tlb_miss, 1021 memcpy((void *)MIPS_UTLB_MISS_EXC_VEC, mips64_tlb_miss,
1022 mips64_intr_end - mips64_tlb_miss); 1022 mips64_intr_end - mips64_tlb_miss);
1023 1023
1024 /* 1024 /*
1025 * Copy locore-function vector. 1025 * Copy locore-function vector.
1026 */ 1026 */
1027 mips_locore_jumpvec = mips64_locore_vec; 1027 mips_locore_jumpvec = mips64_locore_vec;
1028 1028
1029 mips_icache_sync_all(); 1029 mips_icache_sync_all();
1030 mips_dcache_wbinv_all(); 1030 mips_dcache_wbinv_all();
1031 1031
1032 /* Clear BEV in SR so we start handling our own exceptions */ 1032 /* Clear BEV in SR so we start handling our own exceptions */
1033 mips_cp0_status_write(mips_cp0_status_read() & ~MIPS_SR_BEV); 1033 mips_cp0_status_write(mips_cp0_status_read() & ~MIPS_SR_BEV);
1034 1034
1035 mips_watchpoint_init(); 1035 mips_watchpoint_init();
1036} 1036}
1037#endif /* MIPS64 */ 1037#endif /* MIPS64 */
1038 1038
1039#if defined(MIPS64R2) 1039#if defined(MIPS64R2)
1040void 1040void
1041mips64r2_vector_init(const struct splsw *splsw) 1041mips64r2_vector_init(const struct splsw *splsw)
1042{ 1042{
1043 /* r4000 exception handler address */ 1043 /* r4000 exception handler address */
1044 extern char mips64r2_exception[]; 1044 extern char mips64r2_exception[];
1045 1045
1046 /* TLB miss handler addresses */ 1046 /* TLB miss handler addresses */
1047 extern char mips64r2_tlb_miss[]; 1047 extern char mips64r2_tlb_miss[];
1048 extern char mips64r2_xtlb_miss[]; 1048 extern char mips64r2_xtlb_miss[];
1049 1049
1050 /* Cache error handler */ 1050 /* Cache error handler */
1051 extern char mips64r2_cache[]; 1051 extern char mips64r2_cache[];
1052 1052
1053 /* MIPS64 interrupt exception handler */ 1053 /* MIPS64 interrupt exception handler */
1054 extern char mips64r2_intr[], mips64r2_intr_end[]; 1054 extern char mips64r2_intr[], mips64r2_intr_end[];
1055 1055
1056 /* 1056 /*
1057 * Copy down exception vector code. 1057 * Copy down exception vector code.
1058 */ 1058 */
1059 1059
1060 if (mips64r2_xtlb_miss - mips64r2_tlb_miss != 0x80) 1060 if (mips64r2_xtlb_miss - mips64r2_tlb_miss != 0x80)
1061 panic("startup: %s vector code not 128 bytes in length", 1061 panic("startup: %s vector code not 128 bytes in length",
1062 "UTLB"); 1062 "UTLB");
1063 if (mips64r2_cache - mips64r2_xtlb_miss != 0x80) 1063 if (mips64r2_cache - mips64r2_xtlb_miss != 0x80)
1064 panic("startup: %s vector code not 128 bytes in length", 1064 panic("startup: %s vector code not 128 bytes in length",
1065 "XTLB"); 1065 "XTLB");
1066 if (mips64r2_exception - mips64r2_cache != 0x80) 1066 if (mips64r2_exception - mips64r2_cache != 0x80)
1067 panic("startup: %s vector code not 128 bytes in length", 1067 panic("startup: %s vector code not 128 bytes in length",
1068 "Cache error"); 1068 "Cache error");
1069 if (mips64r2_intr - mips64r2_exception != 0x80) 1069 if (mips64r2_intr - mips64r2_exception != 0x80)
1070 panic("startup: %s vector code not 128 bytes in length", 1070 panic("startup: %s vector code not 128 bytes in length",
1071 "General exception"); 1071 "General exception");
1072 if (mips64r2_intr_end - mips64r2_intr > 0x80) 1072 if (mips64r2_intr_end - mips64r2_intr > 0x80)
1073 panic("startup: %s vector code too large", 1073 panic("startup: %s vector code too large",
1074 "interrupt exception"); 1074 "interrupt exception");
1075 1075
1076 const intptr_t ebase = (intptr_t)mipsNN_cp0_ebase_read(); 1076 const intptr_t ebase = (intptr_t)mipsNN_cp0_ebase_read();
1077 const int cpunum = ebase & MIPS_EBASE_CPUNUM; 1077 const int cpunum = ebase & MIPS_EBASE_CPUNUM;
1078 1078
1079 // This may need to be on CPUs other CPU0 so use EBASE to fetch 1079 // This may need to be on CPUs other CPU0 so use EBASE to fetch
1080 // the appropriate address for exception code. EBASE also contains 1080 // the appropriate address for exception code. EBASE also contains
1081 // the cpunum so remove that. 1081 // the cpunum so remove that.
1082 memcpy((void *)(intptr_t)(ebase & ~MIPS_EBASE_CPUNUM), mips64r2_tlb_miss, 1082 memcpy((void *)(intptr_t)(ebase & ~MIPS_EBASE_CPUNUM), mips64r2_tlb_miss,
1083 mips64r2_intr_end - mips64r2_tlb_miss); 1083 mips64r2_intr_end - mips64r2_tlb_miss);
1084 1084
1085 /* 1085 /*
1086 * Let's see if this cpu has USERLOCAL or DSP V2 ASE... 1086 * Let's see if this cpu has USERLOCAL or DSP V2 ASE...
1087 */ 1087 */
1088 if (mipsNN_cp0_config2_read() & MIPSNN_CFG2_M) { 1088 if (mipsNN_cp0_config2_read() & MIPSNN_CFG2_M) {
1089 const uint32_t cfg3 = mipsNN_cp0_config3_read(); 1089 const uint32_t cfg3 = mipsNN_cp0_config3_read();
1090 if (cfg3 & MIPSNN_CFG3_ULRI) { 1090 if (cfg3 & MIPSNN_CFG3_ULRI) {
1091 mips_options.mips_cpu_flags |= CPU_MIPS_HAVE_USERLOCAL; 1091 mips_options.mips_cpu_flags |= CPU_MIPS_HAVE_USERLOCAL;
1092 } 1092 }
1093 if (cfg3 & MIPSNN_CFG3_DSP2P) { 1093 if (cfg3 & MIPSNN_CFG3_DSP2P) {
1094 mips_options.mips_cpu_flags |= CPU_MIPS_HAVE_DSP; 1094 mips_options.mips_cpu_flags |= CPU_MIPS_HAVE_DSP;
1095 } 1095 }
1096 } 1096 }
1097 1097
1098 /* 1098 /*
1099 * If this CPU doesn't have a COP0 USERLOCAL register, at the end 1099 * If this CPU doesn't have a COP0 USERLOCAL register, at the end
1100 * of cpu_switch resume overwrite the instructions which update it. 1100 * of cpu_switch resume overwrite the instructions which update it.
1101 */ 1101 */
1102 if (!MIPS_HAS_USERLOCAL && cpunum == 0) { 1102 if (!MIPS_HAS_USERLOCAL && cpunum == 0) {
1103 extern uint32_t mips64r2_cpu_switch_resume[]; 1103 extern uint32_t mips64r2_cpu_switch_resume[];
1104 for (uint32_t *insnp = mips64r2_cpu_switch_resume;; insnp++) { 1104 for (uint32_t *insnp = mips64r2_cpu_switch_resume;; insnp++) {
1105 KASSERT(insnp[0] != JR_RA); 1105 KASSERT(insnp[0] != JR_RA);
1106 if (insnp[0] == _LOAD_V0_L_PRIVATE_A0 1106 if (insnp[0] == _LOAD_V0_L_PRIVATE_A0
1107 && insnp[1] == _MTC0_V0_USERLOCAL) { 1107 && insnp[1] == _MTC0_V0_USERLOCAL) {
1108 insnp[0] = JR_RA; 1108 insnp[0] = JR_RA;
1109 insnp[1] = 0; /* NOP */ 1109 insnp[1] = 0; /* NOP */
1110 break; 1110 break;
1111 } 1111 }
1112 } 1112 }
1113 } 1113 }
1114 1114
1115 /* 1115 /*
1116 * Copy locore-function vector. 1116 * Copy locore-function vector.
1117 */ 1117 */
1118 if (cpunum == 0) 1118 if (cpunum == 0)
1119 mips_locore_jumpvec = mips64r2_locore_vec; 1119 mips_locore_jumpvec = mips64r2_locore_vec;
1120 1120
1121 mips_icache_sync_all(); 1121 mips_icache_sync_all();
1122 mips_dcache_wbinv_all(); 1122 mips_dcache_wbinv_all();
1123 1123
1124 /* Clear BEV in SR so we start handling our own exceptions */ 1124 /* Clear BEV in SR so we start handling our own exceptions */
1125 mips_cp0_status_write(mips_cp0_status_read() & ~MIPS_SR_BEV); 1125 mips_cp0_status_write(mips_cp0_status_read() & ~MIPS_SR_BEV);
1126 1126
1127 mips_watchpoint_init(); 1127 mips_watchpoint_init();
1128} 1128}
1129#endif /* MIPS64R2 */ 1129#endif /* MIPS64R2 */
1130 1130
1131/* 1131/*
1132 * Do all the stuff that locore normally does before calling main(), 1132 * Do all the stuff that locore normally does before calling main(),
1133 * that is common to all mips-CPU NetBSD ports. 1133 * that is common to all mips-CPU NetBSD ports.
1134 * 1134 *
1135 * The principal purpose of this function is to examine the 1135 * The principal purpose of this function is to examine the
1136 * variable cpu_id, into which the kernel locore start code 1136 * variable cpu_id, into which the kernel locore start code
1137 * writes the CPU ID register, and to then copy appropriate 1137 * writes the CPU ID register, and to then copy appropriate
1138 * code into the CPU exception-vector entries and the jump tables 1138 * code into the CPU exception-vector entries and the jump tables
1139 * used to hide the differences in cache and TLB handling in 1139 * used to hide the differences in cache and TLB handling in
1140 * different MIPS CPUs. 1140 * different MIPS CPUs.
1141 * 1141 *
1142 * This should be the very first thing called by each port's 1142 * This should be the very first thing called by each port's
1143 * init_main() function. 1143 * init_main() function.
1144 */ 1144 */
1145 1145
1146/* 1146/*
1147 * Initialize the hardware exception vectors, and the jump table used to 1147 * Initialize the hardware exception vectors, and the jump table used to
1148 * call locore cache and TLB management functions, based on the kind 1148 * call locore cache and TLB management functions, based on the kind
1149 * of CPU the kernel is running on. 1149 * of CPU the kernel is running on.
1150 */ 1150 */
1151void 1151void
1152mips_vector_init(const struct splsw *splsw, bool multicpu_p) 1152mips_vector_init(const struct splsw *splsw, bool multicpu_p)
1153{ 1153{
1154 struct mips_options * const opts = &mips_options; 1154 struct mips_options * const opts = &mips_options;
1155 const struct pridtab *ct; 1155 const struct pridtab *ct;
1156 const mips_prid_t cpu_id = opts->mips_cpu_id; 1156 const mips_prid_t cpu_id = opts->mips_cpu_id;
1157 1157
1158 for (ct = cputab; ct->cpu_name != NULL; ct++) { 1158 for (ct = cputab; ct->cpu_name != NULL; ct++) {
1159 if (MIPS_PRID_CID(cpu_id) != ct->cpu_cid || 1159 if (MIPS_PRID_CID(cpu_id) != ct->cpu_cid ||
1160 MIPS_PRID_IMPL(cpu_id) != ct->cpu_pid) 1160 MIPS_PRID_IMPL(cpu_id) != ct->cpu_pid)
1161 continue; 1161 continue;
1162 if (ct->cpu_rev >= 0 && 1162 if (ct->cpu_rev >= 0 &&
1163 MIPS_PRID_REV(cpu_id) != ct->cpu_rev) 1163 MIPS_PRID_REV(cpu_id) != ct->cpu_rev)
1164 continue; 1164 continue;
1165 if (ct->cpu_copts >= 0 && 1165 if (ct->cpu_copts >= 0 &&
1166 MIPS_PRID_COPTS(cpu_id) != ct->cpu_copts) 1166 MIPS_PRID_COPTS(cpu_id) != ct->cpu_copts)
1167 continue; 1167 continue;
1168 1168
1169 opts->mips_cpu = ct; 1169 opts->mips_cpu = ct;
1170 opts->mips_cpu_arch = ct->cpu_isa; 1170 opts->mips_cpu_arch = ct->cpu_isa;
1171 opts->mips_num_tlb_entries = ct->cpu_ntlb; 1171 opts->mips_num_tlb_entries = ct->cpu_ntlb;
1172 break; 1172 break;
1173 } 1173 }
1174 1174
1175 if (opts->mips_cpu == NULL) 1175 if (opts->mips_cpu == NULL)
1176 panic("CPU type (0x%x) not supported", cpu_id); 1176 panic("CPU type (0x%x) not supported", cpu_id);
1177 1177
1178#if (MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0 1178#if (MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0
1179 if (MIPS_PRID_CID(cpu_id) != 0) { 1179 if (MIPS_PRID_CID(cpu_id) != 0) {
1180 /* MIPS32/MIPS64, use coprocessor 0 config registers */ 1180 /* MIPS32/MIPS64, use coprocessor 0 config registers */
1181 uint32_t cfg, cfg1, cfg4; 1181 uint32_t cfg, cfg1, cfg4;
1182 1182
1183 cfg = mips3_cp0_config_read(); 1183 cfg = mips3_cp0_config_read();
1184 cfg1 = mipsNN_cp0_config1_read(); 1184 cfg1 = mipsNN_cp0_config1_read();
1185 if (opts->mips_cpu->cpu_cp0flags & MIPS_CP0FL_CONFIG4) 1185 if (opts->mips_cpu->cpu_cp0flags & MIPS_CP0FL_CONFIG4)
1186 cfg4 = mipsNN_cp0_config4_read(); 1186 cfg4 = mipsNN_cp0_config4_read();
1187 else 1187 else
1188 cfg4 = 0; 1188 cfg4 = 0;
1189 1189
1190 /* pick CPU type */ 1190 /* pick CPU type */
1191 switch (MIPSNN_GET(CFG_AT, cfg)) { 1191 switch (MIPSNN_GET(CFG_AT, cfg)) {
1192 case MIPSNN_CFG_AT_MIPS32: 1192 case MIPSNN_CFG_AT_MIPS32:
1193 opts->mips_cpu_arch = CPU_ARCH_MIPS32; 1193 opts->mips_cpu_arch = CPU_ARCH_MIPS32;
1194 break; 1194 break;
1195 case MIPSNN_CFG_AT_MIPS64: 1195 case MIPSNN_CFG_AT_MIPS64:
1196 opts->mips_cpu_arch = CPU_ARCH_MIPS64; 1196 opts->mips_cpu_arch = CPU_ARCH_MIPS64;
1197 break; 1197 break;
1198 case MIPSNN_CFG_AT_MIPS64S: 1198 case MIPSNN_CFG_AT_MIPS64S:
1199 default: 1199 default:
1200 panic("MIPS32/64 architecture type %d not supported", 1200 panic("MIPS32/64 architecture type %d not supported",
1201 MIPSNN_GET(CFG_AT, cfg)); 1201 MIPSNN_GET(CFG_AT, cfg));
1202 } 1202 }
1203 1203
1204 switch (MIPSNN_GET(CFG_AR, cfg)) { 1204 switch (MIPSNN_GET(CFG_AR, cfg)) {
1205 case MIPSNN_CFG_AR_REV1: 1205 case MIPSNN_CFG_AR_REV1:
1206 break; 1206 break;
1207 case MIPSNN_CFG_AR_REV2: 1207 case MIPSNN_CFG_AR_REV2:
1208 switch (opts->mips_cpu_arch) { 1208 switch (opts->mips_cpu_arch) {
1209 case CPU_ARCH_MIPS32: 1209 case CPU_ARCH_MIPS32:
1210 opts->mips_cpu_arch = CPU_ARCH_MIPS32R2; 1210 opts->mips_cpu_arch = CPU_ARCH_MIPS32R2;
1211 break; 1211 break;
1212 case CPU_ARCH_MIPS64: 1212 case CPU_ARCH_MIPS64:
1213 opts->mips_cpu_arch = CPU_ARCH_MIPS64R2; 1213 opts->mips_cpu_arch = CPU_ARCH_MIPS64R2;
1214 break; 1214 break;
1215 default: 1215 default:
1216 printf("WARNING: MIPS32/64 arch %d revision %d " 1216 printf("WARNING: MIPS32/64 arch %d revision %d "
1217 "unknown!\n", opts->mips_cpu_arch, 1217 "unknown!\n", opts->mips_cpu_arch,
1218 MIPSNN_GET(CFG_AR, cfg)); 1218 MIPSNN_GET(CFG_AR, cfg));
1219 break; 1219 break;
1220 } 1220 }
1221 break; 1221 break;
1222 default: 1222 default:
1223 printf("WARNING: MIPS32/64 arch revision %d " 1223 printf("WARNING: MIPS32/64 arch revision %d "
1224 "unknown!\n", MIPSNN_GET(CFG_AR, cfg)); 1224 "unknown!\n", MIPSNN_GET(CFG_AR, cfg));
1225 break; 1225 break;
1226 } 1226 }
1227 1227
1228 /* figure out MMU type (and number of TLB entries) */ 1228 /* figure out MMU type (and number of TLB entries) */
1229 switch (MIPSNN_GET(CFG_MT, cfg)) { 1229 switch (MIPSNN_GET(CFG_MT, cfg)) {
1230 case MIPSNN_CFG_MT_TLB: 1230 case MIPSNN_CFG_MT_TLB:
1231 /* 1231 /*
1232 * Config1[MMUSize-1] defines the number of TLB 1232 * Config1[MMUSize-1] defines the number of TLB
1233 * entries minus 1, allowing up to 64 TLBs to be 1233 * entries minus 1, allowing up to 64 TLBs to be
1234 * defined. For MIPS32R2 and MIPS64R2 and later 1234 * defined. For MIPS32R2 and MIPS64R2 and later
1235 * if the Config4[MMUExtDef] field is 1 then the 1235 * if the Config4[MMUExtDef] field is 1 then the
1236 * Config4[MMUSizeExt] field is an extension of 1236 * Config4[MMUSizeExt] field is an extension of
1237 * Config1[MMUSize-1] field. 1237 * Config1[MMUSize-1] field.
1238 */ 1238 */
1239 opts->mips_num_tlb_entries = MIPSNN_CFG1_MS(cfg1); 1239 opts->mips_num_tlb_entries = MIPSNN_CFG1_MS(cfg1);
1240 if (__SHIFTOUT(cfg4, MIPSNN_CFG4_MMU_EXT_DEF) == 1240 if (__SHIFTOUT(cfg4, MIPSNN_CFG4_MMU_EXT_DEF) ==
1241 MIPSNN_CFG4_MMU_EXT_DEF_MMU) { 1241 MIPSNN_CFG4_MMU_EXT_DEF_MMU) {
1242 opts->mips_num_tlb_entries += 1242 opts->mips_num_tlb_entries +=
1243 __SHIFTOUT(cfg4, MIPSNN_CFG4_MMU_SIZE_EXT) << 1243 __SHIFTOUT(cfg4, MIPSNN_CFG4_MMU_SIZE_EXT) <<
1244 popcount(MIPSNN_CFG1_MS_MASK); 1244 popcount(MIPSNN_CFG1_MS_MASK);
1245 } 1245 }
1246 break; 1246 break;
1247 case MIPSNN_CFG_MT_NONE: 1247 case MIPSNN_CFG_MT_NONE:
1248 case MIPSNN_CFG_MT_BAT: 1248 case MIPSNN_CFG_MT_BAT:
1249 case MIPSNN_CFG_MT_FIXED: 1249 case MIPSNN_CFG_MT_FIXED:
1250 default: 1250 default:
1251 panic("MIPS32/64 MMU type %d not supported", 1251 panic("MIPS32/64 MMU type %d not supported",
1252 MIPSNN_GET(CFG_MT, cfg)); 1252 MIPSNN_GET(CFG_MT, cfg));
1253 } 1253 }
1254 } 1254 }
1255#endif /* (MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0 */ 1255#endif /* (MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0 */
1256 1256
1257 if (opts->mips_cpu_arch < 1) 1257 if (opts->mips_cpu_arch < 1)
1258 panic("Unknown CPU ISA for CPU type 0x%x", cpu_id); 1258 panic("Unknown CPU ISA for CPU type 0x%x", cpu_id);
1259 if (opts->mips_num_tlb_entries < 1) 1259 if (opts->mips_num_tlb_entries < 1)
1260 panic("Unknown number of TLBs for CPU type 0x%x", cpu_id); 1260 panic("Unknown number of TLBs for CPU type 0x%x", cpu_id);
1261 1261
1262 /* 1262 /*
1263 * Check CPU-specific flags. 1263 * Check CPU-specific flags.
1264 */ 1264 */
1265 opts->mips_cpu_flags = opts->mips_cpu->cpu_flags; 1265 opts->mips_cpu_flags = opts->mips_cpu->cpu_flags;
1266 opts->mips_has_r4k_mmu = (opts->mips_cpu_flags & CPU_MIPS_R4K_MMU) != 0; 1266 opts->mips_has_r4k_mmu = (opts->mips_cpu_flags & CPU_MIPS_R4K_MMU) != 0;
1267 opts->mips_has_llsc = (opts->mips_cpu_flags & CPU_MIPS_NO_LLSC) == 0; 1267 opts->mips_has_llsc = (opts->mips_cpu_flags & CPU_MIPS_NO_LLSC) == 0;
1268#if defined(MIPS3_4100) 1268#if defined(MIPS3_4100)
1269 if (MIPS_PRID_IMPL(cpu_id) == MIPS_R4100) 1269 if (MIPS_PRID_IMPL(cpu_id) == MIPS_R4100)
1270 opts->mips3_pg_shift = MIPS3_4100_PG_SHIFT; 1270 opts->mips3_pg_shift = MIPS3_4100_PG_SHIFT;
1271 else 1271 else
1272#endif 1272#endif
1273 opts->mips3_pg_shift = MIPS3_DEFAULT_PG_SHIFT; 1273 opts->mips3_pg_shift = MIPS3_DEFAULT_PG_SHIFT;
1274 1274
1275 opts->mips3_cca_devmem = CCA_UNCACHED; 1275 opts->mips3_cca_devmem = CCA_UNCACHED;
1276 if (opts->mips_cpu_flags & CPU_MIPS_HAVE_SPECIAL_CCA) { 1276 if (opts->mips_cpu_flags & CPU_MIPS_HAVE_SPECIAL_CCA) {
1277 uint32_t cca; 1277 uint32_t cca;
1278 1278
1279 cca = (opts->mips_cpu_flags & CPU_MIPS_CACHED_CCA_MASK) >> 1279 cca = (opts->mips_cpu_flags & CPU_MIPS_CACHED_CCA_MASK) >>
1280 CPU_MIPS_CACHED_CCA_SHIFT; 1280 CPU_MIPS_CACHED_CCA_SHIFT;
1281 opts->mips3_pg_cached = MIPS3_CCA_TO_PG(cca); 1281 opts->mips3_pg_cached = MIPS3_CCA_TO_PG(cca);
1282#ifndef __mips_o32 1282#ifndef __mips_o32
1283 opts->mips3_xkphys_cached = MIPS_PHYS_TO_XKPHYS(cca, 0); 1283 opts->mips3_xkphys_cached = MIPS_PHYS_TO_XKPHYS(cca, 0);
1284#endif 1284#endif
1285 } else { 1285 } else {
1286 opts->mips3_pg_cached = MIPS3_DEFAULT_PG_CACHED; 1286 opts->mips3_pg_cached = MIPS3_DEFAULT_PG_CACHED;
1287#ifndef __mips_o32 1287#ifndef __mips_o32
1288 opts->mips3_xkphys_cached = MIPS3_DEFAULT_XKPHYS_CACHED; 1288 opts->mips3_xkphys_cached = MIPS3_DEFAULT_XKPHYS_CACHED;
1289#endif 1289#endif
1290 } 1290 }
1291 1291
1292#ifdef __HAVE_MIPS_MACHDEP_CACHE_CONFIG 1292#ifdef __HAVE_MIPS_MACHDEP_CACHE_CONFIG
1293 mips_machdep_cache_config(); 1293 mips_machdep_cache_config();
1294#endif 1294#endif
1295 1295
1296 /* 1296 /*
1297 * if 'splsw' is NULL, use standard SPL with COP0 status/cause 1297 * if 'splsw' is NULL, use standard SPL with COP0 status/cause
1298 * otherwise use chip-specific splsw 1298 * otherwise use chip-specific splsw
1299 */ 1299 */
1300 if (splsw == NULL) { 1300 if (splsw == NULL) {
1301 mips_splsw = std_splsw; 1301 mips_splsw = std_splsw;
1302#ifdef PARANOIA 1302#ifdef PARANOIA
1303 std_splsw_test(); /* only works with std_splsw */ 1303 std_splsw_test(); /* only works with std_splsw */
1304#endif 1304#endif
1305 } else { 1305 } else {
1306 mips_splsw = *splsw; 1306 mips_splsw = *splsw;
1307 } 1307 }
1308 1308
1309 /* 1309 /*
1310 * Determine cache configuration and initialize our cache 1310 * Determine cache configuration and initialize our cache
1311 * frobbing routine function pointers. 1311 * frobbing routine function pointers.
1312 */ 1312 */
1313 mips_config_cache(); 1313 mips_config_cache();
1314 1314
1315 /* 1315 /*
1316 * We default to RAS atomic ops since they are the lowest overhead. 1316 * We default to RAS atomic ops since they are the lowest overhead.
1317 */ 1317 */
1318#ifdef MULTIPROCESSOR 1318#ifdef MULTIPROCESSOR
1319 if (multicpu_p) { 1319 if (multicpu_p) {
1320 /* 1320 /*
1321 * If we could have multiple CPUs active, 1321 * If we could have multiple CPUs active,
1322 * use the ll/sc variants. 1322 * use the ll/sc variants.
1323 */ 1323 */
1324 mips_locore_atomicvec = mips_llsc_locore_atomicvec; 1324 mips_locore_atomicvec = mips_llsc_locore_atomicvec;
1325 } 1325 }
1326#endif 1326#endif
1327 /* 1327 /*
1328 * Now initialize our ISA-dependent function vector. 1328 * Now initialize our ISA-dependent function vector.
1329 */ 1329 */
1330 switch (opts->mips_cpu_arch) { 1330 switch (opts->mips_cpu_arch) {
1331#if defined(MIPS1) 1331#if defined(MIPS1)
1332 case CPU_ARCH_MIPS1: 1332 case CPU_ARCH_MIPS1:
1333 (*mips1_locore_vec.ljv_tlb_invalidate_all)(); 1333 (*mips1_locore_vec.ljv_tlb_invalidate_all)();
1334 mips1_vector_init(splsw); 1334 mips1_vector_init(splsw);
1335 mips_locoresw = mips1_locoresw; 1335 mips_locoresw = mips1_locoresw;
1336 break; 1336 break;
1337#endif 1337#endif
1338#if defined(MIPS3) 1338#if defined(MIPS3)
1339 case CPU_ARCH_MIPS3: 1339 case CPU_ARCH_MIPS3:
1340 case CPU_ARCH_MIPS4: 1340 case CPU_ARCH_MIPS4:
1341 mips3_tlb_probe(); 1341 mips3_tlb_probe();
1342#if defined(MIPS3_4100) 1342#if defined(MIPS3_4100)
1343 if (MIPS_PRID_IMPL(cpu_id) == MIPS_R4100) 1343 if (MIPS_PRID_IMPL(cpu_id) == MIPS_R4100)
1344 mips3_cp0_pg_mask_write(MIPS4100_PG_SIZE_TO_MASK(PAGE_SIZE)); 1344 mips3_cp0_pg_mask_write(MIPS4100_PG_SIZE_TO_MASK(PAGE_SIZE));
1345 else 1345 else
1346#endif 1346#endif
1347 mips3_cp0_pg_mask_write(MIPS3_PG_SIZE_TO_MASK(PAGE_SIZE)); 1347 mips3_cp0_pg_mask_write(MIPS3_PG_SIZE_TO_MASK(PAGE_SIZE));
1348 mips3_cp0_wired_write(0); 1348 mips3_cp0_wired_write(0);
1349#if defined(MIPS3_LOONGSON2) 1349#if defined(MIPS3_LOONGSON2)
1350 if (opts->mips_cpu_flags & CPU_MIPS_LOONGSON2) { 1350 if (opts->mips_cpu_flags & CPU_MIPS_LOONGSON2) {
1351 (*loongson2_locore_vec.ljv_tlb_invalidate_all)(); 1351 (*loongson2_locore_vec.ljv_tlb_invalidate_all)();
1352 mips3_cp0_wired_write(pmap_tlb0_info.ti_wired); 1352 mips3_cp0_wired_write(pmap_tlb0_info.ti_wired);
1353 loongson2_vector_init(splsw); 1353 loongson2_vector_init(splsw);
1354 mips_locoresw = loongson2_locoresw; 1354 mips_locoresw = loongson2_locoresw;
1355 opts->mips3_cca_devmem = CCA_ACCEL; 1355 opts->mips3_cca_devmem = CCA_ACCEL;
1356 break; 1356 break;
1357 } 1357 }
1358#endif /* MIPS3_LOONGSON2 */ 1358#endif /* MIPS3_LOONGSON2 */
1359 (*mips3_locore_vec.ljv_tlb_invalidate_all)(); 1359 (*mips3_locore_vec.ljv_tlb_invalidate_all)();
1360 mips3_cp0_wired_write(pmap_tlb0_info.ti_wired); 1360 mips3_cp0_wired_write(pmap_tlb0_info.ti_wired);
1361 mips3_vector_init(splsw); 1361 mips3_vector_init(splsw);
1362 mips_locoresw = mips3_locoresw; 1362 mips_locoresw = mips3_locoresw;
1363 break; 1363 break;
1364 1364
1365#endif /* MIPS3 */ 1365#endif /* MIPS3 */
1366#if defined(MIPS32) 1366#if defined(MIPS32)
1367 case CPU_ARCH_MIPS32: 1367 case CPU_ARCH_MIPS32:
1368 mips3_tlb_probe(); 1368 mips3_tlb_probe();
1369 mips3_cp0_pg_mask_write(MIPS3_PG_SIZE_TO_MASK(PAGE_SIZE)); 1369 mips3_cp0_pg_mask_write(MIPS3_PG_SIZE_TO_MASK(PAGE_SIZE));
1370 mips3_cp0_wired_write(0); 1370 mips3_cp0_wired_write(0);
1371 (*mips32_locore_vec.ljv_tlb_invalidate_all)(); 1371 (*mips32_locore_vec.ljv_tlb_invalidate_all)();
1372 mips3_cp0_wired_write(pmap_tlb0_info.ti_wired); 1372 mips3_cp0_wired_write(pmap_tlb0_info.ti_wired);
1373 mips32_vector_init(splsw); 1373 mips32_vector_init(splsw);
1374 mips_locoresw = mips32_locoresw; 1374 mips_locoresw = mips32_locoresw;
1375 break; 1375 break;
1376#endif 1376#endif
1377#if defined(MIPS32R2) 1377#if defined(MIPS32R2)
1378 case CPU_ARCH_MIPS32R2: 1378 case CPU_ARCH_MIPS32R2:
1379 mips3_tlb_probe(); 1379 mips3_tlb_probe();
1380 mips3_cp0_pg_mask_write(MIPS3_PG_SIZE_TO_MASK(PAGE_SIZE)); 1380 mips3_cp0_pg_mask_write(MIPS3_PG_SIZE_TO_MASK(PAGE_SIZE));
1381 mips3_cp0_wired_write(0); 1381 mips3_cp0_wired_write(0);
1382 (*mips32r2_locore_vec.ljv_tlb_invalidate_all)(); 1382 (*mips32r2_locore_vec.ljv_tlb_invalidate_all)();
1383 mips3_cp0_wired_write(pmap_tlb0_info.ti_wired); 1383 mips3_cp0_wired_write(pmap_tlb0_info.ti_wired);
1384 mips32r2_vector_init(splsw); 1384 mips32r2_vector_init(splsw);
1385 mips_locoresw = mips32r2_locoresw; 1385 mips_locoresw = mips32r2_locoresw;
1386 break; 1386 break;
1387#endif 1387#endif
1388#if defined(MIPS64) 1388#if defined(MIPS64)
1389 case CPU_ARCH_MIPS64: { 1389 case CPU_ARCH_MIPS64: {
1390 mips3_tlb_probe(); 1390 mips3_tlb_probe();
1391 mips3_cp0_pg_mask_write(MIPS3_PG_SIZE_TO_MASK(PAGE_SIZE)); 1391 mips3_cp0_pg_mask_write(MIPS3_PG_SIZE_TO_MASK(PAGE_SIZE));
1392 mips3_cp0_wired_write(0); 1392 mips3_cp0_wired_write(0);
1393 (*mips64_locore_vec.ljv_tlb_invalidate_all)(); 1393 (*mips64_locore_vec.ljv_tlb_invalidate_all)();
1394 mips3_cp0_wired_write(pmap_tlb0_info.ti_wired); 1394 mips3_cp0_wired_write(pmap_tlb0_info.ti_wired);
1395 mips64_vector_init(splsw); 1395 mips64_vector_init(splsw);
1396 mips_locoresw = mips64_locoresw; 1396 mips_locoresw = mips64_locoresw;
1397 break; 1397 break;
1398 } 1398 }
1399#endif 1399#endif
1400#if defined(MIPS64R2) 1400#if defined(MIPS64R2)
1401 case CPU_ARCH_MIPS64R2: { 1401 case CPU_ARCH_MIPS64R2: {
1402 mips3_tlb_probe(); 1402 mips3_tlb_probe();
1403 mips3_cp0_pg_mask_write(MIPS3_PG_SIZE_TO_MASK(PAGE_SIZE)); 1403 mips3_cp0_pg_mask_write(MIPS3_PG_SIZE_TO_MASK(PAGE_SIZE));
1404 mips3_cp0_wired_write(0); 1404 mips3_cp0_wired_write(0);
1405 (*mips64r2_locore_vec.ljv_tlb_invalidate_all)(); 1405 (*mips64r2_locore_vec.ljv_tlb_invalidate_all)();
1406 mips3_cp0_wired_write(pmap_tlb0_info.ti_wired); 1406 mips3_cp0_wired_write(pmap_tlb0_info.ti_wired);
1407 mips64r2_vector_init(splsw); 1407 mips64r2_vector_init(splsw);
1408 mips_locoresw = mips64r2_locoresw; 1408 mips_locoresw = mips64r2_locoresw;
1409 break; 1409 break;
1410 } 1410 }
1411#endif 1411#endif
1412 default: 1412 default:
1413 printf("cpu_arch 0x%x: not supported\n", opts->mips_cpu_arch); 1413 printf("cpu_arch 0x%x: not supported\n", opts->mips_cpu_arch);
1414 cpu_reboot(RB_HALT, NULL); 1414 cpu_reboot(RB_HALT, NULL);
1415 } 1415 }
1416 1416
1417 /* 1417 /*
1418 * Now that the splsw and locoresw have been filled in, fixup the 1418 * Now that the splsw and locoresw have been filled in, fixup the
1419 * jumps to any stubs to actually jump to the real routines. 1419 * jumps to any stubs to actually jump to the real routines.
1420 */ 1420 */
1421 extern uint32_t _ftext[]; 1421 extern uint32_t _ftext[];
1422 extern uint32_t _etext[]; 1422 extern uint32_t _etext[];
1423 mips_fixup_stubs(_ftext, _etext); 1423 mips_fixup_stubs(_ftext, _etext);
1424 1424
1425#if (MIPS3 + MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0 1425#if (MIPS3 + MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0
1426 /* 1426 /*
1427 * Install power-saving idle routines. 1427 * Install power-saving idle routines.
1428 */ 1428 */
1429 if ((opts->mips_cpu_flags & CPU_MIPS_USE_WAIT) && 1429 if ((opts->mips_cpu_flags & CPU_MIPS_USE_WAIT) &&
1430 !(opts->mips_cpu_flags & CPU_MIPS_NO_WAIT)) 1430 !(opts->mips_cpu_flags & CPU_MIPS_NO_WAIT))
1431 mips_locoresw.lsw_cpu_idle = mips_wait_idle; 1431 mips_locoresw.lsw_cpu_idle = mips_wait_idle;
1432#endif /* (MIPS3 + MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0 */ 1432#endif /* (MIPS3 + MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0 */
1433} 1433}
1434 1434
1435void 1435void
1436mips_set_wbflush(void (*flush_fn)(void)) 1436mips_set_wbflush(void (*flush_fn)(void))
1437{ 1437{
1438 mips_locoresw.lsw_wbflush = flush_fn; 1438 mips_locoresw.lsw_wbflush = flush_fn;
1439 (*flush_fn)(); 1439 (*flush_fn)();
1440} 1440}
1441 1441
1442#if defined(MIPS3_PLUS) 1442#if defined(MIPS3_PLUS)
1443static void 1443static void
1444mips3_tlb_probe(void) 1444mips3_tlb_probe(void)
1445{ 1445{
1446 struct mips_options * const opts = &mips_options; 1446 struct mips_options * const opts = &mips_options;
1447 opts->mips3_tlb_pg_mask = mips3_cp0_tlb_page_mask_probe(); 1447 opts->mips3_tlb_pg_mask = mips3_cp0_tlb_page_mask_probe();
1448 if (CPUIS64BITS) { 1448 if (CPUIS64BITS) {
1449 opts->mips3_tlb_vpn_mask = mips3_cp0_tlb_entry_hi_probe(); 1449 opts->mips3_tlb_vpn_mask = mips3_cp0_tlb_entry_hi_probe();
1450 opts->mips3_tlb_vpn_mask |= PAGE_MASK; 1450 opts->mips3_tlb_vpn_mask |= PAGE_MASK;
1451 opts->mips3_tlb_vpn_mask <<= 2; 1451 opts->mips3_tlb_vpn_mask <<= 2;
1452 opts->mips3_tlb_vpn_mask >>= 2; 1452 opts->mips3_tlb_vpn_mask >>= 2;
1453 opts->mips3_tlb_pfn_mask = mips3_cp0_tlb_entry_lo_probe(); 1453 opts->mips3_tlb_pfn_mask = mips3_cp0_tlb_entry_lo_probe();
1454#if defined(_LP64) && defined(ENABLE_MIPS_16KB_PAGE) 1454#if defined(_LP64) && defined(ENABLE_MIPS_16KB_PAGE)
1455 /* 1455 /*
1456 * 16KB pages could cause our page table being able to address 1456 * 16KB pages could cause our page table being able to address
1457 * a larger address space than the actual chip supports. So 1457 * a larger address space than the actual chip supports. So
1458 * we need to limit the address space to what it can really 1458 * we need to limit the address space to what it can really
1459 * address. 1459 * address.
1460 */ 1460 */
1461 if (mips_vm_maxuser_address > opts->mips3_tlb_vpn_mask + 1) 1461 if (mips_vm_maxuser_address > opts->mips3_tlb_vpn_mask + 1)
1462 mips_vm_maxuser_address = opts->mips3_tlb_vpn_mask + 1; 1462 mips_vm_maxuser_address = opts->mips3_tlb_vpn_mask + 1;
1463#endif 1463#endif
1464 } 1464 }
1465} 1465}
1466#endif 1466#endif
1467 1467
1468static const char * 1468static const char *
1469wayname(int ways) 1469wayname(int ways)
1470{ 1470{
1471 static char buf[sizeof("xxx-way set-associative")]; 1471 static char buf[sizeof("xxx-way set-associative")];
1472 1472
1473#ifdef DIAGNOSTIC 1473#ifdef DIAGNOSTIC
1474 if (ways > 999) 1474 if (ways > 999)
1475 panic("mips cache - too many ways (%d)", ways); 1475 panic("mips cache - too many ways (%d)", ways);
1476#endif 1476#endif
1477 1477
1478 switch (ways) { 1478 switch (ways) {
1479 case 0: 1479 case 0:
1480 return "fully set-associative"; 1480 return "fully set-associative";
1481 case 1: 1481 case 1:
1482 return "direct-mapped"; 1482 return "direct-mapped";
1483 default: 1483 default:
1484 snprintf(buf, sizeof(buf), "%d-way set-associative", ways); 1484 snprintf(buf, sizeof(buf), "%d-way set-associative", ways);
1485 return buf; 1485 return buf;
1486 } 1486 }
1487} 1487}
1488 1488
1489/* 1489/*
1490 * Identify product revision IDs of CPU and FPU. 1490 * Identify product revision IDs of CPU and FPU.
1491 */ 1491 */
1492void 1492void
1493cpu_identify(device_t dev) 1493cpu_identify(device_t dev)
1494{ 1494{
1495 const struct mips_options * const opts = &mips_options; 1495 const struct mips_options * const opts = &mips_options;
1496 const struct mips_cache_info * const mci = &mips_cache_info; 1496 const struct mips_cache_info * const mci = &mips_cache_info;
1497 const mips_prid_t cpu_id = opts->mips_cpu_id; 1497 const mips_prid_t cpu_id = opts->mips_cpu_id;
1498 const mips_prid_t fpu_id = opts->mips_fpu_id; 1498 const mips_prid_t fpu_id = opts->mips_fpu_id;
1499 static const char * const wtnames[] = { 1499 static const char * const wtnames[] = {
1500 "write-back", 1500 "write-back",
1501 "write-through", 1501 "write-through",
1502 }; 1502 };
1503 const char *cpuname, *fpuname; 1503 const char *cpuname, *fpuname;
1504 int i; 1504 int i;
1505 1505
1506 cpuname = opts->mips_cpu->cpu_name; 1506 cpuname = opts->mips_cpu->cpu_name;
1507#ifdef MIPS64_OCTEON 1507#ifdef MIPS64_OCTEON
1508 if (MIPS_PRID_CID(cpu_id) == MIPS_PRID_CID_CAVIUM) { 1508 if (MIPS_PRID_CID(cpu_id) == MIPS_PRID_CID_CAVIUM) {
1509 cpuname = octeon_cpu_model(cpu_id); 1509 cpuname = octeon_cpu_model(cpu_id);
1510 } 1510 }
1511#endif 1511#endif
1512 1512
1513 fpuname = NULL; 1513 fpuname = NULL;
1514 for (i = 0; i < sizeof(fputab)/sizeof(fputab[0]); i++) { 1514 for (i = 0; i < sizeof(fputab)/sizeof(fputab[0]); i++) {
1515 if (MIPS_PRID_CID(fpu_id) == fputab[i].cpu_cid && 1515 if (MIPS_PRID_CID(fpu_id) == fputab[i].cpu_cid &&
1516 MIPS_PRID_IMPL(fpu_id) == fputab[i].cpu_pid) { 1516 MIPS_PRID_IMPL(fpu_id) == fputab[i].cpu_pid) {
1517 fpuname = fputab[i].cpu_name; 1517 fpuname = fputab[i].cpu_name;
1518 break; 1518 break;
1519 } 1519 }
1520 } 1520 }
1521 if (fpuname == NULL && MIPS_PRID_IMPL(fpu_id) == MIPS_PRID_IMPL(cpu_id)) 1521 if (fpuname == NULL && MIPS_PRID_IMPL(fpu_id) == MIPS_PRID_IMPL(cpu_id))
1522 fpuname = "built-in FPU"; 1522 fpuname = "built-in FPU";
1523 if (MIPS_PRID_IMPL(cpu_id) == MIPS_R4700) /* FPU PRid is 0x20 */ 1523 if (MIPS_PRID_IMPL(cpu_id) == MIPS_R4700) /* FPU PRid is 0x20 */
1524 fpuname = "built-in FPU"; 1524 fpuname = "built-in FPU";
1525 if (MIPS_PRID_IMPL(cpu_id) == MIPS_RC64470) /* FPU PRid is 0x21 */ 1525 if (MIPS_PRID_IMPL(cpu_id) == MIPS_RC64470) /* FPU PRid is 0x21 */
1526 fpuname = "built-in FPU"; 1526 fpuname = "built-in FPU";
1527#ifdef MIPSNN 1527#ifdef MIPSNN
1528 if (CPUISMIPSNN) { 1528 if (CPUISMIPSNN) {
1529 uint32_t cfg1; 1529 uint32_t cfg1;
1530 1530
1531 switch (MIPS_PRID_CID(cpu_id)) { 1531 switch (MIPS_PRID_CID(cpu_id)) {
1532 /* 1532 /*
1533 * CPUs from the following companies have a built-in 1533 * CPUs from the following companies have a built-in
1534 * FPU if Config1[FP] is set. 1534 * FPU if Config1[FP] is set.
1535 */ 1535 */
1536 case MIPS_PRID_CID_SIBYTE: 1536 case MIPS_PRID_CID_SIBYTE:
1537 case MIPS_PRID_CID_CAVIUM: 1537 case MIPS_PRID_CID_CAVIUM:
1538 cfg1 = mipsNN_cp0_config1_read(); 1538 cfg1 = mipsNN_cp0_config1_read();
1539 if (cfg1 & MIPSNN_CFG1_FP) 1539 if (cfg1 & MIPSNN_CFG1_FP)
1540 fpuname = "built-in FPU"; 1540 fpuname = "built-in FPU";
1541 break; 1541 break;
1542 } 1542 }
1543 } 1543 }
1544#endif 1544#endif
1545 1545
1546 if (opts->mips_cpu->cpu_cid != 0) { 1546 if (opts->mips_cpu->cpu_cid != 0) {
1547 if (opts->mips_cpu->cpu_cid <= ncidnames) 1547 if (opts->mips_cpu->cpu_cid <= ncidnames)
1548 aprint_normal("%s ", cidnames[opts->mips_cpu->cpu_cid]); 1548 aprint_normal("%s ", cidnames[opts->mips_cpu->cpu_cid]);
1549 else if (opts->mips_cpu->cpu_cid == MIPS_PRID_CID_INGENIC) { 1549 else if (opts->mips_cpu->cpu_cid == MIPS_PRID_CID_INGENIC) {
1550 aprint_normal("Ingenic "); 1550 aprint_normal("Ingenic ");
1551 } else { 1551 } else {
1552 aprint_normal("Unknown Company ID - 0x%x", 1552 aprint_normal("Unknown Company ID - 0x%x",
1553 opts->mips_cpu->cpu_cid); 1553 opts->mips_cpu->cpu_cid);
1554 aprint_normal_dev(dev, ""); 1554 aprint_normal_dev(dev, "");
1555 } 1555 }
1556 } 1556 }
1557 if (cpuname != NULL) 1557 if (cpuname != NULL)
1558 aprint_normal("%s (0x%x)", cpuname, cpu_id); 1558 aprint_normal("%s (0x%x)", cpuname, cpu_id);
1559 else 1559 else
1560 aprint_normal("unknown CPU type (0x%x)", cpu_id); 1560 aprint_normal("unknown CPU type (0x%x)", cpu_id);
1561 if (MIPS_PRID_CID(cpu_id) == MIPS_PRID_CID_PREHISTORIC) 1561 if (MIPS_PRID_CID(cpu_id) == MIPS_PRID_CID_PREHISTORIC)
1562 aprint_normal(" Rev. %d.%d", MIPS_PRID_REV_MAJ(cpu_id), 1562 aprint_normal(" Rev. %d.%d", MIPS_PRID_REV_MAJ(cpu_id),
1563 MIPS_PRID_REV_MIN(cpu_id)); 1563 MIPS_PRID_REV_MIN(cpu_id));
1564 else 1564 else
1565 aprint_normal(" Rev. %d", MIPS_PRID_REV(cpu_id)); 1565 aprint_normal(" Rev. %d", MIPS_PRID_REV(cpu_id));
1566 1566
1567 if (fpuname != NULL) 1567 if (fpuname != NULL)
1568 aprint_normal(" with %s", fpuname); 1568 aprint_normal(" with %s", fpuname);
1569 else 1569 else
1570 aprint_normal(" with unknown FPC type (0x%x)", fpu_id); 1570 aprint_normal(" with unknown FPC type (0x%x)", fpu_id);
1571 if (opts->mips_fpu_id != 0) { 1571 if (opts->mips_fpu_id != 0) {
1572 if (MIPS_PRID_CID(cpu_id) == MIPS_PRID_CID_PREHISTORIC) 1572 if (MIPS_PRID_CID(cpu_id) == MIPS_PRID_CID_PREHISTORIC)
1573 aprint_normal(" Rev. %d.%d", MIPS_PRID_REV_MAJ(fpu_id), 1573 aprint_normal(" Rev. %d.%d", MIPS_PRID_REV_MAJ(fpu_id),
1574 MIPS_PRID_REV_MIN(fpu_id)); 1574 MIPS_PRID_REV_MIN(fpu_id));
1575 else 1575 else
1576 aprint_normal(" Rev. %d", MIPS_PRID_REV(fpu_id)); 1576 aprint_normal(" Rev. %d", MIPS_PRID_REV(fpu_id));
1577 } 1577 }
1578 if (opts->mips_cpu_flags & MIPS_HAS_DSP) { 1578 if (opts->mips_cpu_flags & MIPS_HAS_DSP) {
1579 aprint_normal(" and DSPv2"); 1579 aprint_normal(" and DSPv2");
1580 } 1580 }
1581 aprint_normal("\n"); 1581 aprint_normal("\n");
1582 1582
1583 if (MIPS_PRID_CID(cpu_id) == MIPS_PRID_CID_PREHISTORIC && 1583 if (MIPS_PRID_CID(cpu_id) == MIPS_PRID_CID_PREHISTORIC &&
1584 MIPS_PRID_RSVD(cpu_id) != 0) { 1584 MIPS_PRID_RSVD(cpu_id) != 0) {
1585 aprint_normal_dev(dev, 1585 aprint_normal_dev(dev,
1586 "NOTE: top 8 bits of prehistoric PRID not 0!\n"); 1586 "NOTE: top 8 bits of prehistoric PRID not 0!\n");
1587 aprint_normal_dev(dev, "Please mail port-mips@NetBSD.org " 1587 aprint_normal_dev(dev, "Please mail port-mips@NetBSD.org "
1588 "with %s dmesg lines.\n", device_xname(dev)); 1588 "with %s dmesg lines.\n", device_xname(dev));
1589 } 1589 }
1590 1590
1591 switch (opts->mips_cpu_arch) { 1591 switch (opts->mips_cpu_arch) {
1592#if defined(MIPS1) 1592#if defined(MIPS1)
1593 case CPU_ARCH_MIPS1: 1593 case CPU_ARCH_MIPS1:
1594 if (mci->mci_picache_size) 1594 if (mci->mci_picache_size)
1595 aprint_normal_dev(dev, "%dKB/%dB %s Instruction cache, " 1595 aprint_normal_dev(dev, "%dKB/%dB %s Instruction cache, "
1596 "%d TLB entries\n", mci->mci_picache_size / 1024, 1596 "%d TLB entries\n", mci->mci_picache_size / 1024,
1597 mci->mci_picache_line_size, 1597 mci->mci_picache_line_size,
1598 wayname(mci->mci_picache_ways), 1598 wayname(mci->mci_picache_ways),
1599 opts->mips_num_tlb_entries); 1599 opts->mips_num_tlb_entries);
1600 else 1600 else
1601 aprint_normal_dev(dev, "%d TLB entries\n", 1601 aprint_normal_dev(dev, "%d TLB entries\n",
1602 opts->mips_num_tlb_entries); 1602 opts->mips_num_tlb_entries);
1603 if (mci->mci_pdcache_size) 1603 if (mci->mci_pdcache_size)
1604 aprint_normal_dev(dev, "%dKB/%dB %s %s Data cache\n", 1604 aprint_normal_dev(dev, "%dKB/%dB %s %s Data cache\n",
1605 mci->mci_pdcache_size / 1024, 1605 mci->mci_pdcache_size / 1024,
1606 mci->mci_pdcache_line_size, 1606 mci->mci_pdcache_line_size,
1607 wayname(mci->mci_pdcache_ways), 1607 wayname(mci->mci_pdcache_ways),
1608 wtnames[mci->mci_pdcache_write_through]); 1608 wtnames[mci->mci_pdcache_write_through]);
1609 break; 1609 break;
1610#endif /* MIPS1 */ 1610#endif /* MIPS1 */
1611#if (MIPS3 + MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0 1611#if (MIPS3 + MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0
1612 case CPU_ARCH_MIPS3: 1612 case CPU_ARCH_MIPS3:
1613 case CPU_ARCH_MIPS4: 1613 case CPU_ARCH_MIPS4:
1614 case CPU_ARCH_MIPS32: 1614 case CPU_ARCH_MIPS32:
1615 case CPU_ARCH_MIPS32R2: 1615 case CPU_ARCH_MIPS32R2:
1616 case CPU_ARCH_MIPS64: 1616 case CPU_ARCH_MIPS64:
1617 case CPU_ARCH_MIPS64R2: { 1617 case CPU_ARCH_MIPS64R2: {
1618 const char *sufx = "KMGTPE"; 1618 const char *sufx = "KMGTPE";
1619 uint32_t pg_mask; 1619 uint32_t pg_mask;
1620 aprint_normal_dev(dev, "%d TLB entries", 1620 aprint_normal_dev(dev, "%d TLB entries",
1621 opts->mips_num_tlb_entries); 1621 opts->mips_num_tlb_entries);
1622#if !defined(__mips_o32) 1622#if !defined(__mips_o32)
1623 if (CPUIS64BITS) { 1623 if (CPUIS64BITS) {
1624 int64_t pfn_mask; 1624 int64_t pfn_mask;
1625 i = ffs(~(opts->mips3_tlb_vpn_mask >> 31)) + 30; 1625 i = ffs(~(opts->mips3_tlb_vpn_mask >> 31)) + 30;
1626 aprint_normal(", %d%cB (%d-bit) VAs", 1626 aprint_normal(", %d%cB (%d-bit) VAs",
1627 1 << (i % 10), sufx[(i / 10) - 1], i); 1627 1 << (i % 10), sufx[(i / 10) - 1], i);
1628 for (i = 64, pfn_mask = opts->mips3_tlb_pfn_mask << 6; 1628 for (i = 64, pfn_mask = opts->mips3_tlb_pfn_mask << 6;
1629 pfn_mask > 0; i--, pfn_mask <<= 1) 1629 pfn_mask > 0; i--, pfn_mask <<= 1)
1630 ; 1630 ;
1631 aprint_normal(", %d%cB (%d-bit) PAs", 1631 aprint_normal(", %d%cB (%d-bit) PAs",
1632 1 << (i % 10), sufx[(i / 10) - 1], i); 1632 1 << (i % 10), sufx[(i / 10) - 1], i);
1633 } 1633 }
1634#endif 1634#endif
1635 for (i = 4, pg_mask = opts->mips3_tlb_pg_mask >> 13; 1635 for (i = 4, pg_mask = opts->mips3_tlb_pg_mask >> 13;
1636 pg_mask != 0; ) { 1636 pg_mask != 0; ) {
1637 if ((pg_mask & 3) != 3) 1637 if ((pg_mask & 3) != 3)
1638 break; 1638 break;
1639 pg_mask >>= 2; 1639 pg_mask >>= 2;
1640 i *= 4; 1640 i *= 4;
1641 if (i == 1024) { 1641 if (i == 1024) {
1642 i = 1; 1642 i = 1;
1643 sufx++; 1643 sufx++;
1644 } 1644 }
1645 } 1645 }
1646 aprint_normal(", %d%cB max page size\n", i, sufx[0]); 1646 aprint_normal(", %d%cB max page size\n", i, sufx[0]);
1647 if (mci->mci_picache_size) 1647 if (mci->mci_picache_size)
1648 aprint_normal_dev(dev, 1648 aprint_normal_dev(dev,
1649 "%dKB/%dB %s L1 instruction cache\n", 1649 "%dKB/%dB %s L1 instruction cache\n",
1650 mci->mci_picache_size / 1024, 1650 mci->mci_picache_size / 1024,
1651 mci->mci_picache_line_size, 1651 mci->mci_picache_line_size,
1652 wayname(mci->mci_picache_ways)); 1652 wayname(mci->mci_picache_ways));
1653 if (mci->mci_pdcache_size) 1653 if (mci->mci_pdcache_size)
1654 aprint_normal_dev(dev, 1654 aprint_normal_dev(dev,
1655 "%dKB/%dB %s %s %sL1 data cache\n", 1655 "%dKB/%dB %s %s %sL1 data cache\n",
1656 mci->mci_pdcache_size / 1024, 1656 mci->mci_pdcache_size / 1024,
1657 mci->mci_pdcache_line_size, 1657 mci->mci_pdcache_line_size,
1658 wayname(mci->mci_pdcache_ways), 1658 wayname(mci->mci_pdcache_ways),
1659 wtnames[mci->mci_pdcache_write_through], 1659 wtnames[mci->mci_pdcache_write_through],
1660 ((opts->mips_cpu_flags & CPU_MIPS_D_CACHE_COHERENT) 1660 ((opts->mips_cpu_flags & CPU_MIPS_D_CACHE_COHERENT)
1661 ? "coherent " : "")); 1661 ? "coherent " : ""));
1662 if (mci->mci_sdcache_line_size) 1662 if (mci->mci_sdcache_line_size)
1663 aprint_normal_dev(dev, 1663 aprint_normal_dev(dev,
1664 "%dKB/%dB %s %s L2 %s cache\n", 1664 "%dKB/%dB %s %s L2 %s cache\n",
1665 mci->mci_sdcache_size / 1024, 1665 mci->mci_sdcache_size / 1024,
1666 mci->mci_sdcache_line_size, 1666 mci->mci_sdcache_line_size,
1667 wayname(mci->mci_sdcache_ways), 1667 wayname(mci->mci_sdcache_ways),
1668 wtnames[mci->mci_sdcache_write_through], 1668 wtnames[mci->mci_sdcache_write_through],
1669 mci->mci_scache_unified ? "unified" : "data"); 1669 mci->mci_scache_unified ? "unified" : "data");
1670 break; 1670 break;
1671 } 1671 }
1672#endif /* (MIPS3 + MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0 */ 1672#endif /* (MIPS3 + MIPS32 + MIPS32R2 + MIPS64 + MIPS64R2) > 0 */
1673 default: 1673 default:
1674 panic("cpu_identify: impossible"); 1674 panic("cpu_identify: impossible");
1675 } 1675 }
1676} 1676}
1677 1677