diff options
author | Waldemar Brodkorb <wbx@openadk.org> | 2024-03-03 05:15:14 +0100 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2024-03-03 05:15:50 +0100 |
commit | 1be78c337c45d8a090ae9c658a9146b5ada620b1 (patch) | |
tree | c2057ff3b5fd25856e39916a64acd4cb642926d7 /libc/sysdeps/linux/riscv32/sys | |
parent | 5e99f71185dc0ef42d4e8c9972cf57f76df5df04 (diff) |
riscv32: decouple from riscv64
Diffstat (limited to 'libc/sysdeps/linux/riscv32/sys')
-rw-r--r-- | libc/sysdeps/linux/riscv32/sys/asm.h | 67 | ||||
-rw-r--r-- | libc/sysdeps/linux/riscv32/sys/procfs.h | 114 | ||||
-rw-r--r-- | libc/sysdeps/linux/riscv32/sys/ucontext.h | 108 | ||||
-rw-r--r-- | libc/sysdeps/linux/riscv32/sys/user.h | 1 |
4 files changed, 290 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/riscv32/sys/asm.h b/libc/sysdeps/linux/riscv32/sys/asm.h new file mode 100644 index 000000000..3c94c9a70 --- /dev/null +++ b/libc/sysdeps/linux/riscv32/sys/asm.h @@ -0,0 +1,67 @@ +/* Miscellaneous macros. + Copyright (C) 2000-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_ASM_H +#define _SYS_ASM_H + +/* Macros to handle different pointer/register sizes for 32/64-bit code. */ +#if __riscv_xlen == 64 +# define PTRLOG 3 +# define SZREG 8 +# define REG_S sd +# define REG_L ld +#elif __riscv_xlen == 32 +# define PTRLOG 2 +# define SZREG 4 +# define REG_S sw +# define REG_L lw +// # warning "rv32i-based targets are experimental" +#else +# error __riscv_xlen must equal 32 or 64 +#endif + +#if !defined __riscv_float_abi_soft +/* For ABI uniformity, reserve 8 bytes for floats, even if double-precision + floating-point is not supported in hardware. */ +# if defined __riscv_float_abi_double +# define FREG_L fld +# define FREG_S fsd +# define SZFREG 8 +# else +# error unsupported FLEN +# endif +#endif + +/* Declare leaf routine. */ +#define LEAF(symbol) \ + .globl symbol; \ + .align 2; \ + .type symbol,@function; \ +symbol: \ + cfi_startproc; + +/* Mark end of function. */ +#undef END +#define END(function) \ + cfi_endproc; \ + .size function,.-function + +/* Stack alignment. */ +#define ALMASK ~15 + +#endif /* sys/asm.h */ diff --git a/libc/sysdeps/linux/riscv32/sys/procfs.h b/libc/sysdeps/linux/riscv32/sys/procfs.h new file mode 100644 index 000000000..518de5674 --- /dev/null +++ b/libc/sysdeps/linux/riscv32/sys/procfs.h @@ -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 */ diff --git a/libc/sysdeps/linux/riscv32/sys/ucontext.h b/libc/sysdeps/linux/riscv32/sys/ucontext.h new file mode 100644 index 000000000..2893ff359 --- /dev/null +++ b/libc/sysdeps/linux/riscv32/sys/ucontext.h @@ -0,0 +1,108 @@ +/* struct ucontext definition, RISC-V version. + Copyright (C) 1997-2018 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/>. */ + +/* 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 <signal.h> +#include <bits/sigcontext.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 */ diff --git a/libc/sysdeps/linux/riscv32/sys/user.h b/libc/sysdeps/linux/riscv32/sys/user.h new file mode 100644 index 000000000..c871f1a03 --- /dev/null +++ b/libc/sysdeps/linux/riscv32/sys/user.h @@ -0,0 +1 @@ +/* This file is not needed, but in practice gdb might try to include it. */ |