[rtems commit] sparc: Fix window underflow trap handler

Sebastian Huber sebh at rtems.org
Thu Mar 17 10:12:38 UTC 2016


Module:    rtems
Branch:    master
Commit:    6c4aaf4f3167a9ca2eb2b1ae9b87381a03cb8aa1
Changeset: http://git.rtems.org/rtems/commit/?id=6c4aaf4f3167a9ca2eb2b1ae9b87381a03cb8aa1

Author:    Daniel Hellstrom <daniel at gaisler.com>
Date:      Thu Mar 17 09:12:19 2016 +0100

sparc: Fix window underflow trap handler

The window underflow trap handler used %i5 which destroyed the %o5 of
the calling context.  Bug introduced by
0d3b5d47429effb350448d9e9123a67db722109f.

Go back to the pre 0d3b5d47429effb350448d9e9123a67db722109f behaviour
and use the two unused instructions in the trap vector to optimize a
bit.

Update #2651.

---

 c/src/lib/libbsp/sparc/shared/start/start.S |  2 +-
 c/src/lib/libcpu/sparc/reg_win/window.S     | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/c/src/lib/libbsp/sparc/shared/start/start.S b/c/src/lib/libbsp/sparc/shared/start/start.S
index f38fe8c..3d621fd 100644
--- a/c/src/lib/libbsp/sparc/shared/start/start.S
+++ b/c/src/lib/libbsp/sparc/shared/start/start.S
@@ -66,7 +66,7 @@
   mov   %wim, %l3 ; \
   sethi %hi(_handler), %l4 ; \
   jmp   %l4+%lo(_handler); \
-   mov  %g0, %wim ! WIM = 0, so that we can restore regardless of WIM
+   sll  %l3, 1, %l4 ! l4 = WIM << 1
 
 /*
  *  Software trap. Treat as BAD_TRAP for the time being...
diff --git a/c/src/lib/libcpu/sparc/reg_win/window.S b/c/src/lib/libcpu/sparc/reg_win/window.S
index 06a7056..f57fbe1 100644
--- a/c/src/lib/libcpu/sparc/reg_win/window.S
+++ b/c/src/lib/libcpu/sparc/reg_win/window.S
@@ -76,7 +76,8 @@ SYM(window_overflow_trap_handler):
          *
          *    l1 = pc
          *    l2 = npc
-         *    l3 = wim (from trap table)
+         *    l3 = wim (from trap vector)
+         *    l4 = wim << 1 (from trap vector)
          */
 
         PUBLIC(window_underflow_trap_handler)
@@ -96,15 +97,14 @@ SYM(window_underflow_trap_handler):
          *        register will result in the local register set changing.
          */
 
-        ! In WIM 3 write instruction delay. since WIM<=0 from trap entry
-        sll  %l3, 1, %l4                ! l4 = WIM << 1
         srl  %l3, SPARC_NUMBER_OF_REGISTER_WINDOWS-1, %l5
-        or   %l5, %l4, %i5              ! %i5= (WIM << 1) |
+        or   %l5, %l4, %l5              ! l5 = (WIM << 1) |
                                         !      (WIM >> (Number Windows-1))
+        mov  %l5, %wim                  ! load the new WIM
+        nop; nop; nop                   ! 3 slot delay
         restore                         ! Two restores to get into the
-        restore %o5, %g0, %l7           ! window to restore. Carry along new WIM
+        restore                         ! window to restore
         ldd  [%sp + 0x00], %l0          ! First the local register set
-        mov   %l7, %wim                 ! load the new WIM
         ldd  [%sp + 0x08], %l2
         ldd  [%sp + 0x10], %l4
         ldd  [%sp + 0x18], %l6



More information about the vc mailing list