From bd8dd776db79b608ee9b71527add272247b18382 Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Sat, 18 Apr 2015 17:33:27 -0300 Subject: [PATCH] Add support for Altera's Nios-II softcore architecture 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. * configure.ac: Add nios2 support. * cacheflush.c [NIOS2] (sys_cacheflush): New function. * linux/nios2/*: New Nios-II specific files. * Makefile.am (EXTRA_DIST): Add them. Signed-off-by: Ezequiel Garcia --- Makefile.am | 8 ++++++++ cacheflush.c | 12 ++++++++++++ configure.ac | 5 +++++ linux/nios2/arch_regs.c | 2 ++ linux/nios2/get_error.c | 13 +++++++++++++ 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, 54 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 549aebc4..425df6cb 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 727d49bc..1ad3a15f 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 d829e18b..4713c9a1 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 00000000..62827f97 --- /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 00000000..5d7e6db6 --- /dev/null +++ b/linux/nios2/get_error.c @@ -0,0 +1,13 @@ +/* + * 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 00000000..c820bcea --- /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 00000000..d12c2f7e --- /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 00000000..f015def4 --- /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 00000000..4aecf983 --- /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 00000000..d22e8f73 --- /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 00000000..de208f20 --- /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.40.0