aboutsummaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-04-18 22:24:37 -0400
committerMike Frysinger <vapier@gentoo.org>2021-04-18 23:00:58 -0400
commit2390d779430a64350be827929a0ebf73155f4fd7 (patch)
tree377bebedd19ef230048f6f326ec1438fd90e57ce /sim
parent37e9f18266e768ad93243fd34f9046c260b3096b (diff)
downloadfsf-binutils-gdb-2390d779430a64350be827929a0ebf73155f4fd7.zip
fsf-binutils-gdb-2390d779430a64350be827929a0ebf73155f4fd7.tar.gz
fsf-binutils-gdb-2390d779430a64350be827929a0ebf73155f4fd7.tar.bz2
sim: iq2000: 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 :).
Diffstat (limited to 'sim')
-rw-r--r--sim/common/ChangeLog5
-rwxr-xr-xsim/common/gennltvals.py1
-rw-r--r--sim/common/nltvals.def32
-rw-r--r--sim/iq2000/ChangeLog7
-rw-r--r--sim/iq2000/Makefile.in3
-rw-r--r--sim/iq2000/iq2000.c38
6 files changed, 56 insertions, 30 deletions
diff --git a/sim/common/ChangeLog b/sim/common/ChangeLog
index b1af152..2d5934a 100644
--- a/sim/common/ChangeLog
+++ b/sim/common/ChangeLog
@@ -1,5 +1,10 @@
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.
2021-04-15 John Baldwin <jhb@FreeBSD.org>
diff --git a/sim/common/gennltvals.py b/sim/common/gennltvals.py
index 23b2187..a246977 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 6f93316..4aaeff8 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 c6fc38c..cb67450 100644
--- a/sim/iq2000/ChangeLog
+++ b/sim/iq2000/ChangeLog
@@ -1,5 +1,12 @@
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.
2021-04-12 Mike Frysinger <vapier@gentoo.org>
diff --git a/sim/iq2000/Makefile.in b/sim/iq2000/Makefile.in
index f3ab635..baf49dd 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 e03c479..66d7b47 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;