diff options
author | Yuriy Kolerov <ykolerov@synopsys.com> | 2024-08-20 15:10:43 +0300 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2024-08-20 18:24:15 -0400 |
commit | b99f27c25f5b68faf37c11b98395d29018a45c33 (patch) | |
tree | d3aac09b4bf92f293f0f53445f11b72d3952d92e | |
parent | 03f4e346f42dad88cf1742c277b1832ad217133b (diff) | |
download | newlib-b99f27c25f5b68faf37c11b98395d29018a45c33.zip newlib-b99f27c25f5b68faf37c11b98395d29018a45c33.tar.gz newlib-b99f27c25f5b68faf37c11b98395d29018a45c33.tar.bz2 |
arc: libgloss: Prepare for porting to ARCv3
There are 3 families of Synopsys DeisgnWare ARC processors:
ARCompact/ARCv1 (32-bit), ARCv2 (32-bit) and ARCv3 (32-bit
and 64-bit targets). Upstream Newlib supports only ARCv1/2.
This commit prepares ARCv1/2 libgloss port to be reused by
ARCv3 port (except crt* files). Note that __ARC64__ macro
stands for all ARCv3 targets.
Signed-off-by: Yuriy Kolerov <ykolerov@synopsys.com>
-rw-r--r-- | libgloss/arc/hl-stub.c | 14 | ||||
-rw-r--r-- | libgloss/arc/hl/hl_gw.c | 9 | ||||
-rw-r--r-- | libgloss/arc/hl/hl_toolchain.h | 10 | ||||
-rw-r--r-- | libgloss/arc/nsim-syscalls.c | 5 |
4 files changed, 38 insertions, 0 deletions
diff --git a/libgloss/arc/hl-stub.c b/libgloss/arc/hl-stub.c index 7f5b9fa..c4d6ee6 100644 --- a/libgloss/arc/hl-stub.c +++ b/libgloss/arc/hl-stub.c @@ -15,6 +15,7 @@ * */ +#include <string.h> #include <errno.h> #include <unistd.h> #include <sys/times.h> @@ -44,6 +45,19 @@ _getpid (void) return __MYPID; } +/* We do not have 64-bit compatible hostlink fstat. */ +#if defined (__ARC64__) +int +_fstat (int fd, struct stat *st) +{ + memset (st, 0, sizeof (*st)); + st->st_mode = S_IFCHR; + st->st_blksize = 1024; + + return 0; +} +#endif + /* hostlink backend has only fstat(), so use fstat() in stat(). */ int diff --git a/libgloss/arc/hl/hl_gw.c b/libgloss/arc/hl/hl_gw.c index f576f09..4a8f878 100644 --- a/libgloss/arc/hl/hl_gw.c +++ b/libgloss/arc/hl/hl_gw.c @@ -15,6 +15,7 @@ * */ +#include <stdint.h> #include "hl_gw.h" #define HL_VERSION 1 @@ -134,7 +135,15 @@ _hl_send (volatile __uncached void *p) _hl_pkt_init (pkt_hdr, _hl_payload_used (p)); +#if defined (__ARC64__) + /* + * Here we pass only low 4 bytes of the packet address (pkt_hdr). + * The high part of the address is obtained from __HOSTLINK__ address. + */ + hdr->buf_addr = (uintptr_t) pkt_hdr & 0xFFFFFFFF; +#else hdr->buf_addr = (uint32_t) pkt_hdr; +#endif hdr->payload_size = _hl_payload_size (); hdr->host2target_addr = HL_NOADDRESS; hdr->version = HL_VERSION; diff --git a/libgloss/arc/hl/hl_toolchain.h b/libgloss/arc/hl/hl_toolchain.h index bf884bf..9460617 100644 --- a/libgloss/arc/hl/hl_toolchain.h +++ b/libgloss/arc/hl/hl_toolchain.h @@ -19,7 +19,12 @@ #define _HL_TOOLCHAIN_H #ifndef __uncached +#if defined (__ARC64__) + /* TODO: Uncached attribute is not implemented for ARCv3 yet. */ + #define __uncached +#else #define __uncached __attribute__((uncached)) +#endif #endif /* __uncached */ #ifndef __aligned @@ -43,7 +48,12 @@ #endif /* __noreturn */ #ifndef __longcall +#if defined (__ARC64__) + /* TODO: Long call attribute is not implemented for ARCv3 yet. */ + #define __longcall +#else #define __longcall __attribute__((long_call)) +#endif #endif /* __longcall */ #define HL_MAX_DCACHE_LINE 256 diff --git a/libgloss/arc/nsim-syscalls.c b/libgloss/arc/nsim-syscalls.c index 807f95c..0a99ad5 100644 --- a/libgloss/arc/nsim-syscalls.c +++ b/libgloss/arc/nsim-syscalls.c @@ -100,7 +100,12 @@ _open (const char * pathname, int flags, int mode) } /* Should be provided by crt0.S. */ +#if defined (__ARC64__) +/* TODO: long_call is not implemented yet in GCC. Fix this when implemented. */ +extern void __attribute__((noreturn)) _exit_halt (int ret); +#else extern void __attribute__((noreturn, long_call)) _exit_halt (int ret); +#endif void __attribute__((noreturn)) |