Sun Jul 31 15:39:29 2011 UTC ()
Add support for a loongson2_subr.S.  This is needed since that chip needs
special handling to manually flush the ITLB on TLB updates.


(matt)
diff -r1.70 -r1.71 src/sys/arch/mips/conf/files.mips
diff -r1.100 -r1.101 src/sys/arch/mips/mips/locore_mips3.S
diff -r0 -r1.1 src/sys/arch/mips/mips/loongson2_subr.S
diff -r1.5 -r1.6 src/sys/arch/mips/mips/mips32_subr.S
diff -r1.5 -r1.6 src/sys/arch/mips/mips/mips3_subr.S
diff -r1.5 -r1.6 src/sys/arch/mips/mips/mips64_subr.S
diff -r1.1 -r1.2 src/sys/arch/mips/mips/mips32r2_subr.S
diff -r1.1 -r1.2 src/sys/arch/mips/mips/mips64r2_subr.S
diff -r1.50 -r1.51 src/sys/arch/mips/mips/mipsX_subr.S
diff -r1.244 -r1.245 src/sys/arch/mips/mips/mips_machdep.c

cvs diff -r1.70 -r1.71 src/sys/arch/mips/conf/files.mips (expand / switch to unified diff)

--- src/sys/arch/mips/conf/files.mips 2011/06/12 03:35:43 1.70
+++ src/sys/arch/mips/conf/files.mips 2011/07/31 15:39:28 1.71
@@ -1,42 +1,43 @@ @@ -1,42 +1,43 @@
1# $NetBSD: files.mips,v 1.70 2011/06/12 03:35:43 rmind Exp $ 1# $NetBSD: files.mips,v 1.71 2011/07/31 15:39:28 matt Exp $
2# 2#
3 3
4defflag opt_cputype.h NOFPU FPEMUL 4defflag opt_cputype.h NOFPU FPEMUL
5 MIPS64_SB1 5 MIPS64_SB1
6 MIPS3_LOONGSON2F 
7 ENABLE_MIPS_16KB_PAGE 6 ENABLE_MIPS_16KB_PAGE
8 MIPS64_XLP MIPS64_XLR MIPS64_XLS 7 MIPS64_XLP MIPS64_XLR MIPS64_XLS
9 # and the rest... 8 # and the rest...
10 # MIPS1 MIPS2 MIPS3 MIPS4 MIPS5 9 # MIPS1 MIPS2 MIPS3 MIPS4 MIPS5
 10 # MIPS3_LOONGSON2
11 # MIPS32 MIPS32R2 MIPS64 MIPS64R2 11 # MIPS32 MIPS32R2 MIPS64 MIPS64R2
12 # MIPS3_4100 12 # MIPS3_4100
13 # ENABLE_MIPS_4KB_PAGE 13 # ENABLE_MIPS_4KB_PAGE
14 # ENABLE_MIPS_TX3900 14 # ENABLE_MIPS_TX3900
15 # ENABLE_MIPS_R4700 15 # ENABLE_MIPS_R4700
16 # ENABLE_MIPS_R3NKK 16 # ENABLE_MIPS_R3NKK
17defflag opt_mips_cache.h MIPS3_NO_PV_UNCACHED 17defflag opt_mips_cache.h MIPS3_NO_PV_UNCACHED
18 ENABLE_MIPS4_CACHE_R10K 18 ENABLE_MIPS4_CACHE_R10K
19defflag opt_mips3_wired.h ENABLE_MIPS3_WIRED_MAP 19defflag opt_mips3_wired.h ENABLE_MIPS3_WIRED_MAP
20 20
21defflag opt_ddb.h DDB_TRACE 21defflag opt_ddb.h DDB_TRACE
22 22
23file arch/mips/mips/locore_mips1.S mips1 23file arch/mips/mips/locore_mips1.S mips1
24file arch/mips/mips/locore_mips3.S mips3|mips4|mips32|mips32r2|mips64|mips64r2 24file arch/mips/mips/locore_mips3.S mips3|mips4|mips32|mips32r2|mips64|mips64r2
25file arch/mips/mips/mips3_subr.S mips3|mips4 25file arch/mips/mips/mips3_subr.S mips3|mips4
26file arch/mips/mips/mips32_subr.S mips32 26file arch/mips/mips/mips32_subr.S mips32
27file arch/mips/mips/mips32r2_subr.S mips32r2 27file arch/mips/mips/mips32r2_subr.S mips32r2
28file arch/mips/mips/mips64_subr.S mips64 28file arch/mips/mips/mips64_subr.S mips64
29file arch/mips/mips/mips64r2_subr.S mips64r2 29file arch/mips/mips/mips64r2_subr.S mips64r2
 30file arch/mips/mips/loongson2_subr.S mips3_loongson2
30file arch/mips/mips/sigcode.S 31file arch/mips/mips/sigcode.S
31file arch/mips/mips/copy.S 32file arch/mips/mips/copy.S
32file arch/mips/mips/lock_stubs_llsc.S multiprocessor 33file arch/mips/mips/lock_stubs_llsc.S multiprocessor
33file arch/mips/mips/lock_stubs_ras.S 34file arch/mips/mips/lock_stubs_ras.S
34file arch/mips/mips/spl.S 35file arch/mips/mips/spl.S
35file arch/mips/mips/spl_stubs.c 36file arch/mips/mips/spl_stubs.c
36 37
37file arch/mips/mips/core_machdep.c coredump 38file arch/mips/mips/core_machdep.c coredump
38file arch/mips/mips/cpu_subr.c 39file arch/mips/mips/cpu_subr.c
39file arch/mips/mips/db_disasm.c ddb 40file arch/mips/mips/db_disasm.c ddb
40file arch/mips/mips/db_interface.c ddb | kgdb 41file arch/mips/mips/db_interface.c ddb | kgdb
41file arch/mips/mips/db_trace.c ddb 42file arch/mips/mips/db_trace.c ddb
42file arch/mips/mips/ipifuncs.c multiprocessor 43file arch/mips/mips/ipifuncs.c multiprocessor

cvs diff -r1.100 -r1.101 src/sys/arch/mips/mips/locore_mips3.S (expand / switch to unified diff)

--- src/sys/arch/mips/mips/locore_mips3.S 2011/07/10 23:21:59 1.100
+++ src/sys/arch/mips/mips/locore_mips3.S 2011/07/31 15:39:29 1.101
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: locore_mips3.S,v 1.100 2011/07/10 23:21:59 matt Exp $ */ 1/* $NetBSD: locore_mips3.S,v 1.101 2011/07/31 15:39:29 matt Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1997 Jonathan Stone (hereinafter referred to as the author) 4 * Copyright (c) 1997 Jonathan Stone (hereinafter referred to as the author)
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -141,26 +141,27 @@ @@ -141,26 +141,27 @@
141 * Return when the write buffer is empty. 141 * Return when the write buffer is empty.
142 * 142 *
143 * Common for all MIPS3 and greater ISAs 143 * Common for all MIPS3 and greater ISAs
144 * 144 *
145 * Results: 145 * Results:
146 * None. 146 * None.
147 * 147 *
148 * Side effects: 148 * Side effects:
149 * None. 149 * None.
150 * 150 *
151 *---------------------------------------------------------------------------- 151 *----------------------------------------------------------------------------
152 */ 152 */
153LEAF(mips3_wbflush) 153LEAF(mips3_wbflush)
 154XLEAF(loongson2_wbflush)
154XLEAF(mips32_wbflush) 155XLEAF(mips32_wbflush)
155XLEAF(mips32r2_wbflush) 156XLEAF(mips32r2_wbflush)
156XLEAF(mips64_wbflush) 157XLEAF(mips64_wbflush)
157XLEAF(mips64r2_wbflush) 158XLEAF(mips64r2_wbflush)
158 nop 159 nop
159 sync 160 sync
160 j ra 161 j ra
161 nop 162 nop
162END(mips3_wbflush) 163END(mips3_wbflush)
163 164
164 165
165/* 166/*
166 * mips_wait_idle: 167 * mips_wait_idle:

File Added: src/sys/arch/mips/mips/loongson2_subr.S
/*	$NetBSD: loongson2_subr.S,v 1.1 2011/07/31 15:39:29 matt Exp $	*/

#undef MIPS1
/* #undef MIPS3 */
/* #undef MIPS3_LOONGSON2 */
#undef MIPS32
#undef MIPS32R2
#undef MIPS64
#undef MIPS64R2
#undef MIPS64_SB1
#undef MIPS64_XLP
#undef MIPS64_XLR
#undef MIPS64_XLS

#include <mips/mips/mipsX_subr.S>

cvs diff -r1.5 -r1.6 src/sys/arch/mips/mips/mips32_subr.S (expand / switch to unified diff)

--- src/sys/arch/mips/mips/mips32_subr.S 2011/03/15 07:39:22 1.5
+++ src/sys/arch/mips/mips/mips32_subr.S 2011/07/31 15:39:29 1.6
@@ -1,14 +1,15 @@ @@ -1,14 +1,15 @@
1/* $NetBSD: mips32_subr.S,v 1.5 2011/03/15 07:39:22 matt Exp $ */ 1/* $NetBSD: mips32_subr.S,v 1.6 2011/07/31 15:39:29 matt Exp $ */
2 2
3#undef MIPS1 3#undef MIPS1
4#undef MIPS3 4#undef MIPS3
 5#undef MIPS3_LOONGSON2
5/* #undef MIPS32 */ 6/* #undef MIPS32 */
6#undef MIPS32R2 7#undef MIPS32R2
7#undef MIPS64 8#undef MIPS64
8#undef MIPS64R2 9#undef MIPS64R2
9#undef MIPS64_SB1 10#undef MIPS64_SB1
10#undef MIPS64_XLP 11#undef MIPS64_XLP
11#undef MIPS64_XLR 12#undef MIPS64_XLR
12#undef MIPS64_XLS 13#undef MIPS64_XLS
13 14
14#include <mips/mips/mipsX_subr.S> 15#include <mips/mips/mipsX_subr.S>

cvs diff -r1.5 -r1.6 src/sys/arch/mips/mips/mips3_subr.S (expand / switch to unified diff)

--- src/sys/arch/mips/mips/mips3_subr.S 2011/03/15 07:39:22 1.5
+++ src/sys/arch/mips/mips/mips3_subr.S 2011/07/31 15:39:29 1.6
@@ -1,14 +1,15 @@ @@ -1,14 +1,15 @@
1/* $NetBSD: mips3_subr.S,v 1.5 2011/03/15 07:39:22 matt Exp $ */ 1/* $NetBSD: mips3_subr.S,v 1.6 2011/07/31 15:39:29 matt Exp $ */
2 2
3#undef MIPS1 3#undef MIPS1
4/* #undef MIPS3 */ 4/* #undef MIPS3 */
 5#undef MIPS3_LOONGSON2
5#undef MIPS32 6#undef MIPS32
6#undef MIPS32R2 7#undef MIPS32R2
7#undef MIPS64 8#undef MIPS64
8#undef MIPS64R2 9#undef MIPS64R2
9#undef MIPS64_SB1 10#undef MIPS64_SB1
10#undef MIPS64_XLP 11#undef MIPS64_XLP
11#undef MIPS64_XLR 12#undef MIPS64_XLR
12#undef MIPS64_XLS 13#undef MIPS64_XLS
13 14
14#include <mips/mips/mipsX_subr.S> 15#include <mips/mips/mipsX_subr.S>

cvs diff -r1.5 -r1.6 src/sys/arch/mips/mips/mips64_subr.S (expand / switch to unified diff)

--- src/sys/arch/mips/mips/mips64_subr.S 2011/03/15 07:39:22 1.5
+++ src/sys/arch/mips/mips/mips64_subr.S 2011/07/31 15:39:29 1.6
@@ -1,14 +1,15 @@ @@ -1,14 +1,15 @@
1/* $NetBSD: mips64_subr.S,v 1.5 2011/03/15 07:39:22 matt Exp $ */ 1/* $NetBSD: mips64_subr.S,v 1.6 2011/07/31 15:39:29 matt Exp $ */
2 2
3#undef MIPS1 3#undef MIPS1
4#undef MIPS3 4#undef MIPS3
 5#undef MIPS3_LOONGSON2
5#undef MIPS32 6#undef MIPS32
6#undef MIPS32R2 7#undef MIPS32R2
7/* #undef MIPS64 */ 8/* #undef MIPS64 */
8#undef MIPS64R2 9#undef MIPS64R2
9#undef MIPS64_SB1 10#undef MIPS64_SB1
10#undef MIPS64_XLP 11#undef MIPS64_XLP
11#undef MIPS64_XLR 12#undef MIPS64_XLR
12#undef MIPS64_XLS 13#undef MIPS64_XLS
13 14
14#include <mips/mips/mipsX_subr.S> 15#include <mips/mips/mipsX_subr.S>

cvs diff -r1.1 -r1.2 src/sys/arch/mips/mips/mips32r2_subr.S (expand / switch to unified diff)

--- src/sys/arch/mips/mips/mips32r2_subr.S 2011/03/15 07:39:22 1.1
+++ src/sys/arch/mips/mips/mips32r2_subr.S 2011/07/31 15:39:29 1.2
@@ -1,14 +1,15 @@ @@ -1,14 +1,15 @@
1/* $NetBSD: mips32r2_subr.S,v 1.1 2011/03/15 07:39:22 matt Exp $ */ 1/* $NetBSD: mips32r2_subr.S,v 1.2 2011/07/31 15:39:29 matt Exp $ */
2 2
3#undef MIPS1 3#undef MIPS1
4#undef MIPS3 4#undef MIPS3
 5#undef MIPS3_LOONGSON2
5#undef MIPS32 6#undef MIPS32
6/* #undef MIPS32R2 */ 7/* #undef MIPS32R2 */
7#undef MIPS64 8#undef MIPS64
8#undef MIPS64R2 9#undef MIPS64R2
9#undef MIPS64_SB1 10#undef MIPS64_SB1
10#undef MIPS64_XLP 11#undef MIPS64_XLP
11#undef MIPS64_XLR 12#undef MIPS64_XLR
12#undef MIPS64_XLS 13#undef MIPS64_XLS
13 14
14#include <mips/mips/mipsX_subr.S> 15#include <mips/mips/mipsX_subr.S>

cvs diff -r1.1 -r1.2 src/sys/arch/mips/mips/mips64r2_subr.S (expand / switch to unified diff)

--- src/sys/arch/mips/mips/mips64r2_subr.S 2011/03/15 07:39:22 1.1
+++ src/sys/arch/mips/mips/mips64r2_subr.S 2011/07/31 15:39:29 1.2
@@ -1,14 +1,15 @@ @@ -1,14 +1,15 @@
1/* $NetBSD: mips64r2_subr.S,v 1.1 2011/03/15 07:39:22 matt Exp $ */ 1/* $NetBSD: mips64r2_subr.S,v 1.2 2011/07/31 15:39:29 matt Exp $ */
2 2
3#undef MIPS1 3#undef MIPS1
4#undef MIPS3 4#undef MIPS3
 5#undef MIPS3_LOONGSON2
5#undef MIPS32 6#undef MIPS32
6#undef MIPS32R2 7#undef MIPS32R2
7#undef MIPS64 8#undef MIPS64
8/* #undef MIPS64R2 */ 9/* #undef MIPS64R2 */
9#undef MIPS64_SB1 10#undef MIPS64_SB1
10#undef MIPS64_XLP 11#undef MIPS64_XLP
11#undef MIPS64_XLR 12#undef MIPS64_XLR
12#undef MIPS64_XLS 13#undef MIPS64_XLS
13 14
14#include <mips/mips/mipsX_subr.S> 15#include <mips/mips/mipsX_subr.S>

cvs diff -r1.50 -r1.51 src/sys/arch/mips/mips/mipsX_subr.S (expand / switch to unified diff)

--- src/sys/arch/mips/mips/mipsX_subr.S 2011/07/10 23:21:59 1.50
+++ src/sys/arch/mips/mips/mipsX_subr.S 2011/07/31 15:39:29 1.51
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mipsX_subr.S,v 1.50 2011/07/10 23:21:59 matt Exp $ */ 1/* $NetBSD: mipsX_subr.S,v 1.51 2011/07/31 15:39:29 matt 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
@@ -218,27 +218,29 @@ @@ -218,27 +218,29 @@
218#if defined(MIPS64) 218#if defined(MIPS64)
219 .set mips64 219 .set mips64
220#endif 220#endif
221 221
222#if defined(MIPS64R2) 222#if defined(MIPS64R2)
223 .set mips64r2 223 .set mips64r2
224#endif 224#endif
225 225
226 226
227/* 227/*
228 * CPP function renaming macros. 228 * CPP function renaming macros.
229 */ 229 */
230 230
231#if defined(MIPS3) 231#if defined(MIPS3_LOONGSON2)
 232#define MIPSX(name) __CONCAT(loongson2_,name)
 233#elif defined(MIPS3)
232#define MIPSX(name) __CONCAT(mips3_,name) 234#define MIPSX(name) __CONCAT(mips3_,name)
233#endif 235#endif
234 236
235#if defined(MIPS32) 237#if defined(MIPS32)
236#define MIPSX(name) __CONCAT(mips32_,name) 238#define MIPSX(name) __CONCAT(mips32_,name)
237#endif 239#endif
238 240
239#if defined(MIPS32R2) 241#if defined(MIPS32R2)
240#define MIPSX(name) __CONCAT(mips32r2_,name) 242#define MIPSX(name) __CONCAT(mips32r2_,name)
241#endif 243#endif
242 244
243#if defined(MIPS64) 245#if defined(MIPS64)
244#define MIPSX(name) __CONCAT(mips64_,name) 246#define MIPSX(name) __CONCAT(mips64_,name)
@@ -1629,27 +1631,30 @@ LEAF_NOPROFILE(MIPSX(tlb_invalid_excepti @@ -1629,27 +1631,30 @@ LEAF_NOPROFILE(MIPSX(tlb_invalid_excepti
1629 _SLL k0, k0, WIRED_SHIFT 1631 _SLL k0, k0, WIRED_SHIFT
1630 mfc0 k1, MIPS_COP_0_TLB_INDEX 1632 mfc0 k1, MIPS_COP_0_TLB_INDEX
1631 _SRL k0, k0, WIRED_SHIFT 1633 _SRL k0, k0, WIRED_SHIFT
1632 sltiu k1, k1, MIPS3_TLB_WIRED_UPAGES # Luckily this is MIPS3_PG_G 1634 sltiu k1, k1, MIPS3_TLB_WIRED_UPAGES # Luckily this is MIPS3_PG_G
1633 or k1, k1, k0 1635 or k1, k1, k0
1634 _MTC0 k0, MIPS_COP_0_TLB_LO1 # load PTE entry 1636 _MTC0 k0, MIPS_COP_0_TLB_LO1 # load PTE entry
1635 COP0_SYNC 1637 COP0_SYNC
1636#ifdef MIPS3 1638#ifdef MIPS3
1637 nop 1639 nop
1638 nop # required for QED5230 1640 nop # required for QED5230
1639#endif 1641#endif
1640 tlbwi # write TLB 1642 tlbwi # write TLB
1641 COP0_SYNC 1643 COP0_SYNC
1642#ifdef MIPS3 1644#ifdef MIPS3_LOONGSON2
 1645 li k0, 4 # ugly
 1646 mtc0 k0, MIPS_COP_0_DIAG # invalidate ITLB
 1647#elif defined(MIPS3)
1643 nop 1648 nop
1644 nop 1649 nop
1645#endif 1650#endif
1646 eret 1651 eret
1647 1652
1648MIPSX(kern_tlbi_odd): 1653MIPSX(kern_tlbi_odd):
1649 INT_L k0, 0(k1) # get PTE entry 1654 INT_L k0, 0(k1) # get PTE entry
1650 _SLL k0, k0, WIRED_SHIFT # get rid of wired bit 1655 _SLL k0, k0, WIRED_SHIFT # get rid of wired bit
1651 _SRL k0, k0, WIRED_SHIFT 1656 _SRL k0, k0, WIRED_SHIFT
1652 _MTC0 k0, MIPS_COP_0_TLB_LO1 # save PTE entry 1657 _MTC0 k0, MIPS_COP_0_TLB_LO1 # save PTE entry
1653 COP0_SYNC 1658 COP0_SYNC
1654 and k0, k0, MIPS3_PG_V # check for valid entry 1659 and k0, k0, MIPS3_PG_V # check for valid entry
1655#ifdef MIPS3 1660#ifdef MIPS3
@@ -1661,27 +1666,30 @@ MIPSX(kern_tlbi_odd): @@ -1661,27 +1666,30 @@ MIPSX(kern_tlbi_odd):
1661 INT_L k0, -4(k1) # get even PTE entry 1666 INT_L k0, -4(k1) # get even PTE entry
1662 _SLL k0, k0, WIRED_SHIFT 1667 _SLL k0, k0, WIRED_SHIFT
1663 mfc0 k1, MIPS_COP_0_TLB_INDEX 1668 mfc0 k1, MIPS_COP_0_TLB_INDEX
1664 _SRL k0, k0, WIRED_SHIFT 1669 _SRL k0, k0, WIRED_SHIFT
1665 sltiu k1, k1, MIPS3_TLB_WIRED_UPAGES # Luckily this is MIPS3_PG_G 1670 sltiu k1, k1, MIPS3_TLB_WIRED_UPAGES # Luckily this is MIPS3_PG_G
1666 or k1, k1, k0 1671 or k1, k1, k0
1667 _MTC0 k0, MIPS_COP_0_TLB_LO0 # save PTE entry 1672 _MTC0 k0, MIPS_COP_0_TLB_LO0 # save PTE entry
1668 COP0_SYNC 1673 COP0_SYNC
1669#ifdef MIPS3 1674#ifdef MIPS3
1670 nop # required for QED5230 1675 nop # required for QED5230
1671#endif 1676#endif
1672 tlbwi # update TLB 1677 tlbwi # update TLB
1673 COP0_SYNC 1678 COP0_SYNC
1674#ifdef MIPS3 1679#ifdef MIPS3_LOONGSON2
 1680 li k0, 4 # ugly
 1681 mtc0 k0, MIPS_COP_0_DIAG # invalidate ITLB
 1682#elif defined(MIPS3)
1675 nop 1683 nop
1676 nop 1684 nop
1677#endif 1685#endif
1678 eret 1686 eret
1679END(MIPSX(tlb_invalid_exception)) 1687END(MIPSX(tlb_invalid_exception))
1680 1688
1681/* 1689/*
1682 * Mark where code entered from exception hander jumptable 1690 * Mark where code entered from exception hander jumptable
1683 * ends, for stack traceback code. 1691 * ends, for stack traceback code.
1684 */ 1692 */
1685 1693
1686 .globl _C_LABEL(MIPSX(exceptionentry_end)) 1694 .globl _C_LABEL(MIPSX(exceptionentry_end))
1687_C_LABEL(MIPSX(exceptionentry_end)): 1695_C_LABEL(MIPSX(exceptionentry_end)):
@@ -1743,46 +1751,52 @@ LEAF(MIPSX(tlb_update)) @@ -1743,46 +1751,52 @@ LEAF(MIPSX(tlb_update))
1743 nop 1751 nop
1744# EVEN 1752# EVEN
1745 bltz v0, 1f # index < 0 => !found 1753 bltz v0, 1f # index < 0 => !found
1746 nop 1754 nop
1747#ifdef MIPS3 1755#ifdef MIPS3
1748 nop # required for QED5230 1756 nop # required for QED5230
1749#endif 1757#endif
1750 tlbr # update, read entry first 1758 tlbr # update, read entry first
1751 COP0_SYNC 1759 COP0_SYNC
1752 _MTC0 a1, MIPS_COP_0_TLB_LO0 # init low reg0. 1760 _MTC0 a1, MIPS_COP_0_TLB_LO0 # init low reg0.
1753 COP0_SYNC 1761 COP0_SYNC
1754 tlbwi # update slot found 1762 tlbwi # update slot found
1755 COP0_SYNC 1763 COP0_SYNC
1756#ifdef MIPS3 1764#ifdef MIPS3_LOONGSON2
 1765 li v0, 4 # ugly
 1766 mtc0 v0, MIPS_COP_0_DIAG # invalidate ITLB
 1767#elif defined(MIPS3)
1757 nop # required for QED5230 1768 nop # required for QED5230
1758 nop # required for QED5230 1769 nop # required for QED5230
1759#endif 1770#endif
1760 b 4f 1771 b 4f
1761 nop 1772 nop
17621: 17731:
1763# ODD 1774# ODD
1764 bltz v0, 4f # index < 0 => !found 1775 bltz v0, 4f # index < 0 => !found
1765 nop 1776 nop
1766#ifdef MIPS3 1777#ifdef MIPS3
1767 nop # required for QED5230 1778 nop # required for QED5230
1768#endif 1779#endif
1769 tlbr # read the entry first 1780 tlbr # read the entry first
1770 COP0_SYNC 1781 COP0_SYNC
1771 _MTC0 a1, MIPS_COP_0_TLB_LO1 # init low reg1. 1782 _MTC0 a1, MIPS_COP_0_TLB_LO1 # init low reg1.
1772 COP0_SYNC 1783 COP0_SYNC
1773 tlbwi # update slot found 1784 tlbwi # update slot found
1774 COP0_SYNC 1785 COP0_SYNC
1775#ifdef MIPS3 1786#ifdef MIPS3_LOONGSON2
 1787 li v0, 4 # ugly
 1788 mtc0 v0, MIPS_COP_0_DIAG # invalidate ITLB
 1789#elif defined(MIPS3)
1776 nop # required for QED5230 1790 nop # required for QED5230
1777 nop # required for QED5230 1791 nop # required for QED5230
1778#endif 1792#endif
17794: 17934:
1780#ifdef MIPS3 1794#ifdef MIPS3
1781 nop # Make sure pipeline 1795 nop # Make sure pipeline
1782 nop # advances before we 1796 nop # advances before we
1783 nop # use the TLB. 1797 nop # use the TLB.
1784 nop 1798 nop
1785#endif 1799#endif
1786 _MTC0 t0, MIPS_COP_0_TLB_HI # restore PID 1800 _MTC0 t0, MIPS_COP_0_TLB_HI # restore PID
1787 COP0_SYNC 1801 COP0_SYNC
1788#ifdef MIPS3 1802#ifdef MIPS3
@@ -1880,27 +1894,30 @@ LEAF_NOPROFILE(MIPSX(tlb_invalidate_addr @@ -1880,27 +1894,30 @@ LEAF_NOPROFILE(MIPSX(tlb_invalidate_addr
1880 _MTC0 zero, MIPS_COP_0_TLB_LO0 # zero out entryLo0 1894 _MTC0 zero, MIPS_COP_0_TLB_LO0 # zero out entryLo0
1881 _MTC0 zero, MIPS_COP_0_TLB_LO1 # zero out entryLo1 1895 _MTC0 zero, MIPS_COP_0_TLB_LO1 # zero out entryLo1
1882#if 0 1896#if 0
1883 mtc0 zero, MIPS_COP_0_TLB_PG_MASK # zero out pageMask 1897 mtc0 zero, MIPS_COP_0_TLB_PG_MASK # zero out pageMask
1884#endif 1898#endif
1885 COP0_SYNC 1899 COP0_SYNC
1886#ifdef MIPS3 1900#ifdef MIPS3
1887 nop 1901 nop
1888 nop 1902 nop
1889#endif 1903#endif
1890 1904
1891 tlbwi 1905 tlbwi
1892 COP0_SYNC 1906 COP0_SYNC
1893#ifdef MIPS3 1907#ifdef MIPS3_LOONGSON2
 1908 li v0, 4 # ugly
 1909 mtc0 v0, MIPS_COP_0_DIAG # invalidate ITLB
 1910#elif defined(MIPS3)
1894 nop 1911 nop
1895 nop 1912 nop
1896#endif 1913#endif
18971: 19141:
1898 _MTC0 t0, MIPS_COP_0_TLB_HI # restore current ASID 1915 _MTC0 t0, MIPS_COP_0_TLB_HI # restore current ASID
1899 mtc0 t3, MIPS_COP_0_TLB_PG_MASK # restore pgMask 1916 mtc0 t3, MIPS_COP_0_TLB_PG_MASK # restore pgMask
1900 COP0_SYNC 1917 COP0_SYNC
1901 mtc0 v1, MIPS_COP_0_STATUS # restore status register 1918 mtc0 v1, MIPS_COP_0_STATUS # restore status register
1902 JR_HB_RA 1919 JR_HB_RA
1903END(MIPSX(tlb_invalidate_addr)) 1920END(MIPSX(tlb_invalidate_addr))
1904 1921
1905/* 1922/*
1906 * void mipsN_tlb_invalidate_asids(uint32_t base, uint32_t limit); 1923 * void mipsN_tlb_invalidate_asids(uint32_t base, uint32_t limit);
@@ -1946,26 +1963,32 @@ LEAF_NOPROFILE(MIPSX(tlb_invalidate_asid @@ -1946,26 +1963,32 @@ LEAF_NOPROFILE(MIPSX(tlb_invalidate_asid
1946 _MTC0 zero, MIPS_COP_0_TLB_LO1 # zero out entryLo1 1963 _MTC0 zero, MIPS_COP_0_TLB_LO1 # zero out entryLo1
1947 mtc0 zero, MIPS_COP_0_TLB_PG_MASK # zero out mask entry 1964 mtc0 zero, MIPS_COP_0_TLB_PG_MASK # zero out mask entry
1948 COP0_SYNC 1965 COP0_SYNC
1949 tlbwi # invalidate the TLB entry 1966 tlbwi # invalidate the TLB entry
1950 COP0_SYNC 1967 COP0_SYNC
19512: 19682:
1952 addu t1, 1 1969 addu t1, 1
1953 bne t1, t2, 1b 1970 bne t1, t2, 1b
1954 nop 1971 nop
1955 1972
1956 _MFC0 t0, MIPS_COP_0_TLB_HI # restore PID. 1973 _MFC0 t0, MIPS_COP_0_TLB_HI # restore PID.
1957 mtc0 t3, MIPS_COP_0_TLB_PG_MASK # restore pgMask 1974 mtc0 t3, MIPS_COP_0_TLB_PG_MASK # restore pgMask
1958 COP0_SYNC 1975 COP0_SYNC
 1976
 1977#ifdef MIPS3_LOONGSON2
 1978 li v0, 4 # ugly
 1979 mtc0 v0, MIPS_COP_0_DIAG # invalidate ITLB
 1980#endif
 1981
1959 mtc0 v1, MIPS_COP_0_STATUS # restore status register 1982 mtc0 v1, MIPS_COP_0_STATUS # restore status register
1960 JR_HB_RA # new ASID will be set soon 1983 JR_HB_RA # new ASID will be set soon
1961END(MIPSX(tlb_invalidate_asids)) 1984END(MIPSX(tlb_invalidate_asids))
1962 1985
1963/* 1986/*
1964 * void mipsN_tlb_invalidate_globals(void); 1987 * void mipsN_tlb_invalidate_globals(void);
1965 * 1988 *
1966 * Invalidate the non-wired TLB entries belonging to kernel space while 1989 * Invalidate the non-wired TLB entries belonging to kernel space while
1967 * leaving entries for user space (not marked global) intact. 1990 * leaving entries for user space (not marked global) intact.
1968 */ 1991 */
1969LEAF_NOPROFILE(MIPSX(tlb_invalidate_globals)) 1992LEAF_NOPROFILE(MIPSX(tlb_invalidate_globals))
1970 mfc0 v1, MIPS_COP_0_STATUS # save status register 1993 mfc0 v1, MIPS_COP_0_STATUS # save status register
1971 mtc0 zero, MIPS_COP_0_STATUS # disable interrupts 1994 mtc0 zero, MIPS_COP_0_STATUS # disable interrupts
@@ -1995,26 +2018,32 @@ LEAF_NOPROFILE(MIPSX(tlb_invalidate_glob @@ -1995,26 +2018,32 @@ LEAF_NOPROFILE(MIPSX(tlb_invalidate_glob
1995 _MTC0 zero, MIPS_COP_0_TLB_LO1 # zero out entryLo1 2018 _MTC0 zero, MIPS_COP_0_TLB_LO1 # zero out entryLo1
1996 mtc0 zero, MIPS_COP_0_TLB_PG_MASK # zero out mask entry 2019 mtc0 zero, MIPS_COP_0_TLB_PG_MASK # zero out mask entry
1997 COP0_SYNC 2020 COP0_SYNC
1998 tlbwi # invalidate the TLB entry 2021 tlbwi # invalidate the TLB entry
1999 COP0_SYNC 2022 COP0_SYNC
20002: 20232:
2001 addu t1, 1 2024 addu t1, 1
2002 bne t1, t2, 1b 2025 bne t1, t2, 1b
2003 nop 2026 nop
2004 2027
2005 _MTC0 t0, MIPS_COP_0_TLB_HI # restore current ASID 2028 _MTC0 t0, MIPS_COP_0_TLB_HI # restore current ASID
2006 mtc0 t3, MIPS_COP_0_TLB_PG_MASK # restore pgMask 2029 mtc0 t3, MIPS_COP_0_TLB_PG_MASK # restore pgMask
2007 COP0_SYNC 2030 COP0_SYNC
 2031
 2032#ifdef MIPS3_LOONGSON2
 2033 li v0, 4 # ugly
 2034 mtc0 v0, MIPS_COP_0_DIAG # invalidate ITLB
 2035#endif
 2036
2008 mtc0 v1, MIPS_COP_0_STATUS # restore status register 2037 mtc0 v1, MIPS_COP_0_STATUS # restore status register
2009 JR_HB_RA 2038 JR_HB_RA
2010END(MIPSX(tlb_invalidate_globals)) 2039END(MIPSX(tlb_invalidate_globals))
2011 2040
2012/* 2041/*
2013 * void mipsN_tlb_invalidate_all(void); 2042 * void mipsN_tlb_invalidate_all(void);
2014 * 2043 *
2015 * Invalidate all of non-wired TLB entries. 2044 * Invalidate all of non-wired TLB entries.
2016 */ 2045 */
2017LEAF_NOPROFILE(MIPSX(tlb_invalidate_all)) 2046LEAF_NOPROFILE(MIPSX(tlb_invalidate_all))
2018 mfc0 v1, MIPS_COP_0_STATUS # save status register 2047 mfc0 v1, MIPS_COP_0_STATUS # save status register
2019 mtc0 zero, MIPS_COP_0_STATUS # disable interrupts 2048 mtc0 zero, MIPS_COP_0_STATUS # disable interrupts
2020 COP0_SYNC 2049 COP0_SYNC
@@ -2037,26 +2066,32 @@ LEAF_NOPROFILE(MIPSX(tlb_invalidate_all) @@ -2037,26 +2066,32 @@ LEAF_NOPROFILE(MIPSX(tlb_invalidate_all)
2037 sll ta0, t1, PGSHIFT + 1 # PAGE_SHIFT + 1 2066 sll ta0, t1, PGSHIFT + 1 # PAGE_SHIFT + 1
2038 PTR_ADDU ta0, v0 2067 PTR_ADDU ta0, v0
2039 _MTC0 ta0, MIPS_COP_0_TLB_HI # make entryHi invalid 2068 _MTC0 ta0, MIPS_COP_0_TLB_HI # make entryHi invalid
2040 COP0_SYNC 2069 COP0_SYNC
2041 tlbwi # clear the entry 2070 tlbwi # clear the entry
2042 COP0_SYNC 2071 COP0_SYNC
2043 addu t1, 1 # increment index 2072 addu t1, 1 # increment index
2044 bne t1, a0, 1b 2073 bne t1, a0, 1b
2045 nop 2074 nop
2046 2075
2047 _MTC0 t0, MIPS_COP_0_TLB_HI # restore ASID 2076 _MTC0 t0, MIPS_COP_0_TLB_HI # restore ASID
2048 mtc0 t2, MIPS_COP_0_TLB_PG_MASK # restore pgMask 2077 mtc0 t2, MIPS_COP_0_TLB_PG_MASK # restore pgMask
2049 COP0_SYNC 2078 COP0_SYNC
 2079
 2080#ifdef MIPS3_LOONGSON2
 2081 li v0, 4 # ugly
 2082 mtc0 v0, MIPS_COP_0_DIAG # invalidate ITLB
 2083#endif
 2084
2050 mtc0 v1, MIPS_COP_0_STATUS # restore status register 2085 mtc0 v1, MIPS_COP_0_STATUS # restore status register
2051 JR_HB_RA 2086 JR_HB_RA
2052END(MIPSX(tlb_invalidate_all)) 2087END(MIPSX(tlb_invalidate_all))
2053 2088
2054/* 2089/*
2055 * u_int mipsN_tlb_record_asids(u_long *bitmap, uint32_t asid_mask) 2090 * u_int mipsN_tlb_record_asids(u_long *bitmap, uint32_t asid_mask)
2056 * 2091 *
2057 * Record all the ASIDs in use in the TLB and return the number of different 2092 * Record all the ASIDs in use in the TLB and return the number of different
2058 * ASIDs present. 2093 * ASIDs present.
2059 */ 2094 */
2060LEAF_NOPROFILE(MIPSX(tlb_record_asids)) 2095LEAF_NOPROFILE(MIPSX(tlb_record_asids))
2061 _MFC0 a3, MIPS_COP_0_TLB_HI # Save the current PID. 2096 _MFC0 a3, MIPS_COP_0_TLB_HI # Save the current PID.
2062 mfc0 ta0, MIPS_COP_0_TLB_WIRED 2097 mfc0 ta0, MIPS_COP_0_TLB_WIRED
@@ -2194,26 +2229,32 @@ LEAF(MIPSX(tlb_enter)) @@ -2194,26 +2229,32 @@ LEAF(MIPSX(tlb_enter))
2194 or t2, ta2, ta3 # t2 = (v1 & t2) | (~v1 & a2) 2229 or t2, ta2, ta3 # t2 = (v1 & t2) | (~v1 & a2)
2195 and ta2, t3, v0 2230 and ta2, t3, v0
2196 and ta3, a2, v1 2231 and ta3, a2, v1
2197 or t3, ta2, ta3 # t3 = (~v1 & t3) | (v1 & a2) 2232 or t3, ta2, ta3 # t3 = (~v1 & t3) | (v1 & a2)
2198 2233
2199 mtc0 t2, MIPS_COP_0_TLB_LO0 # set tlb_lo0 (even) 2234 mtc0 t2, MIPS_COP_0_TLB_LO0 # set tlb_lo0 (even)
2200 mtc0 t3, MIPS_COP_0_TLB_LO1 # set tlb_lo1 (odd) 2235 mtc0 t3, MIPS_COP_0_TLB_LO1 # set tlb_lo1 (odd)
2201 COP0_SYNC 2236 COP0_SYNC
2202 2237
2203 tlbwi # enter it into the TLB 2238 tlbwi # enter it into the TLB
2204 COP0_SYNC 2239 COP0_SYNC
2205 2240
2206 _MTC0 ta1, MIPS_COP_0_TLB_HI # restore EntryHi 2241 _MTC0 ta1, MIPS_COP_0_TLB_HI # restore EntryHi
 2242
 2243#ifdef MIPS3_LOONGSON2
 2244 li v0, 4 # ugly
 2245 mtc0 v0, MIPS_COP_0_DIAG # invalidate ITLB
 2246#endif
 2247
2207 JR_HB_RA 2248 JR_HB_RA
2208 .set at 2249 .set at
2209END(MIPSX(tlb_enter)) 2250END(MIPSX(tlb_enter))
2210 2251
2211/* 2252/*
2212 * mipsN_lwp_trampoline() 2253 * mipsN_lwp_trampoline()
2213 * 2254 *
2214 * Arrange for a function to be invoked neatly, after a cpu_switch(). 2255 * Arrange for a function to be invoked neatly, after a cpu_switch().
2215 * Call the service function with one argument, specified by the s0 2256 * Call the service function with one argument, specified by the s0
2216 * and s1 respectively. There is no need register save operation. 2257 * and s1 respectively. There is no need register save operation.
2217 */ 2258 */
2218LEAF(MIPSX(lwp_trampoline)) 2259LEAF(MIPSX(lwp_trampoline))
2219 PTR_ADDU sp, -CALLFRAME_SIZ 2260 PTR_ADDU sp, -CALLFRAME_SIZ
@@ -2422,26 +2463,32 @@ LEAF(MIPSX(tlb_write_indexed)) @@ -2422,26 +2463,32 @@ LEAF(MIPSX(tlb_write_indexed))
2422 mtc0 a0, MIPS_COP_0_TLB_INDEX # Set the index. 2463 mtc0 a0, MIPS_COP_0_TLB_INDEX # Set the index.
2423 mtc0 a2, MIPS_COP_0_TLB_PG_MASK # Set up entry pagemask. 2464 mtc0 a2, MIPS_COP_0_TLB_PG_MASK # Set up entry pagemask.
2424 _MTC0 a3, MIPS_COP_0_TLB_HI # Set up entry high. 2465 _MTC0 a3, MIPS_COP_0_TLB_HI # Set up entry high.
2425 COP0_SYNC 2466 COP0_SYNC
2426 tlbwi # Write the TLB 2467 tlbwi # Write the TLB
2427 COP0_SYNC 2468 COP0_SYNC
2428#ifdef MIPS3 2469#ifdef MIPS3
2429 nop 2470 nop
2430#endif 2471#endif
2431 2472
2432 _MTC0 t0, MIPS_COP_0_TLB_HI # Restore the PID. 2473 _MTC0 t0, MIPS_COP_0_TLB_HI # Restore the PID.
2433 mtc0 v0, MIPS_COP_0_TLB_PG_MASK # Restore page mask. 2474 mtc0 v0, MIPS_COP_0_TLB_PG_MASK # Restore page mask.
2434 COP0_SYNC 2475 COP0_SYNC
 2476
 2477#ifdef MIPS3_LOONGSON2
 2478 li v0, 4 # ugly
 2479 mtc0 v0, MIPS_COP_0_DIAG # invalidate ITLB
 2480#endif
 2481
2435 mtc0 v1, MIPS_COP_0_STATUS # Restore the status register 2482 mtc0 v1, MIPS_COP_0_STATUS # Restore the status register
2436 JR_HB_RA 2483 JR_HB_RA
2437END(MIPSX(tlb_write_indexed)) 2484END(MIPSX(tlb_write_indexed))
2438 2485
2439#if defined(MIPS3) 2486#if defined(MIPS3)
2440/*---------------------------------------------------------------------------- 2487/*----------------------------------------------------------------------------
2441 * 2488 *
2442 * mipsN_VCED -- 2489 * mipsN_VCED --
2443 * 2490 *
2444 * Handle virtual coherency exceptions. 2491 * Handle virtual coherency exceptions.
2445 * Called directly from the mips3 exception-table code. 2492 * Called directly from the mips3 exception-table code.
2446 * only k0, k1 are available on entry 2493 * only k0, k1 are available on entry
2447 * 2494 *

cvs diff -r1.244 -r1.245 src/sys/arch/mips/mips/mips_machdep.c (expand / switch to unified diff)

--- src/sys/arch/mips/mips/mips_machdep.c 2011/06/14 05:30:40 1.244
+++ src/sys/arch/mips/mips/mips_machdep.c 2011/07/31 15:39:29 1.245
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mips_machdep.c,v 1.244 2011/06/14 05:30:40 matt Exp $ */ 1/* $NetBSD: mips_machdep.c,v 1.245 2011/07/31 15:39:29 matt 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
@@ -102,27 +102,27 @@ @@ -102,27 +102,27 @@
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 114
115__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.244 2011/06/14 05:30:40 matt Exp $"); 115__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.245 2011/07/31 15:39:29 matt Exp $");
116 116
117#define __INTR_PRIVATE 117#define __INTR_PRIVATE
118#include "opt_cputype.h" 118#include "opt_cputype.h"
119#include "opt_compat_netbsd32.h" 119#include "opt_compat_netbsd32.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>
@@ -210,26 +210,32 @@ int safepri = IPL_SOFTSERIAL; @@ -210,26 +210,32 @@ int safepri = IPL_SOFTSERIAL;
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)
 224static void loongson2_vector_init(const struct splsw *);
 225extern const struct locoresw loongson2_locoresw;
 226extern const mips_locore_jumpvec_t loongson2_locore_vec;
 227#endif
 228
223#if defined(MIPS32) 229#if defined(MIPS32)
224static void mips32_vector_init(const struct splsw *); 230static void mips32_vector_init(const struct splsw *);
225extern const struct locoresw mips32_locoresw; 231extern const struct locoresw mips32_locoresw;
226extern const mips_locore_jumpvec_t mips32_locore_vec; 232extern const mips_locore_jumpvec_t mips32_locore_vec;
227#endif 233#endif
228 234
229#if defined(MIPS32R2) 235#if defined(MIPS32R2)
230static void mips32r2_vector_init(const struct splsw *); 236static void mips32r2_vector_init(const struct splsw *);
231extern const struct locoresw mips32r2_locoresw; 237extern const struct locoresw mips32r2_locoresw;
232extern const mips_locore_jumpvec_t mips32r2_locore_vec; 238extern const mips_locore_jumpvec_t mips32r2_locore_vec;
233#endif 239#endif
234 240
235#if defined(MIPS64) 241#if defined(MIPS64)
@@ -422,31 +428,31 @@ static const struct pridtab cputab[] = { @@ -422,31 +428,31 @@ static const struct pridtab cputab[] = {
422 /*  428 /*
423 * ICT Loongson2 is a MIPS64 CPU with a few quirks. For some reason 429 * ICT Loongson2 is a MIPS64 CPU with a few quirks. For some reason
424 * the virtual aliases present with 4KB pages make the caches misbehave 430 * the virtual aliases present with 4KB pages make the caches misbehave
425 * so we make all accesses uncached. With 16KB pages, no virtual 431 * so we make all accesses uncached. With 16KB pages, no virtual
426 * aliases are possible so we can use caching. 432 * aliases are possible so we can use caching.
427 */ 433 */
428#ifdef ENABLE_MIPS_16KB_PAGE 434#ifdef ENABLE_MIPS_16KB_PAGE
429#define MIPS_LOONGSON2_CCA 0 435#define MIPS_LOONGSON2_CCA 0
430#else 436#else
431#define MIPS_LOONGSON2_CCA (CPU_MIPS_HAVE_SPECIAL_CCA | \ 437#define MIPS_LOONGSON2_CCA (CPU_MIPS_HAVE_SPECIAL_CCA | \
432 (2 << CPU_MIPS_CACHED_CCA_SHIFT)) 438 (2 << CPU_MIPS_CACHED_CCA_SHIFT))
433#endif 439#endif
434 { 0, MIPS_LOONGSON2, MIPS_REV_LOONGSON2E, -1, CPU_ARCH_MIPS3, 64, 440 { 0, MIPS_LOONGSON2, MIPS_REV_LOONGSON2E, -1, CPU_ARCH_MIPS3, 64,
435 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT | MIPS_LOONGSON2_CCA, 0, 0, 441 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT | CPU_MIPS_LOONGSON2
436 "ICT Loongson 2E CPU" }, 442 | MIPS_LOONGSON2_CCA, 0, 0, "ICT Loongson 2E CPU" },
437 { 0, MIPS_LOONGSON2, MIPS_REV_LOONGSON2F, -1, CPU_ARCH_MIPS3, 64, 443 { 0, MIPS_LOONGSON2, MIPS_REV_LOONGSON2F, -1, CPU_ARCH_MIPS3, 64,
438 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT | MIPS_LOONGSON2_CCA, 0, 0, 444 CPU_MIPS_R4K_MMU | CPU_MIPS_DOUBLE_COUNT | CPU_MIPS_LOONGSON2
439 "ICT Loongson 2F CPU" }, 445 | MIPS_LOONGSON2_CCA, 0, 0, "ICT Loongson 2F CPU" },
440 446
441#if 0 /* ID collisions : can we use a CU1 test or similar? */ 447#if 0 /* ID collisions : can we use a CU1 test or similar? */
442 { 0, MIPS_R3SONY, -1, -1, CPU_ARCH_MIPS1, -1, 448 { 0, MIPS_R3SONY, -1, -1, CPU_ARCH_MIPS1, -1,
443 MIPS_NOT_SUPP, 0, 0, "SONY R3000 derivative" }, /* 0x21; crash R4700? */ 449 MIPS_NOT_SUPP, 0, 0, "SONY R3000 derivative" }, /* 0x21; crash R4700? */
444 { 0, MIPS_R3NKK, -1, -1, CPU_ARCH_MIPS1, -1, 450 { 0, MIPS_R3NKK, -1, -1, CPU_ARCH_MIPS1, -1,
445 MIPS_NOT_SUPP, 0, 0, "NKK R3000 derivative" }, /* 0x23; crash R5000? */ 451 MIPS_NOT_SUPP, 0, 0, "NKK R3000 derivative" }, /* 0x23; crash R5000? */
446#endif 452#endif
447 453
448 { MIPS_PRID_CID_MTI, MIPS_4Kc, -1, -1, -1, 0, 454 { MIPS_PRID_CID_MTI, MIPS_4Kc, -1, -1, -1, 0,
449 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 0, 0, "4Kc" }, 455 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 0, 0, "4Kc" },
450 { MIPS_PRID_CID_MTI, MIPS_4KEc, -1, -1, -1, 0, 456 { MIPS_PRID_CID_MTI, MIPS_4KEc, -1, -1, -1, 0,
451 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 0, 0, "4KEc" }, 457 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 0, 0, "4KEc" },
452 { MIPS_PRID_CID_MTI, MIPS_4KEc_R2, -1, -1, -1, 0, 458 { MIPS_PRID_CID_MTI, MIPS_4KEc_R2, -1, -1, -1, 0,
@@ -469,26 +475,27 @@ static const struct pridtab cputab[] = { @@ -469,26 +475,27 @@ static const struct pridtab cputab[] = {
469 MIPS_CP0FL_USE | 475 MIPS_CP0FL_USE |
470 MIPS_CP0FL_EBASE | MIPS_CP0FL_USERLOCAL | MIPS_CP0FL_HWRENA | 476 MIPS_CP0FL_EBASE | MIPS_CP0FL_USERLOCAL | MIPS_CP0FL_HWRENA |
471 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 | 477 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 |
472 MIPS_CP0FL_CONFIG3 | MIPS_CP0FL_CONFIG7, 478 MIPS_CP0FL_CONFIG3 | MIPS_CP0FL_CONFIG7,
473 0, "24KE" }, 479 0, "24KE" },
474 { MIPS_PRID_CID_MTI, MIPS_34K, -1, -1, -1, 0, 480 { MIPS_PRID_CID_MTI, MIPS_34K, -1, -1, -1, 0,
475 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 481 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT,
476 MIPS_CP0FL_USE | 482 MIPS_CP0FL_USE |
477 MIPS_CP0FL_EBASE | MIPS_CP0FL_USERLOCAL | MIPS_CP0FL_HWRENA | 483 MIPS_CP0FL_EBASE | MIPS_CP0FL_USERLOCAL | MIPS_CP0FL_HWRENA |
478 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 | 484 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 |
479 MIPS_CP0FL_CONFIG3 | MIPS_CP0FL_CONFIG7, 485 MIPS_CP0FL_CONFIG3 | MIPS_CP0FL_CONFIG7,
480 0, "34K" }, 486 0, "34K" },
481 { 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) |
482 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 489 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT,
483 MIPS_CP0FL_USE | 490 MIPS_CP0FL_USE |
484 MIPS_CP0FL_EBASE | MIPS_CP0FL_USERLOCAL | MIPS_CP0FL_HWRENA | 491 MIPS_CP0FL_EBASE | MIPS_CP0FL_USERLOCAL | MIPS_CP0FL_HWRENA |
485 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 | 492 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 |
486 MIPS_CP0FL_CONFIG3 | MIPS_CP0FL_CONFIG6 | MIPS_CP0FL_CONFIG7, 493 MIPS_CP0FL_CONFIG3 | MIPS_CP0FL_CONFIG6 | MIPS_CP0FL_CONFIG7,
487 0, "74K" }, 494 0, "74K" },
488 { MIPS_PRID_CID_MTI, MIPS_1004K, -1, -1, -1, 0, 495 { MIPS_PRID_CID_MTI, MIPS_1004K, -1, -1, -1, 0,
489 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT, 496 MIPS32_FLAGS | CPU_MIPS_DOUBLE_COUNT,
490 MIPS_CP0FL_USE | 497 MIPS_CP0FL_USE |
491 MIPS_CP0FL_EBASE | MIPS_CP0FL_USERLOCAL | MIPS_CP0FL_HWRENA | 498 MIPS_CP0FL_EBASE | MIPS_CP0FL_USERLOCAL | MIPS_CP0FL_HWRENA |
492 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 | 499 MIPS_CP0FL_CONFIG | MIPS_CP0FL_CONFIG1 | MIPS_CP0FL_CONFIG2 |
493 MIPS_CP0FL_CONFIG3 | MIPS_CP0FL_CONFIG6 | MIPS_CP0FL_CONFIG7, 500 MIPS_CP0FL_CONFIG3 | MIPS_CP0FL_CONFIG6 | MIPS_CP0FL_CONFIG7,
494 0, "1004K" }, 501 0, "1004K" },
@@ -732,26 +739,73 @@ mips3_vector_init(const struct splsw *sp @@ -732,26 +739,73 @@ mips3_vector_init(const struct splsw *sp
732 /* 739 /*
733 * Copy locore-function vector. 740 * Copy locore-function vector.
734 */ 741 */
735 mips_locore_jumpvec = mips3_locore_vec; 742 mips_locore_jumpvec = mips3_locore_vec;
736 743
737 mips_icache_sync_all(); 744 mips_icache_sync_all();
738 mips_dcache_wbinv_all(); 745 mips_dcache_wbinv_all();
739 746
740 /* Clear BEV in SR so we start handling our own exceptions */ 747 /* Clear BEV in SR so we start handling our own exceptions */
741 mips_cp0_status_write(mips_cp0_status_read() & ~MIPS_SR_BEV); 748 mips_cp0_status_write(mips_cp0_status_read() & ~MIPS_SR_BEV);
742} 749}
743#endif /* MIPS3 */ 750#endif /* MIPS3 */
744 751
 752#if defined(MIPS3_LOONGSON2)
 753static void
 754loongson2_vector_init(const struct splsw *splsw)
 755{
 756 /* r4000 exception handler address and end */
 757 extern char loongson2_exception[], loongson2_exception_end[];
 758
 759 /* TLB miss handler address and end */
 760 extern char loongson2_tlb_miss[];
 761 extern char loongson2_xtlb_miss[];
 762
 763 /* Cache error handler */
 764 extern char loongson2_cache[];
 765
 766 /*
 767 * Copy down exception vector code.
 768 */
 769
 770 if (loongson2_xtlb_miss - loongson2_tlb_miss != 0x80)
 771 panic("startup: %s vector code not 128 bytes in length",
 772 "UTLB");
 773 if (loongson2_cache - loongson2_xtlb_miss != 0x80)
 774 panic("startup: %s vector code not 128 bytes in length",
 775 "XTLB");
 776 if (loongson2_exception - loongson2_cache != 0x80)
 777 panic("startup: %s vector code not 128 bytes in length",
 778 "Cache error");
 779 if (loongson2_exception_end - loongson2_exception > 0x80)
 780 panic("startup: %s vector code too large",
 781 "General exception");
 782
 783 memcpy((void *)MIPS_UTLB_MISS_EXC_VEC, loongson2_tlb_miss,
 784 loongson2_exception_end - loongson2_tlb_miss);
 785
 786 /*
 787 * Copy locore-function vector.
 788 */
 789 mips_locore_jumpvec = loongson2_locore_vec;
 790
 791 mips_icache_sync_all();
 792 mips_dcache_wbinv_all();
 793
 794 /* Clear BEV in SR so we start handling our own exceptions */
 795 mips_cp0_status_write(mips_cp0_status_read() & ~MIPS_SR_BEV);
 796}
 797#endif /* MIPS3_LOONGSON2 */
 798
745#if defined(MIPS32) 799#if defined(MIPS32)
746static void 800static void
747mips32_vector_init(const struct splsw *splsw) 801mips32_vector_init(const struct splsw *splsw)
748{ 802{
749 /* r4000 exception handler address */ 803 /* r4000 exception handler address */
750 extern char mips32_exception[]; 804 extern char mips32_exception[];
751 805
752 /* TLB miss handler addresses */ 806 /* TLB miss handler addresses */
753 extern char mips32_tlb_miss[]; 807 extern char mips32_tlb_miss[];
754 808
755 /* Cache error handler */ 809 /* Cache error handler */
756 extern char mips32_cache[]; 810 extern char mips32_cache[];
757 811
@@ -1164,32 +1218,41 @@ mips_vector_init(const struct splsw *spl @@ -1164,32 +1218,41 @@ mips_vector_init(const struct splsw *spl
1164 break; 1218 break;
1165#endif 1219#endif
1166#if defined(MIPS3) 1220#if defined(MIPS3)
1167 case CPU_ARCH_MIPS3: 1221 case CPU_ARCH_MIPS3:
1168 case CPU_ARCH_MIPS4: 1222 case CPU_ARCH_MIPS4:
1169 mips3_tlb_probe(); 1223 mips3_tlb_probe();
1170#if defined(MIPS3_4100) 1224#if defined(MIPS3_4100)
1171 if (MIPS_PRID_IMPL(cpu_id) == MIPS_R4100) 1225 if (MIPS_PRID_IMPL(cpu_id) == MIPS_R4100)
1172 mips3_cp0_pg_mask_write(MIPS4100_PG_SIZE_TO_MASK(PAGE_SIZE)); 1226 mips3_cp0_pg_mask_write(MIPS4100_PG_SIZE_TO_MASK(PAGE_SIZE));
1173 else 1227 else
1174#endif 1228#endif
1175 mips3_cp0_pg_mask_write(MIPS3_PG_SIZE_TO_MASK(PAGE_SIZE)); 1229 mips3_cp0_pg_mask_write(MIPS3_PG_SIZE_TO_MASK(PAGE_SIZE));
1176 mips3_cp0_wired_write(0); 1230 mips3_cp0_wired_write(0);
 1231#if defined(MIPS3_LOONGSON2)
 1232 if (opts->mips_cpu_flags & CPU_MIPS_LOONGSON2) {
 1233 (*loongson2_locore_vec.ljv_tlb_invalidate_all)();
 1234 mips3_cp0_wired_write(pmap_tlb0_info.ti_wired);
 1235 loongson2_vector_init(splsw);
 1236 mips_locoresw = loongson2_locoresw;
 1237 break;
 1238 }
 1239#endif /* MIPS3_LOONGSON2 */
1177 (*mips3_locore_vec.ljv_tlb_invalidate_all)(); 1240 (*mips3_locore_vec.ljv_tlb_invalidate_all)();
1178 mips3_cp0_wired_write(pmap_tlb0_info.ti_wired); 1241 mips3_cp0_wired_write(pmap_tlb0_info.ti_wired);
1179 mips3_vector_init(splsw); 1242 mips3_vector_init(splsw);
1180 mips_locoresw = mips3_locoresw; 1243 mips_locoresw = mips3_locoresw;
1181 break; 1244 break;
1182#endif 1245#endif /* MIPS3 */
1183#if defined(MIPS32) 1246#if defined(MIPS32)
1184 case CPU_ARCH_MIPS32: 1247 case CPU_ARCH_MIPS32:
1185 mips3_tlb_probe(); 1248 mips3_tlb_probe();
1186 mips3_cp0_pg_mask_write(MIPS3_PG_SIZE_TO_MASK(PAGE_SIZE)); 1249 mips3_cp0_pg_mask_write(MIPS3_PG_SIZE_TO_MASK(PAGE_SIZE));
1187 mips3_cp0_wired_write(0); 1250 mips3_cp0_wired_write(0);
1188 (*mips32_locore_vec.ljv_tlb_invalidate_all)(); 1251 (*mips32_locore_vec.ljv_tlb_invalidate_all)();
1189 mips3_cp0_wired_write(pmap_tlb0_info.ti_wired); 1252 mips3_cp0_wired_write(pmap_tlb0_info.ti_wired);
1190 mips32_vector_init(splsw); 1253 mips32_vector_init(splsw);
1191 mips_locoresw = mips32_locoresw; 1254 mips_locoresw = mips32_locoresw;
1192 break; 1255 break;
1193#endif 1256#endif
1194#if defined(MIPS32R2) 1257#if defined(MIPS32R2)
1195 case CPU_ARCH_MIPS32R2: 1258 case CPU_ARCH_MIPS32R2: