Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src/sys/arch/sparc64/sparc64 pull up 1.91 (approved by thor...
details: https://anonhg.NetBSD.org/src/rev/f476b8a0a71c
branches: netbsd-1-5
changeset: 488943:f476b8a0a71c
user: mrg <mrg%NetBSD.org@localhost>
date: Mon Aug 07 01:16:34 2000 +0000
description:
pull up 1.91 (approved by thorpej):
>Overhaul cache flush code and coredump code.
diffstat:
sys/arch/sparc64/sparc64/locore.s | 421 +++++++++++++++++++++++++------------
1 files changed, 287 insertions(+), 134 deletions(-)
diffs (truncated from 621 to 300 lines):
diff -r 548f370b2921 -r f476b8a0a71c sys/arch/sparc64/sparc64/locore.s
--- a/sys/arch/sparc64/sparc64/locore.s Mon Aug 07 01:11:28 2000 +0000
+++ b/sys/arch/sparc64/sparc64/locore.s Mon Aug 07 01:16:34 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.s,v 1.62.2.3 2000/07/31 05:12:43 mrg Exp $ */
+/* $NetBSD: locore.s,v 1.62.2.4 2000/08/07 01:16:34 mrg Exp $ */
/*
* Copyright (c) 1996-1999 Eduardo Horvath
* Copyright (c) 1996 Paul Kranenburg
@@ -224,6 +224,23 @@
/*
+ * Combine 2 regs -- used to convert 64-bit ILP32
+ * values to LP64.
+ */
+#define COMBINE(r1, r2, d) \
+ sllx r1, 32, d; \
+ or d, r2, d
+
+/*
+ * Split 64-bit value in 1 reg into high and low halves.
+ * Used for ILP32 return values.
+ */
+#define SPLIT(r0, r1) \
+ srl r0, 0, r1; \
+ srlx r0, 32, r0
+
+
+/*
* A handy macro for maintaining instrumentation counters.
* Note that this clobbers %o0 and %o1. Normal usage is
* something like:
@@ -2942,7 +2959,8 @@
set CPCB, %g6 ! Load up nsaved
LDPTR [%g6], %g6
- ldub [%g6 + PCB_NSAVED], %g6
+ clr %g6
+! ldub [%g6 + PCB_NSAVED], %g6! this could fault
sllx %g6, 9, %g6
or %g6, %g4, %g4
@@ -4191,6 +4209,11 @@
wr %g0, 1, CLEAR_SOFTINT
DLFLUSH(%g3, %g2)
#ifndef TICK_IS_TIME
+ rd TICK_CMPR, %g2
+ rd %tick, %g5
+ srax %g2, 1, %g2
+ cmp %g2, %g5
+ tg %xcc, 1
wrpr %g0, 0, %tick ! Reset %tick so we'll get another interrupt
#endif
ba,pt %icc, setup_sparcintr
@@ -6110,11 +6133,42 @@
flush %o2
retl
wrpr %o3, %pstate
-/*
- * dcache_flush_page()
- *
- * Clear one page from D$. We should do one for the I$,
- * but it does not alias and is not likely as large a problem.
+
+
+/*
+ * blast_icache()
+ *
+ * Clear out all of I$ regardless of contents
+ * Does not modify %o0
+ *
+ */
+ .align 8
+ .globl _C_LABEL(blast_icache)
+ .proc 1
+ FTYPE(blast_icache)
+_C_LABEL(blast_icache):
+/*
+ * We turn off interrupts for the duration to prevent RED exceptions.
+ */
+ rdpr %pstate, %o3
+ set (2*NBPG)-8, %o1
+ andn %o3, PSTATE_IE, %o4 ! Turn off PSTATE_IE bit
+ wrpr %o4, 0, %pstate
+1:
+ stxa %g0, [%o1] ASI_ICACHE_TAG
+ brnz,pt %o1, 1b
+ dec 8, %o1
+ sethi %hi(KERNBASE), %o2
+ flush %o2
+ retl
+ wrpr %o3, %pstate
+
+
+
+/*
+ * dcache_flush_page(vaddr_t pa)
+ *
+ * Clear one page from D$ and I$.
*
*/
.align 8
@@ -6122,28 +6176,185 @@
.proc 1
FTYPE(dcache_flush_page)
_C_LABEL(dcache_flush_page):
- mov -1, %g1 ! Generate mask for tag: bits [29..2]
- srlx %o0, 13-2, %g2 ! Tag is VA bits <40:13> in bits <29:2>
- srl %g1, 2, %g1 ! Now we have bits <29:0> set
- andn %g1, 3, %g1 ! Now we have bits <29:2> set
-
- set (2*NBPG), %o3
- clr %o1
-1:
- ldxa [%o1] ASI_DCACHE_TAG, %g3
- xor %g3, %g2, %g3
- andcc %g3, %g1, %g0
+#ifdef _LP64
+ COMBINE(%o0, %o1, %o0)
+#endif
+
+ !! Try using cache_flush_phys for a change.
+
+ mov -1, %o1 ! Generate mask for tag: bits [29..2]
+ srlx %o0, 13-2, %o2 ! Tag is VA bits <40:13> in bits <29:2>
+ srl %o1, 2, %o1 ! Now we have bits <29:0> set
+ andn %o1, 3, %o1 ! Now we have bits <29:2> set
+
+ set (2*NBPG), %o5
+ clr %o4
+1:
+ ldxa [%o4] ASI_DCACHE_TAG, %o3
+ xor %o3, %o2, %o3
+ andcc %o3, %o1, %g0
+ bne,pt %xcc, 2f
+ dec 16, %o5
+ membar #LoadStore
+ stxa %g0, [%o4] ASI_DCACHE_TAG
+ membar #StoreLoad
+2:
+ brnz,pt %o5, 1b
+ inc 16, %o4
+
+ !! Now do the I$
+ mov -1, %o1 ! Generate mask for tag: bits [35..8]
+ srlx %o0, 13-8, %o2
+ srl %o1, 32-35+7, %o1
+ sll %o1, 7, %o1 ! Mask
+
+ set (2*NBPG), %o5
+ clr %o4
+1:
+ ldda [%o4] ASI_ICACHE_TAG, %g0 ! Tag goes in %g1
+ xor %g1, %o2, %g1
+ andcc %g1, %o1, %g0
bne,pt %xcc, 2f
- dec 16, %o3
- stxa %g0, [%o1] ASI_DCACHE_TAG
+ dec 16, %o5
+ membar #LoadStore
+ stxa %g0, [%o4] ASI_ICACHE_TAG
+ membar #StoreLoad
2:
- brnz,pt %o3, 1b
- inc 16, %o1
+ brnz,pt %o5, 1b
+ inc 16, %o4
+
+ sethi %hi(KERNBASE), %o5
+ flush %o5
+ membar #Sync
+ retl
+ nop
+
+/*
+ * cache_flush_virt(va, len)
+ *
+ * Clear everything in that va range from D$ and I$.
+ *
+ */
+ .align 8
+ .globl _C_LABEL(cache_flush_virt)
+ .proc 1
+ FTYPE(cache_flush_virt)
+_C_LABEL(cache_flush_virt):
+ brz,pn %o1, 2f ! What? nothing to clear?
+ add %o0, %o1, %o2
+ mov 0x1ff, %o3
+ sllx %o3, 5, %o3 ! Generate mask for VA bits
+ and %o0, %o3, %o0
+ and %o2, %o3, %o2
+ sub %o2, %o1, %o4 ! End < start? need to split flushes.
+ sethi %hi((1<<13)), %o5
+ brlz,pn %o4, 1f
+ movrz %o4, %o3, %o4 ! If start == end we need to wrap
+
+ !! Clear from start to end
+1:
+ stxa %g0, [%o0] ASI_DCACHE_TAG
+ dec 16, %o4
+ xor %o5, %o0, %o3 ! Second way
+ stxa %g0, [%o0] ASI_ICACHE_TAG
+ stxa %g0, [%o3] ASI_ICACHE_TAG
+ brgz,pt %o4, 1b
+ inc 16, %o0
+2:
sethi %hi(KERNBASE), %o5
flush %o5
+ membar #Sync
retl
nop
+ !! We got a hole. Clear from start to hole
+ clr %o4
+3:
+ stxa %g0, [%o4] ASI_DCACHE_TAG
+ dec 16, %o1
+ xor %o5, %o4, %g1 ! Second way
+ stxa %g0, [%o4] ASI_ICACHE_TAG
+ stxa %g0, [%g1] ASI_ICACHE_TAG
+ brgz,pt %o1, 3b
+ inc 16, %o4
+
+ !! Now clear to the end.
+ sub %o3, %o2, %o4 ! Size to clear (NBPG - end)
+ ba,pt %icc, 1b
+ mov %o2, %o0 ! Start of clear
+
+/*
+ * cache_flush_phys __P((paddr_t, psize_t, int));
+ *
+ * Clear a set of paddrs from the D$, I$ and if param3 is
+ * non-zero, E$. (E$ is not supported yet).
+ */
+
+ .align 8
+ .globl _C_LABEL(cache_flush_phys)
+ .proc 1
+ FTYPE(cache_flush_phys)
+_C_LABEL(cache_flush_phys):
+#ifndef _LP64
+ COMBINE(%o0, %o1, %o0)
+ COMBINE(%o2, %o3, %o1)
+ mov %o4, %o2
+#endif
+#ifdef DEBUG
+ tst %o2 ! Want to clear E$?
+ tnz 1 ! Error!
+#endif
+ add %o0, %o1, %o1 ! End PA
+
+ !!
+ !! Both D$ and I$ tags match pa bits 40-13, but
+ !! they are shifted different amounts. So we'll
+ !! generate a mask for bits 40-13.
+ !!
+
+ mov -1, %o2 ! Generate mask for tag: bits [40..13]
+ srl %o2, 5, %o2 ! 32-5 = [27..0]
+ sllx %o2, 13, %o2 ! 27+13 = [40..13]
+
+ and %o2, %o0, %o0 ! Mask away uninteresting bits
+ and %o2, %o1, %o1 ! (probably not necessary)
+
+ set (2*NBPG), %o5
+ clr %o4
+1:
+ ldxa [%o4] ASI_DCACHE_TAG, %o3
+ ldda [%o4] ASI_ICACHE_TAG, %g0 ! Tag goes in %g1
+ sllx %o3, 40-29, %o3 ! Shift D$ tag into place
+ and %o3, %o2, %o3 ! Mask out trash
+ cmp %o0, %o3
+ blt,pt %xcc, 2f ! Too low
+ sllx %g1, 40-35, %g1 ! Shift I$ tag into place
+ cmp %o1, %o3
+ bgt,pt %xcc, 2f ! Too high
+ nop
+
+ membar #LoadStore
+ stxa %g0, [%o4] ASI_DCACHE_TAG ! Just right
+2:
+ cmp %o0, %g1
+ blt,pt %xcc, 3f
+ cmp %o1, %g1
+ bgt,pt %icc, 3f
+ nop
+ stxa %g0, [%o4] ASI_ICACHE_TAG
+3:
+ membar #StoreLoad
+ dec 16, %o5
+ brgz,pt %o5, 1b
+ inc 16, %o4
+
+ sethi %hi(KERNBASE), %o5
+ flush %o5
+ membar #Sync
+ retl
+ nop
+
Home |
Main Index |
Thread Index |
Old Index