Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sh5/sh5 Track FPU register save status.



details:   https://anonhg.NetBSD.org/src/rev/cb97597b904c
branches:  trunk
changeset: 533886:cb97597b904c
user:      scw <scw%NetBSD.org@localhost>
date:      Wed Jul 10 15:49:33 2002 +0000

description:
Track FPU register save status.

diffstat:

 sys/arch/sh5/sh5/cpu_switch.S |  33 +++++++++++++++++++++++++++------
 sys/arch/sh5/sh5/genassym.cf  |   6 +++++-
 2 files changed, 32 insertions(+), 7 deletions(-)

diffs (129 lines):

diff -r 409569930075 -r cb97597b904c sys/arch/sh5/sh5/cpu_switch.S
--- a/sys/arch/sh5/sh5/cpu_switch.S     Wed Jul 10 15:45:17 2002 +0000
+++ b/sys/arch/sh5/sh5/cpu_switch.S     Wed Jul 10 15:49:33 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu_switch.S,v 1.1 2002/07/05 13:32:04 scw Exp $       */
+/*     $NetBSD: cpu_switch.S,v 1.2 2002/07/10 15:49:33 scw Exp $       */
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -85,7 +85,7 @@
  *
  * On entry, r1 must be the value of USR for the process
  */
-#define        SAVE_CTX(pcb)                                                          \
+#define        SAVE_CTX(pcb,mdf)                                                      \
        gettr   tr5, r0                         /* Save target regs */        ;\
        st.q    pcb, PCB_CTX_REGS_TR5, r0                                     ;\
        gettr   tr6, r0                                                       ;\
@@ -128,6 +128,12 @@
        shlri   r0, SH5_CONREG_SR_FD_SHIFT, r0                                ;\
        andi    r0, 1, r0                                                     ;\
        bne/u   r0, r63, tr0            /* Skip FP save if FPU disabled */    ;\
+       andi    mdf, MDP_FPSAVED, r0    /* Skip FP save if already done */    ;\
+       beq/u   r0, r63, tr0                                                  ;\
+       shlri   r1, 8, mdf                                                    ;\
+       andi    mdf, 0xff, mdf                                                ;\
+       cmpgt   mdf, r63, mdf           /* mdf = MDP_FPUSED if fpregs dirty */;\
+       ori     mdf, MDP_FPSAVED, mdf                                         ;\
        FPSV(pcb,PCB_CTX_FPREGS_DR0,dr0,dr2,dr4,dr6)                          ;\
        FPSV(pcb,PCB_CTX_FPREGS_DR8,dr8,dr10,dr12,dr14)                       ;\
        FPSV(pcb,PCB_CTX_FPREGS_DR16,dr16,dr18,dr20,dr22)                     ;\
@@ -150,7 +156,7 @@
  * On entry, r1 must be the value of USR for the process
  * Note: Does not restore the Status Register
  */
-#define        RESTORE_CTX(pcb)                                                       \
+#define        RESTORE_CTX(pcb,mdf)                                                   \
        ld.q    pcb, PCB_CTX_REGS_TR5, r0                                     ;\
        ptabs/u r0, tr5                         /* Restore target regs */     ;\
        ld.q    pcb, PCB_CTX_REGS_TR6, r0                                     ;\
@@ -192,6 +198,8 @@
        shlri   r0, SH5_CONREG_SR_FD_SHIFT, r0                                ;\
        andi    r0, 1, r0                                                     ;\
        bne/u   r0, r63, tr0            /* Skip FP restore if FPU disabled */ ;\
+       andi    mdf, MDP_FPSAVED, r0    /* Skip if FP state wasn't saved */   ;\
+       beq/u   r0, r63, tr0                                                  ;\
        fld.d   pcb, PCB_CTX_FPREGS_FPSCR, dr0                                ;\
        fputscr fr0                                                           ;\
        FPRS(pcb,PCB_CTX_FPREGS_DR0,dr0,dr2,dr4,dr6)                          ;\
@@ -284,9 +292,13 @@
        getcon  kcr0, r0
        LDPTR   r0, CI_CURPCB, r2       /* Fetch curpcb */
        LDPTR   r0, CI_CURPROC, r0      /* Fetch curproc */
+       ld.l    r0, P_MD_FLAGS, r3      /* Fetch md_flags */
        LDPTR   r0, P_MD_REGS, r0       /* Fetch pointer to trapframe */
        ld.q    r0, TF_USR, r1          /* Fetch saved USR */
-       SAVE_CTX(r2)                    /* Save process context */
+       SAVE_CTX(r2,r3)                 /* Save process context */
+       getcon  kcr0, r0
+       LDPTR   r0, CI_CURPROC, r0      /* Fetch curproc */
+       st.l    r0, P_MD_FLAGS, r3      /* Save FP state */
 
 Lsw1:
        pta/u   _C_LABEL(idle), tr0
@@ -367,8 +379,9 @@
 
 2:
        LDPTR   r2, P_MD_REGS, r1       /* Fetch pointer to trapframe */
+       ld.l    r2, P_MD_FLAGS, r4
        ld.q    r1, TF_USR, r1          /* Fetch saved USR */
-       RESTORE_CTX(r3)                 /* Switch context to the new process */
+       RESTORE_CTX(r3,r4)              /* Switch context to the new process */
 
        /*
         * We're running in the new process context. Only caller-saved
@@ -448,14 +461,22 @@
  * int sh5_fpsave(u_int usr, struct pcb *pcb)
  *
  * Save FP state in the PCB
+ *
+ * Returns a value suitable for storing in curproc->p_md.md_flags to
+ * indicate if the FPU state was used/saved.
  */
 ENTRY(sh5_fpsave)
        ptabs/l r18, tr0
        getcon  sr, r0
        or      r2, r63, r1
+       movi    0, r2
        shlri   r0, SH5_CONREG_SR_FD_SHIFT, r0
        andi    r0, 1, r0
        bne/u   r0, r63, tr0            /* Skip FP save if FPU disabled */
+       shlri   r1, 8, r0
+       andi    r0, 0xff, r0
+       cmpgt   r0, r63, r2             /* r2 = MDP_FPUSED if fpregs dirty */
+       ori     r2, MDP_FPSAVED, r2
        FPSV(r3,PCB_CTX_FPREGS_DR0,dr0,dr2,dr4,dr6)
        FPSV(r3,PCB_CTX_FPREGS_DR8,dr8,dr10,dr12,dr14)
        FPSV(r3,PCB_CTX_FPREGS_DR16,dr16,dr18,dr20,dr22)
@@ -471,7 +492,7 @@
 
 /******************************************************************************
  *
- * int sh5_fprestore(u_int usr, struct pcb *pcb)
+ * void sh5_fprestore(u_int usr, struct pcb *pcb)
  *
  * Restore FP state from the PCB
  */
diff -r 409569930075 -r cb97597b904c sys/arch/sh5/sh5/genassym.cf
--- a/sys/arch/sh5/sh5/genassym.cf      Wed Jul 10 15:45:17 2002 +0000
+++ b/sys/arch/sh5/sh5/genassym.cf      Wed Jul 10 15:49:33 2002 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: genassym.cf,v 1.1 2002/07/05 13:32:04 scw Exp $
+#      $NetBSD: genassym.cf,v 1.2 2002/07/10 15:49:33 scw Exp $
 
 # Copyright 2002 Wasabi Systems, Inc.
 # All rights reserved.
@@ -239,8 +239,12 @@
 define P_MD_SYSCALL            offsetof(struct proc, p_md.md_syscall)
 define P_MD_ASTPENDING         offsetof(struct proc, p_md.md_astpending)
 define P_MD_REGS               offsetof(struct proc, p_md.md_regs)
+define P_MD_FLAGS              offsetof(struct proc, p_md.md_flags)
 define PH_LINK                 offsetof(struct prochd, ph_link)
 
+define MDP_FPUSED              MDP_FPUSED
+define MDP_FPSAVED             MDP_FPSAVED
+
 define T_TRAP                  T_TRAP
 define T_AST                   T_AST
 define T_WTLBMISS              T_WTLBMISS



Home | Main Index | Thread Index | Old Index