Sun Oct 5 02:00:53 2008 UTC ()
- in flushing cache, use 32 as increment/decrement value to match the
  cache line size.
- remove useless restore of %asi.
- remove nop in delay slot if we can.


(nakayama)
diff -r1.284 -r1.285 src/sys/arch/sparc64/sparc64/locore.s

cvs diff -r1.284 -r1.285 src/sys/arch/sparc64/sparc64/locore.s (expand / switch to unified diff)

--- src/sys/arch/sparc64/sparc64/locore.s 2008/07/10 15:38:40 1.284
+++ src/sys/arch/sparc64/sparc64/locore.s 2008/10/05 02:00:53 1.285
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: locore.s,v 1.284 2008/07/10 15:38:40 nakayama Exp $ */ 1/* $NetBSD: locore.s,v 1.285 2008/10/05 02:00:53 nakayama Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1996-2002 Eduardo Horvath 4 * Copyright (c) 1996-2002 Eduardo Horvath
5 * Copyright (c) 1996 Paul Kranenburg 5 * Copyright (c) 1996 Paul Kranenburg
6 * Copyright (c) 1996 6 * Copyright (c) 1996
7 * The President and Fellows of Harvard College. 7 * The President and Fellows of Harvard College.
8 * All rights reserved. 8 * All rights reserved.
9 * Copyright (c) 1992, 1993 9 * Copyright (c) 1992, 1993
10 * The Regents of the University of California. 10 * The Regents of the University of California.
11 * All rights reserved. 11 * All rights reserved.
12 * 12 *
13 * This software was developed by the Computer Systems Engineering group 13 * This software was developed by the Computer Systems Engineering group
14 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 14 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
@@ -3646,35 +3646,35 @@ Lsoftint_regular: @@ -3646,35 +3646,35 @@ Lsoftint_regular:
3646 bgeu,pn %xcc, 3f 3646 bgeu,pn %xcc, 3f
3647 or %g3, %lo(_C_LABEL(intrlev)), %g3 3647 or %g3, %lo(_C_LABEL(intrlev)), %g3
3648 LDPTR [%g3 + %g5], %g5 ! We have a pointer to the handler 3648 LDPTR [%g3 + %g5], %g5 ! We have a pointer to the handler
3649 brz,pn %g5, 3f ! NULL means it isn't registered yet. Skip it. 3649 brz,pn %g5, 3f ! NULL means it isn't registered yet. Skip it.
3650 nop 3650 nop
3651 3651
3652setup_sparcintr: 3652setup_sparcintr:
3653 LDPTR [%g5+IH_PEND], %g6 ! Read pending flag 3653 LDPTR [%g5+IH_PEND], %g6 ! Read pending flag
3654 brnz,pn %g6, ret_from_intr_vector ! Skip it if it's running 3654 brnz,pn %g6, ret_from_intr_vector ! Skip it if it's running
3655 ldub [%g5+IH_PIL], %g6 ! Read interrupt mask 3655 ldub [%g5+IH_PIL], %g6 ! Read interrupt mask
3656 sethi %hi(CPUINFO_VA+CI_INTRPENDING), %g1 3656 sethi %hi(CPUINFO_VA+CI_INTRPENDING), %g1
3657 sll %g6, PTRSHFT, %g3 ! Find start of table for this IPL 3657 sll %g6, PTRSHFT, %g3 ! Find start of table for this IPL
3658 or %g1, %lo(CPUINFO_VA+CI_INTRPENDING), %g1 3658 or %g1, %lo(CPUINFO_VA+CI_INTRPENDING), %g1
3659 add %g1, %g3, %g1 3659 add %g1, %g3, %g1
36601: 36601:
3661 LDPTR [%g1], %g3 ! Load list head 3661 LDPTR [%g1], %g3 ! Load list head
3662 STPTR %g3, [%g5+IH_PEND] ! Link our intrhand node in 3662 STPTR %g3, [%g5+IH_PEND] ! Link our intrhand node in
3663 mov %g5, %g7 3663 mov %g5, %g7
3664 CASPTR [%g1] ASI_N, %g3, %g7 3664 CASPTR [%g1] ASI_N, %g3, %g7
3665 cmp %g7, %g3 ! Did it work? 3665 cmp %g7, %g3 ! Did it work?
3666 bne,pn CCCR, 1b ! No, try again 3666 bne,pn CCCR, 1b ! No, try again
3667 nop 3667 EMPTY
36682: 36682:
3669 mov 1, %g7 3669 mov 1, %g7
3670 sll %g7, %g6, %g6 3670 sll %g7, %g6, %g6
3671 wr %g6, 0, SET_SOFTINT ! Invoke a softint 3671 wr %g6, 0, SET_SOFTINT ! Invoke a softint
3672 3672
3673ret_from_intr_vector: 3673ret_from_intr_vector:
3674#if KTR_COMPILE & KTR_INTR 3674#if KTR_COMPILE & KTR_INTR
3675 CATR(KTR_TRAP, "ret_from_intr_vector: tl %d, tstate %p, tpc %p", 3675 CATR(KTR_TRAP, "ret_from_intr_vector: tl %d, tstate %p, tpc %p",
3676 %g3, %g4, %g5, 10, 11, 12) 3676 %g3, %g4, %g5, 10, 11, 12)
3677 rdpr %tl, %g5 3677 rdpr %tl, %g5
3678 stx %g5, [%g3 + KTR_PARM1] 3678 stx %g5, [%g3 + KTR_PARM1]
3679 rdpr %tstate, %g5 3679 rdpr %tstate, %g5
3680 stx %g5, [%g3 + KTR_PARM2] 3680 stx %g5, [%g3 + KTR_PARM2]
@@ -4118,27 +4118,27 @@ sparc_intr_retry: @@ -4118,27 +4118,27 @@ sparc_intr_retry:
4118 or %l4, %lo(CPUINFO_VA+CI_INTRPENDING), %l4 4118 or %l4, %lo(CPUINFO_VA+CI_INTRPENDING), %l4
4119 add %l2, %l4, %l4 4119 add %l2, %l4, %l4
4120 4120
41211: 41211:
4122 membar #StoreLoad ! Make sure any failed casxa insns complete 4122 membar #StoreLoad ! Make sure any failed casxa insns complete
4123 LDPTR [%l4], %l2 ! Check a slot 4123 LDPTR [%l4], %l2 ! Check a slot
4124 cmp %l2, -1 4124 cmp %l2, -1
4125 beq,pn CCCR, intrcmplt ! Empty list? 4125 beq,pn CCCR, intrcmplt ! Empty list?
4126 mov -1, %l7 4126 mov -1, %l7
4127 membar #LoadStore 4127 membar #LoadStore
4128 CASPTR [%l4] ASI_N, %l2, %l7 ! Grab the entire list 4128 CASPTR [%l4] ASI_N, %l2, %l7 ! Grab the entire list
4129 cmp %l7, %l2 4129 cmp %l7, %l2
4130 bne,pn CCCR, 1b 4130 bne,pn CCCR, 1b
4131 nop 4131 EMPTY
41322: 41322:
4133 add %sp, CC64FSZ+STKB, %o2 ! tf = %sp + CC64FSZ + STKB 4133 add %sp, CC64FSZ+STKB, %o2 ! tf = %sp + CC64FSZ + STKB
4134 LDPTR [%l2 + IH_PEND], %l7 ! save ih->ih_pending 4134 LDPTR [%l2 + IH_PEND], %l7 ! save ih->ih_pending
4135 membar #LoadStore 4135 membar #LoadStore
4136 STPTR %g0, [%l2 + IH_PEND] ! Clear pending flag 4136 STPTR %g0, [%l2 + IH_PEND] ! Clear pending flag
4137 membar #Sync 4137 membar #Sync
4138 LDPTR [%l2 + IH_FUN], %o4 ! ih->ih_fun 4138 LDPTR [%l2 + IH_FUN], %o4 ! ih->ih_fun
4139 LDPTR [%l2 + IH_ARG], %o0 ! ih->ih_arg 4139 LDPTR [%l2 + IH_ARG], %o0 ! ih->ih_arg
4140 4140
4141 wrpr %g0, PSTATE_INTR, %pstate ! Reenable interrupts 4141 wrpr %g0, PSTATE_INTR, %pstate ! Reenable interrupts
4142 jmpl %o4, %o7 ! handled = (*ih->ih_fun)(...) 4142 jmpl %o4, %o7 ! handled = (*ih->ih_fun)(...)
4143 movrz %o0, %o2, %o0 ! arg = (arg == 0) ? arg : tf 4143 movrz %o0, %o2, %o0 ! arg = (arg == 0) ? arg : tf
4144 wrpr %g0, PSTATE_KERN, %pstate ! Disable interrupts 4144 wrpr %g0, PSTATE_KERN, %pstate ! Disable interrupts
@@ -5654,66 +5654,68 @@ ENTRY(sp_tlb_flush_all) @@ -5654,66 +5654,68 @@ ENTRY(sp_tlb_flush_all)
5654 * Does not modify %o0 5654 * Does not modify %o0
5655 * 5655 *
5656 */ 5656 */
5657 .align 8 5657 .align 8
5658ENTRY(blast_dcache) 5658ENTRY(blast_dcache)
5659/* 5659/*
5660 * We turn off interrupts for the duration to prevent RED exceptions. 5660 * We turn off interrupts for the duration to prevent RED exceptions.
5661 */ 5661 */
5662#ifdef PROF 5662#ifdef PROF
5663 save %sp, -CC64FSZ, %sp 5663 save %sp, -CC64FSZ, %sp
5664#endif 5664#endif
5665 5665
5666 rdpr %pstate, %o3 5666 rdpr %pstate, %o3
5667 set (2 * NBPG) - 8, %o1 5667 set (2 * NBPG) - 32, %o1
5668 andn %o3, PSTATE_IE, %o4 ! Turn off PSTATE_IE bit 5668 andn %o3, PSTATE_IE, %o4 ! Turn off PSTATE_IE bit
5669 wrpr %o4, 0, %pstate 5669 wrpr %o4, 0, %pstate
56701: 56701:
5671 stxa %g0, [%o1] ASI_DCACHE_TAG 5671 stxa %g0, [%o1] ASI_DCACHE_TAG
5672 brnz,pt %o1, 1b 5672 brnz,pt %o1, 1b
5673 dec 8, %o1 5673 dec 32, %o1
5674 sethi %hi(KERNBASE), %o2 5674 sethi %hi(KERNBASE), %o2
5675 flush %o2 5675 flush %o2
 5676 membar #Sync
5676#ifdef PROF 5677#ifdef PROF
5677 wrpr %o3, %pstate 5678 wrpr %o3, %pstate
5678 ret 5679 ret
5679 restore 5680 restore
5680#else 5681#else
5681 retl 5682 retl
5682 wrpr %o3, %pstate 5683 wrpr %o3, %pstate
5683#endif 5684#endif
5684 5685
5685/* 5686/*
5686 * blast_icache() 5687 * blast_icache()
5687 * 5688 *
5688 * Clear out all of I$ regardless of contents 5689 * Clear out all of I$ regardless of contents
5689 * Does not modify %o0 5690 * Does not modify %o0
5690 * 5691 *
5691 */ 5692 */
5692 .align 8 5693 .align 8
5693ENTRY(blast_icache) 5694ENTRY(blast_icache)
5694/* 5695/*
5695 * We turn off interrupts for the duration to prevent RED exceptions. 5696 * We turn off interrupts for the duration to prevent RED exceptions.
5696 */ 5697 */
5697 rdpr %pstate, %o3 5698 rdpr %pstate, %o3
5698 set (2 * NBPG) - 8, %o1 5699 set (2 * NBPG) - 32, %o1
5699 andn %o3, PSTATE_IE, %o4 ! Turn off PSTATE_IE bit 5700 andn %o3, PSTATE_IE, %o4 ! Turn off PSTATE_IE bit
5700 wrpr %o4, 0, %pstate 5701 wrpr %o4, 0, %pstate
57011: 57021:
5702 stxa %g0, [%o1] ASI_ICACHE_TAG 5703 stxa %g0, [%o1] ASI_ICACHE_TAG
5703 brnz,pt %o1, 1b 5704 brnz,pt %o1, 1b
5704 dec 8, %o1 5705 dec 32, %o1
5705 sethi %hi(KERNBASE), %o2 5706 sethi %hi(KERNBASE), %o2
5706 flush %o2 5707 flush %o2
 5708 membar #Sync
5707 retl 5709 retl
5708 wrpr %o3, %pstate 5710 wrpr %o3, %pstate
5709 5711
5710/* 5712/*
5711 * dcache_flush_page(paddr_t pa) 5713 * dcache_flush_page(paddr_t pa)
5712 * 5714 *
5713 * Clear one page from D$. 5715 * Clear one page from D$.
5714 * 5716 *
5715 */ 5717 */
5716 .align 8 5718 .align 8
5717ENTRY(dcache_flush_page) 5719ENTRY(dcache_flush_page)
5718#ifndef _LP64 5720#ifndef _LP64
5719 COMBINE(%o0, %o1, %o0) 5721 COMBINE(%o0, %o1, %o0)
@@ -5734,27 +5736,26 @@ ENTRY(dcache_flush_page) @@ -5734,27 +5736,26 @@ ENTRY(dcache_flush_page)
5734 bl,pn %icc, 2f 5736 bl,pn %icc, 2f
5735 inc 32, %o4 5737 inc 32, %o4
5736 5738
5737 xor %o3, %o2, %o3 5739 xor %o3, %o2, %o3
5738 andcc %o3, %o1, %g0 5740 andcc %o3, %o1, %g0
5739 bne,pt %xcc, 1b 5741 bne,pt %xcc, 1b
5740 membar #LoadStore 5742 membar #LoadStore
5741 5743
5742 stxa %g0, [%o0] ASI_DCACHE_TAG 5744 stxa %g0, [%o0] ASI_DCACHE_TAG
5743 ba,pt %icc, 1b 5745 ba,pt %icc, 1b
5744 membar #StoreLoad 5746 membar #StoreLoad
57452: 57472:
5746 5748
5747 wr %g0, ASI_PRIMARY_NOFAULT, %asi 
5748 sethi %hi(KERNBASE), %o5 5749 sethi %hi(KERNBASE), %o5
5749 flush %o5 5750 flush %o5
5750 retl 5751 retl
5751 membar #Sync 5752 membar #Sync
5752 5753
5753/* 5754/*
5754 * icache_flush_page(paddr_t pa) 5755 * icache_flush_page(paddr_t pa)
5755 * 5756 *
5756 * Clear one page from I$. 5757 * Clear one page from I$.
5757 * 5758 *
5758 */ 5759 */
5759 .align 8 5760 .align 8
5760ENTRY(icache_flush_page) 5761ENTRY(icache_flush_page)
@@ -5767,36 +5768,36 @@ ENTRY(icache_flush_page) @@ -5767,36 +5768,36 @@ ENTRY(icache_flush_page)
5767 !! Linux sez that I$ flushes are not needed for cheetah. 5768 !! Linux sez that I$ flushes are not needed for cheetah.
5768 !! 5769 !!
5769  5770
5770 !! Now do the I$ 5771 !! Now do the I$
5771 srlx %o0, 13-8, %o2 5772 srlx %o0, 13-8, %o2
5772 mov -1, %o1 ! Generate mask for tag: bits [35..8] 5773 mov -1, %o1 ! Generate mask for tag: bits [35..8]
5773 srl %o1, 32-35+7, %o1 5774 srl %o1, 32-35+7, %o1
5774 clr %o4 5775 clr %o4
5775 sll %o1, 7, %o1 ! Mask 5776 sll %o1, 7, %o1 ! Mask
5776 set (2*NBPG), %o5 5777 set (2*NBPG), %o5
5777  5778
57781: 57791:
5779 ldda [%o4] ASI_ICACHE_TAG, %g0 ! Tag goes in %g1 5780 ldda [%o4] ASI_ICACHE_TAG, %g0 ! Tag goes in %g1
5780 dec 16, %o5 5781 dec 32, %o5
5781 xor %g1, %o2, %g1 5782 xor %g1, %o2, %g1
5782 andcc %g1, %o1, %g0 5783 andcc %g1, %o1, %g0
5783 bne,pt %xcc, 2f 5784 bne,pt %xcc, 2f
5784 membar #LoadStore 5785 membar #LoadStore
5785 stxa %g0, [%o4] ASI_ICACHE_TAG 5786 stxa %g0, [%o4] ASI_ICACHE_TAG
5786 membar #StoreLoad 5787 membar #StoreLoad
57872: 57882:
5788 brnz,pt %o5, 1b 5789 brnz,pt %o5, 1b
5789 inc 16, %o4 5790 inc 32, %o4
5790#endif 5791#endif
5791 sethi %hi(KERNBASE), %o5 5792 sethi %hi(KERNBASE), %o5
5792 flush %o5 5793 flush %o5
5793 membar #Sync 5794 membar #Sync
5794 retl 5795 retl
5795 nop 5796 nop
5796 5797
5797/* 5798/*
5798 * cache_flush_phys(paddr_t, psize_t, int); 5799 * cache_flush_phys(paddr_t, psize_t, int);
5799 * 5800 *
5800 * Clear a set of paddrs from the D$, I$ and if param3 is 5801 * Clear a set of paddrs from the D$, I$ and if param3 is
5801 * non-zero, E$. (E$ is not supported yet). 5802 * non-zero, E$. (E$ is not supported yet).
5802 */ 5803 */
@@ -5846,29 +5847,29 @@ ENTRY(cache_flush_phys) @@ -5846,29 +5847,29 @@ ENTRY(cache_flush_phys)
5846 membar #LoadStore 5847 membar #LoadStore
5847 stxa %g0, [%o4] ASI_DCACHE_TAG ! Just right 5848 stxa %g0, [%o4] ASI_DCACHE_TAG ! Just right
58482: 58492:
5849#ifndef SPITFIRE 5850#ifndef SPITFIRE
5850 cmp %o0, %g1 5851 cmp %o0, %g1
5851 blt,pt %xcc, 3f 5852 blt,pt %xcc, 3f
5852 cmp %o1, %g1 5853 cmp %o1, %g1
5853 bgt,pt %icc, 3f 5854 bgt,pt %icc, 3f
5854 nop 5855 nop
5855 stxa %g0, [%o4] ASI_ICACHE_TAG 5856 stxa %g0, [%o4] ASI_ICACHE_TAG
58563: 58573:
5857#endif 5858#endif
5858 membar #StoreLoad 5859 membar #StoreLoad
5859 dec 16, %o5 5860 dec 32, %o5
5860 brgz,pt %o5, 1b 5861 brgz,pt %o5, 1b
5861 inc 16, %o4 5862 inc 32, %o4
5862 5863
5863 sethi %hi(KERNBASE), %o5 5864 sethi %hi(KERNBASE), %o5
5864 flush %o5 5865 flush %o5
5865 membar #Sync 5866 membar #Sync
5866 retl 5867 retl
5867 nop 5868 nop
5868 5869
5869#ifdef COMPAT_16 5870#ifdef COMPAT_16
5870#ifdef _LP64 5871#ifdef _LP64
5871/* 5872/*
5872 * XXXXX Still needs lotsa cleanup after sendsig is complete and offsets are known 5873 * XXXXX Still needs lotsa cleanup after sendsig is complete and offsets are known
5873 * 5874 *
5874 * The following code is copied to the top of the user stack when each 5875 * The following code is copied to the top of the user stack when each
@@ -9738,31 +9739,31 @@ ENTRY(send_softint) @@ -9738,31 +9739,31 @@ ENTRY(send_softint)
9738 sethi %hi(CPUINFO_VA+CI_INTRPENDING), %o3 9739 sethi %hi(CPUINFO_VA+CI_INTRPENDING), %o3
9739 LDPTR [%o2 + IH_PEND], %o5 9740 LDPTR [%o2 + IH_PEND], %o5
9740 or %o3, %lo(CPUINFO_VA+CI_INTRPENDING), %o3 9741 or %o3, %lo(CPUINFO_VA+CI_INTRPENDING), %o3
9741 brnz %o5, 1f 9742 brnz %o5, 1f
9742 sll %o1, PTRSHFT, %o5 ! Find start of table for this IPL 9743 sll %o1, PTRSHFT, %o5 ! Find start of table for this IPL
9743 add %o3, %o5, %o3 9744 add %o3, %o5, %o3
97442: 97452:
9745 LDPTR [%o3], %o5 ! Load list head 9746 LDPTR [%o3], %o5 ! Load list head
9746 STPTR %o5, [%o2+IH_PEND] ! Link our intrhand node in 9747 STPTR %o5, [%o2+IH_PEND] ! Link our intrhand node in
9747 mov %o2, %o4 9748 mov %o2, %o4
9748 CASPTR [%o3] ASI_N, %o5, %o4 9749 CASPTR [%o3] ASI_N, %o5, %o4
9749 cmp %o4, %o5 ! Did it work? 9750 cmp %o4, %o5 ! Did it work?
9750 bne,pn CCCR, 2b ! No, try again 9751 bne,pn CCCR, 2b ! No, try again
9751 nop 9752 EMPTY
9752 9753
9753 mov 1, %o3 ! Change from level to bitmask 9754 mov 1, %o4 ! Change from level to bitmask
9754 sllx %o3, %o1, %o3 9755 sllx %o4, %o1, %o4
9755 wr %o3, 0, SET_SOFTINT ! SET_SOFTINT 9756 wr %o4, 0, SET_SOFTINT ! SET_SOFTINT
97561: 97571:
9757 retl 9758 retl
9758 wrpr %g1, 0, %pstate ! restore PSTATE.IE 9759 wrpr %g1, 0, %pstate ! restore PSTATE.IE
9759 9760
9760/* 9761/*
9761 * Here is a very good random number generator. This implementation is 9762 * Here is a very good random number generator. This implementation is
9762 * based on _Two Fast Implementations of the `Minimal Standard' Random 9763 * based on _Two Fast Implementations of the `Minimal Standard' Random
9763 * Number Generator_, David G. Carta, Communications of the ACM, Jan 1990, 9764 * Number Generator_, David G. Carta, Communications of the ACM, Jan 1990,
9764 * Vol 33 No 1. 9765 * Vol 33 No 1.
9765 */ 9766 */
9766/* 9767/*
9767 * This should be rewritten using the mulx instr. if I ever understand what it 9768 * This should be rewritten using the mulx instr. if I ever understand what it
9768 * does. 9769 * does.