This commit adds strace support for Altera's Nios-II. The architecture
is supported by Linux since v3.19, and it implements the generic syscall ABI.

* Makefile.am, configure.ac: add nios2 files and support
* cacheflush.c: support nios2 cacheflush syscall
* linux/nios2/: arch-specific port

Signed-off-by: Ezequiel Garcia <ezequ...@vanguardiasur.com.ar>
---
 Makefile.am                    |  8 ++++++++
 cacheflush.c                   | 12 ++++++++++++
 configure.ac                   |  5 +++++
 linux/nios2/arch_regs.c        |  2 ++
 linux/nios2/get_error.c        | 14 ++++++++++++++
 linux/nios2/get_scno.c         |  1 +
 linux/nios2/get_syscall_args.c |  6 ++++++
 linux/nios2/ioctls_arch0.h     |  1 +
 linux/nios2/ioctls_inc0.h      |  1 +
 linux/nios2/print_pc.c         |  1 +
 linux/nios2/syscallent.h       |  4 ++++
 11 files changed, 55 insertions(+)
 create mode 100644 linux/nios2/arch_regs.c
 create mode 100644 linux/nios2/get_error.c
 create mode 100644 linux/nios2/get_scno.c
 create mode 100644 linux/nios2/get_syscall_args.c
 create mode 100644 linux/nios2/ioctls_arch0.h
 create mode 100644 linux/nios2/ioctls_inc0.h
 create mode 100644 linux/nios2/print_pc.c
 create mode 100644 linux/nios2/syscallent.h

diff --git a/Makefile.am b/Makefile.am
index 549aebc..425df6c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -341,6 +341,14 @@ EXTRA_DIST =                               \
        linux/mips/syscallent.h         \
        linux/mips/userent.h            \
        linux/mtd-abi.h                 \
+       linux/nios2/arch_regs.c         \
+       linux/nios2/get_error.c         \
+       linux/nios2/get_scno.c          \
+       linux/nios2/get_syscall_args.c  \
+       linux/nios2/ioctls_arch0.h      \
+       linux/nios2/ioctls_inc0.h       \
+       linux/nios2/print_pc.c          \
+       linux/nios2/syscallent.h        \
        linux/or1k/arch_regs.c          \
        linux/or1k/get_error.c          \
        linux/or1k/get_scno.c           \
diff --git a/cacheflush.c b/cacheflush.c
index 727d49b..1ad3a15 100644
--- a/cacheflush.c
+++ b/cacheflush.c
@@ -89,3 +89,15 @@ SYS_FUNC(cacheflush)
        return 0;
 }
 #endif /* SH */
+
+#ifdef NIOS2
+SYS_FUNC(cacheflush)
+{
+       if (entering(tcp)) {
+               /* addr and len */
+               tprintf("%#lx, %lu", tcp->u_arg[0], tcp->u_arg[3]);
+               /* scope and flags (cache type) are currently ignored */
+       }
+       return 0;
+}
+#endif /* NIOS2 */
diff --git a/configure.ac b/configure.ac
index d829e18..4713c9a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -125,6 +125,11 @@ microblaze*)
        arch=microblaze
        AC_DEFINE([MICROBLAZE], 1, [Define for the MicroBlaze architecture.])
        ;;
+nios2*)
+       arch=nios2
+       AC_DEFINE([NIOS2], 1, [Define for the Nios-II architecture.])
+       ;;
+
 or1k*)
        arch=or1k
        AC_DEFINE([OR1K], 1, [Define for the OpenRISC 1000 architecture.])
diff --git a/linux/nios2/arch_regs.c b/linux/nios2/arch_regs.c
new file mode 100644
index 0000000..62827f9
--- /dev/null
+++ b/linux/nios2/arch_regs.c
@@ -0,0 +1,2 @@
+static struct user_pt_regs nios2_regs;
+# define ARCH_REGS_FOR_GETREGSET nios2_regs
diff --git a/linux/nios2/get_error.c b/linux/nios2/get_error.c
new file mode 100644
index 0000000..e2c46d0
--- /dev/null
+++ b/linux/nios2/get_error.c
@@ -0,0 +1,14 @@
+/*
+ * The system call convention specifies that r2 contains the return
+ * value on success or a positive error number on failure. A flag
+ * indicating successful completion is written to r7; r7=0 indicates
+ * the system call success, r7=1 indicates an error. The positive
+ * errno value written in r2.
+ */
+if (check_errno && nios2_regs.regs[7]) {
+       tcp->u_rval = -1;
+       tcp->u_error = nios2_regs.regs[2];
+}
+else {
+       tcp->u_rval = nios2_regs.regs[2];
+}
diff --git a/linux/nios2/get_scno.c b/linux/nios2/get_scno.c
new file mode 100644
index 0000000..c820bce
--- /dev/null
+++ b/linux/nios2/get_scno.c
@@ -0,0 +1 @@
+scno = nios2_regs.regs[2];
diff --git a/linux/nios2/get_syscall_args.c b/linux/nios2/get_syscall_args.c
new file mode 100644
index 0000000..d12c2f7
--- /dev/null
+++ b/linux/nios2/get_syscall_args.c
@@ -0,0 +1,6 @@
+tcp->u_arg[0] = nios2_regs.regs[4];
+tcp->u_arg[1] = nios2_regs.regs[5];
+tcp->u_arg[2] = nios2_regs.regs[6];
+tcp->u_arg[3] = nios2_regs.regs[7];
+tcp->u_arg[4] = nios2_regs.regs[8];
+tcp->u_arg[5] = nios2_regs.regs[9];
diff --git a/linux/nios2/ioctls_arch0.h b/linux/nios2/ioctls_arch0.h
new file mode 100644
index 0000000..f015def
--- /dev/null
+++ b/linux/nios2/ioctls_arch0.h
@@ -0,0 +1 @@
+/* Generated by ioctls_gen.sh from definitions found in 
$linux/arch/nios2/include/ tree. */
diff --git a/linux/nios2/ioctls_inc0.h b/linux/nios2/ioctls_inc0.h
new file mode 100644
index 0000000..4aecf98
--- /dev/null
+++ b/linux/nios2/ioctls_inc0.h
@@ -0,0 +1 @@
+#include "32/ioctls_inc.h"
diff --git a/linux/nios2/print_pc.c b/linux/nios2/print_pc.c
new file mode 100644
index 0000000..d22e8f7
--- /dev/null
+++ b/linux/nios2/print_pc.c
@@ -0,0 +1 @@
+tprintf(fmt, nios2_regs.regs[PTR_EA]);
diff --git a/linux/nios2/syscallent.h b/linux/nios2/syscallent.h
new file mode 100644
index 0000000..de208f2
--- /dev/null
+++ b/linux/nios2/syscallent.h
@@ -0,0 +1,4 @@
+#define ARCH_sys_mmap sys_mmap_pgoff
+#include "32/syscallent.h"
+[244] = {4,    0,      sys_cacheflush, "cacheflush"},
+[245 ... 259] = { },
-- 
2.3.3


------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to