From patchwork Wed Jun 5 11:56:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Chen X-Patchwork-Id: 33022 Received: (qmail 91650 invoked by alias); 5 Jun 2019 11:58:10 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 91582 invoked by uid 89); 5 Jun 2019 11:58:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RDNS_DYNAMIC, SPF_PASS, TVD_RCVD_IP autolearn=ham version=3.3.1 spammy=8th X-HELO: ATCSQR.andestech.com From: Vincent Chen To: , CC: , , Subject: [PATCH v4 08/11] nds32: Linux ABI Date: Wed, 5 Jun 2019 19:56:52 +0800 Message-ID: <1559735815-20093-9-git-send-email-vincentc@andestech.com> In-Reply-To: <1559735815-20093-1-git-send-email-vincentc@andestech.com> References: <1559735815-20093-1-git-send-email-vincentc@andestech.com> MIME-Version: 1.0 X-DNSRBL: X-MAIL: ATCSQR.andestech.com x55BpatC068320 Linux-specific code that is required for maintaining ABI compatibility. This doesn't contain the actual system call interface, that is split out in order to avoid having a patch that's too big. 2019-06-03 Vincent Chen 2019-06-03 CheWei Chuang * sysdeps/unix/sysv/linux/nds32/bits/fcntl.h: New file. * sysdeps/unix/sysv/linux/nds32/bits/procfs.h: Likewise. * sysdeps/unix/sysv/linux/nds32/bits/shmlba.h: Likewise. * sysdeps/unix/sysv/linux/nds32/fpu/Makefile: Likewise. * sysdeps/unix/sysv/linux/nds32/fpu/ioctl.c: Likewise. * sysdeps/unix/sysv/linux/nds32/fpu/mremap.c: Likewise. * sysdeps/unix/sysv/linux/nds32/fpu/prctl.c: Likewise. * sysdeps/unix/sysv/linux/nds32/fpu/setfpucw.c: Likewise. * sysdeps/unix/sysv/linux/nds32/getcontext.S: Likewise. * sysdeps/unix/sysv/linux/nds32/init-first.c: Likewise. * sysdeps/unix/sysv/linux/nds32/ipc_priv.h: Likewise. * sysdeps/unix/sysv/linux/nds32/kernel-features.h: Likewise. * sysdeps/unix/sysv/linux/nds32/libc-vdso.h: Likewise. * sysdeps/unix/sysv/linux/nds32/makecontext.c: Likewise. * sysdeps/unix/sysv/linux/nds32/setcontext.S: Likewise. * sysdeps/unix/sysv/linux/nds32/sigcontextinfo.h: Likewise. * sysdeps/unix/sysv/linux/nds32/swapcontext.S: Likewise. * sysdeps/unix/sysv/linux/nds32/sys/cachectl.h: Likewise. * sysdeps/unix/sysv/linux/nds32/sys/ucontext.h: Likewise. * sysdeps/unix/sysv/linux/nds32/sys/user.h: Likewise. * sysdeps/unix/sysv/linux/nds32/sysctl.mk: Likewise. * sysdeps/unix/sysv/linux/nds32/ucontext_i.sym: Likewise. * sysdeps/unix/sysv/linux/nds32/vfork.S: Likewise. --- sysdeps/unix/sysv/linux/nds32/bits/fcntl.h | 53 ++++++++ sysdeps/unix/sysv/linux/nds32/bits/procfs.h | 40 ++++++ sysdeps/unix/sysv/linux/nds32/bits/shmlba.h | 24 ++++ sysdeps/unix/sysv/linux/nds32/fpu/Makefile | 3 + sysdeps/unix/sysv/linux/nds32/fpu/ioctl.c | 37 ++++++ sysdeps/unix/sysv/linux/nds32/fpu/mremap.c | 37 ++++++ sysdeps/unix/sysv/linux/nds32/fpu/prctl.c | 40 ++++++ sysdeps/unix/sysv/linux/nds32/fpu/setfpucw.c | 50 ++++++++ sysdeps/unix/sysv/linux/nds32/getcontext.S | 102 ++++++++++++++++ sysdeps/unix/sysv/linux/nds32/init-first.c | 48 ++++++++ sysdeps/unix/sysv/linux/nds32/ipc_priv.h | 22 ++++ sysdeps/unix/sysv/linux/nds32/kernel-features.h | 31 +++++ sysdeps/unix/sysv/linux/nds32/libc-vdso.h | 32 +++++ sysdeps/unix/sysv/linux/nds32/makecontext.c | 57 +++++++++ sysdeps/unix/sysv/linux/nds32/setcontext.S | 111 +++++++++++++++++ sysdeps/unix/sysv/linux/nds32/sigcontextinfo.h | 35 ++++++ sysdeps/unix/sysv/linux/nds32/swapcontext.S | 154 ++++++++++++++++++++++++ sysdeps/unix/sysv/linux/nds32/sys/cachectl.h | 33 +++++ sysdeps/unix/sysv/linux/nds32/sys/ucontext.h | 88 ++++++++++++++ sysdeps/unix/sysv/linux/nds32/sys/user.h | 22 ++++ sysdeps/unix/sysv/linux/nds32/sysctl.mk | 1 + sysdeps/unix/sysv/linux/nds32/ucontext_i.sym | 28 +++++ sysdeps/unix/sysv/linux/nds32/vfork.S | 46 +++++++ 23 files changed, 1094 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/nds32/bits/fcntl.h create mode 100644 sysdeps/unix/sysv/linux/nds32/bits/procfs.h create mode 100644 sysdeps/unix/sysv/linux/nds32/bits/shmlba.h create mode 100644 sysdeps/unix/sysv/linux/nds32/fpu/Makefile create mode 100644 sysdeps/unix/sysv/linux/nds32/fpu/ioctl.c create mode 100644 sysdeps/unix/sysv/linux/nds32/fpu/mremap.c create mode 100644 sysdeps/unix/sysv/linux/nds32/fpu/prctl.c create mode 100644 sysdeps/unix/sysv/linux/nds32/fpu/setfpucw.c create mode 100644 sysdeps/unix/sysv/linux/nds32/getcontext.S create mode 100644 sysdeps/unix/sysv/linux/nds32/init-first.c create mode 100644 sysdeps/unix/sysv/linux/nds32/ipc_priv.h create mode 100644 sysdeps/unix/sysv/linux/nds32/kernel-features.h create mode 100644 sysdeps/unix/sysv/linux/nds32/libc-vdso.h create mode 100644 sysdeps/unix/sysv/linux/nds32/makecontext.c create mode 100644 sysdeps/unix/sysv/linux/nds32/setcontext.S create mode 100644 sysdeps/unix/sysv/linux/nds32/sigcontextinfo.h create mode 100644 sysdeps/unix/sysv/linux/nds32/swapcontext.S create mode 100644 sysdeps/unix/sysv/linux/nds32/sys/cachectl.h create mode 100644 sysdeps/unix/sysv/linux/nds32/sys/ucontext.h create mode 100644 sysdeps/unix/sysv/linux/nds32/sys/user.h create mode 100644 sysdeps/unix/sysv/linux/nds32/sysctl.mk create mode 100644 sysdeps/unix/sysv/linux/nds32/ucontext_i.sym create mode 100644 sysdeps/unix/sysv/linux/nds32/vfork.S diff --git a/sysdeps/unix/sysv/linux/nds32/bits/fcntl.h b/sysdeps/unix/sysv/linux/nds32/bits/fcntl.h new file mode 100644 index 0000000..1b27ebe --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/bits/fcntl.h @@ -0,0 +1,53 @@ +/* O_*, F_*, FD_* bit values. Andes Linux/nds32 version. + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#ifndef _FCNTL_H +# error "Never use directly; include instead." +#endif + +#include + +typedef struct flock + { + short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */ + short int l_whence; /* Where `l_start' is relative to (like `lseek'). */ +#ifndef __USE_FILE_OFFSET64 + __off_t l_start; /* Offset where the lock begins. */ + __off_t l_len; /* Size of the locked area; zero means until EOF. */ +#else + __off64_t l_start; /* Offset where the lock begins. */ + __off64_t l_len; /* Size of the locked area; zero means until EOF. */ +#endif + __pid_t l_pid; /* Process holding the lock. */ +} flock_t; + +#ifdef __USE_LARGEFILE64 +struct flock64 + { + short int l_type; /* Type of lock: F_RDLCK, F_WRLCK, or F_UNLCK. */ + short int l_whence; /* Where `l_start' is relative to (like `lseek'). */ + __off64_t l_start; /* Offset where the lock begins. */ + __off64_t l_len; /* Size of the locked area; zero means until EOF. */ + __pid_t l_pid; /* Process holding the lock. */ + }; +#endif + + +/* Include generic Linux declarations. */ +#include + diff --git a/sysdeps/unix/sysv/linux/nds32/bits/procfs.h b/sysdeps/unix/sysv/linux/nds32/bits/procfs.h new file mode 100644 index 0000000..94a3893 --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/bits/procfs.h @@ -0,0 +1,40 @@ +/* Types for registers for sys/procfs.h. Andes nds32 version. + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#ifndef _SYS_PROCFS_H +# error "Never include directly; use instead." +#endif + +#include + +/* Type for a general-purpose register. */ +typedef unsigned long elf_greg_t; +/* Type for a floating-point registers. */ +typedef long long elf_fpreg_t; + +/* And the whole bunch of them. We could have used `struct + user_regs' directly in the typedef, but tradition says that + the register set is an array, which does have some peculiar + semantics, so leave it that way. */ + +#define ELF_NGREG (sizeof(struct user_pt_regs)/sizeof(elf_greg_t)) +typedef elf_greg_t elf_gregset_t[ELF_NGREG]; + +/* Register set for the floating-point registers. */ +#define ELF_NFPREG 33 +typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG]; diff --git a/sysdeps/unix/sysv/linux/nds32/bits/shmlba.h b/sysdeps/unix/sysv/linux/nds32/bits/shmlba.h new file mode 100644 index 0000000..2a1e0d6 --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/bits/shmlba.h @@ -0,0 +1,24 @@ +/* Define SHMLBA. Andes nds32 version. + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#ifndef _SYS_SHM_H +# error "Never use directly; include instead." +#endif + +/* Segment low boundary address multiple. */ +#define SHMLBA 0x8000 diff --git a/sysdeps/unix/sysv/linux/nds32/fpu/Makefile b/sysdeps/unix/sysv/linux/nds32/fpu/Makefile new file mode 100644 index 0000000..7d96145 --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/fpu/Makefile @@ -0,0 +1,3 @@ +ifeq ($(subdir),math) +libm-support += fp_udfiex_crtl +endif diff --git a/sysdeps/unix/sysv/linux/nds32/fpu/ioctl.c b/sysdeps/unix/sysv/linux/nds32/fpu/ioctl.c new file mode 100644 index 0000000..bb8268b --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/fpu/ioctl.c @@ -0,0 +1,37 @@ +/* Control device. + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + + +#include +#include +#include + +#include +#include + +int __ioctl (int __fd, unsigned long int __request, ...) +{ + unsigned long arg1; + va_list arg; + va_start (arg, __request); + arg1 = va_arg (arg, unsigned long); + va_end (arg); + return INLINE_SYSCALL(ioctl,3,__fd,__request,arg1); +} +libc_hidden_def (__ioctl) +weak_alias (__ioctl, ioctl) diff --git a/sysdeps/unix/sysv/linux/nds32/fpu/mremap.c b/sysdeps/unix/sysv/linux/nds32/fpu/mremap.c new file mode 100644 index 0000000..21dc5f2 --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/fpu/mremap.c @@ -0,0 +1,37 @@ +/* Re-map a virtual memory address. + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + + + +#include +#include +#include +#include +#include + +void *__mremap (void *__addr, size_t __old_len, size_t __new_len, int __flags, ...) +{ + unsigned long arg1; + va_list arg; + va_start (arg, __flags); + arg1 = va_arg (arg, int); + va_end (arg); + return (void *)INLINE_SYSCALL(mremap,5,__addr,__old_len,__new_len,__flags,arg1); +} +weak_alias (__mremap, mremap) +libc_hidden_def (__mremap) diff --git a/sysdeps/unix/sysv/linux/nds32/fpu/prctl.c b/sysdeps/unix/sysv/linux/nds32/fpu/prctl.c new file mode 100644 index 0000000..150a453 --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/fpu/prctl.c @@ -0,0 +1,40 @@ +/* Operations on a process. + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#include +#include +#include +#include +#include +int prctl (int __option, ...); +libc_hidden_proto(prctl) + +int __prctl (int __option, ...) +{ + unsigned long arg1,arg2,arg3,arg4; + va_list arg; + va_start (arg, __option); + arg1 = va_arg (arg, unsigned long); + arg2 = va_arg (arg, unsigned long); + arg3 = va_arg (arg, unsigned long); + arg4 = va_arg (arg, unsigned long); + va_end (arg); + return INLINE_SYSCALL(prctl,5,__option,arg1,arg2,arg3,arg4); +} +weak_alias( __prctl,prctl) +libc_hidden_weak (prctl) diff --git a/sysdeps/unix/sysv/linux/nds32/fpu/setfpucw.c b/sysdeps/unix/sysv/linux/nds32/fpu/setfpucw.c new file mode 100644 index 0000000..dfc1aac --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/fpu/setfpucw.c @@ -0,0 +1,50 @@ +/* Set the FPU control word. Andes nds32 version + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#include +#include +#include +#include + +void +__setfpucw (fpu_control_t set) +{ + + fpu_control_t cw; + /* Fetch the current control word. */ + _FPU_GETCW (cw); + + /* Preserve the reserved bits, and set the rest as the user + specified (or the default, if the user gave zero). */ + cw &= _FPU_RESERVED; + cw |= set & ~_FPU_RESERVED; + + + /* GLRO(dl_fpu_control) == _FPU_DEFAULT_SUPPORT_SUBNORMAL_OUTPUT indicates + * Kernel will recalculate the underflow operation to support denormalize + * output. To ensure each that an underflow exception is issued each time a + * denormalize output occurs, the enable bit of underflow exception in + * $fpcsr shall be set by default. + */ + if (GLRO(dl_fpu_control) == _FPU_DEFAULT_SUPPORT_SUBNORMAL_OUTPUT) { + __fpu_control = GLRO(dl_fpu_control); + cw |= FPU_MASK_SUBOUT; + } + _FPU_SETCW (cw); + +} diff --git a/sysdeps/unix/sysv/linux/nds32/getcontext.S b/sysdeps/unix/sysv/linux/nds32/getcontext.S new file mode 100644 index 0000000..8d29096 --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/getcontext.S @@ -0,0 +1,102 @@ +/* Save current context. Andes LINUX/nds32 version. + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#include +#include + +#include "ucontext_i.h" + +/* __getcontext (const ucontext_t *ucp). */ + +ENTRY(__getcontext) + swi $lp, [$r0 + UCONTEXT_PC] + addi $r15, $r0, UCONTEXT_GREGS + xor $r1, $r1, $r1 + smw.bim $r1, [$r15], $r1 + addi $r15, $r15, 20 + smw.bim $r6, [$r15], $r14 + addi $r15, $r15, 4 + smw.bim $r16, [$r15], $r25, #0xf +#ifdef __NDS32_ABI_2FP_PLUS__ + move $r4, $r0 +#endif + +/* rt_sigprocmask (SIG_BLOCK, NULL, &ucp->uc_sigmask, _NSIG8). */ + move $r3, _NSIG8 + addi $r2, $r0, UCONTEXT_SIGMASK + movi $r1, 0 + movi $r0, SIG_BLOCK + movi $r15, SYS_ify(rt_sigprocmask) + syscall 0x0 + bnez $r0, .err + + +#ifdef __NDS32_ABI_2FP_PLUS__ + addi $r2, $r4, UCONTEXT_FDREGS +/* Process for FPU registers. */ + fmfcfg $r20 /* Keep $fpcfg in $r20. */ + slli $r20, $r20, #28 + srli $r20, $r20, #30 /* Set $r20 as $fpcfg.freg. */ + + /* Case switch for $r20 as $fpcfg.freg. */ + beqz $r20, .LCFG0 /* Branch if $fpcfg.freg = 0b00. */ + xori $r15, $r20, #0b10 + beqz $r15, .LCFG2 /* Branch if $fpcfg.freg = 0b10. */ + srli $r20, $r20, #0b01 + beqz $r20, .LCFG1 /* Branch if $fpcfg.freg = 0b01. */ + /* Fall-through if $fpcfg.freg = 0b11. */ +.LCFG3: + fsdi $fd31, [$r2 + 248] + fsdi $fd30, [$r2 + 240] + fsdi $fd29, [$r2 + 232] + fsdi $fd28, [$r2 + 224] + fsdi $fd27, [$r2 + 216] + fsdi $fd26, [$r2 + 208] + fsdi $fd25, [$r2 + 200] + fsdi $fd24, [$r2 + 192] +.LCFG2: + fsdi $fd10, [$r2 + 80] + fsdi $fd9, [$r2 + 72] + fsdi $fd8, [$r2 + 64] +.LCFG1: + fsdi $fd7, [$r2 + 56] + fsdi $fd6, [$r2 + 48] + fsdi $fd5, [$r2 + 40] + fsdi $fd4, [$r2 + 32] +.LCFG0: + fsdi $fd3, [$r2 + 24] + /* save fpcsr. */ + fmfcsr $r1 + swi $r1, [$r2 + 0x100] + /* save the status of udf and iex trap. */ + movi $r0, GET_UDF_IEX_TRAP + movi $r15, SYS_ify(fp_udfiex_crtl) + syscall SYS_ify(fp_udfiex_crtl) + bltz $r0, .err + swi $r0, [$r2 + 0x104] + movi $r0, 0 +#endif /* __NDS32_ABI_2FP_PLUS__. */ + ret + +.err: + j SYSCALL_ERROR_LABEL + +PSEUDO_END(__getcontext) + +weak_alias (__getcontext, getcontext) + diff --git a/sysdeps/unix/sysv/linux/nds32/init-first.c b/sysdeps/unix/sysv/linux/nds32/init-first.c new file mode 100644 index 0000000..aada091 --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/init-first.c @@ -0,0 +1,48 @@ +/* VDSO initialization. Andes Nds32 version + Copyright (C) 2018-2019 Free Software Foundation, Inc. + + This file is part of the GNU C Library. + + 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 + . */ + +# include +# include + +int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *) attribute_hidden; +int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *); +int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *); + +static inline void +_libc_vdso_platform_setup (void) +{ + PREPARE_VERSION (linux4, "LINUX_4", 14921332); + + void *p = _dl_vdso_vsym ("__vdso_gettimeofday", &linux4); + PTR_MANGLE (p); + VDSO_SYMBOL(gettimeofday) = p; + + p = _dl_vdso_vsym ("__vdso_clock_getres", &linux4); + PTR_MANGLE (p); + VDSO_SYMBOL(clock_getres) = p; + + p = _dl_vdso_vsym ("__vdso_clock_gettime", &linux4); + PTR_MANGLE (p); + VDSO_SYMBOL(clock_gettime) = p; + +} + +# define VDSO_SETUP _libc_vdso_platform_setup + +#include diff --git a/sysdeps/unix/sysv/linux/nds32/ipc_priv.h b/sysdeps/unix/sysv/linux/nds32/ipc_priv.h new file mode 100644 index 0000000..c88bbb1 --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/ipc_priv.h @@ -0,0 +1,22 @@ +/* Old SysV permission definition for Linux. Andes nds32 version. + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#include /* For __key_t. */ + +#define __IPC_64 0x0 + diff --git a/sysdeps/unix/sysv/linux/nds32/kernel-features.h b/sysdeps/unix/sysv/linux/nds32/kernel-features.h new file mode 100644 index 0000000..4ab663e --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/kernel-features.h @@ -0,0 +1,31 @@ +/* Set flags signalling availability of kernel features based on given + kernel version number. Andes nds32 version. + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#include_next + + +#undef __ASSUME_CLONE_DEFAULT +#define __ASSUME_CLONE_BACKWARDS 1 + +/* Define this if your 32-bit syscall API requires 64-bit register + pairs to start with an even-number register. */ +#define __ASSUME_ALIGNED_REGISTER_PAIRS 1 + +/* nds32 fadvise64_64 reorganize the syscall arguments. */ +#define __ASSUME_FADVISE64_64_6ARG 1 diff --git a/sysdeps/unix/sysv/linux/nds32/libc-vdso.h b/sysdeps/unix/sysv/linux/nds32/libc-vdso.h new file mode 100644 index 0000000..3247e09 --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/libc-vdso.h @@ -0,0 +1,32 @@ +/* VDSO function declaration, Andes nds32 version. + Copyright (C) 2018-2019 Free Software Foundation, Inc. + + This file is part of the GNU C Library. + + 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 + . */ + +#ifndef _LIBC_VDSO_H +#define _LIBC_VDSO_H + +# include + +extern int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *) + attribute_hidden; +extern int (*VDSO_SYMBOL (clock_gettime)) (clockid_t, struct timespec *) + attribute_hidden; +extern int (*VDSO_SYMBOL (clock_getres)) (clockid_t, struct timespec *) + attribute_hidden; + +#endif /* _LIBC_VDSO_H. */ diff --git a/sysdeps/unix/sysv/linux/nds32/makecontext.c b/sysdeps/unix/sysv/linux/nds32/makecontext.c new file mode 100644 index 0000000..de01d16 --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/makecontext.c @@ -0,0 +1,57 @@ +/* Create new context. Andes nds32 version. + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#include +#include +#include + +void +__makecontext (ucontext_t *ucp, void (*func) (void), int argc, ...) +{ + extern void __startcontext (void); + unsigned long int *sp; + unsigned long int *regptr; + va_list ap; + int i; + + sp = (unsigned long int *) + ((uintptr_t) ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); + + /* Allocate stack for 7-th, 8-th, ..., n-th arguments. */ + sp -= argc <= 6 ? 0 : argc - 6; + + /* Keep the stack aligned. */ + sp = (unsigned long int *) (((uintptr_t) sp) & -8L); + + ucp->uc_mcontext.nds32_r6 = (uintptr_t) ucp->uc_link; + ucp->uc_mcontext.nds32_sp = (uintptr_t) sp; + ucp->uc_mcontext.nds32_ipc = (uintptr_t) func; + ucp->uc_mcontext.nds32_lp = (uintptr_t) &__startcontext; + + va_start (ap, argc); + regptr = &ucp->uc_mcontext.nds32_r0; + for (i = 0; i < argc; ++i) + if (i < 6) + *regptr++ = va_arg (ap, unsigned long int); + else + sp[i - 6] = va_arg (ap, unsigned long int); + + va_end (ap); + +} +weak_alias (__makecontext, makecontext) diff --git a/sysdeps/unix/sysv/linux/nds32/setcontext.S b/sysdeps/unix/sysv/linux/nds32/setcontext.S new file mode 100644 index 0000000..f1d2fd7 --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/setcontext.S @@ -0,0 +1,111 @@ +/* Set current context. Andes nds32 version. + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#include + +#include "ucontext_i.h" + +/* int __setcontext (const ucontext_t *ucp). */ + +ENTRY(__setcontext) + move $r4, $r0 + +/* sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, NULL, _NSIG8). */ + move $r0, SIG_SETMASK + addi $r1, $r4, UCONTEXT_SIGMASK + movi $r2, 0 + movi $r3, _NSIG8 + movi $r15, SYS_ify(rt_sigprocmask) + syscall SYS_ify(rt_sigprocmask) + bnez $r0, .err + +#ifdef __NDS32_ABI_2FP_PLUS__ + addi $r3, $r4, UCONTEXT_FDREGS + + fmfcfg $r20 /* Keep $fpcfg in $r20. */ + slli $r20, $r20, #28 + srli $r20, $r20, #30 /* Set $r20 as $fpcfg.freg. */ + + + /* Case switch for $r20 as $fpcfg.freg. */ + beqz $r20, .LCFG0 /* Branch if $fpcfg.freg = 0b00. */ + xori $r15, $r20, #0b10 + beqz $r15, .LCFG2 /* Branch if $fpcfg.freg = 0b10. */ + srli $r20, $r20, #0b01 + beqz $r20, .LCFG1 /* Branch if $fpcfg.freg = 0b01. */ + /* Fall-through if $fpcfg.freg = 0b11. */ +.LCFG3: + fldi $fd31, [$r3 + 248] + fldi $fd30, [$r3 + 240] + fldi $fd29, [$r3 + 232] + fldi $fd28, [$r3 + 224] + fldi $fd27, [$r3 + 216] + fldi $fd26, [$r3 + 208] + fldi $fd25, [$r3 + 200] + fldi $fd24, [$r3 + 192] +.LCFG2: + fldi $fd10, [$r3 + 80] + fldi $fd9, [$r3 + 72] + fldi $fd8, [$r3 + 64] +.LCFG1: + fldi $fd7, [$r3 + 56] + fldi $fd6, [$r3 + 48] + fldi $fd5, [$r3 + 40] + fldi $fd4, [$r3 + 32] +.LCFG0: + fldi $fd3, [$r3 + 24] + /* save fpcsr. */ + lwi $r1, [$r3 + 0x100] + fmtcsr $r1 + /* save the status of udf and iex trap. */ + lwi $r0, [$r3 + 0x104] + bltz $r0, 1f + movi $r15, SYS_ify(fp_udfiex_crtl) + syscall SYS_ify(fp_udfiex_crtl) +1: +#endif /* __NDS32_ABI_2FP_PLUS__. */ + + move $r0, $r4 + addi $r15, $r0, UCONTEXT_GREGS + 4 + lmw.bim $r1, [$r15], $r14 + addi $r15, $r15, 4 + lmw.bim $r16, [$r15], $r25, #0xf + lwi $r15, [$r0 + UCONTEXT_PC] + lwi $r0, [$r0 + UCONTEXT_GREGS] + jr $r15 +.err: + j SYSCALL_ERROR_LABEL +PSEUDO_END(__setcontext) + +weak_alias (__setcontext, setcontext) + + cfi_startproc + cfi_undefined (lp) + nop16 + cfi_endproc +ENTRY (__startcontext) + beqz $r6, 1f + move $r0, $r6 + jal __setcontext +1: + move $r0, 0 + j HIDDEN_JUMPTARGET(exit) +END (__startcontext) + +.hidden __startcontext + diff --git a/sysdeps/unix/sysv/linux/nds32/sigcontextinfo.h b/sysdeps/unix/sysv/linux/nds32/sigcontextinfo.h new file mode 100644 index 0000000..b3faade --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/sigcontextinfo.h @@ -0,0 +1,35 @@ +/* Definitions for signal handling calling conventions. Andes nds32 version. + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#include + +#define SIGCONTEXT siginfo_t *_si, struct ucontext_t * +#define GET_PC(ctx) ((void *) (ctx)->uc_mcontext.nds32_ipc) + + +/* There is no reliable way to get the sigcontext unless we use a + three-argument signal handler. */ +#define __sigaction(sig, act, oact) ({ \ + (act)->sa_flags |= SA_SIGINFO; \ + (__sigaction) (sig, act, oact); \ +}) + +#define sigaction(sig, act, oact) ({ \ + (act)->sa_flags |= SA_SIGINFO; \ + (sigaction) (sig, act, oact); \ +}) diff --git a/sysdeps/unix/sysv/linux/nds32/swapcontext.S b/sysdeps/unix/sysv/linux/nds32/swapcontext.S new file mode 100644 index 0000000..9f489fd --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/swapcontext.S @@ -0,0 +1,154 @@ +/* Save and set current context. Andes nds32 version + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#include +#include +#include "ucontext_i.h" + +/* int swapcontext (ucontext_t *oucp, const ucontext_t *ucp). */ + +ENTRY(__swapcontext) + move $r5, $r1 + swi $lp, [$r0 + UCONTEXT_PC] + addi $r15, $r0, UCONTEXT_GREGS + xor $r1, $r1, $r1 + smw.bim $r1, [$r15], $r1 + addi $r15, $r15, 20 + smw.bim $r6, [$r15], $r14 + addi $r15, $r15, 4 + smw.bim $r16, [$r15], $r25, #0xf +#ifdef __NDS32_ABI_2FP_PLUS__ + addi $r4, $r0, UCONTEXT_FDREGS +#endif /* __NDS32_ABI_2FP_PLUS__. */ + +/* rt_sigprocmask (SIG_SETMASK, &ucp->uc_sigmask, &oucp->uc_sigmask, _NSIG8). */ + move $r3, _NSIG8 + addi $r2, $r0, UCONTEXT_SIGMASK + addi $r1, $r5, UCONTEXT_SIGMASK + move $r0, SIG_SETMASK + movi $r15, SYS_ify(rt_sigprocmask) + syscall SYS_ify(rt_sigprocmask) + bnez $r0, .err + +#ifdef __NDS32_ABI_2FP_PLUS__ +/* Process for FPU registers. */ + fmfcfg $r20 /* Keep $fpcfg in $r20. */ + slli $r20, $r20, #28 + srli $r20, $r20, #30 /* Set $r20 as $fpcfg.freg. */ + + /* Case switch for $r20 as $fpcfg.freg. */ + beqz $r20, .LCFG0 /* Branch if $fpcfg.freg = 0b00. */ + xori $r15, $r20, #0b10 + beqz $r15, .LCFG2 /* Branch if $fpcfg.freg = 0b10. */ + srli $r20, $r20, #0b01 + beqz $r20, .LCFG1 /* Branch if $fpcfg.freg = 0b01. */ + /* Fall-through if $fpcfg.freg = 0b11. */ +.LCFG3: + fsdi $fd31, [$r4 + 248] + fsdi $fd30, [$r4 + 240] + fsdi $fd29, [$r4 + 232] + fsdi $fd28, [$r4 + 224] + fsdi $fd27, [$r4 + 216] + fsdi $fd26, [$r4 + 208] + fsdi $fd25, [$r4 + 200] + fsdi $fd24, [$r4 + 192] +.LCFG2: + fsdi $fd10, [$r4 + 80] + fsdi $fd9, [$r4 + 72] + fsdi $fd8, [$r4 + 64] +.LCFG1: + fsdi $fd7, [$r4 + 56] + fsdi $fd6, [$r4 + 48] + fsdi $fd5, [$r4 + 40] + fsdi $fd4, [$r4 + 32] +.LCFG0: + fsdi $fd3, [$r4 + 24] + /* save fpcsr. */ + fmfcsr $r1 + swi $r1, [$r4 + 0x100] + /* save the status of udf and iex trap. */ + movi $r0, GET_UDF_IEX_TRAP + movi $r15, SYS_ify(fp_udfiex_crtl) + syscall SYS_ify(fp_udfiex_crtl) + swi $r0, [$r4 + 0x104] +#endif /* __NDS32_ABI_2FP_PLUS__. */ + + + +#ifdef __NDS32_ABI_2FP_PLUS__ + addi $r0, $r5, UCONTEXT_FDREGS + fmfcfg $r20 /* Keep $fpcfg in $r20. */ + slli $r20, $r20, #28 + srli $r20, $r20, #30 /* Set $r20 as $fpcfg.freg. */ + + fmfcfg $r20 /* Keep $fpcfg in $r20. */ + slli $r20, $r20, #28 + srli $r20, $r20, #30 /* Set $r20 as $fpcfg.freg. */ + + /* Case switch for $r20 as $fpcfg.freg. */ + beqz $r20, .LCFG4 /* Branch if $fpcfg.freg = 0b00. */ + xori $r15, $r20, #0b10 + beqz $r15, .LCFG6 /* Branch if $fpcfg.freg = 0b10. */ + srli $r20, $r20, #0b01 + beqz $r20, .LCFG5 /* Branch if $fpcfg.freg = 0b01. */ + /* Fall-through if $fpcfg.freg = 0b11. */ +.LCFG7: + fldi $fd31, [$r0 + 248] + fldi $fd30, [$r0 + 240] + fldi $fd29, [$r0 + 232] + fldi $fd28, [$r0 + 224] + fldi $fd27, [$r0 + 216] + fldi $fd26, [$r0 + 208] + fldi $fd25, [$r0 + 200] + fldi $fd24, [$r0 + 192] +.LCFG6: + fldi $fd10, [$r0 + 80] + fldi $fd9, [$r0 + 72] + fldi $fd8, [$r0 + 64] +.LCFG5: + fldi $fd7, [$r0 + 56] + fldi $fd6, [$r0 + 48] + fldi $fd5, [$r0 + 40] + fldi $fd4, [$r0 + 32] +.LCFG4: + fldi $fd3, [$r0 + 24] + /* save fpcsr. */ + lwi $r1, [$r0 + 0x100] + fmtcsr $r1 + /* save the status of udf and iex trap. */ + lwi $r0, [$r0 + 0x104] + bltz $r0, 1f + movi $r15, SYS_ify(fp_udfiex_crtl) + syscall SYS_ify(fp_udfiex_crtl) +1: +#endif /* __NDS32_ABI_2FP_PLUS__. */ + + move $r0, $r5 + addi $r15, $r5, UCONTEXT_GREGS + 4 + lmw.bim $r1, [$r15], $r14 + addi $r15, $r15, 4 + lmw.bim $r16, [$r15], $r25, #0xf + lwi $r15, [$r0 + UCONTEXT_PC] + lwi $r0, [$r0 + UCONTEXT_GREGS] + jr $r15 + +.err: + j SYSCALL_ERROR_LABEL +PSEUDO_END(__swapcontext) + +weak_alias (__swapcontext, swapcontext) diff --git a/sysdeps/unix/sysv/linux/nds32/sys/cachectl.h b/sysdeps/unix/sysv/linux/nds32/sys/cachectl.h new file mode 100644 index 0000000..412b46f --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/sys/cachectl.h @@ -0,0 +1,33 @@ +/* Andes nds32 cache flushing interface + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#ifndef _SYS_CACHECTL_H +#define _SYS_CACHECTL_H 1 + +#include + +/* Get the kernel definition for the __op argument. */ +#include + +__BEGIN_DECLS + +extern int cacheflush (void *__addr, const int __end, const int __op) __THROW; + +__END_DECLS + +#endif /* sys/cachectl.h */ diff --git a/sysdeps/unix/sysv/linux/nds32/sys/ucontext.h b/sysdeps/unix/sysv/linux/nds32/sys/ucontext.h new file mode 100644 index 0000000..dc6bab4 --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/sys/ucontext.h @@ -0,0 +1,88 @@ +/* struct ucontext definition, Andes nds32 version. + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#ifndef _SYS_UCONTEXT_H +#define _SYS_UCONTEXT_H 1 + +#include +#include +#include + + +#ifdef __USE_MISC +# define __ctx(fld) fld +#else +# define __ctx(fld) __ ## fld +#endif + +/* Context to describe whole processor state. */ + +typedef struct { + unsigned long int __ctx(trap_no); + unsigned long int __ctx(error_code); + unsigned long int __ctx(oldmask); + unsigned long int __ctx(nds32_r0); + unsigned long int __ctx(nds32_r1); + unsigned long int __ctx(nds32_r2); + unsigned long int __ctx(nds32_r3); + unsigned long int __ctx(nds32_r4); + unsigned long int __ctx(nds32_r5); + unsigned long int __ctx(nds32_r6); + unsigned long int __ctx(nds32_r7); + unsigned long int __ctx(nds32_r8); + unsigned long int __ctx(nds32_r9); + unsigned long int __ctx(nds32_r10); + unsigned long int __ctx(nds32_r11); + unsigned long int __ctx(nds32_r12); + unsigned long int __ctx(nds32_r13); + unsigned long int __ctx(nds32_r14); + unsigned long int __ctx(nds32_r15); + unsigned long int __ctx(nds32_r16); + unsigned long int __ctx(nds32_r17); + unsigned long int __ctx(nds32_r18); + unsigned long int __ctx(nds32_r19); + unsigned long int __ctx(nds32_r20); + unsigned long int __ctx(nds32_r21); + unsigned long int __ctx(nds32_r22); + unsigned long int __ctx(nds32_r23); + unsigned long int __ctx(nds32_r24); + unsigned long int __ctx(nds32_r25); + unsigned long int __ctx(nds32_fp); + unsigned long int __ctx(nds32_gp); + unsigned long int __ctx(nds32_lp); + unsigned long int __ctx(nds32_sp); + unsigned long int __ctx(nds32_ipc); + unsigned long int __ctx(fault_address); + unsigned long int __ctx(used_math_flag); + unsigned long long __ctx(fd_regs)[32]; + unsigned long int __ctx(fpcsr); + unsigned long int __ctx(UDF_trap); + unsigned long int __ctx(zol)[3]; +} mcontext_t; + + +/* Userlevel context. */ +typedef struct ucontext_t + { + unsigned long int __ctx(uc_flags); + struct ucontext_t *uc_link; + stack_t uc_stack; + mcontext_t uc_mcontext; + __sigset_t uc_sigmask; + } ucontext_t; +#endif /* _SYS_UCONTEXT_H. */ diff --git a/sysdeps/unix/sysv/linux/nds32/sys/user.h b/sysdeps/unix/sysv/linux/nds32/sys/user.h new file mode 100644 index 0000000..b529a0b --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/sys/user.h @@ -0,0 +1,22 @@ +/* Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#ifndef _SYS_USER_H +#define _SYS_USER_H 1 + + +#endif /* _SYS_USER_H. */ diff --git a/sysdeps/unix/sysv/linux/nds32/sysctl.mk b/sysdeps/unix/sysv/linux/nds32/sysctl.mk new file mode 100644 index 0000000..cd10656 --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/sysctl.mk @@ -0,0 +1 @@ +# nds32 doesn't support sysctl. diff --git a/sysdeps/unix/sysv/linux/nds32/ucontext_i.sym b/sysdeps/unix/sysv/linux/nds32/ucontext_i.sym new file mode 100644 index 0000000..266a158 --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/ucontext_i.sym @@ -0,0 +1,28 @@ +#include +#include +#include + +-- + +SIG_BLOCK +SIG_SETMASK + +_NSIG8 (_NSIG / 8) + +-- Offsets of the fields in the ucontext_t structure. +#define ucontext(member) offsetof (ucontext_t, member) +#define mcontext(member) ucontext (uc_mcontext.member) + + +UCONTEXT_GREGS mcontext (nds32_r0) +#ifdef __NDS32_ABI_2FP_PLUS__ +UCONTEXT_FDREGS mcontext (fd_regs) +#endif +UCONTEXT_PC mcontext (nds32_ipc) + + +UCONTEXT_FLAGS ucontext (uc_flags) +UCONTEXT_LINK ucontext (uc_link) +UCONTEXT_STACK ucontext (uc_stack) +UCONTEXT_MCONTEXT ucontext (uc_mcontext) +UCONTEXT_SIGMASK ucontext (uc_sigmask) diff --git a/sysdeps/unix/sysv/linux/nds32/vfork.S b/sysdeps/unix/sysv/linux/nds32/vfork.S new file mode 100644 index 0000000..412706f --- /dev/null +++ b/sysdeps/unix/sysv/linux/nds32/vfork.S @@ -0,0 +1,46 @@ +/* vfork for Linux. Andes Linux/nds32 version. + Copyright (C) 2018-2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + 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 + . */ + +#include +#define _ERRNO_H 1 +#include + + +ENTRY (__libc_vfork) +#ifdef PIC +.pic +#endif + + movi $r0, #0x4111 /* 0x4111 = CLONE_VM | CLONE_VFORK | SIGCHLD. */ + move $r1, $sp + movi $r15, __NR_clone + syscall #0x0 + bltz $r0, 2f +1: + ret +2: + sltsi $r1, $r0, -4096 + bnez $r1, 1b; + + j SYSCALL_ERROR_LABEL + +PSEUDO_END (__libc_vfork) + +weak_alias (__libc_vfork, vfork) +strong_alias (__libc_vfork, __vfork) +libc_hidden_def (__vfork)