* [PATCH/committed 1/5] sim: iq2000: switch syscalls to common nltvals
@ 2021-04-19 3:20 Mike Frysinger
2021-04-19 3:20 ` [PATCH/committed 2/5] sim: m32c: " Mike Frysinger
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Mike Frysinger @ 2021-04-19 3:20 UTC (permalink / raw)
To: gdb-patches
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 :).
---
sim/common/ChangeLog | 5 +++++
sim/common/gennltvals.py | 1 +
sim/common/nltvals.def | 32 ++++++++++++++++++++++++++++++++
sim/iq2000/ChangeLog | 7 +++++++
sim/iq2000/Makefile.in | 3 +++
sim/iq2000/iq2000.c | 38 ++++++++------------------------------
6 files changed, 56 insertions(+), 30 deletions(-)
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index b1af152930a9..2d5934ad064a 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 iq2000.
+ * nltvals.def: Regenerate.
+
2021-04-18 Mike Frysinger <vapier@gentoo.org>
* syscall.c (cb_syscall): Implement CB_SYS_getpid.
diff --git a/sim/common/gennltvals.py b/sim/common/gennltvals.py
index 23b218728c2b..a246977fbf8e 100755
--- a/sim/common/gennltvals.py
+++ b/sim/common/gennltvals.py
@@ -60,6 +60,7 @@ TARGETS = {
'fr30',
'frv',
'i960',
+ 'iq2000',
'lm32',
'm32r',
'mcore',
diff --git a/sim/common/nltvals.def b/sim/common/nltvals.def
index 6f93316ea022..4aaeff8a446d 100644
--- a/sim/common/nltvals.def
+++ b/sim/common/nltvals.def
@@ -342,6 +342,37 @@
/* end i960 sys target macros */
#endif
#endif
+#ifdef NL_TARGET_iq2000
+#ifdef sys_defs
+/* from syscall.h */
+/* begin iq2000 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 iq2000 sys target macros */
+#endif
+#endif
#ifdef NL_TARGET_lm32
#ifdef sys_defs
/* from syscall.h */
@@ -553,6 +584,7 @@
{ "SYS_access", 1033 },
{ "SYS_brk", 214 },
{ "SYS_chdir", 49 },
+ { "SYS_clock_gettime64", 403 },
{ "SYS_close", 57 },
{ "SYS_dup", 23 },
{ "SYS_exit", 93 },
diff --git a/sim/iq2000/ChangeLog b/sim/iq2000/ChangeLog
index c6fc38c18c10..cb67450fd7a6 100644
--- a/sim/iq2000/ChangeLog
+++ b/sim/iq2000/ChangeLog
@@ -1,3 +1,10 @@
+2021-04-18 Mike Frysinger <vapier@gentoo.org>
+
+ * Makefile.in (NL_TARGET): Define.
+ * iq2000.c: Include targ-vals.h.
+ (libgloss_syscall): Delete.
+ (do_syscall): Add TARGET_ prefix to all SYS_ constants.
+
2021-04-18 Mike Frysinger <vapier@gentoo.org>
* configure: Regenerate.
diff --git a/sim/iq2000/Makefile.in b/sim/iq2000/Makefile.in
index f3ab6351b25f..baf49dd3330f 100644
--- a/sim/iq2000/Makefile.in
+++ b/sim/iq2000/Makefile.in
@@ -15,6 +15,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_iq2000
+
## COMMON_PRE_CONFIG_FRAG
IQ2000_OBJS = iq2000.o cpu.o decode.o sem.o model.o mloop.o
diff --git a/sim/iq2000/iq2000.c b/sim/iq2000/iq2000.c
index e03c47919fdf..66d7b47dfb4f 100644
--- a/sim/iq2000/iq2000.c
+++ b/sim/iq2000/iq2000.c
@@ -23,6 +23,7 @@
#include "sim-main.h"
#include "cgen-mem.h"
#include "cgen-ops.h"
+#include "targ-vals.h"
#include <stdlib.h>
enum
@@ -32,29 +33,6 @@ enum
PC_REGNUM = 32
};
-enum libgloss_syscall
-{
- SYS_exit = 1,
- SYS_open = 2,
- SYS_close = 3,
- SYS_read = 4,
- SYS_write = 5,
- SYS_lseek = 6,
- SYS_unlink = 7,
- SYS_getpid = 8,
- SYS_kill = 9,
- SYS_fstat = 10,
- SYS_argvlen = 12,
- SYS_argv = 13,
- SYS_chdir = 14,
- SYS_stat = 15,
- SYS_chmod = 16,
- SYS_utime = 17,
- SYS_time = 18,
- SYS_gettimeofday = 19,
- SYS_times = 20
-};
-
/* Read a null terminated string from memory, return in a buffer */
static char *
fetch_str (SIM_CPU *current_cpu, PCADDR pc, DI addr)
@@ -98,7 +76,7 @@ do_syscall (SIM_CPU *current_cpu, PCADDR pc)
exit (1);
}
- case SYS_write:
+ case TARGET_SYS_write:
buf = zalloc (PARM3);
sim_read (CPU_STATE (current_cpu), CPU2DATA(PARM2), buf, PARM3);
SET_H_GR (ret_reg,
@@ -107,18 +85,18 @@ do_syscall (SIM_CPU *current_cpu, PCADDR pc)
free (buf);
break;
- case SYS_lseek:
+ case TARGET_SYS_lseek:
SET_H_GR (ret_reg,
sim_io_lseek (CPU_STATE (current_cpu),
PARM1, PARM2, PARM3));
break;
- case SYS_exit:
+ case TARGET_SYS_exit:
sim_engine_halt (CPU_STATE (current_cpu), current_cpu,
NULL, pc, sim_exited, PARM1);
break;
- case SYS_read:
+ case TARGET_SYS_read:
buf = zalloc (PARM3);
SET_H_GR (ret_reg,
sim_io_read (CPU_STATE (current_cpu),
@@ -127,7 +105,7 @@ do_syscall (SIM_CPU *current_cpu, PCADDR pc)
free (buf);
break;
- case SYS_open:
+ case TARGET_SYS_open:
buf = fetch_str (current_cpu, pc, PARM1);
SET_H_GR (ret_reg,
sim_io_open (CPU_STATE (current_cpu),
@@ -135,12 +113,12 @@ do_syscall (SIM_CPU *current_cpu, PCADDR pc)
free (buf);
break;
- case SYS_close:
+ case TARGET_SYS_close:
SET_H_GR (ret_reg,
sim_io_close (CPU_STATE (current_cpu), PARM1));
break;
- case SYS_time:
+ case TARGET_SYS_time:
SET_H_GR (ret_reg, time (0));
break;
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH/committed 2/5] sim: m32c: switch syscalls to common nltvals
2021-04-19 3:20 [PATCH/committed 1/5] sim: iq2000: switch syscalls to common nltvals Mike Frysinger
@ 2021-04-19 3:20 ` Mike Frysinger
2021-04-19 3:20 ` [PATCH/committed 3/5] sim: rx: " Mike Frysinger
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2021-04-19 3:20 UTC (permalink / raw)
To: gdb-patches
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 :).
---
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(-)
delete mode 100644 sim/m32c/syscall.h
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 2d5934ad064a..8806233d47cb 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 a246977fbf8e..168ce4b5ecb9 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 4aaeff8a446d..fb3144a85562 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 8d9123245930..26c7c98e06dc 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 186c9c063d32..15ade0b74be0 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 0194e039e7fe..000000000000
--- 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 a033dba604cc..86695cb4dde7 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);
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH/committed 3/5] sim: rx: switch syscalls to common nltvals
2021-04-19 3:20 [PATCH/committed 1/5] sim: iq2000: switch syscalls to common nltvals Mike Frysinger
2021-04-19 3:20 ` [PATCH/committed 2/5] sim: m32c: " Mike Frysinger
@ 2021-04-19 3:20 ` Mike Frysinger
2021-04-19 3:20 ` [PATCH/committed 4/5] sim: sh: " Mike Frysinger
2021-04-19 3:20 ` [PATCH/committed 5/5] sim: moxie: " Mike Frysinger
3 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2021-04-19 3:20 UTC (permalink / raw)
To: gdb-patches
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 :).
---
sim/common/ChangeLog | 5 ++++
sim/common/gennltvals.py | 1 +
sim/common/nltvals.def | 31 +++++++++++++++++++++++++
sim/rx/ChangeLog | 8 +++++++
sim/rx/Makefile.in | 5 +++-
sim/rx/syscall.h | 50 ----------------------------------------
sim/rx/syscalls.c | 21 ++++++++---------
7 files changed, 59 insertions(+), 62 deletions(-)
delete mode 100644 sim/rx/syscall.h
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 8806233d47cb..f0827b283a6f 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 rx.
+ * nltvals.def: Regenerate.
+
2021-04-18 Mike Frysinger <vapier@gentoo.org>
* gennltvals.py (TARGETS): Add m32c.
diff --git a/sim/common/gennltvals.py b/sim/common/gennltvals.py
index 168ce4b5ecb9..bf0aaa484adf 100755
--- a/sim/common/gennltvals.py
+++ b/sim/common/gennltvals.py
@@ -70,6 +70,7 @@ TARGETS = {
'msp430',
'pru',
'riscv',
+ 'rx',
'sparc',
'v850',
}
diff --git a/sim/common/nltvals.def b/sim/common/nltvals.def
index fb3144a85562..fbaee3abc646 100644
--- a/sim/common/nltvals.def
+++ b/sim/common/nltvals.def
@@ -657,6 +657,37 @@
/* end riscv sys target macros */
#endif
#endif
+#ifdef NL_TARGET_rx
+#ifdef sys_defs
+/* from syscall.h */
+/* begin rx 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 rx sys target macros */
+#endif
+#endif
#ifdef NL_TARGET_sparc
#ifdef sys_defs
/* from syscall.h */
diff --git a/sim/rx/ChangeLog b/sim/rx/ChangeLog
index 618b0c0df064..6660671bca24 100644
--- a/sim/rx/ChangeLog
+++ b/sim/rx/ChangeLog
@@ -1,3 +1,11 @@
+2021-04-18 Mike Frysinger <vapier@gentoo.org>
+
+ * Makefile.in (NL_TARGET): Define.
+ (syscalls.o): Delete syscall.h.
+ * syscalls.c: Change syscall.h include to targ-vals.h.
+ (rx_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/rx/Makefile.in b/sim/rx/Makefile.in
index 4de062153c77..3c6094caf2e7 100644
--- a/sim/rx/Makefile.in
+++ b/sim/rx/Makefile.in
@@ -18,6 +18,9 @@
### You should have received a copy of the GNU General Public License
### along with the GNU simulators; if not, see <http://www.gnu.org/licenses/>.
+# This selects the newlib/libgloss syscall definitions.
+NL_TARGET = -DNL_TARGET_rx
+
## COMMON_PRE_CONFIG_FRAG
SIM_EXTRA_CFLAGS = -Wall
@@ -58,5 +61,5 @@ mem.o : mem.h cpu.h syscalls.h misc.h err.h
misc.o : cpu.h misc.h
reg.o : cpu.h trace.h
rx.o : $(srcdir)/../../include/opcode/rx.h cpu.h mem.h syscalls.h fpu.h
-syscalls.o : $(srcdir)/../../include/gdb/callback.h cpu.h mem.h syscalls.h syscall.h
+syscalls.o : $(srcdir)/../../include/gdb/callback.h cpu.h mem.h syscalls.h
trace.o : ../../bfd/bfd.h $(srcdir)/../../include/dis-asm.h cpu.h mem.h load.h
diff --git a/sim/rx/syscall.h b/sim/rx/syscall.h
deleted file mode 100644
index 0194e039e7fe..000000000000
--- a/sim/rx/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/rx/syscalls.c b/sim/rx/syscalls.c
index 22778b3df490..0c75c7dcdf8a 100644
--- a/sim/rx/syscalls.c
+++ b/sim/rx/syscalls.c
@@ -31,8 +31,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;
@@ -146,10 +145,10 @@ rx_syscall (int id)
argp = 0;
stackp = 4;
if (trace)
- printf ("\033[31m/* SYSCALL(%d) = %s */\033[0m\n", id, id <= SYS_link ? callnames[id] : "unknown");
+ printf ("\033[31m/* SYSCALL(%d) = %s */\033[0m\n", id, id <= TARGET_SYS_link ? callnames[id] : "unknown");
switch (id)
{
- case SYS_exit:
+ case TARGET_SYS_exit:
{
int ec = arg ();
if (verbose)
@@ -158,7 +157,7 @@ rx_syscall (int id)
}
break;
- case SYS_open:
+ case TARGET_SYS_open:
{
int oflags, cflags;
int path = arg ();
@@ -200,7 +199,7 @@ rx_syscall (int id)
}
break;
- case SYS_close:
+ case TARGET_SYS_close:
{
int fd = arg ();
@@ -216,7 +215,7 @@ rx_syscall (int id)
}
break;
- case SYS_read:
+ case TARGET_SYS_read:
{
int fd = arg ();
int addr = arg ();
@@ -236,7 +235,7 @@ rx_syscall (int id)
}
break;
- case SYS_write:
+ case TARGET_SYS_write:
{
int fd = arg ();
int addr = arg ();
@@ -259,11 +258,11 @@ rx_syscall (int id)
}
break;
- case SYS_getpid:
+ case TARGET_SYS_getpid:
put_reg (1, 42);
break;
- case SYS_gettimeofday:
+ case TARGET_SYS_gettimeofday:
{
int tvaddr = arg ();
struct timeval tv;
@@ -278,7 +277,7 @@ rx_syscall (int id)
}
break;
- case SYS_kill:
+ case TARGET_SYS_kill:
{
int pid = arg ();
int sig = arg ();
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH/committed 4/5] sim: sh: switch syscalls to common nltvals
2021-04-19 3:20 [PATCH/committed 1/5] sim: iq2000: switch syscalls to common nltvals Mike Frysinger
2021-04-19 3:20 ` [PATCH/committed 2/5] sim: m32c: " Mike Frysinger
2021-04-19 3:20 ` [PATCH/committed 3/5] sim: rx: " Mike Frysinger
@ 2021-04-19 3:20 ` Mike Frysinger
2021-04-19 3:20 ` [PATCH/committed 5/5] sim: moxie: " Mike Frysinger
3 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2021-04-19 3:20 UTC (permalink / raw)
To: gdb-patches
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 :).
---
sim/common/ChangeLog | 5 +++++
sim/common/gennltvals.py | 2 ++
sim/common/nltvals.def | 38 +++++++++++++++++++++++++++++++++
sim/sh/ChangeLog | 7 +++++++
sim/sh/Makefile.in | 3 +++
sim/sh/interp.c | 45 ++++++++++++++++++++--------------------
sim/sh/syscall.h | 36 --------------------------------
7 files changed, 77 insertions(+), 59 deletions(-)
delete mode 100644 sim/sh/syscall.h
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index f0827b283a6f..20a425731f52 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,3 +1,8 @@
+2021-04-18 Mike Frysinger <vapier@gentoo.org>
+
+ * gennltvals.py (TARGET_DIRS, TARGETS): Add sh.
+ * nltvals.def: Regenerate.
+
2021-04-18 Mike Frysinger <vapier@gentoo.org>
* gennltvals.py (TARGETS): Add rx.
diff --git a/sim/common/gennltvals.py b/sim/common/gennltvals.py
index bf0aaa484adf..5831607a17c7 100755
--- a/sim/common/gennltvals.py
+++ b/sim/common/gennltvals.py
@@ -51,6 +51,7 @@ TARGET_DIRS = {
'i960': 'libgloss/i960',
'mcore': 'libgloss/mcore',
'riscv': 'libgloss/riscv/machine',
+ 'sh': 'newlib/libc/sys/sh/sys',
'v850': 'libgloss/v850/sys',
}
TARGETS = {
@@ -71,6 +72,7 @@ TARGETS = {
'pru',
'riscv',
'rx',
+ 'sh',
'sparc',
'v850',
}
diff --git a/sim/common/nltvals.def b/sim/common/nltvals.def
index fbaee3abc646..3b890af0639f 100644
--- a/sim/common/nltvals.def
+++ b/sim/common/nltvals.def
@@ -688,6 +688,44 @@
/* end rx sys target macros */
#endif
#endif
+#ifdef NL_TARGET_sh
+#ifdef sys_defs
+/* from syscall.h */
+/* begin sh sys target macros */
+ { "SYS_ARG", 24 },
+ { "SYS_argc", 172 },
+ { "SYS_argn", 174 },
+ { "SYS_argnlen", 173 },
+ { "SYS_chdir", 12 },
+ { "SYS_chmod", 15 },
+ { "SYS_chown", 16 },
+ { "SYS_close", 6 },
+ { "SYS_creat", 8 },
+ { "SYS_execv", 11 },
+ { "SYS_execve", 59 },
+ { "SYS_exit", 1 },
+ { "SYS_fork", 2 },
+ { "SYS_fstat", 22 },
+ { "SYS_ftruncate", 130 },
+ { "SYS_getpid", 20 },
+ { "SYS_isatty", 21 },
+ { "SYS_link", 9 },
+ { "SYS_lseek", 19 },
+ { "SYS_mknod", 14 },
+ { "SYS_open", 5 },
+ { "SYS_pipe", 42 },
+ { "SYS_read", 3 },
+ { "SYS_stat", 38 },
+ { "SYS_time", 23 },
+ { "SYS_truncate", 129 },
+ { "SYS_unlink", 10 },
+ { "SYS_utime", 201 },
+ { "SYS_wait", 202 },
+ { "SYS_wait4", 7 },
+ { "SYS_write", 4 },
+/* end sh sys target macros */
+#endif
+#endif
#ifdef NL_TARGET_sparc
#ifdef sys_defs
/* from syscall.h */
diff --git a/sim/sh/ChangeLog b/sim/sh/ChangeLog
index 1389261de164..984ff5e63211 100644
--- a/sim/sh/ChangeLog
+++ b/sim/sh/ChangeLog
@@ -1,3 +1,10 @@
+2021-04-18 Mike Frysinger <vapier@gentoo.org>
+
+ * Makefile.in (NL_TARGET): Define.
+ * interp.c: Change syscall.h include to targ-vals.h.
+ (trap): Add TARGET_ prefix to all SYS_ constants.
+ * syscall.h: Removed.
+
2021-04-18 Mike Frysinger <vapier@gentoo.org>
* configure: Regenerate.
diff --git a/sim/sh/Makefile.in b/sim/sh/Makefile.in
index 54f1e0ab94b8..e92b7843dab8 100644
--- a/sim/sh/Makefile.in
+++ b/sim/sh/Makefile.in
@@ -15,6 +15,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_sh
+
## COMMON_PRE_CONFIG_FRAG
SIM_OBJS = \
diff --git a/sim/sh/interp.c b/sim/sh/interp.c
index 7b9dd521c870..2fafcfd66285 100644
--- a/sim/sh/interp.c
+++ b/sim/sh/interp.c
@@ -60,8 +60,7 @@
#include "sim-base.h"
#include "sim-options.h"
-/* This file is local - if newlib changes, then so should this. */
-#include "syscall.h"
+#include "targ-vals.h"
#include <math.h>
@@ -887,21 +886,21 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
{
#if !defined(__GO32__) && !defined(_WIN32)
- case SYS_fork:
+ case TARGET_SYS_fork:
regs[0] = fork ();
break;
/* This would work only if endianness matched between host and target.
Besides, it's quite dangerous. */
#if 0
- case SYS_execve:
+ case TARGET_SYS_execve:
regs[0] = execve (ptr (regs[5]), (char **) ptr (regs[6]),
(char **) ptr (regs[7]));
break;
- case SYS_execv:
+ case TARGET_SYS_execv:
regs[0] = execve (ptr (regs[5]), (char **) ptr (regs[6]), 0);
break;
#endif
- case SYS_pipe:
+ case TARGET_SYS_pipe:
{
regs[0] = (BUSERROR (regs[5], maskl)
? -EINVAL
@@ -909,18 +908,18 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
}
break;
- case SYS_wait:
+ case TARGET_SYS_wait:
regs[0] = wait ((int *) ptr (regs[5]));
break;
#endif /* !defined(__GO32__) && !defined(_WIN32) */
- case SYS_read:
+ case TARGET_SYS_read:
strnswap (regs[6], regs[7]);
regs[0]
= callback->read (callback, regs[5], ptr (regs[6]), regs[7]);
strnswap (regs[6], regs[7]);
break;
- case SYS_write:
+ case TARGET_SYS_write:
strnswap (regs[6], regs[7]);
if (regs[5] == 1)
regs[0] = (int) callback->write_stdout (callback,
@@ -930,13 +929,13 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
ptr (regs[6]), regs[7]);
strnswap (regs[6], regs[7]);
break;
- case SYS_lseek:
+ case TARGET_SYS_lseek:
regs[0] = callback->lseek (callback,regs[5], regs[6], regs[7]);
break;
- case SYS_close:
+ case TARGET_SYS_close:
regs[0] = callback->close (callback,regs[5]);
break;
- case SYS_open:
+ case TARGET_SYS_open:
{
int len = strswaplen (regs[5]);
strnswap (regs[5], len);
@@ -944,13 +943,13 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
strnswap (regs[5], len);
break;
}
- case SYS_exit:
+ case TARGET_SYS_exit:
/* EXIT - caller can look in r5 to work out the reason */
raise_exception (SIGQUIT);
regs[0] = regs[5];
break;
- case SYS_stat: /* added at hmsi */
+ case TARGET_SYS_stat: /* added at hmsi */
/* stat system call */
{
struct stat host_stat;
@@ -999,7 +998,7 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
break;
#ifndef _WIN32
- case SYS_chown:
+ case TARGET_SYS_chown:
{
int len = strswaplen (regs[5]);
@@ -1009,7 +1008,7 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
break;
}
#endif /* _WIN32 */
- case SYS_chmod:
+ case TARGET_SYS_chmod:
{
int len = strswaplen (regs[5]);
@@ -1018,7 +1017,7 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
strnswap (regs[5], len);
break;
}
- case SYS_utime:
+ case TARGET_SYS_utime:
{
/* Cast the second argument to void *, to avoid type mismatch
if a prototype is present. */
@@ -1029,16 +1028,16 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
strnswap (regs[5], len);
break;
}
- case SYS_argc:
+ case TARGET_SYS_argc:
regs[0] = countargv (prog_argv);
break;
- case SYS_argnlen:
+ case TARGET_SYS_argnlen:
if (regs[5] < countargv (prog_argv))
regs[0] = strlen (prog_argv[regs[5]]);
else
regs[0] = -1;
break;
- case SYS_argn:
+ case TARGET_SYS_argn:
if (regs[5] < countargv (prog_argv))
{
/* Include the termination byte. */
@@ -1048,13 +1047,13 @@ trap (SIM_DESC sd, int i, int *regs, unsigned char *insn_ptr,
else
regs[0] = -1;
break;
- case SYS_time:
+ case TARGET_SYS_time:
regs[0] = get_now ();
break;
- case SYS_ftruncate:
+ case TARGET_SYS_ftruncate:
regs[0] = callback->ftruncate (callback, regs[5], regs[6]);
break;
- case SYS_truncate:
+ case TARGET_SYS_truncate:
{
int len = strswaplen (regs[5]);
strnswap (regs[5], len);
diff --git a/sim/sh/syscall.h b/sim/sh/syscall.h
deleted file mode 100644
index aebce2ce26d9..000000000000
--- a/sim/sh/syscall.h
+++ /dev/null
@@ -1,36 +0,0 @@
-
-/* !!! DANGER !!!
- This was copied from newlib. */
-
-
-#define SYS_exit 1
-#define SYS_fork 2
-#define SYS_read 3
-#define SYS_write 4
-#define SYS_open 5
-#define SYS_close 6
-#define SYS_wait4 7
-#define SYS_creat 8
-#define SYS_link 9
-#define SYS_unlink 10
-#define SYS_execv 11
-#define SYS_chdir 12
-#define SYS_mknod 14
-#define SYS_chmod 15
-#define SYS_chown 16
-#define SYS_lseek 19
-#define SYS_getpid 20
-#define SYS_isatty 21
-#define SYS_fstat 22
-#define SYS_time 23
-#define SYS_ARG 24
-#define SYS_stat 38
-#define SYS_pipe 42
-#define SYS_execve 59
-#define SYS_truncate 129
-#define SYS_ftruncate 130
-#define SYS_argc 172
-#define SYS_argnlen 173
-#define SYS_argn 174
-#define SYS_utime 201 /* not really a system call */
-#define SYS_wait 202 /* nor is this */
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH/committed 5/5] sim: moxie: switch syscalls to common nltvals
2021-04-19 3:20 [PATCH/committed 1/5] sim: iq2000: switch syscalls to common nltvals Mike Frysinger
` (2 preceding siblings ...)
2021-04-19 3:20 ` [PATCH/committed 4/5] sim: sh: " Mike Frysinger
@ 2021-04-19 3:20 ` Mike Frysinger
3 siblings, 0 replies; 5+ messages in thread
From: Mike Frysinger @ 2021-04-19 3:20 UTC (permalink / raw)
To: gdb-patches
Rather than hand duplicate the syscall constants, switch to the
common nltvals framework. I made sure the constants have the
same values before & after too :).
---
sim/common/ChangeLog | 5 +++++
sim/common/gennltvals.py | 1 +
sim/common/nltvals.def | 31 +++++++++++++++++++++++++++++++
sim/moxie/ChangeLog | 6 ++++++
sim/moxie/Makefile.in | 3 +++
sim/moxie/interp.c | 11 ++++++-----
6 files changed, 52 insertions(+), 5 deletions(-)
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index 20a425731f52..d62a40d5db89 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 moxie.
+ * nltvals.def: Regenerate.
+
2021-04-18 Mike Frysinger <vapier@gentoo.org>
* gennltvals.py (TARGET_DIRS, TARGETS): Add sh.
diff --git a/sim/common/gennltvals.py b/sim/common/gennltvals.py
index 5831607a17c7..cf23c3926994 100755
--- a/sim/common/gennltvals.py
+++ b/sim/common/gennltvals.py
@@ -68,6 +68,7 @@ TARGETS = {
'mcore',
'mn10200',
'mn10300',
+ 'moxie',
'msp430',
'pru',
'riscv',
diff --git a/sim/common/nltvals.def b/sim/common/nltvals.def
index 3b890af0639f..27f1b0d43b26 100644
--- a/sim/common/nltvals.def
+++ b/sim/common/nltvals.def
@@ -546,6 +546,37 @@
/* end mn10300 sys target macros */
#endif
#endif
+#ifdef NL_TARGET_moxie
+#ifdef sys_defs
+/* from syscall.h */
+/* begin moxie 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 moxie sys target macros */
+#endif
+#endif
#ifdef NL_TARGET_msp430
#ifdef sys_defs
/* from syscall.h */
diff --git a/sim/moxie/ChangeLog b/sim/moxie/ChangeLog
index b6e91a24bda4..9621907dabb5 100644
--- a/sim/moxie/ChangeLog
+++ b/sim/moxie/ChangeLog
@@ -1,3 +1,9 @@
+2021-04-18 Mike Frysinger <vapier@gentoo.org>
+
+ * Makefile.in (NL_TARGET): Define.
+ * interp.c: Include targ-vals.h.
+ (sim_engine_run): Change numeric literals to SYS_ constants.
+
2021-04-18 Mike Frysinger <vapier@gentoo.org>
* configure: Regenerate.
diff --git a/sim/moxie/Makefile.in b/sim/moxie/Makefile.in
index bd58074491fc..3d9618846cc3 100644
--- a/sim/moxie/Makefile.in
+++ b/sim/moxie/Makefile.in
@@ -15,6 +15,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_moxie
+
## COMMON_PRE_CONFIG_FRAG
DTC = @DTC@
diff --git a/sim/moxie/interp.c b/sim/moxie/interp.c
index 5da13f7808cb..417ff9ea5503 100644
--- a/sim/moxie/interp.c
+++ b/sim/moxie/interp.c
@@ -33,6 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "sim-base.h"
#include "sim-options.h"
#include "sim-io.h"
+#include "targ-vals.h"
typedef int word;
typedef unsigned int uword;
@@ -932,13 +933,13 @@ sim_engine_run (SIM_DESC sd,
cpu.asregs.sregs[3] = inum;
switch (inum)
{
- case 0x1: /* SYS_exit */
+ case TARGET_SYS_exit:
{
sim_engine_halt (sd, scpu, NULL, pc, sim_exited,
cpu.asregs.regs[2]);
break;
}
- case 0x2: /* SYS_open */
+ case TARGET_SYS_open:
{
char fname[1024];
int mode = (int) convert_target_flags ((unsigned) cpu.asregs.regs[3]);
@@ -951,7 +952,7 @@ sim_engine_run (SIM_DESC sd,
cpu.asregs.regs[2] = fd;
break;
}
- case 0x4: /* SYS_read */
+ case TARGET_SYS_read:
{
int fd = cpu.asregs.regs[2];
unsigned len = (unsigned) cpu.asregs.regs[4];
@@ -962,7 +963,7 @@ sim_engine_run (SIM_DESC sd,
free (buf);
break;
}
- case 0x5: /* SYS_write */
+ case TARGET_SYS_write:
{
char *str;
/* String length is at 0x12($fp) */
@@ -975,7 +976,7 @@ sim_engine_run (SIM_DESC sd,
cpu.asregs.regs[2] = count;
break;
}
- case 0x7: /* SYS_unlink */
+ case TARGET_SYS_unlink:
{
char fname[1024];
int fd;
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-04-19 3:21 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-19 3:20 [PATCH/committed 1/5] sim: iq2000: switch syscalls to common nltvals Mike Frysinger
2021-04-19 3:20 ` [PATCH/committed 2/5] sim: m32c: " Mike Frysinger
2021-04-19 3:20 ` [PATCH/committed 3/5] sim: rx: " Mike Frysinger
2021-04-19 3:20 ` [PATCH/committed 4/5] sim: sh: " Mike Frysinger
2021-04-19 3:20 ` [PATCH/committed 5/5] sim: moxie: " Mike 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).