From: Edgar E. Iglesias <[email protected]>

* configure.ac: Make it recognize microblaze.
 * process.c (change_syscall, set_arg): Add support for microblaze.
 * signal.c (sys_sigreturn): Add support for microblaze.
 * syscall.c (get_scno): Add support for microblaze.
   (syscall_fixup): Add support for microblaze.
   (get_error): Add support for microblaze.
   (syscall_enter): Add support for microblaze.
 * util.c (printcall): Add support for microblaze.

Signed-off-by: Edgar E. Iglesias <[email protected]>
Signed-off-by: Michal Simek <[email protected]>
---
 configure.ac |    4 +++
 process.c    |   80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 signal.c     |   27 +++++++++++++++++++
 syscall.c    |   35 +++++++++++++++++++++++++
 util.c       |    8 ++++++
 5 files changed, 153 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index 3b1db7c..1e69c68 100644
--- a/configure.ac
+++ b/configure.ac
@@ -71,6 +71,10 @@ mips*)
        arch=mips
        AC_DEFINE([MIPS], 1, [Define for the MIPS architecture.])
        ;;
+microblaze*)
+       arch=microblaze
+       AC_DEFINE([MICROBLAZE], 1, [Define for the MicroBlaze architecture.])
+       ;;
 alpha*)
        arch=alpha
        AC_DEFINE([ALPHA], 1, [Define for the Alpha architecture.])
diff --git a/process.c b/process.c
index 45ba33b..bf83f7e 100644
--- a/process.c
+++ b/process.c
@@ -141,6 +141,39 @@
 #define WCOREDUMP(status) ((status) & 0200)
 #endif
 
+#if defined(MICROBLAZE)
+/* FIXME: Let the kernel export a user-struct.  */
+#if 0
+#ifndef HAVE_STRUCT_USER
+struct user
+{
+  struct pt_regs regs;
+};
+#endif
+#endif
+
+#ifndef PT_GPR
+#define PT_GPR(x) (x * 4)
+#endif
+#ifndef NUM_GPRS
+#define NUM_GPRS 32
+#endif
+
+#ifndef PT_PC
+#define PT_PC           ((NUM_GPRS + 0) * 4)
+#endif
+#ifndef PT_MSR
+#define PT_MSR          ((NUM_GPRS + 1) * 4)
+#endif
+#ifndef PT_EAR
+#define PT_EAR          ((NUM_GPRS + 2) * 4)
+#define PT_ESR          ((NUM_GPRS + 3) * 4)
+#define PT_FSR          ((NUM_GPRS + 4) * 4)
+#define PT_KERNEL_MODE  ((NUM_GPRS + 5) * 4)
+#define PT_SINGLESTEP   ((NUM_GPRS + 6) * 4)
+#endif
+#endif
+
 /* WTA: this was `&& !defined(LINUXSPARC)', this seems unneeded though? */
 #if defined(HAVE_PRCTL)
 static const struct xlat prctl_options[] = {
@@ -737,6 +770,10 @@ change_syscall(struct tcb *tcp, int new)
        if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_V0), new)<0)
                return -1;
        return 0;
+#elif defined(MICROBLAZE)
+       if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(PT_GPR(0)), new)<0)
+               return -1;
+       return 0;
 #elif defined(ALPHA)
        if (ptrace(PTRACE_POKEUSER, tcp->pid, (char*)(REG_A3), new)<0)
                return -1;
@@ -3124,6 +3161,47 @@ const struct xlat struct_user_offsets[] = {
        { 69,                   "fpcsr"                                 },
        { 70,                   "fpeir"                                 },
 #   endif
+#   ifdef MICROBLAZE
+       { PT_GPR(0),            "r0"                                    },
+       { PT_GPR(1),            "r1"                                    },
+       { PT_GPR(2),            "r2"                                    },
+       { PT_GPR(3),            "r3"                                    },
+       { PT_GPR(4),            "r4"                                    },
+       { PT_GPR(5),            "r5"                                    },
+       { PT_GPR(6),            "r6"                                    },
+       { PT_GPR(7),            "r7"                                    },
+       { PT_GPR(8),            "r8"                                    },
+       { PT_GPR(9),            "r9"                                    },
+       { PT_GPR(10),           "r10"                                   },
+       { PT_GPR(11),           "r11"                                   },
+       { PT_GPR(12),           "r12"                                   },
+       { PT_GPR(13),           "r13"                                   },
+       { PT_GPR(14),           "r14"                                   },
+       { PT_GPR(15),           "r15"                                   },
+       { PT_GPR(16),           "r16"                                   },
+       { PT_GPR(17),           "r17"                                   },
+       { PT_GPR(18),           "r18"                                   },
+       { PT_GPR(19),           "r19"                                   },
+       { PT_GPR(20),           "r20"                                   },
+       { PT_GPR(21),           "r21"                                   },
+       { PT_GPR(22),           "r22"                                   },
+       { PT_GPR(23),           "r23"                                   },
+       { PT_GPR(24),           "r24"                                   },
+       { PT_GPR(25),           "r25"                                   },
+       { PT_GPR(26),           "r26"                                   },
+       { PT_GPR(27),           "r27"                                   },
+       { PT_GPR(28),           "r28"                                   },
+       { PT_GPR(29),           "r29"                                   },
+       { PT_GPR(30),           "r30"                                   },
+       { PT_GPR(31),           "r31"                                   },
+       { PT_PC,                "rpc",                                  },
+       { PT_MSR,               "rmsr",                                 },
+       { PT_EAR,               "rear",                                 },
+       { PT_ESR,               "resr",                                 },
+       { PT_FSR,               "rfsr",                                 },
+       { PT_KERNEL_MODE,       "kernel_mode",                          },
+       { PT_SINGLESTEP,        "singlestep",                           },
+#   endif
 #   ifdef CRISV10
        { 4*PT_FRAMETYPE, "4*PT_FRAMETYPE" },
        { 4*PT_ORIG_R10, "4*PT_ORIG_R10" },
@@ -3196,7 +3274,7 @@ const struct xlat struct_user_offsets[] = {
 
 #   if !defined(SPARC) && !defined(HPPA) && !defined(POWERPC) \
                && !defined(ALPHA) && !defined(IA64) \
-               && !defined(CRISV10) && !defined(CRISV32)
+               && !defined(CRISV10) && !defined(CRISV32) && 
!defined(MICROBLAZE)
 #    if !defined(S390) && !defined(S390X) && !defined(MIPS) && 
!defined(SPARC64) && !defined(AVR32) && !defined(BFIN)
        { uoff(u_fpvalid),      "offsetof(struct user, u_fpvalid)"      },
 #    endif
diff --git a/signal.c b/signal.c
index 76504f6..e21ef28 100644
--- a/signal.c
+++ b/signal.c
@@ -1477,6 +1477,33 @@ sys_sigreturn(struct tcb *tcp)
                return RVAL_NONE | RVAL_STR;
        }
        return 0;
+#elif defined(MICROBLAZE)
+       struct sigcontext sc;
+
+       /* TODO: Verify that this is correct...  */
+       if (entering(tcp)) {
+               long sp;
+
+               tcp->u_arg[0] = 0;
+
+               /* Read r1, the stack pointer.  */
+               if (upeek(tcp, 1 * 4, &sp) < 0)
+                       return 0;
+               if (umove(tcp, sp, &sc) < 0)
+                       return 0;
+               tcp->u_arg[0] = 1;
+               tcp->u_arg[1] = sc.oldmask;
+       } else {
+               sigset_t sigm;
+               long_to_sigset(tcp->u_arg[1], &sigm);
+               tcp->u_rval = tcp->u_error = 0;
+
+               if (tcp->u_arg[0] == 0)
+                       return 0;
+               tcp->auxstr = sprintsigmask("mask now ", &sigm, 0);
+               return RVAL_NONE | RVAL_STR;
+       }
+       return 0;
 #elif defined(CRISV10) || defined(CRISV32)
        struct sigcontext sc;
 
diff --git a/syscall.c b/syscall.c
index 26b1a9d..55400b7 100644
--- a/syscall.c
+++ b/syscall.c
@@ -775,6 +775,8 @@ internal_syscall(struct tcb *tcp)
        static long r9;
 #elif defined(X86_64)
        static long rax;
+#elif defined(MICROBLAZE)
+       static long r3;
 #elif defined(CRISV10) || defined(CRISV32)
        static long r10;
 #endif
@@ -1296,6 +1298,9 @@ get_scno(struct tcb *tcp)
                        return 0;
                }
        }
+# elif defined(MICROBLAZE)
+       if (upeek(tcp, 0, &scno) < 0)
+               return -1;
 # elif defined(CRISV10) || defined(CRISV32)
        if (upeek(tcp, 4*PT_R9, &scno) < 0)
                return -1;
@@ -1503,6 +1508,14 @@ syscall_fixup(struct tcb *tcp)
                        fprintf(stderr, "stray syscall exit: r8 = %ld\n", r8);
                return 0;
        }
+#elif defined(MICROBLAZE)
+       if (upeek(tcp, 3 * 4, &r3) < 0)
+               return -1;
+       if (r3 != -ENOSYS && !(tcp->flags & TCB_INSYSCALL)) {
+               if (debug)
+                       fprintf(stderr, "stray syscall exit: r3 = %ld\n", r3);
+               return 0;
+       }
 #elif defined(CRISV10) || defined(CRISV32)
        if (upeek(tcp->pid, 4*PT_R10, &r10) < 0)
                return -1;
@@ -1695,6 +1708,16 @@ get_error(struct tcb *tcp)
                        tcp->u_rval = r9;
                        u_error = 0;
                }
+# elif defined(MICROBLAZE)
+               /* interpret result as return value or error number */
+               if (is_negated_errno(r3)) {
+                       tcp->u_rval = -1;
+                       u_error = -r3;
+               }
+               else {
+                       tcp->u_rval = r3;
+                       u_error = 0;
+               }
 # elif defined(CRISV10) || defined(CRISV32)
                if (r10 && (unsigned) -r10 < nerrnos) {
                        tcp->u_rval = -1;
@@ -2214,6 +2237,18 @@ syscall_enter(struct tcb *tcp)
                                return -1;
                }
        }
+#elif defined(MICROBLAZE)
+       {
+               int i;
+               if (tcp->scno >= 0 && tcp->scno < nsyscalls)
+                       tcp->u_nargs = sysent[tcp->scno].nargs;
+               else
+                       tcp->u_nargs = 0;
+               for (i = 0; i < tcp->u_nargs; i++) {
+                       if (upeek(tcp, (5 + i) * 4, &tcp->u_arg[i]) < 0)
+                               return -1;
+               }
+       }
 #elif defined(CRISV10) || defined(CRISV32)
        {
                int i;
diff --git a/util.c b/util.c
index f41b0c3..95cdde4 100644
--- a/util.c
+++ b/util.c
@@ -1319,6 +1319,14 @@ printcall(struct tcb *tcp)
                return;
        }
        tprintf("[%08lx] ", pc);
+# elif defined(MICROBLAZE)
+       long pc;
+
+       if (upeek(tcp, PT_PC, &pc) < 0) {
+               tprintf ("[????????] ");
+               return;
+       }
+       tprintf("[%08lx] ", pc);
 # elif defined(SH)
        long pc;
 
-- 
1.5.5.1


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Strace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to