sim: v850: switch to new target-newlib-syscall

Use the new target-newlib-syscall module.  This is needed to merge all
the architectures into a single build, and v850 has a custom syscall
table for its newlib/libgloss port.

This allows cleaning up the syscall ifdef logic.  We know these will
always exist now.
This commit is contained in:
Mike Frysinger
2021-11-28 00:13:59 -05:00
parent e38330f8b0
commit 96b1eb7e17
3 changed files with 26 additions and 67 deletions

View File

@ -31,6 +31,4 @@ SIM_EXTRA_DEPS = v850_sim.h sim-main.h
SIM_EXTRA_CFLAGS = \ SIM_EXTRA_CFLAGS = \
-DDEBUG -DDEBUG
NL_TARGET = -DNL_TARGET_v850
## COMMON_POST_CONFIG_FRAG ## COMMON_POST_CONFIG_FRAG

View File

@ -12,6 +12,8 @@
#include "bfd.h" #include "bfd.h"
#include "target-newlib-syscall.h"
static const char * get_insn_name (sim_cpu *, int); static const char * get_insn_name (sim_cpu *, int);
/* For compatibility. */ /* For compatibility. */
@ -199,6 +201,7 @@ sim_open (SIM_OPEN_KIND kind,
/* Set default options before parsing user options. */ /* Set default options before parsing user options. */
current_target_byte_order = BFD_ENDIAN_LITTLE; current_target_byte_order = BFD_ENDIAN_LITTLE;
cb->syscall_map = cb_v850_syscall_map;
/* The cpu data is kept in a separately allocated chunk of memory. */ /* The cpu data is kept in a separately allocated chunk of memory. */
if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK) if (sim_cpu_alloc_all (sd, 1) != SIM_RC_OK)

View File

@ -18,8 +18,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "targ-vals.h"
#include "libiberty.h" #include "libiberty.h"
#include <errno.h> #include <errno.h>
@ -29,6 +27,8 @@
#include <sys/time.h> #include <sys/time.h>
#endif #endif
#include "target-newlib-syscall.h"
/* This is an array of the bit positions of registers r20 .. r31 in /* This is an array of the bit positions of registers r20 .. r31 in
that order in a prepare/dispose instruction. */ that order in a prepare/dispose instruction. */
int type1_regs[12] = { 27, 26, 25, 24, 31, 30, 29, 28, 23, 22, 0, 21 }; int type1_regs[12] = { 27, 26, 25, 24, 31, 30, 29, 28, 23, 22, 0, 21 };
@ -1626,17 +1626,14 @@ OP_10007E0 (void)
{ {
#ifdef HAVE_FORK #ifdef HAVE_FORK
#ifdef TARGET_SYS_fork case TARGET_NEWLIB_V850_SYS_fork:
case TARGET_SYS_fork:
RETVAL = fork (); RETVAL = fork ();
RETERR = errno; RETERR = errno;
break; break;
#endif #endif
#endif
#ifdef HAVE_EXECVE #ifdef HAVE_EXECVE
#ifdef TARGET_SYS_execv case TARGET_NEWLIB_V850_SYS_execve:
case TARGET_SYS_execve:
{ {
char *path = fetch_str (simulator, PARM1); char *path = fetch_str (simulator, PARM1);
char **argv = fetch_argv (simulator, PARM2); char **argv = fetch_argv (simulator, PARM2);
@ -1649,11 +1646,9 @@ OP_10007E0 (void)
break; break;
} }
#endif #endif
#endif
#if HAVE_EXECV #if HAVE_EXECV
#ifdef TARGET_SYS_execv case TARGET_NEWLIB_V850_SYS_execv:
case TARGET_SYS_execv:
{ {
char *path = fetch_str (simulator, PARM1); char *path = fetch_str (simulator, PARM1);
char **argv = fetch_argv (simulator, PARM2); char **argv = fetch_argv (simulator, PARM2);
@ -1664,11 +1659,9 @@ OP_10007E0 (void)
break; break;
} }
#endif #endif
#endif
#if 0 #if 0
#ifdef TARGET_SYS_pipe case TARGET_NEWLIB_V850_SYS_pipe:
case TARGET_SYS_pipe:
{ {
reg_t buf; reg_t buf;
int host_fd[2]; int host_fd[2];
@ -1682,11 +1675,9 @@ OP_10007E0 (void)
} }
break; break;
#endif #endif
#endif
#if 0 #if 0
#ifdef TARGET_SYS_wait case TARGET_NEWLIB_V850_SYS_wait:
case TARGET_SYS_wait:
{ {
int status; int status;
@ -1696,10 +1687,8 @@ OP_10007E0 (void)
} }
break; break;
#endif #endif
#endif
#ifdef TARGET_SYS_read case TARGET_NEWLIB_V850_SYS_read:
case TARGET_SYS_read:
{ {
char *buf = zalloc (PARM3); char *buf = zalloc (PARM3);
RETVAL = sim_io_read (simulator, PARM1, buf, PARM3); RETVAL = sim_io_read (simulator, PARM1, buf, PARM3);
@ -1709,10 +1698,8 @@ OP_10007E0 (void)
RETERR = sim_io_get_errno (simulator); RETERR = sim_io_get_errno (simulator);
break; break;
} }
#endif
#ifdef TARGET_SYS_write case TARGET_NEWLIB_V850_SYS_write:
case TARGET_SYS_write:
{ {
char *buf = zalloc (PARM3); char *buf = zalloc (PARM3);
sim_read (simulator, PARM2, (unsigned char *) buf, PARM3); sim_read (simulator, PARM2, (unsigned char *) buf, PARM3);
@ -1725,26 +1712,20 @@ OP_10007E0 (void)
RETERR = sim_io_get_errno (simulator); RETERR = sim_io_get_errno (simulator);
break; break;
} }
#endif
#ifdef TARGET_SYS_lseek case TARGET_NEWLIB_V850_SYS_lseek:
case TARGET_SYS_lseek:
RETVAL = sim_io_lseek (simulator, PARM1, PARM2, PARM3); RETVAL = sim_io_lseek (simulator, PARM1, PARM2, PARM3);
if ((int) RETVAL < 0) if ((int) RETVAL < 0)
RETERR = sim_io_get_errno (simulator); RETERR = sim_io_get_errno (simulator);
break; break;
#endif
#ifdef TARGET_SYS_close case TARGET_NEWLIB_V850_SYS_close:
case TARGET_SYS_close:
RETVAL = sim_io_close (simulator, PARM1); RETVAL = sim_io_close (simulator, PARM1);
if ((int) RETVAL < 0) if ((int) RETVAL < 0)
RETERR = sim_io_get_errno (simulator); RETERR = sim_io_get_errno (simulator);
break; break;
#endif
#ifdef TARGET_SYS_open case TARGET_NEWLIB_V850_SYS_open:
case TARGET_SYS_open:
{ {
char *buf = fetch_str (simulator, PARM1); char *buf = fetch_str (simulator, PARM1);
RETVAL = sim_io_open (simulator, buf, PARM2); RETVAL = sim_io_open (simulator, buf, PARM2);
@ -1753,10 +1734,8 @@ OP_10007E0 (void)
RETERR = sim_io_get_errno (simulator); RETERR = sim_io_get_errno (simulator);
break; break;
} }
#endif
#ifdef TARGET_SYS_exit case TARGET_NEWLIB_V850_SYS_exit:
case TARGET_SYS_exit:
if ((PARM1 & 0xffff0000) == 0xdead0000 && (PARM1 & 0xffff) != 0) if ((PARM1 & 0xffff0000) == 0xdead0000 && (PARM1 & 0xffff) != 0)
/* get signal encoded by kill */ /* get signal encoded by kill */
sim_engine_halt (simulator, STATE_CPU (simulator, 0), NULL, PC, sim_engine_halt (simulator, STATE_CPU (simulator, 0), NULL, PC,
@ -1770,10 +1749,8 @@ OP_10007E0 (void)
sim_engine_halt (simulator, STATE_CPU (simulator, 0), NULL, PC, sim_engine_halt (simulator, STATE_CPU (simulator, 0), NULL, PC,
sim_exited, PARM1); sim_exited, PARM1);
break; break;
#endif
#ifdef TARGET_SYS_stat case TARGET_NEWLIB_V850_SYS_stat: /* added at hmsi */
case TARGET_SYS_stat: /* added at hmsi */
/* stat system call */ /* stat system call */
{ {
struct stat host_stat; struct stat host_stat;
@ -1802,10 +1779,8 @@ OP_10007E0 (void)
RETERR = sim_io_get_errno (simulator); RETERR = sim_io_get_errno (simulator);
} }
break; break;
#endif
#ifdef TARGET_SYS_fstat case TARGET_NEWLIB_V850_SYS_fstat:
case TARGET_SYS_fstat:
/* fstat system call */ /* fstat system call */
{ {
struct stat host_stat; struct stat host_stat;
@ -1832,10 +1807,8 @@ OP_10007E0 (void)
RETERR = sim_io_get_errno (simulator); RETERR = sim_io_get_errno (simulator);
} }
break; break;
#endif
#ifdef TARGET_SYS_rename case TARGET_NEWLIB_V850_SYS_rename:
case TARGET_SYS_rename:
{ {
char *oldpath = fetch_str (simulator, PARM1); char *oldpath = fetch_str (simulator, PARM1);
char *newpath = fetch_str (simulator, PARM2); char *newpath = fetch_str (simulator, PARM2);
@ -1846,10 +1819,8 @@ OP_10007E0 (void)
RETERR = sim_io_get_errno (simulator); RETERR = sim_io_get_errno (simulator);
} }
break; break;
#endif
#ifdef TARGET_SYS_unlink case TARGET_NEWLIB_V850_SYS_unlink:
case TARGET_SYS_unlink:
{ {
char *path = fetch_str (simulator, PARM1); char *path = fetch_str (simulator, PARM1);
RETVAL = sim_io_unlink (simulator, path); RETVAL = sim_io_unlink (simulator, path);
@ -1858,10 +1829,8 @@ OP_10007E0 (void)
RETERR = sim_io_get_errno (simulator); RETERR = sim_io_get_errno (simulator);
} }
break; break;
#endif
#ifdef TARGET_SYS_chown case TARGET_NEWLIB_V850_SYS_chown:
case TARGET_SYS_chown:
{ {
char *path = fetch_str (simulator, PARM1); char *path = fetch_str (simulator, PARM1);
RETVAL = chown (path, PARM2, PARM3); RETVAL = chown (path, PARM2, PARM3);
@ -1869,11 +1838,9 @@ OP_10007E0 (void)
RETERR = errno; RETERR = errno;
} }
break; break;
#endif
#if HAVE_CHMOD #if HAVE_CHMOD
#ifdef TARGET_SYS_chmod case TARGET_NEWLIB_V850_SYS_chmod:
case TARGET_SYS_chmod:
{ {
char *path = fetch_str (simulator, PARM1); char *path = fetch_str (simulator, PARM1);
RETVAL = chmod (path, PARM2); RETVAL = chmod (path, PARM2);
@ -1882,11 +1849,9 @@ OP_10007E0 (void)
} }
break; break;
#endif #endif
#endif
#ifdef TARGET_SYS_time
#if HAVE_TIME #if HAVE_TIME
case TARGET_SYS_time: case TARGET_NEWLIB_V850_SYS_time:
{ {
time_t now; time_t now;
RETVAL = time (&now); RETVAL = time (&now);
@ -1895,11 +1860,9 @@ OP_10007E0 (void)
} }
break; break;
#endif #endif
#endif
#if !defined(__GO32__) && !defined(_WIN32) #if !defined(__GO32__) && !defined(_WIN32)
#ifdef TARGET_SYS_times case TARGET_NEWLIB_V850_SYS_times:
case TARGET_SYS_times:
{ {
struct tms tms; struct tms tms;
RETVAL = times (&tms); RETVAL = times (&tms);
@ -1911,11 +1874,9 @@ OP_10007E0 (void)
break; break;
} }
#endif #endif
#endif
#ifdef TARGET_SYS_gettimeofday
#if !defined(__GO32__) && !defined(_WIN32) #if !defined(__GO32__) && !defined(_WIN32)
case TARGET_SYS_gettimeofday: case TARGET_NEWLIB_V850_SYS_gettimeofday:
{ {
struct timeval t; struct timeval t;
struct timezone tz; struct timezone tz;
@ -1928,11 +1889,9 @@ OP_10007E0 (void)
break; break;
} }
#endif #endif
#endif
#ifdef TARGET_SYS_utime
#if HAVE_UTIME #if HAVE_UTIME
case TARGET_SYS_utime: case TARGET_NEWLIB_V850_SYS_utime:
{ {
/* Cast the second argument to void *, to avoid type mismatch /* Cast the second argument to void *, to avoid type mismatch
if a prototype is present. */ if a prototype is present. */
@ -1940,7 +1899,6 @@ OP_10007E0 (void)
/* RETVAL = utime (path, (void *) MEMPTR (PARM2)); */ /* RETVAL = utime (path, (void *) MEMPTR (PARM2)); */
} }
break; break;
#endif
#endif #endif
default: default: