public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] sim: m32c: switch syscalls to common nltvals
@ 2021-04-19  3:21 Michael Frysinger
  0 siblings, 0 replies; only message in thread
From: Michael Frysinger @ 2021-04-19  3:21 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f956ecde56495cbcd5f8a3b440220090ee39ff56

commit f956ecde56495cbcd5f8a3b440220090ee39ff56
Author: Mike Frysinger <vapier@gentoo.org>
Date:   Sun Apr 18 22:31:19 2021 -0400

    sim: m32c: switch syscalls to common nltvals
    
    Rather than hand duplicate the syscall table, switch to the common
    nltvals framework.  We have to tweak the constant names, but we get
    everything else for free.  I made sure the constants have the same
    values before & after too :).

Diff:
---
 sim/common/ChangeLog     |  5 +++++
 sim/common/gennltvals.py |  1 +
 sim/common/nltvals.def   | 31 ++++++++++++++++++++++++++++++
 sim/m32c/ChangeLog       |  7 +++++++
 sim/m32c/Makefile.in     |  3 +++
 sim/m32c/syscall.h       | 50 ------------------------------------------------
 sim/m32c/syscalls.c      | 19 +++++++++---------
 7 files changed, 56 insertions(+), 60 deletions(-)

diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 2d5934ad064..8806233d47c 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,3 +1,8 @@
+2021-04-18  Mike Frysinger  <vapier@gentoo.org>
+
+	* gennltvals.py (TARGETS): Add m32c.
+	* nltvals.def: Regenerate.
+
 2021-04-18  Mike Frysinger  <vapier@gentoo.org>
 
 	* gennltvals.py (TARGETS): Add iq2000.
diff --git a/sim/common/gennltvals.py b/sim/common/gennltvals.py
index a246977fbf8..168ce4b5ecb 100755
--- a/sim/common/gennltvals.py
+++ b/sim/common/gennltvals.py
@@ -62,6 +62,7 @@ TARGETS = {
     'i960',
     'iq2000',
     'lm32',
+    'm32c',
     'm32r',
     'mcore',
     'mn10200',
diff --git a/sim/common/nltvals.def b/sim/common/nltvals.def
index 4aaeff8a446..fb3144a8556 100644
--- a/sim/common/nltvals.def
+++ b/sim/common/nltvals.def
@@ -404,6 +404,37 @@
 /* end lm32 sys target macros */
 #endif
 #endif
+#ifdef NL_TARGET_m32c
+#ifdef sys_defs
+/* from syscall.h */
+/* begin m32c sys target macros */
+ { "SYS_argc", 22 },
+ { "SYS_argn", 24 },
+ { "SYS_argnlen", 23 },
+ { "SYS_argv", 13 },
+ { "SYS_argvlen", 12 },
+ { "SYS_chdir", 14 },
+ { "SYS_chmod", 16 },
+ { "SYS_close", 3 },
+ { "SYS_exit", 1 },
+ { "SYS_fstat", 10 },
+ { "SYS_getpid", 8 },
+ { "SYS_gettimeofday", 19 },
+ { "SYS_kill", 9 },
+ { "SYS_link", 21 },
+ { "SYS_lseek", 6 },
+ { "SYS_open", 2 },
+ { "SYS_read", 4 },
+ { "SYS_reconfig", 25 },
+ { "SYS_stat", 15 },
+ { "SYS_time", 18 },
+ { "SYS_times", 20 },
+ { "SYS_unlink", 7 },
+ { "SYS_utime", 17 },
+ { "SYS_write", 5 },
+/* end m32c sys target macros */
+#endif
+#endif
 #ifdef NL_TARGET_m32r
 #ifdef sys_defs
 /* from syscall.h */
diff --git a/sim/m32c/ChangeLog b/sim/m32c/ChangeLog
index 8d912324593..26c7c98e06d 100644
--- a/sim/m32c/ChangeLog
+++ b/sim/m32c/ChangeLog
@@ -1,3 +1,10 @@
+2021-04-18  Mike Frysinger  <vapier@gentoo.org>
+
+	* Makefile.in (NL_TARGET): Define.
+	* syscalls.c: Change syscall.h include to targ-vals.h.
+	(m32c_syscall): Add TARGET_ prefix to all SYS_ constants.
+	* syscall.h: Removed.
+
 2021-04-18  Mike Frysinger  <vapier@gentoo.org>
 
 	* configure: Regenerate.
diff --git a/sim/m32c/Makefile.in b/sim/m32c/Makefile.in
index 186c9c063d3..15ade0b74be 100644
--- a/sim/m32c/Makefile.in
+++ b/sim/m32c/Makefile.in
@@ -18,6 +18,9 @@
 ### You should have received a copy of the GNU General Public License
 ### along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+# This selects the newlib/libgloss syscall definitions.
+NL_TARGET = -DNL_TARGET_m32c
+
 ## COMMON_PRE_CONFIG_FRAG
 
 SIM_EXTRA_CFLAGS = -Wall -DTIMER_A
diff --git a/sim/m32c/syscall.h b/sim/m32c/syscall.h
deleted file mode 100644
index 0194e039e7f..00000000000
--- a/sim/m32c/syscall.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* Copied from libgloss */
-/* General use syscall.h file.
-   The more ports that use this file, the simpler sim/common/nltvals.def
-   remains.  */
-
-#ifndef LIBGLOSS_SYSCALL_H
-#define LIBGLOSS_SYSCALL_H
-
-/* Note: This file may be included by assembler source.  */
-
-/* These should be as small as possible to allow a port to use a trap type
-   instruction, which the system call # as the trap (the d10v for instance
-   supports traps 0..31).  An alternative would be to define one trap for doing
-   system calls, and put the system call number in a register that is not used
-   for the normal calling sequence (so that you don't have to shift down the
-   arguments to add the system call number).  Obviously, if these system call
-   numbers are ever changed, all of the simulators and potentially user code
-   will need to be updated.  */
-
-/* There is no current need for the following: SYS_execv, SYS_creat, SYS_wait,
-   etc. etc.  Don't add them.  */
-
-/* These are required by the ANSI C part of newlib (excluding system() of
-   course).  */
-#define	SYS_exit	1
-#define	SYS_open	2
-#define	SYS_close	3
-#define	SYS_read	4
-#define	SYS_write	5
-#define	SYS_lseek	6
-#define	SYS_unlink	7
-#define	SYS_getpid	8
-#define	SYS_kill	9
-#define SYS_fstat       10
-/*#define SYS_sbrk	11 - not currently a system call, but reserved.  */
-
-/* ARGV support.  */
-#define SYS_argvlen	12
-#define SYS_argv	13
-
-/* These are extras added for one reason or another.  */
-#define SYS_chdir	 14
-#define SYS_stat	 15
-#define SYS_chmod 	 16
-#define SYS_utime 	 17
-#define SYS_time 	 18
-#define SYS_gettimeofday 19
-#define SYS_times	 20
-#define SYS_link	 21
-#endif
diff --git a/sim/m32c/syscalls.c b/sim/m32c/syscalls.c
index a033dba604c..86695cb4dde 100644
--- a/sim/m32c/syscalls.c
+++ b/sim/m32c/syscalls.c
@@ -30,8 +30,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "cpu.h"
 #include "mem.h"
 #include "syscalls.h"
-
-#include "syscall.h"
+#include "targ-vals.h"
 
 /* The current syscall callbacks we're using.  */
 static struct host_callback_struct *callbacks;
@@ -184,7 +183,7 @@ m32c_syscall (int id)
     printf ("\033[31m/* SYSCALL(%d) = %s */\033[0m\n", id, callnames[id]);
   switch (id)
     {
-    case SYS_exit:
+    case TARGET_SYS_exit:
       {
 	int ec = arg (2);
 	if (verbose)
@@ -193,7 +192,7 @@ m32c_syscall (int id)
       }
       break;
 
-    case SYS_open:
+    case TARGET_SYS_open:
       {
 	int path = arg (PTRSZ);
 	int oflags = arg (2);
@@ -228,7 +227,7 @@ m32c_syscall (int id)
       }
       break;
 
-    case SYS_close:
+    case TARGET_SYS_close:
       {
 	int fd = arg (2);
 
@@ -244,7 +243,7 @@ m32c_syscall (int id)
       }
       break;
 
-    case SYS_read:
+    case TARGET_SYS_read:
       {
 	int fd = arg (2);
 	int addr = arg (PTRSZ);
@@ -264,7 +263,7 @@ m32c_syscall (int id)
       }
       break;
 
-    case SYS_write:
+    case TARGET_SYS_write:
       {
 	int fd = arg (2);
 	int addr = arg (PTRSZ);
@@ -287,11 +286,11 @@ m32c_syscall (int id)
       }
       break;
 
-    case SYS_getpid:
+    case TARGET_SYS_getpid:
       put_reg (r0, 42);
       break;
 
-    case SYS_gettimeofday:
+    case TARGET_SYS_gettimeofday:
       {
 	int tvaddr = arg (PTRSZ);
 	struct timeval tv;
@@ -306,7 +305,7 @@ m32c_syscall (int id)
       }
       break;
 
-    case SYS_kill:
+    case TARGET_SYS_kill:
       {
 	int pid = arg (2);
 	int sig = arg (2);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-04-19  3:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-19  3:21 [binutils-gdb] sim: m32c: switch syscalls to common nltvals Michael Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).