mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
RISC-V: Linux ABI
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. 2018-01-29 Palmer Dabbelt <palmer@sifive.com> * sysdeps/riscv/nptl/pthread-offsets.h: New file. * sysdeps/riscv/nptl/pthreaddef.h: Likewise. * sysdeps/unix/sysv/linux/riscv/bits/fcntl.h: Likewise. * sysdeps/unix/sysv/linux/riscv/bits/mman.h: Likewise. * sysdeps/unix/sysv/linux/riscv/bits/sigcontext.h: Likewise. * sysdeps/unix/sysv/linux/riscv/dl-cache.h: Likewise. * sysdeps/unix/sysv/linux/riscv/flush-icache.c: Likewise. * sysdeps/unix/sysv/linux/riscv/getcontext.S: Likewise. * sysdeps/unix/sysv/linux/riscv/init-first.c: Likewise. * sysdeps/unix/sysv/linux/riscv/libc-vdso.h: Likewise. * sysdeps/unix/sysv/linux/riscv/makecontext.c: Likewise. * sysdeps/unix/sysv/linux/riscv/readelflib.c: Likewise. * sysdeps/unix/sysv/linux/riscv/register-dump.h: Likewise. * sysdeps/unix/sysv/linux/riscv/setcontext.S: Likewise. * sysdeps/unix/sysv/linux/riscv/sigcontextinfo.h: Likewise. * sysdeps/unix/sysv/linux/riscv/swapcontext.S: Likewise. * sysdeps/unix/sysv/linux/riscv/sys/cachectl.h: Likewise. * sysdeps/unix/sysv/linux/riscv/sys/procfs.h: Likewise. * sysdeps/unix/sysv/linux/riscv/sys/ucontext.h: Likewise. * sysdeps/unix/sysv/linux/riscv/sys/user.h: Likewise. * sysdeps/unix/sysv/linux/riscv/ucontext-macros.h: Likewise. * sysdeps/unix/sysv/linux/riscv/ucontext_i.sym: Likewise.
This commit is contained in:
32
sysdeps/unix/sysv/linux/riscv/sys/cachectl.h
Normal file
32
sysdeps/unix/sysv/linux/riscv/sys/cachectl.h
Normal file
@ -0,0 +1,32 @@
|
||||
/* RISC-V instruction cache flushing interface
|
||||
Copyright (C) 2017-2018 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
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _SYS_CACHECTL_H
|
||||
#define _SYS_CACHECTL_H 1
|
||||
|
||||
#include <features.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
extern int __riscv_flush_icache (void *__start, void *__end,
|
||||
unsigned long int __flags);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* sys/cachectl.h */
|
114
sysdeps/unix/sysv/linux/riscv/sys/procfs.h
Normal file
114
sysdeps/unix/sysv/linux/riscv/sys/procfs.h
Normal file
@ -0,0 +1,114 @@
|
||||
/* Core image file related definitions, RISC-V version.
|
||||
Copyright (C) 1996-2018 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
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _SYS_PROCFS_H
|
||||
#define _SYS_PROCFS_H 1
|
||||
|
||||
/* This is somehow modelled after the file of the same name on SysVr4
|
||||
systems. It provides a definition of the core file format for ELF
|
||||
used on Linux. */
|
||||
|
||||
#include <features.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/user.h>
|
||||
#include <sys/ucontext.h>
|
||||
|
||||
/* ELF register definitions */
|
||||
#define ELF_NGREG NGREG
|
||||
#define ELF_NFPREG NFPREG
|
||||
|
||||
typedef unsigned long int elf_greg_t;
|
||||
typedef unsigned long int elf_gregset_t[32];
|
||||
typedef union __riscv_mc_fp_state elf_fpregset_t;
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
struct elf_siginfo
|
||||
{
|
||||
int si_signo; /* Signal number. */
|
||||
int si_code; /* Extra code. */
|
||||
int si_errno; /* Errno. */
|
||||
};
|
||||
|
||||
|
||||
/* Definitions to generate Intel SVR4-like core files. These mostly
|
||||
have the same names as the SVR4 types with "elf_" tacked on the
|
||||
front to prevent clashes with linux definitions, and the typedef
|
||||
forms have been avoided. This is mostly like the SVR4 structure,
|
||||
but more Linuxy, with things that Linux does not support and which
|
||||
gdb doesn't really use excluded. Fields present but not used are
|
||||
marked with "XXX". */
|
||||
struct elf_prstatus
|
||||
{
|
||||
struct elf_siginfo pr_info; /* Info associated with signal. */
|
||||
short int pr_cursig; /* Current signal. */
|
||||
unsigned long int pr_sigpend; /* Set of pending signals. */
|
||||
unsigned long int pr_sighold; /* Set of held signals. */
|
||||
__pid_t pr_pid;
|
||||
__pid_t pr_ppid;
|
||||
__pid_t pr_pgrp;
|
||||
__pid_t pr_sid;
|
||||
struct timeval pr_utime; /* User time. */
|
||||
struct timeval pr_stime; /* System time. */
|
||||
struct timeval pr_cutime; /* Cumulative user time. */
|
||||
struct timeval pr_cstime; /* Cumulative system time. */
|
||||
elf_gregset_t pr_reg; /* GP registers. */
|
||||
int pr_fpvalid; /* True if math copro being used. */
|
||||
};
|
||||
|
||||
|
||||
#define ELF_PRARGSZ (80) /* Number of chars for args */
|
||||
|
||||
struct elf_prpsinfo
|
||||
{
|
||||
char pr_state; /* Numeric process state. */
|
||||
char pr_sname; /* Char for pr_state. */
|
||||
char pr_zomb; /* Zombie. */
|
||||
char pr_nice; /* Nice val. */
|
||||
unsigned long int pr_flag; /* Flags. */
|
||||
long int pr_uid;
|
||||
long int pr_gid;
|
||||
int pr_pid, pr_ppid, pr_pgrp, pr_sid;
|
||||
/* Lots missing */
|
||||
char pr_fname[16]; /* Filename of executable. */
|
||||
char pr_psargs[ELF_PRARGSZ]; /* Initial part of arg list. */
|
||||
};
|
||||
|
||||
/* The rest of this file provides the types for emulation of the
|
||||
Solaris <proc_service.h> interfaces that should be implemented by
|
||||
users of libthread_db. */
|
||||
|
||||
/* Addresses. */
|
||||
typedef void *psaddr_t;
|
||||
|
||||
/* Register sets. Linux has different names. */
|
||||
typedef elf_gregset_t prgregset_t;
|
||||
typedef elf_fpregset_t prfpregset_t;
|
||||
|
||||
/* We don't have any differences between processes and threads,
|
||||
therefore habe only ine PID type. */
|
||||
typedef __pid_t lwpid_t;
|
||||
|
||||
/* Process status and info. In the end we do provide typedefs for them. */
|
||||
typedef struct elf_prstatus prstatus_t;
|
||||
typedef struct elf_prpsinfo prpsinfo_t;
|
||||
|
||||
__END_DECLS
|
||||
|
||||
#endif /* sys/procfs.h */
|
110
sysdeps/unix/sysv/linux/riscv/sys/ucontext.h
Normal file
110
sysdeps/unix/sysv/linux/riscv/sys/ucontext.h
Normal file
@ -0,0 +1,110 @@
|
||||
/* struct ucontext definition, RISC-V version.
|
||||
Copyright (C) 1997-2018 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
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Don't rely on this, the interface is currently messed up and may need to
|
||||
be broken to be fixed. */
|
||||
#ifndef _SYS_UCONTEXT_H
|
||||
#define _SYS_UCONTEXT_H 1
|
||||
|
||||
#include <features.h>
|
||||
|
||||
#include <bits/types/sigset_t.h>
|
||||
#include <bits/types/stack_t.h>
|
||||
|
||||
typedef unsigned long int __riscv_mc_gp_state[32];
|
||||
|
||||
#ifdef __USE_MISC
|
||||
# define NGREG 32
|
||||
|
||||
# define REG_PC 0
|
||||
# define REG_RA 1
|
||||
# define REG_SP 2
|
||||
# define REG_TP 4
|
||||
# define REG_S0 8
|
||||
# define REG_S1 9
|
||||
# define REG_A0 10
|
||||
# define REG_S2 18
|
||||
# define REG_NARGS 8
|
||||
|
||||
typedef unsigned long int greg_t;
|
||||
|
||||
/* Container for all general registers. */
|
||||
typedef __riscv_mc_gp_state gregset_t;
|
||||
|
||||
/* Container for floating-point state. */
|
||||
typedef union __riscv_mc_fp_state fpregset_t;
|
||||
#endif
|
||||
|
||||
struct __riscv_mc_f_ext_state
|
||||
{
|
||||
unsigned int __f[32];
|
||||
unsigned int __fcsr;
|
||||
};
|
||||
|
||||
struct __riscv_mc_d_ext_state
|
||||
{
|
||||
unsigned long long int __f[32];
|
||||
unsigned int __fcsr;
|
||||
};
|
||||
|
||||
struct __riscv_mc_q_ext_state
|
||||
{
|
||||
unsigned long long int __f[64] __attribute__ ((__aligned__ (16)));
|
||||
unsigned int __fcsr;
|
||||
/* Reserved for expansion of sigcontext structure. Currently zeroed
|
||||
upon signal, and must be zero upon sigreturn. */
|
||||
unsigned int __glibc_reserved[3];
|
||||
};
|
||||
|
||||
union __riscv_mc_fp_state
|
||||
{
|
||||
struct __riscv_mc_f_ext_state __f;
|
||||
struct __riscv_mc_d_ext_state __d;
|
||||
struct __riscv_mc_q_ext_state __q;
|
||||
};
|
||||
|
||||
typedef struct mcontext_t
|
||||
{
|
||||
__riscv_mc_gp_state __gregs;
|
||||
union __riscv_mc_fp_state __fpregs;
|
||||
} mcontext_t;
|
||||
|
||||
/* Userlevel context. */
|
||||
typedef struct ucontext_t
|
||||
{
|
||||
unsigned long int __uc_flags;
|
||||
struct ucontext_t *uc_link;
|
||||
stack_t uc_stack;
|
||||
sigset_t uc_sigmask;
|
||||
/* There's some padding here to allow sigset_t to be expanded in the
|
||||
future. Though this is unlikely, other architectures put uc_sigmask
|
||||
at the end of this structure and explicitly state it can be
|
||||
expanded, so we didn't want to box ourselves in here. */
|
||||
char __glibc_reserved[1024 / 8 - sizeof (sigset_t)];
|
||||
/* We can't put uc_sigmask at the end of this structure because we need
|
||||
to be able to expand sigcontext in the future. For example, the
|
||||
vector ISA extension will almost certainly add ISA state. We want
|
||||
to ensure all user-visible ISA state can be saved and restored via a
|
||||
ucontext, so we're putting this at the end in order to allow for
|
||||
infinite extensibility. Since we know this will be extended and we
|
||||
assume sigset_t won't be extended an extreme amount, we're
|
||||
prioritizing this. */
|
||||
mcontext_t uc_mcontext;
|
||||
} ucontext_t;
|
||||
|
||||
#endif /* sys/ucontext.h */
|
23
sysdeps/unix/sysv/linux/riscv/sys/user.h
Normal file
23
sysdeps/unix/sysv/linux/riscv/sys/user.h
Normal file
@ -0,0 +1,23 @@
|
||||
/* Copyright (C) 2001-2018 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
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef _SYS_USER_H
|
||||
#define _SYS_USER_H 1
|
||||
|
||||
|
||||
|
||||
#endif /* _SYS_USER_H */
|
Reference in New Issue
Block a user