Merge pull request #24013 from alexrp/test-matrix

More target coverage in the module test matrix
This commit is contained in:
Andrew Kelley
2025-06-03 17:05:15 -04:00
committed by GitHub
87 changed files with 734 additions and 5951 deletions

View File

@@ -1,58 +0,0 @@
/* $NetBSD: float.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_FLOAT_H_
#define _RISCV_FLOAT_H_
#include <sys/cdefs.h>
#define LDBL_MANT_DIG __LDBL_MANT_DIG__
#define LDBL_DIG __LDBL_DIG__
#define LDBL_MIN_EXP __LDBL_MIN_EXP__
#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__
#define LDBL_MAX_EXP __LDBL_MAX_EXP__
#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
#define LDBL_EPSILON __LDBL_EPSILON__
#define LDBL_MIN __LDBL_MIN__
#define LDBL_MAX __LDBL_MAX__
#include <sys/float_ieee754.h>
#if (!defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) \
&& !defined(_XOPEN_SOURCE)) \
|| (__STDC_VERSION__ - 0) >= 199901L \
|| (_POSIX_C_SOURCE - 0) >= 200112L \
|| ((_XOPEN_SOURCE - 0) >= 600) \
|| defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)
#define DECIMAL_DIG __DECIMAL_DIG__
#endif
#endif /* !_RISCV_FLOAT_H_ */

View File

@@ -1,3 +0,0 @@
/* $NetBSD: ansi.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
#include <sys/common_ansi.h>

View File

@@ -1,40 +0,0 @@
/* $NetBSD: aout_machdep.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_AOUT_MACHDEP_H_
#define _RISCV_AOUT_MACHDEP_H_
#define cpu_exec_aout_makecmds(p, epp) ENOEXEC
/* Size of a page in an object file. */
#define AOUT_LDPGSZ 4096
#endif /* !_RISCV_AOUT_MACHDEP_H_ */

View File

@@ -1,266 +0,0 @@
/* $NetBSD: asm.h,v 1.6 2021/05/01 07:05:07 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_ASM_H
#define _RISCV_ASM_H
#define _C_LABEL(x) x
#define __CONCAT(x,y) x ## y
#define __STRING(x) #x
#define ___CONCAT(x,y) __CONCAT(x,y)
/*
* Define -pg profile entry code.
* Must always be noreorder, must never use a macro instruction
* Final addiu to t9 must always equal the size of this _KERN_MCOUNT
*/
#define _KERN_MCOUNT \
.set push; \
subi sp, sp, CALLFRAME_SIZE; \
REG_S a0, CALLFRAME_S0(sp); \
REG_S ra, CALLFRAME_RA(sp); \
move a0, ra; \
call _mcount \
REG_L ra, CALLFRAME_RA(sp); \
REG_L a0, CALLFRAME_S0(sp); \
addi sp, sp, CALLFRAME_SIZ; \
.set pop;
#ifdef GPROF
#define _PROF_PROLOGUE _KERN_MCOUNT
#else
#define _PROF_PROLOGUE
#endif
#ifdef __PIC__
#define PLT(x) x##@plt
#else
#define PLT(x) x
#endif
/*
* WEAK_ALIAS: create a weak alias.
*/
#define WEAK_ALIAS(alias,sym) \
.weak alias; \
alias = sym
/*
* STRONG_ALIAS: create a strong alias.
*/
#define STRONG_ALIAS(alias,sym) \
.globl alias; \
alias = sym
/*
* WARN_REFERENCES: create a warning if the specified symbol is referenced.
*/
#define WARN_REFERENCES(sym,msg) \
.pushsection __CONCAT(.gnu.warning.,sym); \
.ascii msg; \
.popsection
#define _ENTRY(x) \
.globl _C_LABEL(x); \
.type _C_LABEL(x), @function; \
_C_LABEL(x):
#define ENTRY_NP(x) .text; .align 2; _ENTRY(x)
#define ENTRY(x) ENTRY_NP(x); _PROF_PROLOGUE
#define END(x) .size _C_LABEL(x), . - _C_LABEL(x)
/*
* Macros to panic and printf from assembly language.
*/
#define PANIC(msg) \
la a0, 9f; \
call _C_LABEL(panic); \
MSG(msg)
#define PRINTF(msg) \
la a0, 9f; \
call _C_LABEL(printf); \
MSG(msg)
#define MSG(msg) \
.pushsection .rodata.str1.8,"aMS",@progbits,1; \
9: .asciiz msg; \
.popsection
#define ASMSTR(str) \
.asciiz str; \
.align 3
#define __RCSID(x) .pushsection ".ident","MS",@progbits,1; \
.asciz x; \
.popsection
#define RCSID(name) __RCSID(name)
#if defined(_LP64)
#define SZREG 8
#else
#define SZREG 4
#endif
#define ALSK 15 /* stack alignment */
#define ALMASK -15 /* stack alignment */
#define SZFPREG 8
#define FP_L fld
#define FP_S fsd
/*
* standard callframe {
* register_t cf_sp; frame pointer
* register_t cf_ra; return address
* };
*/
#define CALLFRAME_SIZ (SZREG * 4)
#define CALLFRAME_S1 (CALLFRAME_SIZ - 4 * SZREG)
#define CALLFRAME_S0 (CALLFRAME_SIZ - 3 * SZREG)
#define CALLFRAME_SP (CALLFRAME_SIZ - 2 * SZREG)
#define CALLFRAME_RA (CALLFRAME_SIZ - 1 * SZREG)
/*
* These macros hide the use of rv32 and rv64 instructions from the
* assembler to prevent the assembler from generating 64-bit style
* ABI calls.
*/
#define PTR_ADD add
#define PTR_ADDI addi
#define PTR_SUB sub
#define PTR_SUBI subi
#define PTR_LA la
#define PTR_SLLI slli
#define PTR_SLL sll
#define PTR_SRLI srli
#define PTR_SRL srl
#define PTR_SRAI srai
#define PTR_SRA sra
#if _LP64
#define PTR_L ld
#define PTR_S sd
#define PTR_LR lr.d
#define PTR_SC sc.d
#define PTR_WORD .dword
#define PTR_SCALESHIFT 3
#else
#define PTR_L lw
#define PTR_S sw
#define PTR_LR lr.w
#define PTR_SC sc.w
#define PTR_WORD .word
#define PTR_SCALESHIFT 2
#endif
#define INT_L lw
#define INT_LA la
#define INT_S sw
#define INT_LR lr.w
#define INT_SC sc.w
#define INT_WORD .word
#define INT_SCALESHIFT 2
#ifdef _LP64
#define INT_ADD addw
#define INT_ADDI addwi
#define INT_SUB subw
#define INT_SUBI subwi
#define INT_SLL sllwi
#define INT_SLLV sllw
#define INT_SRL srlwi
#define INT_SRLV srlw
#define INT_SRA srawi
#define INT_SRAV sraw
#else
#define INT_ADD add
#define INT_ADDI addi
#define INT_SUB sub
#define INT_SUBI subi
#define INT_SLLI slli
#define INT_SLL sll
#define INT_SRLI srli
#define INT_SRL srl
#define INT_SRAI srai
#define INT_SRA sra
#endif
#define LONG_LA la
#define LONG_ADD add
#define LONG_ADDI addi
#define LONG_SUB sub
#define LONG_SUBI subi
#define LONG_SLLI slli
#define LONG_SLL sll
#define LONG_SRLI srli
#define LONG_SRL srl
#define LONG_SRAI srai
#define LONG_SRA sra
#ifdef _LP64
#define LONG_L ld
#define LONG_S sd
#define LONG_LR lr.d
#define LONG_SC sc.d
#define LONG_WORD .quad
#define LONG_SCALESHIFT 3
#else
#define LONG_L lw
#define LONG_S sw
#define LONG_LR lr.w
#define LONG_SC sc.w
#define LONG_WORD .word
#define LONG_SCALESHIFT 2
#endif
#define REG_LI li
#define REG_ADD add
#define REG_SLLI slli
#define REG_SLL sll
#define REG_SRLI srli
#define REG_SRL srl
#define REG_SRAI srai
#define REG_SRA sra
#if _LP64
#define REG_L ld
#define REG_S sd
#define REG_LR lr.d
#define REG_SC sc.d
#define REG_SCALESHIFT 3
#else
#define REG_L lw
#define REG_S sw
#define REG_LR lr.w
#define REG_SC sc.w
#define REG_SCALESHIFT 2
#endif
#define CPUVAR(off) _C_LABEL(cpu_info_store)+__CONCAT(CPU_INFO_,off)
#endif /* _RISCV_ASM_H */

View File

@@ -1,11 +0,0 @@
/* $NetBSD: bswap.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
#ifndef _RISCV_BSWAP_H_
#define _RISCV_BSWAP_H_
#include <riscv/byte_swap.h>
#define __BSWAP_RENAME
#include <sys/bswap.h>
#endif /* _RISCV_BSWAP_H_ */

View File

@@ -1,8 +0,0 @@
/* $NetBSD: cdefs.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
#ifndef _RISCV_CDEFS_H_
#define _RISCV_CDEFS_H_
#define __ALIGNBYTES (__BIGGEST_ALIGNMENT__ - 1U)
#endif /* _RISCV_CDEFS_H_ */

View File

@@ -1,153 +0,0 @@
/* $NetBSD: cpu.h,v 1.9 2022/11/17 09:50:23 simonb Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_CPU_H_
#define _RISCV_CPU_H_
#if defined(_KERNEL) || defined(_KMEMUSER)
struct clockframe {
vaddr_t cf_epc;
register_t cf_status;
int cf_intr_depth;
};
#define CLKF_USERMODE(cf) (((cf)->cf_status & SR_SPP) == 0)
#define CLKF_PC(cf) ((cf)->cf_epc)
#define CLKF_INTR(cf) ((cf)->cf_intr_depth > 0)
#include <sys/cpu_data.h>
#include <sys/device_if.h>
#include <sys/evcnt.h>
#include <sys/intr.h>
struct cpu_info {
struct cpu_data ci_data;
device_t ci_dev;
cpuid_t ci_cpuid;
struct lwp *ci_curlwp;
struct lwp *ci_onproc; /* current user LWP / kthread */
struct lwp *ci_softlwps[SOFTINT_COUNT];
struct trapframe *ci_ddb_regs;
uint64_t ci_lastintr;
int ci_mtx_oldspl;
int ci_mtx_count;
int ci_want_resched;
int ci_cpl;
u_int ci_softints;
volatile u_int ci_intr_depth;
tlb_asid_t ci_pmap_asid_cur;
union pmap_segtab *ci_pmap_user_segtab;
#ifdef _LP64
union pmap_segtab *ci_pmap_user_seg0tab;
#endif
struct evcnt ci_ev_fpu_saves;
struct evcnt ci_ev_fpu_loads;
struct evcnt ci_ev_fpu_reenables;
#if defined(GPROF) && defined(MULTIPROCESSOR)
struct gmonparam *ci_gmon; /* MI per-cpu GPROF */
#endif
};
#endif /* _KERNEL || _KMEMUSER */
#ifdef _KERNEL
extern struct cpu_info cpu_info_store;
// This is also in <sys/lwp.h>
struct lwp;
static inline struct cpu_info *lwp_getcpu(struct lwp *);
register struct lwp *riscv_curlwp __asm("tp");
#define curlwp riscv_curlwp
#define curcpu() lwp_getcpu(curlwp)
static inline cpuid_t
cpu_number(void)
{
#ifdef MULTIPROCESSOR
return curcpu()->ci_cpuid;
#else
return 0;
#endif
}
void cpu_proc_fork(struct proc *, struct proc *);
void cpu_signotify(struct lwp *);
void cpu_need_proftick(struct lwp *l);
void cpu_boot_secondary_processors(void);
#define CPU_INFO_ITERATOR cpuid_t
#ifdef MULTIPROCESSOR
#define CPU_INFO_FOREACH(cii, ci) \
(cii) = 0; ((ci) = cpu_infos[cii]) != NULL; (cii)++
#else
#define CPU_INFO_FOREACH(cii, ci) \
(cii) = 0, (ci) = curcpu(); (cii) == 0; (cii)++
#endif
#define CPU_INFO_CURPMAP(ci) (curlwp->l_proc->p_vmspace->vm_map.pmap)
static inline void
cpu_dosoftints(void)
{
extern void dosoftints(void);
struct cpu_info * const ci = curcpu();
if (ci->ci_intr_depth == 0
&& (ci->ci_data.cpu_softints >> ci->ci_cpl) > 0)
dosoftints();
}
static inline bool
cpu_intr_p(void)
{
return curcpu()->ci_intr_depth > 0;
}
#define LWP_PC(l) cpu_lwp_pc(l)
vaddr_t cpu_lwp_pc(struct lwp *);
static inline void
cpu_idle(void)
{
}
#endif /* _KERNEL */
#endif /* _RISCV_CPU_H_ */

View File

@@ -1,68 +0,0 @@
/* $NetBSD: disklabel.h,v 1.2 2022/05/24 19:37:39 andvar Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_DISKLABEL_H_
#define _RISCV_DISKLABEL_H_
#define LABELUSESMBR 1 /* use MBR partitionning */
#define LABELSECTOR 1 /* sector containing label */
#define LABELOFFSET 0 /* offset of label in sector */
#define MAXPARTITIONS 16 /* number of partitions */
#define RAW_PART 2 /* raw partition: XX?c */
#if HAVE_NBTOOL_CONFIG_H
#include <nbinclude/sys/dkbad.h>
#include <nbinclude/sys/bootblock.h>
#else
#include <sys/dkbad.h>
#include <sys/bootblock.h>
#endif /* HAVE_NBTOOL_CONFIG_H */
struct cpu_disklabel {
struct mbr_partition mbrparts[MBR_PART_COUNT];
#define __HAVE_DISKLABEL_DKBAD
struct dkbad bad;
};
#ifdef _KERNEL
struct buf;
struct disklabel;
/* for readdisklabel. rv != 0 -> matches, msg == NULL -> success */
int mbr_label_read(dev_t, void (*)(struct buf *), struct disklabel *,
struct cpu_disklabel *, const char **, int *, int *);
/* for writedisklabel. rv == 0 -> doesn't match, rv > 0 -> success */
int mbr_label_locate(dev_t, void (*)(struct buf *),
struct disklabel *, struct cpu_disklabel *, int *, int *);
#endif /* _KERNEL */
#endif /* _RISCV_DISKLABEL_H_ */

View File

@@ -1,144 +0,0 @@
/* $NetBSD: elf_machdep.h,v 1.9 2022/12/03 08:54:38 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_ELF_MACHDEP_H_
#define _RISCV_ELF_MACHDEP_H_
#define ELF32_MACHDEP_ID EM_RISCV
#define ELF64_MACHDEP_ID EM_RISCV
#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB
#define ELF64_MACHDEP_ENDIANNESS ELFDATA2LSB
#define ELF32_MACHDEP_ID_CASES \
case EM_RISCV: \
break;
#define ELF64_MACHDEP_ID_CASES \
case EM_RISCV: \
break;
#ifdef _LP64
#define KERN_ELFSIZE 64
#define ARCH_ELFSIZE 64 /* MD native binary size */
#else
#define KERN_ELFSIZE 32
#define ARCH_ELFSIZE 32 /* MD native binary size */
#endif
/* Processor specific flags for the ELF header e_flags field. */
/* Processor specific relocation types */
#define R_RISCV_NONE 0
#define R_RISCV_32 1 // A
#define R_RISCV_64 2
#define R_RISCV_RELATIVE 3
#define R_RISCV_COPY 4
#define R_RISCV_JMP_SLOT 5
#define R_RISCV_TLS_DTPMOD32 6
#define R_RISCV_TLS_DTPMOD64 7
#define R_RISCV_TLS_DTPREL32 8
#define R_RISCV_TLS_DTPREL64 9
#define R_RISCV_TLS_TPREL32 10
#define R_RISCV_TLS_TPREL64 11
/* The rest are not used by the dynamic linker */
#define R_RISCV_BRANCH 16 // (A - P) & 0xffff
#define R_RISCV_JAL 17 // A & 0xff
#define R_RISCV_CALL 18 // (A - P) & 0xff
#define R_RISCV_CALL_PLT 19
#define R_RISCV_GOT_HI20 20
#define R_RISCV_TLS_GOT_HI20 21
#define R_RISCV_TLS_GD_HI20 22
#define R_RISCV_PCREL_HI20 23
#define R_RISCV_PCREL_LO12_I 24
#define R_RISCV_PCREL_LO12_S 25
#define R_RISCV_HI20 26 // A & 0xffff
#define R_RISCV_LO12_I 27 // (A >> 16) & 0xffff
#define R_RISCV_LO12_S 28 // (S + A - P) >> 2
#define R_RISCV_TPREL_HI20 29
#define R_RISCV_TPREL_LO12_I 30
#define R_RISCV_TPREL_LO12_S 31
#define R_RISCV_TPREL_ADD 32
#define R_RISCV_ADD8 33
#define R_RISCV_ADD16 34
#define R_RISCV_ADD32 35
#define R_RISCV_ADD64 36
#define R_RISCV_SUB8 37
#define R_RISCV_SUB16 38
#define R_RISCV_SUB32 39
#define R_RISCV_SUB64 40
#define R_RISCV_GNU_VTINHERIT 41 // A & 0xffff
#define R_RISCV_GNU_VTENTRY 42
#define R_RISCV_ALIGN 43
#define R_RISCV_RVC_BRANCH 44
#define R_RISCV_RVC_JUMP 45
#define R_RISCV_RVC_LUI 46
#define R_RISCV_GPREL_I 47
#define R_RISCV_GPREL_S 48
#define R_RISCV_TPREL_I 49
#define R_RISCV_TPREL_S 50
#define R_RISCV_RELAX 51
#define R_RISCV_SUB6 52
#define R_RISCV_SET6 53
#define R_RISCV_SET8 54
#define R_RISCV_SET16 55
#define R_RISCV_SET32 56
#define R_RISCV_32_PCREL 57
/* These are aliases we can use R_TYPESZ */
#define R_RISCV_ADDR32 R_RISCV_32
#define R_RISCV_ADDR64 R_RISCV_64
#define R_TYPE(name) R_RISCV_ ## name
#if ELFSIZE == 32
#define R_TYPESZ(name) R_RISCV_ ## name ## 32
#else
#define R_TYPESZ(name) R_RISCV_ ## name ## 64
#endif
#ifdef _KERNEL
#ifdef ELFSIZE
#define ELF_MD_PROBE_FUNC ELFNAME2(cpu_netbsd,probe)
#endif
struct exec_package;
int cpu_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *,
vaddr_t *);
int cpu_netbsd_elf64_probe(struct lwp *, struct exec_package *, void *, char *,
vaddr_t *);
#endif /* _KERNEL */
#endif /* _RISCV_ELF_MACHDEP_H_ */

View File

@@ -1,3 +0,0 @@
/* $NetBSD: endian.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
#include <sys/endian.h>

View File

@@ -1,3 +0,0 @@
/* $NetBSD: endian_machdep.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
#define _BYTE_ORDER _LITTLE_ENDIAN

View File

@@ -1,35 +0,0 @@
/* $NetBSD: fenv.h,v 1.3 2020/03/14 16:12:16 skrll Exp $ */
/*
* Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995
* Public domain.
*/
#ifndef _RISCV_FENV_H_
#define _RISCV_FENV_H_
typedef int fenv_t; /* FPSCR */
typedef int fexcept_t;
#define FE_INEXACT 0x00 /* Result inexact */
#define FE_UNDERFLOW 0x02 /* Result underflowed */
#define FE_OVERFLOW 0x04 /* Result overflowed */
#define FE_DIVBYZERO 0x08 /* divide-by-zero */
#define FE_INVALID 0x10 /* Result invalid */
#define FE_ALL_EXCEPT 0x1f
#define FE_TONEAREST 0 /* round to nearest representable number */
#define FE_TOWARDZERO 1 /* round to zero (truncate) */
#define FE_DOWNWARD 2 /* round toward negative infinity */
#define FE_UPWARD 3 /* round toward positive infinity */
__BEGIN_DECLS
/* Default floating-point environment */
extern const fenv_t __fe_dfl_env;
#define FE_DFL_ENV (&__fe_dfl_env)
__END_DECLS
#endif /* _RISCV_FENV_H_ */

View File

@@ -1,58 +0,0 @@
/* $NetBSD: float.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_FLOAT_H_
#define _RISCV_FLOAT_H_
#include <sys/cdefs.h>
#define LDBL_MANT_DIG __LDBL_MANT_DIG__
#define LDBL_DIG __LDBL_DIG__
#define LDBL_MIN_EXP __LDBL_MIN_EXP__
#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__
#define LDBL_MAX_EXP __LDBL_MAX_EXP__
#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
#define LDBL_EPSILON __LDBL_EPSILON__
#define LDBL_MIN __LDBL_MIN__
#define LDBL_MAX __LDBL_MAX__
#include <sys/float_ieee754.h>
#if (!defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) \
&& !defined(_XOPEN_SOURCE)) \
|| (__STDC_VERSION__ - 0) >= 199901L \
|| (_POSIX_C_SOURCE - 0) >= 200112L \
|| ((_XOPEN_SOURCE - 0) >= 600) \
|| defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)
#define DECIMAL_DIG __DECIMAL_DIG__
#endif
#endif /* !_RISCV_FLOAT_H_ */

View File

@@ -1,4 +0,0 @@
/* $NetBSD: ieee.h,v 1.2 2019/04/13 15:57:31 maya Exp $ */
#include <riscv/math.h> /* for #define __HAVE_LONG_DOUBLE 128 */
#include <sys/ieee754.h>

View File

@@ -1,44 +0,0 @@
/* $NetBSD: ieeefp.h,v 1.2 2020/03/14 16:12:16 skrll Exp $ */
/*
* Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995
* Public domain.
*/
#ifndef _RISCV_IEEEFP_H_
#define _RISCV_IEEEFP_H_
#include <sys/featuretest.h>
#if defined(_NETBSD_SOURCE) || defined(_ISOC99_SOURCE)
#include <riscv/fenv.h>
#if !defined(_ISOC99_SOURCE)
/* Exception type (used by fpsetmask() et al.) */
typedef int fp_except;
/* Bit defines for fp_except */
#define FP_X_INV FE_INVALID /* invalid operation exception */
#define FP_X_DZ FE_DIVBYZERO /* divide-by-zero exception */
#define FP_X_OFL FE_OVERFLOW /* overflow exception */
#define FP_X_UFL FE_UNDERFLOW /* underflow exception */
#define FP_X_IMP FE_INEXACT /* imprecise (prec. loss; "inexact") */
/* Rounding modes */
typedef enum {
FP_RN=FE_TONEAREST, /* round to nearest representable number */
FP_RP=FE_UPWARD, /* round toward positive infinity */
FP_RM=FE_DOWNWARD, /* round toward negative infinity */
FP_RZ=FE_TOWARDZERO /* round to zero (truncate) */
} fp_rnd;
#endif /* !_ISOC99_SOURCE */
#endif /* _NETBSD_SOURCE || _ISOC99_SOURCE */
#endif /* _RISCV_IEEEFP_H_ */

View File

@@ -1,20 +0,0 @@
/* $NetBSD: int_const.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
#ifndef __INTMAX_C_SUFFIX__
#define __INT8_C_SUFFIX__
#define __INT16_C_SUFFIX__
#define __INT32_C_SUFFIX__
#define __INT64_C_SUFFIX__ LL
#define __UINT8_C_SUFFIX__
#define __UINT16_C_SUFFIX__
#define __UINT32_C_SUFFIX__
#define __UINT64_C_SUFFIX__ ULL
#define __INTMAX_C_SUFFIX__ LL
#define __UINTMAX_C_SUFFIX__ ULL
#endif
#include <sys/common_int_const.h>

View File

@@ -1,381 +0,0 @@
/* $NetBSD: int_fmtio.h,v 1.4 2019/04/17 11:01:19 mrg Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_INT_FMTIO_H_
#define _RISCV_INT_FMTIO_H_
#ifdef __INTPTR_FMTd__
#include <sys/common_int_fmtio.h>
#else
/*
* 7.8.1 Macros for format specifiers
*/
/* fprintf macros for signed integers */
#define PRId8 "hhd" /* int8_t */
#define PRId16 "hd" /* int16_t */
#define PRId32 "d" /* int32_t */
#ifdef _LP64
#define PRId64 "ld" /* int64_t */
#else
#define PRId64 "lld" /* int64_t */
#endif
#define PRIdLEAST8 "hhd" /* int_least8_t */
#define PRIdLEAST16 "hd" /* int_least16_t */
#define PRIdLEAST32 "d" /* int_least32_t */
#ifdef _LP64
#define PRIdLEAST64 "ld" /* int_least64_t */
#define PRIdFAST8 "d" /* int_fast8_t */
#define PRIdFAST16 "d" /* int_fast16_t */
#else
#define PRIdLEAST64 "lld" /* int_least64_t */
#define PRIdFAST8 "hhd" /* int_fast8_t */
#define PRIdFAST16 "hd" /* int_fast16_t */
#endif
#define PRIdFAST32 "d" /* int_fast32_t */
#ifdef _LP64
#define PRIdFAST64 "ld" /* int_fast64_t */
#define PRIdMAX "ld" /* intmax_t */
#else
#define PRIdFAST64 "lld" /* int_fast64_t */
#define PRIdMAX "lld" /* intmax_t */
#endif
#define PRIdPTR "ld" /* intptr_t */
#define PRIi8 "hhi" /* int8_t */
#define PRIi16 "hi" /* int16_t */
#define PRIi32 "i" /* int32_t */
#ifdef _LP64
#define PRIi64 "li" /* int64_t */
#else
#define PRIi64 "lli" /* int64_t */
#endif
#define PRIiLEAST8 "hhi" /* int_least8_t */
#define PRIiLEAST16 "hi" /* int_least16_t */
#define PRIiLEAST32 "i" /* int_least32_t */
#ifdef _LP64
#define PRIiLEAST64 "li" /* int_least64_t */
#define PRIiFAST8 "i" /* int_fast8_t */
#define PRIiFAST16 "i" /* int_fast16_t */
#else
#define PRIiLEAST64 "lli" /* int_least64_t */
#define PRIiFAST8 "hhi" /* int_fast8_t */
#define PRIiFAST16 "hi" /* int_fast16_t */
#endif
#define PRIiFAST32 "i" /* int_fast32_t */
#ifdef _LP64
#define PRIiFAST64 "li" /* int_fast64_t */
#define PRIiMAX "li" /* intmax_t */
#else
#define PRIiFAST64 "lli" /* int_fast64_t */
#define PRIiMAX "lli" /* intmax_t */
#endif
#define PRIiPTR "li" /* intptr_t */
/* fprintf macros for unsigned integers */
#define PRIo8 "hho" /* uint8_t */
#define PRIo16 "ho" /* uint16_t */
#define PRIo32 "o" /* uint32_t */
#ifdef _LP64
#define PRIo64 "lo" /* uint64_t */
#else
#define PRIo64 "llo" /* uint64_t */
#endif
#define PRIoLEAST8 "o" /* uint_least8_t */
#define PRIoLEAST16 "hho" /* uint_least16_t */
#define PRIoLEAST32 "ho" /* uint_least32_t */
#ifdef _LP64
#define PRIoLEAST64 "lo" /* uint_least64_t */
#define PRIoFAST8 "o" /* uint_fast8_t */
#define PRIoFAST16 "o" /* uint_fast16_t */
#else
#define PRIoLEAST64 "llo" /* uint_least64_t */
#define PRIoFAST8 "hho" /* uint_fast8_t */
#define PRIoFAST16 "ho" /* uint_fast16_t */
#endif
#define PRIoFAST32 "o" /* uint_fast32_t */
#ifdef _LP64
#define PRIoFAST64 "lo" /* uint_fast64_t */
#define PRIoMAX "lo" /* uintmax_t */
#else
#define PRIoFAST64 "llo" /* uint_fast64_t */
#define PRIoMAX "llo" /* uintmax_t */
#endif
#define PRIoPTR "lo" /* uintptr_t */
#define PRIu8 "hhu" /* uint8_t */
#define PRIu16 "hu" /* uint16_t */
#define PRIu32 "u" /* uint32_t */
#ifdef _LP64
#define PRIu64 "lu" /* uint64_t */
#else
#define PRIu64 "llu" /* uint64_t */
#endif
#define PRIuLEAST8 "hhu" /* uint_least8_t */
#define PRIuLEAST16 "hu" /* uint_least16_t */
#define PRIuLEAST32 "u" /* uint_least32_t */
#ifdef _LP64
#define PRIuLEAST64 "lu" /* uint_least64_t */
#define PRIuFAST8 "u" /* uint_fast8_t */
#define PRIuFAST16 "u" /* uint_fast16_t */
#else
#define PRIuLEAST64 "llu" /* uint_least64_t */
#define PRIuFAST8 "hhu" /* uint_fast8_t */
#define PRIuFAST16 "hu" /* uint_fast16_t */
#endif
#define PRIuFAST32 "u" /* uint_fast32_t */
#ifdef _LP64
#define PRIuFAST64 "lu" /* uint_fast64_t */
#define PRIuMAX "lu" /* uintmax_t */
#else
#define PRIuFAST64 "llu" /* uint_fast64_t */
#define PRIuMAX "llu" /* uintmax_t */
#endif
#define PRIuPTR "lu" /* uintptr_t */
#define PRIx8 "hhx" /* uint8_t */
#define PRIx16 "hx" /* uint16_t */
#define PRIx32 "x" /* uint32_t */
#ifdef _LP64
#define PRIx64 "lx" /* uint64_t */
#else
#define PRIx64 "llx" /* uint64_t */
#endif
#define PRIxLEAST8 "x" /* uint_least8_t */
#define PRIxLEAST16 "x" /* uint_least16_t */
#define PRIxLEAST32 "x" /* uint_least32_t */
#ifdef _LP64
#define PRIxLEAST64 "lx" /* uint_least64_t */
#define PRIxFAST8 "x" /* uint_fast8_t */
#define PRIxFAST16 "x" /* uint_fast16_t */
#else
#define PRIxLEAST64 "llx" /* uint_least64_t */
#define PRIxFAST8 "hhx" /* uint_fast8_t */
#define PRIxFAST16 "hx" /* uint_fast16_t */
#endif
#define PRIxFAST32 "x" /* uint_fast32_t */
#ifdef _LP64
#define PRIxFAST64 "lx" /* uint_fast64_t */
#define PRIxMAX "lx" /* uintmax_t */
#else
#define PRIxFAST64 "llx" /* uint_fast64_t */
#define PRIxMAX "llx" /* uintmax_t */
#endif
#define PRIxPTR "lx" /* uintptr_t */
#define PRIX8 "hhX" /* uint8_t */
#define PRIX16 "hX" /* uint16_t */
#define PRIX32 "X" /* uint32_t */
#ifdef _LP64
#define PRIX64 "lX" /* uint64_t */
#else
#define PRIX64 "llX" /* uint64_t */
#endif
#define PRIXLEAST8 "X" /* uint_least8_t */
#define PRIXLEAST16 "X" /* uint_least16_t */
#define PRIXLEAST32 "X" /* uint_least32_t */
#ifdef _LP64
#define PRIXLEAST64 "lX" /* uint_least64_t */
#define PRIXFAST8 "X" /* uint_fast8_t */
#define PRIXFAST16 "X" /* uint_fast16_t */
#else
#define PRIXLEAST64 "llX" /* uint_least64_t */
#define PRIXFAST8 "hhX" /* uint_fast8_t */
#define PRIXFAST16 "hX" /* uint_fast16_t */
#endif
#define PRIXFAST32 "X" /* uint_fast32_t */
#ifdef _LP64
#define PRIXFAST64 "lX" /* uint_fast64_t */
#define PRIXMAX "lX" /* uintmax_t */
#else
#define PRIXFAST64 "llX" /* uint_fast64_t */
#define PRIXMAX "llX" /* uintmax_t */
#endif
#define PRIXPTR "lX" /* uintptr_t */
/* fscanf macros for signed integers */
#define SCNd8 "hhd" /* int8_t */
#define SCNd16 "hd" /* int16_t */
#define SCNd32 "d" /* int32_t */
#ifdef _LP64
#define SCNd64 "ld" /* int64_t */
#else
#define SCNd64 "lld" /* int64_t */
#endif
#define SCNdLEAST8 "hhd" /* int_least8_t */
#define SCNdLEAST16 "hd" /* int_least16_t */
#define SCNdLEAST32 "d" /* int_least32_t */
#ifdef _LP64
#define SCNdLEAST64 "ld" /* int_least64_t */
#define SCNdFAST8 "d" /* int_fast8_t */
#define SCNdFAST16 "d" /* int_fast16_t */
#else
#define SCNdLEAST64 "lld" /* int_least64_t */
#define SCNdFAST8 "hhd" /* int_fast8_t */
#define SCNdFAST16 "hd" /* int_fast16_t */
#endif
#define SCNdFAST32 "d" /* int_fast32_t */
#ifdef _LP64
#define SCNdFAST64 "ld" /* int_fast64_t */
#define SCNdMAX "ld" /* intmax_t */
#else
#define SCNdFAST64 "lld" /* int_fast64_t */
#define SCNdMAX "lld" /* intmax_t */
#endif
#define SCNdPTR "ld" /* intptr_t */
#define SCNi8 "hhi" /* int8_t */
#define SCNi16 "hi" /* int16_t */
#define SCNi32 "i" /* int32_t */
#ifdef _LP64
#define SCNi64 "li" /* int64_t */
#else
#define SCNi64 "lli" /* int64_t */
#endif
#define SCNiLEAST8 "hhi" /* int_least8_t */
#define SCNiLEAST16 "hi" /* int_least16_t */
#define SCNiLEAST32 "i" /* int_least32_t */
#ifdef _LP64
#define SCNiLEAST64 "li" /* int_least64_t */
#define SCNiFAST8 "i" /* int_fast8_t */
#define SCNiFAST16 "i" /* int_fast16_t */
#else
#define SCNiLEAST64 "lli" /* int_least64_t */
#define SCNiFAST8 "hhi" /* int_fast8_t */
#define SCNiFAST16 "hi" /* int_fast16_t */
#endif
#define SCNiFAST32 "i" /* int_fast32_t */
#ifdef _LP64
#define SCNiFAST64 "li" /* int_fast64_t */
#define SCNiMAX "li" /* intmax_t */
#else
#define SCNiFAST64 "lli" /* int_fast64_t */
#define SCNiMAX "lli" /* intmax_t */
#endif
#define SCNiPTR "li" /* intptr_t */
/* fscanf macros for unsigned integers */
#define SCNo8 "hho" /* uint8_t */
#define SCNo16 "ho" /* uint16_t */
#define SCNo32 "o" /* uint32_t */
#ifdef _LP64
#define SCNo64 "lo" /* uint64_t */
#else
#define SCNo64 "llo" /* uint64_t */
#endif
#define SCNoLEAST8 "hho" /* uint_least8_t */
#define SCNoLEAST16 "ho" /* uint_least16_t */
#define SCNoLEAST32 "o" /* uint_least32_t */
#ifdef _LP64
#define SCNoLEAST64 "lo" /* uint_least64_t */
#define SCNoFAST8 "o" /* uint_fast8_t */
#define SCNoFAST16 "o" /* uint_fast16_t */
#else
#define SCNoLEAST64 "llo" /* uint_least64_t */
#define SCNoFAST8 "hho" /* uint_fast8_t */
#define SCNoFAST16 "ho" /* uint_fast16_t */
#endif
#define SCNoFAST32 "o" /* uint_fast32_t */
#ifdef _LP64
#define SCNoFAST64 "lo" /* uint_fast64_t */
#define SCNoMAX "lo" /* uintmax_t */
#else
#define SCNoFAST64 "llo" /* uint_fast64_t */
#define SCNoMAX "llo" /* uintmax_t */
#endif
#define SCNoPTR "lo" /* uintptr_t */
#define SCNu8 "hhu" /* uint8_t */
#define SCNu16 "hu" /* uint16_t */
#define SCNu32 "u" /* uint32_t */
#ifdef _LP64
#define SCNu64 "lu" /* uint64_t */
#else
#define SCNu64 "llu" /* uint64_t */
#endif
#define SCNuLEAST8 "hhu" /* uint_least8_t */
#define SCNuLEAST16 "hu" /* uint_least16_t */
#define SCNuLEAST32 "u" /* uint_least32_t */
#ifdef _LP64
#define SCNuLEAST64 "lu" /* uint_least64_t */
#define SCNuFAST8 "u" /* uint_fast8_t */
#define SCNuFAST16 "u" /* uint_fast16_t */
#else
#define SCNuLEAST64 "llu" /* uint_least64_t */
#define SCNuFAST8 "hhu" /* uint_fast8_t */
#define SCNuFAST16 "hu" /* uint_fast16_t */
#endif
#define SCNuFAST32 "u" /* uint_fast32_t */
#ifdef _LP64
#define SCNuFAST64 "lu" /* uint_fast64_t */
#define SCNuMAX "lu" /* uintmax_t */
#else
#define SCNuFAST64 "llu" /* uint_fast64_t */
#define SCNuMAX "llu" /* uintmax_t */
#endif
#define SCNuPTR "lu" /* uintptr_t */
#define SCNx8 "hhx" /* uint8_t */
#define SCNx16 "hx" /* uint16_t */
#define SCNx32 "x" /* uint32_t */
#ifdef _LP64
#define SCNx64 "lx" /* uint64_t */
#else
#define SCNx64 "llx" /* uint64_t */
#endif
#define SCNxLEAST8 "hhx" /* uint_least8_t */
#define SCNxLEAST16 "hx" /* uint_least16_t */
#define SCNxLEAST32 "x" /* uint_least32_t */
#ifdef _LP64
#define SCNxLEAST64 "lx" /* uint_least64_t */
#define SCNxFAST8 "x" /* uint_fast8_t */
#define SCNxFAST16 "x" /* uint_fast16_t */
#else
#define SCNxLEAST64 "llx" /* uint_least64_t */
#define SCNxFAST8 "hhx" /* uint_fast8_t */
#define SCNxFAST16 "hx" /* uint_fast16_t */
#endif
#define SCNxFAST32 "x" /* uint_fast32_t */
#ifdef _LP64
#define SCNxFAST64 "lx" /* uint_fast64_t */
#define SCNxMAX "lx" /* uintmax_t */
#else
#define SCNxFAST64 "llx" /* uint_fast64_t */
#define SCNxMAX "llx" /* uintmax_t */
#endif
#define SCNxPTR "lx" /* uintptr_t */
#endif /* !__INTPTR_FMTd__ */
#endif /* !_RISCV_INT_FMTIO_H_ */

View File

@@ -1,3 +0,0 @@
/* $NetBSD: int_limits.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
#include <sys/common_int_limits.h>

View File

@@ -1,3 +0,0 @@
/* $NetBSD: int_mwgwtypes.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
#include <sys/common_int_mwgwtypes.h>

View File

@@ -1,3 +0,0 @@
/* $NetBSD: int_types.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
#include <sys/common_int_types.h>

View File

@@ -1,40 +0,0 @@
/* $NetBSD: kcore.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_KCORE_H_
#define _RISCV_KCORE_H_
typedef struct cpu_kcore_hdr {
uint64_t kh_misc[8];
phys_ram_seg_t kh_ramsegs[0];
} cpu_kcore_hdr_t;
#endif /* _RISCV_KCORE_H_ */

View File

@@ -1,3 +0,0 @@
/* $NetBSD: limits.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
#include <sys/common_limits.h>

View File

@@ -1,3 +0,0 @@
/* $NetBSD: lock.h,v 1.4 2015/06/26 14:27:35 matt Exp $ */
#include <sys/common_lock.h>

View File

@@ -1,4 +0,0 @@
/* $NetBSD: math.h,v 1.3 2019/04/16 07:40:02 maya Exp $ */
#define __HAVE_NANF
#define __HAVE_LONG_DOUBLE 128

View File

@@ -1,170 +0,0 @@
/* $NetBSD: mcontext.h,v 1.6 2020/03/14 16:12:16 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_MCONTEXT_H_
#define _RISCV_MCONTEXT_H_
/*
*/
#define _NGREG 32 /* GR1-31 */
#define _NFREG 33 /* F0-31, FCSR */
/*
* This fragment is common to <riscv/mcontext.h> and <riscv/reg.h>
*/
#ifndef _BSD_FPREG_T_
union __fpreg {
__uint64_t u_u64;
double u_d;
};
#define _BSD_FPREG_T_ union __fpreg
#endif
typedef __uint64_t __greg_t;
typedef __greg_t __gregset_t[_NGREG];
typedef __uint32_t __greg32_t;
typedef __greg32_t __gregset32_t[_NGREG];
typedef _BSD_FPREG_T_ __fregset_t[_NFREG];
#define _REG_X1 0
#define _REG_X2 1
#define _REG_X3 2
#define _REG_X4 3
#define _REG_X5 4
#define _REG_X6 5
#define _REG_X7 6
#define _REG_X8 7
#define _REG_X9 8
#define _REG_X10 9
#define _REG_X11 10
#define _REG_X12 11
#define _REG_X13 12
#define _REG_X14 13
#define _REG_X15 14
#define _REG_X16 15
#define _REG_X17 16
#define _REG_X18 17
#define _REG_X19 18
#define _REG_X20 19
#define _REG_X21 20
#define _REG_X22 21
#define _REG_X23 22
#define _REG_X24 23
#define _REG_X25 24
#define _REG_X26 25
#define _REG_X27 26
#define _REG_X28 27
#define _REG_X29 28
#define _REG_X30 29
#define _REG_X31 30
#define _REG_PC 31
#define _REG_RA _REG_X1
#define _REG_SP _REG_X2
#define _REG_GP _REG_X3
#define _REG_TP _REG_X4
#define _REG_S0 _REG_X8
#define _REG_RV _REG_X10
#define _REG_A0 _REG_X10
#define _REG_F0 0
#define _REG_FPCSR 32
typedef struct {
__gregset_t __gregs; /* General Purpose Register set */
__fregset_t __fregs; /* Floating Point Register set */
__greg_t __private; /* copy of l_private */
__greg_t __spare[8]; /* future proof */
} mcontext_t;
typedef struct {
__gregset32_t __gregs; /* General Purpose Register set */
__fregset_t __fregs; /* Floating Point Register set */
__greg32_t __private; /* copy of l_private */
__greg32_t __spare[8]; /* future proof */
} mcontext32_t;
/* Machine-dependent uc_flags */
#define _UC_SETSTACK 0x00010000 /* see <sys/ucontext.h> */
#define _UC_CLRSTACK 0x00020000 /* see <sys/ucontext.h> */
#define _UC_TLSBASE 0x00080000 /* see <sys/ucontext.h> */
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP])
#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_S0])
#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC])
#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_RV])
#define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc)
#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || defined(__LIBPTHREAD_SOURCE__)
#include <sys/tls.h>
/*
* On RISCV, since displacements are signed 12-bit values, the TCB pointer is
* not and points to the first static entry.
*/
#define TLS_TP_OFFSET 0x0
#define TLS_DTV_OFFSET 0x800
__CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x800);
static __inline void *
__lwp_getprivate_fast(void)
{
void *__tp;
__asm("move %0,tp" : "=r"(__tp));
return __tp;
}
static __inline void *
__lwp_gettcb_fast(void)
{
void *__tcb;
__asm __volatile(
"addi %[__tcb],tp,%[__offset]"
: [__tcb] "=r" (__tcb)
: [__offset] "n" (-(TLS_TP_OFFSET + sizeof(struct tls_tcb))));
return __tcb;
}
static __inline void
__lwp_settcb(void *__tcb)
{
__asm __volatile(
"addi tp,%[__tcb],%[__offset]"
:
: [__tcb] "r" (__tcb),
[__offset] "n" (TLS_TP_OFFSET + sizeof(struct tls_tcb)));
}
#endif /* _RTLD_SOURCE || _LIBC_SOURCE || __LIBPTHREAD_SOURCE__ */
#endif /* !_RISCV_MCONTEXT_H_ */

View File

@@ -1,124 +0,0 @@
/* $NetBSD: mutex.h,v 1.4.4.1 2023/08/09 17:42:03 martin Exp $ */
/*-
* Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe and Andrew Doran.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_MUTEX_H_
#define _RISCV_MUTEX_H_
#include <sys/types.h>
#ifndef __MUTEX_PRIVATE
struct kmutex {
uintptr_t mtx_pad1;
};
#else /* __MUTEX_PRIVATE */
#include <sys/cdefs.h>
#include <sys/param.h>
#include <machine/intr.h>
struct kmutex {
volatile uintptr_t mtx_owner;
};
#ifdef _LP64
#define MTX_ASMOP_SFX ".d" // doubleword atomic op
#else
#define MTX_ASMOP_SFX ".w" // word atomic op
#endif
#define MTX_LOCK __BIT(8) // just one bit
#define MTX_IPL __BITS(7,4) // only need 4 bits
#undef MUTEX_SPIN_IPL // override <sys/mutex.h>
#define MUTEX_SPIN_IPL(a) riscv_mutex_spin_ipl(a)
#define MUTEX_INITIALIZE_SPIN_IPL(a,b) riscv_mutex_initialize_spin_ipl(a,b)
#define MUTEX_SPINBIT_LOCK_INIT(a) riscv_mutex_spinbit_lock_init(a)
#define MUTEX_SPINBIT_LOCK_TRY(a) riscv_mutex_spinbit_lock_try(a)
#define MUTEX_SPINBIT_LOCKED_P(a) riscv_mutex_spinbit_locked_p(a)
#define MUTEX_SPINBIT_LOCK_UNLOCK(a) riscv_mutex_spinbit_lock_unlock(a)
static inline ipl_cookie_t
riscv_mutex_spin_ipl(kmutex_t *__mtx)
{
return (ipl_cookie_t){._spl = __SHIFTOUT(__mtx->mtx_owner, MTX_IPL)};
}
static inline void
riscv_mutex_initialize_spin_ipl(kmutex_t *__mtx, int ipl)
{
__mtx->mtx_owner = (__mtx->mtx_owner & ~MTX_IPL)
| __SHIFTIN(ipl, MTX_IPL);
}
static inline void
riscv_mutex_spinbit_lock_init(kmutex_t *__mtx)
{
__mtx->mtx_owner &= ~MTX_LOCK;
}
static inline bool
riscv_mutex_spinbit_locked_p(const kmutex_t *__mtx)
{
return (__mtx->mtx_owner & MTX_LOCK) != 0;
}
static inline bool
riscv_mutex_spinbit_lock_try(kmutex_t *__mtx)
{
uintptr_t __old;
__asm __volatile(
"amoor" MTX_ASMOP_SFX ".aq\t%0, %1, (%2)"
: "=r"(__old)
: "r"(MTX_LOCK), "r"(__mtx));
return (__old & MTX_LOCK) == 0;
}
static inline void
riscv_mutex_spinbit_lock_unlock(kmutex_t *__mtx)
{
__asm __volatile(
"amoand" MTX_ASMOP_SFX ".rl\tx0, %0, (%1)"
:: "r"(~MTX_LOCK), "r"(__mtx));
}
#if 0
#define __HAVE_MUTEX_STUBS 1
#define __HAVE_SPIN_MUTEX_STUBS 1
#endif
#define __HAVE_SIMPLE_MUTEXES 1
#endif /* __MUTEX_PRIVATE */
#endif /* _RISCV_MUTEX_H_ */

View File

@@ -1,106 +0,0 @@
/* $NetBSD: param.h,v 1.7 2022/10/12 07:50:00 simonb Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_PARAM_H_
#define _RISCV_PARAM_H_
#ifdef _KERNEL_OPT
#include "opt_param.h"
#endif
/*
* Machine dependent constants for all OpenRISC processors
*/
/*
* For KERNEL code:
* MACHINE must be defined by the individual port. This is so that
* uname returns the correct thing, etc.
*
* For non-KERNEL code:
* If ELF, MACHINE and MACHINE_ARCH are forced to "or1k/or1k".
*/
#ifdef _LP64
#define _MACHINE_ARCH riscv64
#define MACHINE_ARCH "riscv64"
#define _MACHINE_ARCH32 riscv32
#define MACHINE_ARCH32 "riscv32"
#else
#define _MACHINE_ARCH riscv32
#define MACHINE_ARCH "riscv32"
#endif
#define _MACHINE riscv
#define MACHINE "riscv"
#define MID_MACHINE MID_RISCV
/* RISCV-specific macro to align a stack pointer (downwards). */
#define STACK_ALIGNBYTES (__BIGGEST_ALIGNMENT__ - 1)
#define ALIGNBYTES32 __BIGGEST_ALIGNMENT__
#define NKMEMPAGES_MIN_DEFAULT ((128UL * 1024 * 1024) >> PAGE_SHIFT)
#define NKMEMPAGES_MAX_UNLIMITED 1
#define PGSHIFT 12
#define NBPG (1 << PGSHIFT)
#define PGOFSET (NBPG - 1)
#define UPAGES 2
#define USPACE (UPAGES << PGSHIFT)
#define USPACE_ALIGN NBPG
/*
* Constants related to network buffer management.
* MCLBYTES must be no larger than NBPG (the software page size), and
* NBPG % MCLBYTES must be zero.
*/
#define MSIZE 512 /* size of an mbuf */
#ifndef MCLSHIFT
#define MCLSHIFT 11 /* convert bytes to m_buf clusters */
/* 2K cluster can hold Ether frame */
#endif /* MCLSHIFT */
#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */
#ifndef MSGBUFSIZE
#define MSGBUFSIZE 65536 /* default message buffer size */
#endif
#define MAXCPUS 32
#ifdef _KERNEL
void delay(unsigned long);
#define DELAY(x) delay(x)
#endif
#endif /* _RISCV_PARAM_H_ */

View File

@@ -1,46 +0,0 @@
/* $NetBSD: pcb.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_PCB_H_
#define _RISCV_PCB_H_
#include <riscv/reg.h>
struct pcb {
struct fpreg pcb_fpregs;
};
struct md_coredump {
struct reg reg;
struct fpreg fpreg;
};
#endif /* _RISCV_PCB_H_ */

View File

@@ -1,213 +0,0 @@
/* $NetBSD: pmap.h,v 1.13 2022/10/20 07:18:11 skrll Exp $ */
/*
* Copyright (c) 2014, 2019, 2021 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas (of 3am Software Foundry), Maxime Villard, and
* Nick Hudson.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_PMAP_H_
#define _RISCV_PMAP_H_
#ifdef _KERNEL_OPT
#include "opt_modular.h"
#endif
#if !defined(_MODULE)
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/pool.h>
#include <sys/evcnt.h>
#include <uvm/uvm_physseg.h>
#include <uvm/pmap/vmpagemd.h>
#include <riscv/pte.h>
#include <riscv/sysreg.h>
#define PMAP_SEGTABSIZE NPTEPG
#define PMAP_PDETABSIZE NPTEPG
#ifdef _LP64
#define PTPSHIFT 3
/* This is SV48. */
//#define SEGLENGTH + SEGSHIFT + SEGSHIFT */
/* This is SV39. */
#define XSEGSHIFT (SEGSHIFT + SEGLENGTH)
#define NBXSEG (1ULL << XSEGSHIFT)
#define XSEGOFSET (NBXSEG - 1) /* byte offset into xsegment */
#define XSEGLENGTH (PGSHIFT - 3)
#define NXSEGPG (1 << XSEGLENGTH)
#else
#define PTPSHIFT 2
#define XSEGSHIFT SEGSHIFT
#endif
#define SEGLENGTH (PGSHIFT - PTPSHIFT)
#define SEGSHIFT (SEGLENGTH + PGSHIFT)
#define NBSEG (1 << SEGSHIFT) /* bytes/segment */
#define SEGOFSET (NBSEG - 1) /* byte offset into segment */
#define KERNEL_PID 0
#define PMAP_HWPAGEWALKER 1
#define PMAP_TLB_MAX 1
#ifdef _LP64
#define PMAP_INVALID_PDETAB_ADDRESS ((pmap_pdetab_t *)(VM_MIN_KERNEL_ADDRESS - PAGE_SIZE))
#define PMAP_INVALID_SEGTAB_ADDRESS ((pmap_segtab_t *)(VM_MIN_KERNEL_ADDRESS - PAGE_SIZE))
#else
#define PMAP_INVALID_PDETAB_ADDRESS ((pmap_pdetab_t *)0xdeadbeef)
#define PMAP_INVALID_SEGTAB_ADDRESS ((pmap_segtab_t *)0xdeadbeef)
#endif
#define PMAP_TLB_NUM_PIDS (__SHIFTOUT_MASK(SATP_ASID) + 1)
#define PMAP_TLB_BITMAP_LENGTH PMAP_TLB_NUM_PIDS
#define PMAP_TLB_FLUSH_ASID_ON_RESET false
#define pmap_phys_address(x) (x)
#ifndef __BSD_PTENTRY_T__
#define __BSD_PTENTRY_T__
#ifdef _LP64
#define PRIxPTE PRIx64
#else
#define PRIxPTE PRIx32
#endif
#endif /* __BSD_PTENTRY_T__ */
#define PMAP_NEED_PROCWR
static inline void
pmap_procwr(struct proc *p, vaddr_t va, vsize_t len)
{
__asm __volatile("fence\trw,rw; fence.i" ::: "memory");
}
#include <uvm/pmap/tlb.h>
#include <uvm/pmap/pmap_tlb.h>
#define PMAP_GROWKERNEL
#define PMAP_STEAL_MEMORY
#ifdef _KERNEL
#define __HAVE_PMAP_MD
struct pmap_md {
paddr_t md_ppn;
pd_entry_t *md_pdetab;
};
struct vm_page *
pmap_md_alloc_poolpage(int flags);
vaddr_t pmap_md_map_poolpage(paddr_t, vsize_t);
void pmap_md_unmap_poolpage(vaddr_t, vsize_t);
bool pmap_md_direct_mapped_vaddr_p(vaddr_t);
bool pmap_md_io_vaddr_p(vaddr_t);
paddr_t pmap_md_direct_mapped_vaddr_to_paddr(vaddr_t);
vaddr_t pmap_md_direct_map_paddr(paddr_t);
void pmap_md_init(void);
void pmap_md_xtab_activate(struct pmap *, struct lwp *);
void pmap_md_xtab_deactivate(struct pmap *);
void pmap_md_pdetab_init(struct pmap *);
bool pmap_md_ok_to_steal_p(const uvm_physseg_t, size_t);
void pmap_bootstrap(vaddr_t kstart, vaddr_t kend);
extern vaddr_t pmap_direct_base;
extern vaddr_t pmap_direct_end;
#define PMAP_DIRECT_MAP(pa) (pmap_direct_base + (pa))
#define PMAP_DIRECT_UNMAP(va) ((paddr_t)(va) - pmap_direct_base)
#define MEGAPAGE_TRUNC(x) ((x) & ~SEGOFSET)
#define MEGAPAGE_ROUND(x) MEGAPAGE_TRUNC((x) + SEGOFSET)
#ifdef __PMAP_PRIVATE
static inline bool
pmap_md_tlb_check_entry(void *ctx, vaddr_t va, tlb_asid_t asid, pt_entry_t pte)
{
// TLB not walked and so not called.
return false;
}
static inline void
pmap_md_page_syncicache(struct vm_page_md *mdpg, const kcpuset_t *kc)
{
__asm __volatile("fence\trw,rw; fence.i" ::: "memory");
}
/*
* Virtual Cache Alias helper routines. Not a problem for RISCV CPUs.
*/
static inline bool
pmap_md_vca_add(struct vm_page_md *mdpg, vaddr_t va, pt_entry_t *nptep)
{
return false;
}
static inline void
pmap_md_vca_remove(struct vm_page_md *mdpg, vaddr_t va)
{
}
static inline void
pmap_md_vca_clean(struct vm_page_md *mdpg, vaddr_t va, int op)
{
}
static inline size_t
pmap_md_tlb_asid_max(void)
{
return PMAP_TLB_NUM_PIDS - 1;
}
#endif /* __PMAP_PRIVATE */
#endif /* _KERNEL */
#include <uvm/pmap/pmap.h>
#endif /* !_MODULE */
#if defined(MODULAR) || defined(_MODULE)
/*
* Define a compatible vm_page_md so that struct vm_page is the same size
* whether we are using modules or not.
*/
#ifndef __HAVE_VM_PAGE_MD
#define __HAVE_VM_PAGE_MD
struct vm_page_md {
uintptr_t mdpg_dummy[3];
};
__CTASSERT(sizeof(struct vm_page_md) == sizeof(uintptr_t)*3);
#endif /* !__HAVE_VM_PAGE_MD */
#endif /* MODULAR || _MODULE */
#endif /* !_RISCV_PMAP_H_ */

View File

@@ -1,71 +0,0 @@
/* $NetBSD: proc.h,v 1.3 2015/03/31 06:47:47 matt Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_PROC_H_
#define _RISCV_PROC_H_
#include <sys/param.h>
#include <riscv/vmparam.h>
struct lwp;
/*
* Machine-dependent part of the lwp structure for RISCV
*/
struct trapframe;
struct mdlwp {
struct trapframe *md_utf; /* trapframe from userspace */
struct trapframe *md_ktf; /* trapframe from userspace */
struct faultbuf *md_onfault; /* registers to store on fault */
register_t md_usp; /* for locore.S */
vaddr_t md_ss_addr; /* single step address for ptrace */
int md_ss_instr; /* single step instruction for ptrace */
volatile int md_astpending; /* AST pending on return to userland */
#if 0
#if USPACE > PAGE_SIZE
int md_upte[USPACE/4096]; /* ptes for mapping u page */
#else
int md_dpte[USPACE/4096]; /* dummy ptes to keep the same */
#endif
#endif
};
struct mdproc {
/* syscall entry for this process */
void (*md_syscall)(struct trapframe *);
};
#ifdef _KERNEL
#define LWP0_CPU_INFO &cpu_info_store /* staticly set in lwp0 */
#endif /* _KERNEL */
#endif /* _RISCV_PROC_H_ */

View File

@@ -1,91 +0,0 @@
/* $NetBSD: profile.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_PROFILE_H_
#define _RISCV_PROFILE_H_
#define _MCOUNT_DECL void _mcount
/*
* Cannot implement mcount in C as GCC will trash the ip register when it
* pushes a trapframe. Pity we cannot insert assembly before the function
* prologue.
*/
#define MCOUNT_ASM_NAME "__mcount"
#define PLTSYM
#if 0
#define MCOUNT \
__asm(".text"); \
__asm(".align 0"); \
__asm(".type " MCOUNT_ASM_NAME ",@function"); \
__asm(".global " MCOUNT_ASM_NAME); \
__asm(MCOUNT_ASM_NAME ":"); \
/* \
* Preserve registers that are trashed during mcount \
*/ \
__asm("sub sp, sp, #80"); \
__asm("stp x29, x30, [sp, #64]"); \
__asm("add x29, sp, #64"); \
__asm("stp x0, x1, [x29, #0]"); \
__asm("stp x2, x3, [x29, #16]"); \
__asm("stp x4, x5, [x29, #32]"); \
__asm("stp x6, x7, [x29, #48]"); \
/* \
* find the return address for mcount, \
* and the return address for mcount's caller. \
* \
* frompcindex = pc pushed by call into self. \
*/ \
__asm("mov x0, x19"); \
/* \
* selfpc = pc pushed by mcount call \
*/ \
__asm("mov x1, x30"); \
/* \
* Call the real mcount code \
*/ \
__asm("bl " ___STRING(_C_LABEL(_mcount))); \
/* \
* Restore registers that were trashed during mcount \
*/ \
__asm("ldp x0, x1, [x29, #0]"); \
__asm("ldp x2, x3, [x29, #16]"); \
__asm("ldp x4, x5, [x29, #32]"); \
__asm("ldp x6, x7, [x29, #48]"); \
__asm("ldp x29, x30, [x29, #64]"); \
__asm("add sp, sp, #80"); \
__asm("ret"); \
__asm(".size " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME);
#endif
#endif /* _RISCV_PROFILE_H_ */

View File

@@ -1,57 +0,0 @@
/* $NetBSD: ptrace.h,v 1.3 2019/06/18 21:18:12 kamil Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_PTRACE_H_
#define _RISCV_PTRACE_H_
/*
* RISCV-dependent ptrace definitions.
* Note that PT_STEP is _not_ supported.
*/
#define PT_GETREGS (PT_FIRSTMACH + 0)
#define PT_SETREGS (PT_FIRSTMACH + 1)
#define PT_GETFPREGS (PT_FIRSTMACH + 2)
#define PT_SETFPREGS (PT_FIRSTMACH + 3)
#define PT_MACHDEP_STRINGS \
"PT_GETREGS", \
"PT_SETREGS", \
"PT_GETFPREGS", \
"PT_SETFPREGS"
#include <machine/reg.h>
#define PTRACE_REG_PC(r) (r)->r_pc
#define PTRACE_REG_FP(r) (r)->r_reg[7]
#define PTRACE_REG_SET_PC(r, v) (r)->r_pc = (v)
#define PTRACE_REG_SP(r) (r)->r_reg[1]
#define PTRACE_REG_INTRV(r) (r)->r_reg[9]
#endif /* _RISCV_PTRACE_H_ */

View File

@@ -1,125 +0,0 @@
/* $NetBSD: reg.h,v 1.10 2022/12/13 22:25:08 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_REG_H_
#define _RISCV_REG_H_
// x0 = 0
// x1 = ra (return address) Caller
// x2 = sp (stack pointer) Callee
// x3 = gp (global pointer)
// x4 = tp (thread pointer)
// x5 - x7 = t0 - t2 (temporary) Caller
// x8 = s0/fp (saved register / frame pointer) Callee
// x9 = s1 (saved register) Callee
// x10 - x11 = a0 - a1 (arguments/return values) Caller
// x12 - x17 = a2 - a7 (arguments) Caller
// x18 - x27 = s2 - s11 (saved registers) Callee
// x28 - x31 = t3 - t6 (temporaries) Caller
struct reg { // synced with register_t in <riscv/types.h>
#ifdef _LP64
__uint64_t r_reg[31]; /* x0 is always 0 */
__uint64_t r_pc;
#else
__uint32_t r_reg[31]; /* x0 is always 0 */
__uint32_t r_pc;
#endif
};
#ifdef _LP64
struct reg32 { // synced with register_t in <riscv/types.h>
__uint32_t r_reg[31]; /* x0 is always 0 */
__uint32_t r_pc;
};
#endif
#define _XREG(n) ((n) - 1)
#define _X_RA _XREG(1)
#define _X_SP _XREG(2)
#define _X_GP _XREG(3)
#define _X_TP _XREG(4)
#define _X_T0 _XREG(5)
#define _X_T1 _XREG(6)
#define _X_T2 _XREG(7)
#define _X_S0 _XREG(8)
#define _X_S1 _XREG(9)
#define _X_A0 _XREG(10)
#define _X_A1 _XREG(11)
#define _X_A2 _XREG(12)
#define _X_A3 _XREG(13)
#define _X_A4 _XREG(14)
#define _X_A5 _XREG(15)
#define _X_A6 _XREG(16)
#define _X_A7 _XREG(17)
#define _X_S2 _XREG(18)
#define _X_S3 _XREG(19)
#define _X_S4 _XREG(20)
#define _X_S5 _XREG(21)
#define _X_S6 _XREG(22)
#define _X_S7 _XREG(23)
#define _X_S8 _XREG(24)
#define _X_S9 _XREG(25)
#define _X_S10 _XREG(26)
#define _X_S11 _XREG(27)
#define _X_T3 _XREG(28)
#define _X_T4 _XREG(29)
#define _X_T5 _XREG(30)
#define _X_T6 _XREG(31)
// f0 - f7 = ft0 - ft7 (FP temporaries) Caller
// following layout is similar to integer registers above
// f8 - f9 = fs0 - fs1 (FP saved registers) Callee
// f10 - f11 = fa0 - fa1 (FP arguments/return values) Caller
// f12 - f17 = fa2 - fa7 (FP arguments) Caller
// f18 - f27 = fs2 - fa11 (FP saved registers) Callee
// f28 - f31 = ft8 - ft11 (FP temporaries) Caller
/*
* This fragment is common to <riscv/mcontext.h> and <riscv/reg.h>
*/
#ifndef _BSD_FPREG_T_
union __fpreg {
__uint64_t u_u64;
double u_d;
};
#define _BSD_FPREG_T_ union __fpreg
#endif
/*
* 32 double precision floating point, 1 CSR
*/
struct fpreg {
_BSD_FPREG_T_ r_fpreg[33];
};
#define r_fcsr r_fpreg[32].u_u64
#endif /* _RISCV_REG_H_ */

View File

@@ -1 +0,0 @@
/* $NetBSD: rwlock.h,v 1.2 2019/11/29 20:04:53 riastradh Exp $ */

View File

@@ -1,70 +0,0 @@
/* $NetBSD: setjmp.h,v 1.2 2015/03/27 06:57:21 matt Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* magic + 16 reg + 1 fcsr + 12 fp + 4 sigmask + 8 spare */
#define _JBLEN (_JB_SIGMASK + 4 + 8)
#define _JB_MAGIC 0
#define _JB_RA 1
#define _JB_SP 2
#define _JB_GP 3
#define _JB_TP 4
#define _JB_S0 5
#define _JB_S1 6
#define _JB_S2 7
#define _JB_S3 8
#define _JB_S4 9
#define _JB_S5 10
#define _JB_S6 11
#define _JB_S7 12
#define _JB_S8 13
#define _JB_S9 14
#define _JB_S10 15
#define _JB_S11 16
#define _JB_FCSR 17
#define _JB_FS0 18
#define _JB_FS1 (_JB_FS0 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#define _JB_FS2 (_JB_FS1 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#define _JB_FS3 (_JB_FS2 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#define _JB_FS4 (_JB_FS3 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#define _JB_FS5 (_JB_FS4 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#define _JB_FS6 (_JB_FS5 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#define _JB_FS7 (_JB_FS6 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#define _JB_FS8 (_JB_FS7 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#define _JB_FS9 (_JB_FS8 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#define _JB_FS10 (_JB_FS9 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#define _JB_FS11 (_JB_FS10 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#define _JB_SIGMASK (_JB_FS11 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#ifndef _BSD_JBSLOT_T_
#define _BSD_JBSLOT_T_ long long
#endif

View File

@@ -1,39 +0,0 @@
/* $NetBSD: signal.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_SIGNAL_H_
#define _RISCV_SIGNAL_H_
#ifndef _LOCORE
typedef __SIG_ATOMIC_TYPE__ sig_atomic_t;
#endif
#endif /* _RISCV_SIGNAL_H_ */

View File

@@ -1,116 +0,0 @@
/* $NetBSD: types.h,v 1.15 2022/11/08 13:34:17 simonb Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_TYPES_H_
#define _RISCV_TYPES_H_
#include <sys/cdefs.h>
#include <sys/featuretest.h>
#include <riscv/int_types.h>
#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE)
/* XLEN is the native base integer ISA width */
#define XLEN (sizeof(long) * NBBY)
typedef __uint64_t paddr_t;
typedef __uint64_t psize_t;
#define PRIxPADDR PRIx64
#define PRIxPSIZE PRIx64
#define PRIuPSIZE PRIu64
typedef __UINTPTR_TYPE__ vaddr_t;
typedef __UINTPTR_TYPE__ vsize_t;
#define PRIxVADDR PRIxPTR
#define PRIxVSIZE PRIxPTR
#define PRIuVSIZE PRIuPTR
#ifdef _LP64 // match <riscv/reg.h>
#define PRIxREGISTER PRIx64
typedef __int64_t register_t;
typedef __uint64_t uregister_t;
#else
#define PRIxREGISTER PRIx32
typedef __int32_t register_t;
typedef __uint32_t uregister_t;
#endif
typedef signed int register32_t;
typedef unsigned int uregister32_t;
#define PRIxREGISTER32 "x"
typedef unsigned int tlb_asid_t;
#endif
#if defined(_KERNEL)
typedef struct label_t { /* Used by setjmp & longjmp */
register_t lb_reg[16]; /* */
__uint32_t lb_sr;
} label_t;
#endif
typedef unsigned int __cpu_simple_lock_nv_t;
#ifdef _LP64
typedef __int64_t __register_t;
#else
typedef __int32_t __register_t;
#endif
#define __SIMPLELOCK_LOCKED 1
#define __SIMPLELOCK_UNLOCKED 0
#define __HAVE_COMMON___TLS_GET_ADDR
#define __HAVE_COMPAT_NETBSD32
#define __HAVE_CPU_COUNTER
#define __HAVE_CPU_DATA_FIRST
#define __HAVE_FAST_SOFTINTS
#define __HAVE_MM_MD_DIRECT_MAPPED_PHYS
#define __HAVE_NEW_STYLE_BUS_H
#define __HAVE_SYSCALL_INTERN
#define __HAVE_TLS_VARIANT_I
/* XXX temporary */
#define __HAVE_UNLOCKED_PMAP
#define __HAVE___LWP_GETPRIVATE_FAST
#ifdef __LP64
#define __HAVE_ATOMIC64_OPS
#define __HAVE_CPU_UAREA_ROUTINES
#endif
//#if defined(_KERNEL)
//#define __HAVE_RAS
//#endif
#if defined(_KERNEL) || defined(_KMEMUSER)
#define PCU_FPU 0
#define PCU_UNIT_COUNT 1
#endif
#endif /* _RISCV_TYPES_H_ */

View File

@@ -1,203 +0,0 @@
/* $NetBSD: vmparam.h,v 1.13 2022/10/16 06:14:53 skrll Exp $ */
/*-
* Copyright (c) 2014, 2020 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry, and Nick Hudson.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_VMPARAM_H_
#define _RISCV_VMPARAM_H_
#include <riscv/param.h>
#ifdef _KERNEL_OPT
#include "opt_multiprocessor.h"
#endif
/*
* Machine dependent VM constants for RISCV.
*/
/*
* We use a 4K page on both RV64 and RV32 systems.
* Override PAGE_* definitions to compile-time constants.
*/
#define PAGE_SHIFT PGSHIFT
#define PAGE_SIZE (1 << PAGE_SHIFT)
#define PAGE_MASK (PAGE_SIZE - 1)
/*
* USRSTACK is the top (end) of the user stack.
*
* USRSTACK needs to start a page below the maxuser address so that a memory
* access with a maximum displacement (0x7ff) won't cross into the kernel's
* address space. We use PAGE_SIZE instead of 0x800 since these need to be
* page-aligned.
*/
#define USRSTACK (VM_MAXUSER_ADDRESS-PAGE_SIZE) /* Start of user stack */
#define USRSTACK32 ((uint32_t)VM_MAXUSER_ADDRESS32-PAGE_SIZE)
/*
* Virtual memory related constants, all in bytes
*/
#ifndef MAXTSIZ
#define MAXTSIZ (128*1024*1024) /* max text size */
#endif
#ifndef DFLDSIZ
#define DFLDSIZ (256*1024*1024) /* initial data size limit */
#endif
#ifndef MAXDSIZ
#define MAXDSIZ (1536*1024*1024) /* max data size */
#endif
#ifndef DFLSSIZ
#define DFLSSIZ (4*1024*1024) /* initial stack size limit */
#endif
#ifndef MAXSSIZ
#define MAXSSIZ (120*1024*1024) /* max stack size */
#endif
/*
* Virtual memory related constants, all in bytes
*/
#ifndef DFLDSIZ32
#define DFLDSIZ32 DFLDSIZ /* initial data size limit */
#endif
#ifndef MAXDSIZ32
#define MAXDSIZ32 MAXDSIZ /* max data size */
#endif
#ifndef DFLSSIZ32
#define DFLSSIZ32 DFLTSIZ /* initial stack size limit */
#endif
#ifndef MAXSSIZ32
#define MAXSSIZ32 MAXSSIZ /* max stack size */
#endif
/*
* PTEs for mapping user space into the kernel for phyio operations.
* The default PTE number is enough to cover 8 disks * MAXBSIZE.
*/
#ifndef USRIOSIZE
#define USRIOSIZE (MAXBSIZE/PAGE_SIZE * 8)
#endif
/*
* User/kernel map constants.
*/
#define VM_MIN_ADDRESS ((vaddr_t)0x00000000)
#ifdef _LP64 /* Sv39 / Sv48 / Sv57 */
/*
* kernel virtual space layout:
* 0xffff_ffc0_0000_0000 - 64GiB KERNEL VM Space (inc. text/data/bss)
* (0xffff_ffc0_4000_0000 +1GiB) KERNEL VM start of KVA
* (0xffff_ffd0_0000_0000 64GiB) reserved
* 0xffff_ffe0_0000_0000 - 128GiB direct mapping
*/
#define VM_MAXUSER_ADDRESS ((vaddr_t)0x0000004000000000 - 16 * PAGE_SIZE)
#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)0xffffffc000000000)
#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)0xffffffd000000000)
#else /* Sv32 */
#define VM_MAXUSER_ADDRESS ((vaddr_t)-0x7fffffff-1)/* 0xffffffff80000000 */
#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)-0x7fffffff-1)/* 0xffffffff80000000 */
#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)-0x40000000) /* 0xffffffffc0000000 */
#endif
#define VM_KERNEL_BASE VM_MIN_KERNEL_ADDRESS
#define VM_KERNEL_SIZE 0x2000000 /* 32 MiB (8 / 16 megapages) */
#define VM_KERNEL_DTB_BASE (VM_KERNEL_BASE + VM_KERNEL_SIZE)
#define VM_KERNEL_DTB_SIZE 0x1000000 /* 16 MiB (4 / 8 megapages) */
#define VM_KERNEL_IO_BASE (VM_KERNEL_DTB_BASE + VM_KERNEL_DTB_SIZE)
#define VM_KERNEL_IO_SIZE 0x1000000 /* 16 MiB (4 / 8 megapages) */
#define VM_KERNEL_RESERVED (VM_KERNEL_SIZE + VM_KERNEL_DTB_SIZE + VM_KERNEL_IO_SIZE)
#define VM_KERNEL_VM_BASE (VM_MIN_KERNEL_ADDRESS + VM_KERNEL_RESERVED)
#define VM_KERNEL_VM_SIZE (VM_MAX_KERNEL_ADDRESS - VM_KERNEL_VM_BASE)
#define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS
#define VM_MAXUSER_ADDRESS32 ((vaddr_t)(1UL << 31))/* 0x0000000080000000 */
#ifdef _LP64
/*
* Since we have the address space, we map all of physical memory (RAM)
* using gigapages on SV39, terapages on SV48 and petapages on SV57.
*/
#define RISCV_DIRECTMAP_MASK ((vaddr_t) 0xffffffe000000000L)
#define RISCV_DIRECTMAP_SIZE (-RISCV_DIRECTMAP_MASK - PAGE_SIZE) /* 128GiB */
#define RISCV_DIRECTMAP_START RISCV_DIRECTMAP_MASK
#define RISCV_DIRECTMAP_END (RISCV_DIRECTMAP_START + RISCV_DIRECTMAP_SIZE)
#define RISCV_KVA_P(va) (((vaddr_t) (va) & RISCV_DIRECTMAP_MASK) != 0)
#define RISCV_PA_TO_KVA(pa) ((vaddr_t) ((pa) | RISCV_DIRECTMAP_START))
#define RISCV_KVA_TO_PA(va) ((paddr_t) ((va) & ~RISCV_DIRECTMAP_MASK))
#endif
/*
* The address to which unspecified mapping requests default
*/
#define __USE_TOPDOWN_VM
#define VM_DEFAULT_ADDRESS_TOPDOWN(da, sz) \
trunc_page(USRSTACK - MAXSSIZ - (sz) - user_stack_guard_size)
#define VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz) \
round_page((vaddr_t)(da) + (vsize_t)maxdmap)
#define VM_DEFAULT_ADDRESS32_TOPDOWN(da, sz) \
trunc_page(USRSTACK32 - MAXSSIZ32 - (sz) - user_stack_guard_size)
#define VM_DEFAULT_ADDRESS32_BOTTOMUP(da, sz) \
round_page((vaddr_t)(da) + (vsize_t)MAXDSIZ32)
/* virtual sizes (bytes) for various kernel submaps */
#define VM_PHYS_SIZE (USRIOSIZE*PAGE_SIZE)
/* VM_PHYSSEG_MAX defined by platform-dependent code. */
#ifndef VM_PHYSSEG_MAX
#define VM_PHYSSEG_MAX 16
#endif
#if VM_PHYSSEG_MAX == 1
#define VM_PHYSSEG_STRAT VM_PSTRAT_BIGFIRST
#else
#define VM_PHYSSEG_STRAT VM_PSTRAT_BSEARCH
#endif
#define VM_PHYSSEG_NOADD /* can add RAM after vm_mem_init */
#ifndef VM_NFREELIST
#define VM_NFREELIST 2 /* 2 distinct memory segments */
#define VM_FREELIST_DEFAULT 0
#define VM_FREELIST_DIRECTMAP 1
#endif
#ifdef _KERNEL
#define UVM_KM_VMFREELIST riscv_poolpage_vmfreelist
extern int riscv_poolpage_vmfreelist;
#ifdef _LP64
void * cpu_uarea_alloc(bool);
bool cpu_uarea_free(void *);
#endif
#endif
#endif /* ! _RISCV_VMPARAM_H_ */

View File

@@ -1,3 +0,0 @@
/* $NetBSD: wchar_limits.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
#include <sys/common_wchar_limits.h>

View File

@@ -1,58 +0,0 @@
/* $NetBSD: float.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_FLOAT_H_
#define _RISCV_FLOAT_H_
#include <sys/cdefs.h>
#define LDBL_MANT_DIG __LDBL_MANT_DIG__
#define LDBL_DIG __LDBL_DIG__
#define LDBL_MIN_EXP __LDBL_MIN_EXP__
#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__
#define LDBL_MAX_EXP __LDBL_MAX_EXP__
#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
#define LDBL_EPSILON __LDBL_EPSILON__
#define LDBL_MIN __LDBL_MIN__
#define LDBL_MAX __LDBL_MAX__
#include <sys/float_ieee754.h>
#if (!defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) \
&& !defined(_XOPEN_SOURCE)) \
|| (__STDC_VERSION__ - 0) >= 199901L \
|| (_POSIX_C_SOURCE - 0) >= 200112L \
|| ((_XOPEN_SOURCE - 0) >= 600) \
|| defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)
#define DECIMAL_DIG __DECIMAL_DIG__
#endif
#endif /* !_RISCV_FLOAT_H_ */

View File

@@ -1,3 +0,0 @@
/* $NetBSD: ansi.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
#include <sys/common_ansi.h>

View File

@@ -1,40 +0,0 @@
/* $NetBSD: aout_machdep.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_AOUT_MACHDEP_H_
#define _RISCV_AOUT_MACHDEP_H_
#define cpu_exec_aout_makecmds(p, epp) ENOEXEC
/* Size of a page in an object file. */
#define AOUT_LDPGSZ 4096
#endif /* !_RISCV_AOUT_MACHDEP_H_ */

View File

@@ -1,266 +0,0 @@
/* $NetBSD: asm.h,v 1.6 2021/05/01 07:05:07 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_ASM_H
#define _RISCV_ASM_H
#define _C_LABEL(x) x
#define __CONCAT(x,y) x ## y
#define __STRING(x) #x
#define ___CONCAT(x,y) __CONCAT(x,y)
/*
* Define -pg profile entry code.
* Must always be noreorder, must never use a macro instruction
* Final addiu to t9 must always equal the size of this _KERN_MCOUNT
*/
#define _KERN_MCOUNT \
.set push; \
subi sp, sp, CALLFRAME_SIZE; \
REG_S a0, CALLFRAME_S0(sp); \
REG_S ra, CALLFRAME_RA(sp); \
move a0, ra; \
call _mcount \
REG_L ra, CALLFRAME_RA(sp); \
REG_L a0, CALLFRAME_S0(sp); \
addi sp, sp, CALLFRAME_SIZ; \
.set pop;
#ifdef GPROF
#define _PROF_PROLOGUE _KERN_MCOUNT
#else
#define _PROF_PROLOGUE
#endif
#ifdef __PIC__
#define PLT(x) x##@plt
#else
#define PLT(x) x
#endif
/*
* WEAK_ALIAS: create a weak alias.
*/
#define WEAK_ALIAS(alias,sym) \
.weak alias; \
alias = sym
/*
* STRONG_ALIAS: create a strong alias.
*/
#define STRONG_ALIAS(alias,sym) \
.globl alias; \
alias = sym
/*
* WARN_REFERENCES: create a warning if the specified symbol is referenced.
*/
#define WARN_REFERENCES(sym,msg) \
.pushsection __CONCAT(.gnu.warning.,sym); \
.ascii msg; \
.popsection
#define _ENTRY(x) \
.globl _C_LABEL(x); \
.type _C_LABEL(x), @function; \
_C_LABEL(x):
#define ENTRY_NP(x) .text; .align 2; _ENTRY(x)
#define ENTRY(x) ENTRY_NP(x); _PROF_PROLOGUE
#define END(x) .size _C_LABEL(x), . - _C_LABEL(x)
/*
* Macros to panic and printf from assembly language.
*/
#define PANIC(msg) \
la a0, 9f; \
call _C_LABEL(panic); \
MSG(msg)
#define PRINTF(msg) \
la a0, 9f; \
call _C_LABEL(printf); \
MSG(msg)
#define MSG(msg) \
.pushsection .rodata.str1.8,"aMS",@progbits,1; \
9: .asciiz msg; \
.popsection
#define ASMSTR(str) \
.asciiz str; \
.align 3
#define __RCSID(x) .pushsection ".ident","MS",@progbits,1; \
.asciz x; \
.popsection
#define RCSID(name) __RCSID(name)
#if defined(_LP64)
#define SZREG 8
#else
#define SZREG 4
#endif
#define ALSK 15 /* stack alignment */
#define ALMASK -15 /* stack alignment */
#define SZFPREG 8
#define FP_L fld
#define FP_S fsd
/*
* standard callframe {
* register_t cf_sp; frame pointer
* register_t cf_ra; return address
* };
*/
#define CALLFRAME_SIZ (SZREG * 4)
#define CALLFRAME_S1 (CALLFRAME_SIZ - 4 * SZREG)
#define CALLFRAME_S0 (CALLFRAME_SIZ - 3 * SZREG)
#define CALLFRAME_SP (CALLFRAME_SIZ - 2 * SZREG)
#define CALLFRAME_RA (CALLFRAME_SIZ - 1 * SZREG)
/*
* These macros hide the use of rv32 and rv64 instructions from the
* assembler to prevent the assembler from generating 64-bit style
* ABI calls.
*/
#define PTR_ADD add
#define PTR_ADDI addi
#define PTR_SUB sub
#define PTR_SUBI subi
#define PTR_LA la
#define PTR_SLLI slli
#define PTR_SLL sll
#define PTR_SRLI srli
#define PTR_SRL srl
#define PTR_SRAI srai
#define PTR_SRA sra
#if _LP64
#define PTR_L ld
#define PTR_S sd
#define PTR_LR lr.d
#define PTR_SC sc.d
#define PTR_WORD .dword
#define PTR_SCALESHIFT 3
#else
#define PTR_L lw
#define PTR_S sw
#define PTR_LR lr.w
#define PTR_SC sc.w
#define PTR_WORD .word
#define PTR_SCALESHIFT 2
#endif
#define INT_L lw
#define INT_LA la
#define INT_S sw
#define INT_LR lr.w
#define INT_SC sc.w
#define INT_WORD .word
#define INT_SCALESHIFT 2
#ifdef _LP64
#define INT_ADD addw
#define INT_ADDI addwi
#define INT_SUB subw
#define INT_SUBI subwi
#define INT_SLL sllwi
#define INT_SLLV sllw
#define INT_SRL srlwi
#define INT_SRLV srlw
#define INT_SRA srawi
#define INT_SRAV sraw
#else
#define INT_ADD add
#define INT_ADDI addi
#define INT_SUB sub
#define INT_SUBI subi
#define INT_SLLI slli
#define INT_SLL sll
#define INT_SRLI srli
#define INT_SRL srl
#define INT_SRAI srai
#define INT_SRA sra
#endif
#define LONG_LA la
#define LONG_ADD add
#define LONG_ADDI addi
#define LONG_SUB sub
#define LONG_SUBI subi
#define LONG_SLLI slli
#define LONG_SLL sll
#define LONG_SRLI srli
#define LONG_SRL srl
#define LONG_SRAI srai
#define LONG_SRA sra
#ifdef _LP64
#define LONG_L ld
#define LONG_S sd
#define LONG_LR lr.d
#define LONG_SC sc.d
#define LONG_WORD .quad
#define LONG_SCALESHIFT 3
#else
#define LONG_L lw
#define LONG_S sw
#define LONG_LR lr.w
#define LONG_SC sc.w
#define LONG_WORD .word
#define LONG_SCALESHIFT 2
#endif
#define REG_LI li
#define REG_ADD add
#define REG_SLLI slli
#define REG_SLL sll
#define REG_SRLI srli
#define REG_SRL srl
#define REG_SRAI srai
#define REG_SRA sra
#if _LP64
#define REG_L ld
#define REG_S sd
#define REG_LR lr.d
#define REG_SC sc.d
#define REG_SCALESHIFT 3
#else
#define REG_L lw
#define REG_S sw
#define REG_LR lr.w
#define REG_SC sc.w
#define REG_SCALESHIFT 2
#endif
#define CPUVAR(off) _C_LABEL(cpu_info_store)+__CONCAT(CPU_INFO_,off)
#endif /* _RISCV_ASM_H */

View File

@@ -1,11 +0,0 @@
/* $NetBSD: bswap.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
#ifndef _RISCV_BSWAP_H_
#define _RISCV_BSWAP_H_
#include <riscv/byte_swap.h>
#define __BSWAP_RENAME
#include <sys/bswap.h>
#endif /* _RISCV_BSWAP_H_ */

View File

@@ -1,8 +0,0 @@
/* $NetBSD: cdefs.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
#ifndef _RISCV_CDEFS_H_
#define _RISCV_CDEFS_H_
#define __ALIGNBYTES (__BIGGEST_ALIGNMENT__ - 1U)
#endif /* _RISCV_CDEFS_H_ */

View File

@@ -1,153 +0,0 @@
/* $NetBSD: cpu.h,v 1.9 2022/11/17 09:50:23 simonb Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_CPU_H_
#define _RISCV_CPU_H_
#if defined(_KERNEL) || defined(_KMEMUSER)
struct clockframe {
vaddr_t cf_epc;
register_t cf_status;
int cf_intr_depth;
};
#define CLKF_USERMODE(cf) (((cf)->cf_status & SR_SPP) == 0)
#define CLKF_PC(cf) ((cf)->cf_epc)
#define CLKF_INTR(cf) ((cf)->cf_intr_depth > 0)
#include <sys/cpu_data.h>
#include <sys/device_if.h>
#include <sys/evcnt.h>
#include <sys/intr.h>
struct cpu_info {
struct cpu_data ci_data;
device_t ci_dev;
cpuid_t ci_cpuid;
struct lwp *ci_curlwp;
struct lwp *ci_onproc; /* current user LWP / kthread */
struct lwp *ci_softlwps[SOFTINT_COUNT];
struct trapframe *ci_ddb_regs;
uint64_t ci_lastintr;
int ci_mtx_oldspl;
int ci_mtx_count;
int ci_want_resched;
int ci_cpl;
u_int ci_softints;
volatile u_int ci_intr_depth;
tlb_asid_t ci_pmap_asid_cur;
union pmap_segtab *ci_pmap_user_segtab;
#ifdef _LP64
union pmap_segtab *ci_pmap_user_seg0tab;
#endif
struct evcnt ci_ev_fpu_saves;
struct evcnt ci_ev_fpu_loads;
struct evcnt ci_ev_fpu_reenables;
#if defined(GPROF) && defined(MULTIPROCESSOR)
struct gmonparam *ci_gmon; /* MI per-cpu GPROF */
#endif
};
#endif /* _KERNEL || _KMEMUSER */
#ifdef _KERNEL
extern struct cpu_info cpu_info_store;
// This is also in <sys/lwp.h>
struct lwp;
static inline struct cpu_info *lwp_getcpu(struct lwp *);
register struct lwp *riscv_curlwp __asm("tp");
#define curlwp riscv_curlwp
#define curcpu() lwp_getcpu(curlwp)
static inline cpuid_t
cpu_number(void)
{
#ifdef MULTIPROCESSOR
return curcpu()->ci_cpuid;
#else
return 0;
#endif
}
void cpu_proc_fork(struct proc *, struct proc *);
void cpu_signotify(struct lwp *);
void cpu_need_proftick(struct lwp *l);
void cpu_boot_secondary_processors(void);
#define CPU_INFO_ITERATOR cpuid_t
#ifdef MULTIPROCESSOR
#define CPU_INFO_FOREACH(cii, ci) \
(cii) = 0; ((ci) = cpu_infos[cii]) != NULL; (cii)++
#else
#define CPU_INFO_FOREACH(cii, ci) \
(cii) = 0, (ci) = curcpu(); (cii) == 0; (cii)++
#endif
#define CPU_INFO_CURPMAP(ci) (curlwp->l_proc->p_vmspace->vm_map.pmap)
static inline void
cpu_dosoftints(void)
{
extern void dosoftints(void);
struct cpu_info * const ci = curcpu();
if (ci->ci_intr_depth == 0
&& (ci->ci_data.cpu_softints >> ci->ci_cpl) > 0)
dosoftints();
}
static inline bool
cpu_intr_p(void)
{
return curcpu()->ci_intr_depth > 0;
}
#define LWP_PC(l) cpu_lwp_pc(l)
vaddr_t cpu_lwp_pc(struct lwp *);
static inline void
cpu_idle(void)
{
}
#endif /* _KERNEL */
#endif /* _RISCV_CPU_H_ */

View File

@@ -1,68 +0,0 @@
/* $NetBSD: disklabel.h,v 1.2 2022/05/24 19:37:39 andvar Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_DISKLABEL_H_
#define _RISCV_DISKLABEL_H_
#define LABELUSESMBR 1 /* use MBR partitionning */
#define LABELSECTOR 1 /* sector containing label */
#define LABELOFFSET 0 /* offset of label in sector */
#define MAXPARTITIONS 16 /* number of partitions */
#define RAW_PART 2 /* raw partition: XX?c */
#if HAVE_NBTOOL_CONFIG_H
#include <nbinclude/sys/dkbad.h>
#include <nbinclude/sys/bootblock.h>
#else
#include <sys/dkbad.h>
#include <sys/bootblock.h>
#endif /* HAVE_NBTOOL_CONFIG_H */
struct cpu_disklabel {
struct mbr_partition mbrparts[MBR_PART_COUNT];
#define __HAVE_DISKLABEL_DKBAD
struct dkbad bad;
};
#ifdef _KERNEL
struct buf;
struct disklabel;
/* for readdisklabel. rv != 0 -> matches, msg == NULL -> success */
int mbr_label_read(dev_t, void (*)(struct buf *), struct disklabel *,
struct cpu_disklabel *, const char **, int *, int *);
/* for writedisklabel. rv == 0 -> doesn't match, rv > 0 -> success */
int mbr_label_locate(dev_t, void (*)(struct buf *),
struct disklabel *, struct cpu_disklabel *, int *, int *);
#endif /* _KERNEL */
#endif /* _RISCV_DISKLABEL_H_ */

View File

@@ -1,144 +0,0 @@
/* $NetBSD: elf_machdep.h,v 1.9 2022/12/03 08:54:38 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_ELF_MACHDEP_H_
#define _RISCV_ELF_MACHDEP_H_
#define ELF32_MACHDEP_ID EM_RISCV
#define ELF64_MACHDEP_ID EM_RISCV
#define ELF32_MACHDEP_ENDIANNESS ELFDATA2LSB
#define ELF64_MACHDEP_ENDIANNESS ELFDATA2LSB
#define ELF32_MACHDEP_ID_CASES \
case EM_RISCV: \
break;
#define ELF64_MACHDEP_ID_CASES \
case EM_RISCV: \
break;
#ifdef _LP64
#define KERN_ELFSIZE 64
#define ARCH_ELFSIZE 64 /* MD native binary size */
#else
#define KERN_ELFSIZE 32
#define ARCH_ELFSIZE 32 /* MD native binary size */
#endif
/* Processor specific flags for the ELF header e_flags field. */
/* Processor specific relocation types */
#define R_RISCV_NONE 0
#define R_RISCV_32 1 // A
#define R_RISCV_64 2
#define R_RISCV_RELATIVE 3
#define R_RISCV_COPY 4
#define R_RISCV_JMP_SLOT 5
#define R_RISCV_TLS_DTPMOD32 6
#define R_RISCV_TLS_DTPMOD64 7
#define R_RISCV_TLS_DTPREL32 8
#define R_RISCV_TLS_DTPREL64 9
#define R_RISCV_TLS_TPREL32 10
#define R_RISCV_TLS_TPREL64 11
/* The rest are not used by the dynamic linker */
#define R_RISCV_BRANCH 16 // (A - P) & 0xffff
#define R_RISCV_JAL 17 // A & 0xff
#define R_RISCV_CALL 18 // (A - P) & 0xff
#define R_RISCV_CALL_PLT 19
#define R_RISCV_GOT_HI20 20
#define R_RISCV_TLS_GOT_HI20 21
#define R_RISCV_TLS_GD_HI20 22
#define R_RISCV_PCREL_HI20 23
#define R_RISCV_PCREL_LO12_I 24
#define R_RISCV_PCREL_LO12_S 25
#define R_RISCV_HI20 26 // A & 0xffff
#define R_RISCV_LO12_I 27 // (A >> 16) & 0xffff
#define R_RISCV_LO12_S 28 // (S + A - P) >> 2
#define R_RISCV_TPREL_HI20 29
#define R_RISCV_TPREL_LO12_I 30
#define R_RISCV_TPREL_LO12_S 31
#define R_RISCV_TPREL_ADD 32
#define R_RISCV_ADD8 33
#define R_RISCV_ADD16 34
#define R_RISCV_ADD32 35
#define R_RISCV_ADD64 36
#define R_RISCV_SUB8 37
#define R_RISCV_SUB16 38
#define R_RISCV_SUB32 39
#define R_RISCV_SUB64 40
#define R_RISCV_GNU_VTINHERIT 41 // A & 0xffff
#define R_RISCV_GNU_VTENTRY 42
#define R_RISCV_ALIGN 43
#define R_RISCV_RVC_BRANCH 44
#define R_RISCV_RVC_JUMP 45
#define R_RISCV_RVC_LUI 46
#define R_RISCV_GPREL_I 47
#define R_RISCV_GPREL_S 48
#define R_RISCV_TPREL_I 49
#define R_RISCV_TPREL_S 50
#define R_RISCV_RELAX 51
#define R_RISCV_SUB6 52
#define R_RISCV_SET6 53
#define R_RISCV_SET8 54
#define R_RISCV_SET16 55
#define R_RISCV_SET32 56
#define R_RISCV_32_PCREL 57
/* These are aliases we can use R_TYPESZ */
#define R_RISCV_ADDR32 R_RISCV_32
#define R_RISCV_ADDR64 R_RISCV_64
#define R_TYPE(name) R_RISCV_ ## name
#if ELFSIZE == 32
#define R_TYPESZ(name) R_RISCV_ ## name ## 32
#else
#define R_TYPESZ(name) R_RISCV_ ## name ## 64
#endif
#ifdef _KERNEL
#ifdef ELFSIZE
#define ELF_MD_PROBE_FUNC ELFNAME2(cpu_netbsd,probe)
#endif
struct exec_package;
int cpu_netbsd_elf32_probe(struct lwp *, struct exec_package *, void *, char *,
vaddr_t *);
int cpu_netbsd_elf64_probe(struct lwp *, struct exec_package *, void *, char *,
vaddr_t *);
#endif /* _KERNEL */
#endif /* _RISCV_ELF_MACHDEP_H_ */

View File

@@ -1,3 +0,0 @@
/* $NetBSD: endian.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
#include <sys/endian.h>

View File

@@ -1,3 +0,0 @@
/* $NetBSD: endian_machdep.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
#define _BYTE_ORDER _LITTLE_ENDIAN

View File

@@ -1,35 +0,0 @@
/* $NetBSD: fenv.h,v 1.3 2020/03/14 16:12:16 skrll Exp $ */
/*
* Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995
* Public domain.
*/
#ifndef _RISCV_FENV_H_
#define _RISCV_FENV_H_
typedef int fenv_t; /* FPSCR */
typedef int fexcept_t;
#define FE_INEXACT 0x00 /* Result inexact */
#define FE_UNDERFLOW 0x02 /* Result underflowed */
#define FE_OVERFLOW 0x04 /* Result overflowed */
#define FE_DIVBYZERO 0x08 /* divide-by-zero */
#define FE_INVALID 0x10 /* Result invalid */
#define FE_ALL_EXCEPT 0x1f
#define FE_TONEAREST 0 /* round to nearest representable number */
#define FE_TOWARDZERO 1 /* round to zero (truncate) */
#define FE_DOWNWARD 2 /* round toward negative infinity */
#define FE_UPWARD 3 /* round toward positive infinity */
__BEGIN_DECLS
/* Default floating-point environment */
extern const fenv_t __fe_dfl_env;
#define FE_DFL_ENV (&__fe_dfl_env)
__END_DECLS
#endif /* _RISCV_FENV_H_ */

View File

@@ -1,58 +0,0 @@
/* $NetBSD: float.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_FLOAT_H_
#define _RISCV_FLOAT_H_
#include <sys/cdefs.h>
#define LDBL_MANT_DIG __LDBL_MANT_DIG__
#define LDBL_DIG __LDBL_DIG__
#define LDBL_MIN_EXP __LDBL_MIN_EXP__
#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__
#define LDBL_MAX_EXP __LDBL_MAX_EXP__
#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
#define LDBL_EPSILON __LDBL_EPSILON__
#define LDBL_MIN __LDBL_MIN__
#define LDBL_MAX __LDBL_MAX__
#include <sys/float_ieee754.h>
#if (!defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) \
&& !defined(_XOPEN_SOURCE)) \
|| (__STDC_VERSION__ - 0) >= 199901L \
|| (_POSIX_C_SOURCE - 0) >= 200112L \
|| ((_XOPEN_SOURCE - 0) >= 600) \
|| defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)
#define DECIMAL_DIG __DECIMAL_DIG__
#endif
#endif /* !_RISCV_FLOAT_H_ */

View File

@@ -1,4 +0,0 @@
/* $NetBSD: ieee.h,v 1.2 2019/04/13 15:57:31 maya Exp $ */
#include <riscv/math.h> /* for #define __HAVE_LONG_DOUBLE 128 */
#include <sys/ieee754.h>

View File

@@ -1,44 +0,0 @@
/* $NetBSD: ieeefp.h,v 1.2 2020/03/14 16:12:16 skrll Exp $ */
/*
* Based on ieeefp.h written by J.T. Conklin, Apr 28, 1995
* Public domain.
*/
#ifndef _RISCV_IEEEFP_H_
#define _RISCV_IEEEFP_H_
#include <sys/featuretest.h>
#if defined(_NETBSD_SOURCE) || defined(_ISOC99_SOURCE)
#include <riscv/fenv.h>
#if !defined(_ISOC99_SOURCE)
/* Exception type (used by fpsetmask() et al.) */
typedef int fp_except;
/* Bit defines for fp_except */
#define FP_X_INV FE_INVALID /* invalid operation exception */
#define FP_X_DZ FE_DIVBYZERO /* divide-by-zero exception */
#define FP_X_OFL FE_OVERFLOW /* overflow exception */
#define FP_X_UFL FE_UNDERFLOW /* underflow exception */
#define FP_X_IMP FE_INEXACT /* imprecise (prec. loss; "inexact") */
/* Rounding modes */
typedef enum {
FP_RN=FE_TONEAREST, /* round to nearest representable number */
FP_RP=FE_UPWARD, /* round toward positive infinity */
FP_RM=FE_DOWNWARD, /* round toward negative infinity */
FP_RZ=FE_TOWARDZERO /* round to zero (truncate) */
} fp_rnd;
#endif /* !_ISOC99_SOURCE */
#endif /* _NETBSD_SOURCE || _ISOC99_SOURCE */
#endif /* _RISCV_IEEEFP_H_ */

View File

@@ -1,20 +0,0 @@
/* $NetBSD: int_const.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
#ifndef __INTMAX_C_SUFFIX__
#define __INT8_C_SUFFIX__
#define __INT16_C_SUFFIX__
#define __INT32_C_SUFFIX__
#define __INT64_C_SUFFIX__ LL
#define __UINT8_C_SUFFIX__
#define __UINT16_C_SUFFIX__
#define __UINT32_C_SUFFIX__
#define __UINT64_C_SUFFIX__ ULL
#define __INTMAX_C_SUFFIX__ LL
#define __UINTMAX_C_SUFFIX__ ULL
#endif
#include <sys/common_int_const.h>

View File

@@ -1,381 +0,0 @@
/* $NetBSD: int_fmtio.h,v 1.4 2019/04/17 11:01:19 mrg Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Klaus Klein.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_INT_FMTIO_H_
#define _RISCV_INT_FMTIO_H_
#ifdef __INTPTR_FMTd__
#include <sys/common_int_fmtio.h>
#else
/*
* 7.8.1 Macros for format specifiers
*/
/* fprintf macros for signed integers */
#define PRId8 "hhd" /* int8_t */
#define PRId16 "hd" /* int16_t */
#define PRId32 "d" /* int32_t */
#ifdef _LP64
#define PRId64 "ld" /* int64_t */
#else
#define PRId64 "lld" /* int64_t */
#endif
#define PRIdLEAST8 "hhd" /* int_least8_t */
#define PRIdLEAST16 "hd" /* int_least16_t */
#define PRIdLEAST32 "d" /* int_least32_t */
#ifdef _LP64
#define PRIdLEAST64 "ld" /* int_least64_t */
#define PRIdFAST8 "d" /* int_fast8_t */
#define PRIdFAST16 "d" /* int_fast16_t */
#else
#define PRIdLEAST64 "lld" /* int_least64_t */
#define PRIdFAST8 "hhd" /* int_fast8_t */
#define PRIdFAST16 "hd" /* int_fast16_t */
#endif
#define PRIdFAST32 "d" /* int_fast32_t */
#ifdef _LP64
#define PRIdFAST64 "ld" /* int_fast64_t */
#define PRIdMAX "ld" /* intmax_t */
#else
#define PRIdFAST64 "lld" /* int_fast64_t */
#define PRIdMAX "lld" /* intmax_t */
#endif
#define PRIdPTR "ld" /* intptr_t */
#define PRIi8 "hhi" /* int8_t */
#define PRIi16 "hi" /* int16_t */
#define PRIi32 "i" /* int32_t */
#ifdef _LP64
#define PRIi64 "li" /* int64_t */
#else
#define PRIi64 "lli" /* int64_t */
#endif
#define PRIiLEAST8 "hhi" /* int_least8_t */
#define PRIiLEAST16 "hi" /* int_least16_t */
#define PRIiLEAST32 "i" /* int_least32_t */
#ifdef _LP64
#define PRIiLEAST64 "li" /* int_least64_t */
#define PRIiFAST8 "i" /* int_fast8_t */
#define PRIiFAST16 "i" /* int_fast16_t */
#else
#define PRIiLEAST64 "lli" /* int_least64_t */
#define PRIiFAST8 "hhi" /* int_fast8_t */
#define PRIiFAST16 "hi" /* int_fast16_t */
#endif
#define PRIiFAST32 "i" /* int_fast32_t */
#ifdef _LP64
#define PRIiFAST64 "li" /* int_fast64_t */
#define PRIiMAX "li" /* intmax_t */
#else
#define PRIiFAST64 "lli" /* int_fast64_t */
#define PRIiMAX "lli" /* intmax_t */
#endif
#define PRIiPTR "li" /* intptr_t */
/* fprintf macros for unsigned integers */
#define PRIo8 "hho" /* uint8_t */
#define PRIo16 "ho" /* uint16_t */
#define PRIo32 "o" /* uint32_t */
#ifdef _LP64
#define PRIo64 "lo" /* uint64_t */
#else
#define PRIo64 "llo" /* uint64_t */
#endif
#define PRIoLEAST8 "o" /* uint_least8_t */
#define PRIoLEAST16 "hho" /* uint_least16_t */
#define PRIoLEAST32 "ho" /* uint_least32_t */
#ifdef _LP64
#define PRIoLEAST64 "lo" /* uint_least64_t */
#define PRIoFAST8 "o" /* uint_fast8_t */
#define PRIoFAST16 "o" /* uint_fast16_t */
#else
#define PRIoLEAST64 "llo" /* uint_least64_t */
#define PRIoFAST8 "hho" /* uint_fast8_t */
#define PRIoFAST16 "ho" /* uint_fast16_t */
#endif
#define PRIoFAST32 "o" /* uint_fast32_t */
#ifdef _LP64
#define PRIoFAST64 "lo" /* uint_fast64_t */
#define PRIoMAX "lo" /* uintmax_t */
#else
#define PRIoFAST64 "llo" /* uint_fast64_t */
#define PRIoMAX "llo" /* uintmax_t */
#endif
#define PRIoPTR "lo" /* uintptr_t */
#define PRIu8 "hhu" /* uint8_t */
#define PRIu16 "hu" /* uint16_t */
#define PRIu32 "u" /* uint32_t */
#ifdef _LP64
#define PRIu64 "lu" /* uint64_t */
#else
#define PRIu64 "llu" /* uint64_t */
#endif
#define PRIuLEAST8 "hhu" /* uint_least8_t */
#define PRIuLEAST16 "hu" /* uint_least16_t */
#define PRIuLEAST32 "u" /* uint_least32_t */
#ifdef _LP64
#define PRIuLEAST64 "lu" /* uint_least64_t */
#define PRIuFAST8 "u" /* uint_fast8_t */
#define PRIuFAST16 "u" /* uint_fast16_t */
#else
#define PRIuLEAST64 "llu" /* uint_least64_t */
#define PRIuFAST8 "hhu" /* uint_fast8_t */
#define PRIuFAST16 "hu" /* uint_fast16_t */
#endif
#define PRIuFAST32 "u" /* uint_fast32_t */
#ifdef _LP64
#define PRIuFAST64 "lu" /* uint_fast64_t */
#define PRIuMAX "lu" /* uintmax_t */
#else
#define PRIuFAST64 "llu" /* uint_fast64_t */
#define PRIuMAX "llu" /* uintmax_t */
#endif
#define PRIuPTR "lu" /* uintptr_t */
#define PRIx8 "hhx" /* uint8_t */
#define PRIx16 "hx" /* uint16_t */
#define PRIx32 "x" /* uint32_t */
#ifdef _LP64
#define PRIx64 "lx" /* uint64_t */
#else
#define PRIx64 "llx" /* uint64_t */
#endif
#define PRIxLEAST8 "x" /* uint_least8_t */
#define PRIxLEAST16 "x" /* uint_least16_t */
#define PRIxLEAST32 "x" /* uint_least32_t */
#ifdef _LP64
#define PRIxLEAST64 "lx" /* uint_least64_t */
#define PRIxFAST8 "x" /* uint_fast8_t */
#define PRIxFAST16 "x" /* uint_fast16_t */
#else
#define PRIxLEAST64 "llx" /* uint_least64_t */
#define PRIxFAST8 "hhx" /* uint_fast8_t */
#define PRIxFAST16 "hx" /* uint_fast16_t */
#endif
#define PRIxFAST32 "x" /* uint_fast32_t */
#ifdef _LP64
#define PRIxFAST64 "lx" /* uint_fast64_t */
#define PRIxMAX "lx" /* uintmax_t */
#else
#define PRIxFAST64 "llx" /* uint_fast64_t */
#define PRIxMAX "llx" /* uintmax_t */
#endif
#define PRIxPTR "lx" /* uintptr_t */
#define PRIX8 "hhX" /* uint8_t */
#define PRIX16 "hX" /* uint16_t */
#define PRIX32 "X" /* uint32_t */
#ifdef _LP64
#define PRIX64 "lX" /* uint64_t */
#else
#define PRIX64 "llX" /* uint64_t */
#endif
#define PRIXLEAST8 "X" /* uint_least8_t */
#define PRIXLEAST16 "X" /* uint_least16_t */
#define PRIXLEAST32 "X" /* uint_least32_t */
#ifdef _LP64
#define PRIXLEAST64 "lX" /* uint_least64_t */
#define PRIXFAST8 "X" /* uint_fast8_t */
#define PRIXFAST16 "X" /* uint_fast16_t */
#else
#define PRIXLEAST64 "llX" /* uint_least64_t */
#define PRIXFAST8 "hhX" /* uint_fast8_t */
#define PRIXFAST16 "hX" /* uint_fast16_t */
#endif
#define PRIXFAST32 "X" /* uint_fast32_t */
#ifdef _LP64
#define PRIXFAST64 "lX" /* uint_fast64_t */
#define PRIXMAX "lX" /* uintmax_t */
#else
#define PRIXFAST64 "llX" /* uint_fast64_t */
#define PRIXMAX "llX" /* uintmax_t */
#endif
#define PRIXPTR "lX" /* uintptr_t */
/* fscanf macros for signed integers */
#define SCNd8 "hhd" /* int8_t */
#define SCNd16 "hd" /* int16_t */
#define SCNd32 "d" /* int32_t */
#ifdef _LP64
#define SCNd64 "ld" /* int64_t */
#else
#define SCNd64 "lld" /* int64_t */
#endif
#define SCNdLEAST8 "hhd" /* int_least8_t */
#define SCNdLEAST16 "hd" /* int_least16_t */
#define SCNdLEAST32 "d" /* int_least32_t */
#ifdef _LP64
#define SCNdLEAST64 "ld" /* int_least64_t */
#define SCNdFAST8 "d" /* int_fast8_t */
#define SCNdFAST16 "d" /* int_fast16_t */
#else
#define SCNdLEAST64 "lld" /* int_least64_t */
#define SCNdFAST8 "hhd" /* int_fast8_t */
#define SCNdFAST16 "hd" /* int_fast16_t */
#endif
#define SCNdFAST32 "d" /* int_fast32_t */
#ifdef _LP64
#define SCNdFAST64 "ld" /* int_fast64_t */
#define SCNdMAX "ld" /* intmax_t */
#else
#define SCNdFAST64 "lld" /* int_fast64_t */
#define SCNdMAX "lld" /* intmax_t */
#endif
#define SCNdPTR "ld" /* intptr_t */
#define SCNi8 "hhi" /* int8_t */
#define SCNi16 "hi" /* int16_t */
#define SCNi32 "i" /* int32_t */
#ifdef _LP64
#define SCNi64 "li" /* int64_t */
#else
#define SCNi64 "lli" /* int64_t */
#endif
#define SCNiLEAST8 "hhi" /* int_least8_t */
#define SCNiLEAST16 "hi" /* int_least16_t */
#define SCNiLEAST32 "i" /* int_least32_t */
#ifdef _LP64
#define SCNiLEAST64 "li" /* int_least64_t */
#define SCNiFAST8 "i" /* int_fast8_t */
#define SCNiFAST16 "i" /* int_fast16_t */
#else
#define SCNiLEAST64 "lli" /* int_least64_t */
#define SCNiFAST8 "hhi" /* int_fast8_t */
#define SCNiFAST16 "hi" /* int_fast16_t */
#endif
#define SCNiFAST32 "i" /* int_fast32_t */
#ifdef _LP64
#define SCNiFAST64 "li" /* int_fast64_t */
#define SCNiMAX "li" /* intmax_t */
#else
#define SCNiFAST64 "lli" /* int_fast64_t */
#define SCNiMAX "lli" /* intmax_t */
#endif
#define SCNiPTR "li" /* intptr_t */
/* fscanf macros for unsigned integers */
#define SCNo8 "hho" /* uint8_t */
#define SCNo16 "ho" /* uint16_t */
#define SCNo32 "o" /* uint32_t */
#ifdef _LP64
#define SCNo64 "lo" /* uint64_t */
#else
#define SCNo64 "llo" /* uint64_t */
#endif
#define SCNoLEAST8 "hho" /* uint_least8_t */
#define SCNoLEAST16 "ho" /* uint_least16_t */
#define SCNoLEAST32 "o" /* uint_least32_t */
#ifdef _LP64
#define SCNoLEAST64 "lo" /* uint_least64_t */
#define SCNoFAST8 "o" /* uint_fast8_t */
#define SCNoFAST16 "o" /* uint_fast16_t */
#else
#define SCNoLEAST64 "llo" /* uint_least64_t */
#define SCNoFAST8 "hho" /* uint_fast8_t */
#define SCNoFAST16 "ho" /* uint_fast16_t */
#endif
#define SCNoFAST32 "o" /* uint_fast32_t */
#ifdef _LP64
#define SCNoFAST64 "lo" /* uint_fast64_t */
#define SCNoMAX "lo" /* uintmax_t */
#else
#define SCNoFAST64 "llo" /* uint_fast64_t */
#define SCNoMAX "llo" /* uintmax_t */
#endif
#define SCNoPTR "lo" /* uintptr_t */
#define SCNu8 "hhu" /* uint8_t */
#define SCNu16 "hu" /* uint16_t */
#define SCNu32 "u" /* uint32_t */
#ifdef _LP64
#define SCNu64 "lu" /* uint64_t */
#else
#define SCNu64 "llu" /* uint64_t */
#endif
#define SCNuLEAST8 "hhu" /* uint_least8_t */
#define SCNuLEAST16 "hu" /* uint_least16_t */
#define SCNuLEAST32 "u" /* uint_least32_t */
#ifdef _LP64
#define SCNuLEAST64 "lu" /* uint_least64_t */
#define SCNuFAST8 "u" /* uint_fast8_t */
#define SCNuFAST16 "u" /* uint_fast16_t */
#else
#define SCNuLEAST64 "llu" /* uint_least64_t */
#define SCNuFAST8 "hhu" /* uint_fast8_t */
#define SCNuFAST16 "hu" /* uint_fast16_t */
#endif
#define SCNuFAST32 "u" /* uint_fast32_t */
#ifdef _LP64
#define SCNuFAST64 "lu" /* uint_fast64_t */
#define SCNuMAX "lu" /* uintmax_t */
#else
#define SCNuFAST64 "llu" /* uint_fast64_t */
#define SCNuMAX "llu" /* uintmax_t */
#endif
#define SCNuPTR "lu" /* uintptr_t */
#define SCNx8 "hhx" /* uint8_t */
#define SCNx16 "hx" /* uint16_t */
#define SCNx32 "x" /* uint32_t */
#ifdef _LP64
#define SCNx64 "lx" /* uint64_t */
#else
#define SCNx64 "llx" /* uint64_t */
#endif
#define SCNxLEAST8 "hhx" /* uint_least8_t */
#define SCNxLEAST16 "hx" /* uint_least16_t */
#define SCNxLEAST32 "x" /* uint_least32_t */
#ifdef _LP64
#define SCNxLEAST64 "lx" /* uint_least64_t */
#define SCNxFAST8 "x" /* uint_fast8_t */
#define SCNxFAST16 "x" /* uint_fast16_t */
#else
#define SCNxLEAST64 "llx" /* uint_least64_t */
#define SCNxFAST8 "hhx" /* uint_fast8_t */
#define SCNxFAST16 "hx" /* uint_fast16_t */
#endif
#define SCNxFAST32 "x" /* uint_fast32_t */
#ifdef _LP64
#define SCNxFAST64 "lx" /* uint_fast64_t */
#define SCNxMAX "lx" /* uintmax_t */
#else
#define SCNxFAST64 "llx" /* uint_fast64_t */
#define SCNxMAX "llx" /* uintmax_t */
#endif
#define SCNxPTR "lx" /* uintptr_t */
#endif /* !__INTPTR_FMTd__ */
#endif /* !_RISCV_INT_FMTIO_H_ */

View File

@@ -1,3 +0,0 @@
/* $NetBSD: int_limits.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
#include <sys/common_int_limits.h>

View File

@@ -1,3 +0,0 @@
/* $NetBSD: int_mwgwtypes.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
#include <sys/common_int_mwgwtypes.h>

View File

@@ -1,3 +0,0 @@
/* $NetBSD: int_types.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
#include <sys/common_int_types.h>

View File

@@ -1,40 +0,0 @@
/* $NetBSD: kcore.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_KCORE_H_
#define _RISCV_KCORE_H_
typedef struct cpu_kcore_hdr {
uint64_t kh_misc[8];
phys_ram_seg_t kh_ramsegs[0];
} cpu_kcore_hdr_t;
#endif /* _RISCV_KCORE_H_ */

View File

@@ -1,3 +0,0 @@
/* $NetBSD: limits.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
#include <sys/common_limits.h>

View File

@@ -1,3 +0,0 @@
/* $NetBSD: lock.h,v 1.4 2015/06/26 14:27:35 matt Exp $ */
#include <sys/common_lock.h>

View File

@@ -1,4 +0,0 @@
/* $NetBSD: math.h,v 1.3 2019/04/16 07:40:02 maya Exp $ */
#define __HAVE_NANF
#define __HAVE_LONG_DOUBLE 128

View File

@@ -1,170 +0,0 @@
/* $NetBSD: mcontext.h,v 1.6 2020/03/14 16:12:16 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_MCONTEXT_H_
#define _RISCV_MCONTEXT_H_
/*
*/
#define _NGREG 32 /* GR1-31 */
#define _NFREG 33 /* F0-31, FCSR */
/*
* This fragment is common to <riscv/mcontext.h> and <riscv/reg.h>
*/
#ifndef _BSD_FPREG_T_
union __fpreg {
__uint64_t u_u64;
double u_d;
};
#define _BSD_FPREG_T_ union __fpreg
#endif
typedef __uint64_t __greg_t;
typedef __greg_t __gregset_t[_NGREG];
typedef __uint32_t __greg32_t;
typedef __greg32_t __gregset32_t[_NGREG];
typedef _BSD_FPREG_T_ __fregset_t[_NFREG];
#define _REG_X1 0
#define _REG_X2 1
#define _REG_X3 2
#define _REG_X4 3
#define _REG_X5 4
#define _REG_X6 5
#define _REG_X7 6
#define _REG_X8 7
#define _REG_X9 8
#define _REG_X10 9
#define _REG_X11 10
#define _REG_X12 11
#define _REG_X13 12
#define _REG_X14 13
#define _REG_X15 14
#define _REG_X16 15
#define _REG_X17 16
#define _REG_X18 17
#define _REG_X19 18
#define _REG_X20 19
#define _REG_X21 20
#define _REG_X22 21
#define _REG_X23 22
#define _REG_X24 23
#define _REG_X25 24
#define _REG_X26 25
#define _REG_X27 26
#define _REG_X28 27
#define _REG_X29 28
#define _REG_X30 29
#define _REG_X31 30
#define _REG_PC 31
#define _REG_RA _REG_X1
#define _REG_SP _REG_X2
#define _REG_GP _REG_X3
#define _REG_TP _REG_X4
#define _REG_S0 _REG_X8
#define _REG_RV _REG_X10
#define _REG_A0 _REG_X10
#define _REG_F0 0
#define _REG_FPCSR 32
typedef struct {
__gregset_t __gregs; /* General Purpose Register set */
__fregset_t __fregs; /* Floating Point Register set */
__greg_t __private; /* copy of l_private */
__greg_t __spare[8]; /* future proof */
} mcontext_t;
typedef struct {
__gregset32_t __gregs; /* General Purpose Register set */
__fregset_t __fregs; /* Floating Point Register set */
__greg32_t __private; /* copy of l_private */
__greg32_t __spare[8]; /* future proof */
} mcontext32_t;
/* Machine-dependent uc_flags */
#define _UC_SETSTACK 0x00010000 /* see <sys/ucontext.h> */
#define _UC_CLRSTACK 0x00020000 /* see <sys/ucontext.h> */
#define _UC_TLSBASE 0x00080000 /* see <sys/ucontext.h> */
#define _UC_MACHINE_SP(uc) ((uc)->uc_mcontext.__gregs[_REG_SP])
#define _UC_MACHINE_FP(uc) ((uc)->uc_mcontext.__gregs[_REG_S0])
#define _UC_MACHINE_PC(uc) ((uc)->uc_mcontext.__gregs[_REG_PC])
#define _UC_MACHINE_INTRV(uc) ((uc)->uc_mcontext.__gregs[_REG_RV])
#define _UC_MACHINE_SET_PC(uc, pc) _UC_MACHINE_PC(uc) = (pc)
#if defined(_RTLD_SOURCE) || defined(_LIBC_SOURCE) || defined(__LIBPTHREAD_SOURCE__)
#include <sys/tls.h>
/*
* On RISCV, since displacements are signed 12-bit values, the TCB pointer is
* not and points to the first static entry.
*/
#define TLS_TP_OFFSET 0x0
#define TLS_DTV_OFFSET 0x800
__CTASSERT(TLS_TP_OFFSET + sizeof(struct tls_tcb) < 0x800);
static __inline void *
__lwp_getprivate_fast(void)
{
void *__tp;
__asm("move %0,tp" : "=r"(__tp));
return __tp;
}
static __inline void *
__lwp_gettcb_fast(void)
{
void *__tcb;
__asm __volatile(
"addi %[__tcb],tp,%[__offset]"
: [__tcb] "=r" (__tcb)
: [__offset] "n" (-(TLS_TP_OFFSET + sizeof(struct tls_tcb))));
return __tcb;
}
static __inline void
__lwp_settcb(void *__tcb)
{
__asm __volatile(
"addi tp,%[__tcb],%[__offset]"
:
: [__tcb] "r" (__tcb),
[__offset] "n" (TLS_TP_OFFSET + sizeof(struct tls_tcb)));
}
#endif /* _RTLD_SOURCE || _LIBC_SOURCE || __LIBPTHREAD_SOURCE__ */
#endif /* !_RISCV_MCONTEXT_H_ */

View File

@@ -1,124 +0,0 @@
/* $NetBSD: mutex.h,v 1.4.4.1 2023/08/09 17:42:03 martin Exp $ */
/*-
* Copyright (c) 2002, 2007 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe and Andrew Doran.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_MUTEX_H_
#define _RISCV_MUTEX_H_
#include <sys/types.h>
#ifndef __MUTEX_PRIVATE
struct kmutex {
uintptr_t mtx_pad1;
};
#else /* __MUTEX_PRIVATE */
#include <sys/cdefs.h>
#include <sys/param.h>
#include <machine/intr.h>
struct kmutex {
volatile uintptr_t mtx_owner;
};
#ifdef _LP64
#define MTX_ASMOP_SFX ".d" // doubleword atomic op
#else
#define MTX_ASMOP_SFX ".w" // word atomic op
#endif
#define MTX_LOCK __BIT(8) // just one bit
#define MTX_IPL __BITS(7,4) // only need 4 bits
#undef MUTEX_SPIN_IPL // override <sys/mutex.h>
#define MUTEX_SPIN_IPL(a) riscv_mutex_spin_ipl(a)
#define MUTEX_INITIALIZE_SPIN_IPL(a,b) riscv_mutex_initialize_spin_ipl(a,b)
#define MUTEX_SPINBIT_LOCK_INIT(a) riscv_mutex_spinbit_lock_init(a)
#define MUTEX_SPINBIT_LOCK_TRY(a) riscv_mutex_spinbit_lock_try(a)
#define MUTEX_SPINBIT_LOCKED_P(a) riscv_mutex_spinbit_locked_p(a)
#define MUTEX_SPINBIT_LOCK_UNLOCK(a) riscv_mutex_spinbit_lock_unlock(a)
static inline ipl_cookie_t
riscv_mutex_spin_ipl(kmutex_t *__mtx)
{
return (ipl_cookie_t){._spl = __SHIFTOUT(__mtx->mtx_owner, MTX_IPL)};
}
static inline void
riscv_mutex_initialize_spin_ipl(kmutex_t *__mtx, int ipl)
{
__mtx->mtx_owner = (__mtx->mtx_owner & ~MTX_IPL)
| __SHIFTIN(ipl, MTX_IPL);
}
static inline void
riscv_mutex_spinbit_lock_init(kmutex_t *__mtx)
{
__mtx->mtx_owner &= ~MTX_LOCK;
}
static inline bool
riscv_mutex_spinbit_locked_p(const kmutex_t *__mtx)
{
return (__mtx->mtx_owner & MTX_LOCK) != 0;
}
static inline bool
riscv_mutex_spinbit_lock_try(kmutex_t *__mtx)
{
uintptr_t __old;
__asm __volatile(
"amoor" MTX_ASMOP_SFX ".aq\t%0, %1, (%2)"
: "=r"(__old)
: "r"(MTX_LOCK), "r"(__mtx));
return (__old & MTX_LOCK) == 0;
}
static inline void
riscv_mutex_spinbit_lock_unlock(kmutex_t *__mtx)
{
__asm __volatile(
"amoand" MTX_ASMOP_SFX ".rl\tx0, %0, (%1)"
:: "r"(~MTX_LOCK), "r"(__mtx));
}
#if 0
#define __HAVE_MUTEX_STUBS 1
#define __HAVE_SPIN_MUTEX_STUBS 1
#endif
#define __HAVE_SIMPLE_MUTEXES 1
#endif /* __MUTEX_PRIVATE */
#endif /* _RISCV_MUTEX_H_ */

View File

@@ -1,106 +0,0 @@
/* $NetBSD: param.h,v 1.7 2022/10/12 07:50:00 simonb Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_PARAM_H_
#define _RISCV_PARAM_H_
#ifdef _KERNEL_OPT
#include "opt_param.h"
#endif
/*
* Machine dependent constants for all OpenRISC processors
*/
/*
* For KERNEL code:
* MACHINE must be defined by the individual port. This is so that
* uname returns the correct thing, etc.
*
* For non-KERNEL code:
* If ELF, MACHINE and MACHINE_ARCH are forced to "or1k/or1k".
*/
#ifdef _LP64
#define _MACHINE_ARCH riscv64
#define MACHINE_ARCH "riscv64"
#define _MACHINE_ARCH32 riscv32
#define MACHINE_ARCH32 "riscv32"
#else
#define _MACHINE_ARCH riscv32
#define MACHINE_ARCH "riscv32"
#endif
#define _MACHINE riscv
#define MACHINE "riscv"
#define MID_MACHINE MID_RISCV
/* RISCV-specific macro to align a stack pointer (downwards). */
#define STACK_ALIGNBYTES (__BIGGEST_ALIGNMENT__ - 1)
#define ALIGNBYTES32 __BIGGEST_ALIGNMENT__
#define NKMEMPAGES_MIN_DEFAULT ((128UL * 1024 * 1024) >> PAGE_SHIFT)
#define NKMEMPAGES_MAX_UNLIMITED 1
#define PGSHIFT 12
#define NBPG (1 << PGSHIFT)
#define PGOFSET (NBPG - 1)
#define UPAGES 2
#define USPACE (UPAGES << PGSHIFT)
#define USPACE_ALIGN NBPG
/*
* Constants related to network buffer management.
* MCLBYTES must be no larger than NBPG (the software page size), and
* NBPG % MCLBYTES must be zero.
*/
#define MSIZE 512 /* size of an mbuf */
#ifndef MCLSHIFT
#define MCLSHIFT 11 /* convert bytes to m_buf clusters */
/* 2K cluster can hold Ether frame */
#endif /* MCLSHIFT */
#define MCLBYTES (1 << MCLSHIFT) /* size of a m_buf cluster */
#ifndef MSGBUFSIZE
#define MSGBUFSIZE 65536 /* default message buffer size */
#endif
#define MAXCPUS 32
#ifdef _KERNEL
void delay(unsigned long);
#define DELAY(x) delay(x)
#endif
#endif /* _RISCV_PARAM_H_ */

View File

@@ -1,46 +0,0 @@
/* $NetBSD: pcb.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_PCB_H_
#define _RISCV_PCB_H_
#include <riscv/reg.h>
struct pcb {
struct fpreg pcb_fpregs;
};
struct md_coredump {
struct reg reg;
struct fpreg fpreg;
};
#endif /* _RISCV_PCB_H_ */

View File

@@ -1,213 +0,0 @@
/* $NetBSD: pmap.h,v 1.13 2022/10/20 07:18:11 skrll Exp $ */
/*
* Copyright (c) 2014, 2019, 2021 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas (of 3am Software Foundry), Maxime Villard, and
* Nick Hudson.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_PMAP_H_
#define _RISCV_PMAP_H_
#ifdef _KERNEL_OPT
#include "opt_modular.h"
#endif
#if !defined(_MODULE)
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/pool.h>
#include <sys/evcnt.h>
#include <uvm/uvm_physseg.h>
#include <uvm/pmap/vmpagemd.h>
#include <riscv/pte.h>
#include <riscv/sysreg.h>
#define PMAP_SEGTABSIZE NPTEPG
#define PMAP_PDETABSIZE NPTEPG
#ifdef _LP64
#define PTPSHIFT 3
/* This is SV48. */
//#define SEGLENGTH + SEGSHIFT + SEGSHIFT */
/* This is SV39. */
#define XSEGSHIFT (SEGSHIFT + SEGLENGTH)
#define NBXSEG (1ULL << XSEGSHIFT)
#define XSEGOFSET (NBXSEG - 1) /* byte offset into xsegment */
#define XSEGLENGTH (PGSHIFT - 3)
#define NXSEGPG (1 << XSEGLENGTH)
#else
#define PTPSHIFT 2
#define XSEGSHIFT SEGSHIFT
#endif
#define SEGLENGTH (PGSHIFT - PTPSHIFT)
#define SEGSHIFT (SEGLENGTH + PGSHIFT)
#define NBSEG (1 << SEGSHIFT) /* bytes/segment */
#define SEGOFSET (NBSEG - 1) /* byte offset into segment */
#define KERNEL_PID 0
#define PMAP_HWPAGEWALKER 1
#define PMAP_TLB_MAX 1
#ifdef _LP64
#define PMAP_INVALID_PDETAB_ADDRESS ((pmap_pdetab_t *)(VM_MIN_KERNEL_ADDRESS - PAGE_SIZE))
#define PMAP_INVALID_SEGTAB_ADDRESS ((pmap_segtab_t *)(VM_MIN_KERNEL_ADDRESS - PAGE_SIZE))
#else
#define PMAP_INVALID_PDETAB_ADDRESS ((pmap_pdetab_t *)0xdeadbeef)
#define PMAP_INVALID_SEGTAB_ADDRESS ((pmap_segtab_t *)0xdeadbeef)
#endif
#define PMAP_TLB_NUM_PIDS (__SHIFTOUT_MASK(SATP_ASID) + 1)
#define PMAP_TLB_BITMAP_LENGTH PMAP_TLB_NUM_PIDS
#define PMAP_TLB_FLUSH_ASID_ON_RESET false
#define pmap_phys_address(x) (x)
#ifndef __BSD_PTENTRY_T__
#define __BSD_PTENTRY_T__
#ifdef _LP64
#define PRIxPTE PRIx64
#else
#define PRIxPTE PRIx32
#endif
#endif /* __BSD_PTENTRY_T__ */
#define PMAP_NEED_PROCWR
static inline void
pmap_procwr(struct proc *p, vaddr_t va, vsize_t len)
{
__asm __volatile("fence\trw,rw; fence.i" ::: "memory");
}
#include <uvm/pmap/tlb.h>
#include <uvm/pmap/pmap_tlb.h>
#define PMAP_GROWKERNEL
#define PMAP_STEAL_MEMORY
#ifdef _KERNEL
#define __HAVE_PMAP_MD
struct pmap_md {
paddr_t md_ppn;
pd_entry_t *md_pdetab;
};
struct vm_page *
pmap_md_alloc_poolpage(int flags);
vaddr_t pmap_md_map_poolpage(paddr_t, vsize_t);
void pmap_md_unmap_poolpage(vaddr_t, vsize_t);
bool pmap_md_direct_mapped_vaddr_p(vaddr_t);
bool pmap_md_io_vaddr_p(vaddr_t);
paddr_t pmap_md_direct_mapped_vaddr_to_paddr(vaddr_t);
vaddr_t pmap_md_direct_map_paddr(paddr_t);
void pmap_md_init(void);
void pmap_md_xtab_activate(struct pmap *, struct lwp *);
void pmap_md_xtab_deactivate(struct pmap *);
void pmap_md_pdetab_init(struct pmap *);
bool pmap_md_ok_to_steal_p(const uvm_physseg_t, size_t);
void pmap_bootstrap(vaddr_t kstart, vaddr_t kend);
extern vaddr_t pmap_direct_base;
extern vaddr_t pmap_direct_end;
#define PMAP_DIRECT_MAP(pa) (pmap_direct_base + (pa))
#define PMAP_DIRECT_UNMAP(va) ((paddr_t)(va) - pmap_direct_base)
#define MEGAPAGE_TRUNC(x) ((x) & ~SEGOFSET)
#define MEGAPAGE_ROUND(x) MEGAPAGE_TRUNC((x) + SEGOFSET)
#ifdef __PMAP_PRIVATE
static inline bool
pmap_md_tlb_check_entry(void *ctx, vaddr_t va, tlb_asid_t asid, pt_entry_t pte)
{
// TLB not walked and so not called.
return false;
}
static inline void
pmap_md_page_syncicache(struct vm_page_md *mdpg, const kcpuset_t *kc)
{
__asm __volatile("fence\trw,rw; fence.i" ::: "memory");
}
/*
* Virtual Cache Alias helper routines. Not a problem for RISCV CPUs.
*/
static inline bool
pmap_md_vca_add(struct vm_page_md *mdpg, vaddr_t va, pt_entry_t *nptep)
{
return false;
}
static inline void
pmap_md_vca_remove(struct vm_page_md *mdpg, vaddr_t va)
{
}
static inline void
pmap_md_vca_clean(struct vm_page_md *mdpg, vaddr_t va, int op)
{
}
static inline size_t
pmap_md_tlb_asid_max(void)
{
return PMAP_TLB_NUM_PIDS - 1;
}
#endif /* __PMAP_PRIVATE */
#endif /* _KERNEL */
#include <uvm/pmap/pmap.h>
#endif /* !_MODULE */
#if defined(MODULAR) || defined(_MODULE)
/*
* Define a compatible vm_page_md so that struct vm_page is the same size
* whether we are using modules or not.
*/
#ifndef __HAVE_VM_PAGE_MD
#define __HAVE_VM_PAGE_MD
struct vm_page_md {
uintptr_t mdpg_dummy[3];
};
__CTASSERT(sizeof(struct vm_page_md) == sizeof(uintptr_t)*3);
#endif /* !__HAVE_VM_PAGE_MD */
#endif /* MODULAR || _MODULE */
#endif /* !_RISCV_PMAP_H_ */

View File

@@ -1,71 +0,0 @@
/* $NetBSD: proc.h,v 1.3 2015/03/31 06:47:47 matt Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_PROC_H_
#define _RISCV_PROC_H_
#include <sys/param.h>
#include <riscv/vmparam.h>
struct lwp;
/*
* Machine-dependent part of the lwp structure for RISCV
*/
struct trapframe;
struct mdlwp {
struct trapframe *md_utf; /* trapframe from userspace */
struct trapframe *md_ktf; /* trapframe from userspace */
struct faultbuf *md_onfault; /* registers to store on fault */
register_t md_usp; /* for locore.S */
vaddr_t md_ss_addr; /* single step address for ptrace */
int md_ss_instr; /* single step instruction for ptrace */
volatile int md_astpending; /* AST pending on return to userland */
#if 0
#if USPACE > PAGE_SIZE
int md_upte[USPACE/4096]; /* ptes for mapping u page */
#else
int md_dpte[USPACE/4096]; /* dummy ptes to keep the same */
#endif
#endif
};
struct mdproc {
/* syscall entry for this process */
void (*md_syscall)(struct trapframe *);
};
#ifdef _KERNEL
#define LWP0_CPU_INFO &cpu_info_store /* staticly set in lwp0 */
#endif /* _KERNEL */
#endif /* _RISCV_PROC_H_ */

View File

@@ -1,91 +0,0 @@
/* $NetBSD: profile.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_PROFILE_H_
#define _RISCV_PROFILE_H_
#define _MCOUNT_DECL void _mcount
/*
* Cannot implement mcount in C as GCC will trash the ip register when it
* pushes a trapframe. Pity we cannot insert assembly before the function
* prologue.
*/
#define MCOUNT_ASM_NAME "__mcount"
#define PLTSYM
#if 0
#define MCOUNT \
__asm(".text"); \
__asm(".align 0"); \
__asm(".type " MCOUNT_ASM_NAME ",@function"); \
__asm(".global " MCOUNT_ASM_NAME); \
__asm(MCOUNT_ASM_NAME ":"); \
/* \
* Preserve registers that are trashed during mcount \
*/ \
__asm("sub sp, sp, #80"); \
__asm("stp x29, x30, [sp, #64]"); \
__asm("add x29, sp, #64"); \
__asm("stp x0, x1, [x29, #0]"); \
__asm("stp x2, x3, [x29, #16]"); \
__asm("stp x4, x5, [x29, #32]"); \
__asm("stp x6, x7, [x29, #48]"); \
/* \
* find the return address for mcount, \
* and the return address for mcount's caller. \
* \
* frompcindex = pc pushed by call into self. \
*/ \
__asm("mov x0, x19"); \
/* \
* selfpc = pc pushed by mcount call \
*/ \
__asm("mov x1, x30"); \
/* \
* Call the real mcount code \
*/ \
__asm("bl " ___STRING(_C_LABEL(_mcount))); \
/* \
* Restore registers that were trashed during mcount \
*/ \
__asm("ldp x0, x1, [x29, #0]"); \
__asm("ldp x2, x3, [x29, #16]"); \
__asm("ldp x4, x5, [x29, #32]"); \
__asm("ldp x6, x7, [x29, #48]"); \
__asm("ldp x29, x30, [x29, #64]"); \
__asm("add sp, sp, #80"); \
__asm("ret"); \
__asm(".size " MCOUNT_ASM_NAME ", .-" MCOUNT_ASM_NAME);
#endif
#endif /* _RISCV_PROFILE_H_ */

View File

@@ -1,57 +0,0 @@
/* $NetBSD: ptrace.h,v 1.3 2019/06/18 21:18:12 kamil Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_PTRACE_H_
#define _RISCV_PTRACE_H_
/*
* RISCV-dependent ptrace definitions.
* Note that PT_STEP is _not_ supported.
*/
#define PT_GETREGS (PT_FIRSTMACH + 0)
#define PT_SETREGS (PT_FIRSTMACH + 1)
#define PT_GETFPREGS (PT_FIRSTMACH + 2)
#define PT_SETFPREGS (PT_FIRSTMACH + 3)
#define PT_MACHDEP_STRINGS \
"PT_GETREGS", \
"PT_SETREGS", \
"PT_GETFPREGS", \
"PT_SETFPREGS"
#include <machine/reg.h>
#define PTRACE_REG_PC(r) (r)->r_pc
#define PTRACE_REG_FP(r) (r)->r_reg[7]
#define PTRACE_REG_SET_PC(r, v) (r)->r_pc = (v)
#define PTRACE_REG_SP(r) (r)->r_reg[1]
#define PTRACE_REG_INTRV(r) (r)->r_reg[9]
#endif /* _RISCV_PTRACE_H_ */

View File

@@ -1,125 +0,0 @@
/* $NetBSD: reg.h,v 1.10 2022/12/13 22:25:08 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_REG_H_
#define _RISCV_REG_H_
// x0 = 0
// x1 = ra (return address) Caller
// x2 = sp (stack pointer) Callee
// x3 = gp (global pointer)
// x4 = tp (thread pointer)
// x5 - x7 = t0 - t2 (temporary) Caller
// x8 = s0/fp (saved register / frame pointer) Callee
// x9 = s1 (saved register) Callee
// x10 - x11 = a0 - a1 (arguments/return values) Caller
// x12 - x17 = a2 - a7 (arguments) Caller
// x18 - x27 = s2 - s11 (saved registers) Callee
// x28 - x31 = t3 - t6 (temporaries) Caller
struct reg { // synced with register_t in <riscv/types.h>
#ifdef _LP64
__uint64_t r_reg[31]; /* x0 is always 0 */
__uint64_t r_pc;
#else
__uint32_t r_reg[31]; /* x0 is always 0 */
__uint32_t r_pc;
#endif
};
#ifdef _LP64
struct reg32 { // synced with register_t in <riscv/types.h>
__uint32_t r_reg[31]; /* x0 is always 0 */
__uint32_t r_pc;
};
#endif
#define _XREG(n) ((n) - 1)
#define _X_RA _XREG(1)
#define _X_SP _XREG(2)
#define _X_GP _XREG(3)
#define _X_TP _XREG(4)
#define _X_T0 _XREG(5)
#define _X_T1 _XREG(6)
#define _X_T2 _XREG(7)
#define _X_S0 _XREG(8)
#define _X_S1 _XREG(9)
#define _X_A0 _XREG(10)
#define _X_A1 _XREG(11)
#define _X_A2 _XREG(12)
#define _X_A3 _XREG(13)
#define _X_A4 _XREG(14)
#define _X_A5 _XREG(15)
#define _X_A6 _XREG(16)
#define _X_A7 _XREG(17)
#define _X_S2 _XREG(18)
#define _X_S3 _XREG(19)
#define _X_S4 _XREG(20)
#define _X_S5 _XREG(21)
#define _X_S6 _XREG(22)
#define _X_S7 _XREG(23)
#define _X_S8 _XREG(24)
#define _X_S9 _XREG(25)
#define _X_S10 _XREG(26)
#define _X_S11 _XREG(27)
#define _X_T3 _XREG(28)
#define _X_T4 _XREG(29)
#define _X_T5 _XREG(30)
#define _X_T6 _XREG(31)
// f0 - f7 = ft0 - ft7 (FP temporaries) Caller
// following layout is similar to integer registers above
// f8 - f9 = fs0 - fs1 (FP saved registers) Callee
// f10 - f11 = fa0 - fa1 (FP arguments/return values) Caller
// f12 - f17 = fa2 - fa7 (FP arguments) Caller
// f18 - f27 = fs2 - fa11 (FP saved registers) Callee
// f28 - f31 = ft8 - ft11 (FP temporaries) Caller
/*
* This fragment is common to <riscv/mcontext.h> and <riscv/reg.h>
*/
#ifndef _BSD_FPREG_T_
union __fpreg {
__uint64_t u_u64;
double u_d;
};
#define _BSD_FPREG_T_ union __fpreg
#endif
/*
* 32 double precision floating point, 1 CSR
*/
struct fpreg {
_BSD_FPREG_T_ r_fpreg[33];
};
#define r_fcsr r_fpreg[32].u_u64
#endif /* _RISCV_REG_H_ */

View File

@@ -1 +0,0 @@
/* $NetBSD: rwlock.h,v 1.2 2019/11/29 20:04:53 riastradh Exp $ */

View File

@@ -1,70 +0,0 @@
/* $NetBSD: setjmp.h,v 1.2 2015/03/27 06:57:21 matt Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/* magic + 16 reg + 1 fcsr + 12 fp + 4 sigmask + 8 spare */
#define _JBLEN (_JB_SIGMASK + 4 + 8)
#define _JB_MAGIC 0
#define _JB_RA 1
#define _JB_SP 2
#define _JB_GP 3
#define _JB_TP 4
#define _JB_S0 5
#define _JB_S1 6
#define _JB_S2 7
#define _JB_S3 8
#define _JB_S4 9
#define _JB_S5 10
#define _JB_S6 11
#define _JB_S7 12
#define _JB_S8 13
#define _JB_S9 14
#define _JB_S10 15
#define _JB_S11 16
#define _JB_FCSR 17
#define _JB_FS0 18
#define _JB_FS1 (_JB_FS0 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#define _JB_FS2 (_JB_FS1 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#define _JB_FS3 (_JB_FS2 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#define _JB_FS4 (_JB_FS3 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#define _JB_FS5 (_JB_FS4 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#define _JB_FS6 (_JB_FS5 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#define _JB_FS7 (_JB_FS6 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#define _JB_FS8 (_JB_FS7 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#define _JB_FS9 (_JB_FS8 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#define _JB_FS10 (_JB_FS9 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#define _JB_FS11 (_JB_FS10 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#define _JB_SIGMASK (_JB_FS11 + sizeof(double) / sizeof(_BSD_JBSLOT_T_))
#ifndef _BSD_JBSLOT_T_
#define _BSD_JBSLOT_T_ long long
#endif

View File

@@ -1,39 +0,0 @@
/* $NetBSD: signal.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_SIGNAL_H_
#define _RISCV_SIGNAL_H_
#ifndef _LOCORE
typedef __SIG_ATOMIC_TYPE__ sig_atomic_t;
#endif
#endif /* _RISCV_SIGNAL_H_ */

View File

@@ -1,116 +0,0 @@
/* $NetBSD: types.h,v 1.15 2022/11/08 13:34:17 simonb Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_TYPES_H_
#define _RISCV_TYPES_H_
#include <sys/cdefs.h>
#include <sys/featuretest.h>
#include <riscv/int_types.h>
#if defined(_KERNEL) || defined(_KMEMUSER) || defined(_KERNTYPES) || defined(_STANDALONE)
/* XLEN is the native base integer ISA width */
#define XLEN (sizeof(long) * NBBY)
typedef __uint64_t paddr_t;
typedef __uint64_t psize_t;
#define PRIxPADDR PRIx64
#define PRIxPSIZE PRIx64
#define PRIuPSIZE PRIu64
typedef __UINTPTR_TYPE__ vaddr_t;
typedef __UINTPTR_TYPE__ vsize_t;
#define PRIxVADDR PRIxPTR
#define PRIxVSIZE PRIxPTR
#define PRIuVSIZE PRIuPTR
#ifdef _LP64 // match <riscv/reg.h>
#define PRIxREGISTER PRIx64
typedef __int64_t register_t;
typedef __uint64_t uregister_t;
#else
#define PRIxREGISTER PRIx32
typedef __int32_t register_t;
typedef __uint32_t uregister_t;
#endif
typedef signed int register32_t;
typedef unsigned int uregister32_t;
#define PRIxREGISTER32 "x"
typedef unsigned int tlb_asid_t;
#endif
#if defined(_KERNEL)
typedef struct label_t { /* Used by setjmp & longjmp */
register_t lb_reg[16]; /* */
__uint32_t lb_sr;
} label_t;
#endif
typedef unsigned int __cpu_simple_lock_nv_t;
#ifdef _LP64
typedef __int64_t __register_t;
#else
typedef __int32_t __register_t;
#endif
#define __SIMPLELOCK_LOCKED 1
#define __SIMPLELOCK_UNLOCKED 0
#define __HAVE_COMMON___TLS_GET_ADDR
#define __HAVE_COMPAT_NETBSD32
#define __HAVE_CPU_COUNTER
#define __HAVE_CPU_DATA_FIRST
#define __HAVE_FAST_SOFTINTS
#define __HAVE_MM_MD_DIRECT_MAPPED_PHYS
#define __HAVE_NEW_STYLE_BUS_H
#define __HAVE_SYSCALL_INTERN
#define __HAVE_TLS_VARIANT_I
/* XXX temporary */
#define __HAVE_UNLOCKED_PMAP
#define __HAVE___LWP_GETPRIVATE_FAST
#ifdef __LP64
#define __HAVE_ATOMIC64_OPS
#define __HAVE_CPU_UAREA_ROUTINES
#endif
//#if defined(_KERNEL)
//#define __HAVE_RAS
//#endif
#if defined(_KERNEL) || defined(_KMEMUSER)
#define PCU_FPU 0
#define PCU_UNIT_COUNT 1
#endif
#endif /* _RISCV_TYPES_H_ */

View File

@@ -1,203 +0,0 @@
/* $NetBSD: vmparam.h,v 1.13 2022/10/16 06:14:53 skrll Exp $ */
/*-
* Copyright (c) 2014, 2020 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Matt Thomas of 3am Software Foundry, and Nick Hudson.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _RISCV_VMPARAM_H_
#define _RISCV_VMPARAM_H_
#include <riscv/param.h>
#ifdef _KERNEL_OPT
#include "opt_multiprocessor.h"
#endif
/*
* Machine dependent VM constants for RISCV.
*/
/*
* We use a 4K page on both RV64 and RV32 systems.
* Override PAGE_* definitions to compile-time constants.
*/
#define PAGE_SHIFT PGSHIFT
#define PAGE_SIZE (1 << PAGE_SHIFT)
#define PAGE_MASK (PAGE_SIZE - 1)
/*
* USRSTACK is the top (end) of the user stack.
*
* USRSTACK needs to start a page below the maxuser address so that a memory
* access with a maximum displacement (0x7ff) won't cross into the kernel's
* address space. We use PAGE_SIZE instead of 0x800 since these need to be
* page-aligned.
*/
#define USRSTACK (VM_MAXUSER_ADDRESS-PAGE_SIZE) /* Start of user stack */
#define USRSTACK32 ((uint32_t)VM_MAXUSER_ADDRESS32-PAGE_SIZE)
/*
* Virtual memory related constants, all in bytes
*/
#ifndef MAXTSIZ
#define MAXTSIZ (128*1024*1024) /* max text size */
#endif
#ifndef DFLDSIZ
#define DFLDSIZ (256*1024*1024) /* initial data size limit */
#endif
#ifndef MAXDSIZ
#define MAXDSIZ (1536*1024*1024) /* max data size */
#endif
#ifndef DFLSSIZ
#define DFLSSIZ (4*1024*1024) /* initial stack size limit */
#endif
#ifndef MAXSSIZ
#define MAXSSIZ (120*1024*1024) /* max stack size */
#endif
/*
* Virtual memory related constants, all in bytes
*/
#ifndef DFLDSIZ32
#define DFLDSIZ32 DFLDSIZ /* initial data size limit */
#endif
#ifndef MAXDSIZ32
#define MAXDSIZ32 MAXDSIZ /* max data size */
#endif
#ifndef DFLSSIZ32
#define DFLSSIZ32 DFLTSIZ /* initial stack size limit */
#endif
#ifndef MAXSSIZ32
#define MAXSSIZ32 MAXSSIZ /* max stack size */
#endif
/*
* PTEs for mapping user space into the kernel for phyio operations.
* The default PTE number is enough to cover 8 disks * MAXBSIZE.
*/
#ifndef USRIOSIZE
#define USRIOSIZE (MAXBSIZE/PAGE_SIZE * 8)
#endif
/*
* User/kernel map constants.
*/
#define VM_MIN_ADDRESS ((vaddr_t)0x00000000)
#ifdef _LP64 /* Sv39 / Sv48 / Sv57 */
/*
* kernel virtual space layout:
* 0xffff_ffc0_0000_0000 - 64GiB KERNEL VM Space (inc. text/data/bss)
* (0xffff_ffc0_4000_0000 +1GiB) KERNEL VM start of KVA
* (0xffff_ffd0_0000_0000 64GiB) reserved
* 0xffff_ffe0_0000_0000 - 128GiB direct mapping
*/
#define VM_MAXUSER_ADDRESS ((vaddr_t)0x0000004000000000 - 16 * PAGE_SIZE)
#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)0xffffffc000000000)
#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)0xffffffd000000000)
#else /* Sv32 */
#define VM_MAXUSER_ADDRESS ((vaddr_t)-0x7fffffff-1)/* 0xffffffff80000000 */
#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)-0x7fffffff-1)/* 0xffffffff80000000 */
#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)-0x40000000) /* 0xffffffffc0000000 */
#endif
#define VM_KERNEL_BASE VM_MIN_KERNEL_ADDRESS
#define VM_KERNEL_SIZE 0x2000000 /* 32 MiB (8 / 16 megapages) */
#define VM_KERNEL_DTB_BASE (VM_KERNEL_BASE + VM_KERNEL_SIZE)
#define VM_KERNEL_DTB_SIZE 0x1000000 /* 16 MiB (4 / 8 megapages) */
#define VM_KERNEL_IO_BASE (VM_KERNEL_DTB_BASE + VM_KERNEL_DTB_SIZE)
#define VM_KERNEL_IO_SIZE 0x1000000 /* 16 MiB (4 / 8 megapages) */
#define VM_KERNEL_RESERVED (VM_KERNEL_SIZE + VM_KERNEL_DTB_SIZE + VM_KERNEL_IO_SIZE)
#define VM_KERNEL_VM_BASE (VM_MIN_KERNEL_ADDRESS + VM_KERNEL_RESERVED)
#define VM_KERNEL_VM_SIZE (VM_MAX_KERNEL_ADDRESS - VM_KERNEL_VM_BASE)
#define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS
#define VM_MAXUSER_ADDRESS32 ((vaddr_t)(1UL << 31))/* 0x0000000080000000 */
#ifdef _LP64
/*
* Since we have the address space, we map all of physical memory (RAM)
* using gigapages on SV39, terapages on SV48 and petapages on SV57.
*/
#define RISCV_DIRECTMAP_MASK ((vaddr_t) 0xffffffe000000000L)
#define RISCV_DIRECTMAP_SIZE (-RISCV_DIRECTMAP_MASK - PAGE_SIZE) /* 128GiB */
#define RISCV_DIRECTMAP_START RISCV_DIRECTMAP_MASK
#define RISCV_DIRECTMAP_END (RISCV_DIRECTMAP_START + RISCV_DIRECTMAP_SIZE)
#define RISCV_KVA_P(va) (((vaddr_t) (va) & RISCV_DIRECTMAP_MASK) != 0)
#define RISCV_PA_TO_KVA(pa) ((vaddr_t) ((pa) | RISCV_DIRECTMAP_START))
#define RISCV_KVA_TO_PA(va) ((paddr_t) ((va) & ~RISCV_DIRECTMAP_MASK))
#endif
/*
* The address to which unspecified mapping requests default
*/
#define __USE_TOPDOWN_VM
#define VM_DEFAULT_ADDRESS_TOPDOWN(da, sz) \
trunc_page(USRSTACK - MAXSSIZ - (sz) - user_stack_guard_size)
#define VM_DEFAULT_ADDRESS_BOTTOMUP(da, sz) \
round_page((vaddr_t)(da) + (vsize_t)maxdmap)
#define VM_DEFAULT_ADDRESS32_TOPDOWN(da, sz) \
trunc_page(USRSTACK32 - MAXSSIZ32 - (sz) - user_stack_guard_size)
#define VM_DEFAULT_ADDRESS32_BOTTOMUP(da, sz) \
round_page((vaddr_t)(da) + (vsize_t)MAXDSIZ32)
/* virtual sizes (bytes) for various kernel submaps */
#define VM_PHYS_SIZE (USRIOSIZE*PAGE_SIZE)
/* VM_PHYSSEG_MAX defined by platform-dependent code. */
#ifndef VM_PHYSSEG_MAX
#define VM_PHYSSEG_MAX 16
#endif
#if VM_PHYSSEG_MAX == 1
#define VM_PHYSSEG_STRAT VM_PSTRAT_BIGFIRST
#else
#define VM_PHYSSEG_STRAT VM_PSTRAT_BSEARCH
#endif
#define VM_PHYSSEG_NOADD /* can add RAM after vm_mem_init */
#ifndef VM_NFREELIST
#define VM_NFREELIST 2 /* 2 distinct memory segments */
#define VM_FREELIST_DEFAULT 0
#define VM_FREELIST_DIRECTMAP 1
#endif
#ifdef _KERNEL
#define UVM_KM_VMFREELIST riscv_poolpage_vmfreelist
extern int riscv_poolpage_vmfreelist;
#ifdef _LP64
void * cpu_uarea_alloc(bool);
bool cpu_uarea_free(void *);
#endif
#endif
#endif /* ! _RISCV_VMPARAM_H_ */

View File

@@ -1,3 +0,0 @@
/* $NetBSD: wchar_limits.h,v 1.1 2014/09/19 17:36:26 matt Exp $ */
#include <sys/common_wchar_limits.h>