Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/sparc64/sparc64 Lots of changes:



details:   https://anonhg.NetBSD.org/src/rev/fdd0f9237734
branches:  trunk
changeset: 480033:fdd0f9237734
user:      eeh <eeh%NetBSD.org@localhost>
date:      Thu Dec 30 16:39:53 1999 +0000

description:
Lots of changes:

        remove ffs()
        add bzero that uses block store insns
        save %gsr to fpstate
        revert to physical accesses for pmap_zero_page so we don't
                have conflicting page mappings
        general cleanup.

diffstat:

 sys/arch/sparc64/sparc64/locore.s |  650 +++++++++++++++++++++++++++----------
 1 files changed, 478 insertions(+), 172 deletions(-)

diffs (truncated from 844 to 300 lines):

diff -r 5f5ca336de91 -r fdd0f9237734 sys/arch/sparc64/sparc64/locore.s
--- a/sys/arch/sparc64/sparc64/locore.s Thu Dec 30 16:35:25 1999 +0000
+++ b/sys/arch/sparc64/sparc64/locore.s Thu Dec 30 16:39:53 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locore.s,v 1.47 1999/11/06 20:28:37 eeh Exp $  */
+/*     $NetBSD: locore.s,v 1.48 1999/12/30 16:39:53 eeh Exp $  */
 /*
  * Copyright (c) 1996-1999 Eduardo Horvath
  * Copyright (c) 1996 Paul Kranenburg
@@ -60,7 +60,8 @@
 #undef MMUDEBUG                        /* Check use of MMU regs during MMU faults */
 #define VECTORED_INTERRUPTS    /* Use interrupt vectors */
 #define PMAP_FPSTATE           /* Allow nesting of VIS pmap copy/zero */
-#undef PMAP_PHYS_PAGE          /* Don't use block ld/st for pmap copy/zero */
+#define NEW_FPSTATE
+#define PMAP_PHYS_PAGE         /* Don't use block ld/st for pmap copy/zero */
 #define DCACHE_BUG             /* Clear D$ line before loads from ASI_PHYS */
 #define NO_TSB                 /* Don't use TSB */
 #undef TICK_IS_TIME            /* Keep %tick synchronized with time */
@@ -118,6 +119,8 @@
  * support 32-and 64-bit compilers.
  */
 #ifdef _LP64
+/* reg that points to base of data/text segment */
+#define        BASEREG %g4
 /* first constants for storage allocation */
 #define PTRSZ  8
 #define PTRSHFT        3
@@ -130,6 +133,7 @@
 /* Now something to calculate the stack bias */
 #define STKB   BIAS
 #else
+#define        BASEREG %g0
 #define PTRSZ  4
 #define PTRSHFT        2
 #define POINTER        .word
@@ -706,10 +710,10 @@
 #ifdef NOT_DEBUG
        !! 
        !! Check the sp redzone
-       !! 
-       sethi   KERNBASE, t1    
-       cmp     %sp, t1
-       blu,pt  %xcc, 7f
+       !!
+       rdpr    %wstate, t1     ! User stack?
+       cmp     t1, WSTATE_KERN
+       bne,pt  %icc, 7f
         sethi  %hi(_C_LABEL(redzone)), t1
        ldx     [t1 + %lo(_C_LABEL(redzone))], t2
        cmp     %sp, t2                 ! if sp >= t2, not in red zone
@@ -977,10 +981,10 @@
 #ifdef NOT_DEBUG
        !! 
        !! Check the sp redzone
-       !! 
-       sethi   KERNBASE, t1    
-       cmp     %sp, t1
-       blu,pt  %xcc, 7f
+       !!
+       rdpr    %wstate, t1
+       cmp     t1, WSTATE_KERN
+       bne,pt  icc, 7f
         sethi  %hi(_C_LABEL(redzone)), t1
        ldx     [t1 + %lo(_C_LABEL(redzone))], t2
        cmp     %sp, t2                 ! if sp >= t2, not in red zone
@@ -2962,9 +2966,9 @@
        brnz,pt %g6, Lutext_miss                        ! If user context continue miss
        sethi   %hi(KERNBASE), %g5                      ! Don't need %lo
        set     0x0400000, %g6                          ! 4MB
+       add     %g5, 16, %g7
        sub     %g3, %g5, %g5
        cmp     %g5, %g6
-       set     KERNBASE+16, %g7
        mov     6, %g6          ! debug
        stb     %g6, [%g7+0x20] ! debug
        tlu     %xcc, 1; nop
@@ -4946,26 +4950,6 @@
 
 #if 0
        /*
-        * Step 5: save prom configuration so we can panic properly.
-        */     
-       set     TSB, %o0
-       ldxa    [%o0] ASI_IMMU, %o1             ! Get ITSB pointer
-       set     romitsbp, %o2
-       stx     %o1, [%o2]                      ! save it
-       ldxa    [%o0] ASI_DMMU, %o1             ! Get DTSB pointer
-       set     romdtsbp, %o2
-       stx     %o1, [%o2]                      ! save it
-       
-       set     romtrapbase, %o0
-       rdpr    %tba, %o1                       ! Save ROM trapbase
-       stx     %o1, [%o0]
-       set     romwstate, %o0
-       rdpr    %wstate, %o1                    ! Save ROM wstate
-       stx     %o1, [%o0]      
-#endif
-
-#if 0
-       /*
         * Disable the DCACHE entirely for debug.
         */
        ldxa    [%g0] ASI_MCCR, %o1
@@ -5264,35 +5248,6 @@
        .proc 1
        FTYPE(openfirmware)
 _C_LABEL(openfirmware):
-#if 0
-       set     panicstr, %o1                   ! Check if we're panicing
-       ld      [%o1], %o1
-       brz,pt  %o1, 0f                         ! if not, continue
-
-        rdpr   %pstate, %o4                    ! Else, restore prom state
-       flushw                                  ! flushw may be dangerous at this time
-       or      %o4, PSTATE_IE, %o5             ! Disable interrupts
-       wrpr    %o5, 0, %pstate
-       
-       set     romitsbp, %o2                   
-       ldx     [%o2], %o1                      ! Restore TSB pointers
-       set     TSB, %o3
-       stxa    %o1, [%o3] ASI_IMMU
-       membar  #Sync
-       set     romdtsbp, %o2
-       ldx     [%o2], %o1
-       stxa    %o1, [%o3] ASI_DMMU
-       membar  #Sync
-       
-       set     romtrapbase, %o3                ! Restore trapbase
-       ldx     [%o3], %o1
-       wrpr    %o1, 0, %tba
-       set     romwstate, %o3                  ! Restore wstate
-       ldx     [%o3], %o1
-       wrpr    %o1, 0, %wstate
-       wrpr    %o4, 0, %pstate                 ! Restore interrupt state
-0:     
-#endif
        andcc   %sp, 1, %g0
        bz,pt   %icc, 1f
         sethi  %hi(romp), %l7
@@ -5813,7 +5768,7 @@
        mov     %l7, %g7
 
 #ifdef _LP64
-       restore %g0, netbsd32_SYS_netbsd32_sigreturn, %g1       ! get registers back & set syscall #
+       restore %g0, netbsd32_SYS_netbsd32___sigreturn14, %g1   ! get registers back & set syscall #
        add     %sp, 64 + 16, %o0       ! compute scp
        t       ST_SYSCALL              ! sigreturn(scp)
        ! sigreturn does not return unless it fails
@@ -6699,24 +6654,6 @@
         mov    EFAULT, %o0
 
 
-#if 0
-/*
- * Write all user windows presently in the CPU back to the user's stack.
- */
-ENTRY(write_all_windows)
-#if 0
-ALTENTRY(write_user_windows)
-       save    %sp, -CC64FSZ, %sp
-       flushw
-       ret
-        restore
-#else
-ENTRY(write_user_windows)
-       retl
-        flushw
-#endif
-#endif
-       
 /*
  * Masterpaddr is the p->p_addr of the last process on the processor.
  * XXX masterpaddr is almost the same as cpcb
@@ -7893,6 +7830,7 @@
         or     %o2, 0x020, %o3                 ! Nucleus flush page
        
 #ifdef PMAP_FPSTATE
+#ifndef NEW_FPSTATE
        !!
        !! This code will allow us to save the fpstate around this
        !! routine and nest FP use in the kernel
@@ -7908,6 +7846,71 @@
        mov     %i3, %o3
        wr      %g0, FPRS_FEF, %fprs
 #else
+/*
+ * New version, new scheme:
+ *
+ * Here we use VIS instructions to do a block clear of a page.
+ * But before we can do that we need to save and enable the FPU.
+ * The last owner of the FPU registers is fpproc, and 
+ * fpproc->p_md.md_fpstate is the current fpstate.  If that's not
+ * null, call savefpstate() with it to store our current fp state.
+ *
+ * Next, allocate an aligned fpstate on the stack.  We will properly
+ * nest calls on a particular stack so this should not be a problem. 
+ *
+ * Now we grab either curproc (or if we're on the interrupt stack
+ * proc0).  We stash its existing fpstate in a local register and
+ * put our new fpstate in curproc->p_md.md_fpstate.  We point
+ * fpproc at curproc (or proc0) and enable the FPU.
+ *
+ * If we are ever preempted, our FPU state will be saved in our
+ * fpstate.  Then, when we're resumed and we take an FPDISABLED
+ * trap, the trap handler will be able to fish our FPU state out
+ * of curproc (or proc0).
+ *
+ * On exiting this routine we undo the damage: restore the original
+ * pointer to curproc->p_md.md_fpstate, clear our fpproc, and disable
+ * the MMU.
+ *
+ */
+       !!
+       !! This code will allow us to save the fpstate around this
+       !! routine and nest FP use in the kernel
+       !! 
+       save    %sp, -(CC64FSZ+FS_SIZE+BLOCK_SIZE), %sp ! Allocate an fpstate
+       sethi   %hi(_C_LABEL(fpproc)), %l1
+       LDPTR   [%l1 + %lo(_C_LABEL(fpproc))], %l2      ! Load fpproc
+       add     %sp, (CC64FSZ+STKB+BLOCK_SIZE-1), %l0   ! Calculate pointer to fpstate
+       brz,pt  %l2, 1f                                 ! fpproc == NULL?
+        andn   %l0, BLOCK_ALIGN, %l0                   ! And make it block aligned
+       LDPTR   [%l2 + P_FPSTATE], %l3
+       brz,pn  %l3, 1f                                 ! Make sure we have an fpstate
+        mov    %l3, %o0
+       call    _C_LABEL(savefpstate)                   ! Save the old fpstate
+        set    _C_LABEL(eintstack), %l4                ! Are we on intr stack?
+       cmp     %sp, %l4
+       bgu,pt  %xcc, 1f
+        set    _C_LABEL(intstack), %l4
+       cmp     %sp, %l4
+       blu     %xcc, 1f
+0:     
+        sethi  %hi(_C_LABEL(proc0)), %l4               ! Yes, use proc0
+       ba,pt   %xcc, 2f
+        or     %l4, %lo(_C_LABEL(proc0)), %l5
+1:
+       sethi   %hi(_C_LABEL(curproc)), %l4             ! Use curproc
+       LDPTR   [%l4 + %lo(_C_LABEL(curproc))], %l5
+       brz,pn  %l5, 0b                                 ! If curproc is NULL need to use proc0
+2:     
+       mov     %i0, %o0
+       mov     %i2, %o2
+       LDPTR   [%l5 + P_FPSTATE], %l6                  ! Save old fpstate
+       mov     %i3, %o3
+       STPTR   %l0, [%l5 + P_FPSTATE]                  ! Insert new fpstate
+       STPTR   %l5, [%l1 + %lo(_C_LABEL(fpproc))]      ! Set new fpproc
+       wr      %g0, FPRS_FEF, %fprs                    ! Enable FPU
+#endif
+#else
        !!
        !! Don't use FP regs if the kernel's already using them
        !!
@@ -8001,6 +8004,7 @@
        wrpr    %g1, 0, %pil                    ! splx(s)
        
 #ifdef PMAP_FPSTATE
+#ifndef NEW_FPSTATE
        btst    FPRS_DU|FPRS_DL, %l1            ! Anything to restore?
        bz,pt   %icc, 1f
         nop
@@ -8012,6 +8016,21 @@
        ret
         restore
 #else
+#ifdef DEBUG
+       LDPTR   [%l1 + %lo(_C_LABEL(fpproc))], %l7
+       cmp     %l7, %l5
+       tnz     1               ! fpproc has changed!
+       LDPTR   [%l5 + P_FPSTATE], %l7
+       cmp     %l7, %l0
+       tnz     1               ! fpstate has changed!  
+#endif
+       STPTR   %g0, [%l1 + %lo(_C_LABEL(fpproc))]      ! Clear fpproc
+       STPTR   %l6, [%l5 + P_FPSTATE]                  ! Restore old fpstate
+       wr      %g0, 0, %fprs                           ! Disable FPU
+       ret
+        restore
+#endif
+#else
        retl                                    ! Any other mappings have inconsistent D$
         wr     %g0, 0, %fprs                   ! Turn off FPU and mark as clean
 #endif
@@ -8107,6 +8126,7 @@
         or     %o2, 0x020, %o3                 ! Nucleus flush page
        
 #ifdef PMAP_FPSTATE
+#ifndef NEW_FPSTATE
        !!
        !! This code will allow us to save the fpstate around this
        !! routine and nest FP use in the kernel
@@ -8123,6 +8143,71 @@
        mov     %i3, %o3
        wr      %g0, FPRS_FEF, %fprs
 #else
+/*
+ * New version, new scheme:
+ *
+ * Here we use VIS instructions to do a block clear of a page.



Home | Main Index | Thread Index | Old Index