summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYann Sionneau <ysionneau@kalray.eu>2020-10-02 16:24:55 +0200
committerWaldemar Brodkorb <wbx@openadk.org>2020-10-02 19:10:36 +0200
commit672a303852353ba9299f6f50190fca8b3abe4c1d (patch)
treef204ea8dc0b5a3e4b2bd4251b8daf5f0783ae260
parent4acf6f072cbc255b0b0d6cfd598a100f95d84f2a (diff)
kvx: add support for kvx arch to uClibc-ng
This commit adds support for Kalray VLIW family (kvx) Kalray kv3 core is embedded in Kalray Coolidge SoC. This core which is the third of the KV family has the following features: 32/64 bits execution mode 6-issue VLIW architecture 64 x 64bits general purpose registers SIMD instructions little-endian In order to build a usable toolchain, build scripts are provided at the following address: https://github.com/kalray/build-scripts. Kalray uses FOSS which is available at https://github.com/kalray This includes Linux kernel, uClibc-ng, gcc, binutils, etc. Signed-off-by: Clément Léger <cleger@kalray.eu> Signed-off-by: Guillaume Thouvenin <gthouvenin@kalray.eu> Signed-off-by: Laurent Thevenoux <lthevenoux@kalray.eu> Signed-off-by: Marc Poulhies <mpoulhies@kalray.eu> Signed-off-by: Marius Gligor <mgligor@kalray.eu> Signed-off-by: Yann Sionneau <ysionneau@kalray.eu>
-rw-r--r--MAINTAINERS4
-rw-r--r--README2
-rw-r--r--Rules.mak6
-rw-r--r--extra/Configs/Config.in8
-rw-r--r--extra/Configs/Config.kvx18
-rw-r--r--extra/Configs/defconfigs/kvx/defconfig1
-rw-r--r--include/elf.h87
-rw-r--r--ldso/ldso/kvx/dl-startup.h104
-rw-r--r--ldso/ldso/kvx/dl-syscalls.h1
-rw-r--r--ldso/ldso/kvx/dl-sysdep.h99
-rw-r--r--ldso/ldso/kvx/dl-tlsdesc.S33
-rw-r--r--ldso/ldso/kvx/elfinterp.c302
-rw-r--r--ldso/ldso/kvx/resolve.S17
-rw-r--r--libc/string/kvx/Makefile13
-rw-r--r--libc/string/kvx/memcpy.S221
-rw-r--r--libc/string/kvx/memset.S146
-rw-r--r--libc/sysdeps/linux/kvx/Makefile13
-rw-r--r--libc/sysdeps/linux/kvx/Makefile.arch10
-rw-r--r--libc/sysdeps/linux/kvx/__longjmp.S53
-rw-r--r--libc/sysdeps/linux/kvx/__syscall_error.c19
-rw-r--r--libc/sysdeps/linux/kvx/bits/atomic.h141
-rw-r--r--libc/sysdeps/linux/kvx/bits/endian.h13
-rw-r--r--libc/sysdeps/linux/kvx/bits/fcntl.h226
-rw-r--r--libc/sysdeps/linux/kvx/bits/fenv.h106
-rw-r--r--libc/sysdeps/linux/kvx/bits/kernel_types.h42
-rw-r--r--libc/sysdeps/linux/kvx/bits/posix_types.h14
-rw-r--r--libc/sysdeps/linux/kvx/bits/sem.h84
-rw-r--r--libc/sysdeps/linux/kvx/bits/setjmp.h46
-rw-r--r--libc/sysdeps/linux/kvx/bits/stackinfo.h29
-rw-r--r--libc/sysdeps/linux/kvx/bits/statfs.h64
-rw-r--r--libc/sysdeps/linux/kvx/bits/syscalls.h80
-rw-r--r--libc/sysdeps/linux/kvx/bits/uClibc_arch_features.h41
-rw-r--r--libc/sysdeps/linux/kvx/bits/wordsize.h9
-rw-r--r--libc/sysdeps/linux/kvx/bsd-_setjmp.S18
-rw-r--r--libc/sysdeps/linux/kvx/bsd-setjmp.S17
-rw-r--r--libc/sysdeps/linux/kvx/cachectl.c15
-rw-r--r--libc/sysdeps/linux/kvx/clone.S100
-rw-r--r--libc/sysdeps/linux/kvx/crt1.S83
-rw-r--r--libc/sysdeps/linux/kvx/crti.S31
-rw-r--r--libc/sysdeps/linux/kvx/crtn.S33
-rw-r--r--libc/sysdeps/linux/kvx/jmpbuf-offsets.h50
-rw-r--r--libc/sysdeps/linux/kvx/jmpbuf-unwind.h30
-rw-r--r--libc/sysdeps/linux/kvx/setjmp.S59
-rw-r--r--libc/sysdeps/linux/kvx/sys/cachectl.h21
-rw-r--r--libc/sysdeps/linux/kvx/sys/procfs.h101
-rw-r--r--libc/sysdeps/linux/kvx/sys/ucontext.h29
-rw-r--r--libc/sysdeps/linux/kvx/sys/user.h27
-rw-r--r--libc/sysdeps/linux/kvx/sysdep.h49
-rw-r--r--libc/sysdeps/linux/kvx/vfork.S47
-rw-r--r--libm/kvx/Makefile.arch22
-rw-r--r--libm/kvx/feclearexcept.c20
-rw-r--r--libm/kvx/fegetenv.c21
-rw-r--r--libm/kvx/fegetexceptflag.c24
-rw-r--r--libm/kvx/fegetround.c16
-rw-r--r--libm/kvx/feholdexcept.c26
-rw-r--r--libm/kvx/feraiseexcept.c24
-rw-r--r--libm/kvx/fesetenv.c23
-rw-r--r--libm/kvx/fesetexceptflag.c24
-rw-r--r--libm/kvx/fesetround.c21
-rw-r--r--libm/kvx/fetestexcept.c21
-rw-r--r--libm/kvx/feupdateenv.c24
-rw-r--r--libpthread/nptl/sysdeps/kvx/Makefile.arch9
-rw-r--r--libpthread/nptl/sysdeps/kvx/dl-tls.h47
-rw-r--r--libpthread/nptl/sysdeps/kvx/libc-tls.c26
-rw-r--r--libpthread/nptl/sysdeps/kvx/pthread_spin_lock.c60
-rw-r--r--libpthread/nptl/sysdeps/kvx/pthread_spin_trylock.c26
-rw-r--r--libpthread/nptl/sysdeps/kvx/pthreaddef.h26
-rw-r--r--libpthread/nptl/sysdeps/kvx/tcb-offsets.sym6
-rw-r--r--libpthread/nptl/sysdeps/kvx/tls.h160
-rw-r--r--libpthread/nptl/sysdeps/kvx/unwind-forcedunwind.c165
-rw-r--r--libpthread/nptl/sysdeps/pthread/Makefile.in2
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/kvx/Makefile13
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/kvx/Makefile.arch14
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/kvx/bits/pthreadtypes.h166
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/kvx/bits/semaphore.h30
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/kvx/createthread.c14
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/kvx/fork.c11
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/kvx/pthread_once.c77
-rw-r--r--libpthread/nptl/sysdeps/unix/sysv/linux/kvx/sysdep-cancel.h43
-rw-r--r--utils/ldd.c5
80 files changed, 3925 insertions, 3 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index 650d9b5bb..039b16895 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -23,3 +23,7 @@ Stafford Horne <shorne@gmail.com>
Xtensa:
Max Filippov <jcmvbkbc@gmail.com>
+
+KVX:
+Clément Léger <cleger@kalray.eu>
+Yann Sionneau <ysionneau@kalray.eu>
diff --git a/README b/README
index be53d0217..cb3a9ff57 100644
--- a/README
+++ b/README
@@ -12,7 +12,7 @@ Porting applications from glibc to uClibc-ng typically involves just
recompiling the source code. uClibc-ng even supports shared libraries and
threading. It currently runs on standard Linux and MMU-less (also known as
µClinux) systems with support for Alpha, ARC, ARM, Blackfin, CRIS, FR-V, HPPA,
-IA64, LM32, M68K/Coldfire, Metag, Microblaze, MIPS, MIPS64, NDS32, NIOS2,
+IA64, KVX, LM32, M68K/Coldfire, Metag, Microblaze, MIPS, MIPS64, NDS32, NIOS2,
OpenRisc, PowerPC, SuperH, Sparc, Tile, x86, x86_64 and Xtensa processors.
If you are building an embedded Linux system and you find that glibc is eating
diff --git a/Rules.mak b/Rules.mak
index 55e88d462..e9aebeaab 100644
--- a/Rules.mak
+++ b/Rules.mak
@@ -144,7 +144,7 @@ SHARED_LIBNAME := $(LIBC).so.$(ABI_VERSION)
UCLIBC_LDSO_NAME := ld-uClibc
ARCH_NATIVE_BIT := 32
-ifneq ($(findstring $(TARGET_ARCH) , hppa64 ia64 powerpc64 s390x sparc64 x86_64 ),)
+ifneq ($(findstring $(TARGET_ARCH) , hppa64 ia64 powerpc64 s390x sparc64 x86_64 kvx ),)
UCLIBC_LDSO_NAME := ld64-uClibc
ARCH_NATIVE_BIT := 64
else
@@ -465,6 +465,10 @@ ifeq ($(TARGET_ARCH),csky)
CPU_CFLAGS-$(ARCH_BIG_ENDIAN) += -mbig-endian
endif
+ifeq ($(TARGET_ARCH),kvx)
+ CPU_CFLAGS-$(CONFIG_KVX) += -march=kvx
+endif
+
ifeq ($(TARGET_ARCH),m68k)
# -fPIC is only supported for 68020 and above. It is not supported
# for 68000, 68010, or Coldfire.
diff --git a/extra/Configs/Config.in b/extra/Configs/Config.in
index fff434b40..7dca9e305 100644
--- a/extra/Configs/Config.in
+++ b/extra/Configs/Config.in
@@ -28,6 +28,7 @@ choice
default TARGET_hppa if DESIRED_TARGET_ARCH = "hppa"
default TARGET_i386 if DESIRED_TARGET_ARCH = "i386"
default TARGET_ia64 if DESIRED_TARGET_ARCH = "ia64"
+ default TARGET_kvx if DESIRED_TARGET_ARCH = "kvx"
default TARGET_lm32 if DESIRED_TARGET_ARCH = "lm32"
default TARGET_m68k if DESIRED_TARGET_ARCH = "m68k"
default TARGET_metag if DESIRED_TARGET_ARCH = "metag"
@@ -91,6 +92,9 @@ config TARGET_i386
config TARGET_ia64
bool "ia64"
+config TARGET_kvx
+ bool "kvx"
+
config TARGET_lm32
bool "lm32"
@@ -192,6 +196,10 @@ if TARGET_ia64
source "extra/Configs/Config.ia64"
endif
+if TARGET_kvx
+source "extra/Configs/Config.kvx"
+endif
+
if TARGET_lm32
source "extra/Configs/Config.lm32"
endif
diff --git a/extra/Configs/Config.kvx b/extra/Configs/Config.kvx
new file mode 100644
index 000000000..398ffceaa
--- /dev/null
+++ b/extra/Configs/Config.kvx
@@ -0,0 +1,18 @@
+#
+# For a description of the syntax of this configuration file,
+# see extra/config/Kconfig-language.txt
+#
+
+config TARGET_ARCH
+ string
+ default "kvx"
+
+config FORCE_OPTIONS_FOR_ARCH
+ bool
+ default y
+ select ARCH_LITTLE_ENDIAN
+ select ARCH_HAS_MMU
+ select UCLIBC_HAS_FPU
+ select UCLIBC_HAS_FENV
+ select UCLIBC_HAS_WCHAR
+ select DO_C99_MATH
diff --git a/extra/Configs/defconfigs/kvx/defconfig b/extra/Configs/defconfigs/kvx/defconfig
new file mode 100644
index 000000000..c80e6ce8e
--- /dev/null
+++ b/extra/Configs/defconfigs/kvx/defconfig
@@ -0,0 +1 @@
+TARGET_kvx=y
diff --git a/include/elf.h b/include/elf.h
index d1be3bc1b..7d66d70a4 100644
--- a/include/elf.h
+++ b/include/elf.h
@@ -273,9 +273,10 @@ typedef struct
#define EM_ARCV2 195 /* ARCv2 Cores */
#define EM_RISCV 243 /* RISC-V */
#define EM_CSKY 252 /* C-SKY Cores */
+#define EM_KVX 256 /* Kalray VLIW core of the MPPA processor family */
/* NEXT FREE NUMBER: Increment this after adding your official arch number */
-#define EM_NUM 253
+#define EM_NUM 257
/* If it is necessary to assign new unofficial EM_* values, please pick large
random numbers (0x8523, 0xa7f2, etc.) to minimize the chances of collision
@@ -1253,6 +1254,90 @@ typedef struct
#define ELF64_M_SIZE(info) ELF32_M_SIZE (info)
#define ELF64_M_INFO(sym, size) ELF32_M_INFO (sym, size)
+/* KVX relocs */
+#define R_KVX_NONE 0
+#define R_KVX_16 1
+#define R_KVX_32 2
+#define R_KVX_64 3
+#define R_KVX_S16_PCREL 4
+#define R_KVX_PCREL17 5
+#define R_KVX_PCREL27 6
+#define R_KVX_32_PCREL 7
+#define R_KVX_S37_PCREL_LO10 8
+#define R_KVX_S37_PCREL_UP27 9
+#define R_KVX_S43_PCREL_LO10 10
+#define R_KVX_S43_PCREL_UP27 11
+#define R_KVX_S43_PCREL_EX6 12
+#define R_KVX_S64_PCREL_LO10 13
+#define R_KVX_S64_PCREL_UP27 14
+#define R_KVX_S64_PCREL_EX27 15
+#define R_KVX_64_PCREL 16
+#define R_KVX_S16 17
+#define R_KVX_S32_LO5 18
+#define R_KVX_S32_UP27 19
+#define R_KVX_S37_LO10 20
+#define R_KVX_S37_UP27 21
+#define R_KVX_S37_GOTOFF_LO10 22
+#define R_KVX_S37_GOTOFF_UP27 23
+#define R_KVX_S43_GOTOFF_LO10 24
+#define R_KVX_S43_GOTOFF_UP27 25
+#define R_KVX_S43_GOTOFF_EX6 26
+#define R_KVX_32_GOTOFF 27
+#define R_KVX_64_GOTOFF 28
+#define R_KVX_32_GOT 29
+#define R_KVX_S37_GOT_LO10 30
+#define R_KVX_S37_GOT_UP27 31
+#define R_KVX_S43_GOT_LO10 32
+#define R_KVX_S43_GOT_UP27 33
+#define R_KVX_S43_GOT_EX6 34
+#define R_KVX_64_GOT 35
+#define R_KVX_GLOB_DAT 36
+#define R_KVX_COPY 37
+#define R_KVX_JMP_SLOT 38
+#define R_KVX_RELATIVE 39
+#define R_KVX_S43_LO10 40
+#define R_KVX_S43_UP27 41
+#define R_KVX_S43_EX6 42
+#define R_KVX_S64_LO10 43
+#define R_KVX_S64_UP27 44
+#define R_KVX_S64_EX27 45
+#define R_KVX_S37_GOTADDR_LO10 46
+#define R_KVX_S37_GOTADDR_UP27 47
+#define R_KVX_S43_GOTADDR_LO10 48
+#define R_KVX_S43_GOTADDR_UP27 49
+#define R_KVX_S43_GOTADDR_EX6 50
+#define R_KVX_S64_GOTADDR_LO10 51
+#define R_KVX_S64_GOTADDR_UP27 52
+#define R_KVX_S64_GOTADDR_EX27 53
+#define R_KVX_64_DTPMOD 54
+#define R_KVX_64_DTPOFF 55
+#define R_KVX_S37_TLS_DTPOFF_LO10 56
+#define R_KVX_S37_TLS_DTPOFF_UP27 57
+#define R_KVX_S43_TLS_DTPOFF_LO10 58
+#define R_KVX_S43_TLS_DTPOFF_UP27 59
+#define R_KVX_S43_TLS_DTPOFF_EX6 60
+#define R_KVX_S37_TLS_GD_LO10 61
+#define R_KVX_S37_TLS_GD_UP27 62
+#define R_KVX_S43_TLS_GD_LO10 63
+#define R_KVX_S43_TLS_GD_UP27 64
+#define R_KVX_S43_TLS_GD_EX6 65
+#define R_KVX_S37_TLS_LD_LO10 66
+#define R_KVX_S37_TLS_LD_UP27 67
+#define R_KVX_S43_TLS_LD_LO10 68
+#define R_KVX_S43_TLS_LD_UP27 69
+#define R_KVX_S43_TLS_LD_EX6 70
+#define R_KVX_64_TPOFF 71
+#define R_KVX_S37_TLS_IE_LO10 72
+#define R_KVX_S37_TLS_IE_UP27 73
+#define R_KVX_S43_TLS_IE_LO10 74
+#define R_KVX_S43_TLS_IE_UP27 75
+#define R_KVX_S43_TLS_IE_EX6 76
+#define R_KVX_S37_TLS_LE_LO10 77
+#define R_KVX_S37_TLS_LE_UP27 78
+#define R_KVX_S43_TLS_LE_LO10 79
+#define R_KVX_S43_TLS_LE_UP27 80
+#define R_KVX_S43_TLS_LE_EX6 81
+
/* C-SKY relocs. */
#define R_CKCORE_NONE 0
diff --git a/ldso/ldso/kvx/dl-startup.h b/ldso/ldso/kvx/dl-startup.h
new file mode 100644
index 000000000..9784c2345
--- /dev/null
+++ b/ldso/ldso/kvx/dl-startup.h
@@ -0,0 +1,104 @@
+/*
+ * Architecture specific code used by dl-startup.c
+ * Copyright (C) 2016 Waldemar Brodkorb <wbx@uclibc-ng.org>
+ * Copyright (C) 2018 Kalray Inc.
+ *
+ * Ported from GNU libc
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+
+/* Copyright (C) 1995-2016 Free Software Foundation, Inc.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <features.h>
+
+/* This is the first bit of code, ever, executed in user space of a dynamically
+ * linked ELF.
+ * The kernel jumps on this with the following stack layout:
+ * argc argument counter (integer)
+ * argv[0] program name (pointer)
+ * argv[1..argc-1] program args (pointers)
+ * NULL
+ * env[0...N] environment variables (pointers)
+ * NULL
+ * auxvt[0...N] Auxiliary Vector Table elements (mixed types)
+ *
+ * We should call _dl_start($sp) (the argument should point to the previously
+ * described memory layout).
+ *
+ * Next we should skip N arguments (N == _dl_skip_args).
+ * Those correspond to the arguments which are consumed by the dynamic loader
+ * if it is called directly as a program, which is possible when
+ * __LDSO_STANDALONE_SUPPORT__ is defined.
+ *
+ * We eventually end up calling the main executable's _start (from ctr1.S).
+ * The address of this _start is returned by _dl_start (in $r0).
+ *
+ * We should call this with one argument (in $r0): the address of _dl_fini()
+ */
+__asm__("\
+.text \n\
+.globl _start \n\
+.type _start, %function \n\
+_start: \n\
+ copyd $r0 = $sp \n\
+ copyd $r18 = $sp \n\
+ andd $sp = $sp, -32 \n\
+ call _dl_start \n\
+ ;; \n\
+.globl _dl_start_user \n\
+.type _dl_start_user, %function \n\
+_dl_start_user: \n\
+ pcrel $r1 = @gotaddr() \n\
+ copyd $r5 = $r0 \n\
+ copyd $sp = $r18 \n\
+ ;; \n\
+ ld $r2 = @gotoff(_dl_skip_args)[$r1] \n\
+ addd $r0 = $r1, @gotoff(_dl_fini) \n\
+ ;; \n\
+ lwz $r3 = 0[$sp] \n\
+ ;; \n\
+ sbfw $r4 = $r2, $r3 \n\
+ addx8d $sp = $r2, $sp \n\
+ ;; \n\
+ sd 0[$sp] = $r4 \n\
+ icall $r5 \n\
+ ;; \n\
+");
+
+/* Get a pointer to the argv array. On many platforms this can be just
+ * the address of the first argument, on other platforms we need to
+ * do something a little more subtle here. */
+#define GET_ARGV(ARGVP, ARGS) ARGVP = (((unsigned long*)ARGS)+1)
+
+/* Handle relocation of the symbols in the dynamic loader. */
+static __always_inline
+void PERFORM_BOOTSTRAP_RELOC(ELF_RELOC *rpnt, ElfW(Addr) *reloc_addr,
+ ElfW(Addr) symbol_addr, ElfW(Addr) load_addr, ElfW(Sym) *sym)
+{
+ switch (ELF_R_TYPE(rpnt->r_info)) {
+ case R_KVX_NONE:
+ break;
+ case R_KVX_JMP_SLOT:
+ *reloc_addr = symbol_addr + rpnt->r_addend;
+ break;
+ case R_KVX_RELATIVE:
+ *reloc_addr = load_addr + rpnt->r_addend;
+ break;
+ default:
+ _dl_exit(1);
+ }
+}
diff --git a/ldso/ldso/kvx/dl-syscalls.h b/ldso/ldso/kvx/dl-syscalls.h
new file mode 100644
index 000000000..f40c4fd31
--- /dev/null
+++ b/ldso/ldso/kvx/dl-syscalls.h
@@ -0,0 +1 @@
+/* stub for arch-specific syscall issues */
diff --git a/ldso/ldso/kvx/dl-sysdep.h b/ldso/ldso/kvx/dl-sysdep.h
new file mode 100644
index 000000000..9bb20ca8e
--- /dev/null
+++ b/ldso/ldso/kvx/dl-sysdep.h
@@ -0,0 +1,99 @@
+/*
+ * Various assembly language/system dependent hacks that are required
+ * so that we can minimize the amount of platform specific code.
+ * Copyright (C) 2000-2004 by Erik Andersen <andersen@codepoet.org>
+ * Copyright (C) 2017-2018 by Waldemar Brodkorb <wbx@uclibc-ng.org>
+ * Copyright (C) 2018 Kalray Inc.
+
+ * Ported from GNU C Library
+ * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
+ */
+