Source-Changes-HG archive

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

[src/trunk]: src Support SH3 in our unwinder.



details:   https://anonhg.NetBSD.org/src/rev/f3c071221f69
branches:  trunk
changeset: 795156:f3c071221f69
user:      joerg <joerg%NetBSD.org@localhost>
date:      Wed Apr 02 22:34:29 2014 +0000

description:
Support SH3 in our unwinder.

diffstat:

 share/mk/bsd.own.mk                  |   4 +-
 sys/lib/libunwind/Registers.hpp      |  64 ++++++++++++++++++++++++++++++++++++
 sys/lib/libunwind/libunwind.cxx      |   2 +
 sys/lib/libunwind/unwind_registers.S |  57 ++++++++++++++++++++++++++++++++
 4 files changed, 126 insertions(+), 1 deletions(-)

diffs (168 lines):

diff -r 34fa7e6e397e -r f3c071221f69 share/mk/bsd.own.mk
--- a/share/mk/bsd.own.mk       Wed Apr 02 22:22:37 2014 +0000
+++ b/share/mk/bsd.own.mk       Wed Apr 02 22:34:29 2014 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: bsd.own.mk,v 1.792 2014/03/25 09:52:55 ozaki-r Exp $
+#      $NetBSD: bsd.own.mk,v 1.793 2014/04/02 22:34:29 joerg Exp $
 
 # This needs to be before bsd.init.mk
 .if defined(BSD_MK_COMPAT_FILE)
@@ -101,6 +101,8 @@
 _LIBC_UNWIND_SUPPORT.i386=     yes
 _LIBC_UNWIND_SUPPORT.m68k=     yes
 _LIBC_UNWIND_SUPPORT.powerpc=  yes
+_LIBC_UNWIND_SUPPORT.sh3el=    yes
+_LIBC_UNWIND_SUPPORT.sh3eb=    yes
 _LIBC_UNWIND_SUPPORT.vax=      yes
 _LIBC_UNWIND_SUPPORT.x86_64=   yes
 .if ${MKLLVM:Uno} == "yes" && ${_LIBC_UNWIND_SUPPORT.${MACHINE_ARCH}:Uno} == "yes"
diff -r 34fa7e6e397e -r f3c071221f69 sys/lib/libunwind/Registers.hpp
--- a/sys/lib/libunwind/Registers.hpp   Wed Apr 02 22:22:37 2014 +0000
+++ b/sys/lib/libunwind/Registers.hpp   Wed Apr 02 22:34:29 2014 +0000
@@ -454,6 +454,70 @@
   fpreg_t fpreg[8];
 };
 
+enum {
+  DWARF_SH3_R0 = 0,
+  DWARF_SH3_R15 = 15,
+  DWARF_SH3_PC = 16,
+  DWARF_SH3_PR = 17,
+
+  REGNO_SH3_R0 = 0,
+  REGNO_SH3_R15 = 15,
+  REGNO_SH3_PC = 16,
+  REGNO_SH3_PR = 17,
+};
+
+class Registers_SH3 {
+public:
+  enum {
+    LAST_REGISTER = REGNO_SH3_PR,
+    LAST_RESTORE_REG = REGNO_SH3_PR,
+    RETURN_REG = REGNO_SH3_PR,
+  };
+
+  __dso_hidden Registers_SH3();
+
+  static int dwarf2regno(int num) {
+    if (num >= DWARF_SH3_R0 && num <= DWARF_SH3_R15)
+      return REGNO_SH3_R0 + (num - DWARF_SH3_R0);
+    if (num == DWARF_SH3_PC)
+      return REGNO_SH3_PC;
+    if (num == DWARF_SH3_PR)
+      return REGNO_SH3_PR;
+    return LAST_REGISTER + 1;
+  }
+
+  bool validRegister(int num) const {
+    return num >= 0 && num <= REGNO_SH3_PR;
+  }
+
+  uint64_t getRegister(int num) const {
+    assert(validRegister(num));
+    return reg[num];
+  }
+
+  void setRegister(int num, uint64_t value) {
+    assert(validRegister(num));
+    reg[num] = value;
+  }
+
+  uint64_t getIP() const { return reg[REGNO_SH3_PC]; }
+
+  void setIP(uint64_t value) { reg[REGNO_SH3_PC] = value; }
+
+  uint64_t getSP() const { return reg[REGNO_SH3_R15]; }
+
+  void setSP(uint64_t value) { reg[REGNO_SH3_R15] = value; }
+
+  bool validFloatVectorRegister(int num) const { return false; }
+
+  void copyFloatVectorRegister(int num, uint64_t addr_) {}
+
+  __dso_hidden void jumpto() const __dead;
+
+private:
+  uint32_t reg[REGNO_SH3_PR + 1];
+};
+
 } // namespace _Unwind
 
 #endif // __REGISTERS_HPP__
diff -r 34fa7e6e397e -r f3c071221f69 sys/lib/libunwind/libunwind.cxx
--- a/sys/lib/libunwind/libunwind.cxx   Wed Apr 02 22:22:37 2014 +0000
+++ b/sys/lib/libunwind/libunwind.cxx   Wed Apr 02 22:34:29 2014 +0000
@@ -29,6 +29,8 @@
 typedef Registers_vax ThisUnwindRegisters;
 #elif __m68k__
 typedef Registers_M68K ThisUnwindRegisters;
+#elif __sh3__
+typedef Registers_SH3 ThisUnwindRegisters;
 #else
 #error Unsupported architecture
 #endif
diff -r 34fa7e6e397e -r f3c071221f69 sys/lib/libunwind/unwind_registers.S
--- a/sys/lib/libunwind/unwind_registers.S      Wed Apr 02 22:22:37 2014 +0000
+++ b/sys/lib/libunwind/unwind_registers.S      Wed Apr 02 22:34:29 2014 +0000
@@ -364,3 +364,60 @@
        rts
 END(_ZNK7_Unwind14Registers_M68K6jumptoEv)
 #endif
+
+#if defined(__sh3__)
+       .hidden _ZN7_Unwind13Registers_SH3C1Ev
+ENTRY(_ZN7_Unwind13Registers_SH3C1Ev)
+       add     #64, r4
+       mov.l   r8, @-r15
+       sts.l   pr, @-r15
+       mov.l   @r15+, r8
+       mov.l   r8, @r4
+       mov.l   @r15+, r8
+
+       mov.l   r15, @-r4
+       mov.l   r14, @-r4
+       mov.l   r13, @-r4
+       mov.l   r12, @-r4
+       mov.l   r11, @-r4
+       mov.l   r10, @-r4
+       mov.l   r9, @-r4
+       mov.l   r8, @-r4
+       mov.l   r7, @-r4
+       mov.l   r6, @-r4
+       mov.l   r5, @-r4
+       add     #-4, r4
+       mov.l   r3, @-r4
+       mov.l   r2, @-r4
+       mov.l   r1, @-r4
+       mov.l   r0, @-r4
+       rts
+         mov.l r4, @(16,r4)
+SET_ENTRY_SIZE(_ZN7_Unwind13Registers_SH3C1Ev)
+
+       .hidden _ZNK7_Unwind13Registers_SH36jumptoEv
+ENTRY(_ZNK7_Unwind13Registers_SH36jumptoEv)
+       mov     r4, r0
+       add     #4, r0
+       mov.l   @r0+, r1
+       mov.l   @r0+, r2
+       mov.l   @r0+, r3
+       mov.l   @r0+, r4
+       mov.l   @r0+, r5
+       mov.l   @r0+, r6
+       mov.l   @r0+, r7
+       mov.l   @r0+, r8
+       mov.l   @r0+, r9
+       mov.l   @r0+, r10
+       mov.l   @r0+, r11
+       mov.l   @r0+, r12
+       mov.l   @r0+, r13
+       mov.l   @(12, r0), r14
+       lds     r14, pr
+       mov.l   @r0+, r14
+       mov.l   @r0+, r15
+       mov.l   @r0, r0
+       jmp     @r0
+         nop
+SET_ENTRY_SIZE(_ZNK7_Unwind13Registers_SH36jumptoEv)
+#endif



Home | Main Index | Thread Index | Old Index