Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/lib/libc/gen RISC-V support that works on QEMU with a ...
details: https://anonhg.NetBSD.org/src/rev/b93a3eac229b
branches: trunk
changeset: 374594:b93a3eac229b
user: skrll <skrll%NetBSD.org@localhost>
date: Sun May 07 12:41:45 2023 +0000
description:
RISC-V support that works on QEMU with a single hart.
Thanks for Simon Burge for plic(4).
diffstat:
common/lib/libc/arch/riscv/atomic/atomic_sub_64.S | 4 +-
distrib/sets/lists/debug/module.ad.riscv32 | 3 +
distrib/sets/lists/debug/module.ad.riscv64 | 5 +
distrib/sets/lists/modules/ad.riscv32 | 3 +
distrib/sets/lists/modules/ad.riscv64 | 6 +
distrib/utils/embedded/conf/riscv.conf | 157 +
distrib/utils/embedded/conf/riscv32.conf | 46 +
distrib/utils/embedded/conf/riscv64.conf | 51 +
etc/etc.riscv/Makefile.inc | 60 +-
external/gpl3/gdb.old/dist/bfd/configure | 3 +
external/gpl3/gdb.old/dist/bfd/configure.ac | 3 +
external/gpl3/gdb.old/dist/gdb/configure.host | 1 +
external/gpl3/gdb.old/dist/gdb/configure.nat | 4 +
external/gpl3/gdb.old/dist/gdb/configure.tgt | 5 +
external/gpl3/gdb.old/dist/gdb/riscv-nbsd-nat.c | 143 +
external/gpl3/gdb.old/dist/gdb/riscv-nbsd-tdep.c | 231 +
external/gpl3/gdb.old/dist/gdb/riscv-nbsd-tdep.h | 37 +
external/gpl3/gdb/dist/bfd/configure | 3 +
external/gpl3/gdb/dist/bfd/configure.ac | 3 +
external/gpl3/gdb/dist/gdb/configure.nat | 4 +
external/gpl3/gdb/dist/gdb/configure.tgt | 5 +
external/gpl3/gdb/dist/gdb/riscv-nbsd-nat.c | 143 +
external/gpl3/gdb/dist/gdb/riscv-nbsd-tdep.c | 231 +
external/gpl3/gdb/dist/gdb/riscv-nbsd-tdep.h | 37 +
lib/csu/arch/riscv/crt0.S | 9 +-
lib/libc/arch/riscv/SYS.h | 27 +-
lib/libc/arch/riscv/gen/__setjmp14.S | 11 +-
lib/libc/arch/riscv/gen/fpgetmask.c | 6 +-
lib/libc/arch/riscv/gen/fpgetround.c | 6 +-
lib/libc/arch/riscv/gen/fpgetsticky.c | 6 +-
lib/libc/arch/riscv/gen/fpsetmask.c | 6 +-
lib/libc/arch/riscv/gen/fpsetround.c | 6 +-
lib/libc/arch/riscv/gen/fpsetsticky.c | 7 +-
lib/libc/arch/riscv/gen/makecontext.c | 10 +-
lib/libc/arch/riscv/sys/__sigtramp2.S | 7 +-
lib/libc/arch/riscv/sys/__syscall.S | 17 +-
lib/libc/arch/riscv/sys/brk.S | 7 +-
lib/libc/arch/riscv/sys/fork.S | 12 +-
lib/libc/arch/riscv/sys/getcontext.S | 11 +-
lib/libc/arch/riscv/sys/ptrace.S | 16 +-
lib/libc/arch/riscv/sys/sbrk.S | 6 +-
lib/libc/stdlib/jemalloc.c | 17 +-
lib/libm/arch/riscv/fenv.c | 48 +-
lib/libpthread/arch/riscv/pthread_md.h | 4 +-
libexec/ld.elf_so/arch/riscv/mdreloc.c | 145 +-
libexec/ld.elf_so/arch/riscv/rtld_start.S | 35 +-
share/mk/bsd.kmodule.mk | 4 +-
share/mk/bsd.own.mk | 4 +-
sys/arch/riscv/conf/GENERIC | 184 +-
sys/arch/riscv/conf/GENERIC.common | 203 +
sys/arch/riscv/conf/GENERIC64 | 50 +
sys/arch/riscv/conf/Makefile.riscv | 11 +-
sys/arch/riscv/conf/files.generic | 4 +
sys/arch/riscv/conf/files.generic64 | 7 +
sys/arch/riscv/conf/files.riscv | 45 +-
sys/arch/riscv/conf/majors.riscv | 4 +-
sys/arch/riscv/conf/std.riscv64 | 38 +-
sys/arch/riscv/dev/plic.c | 220 +
sys/arch/riscv/dev/plic_fdt.c | 252 +
sys/arch/riscv/dev/plicreg.h | 52 +
sys/arch/riscv/dev/plicvar.h | 68 +
sys/arch/riscv/fdt/clint_fdt.c | 268 ++
sys/arch/riscv/fdt/cpu_fdt.c | 67 +
sys/arch/riscv/fdt/fdt_cpus_machdep.c | 61 +
sys/arch/riscv/fdt/fdt_dma_machdep.c | 36 +-
sys/arch/riscv/fdt/files.fdt | 19 +
sys/arch/riscv/fdt/intc_fdt.c | 327 ++
sys/arch/riscv/fdt/riscv_platform.c | 95 +
sys/arch/riscv/include/asm.h | 3 +-
sys/arch/riscv/include/bus_defs.h | 25 +-
sys/arch/riscv/include/bus_funcs.h | 8 +-
sys/arch/riscv/include/cdefs.h | 4 +-
sys/arch/riscv/include/cpu.h | 9 +-
sys/arch/riscv/include/cpufunc.h | 68 +
sys/arch/riscv/include/cpuvar.h | 43 +
sys/arch/riscv/include/db_machdep.h | 7 +-
sys/arch/riscv/include/frame.h | 54 +-
sys/arch/riscv/include/intr.h | 31 +-
sys/arch/riscv/include/loadfile_machdep.h | 11 +-
sys/arch/riscv/include/locore.h | 59 +-
sys/arch/riscv/include/machdep.h | 17 +-
sys/arch/riscv/include/mcontext.h | 42 +-
sys/arch/riscv/include/param.h | 54 +-
sys/arch/riscv/include/pcb.h | 11 +-
sys/arch/riscv/include/pmap.h | 52 +-
sys/arch/riscv/include/proc.h | 9 +-
sys/arch/riscv/include/pte.h | 83 +-
sys/arch/riscv/include/sbi.h | 462 +++
sys/arch/riscv/include/sysreg.h | 54 +-
sys/arch/riscv/include/types.h | 9 +-
sys/arch/riscv/include/vmparam.h | 73 +-
sys/arch/riscv/riscv/autoconf.c | 21 +-
sys/arch/riscv/riscv/bus_dma.c | 1921 +++++++++++++++
sys/arch/riscv/riscv/bus_space.c | 226 +-
sys/arch/riscv/riscv/bus_space_generic.S | 10 +-
sys/arch/riscv/riscv/bus_space_notimpl.S | 2 +-
sys/arch/riscv/riscv/bus_stubs.c | 99 +
sys/arch/riscv/riscv/clock_machdep.c | 95 +-
sys/arch/riscv/riscv/core_machdep.c | 5 +-
sys/arch/riscv/riscv/cpu.c | 179 +
sys/arch/riscv/riscv/cpu_switch.S | 122 +-
sys/arch/riscv/riscv/db_disasm.c | 5 +-
sys/arch/riscv/riscv/db_trace.c | 48 +-
sys/arch/riscv/riscv/fpu.c | 50 +-
sys/arch/riscv/riscv/genassym.cf | 33 +-
sys/arch/riscv/riscv/interrupt.c | 135 +
sys/arch/riscv/riscv/kobj_machdep.c | 519 +++-
sys/arch/riscv/riscv/locore.S | 52 +-
sys/arch/riscv/riscv/mainbus.c | 92 +-
sys/arch/riscv/riscv/pmap_machdep.c | 189 +-
sys/arch/riscv/riscv/process_machdep.c | 5 +-
sys/arch/riscv/riscv/riscv_generic_dma.c | 41 +
sys/arch/riscv/riscv/riscv_machdep.c | 510 +++-
sys/arch/riscv/riscv/sbi.c | 259 ++
sys/arch/riscv/riscv/sig_machdep.c | 5 +-
sys/arch/riscv/riscv/softint_machdep.c | 8 +-
sys/arch/riscv/riscv/spl.S | 111 +-
sys/arch/riscv/riscv/syscall.c | 46 +-
sys/arch/riscv/riscv/trap.c | 340 ++-
sys/arch/riscv/riscv/vm_machdep.c | 26 +-
sys/dev/fdt/cpus.c | 11 +-
sys/dev/usb/udl.c | 6 +-
sys/external/bsd/compiler_rt/dist/lib/builtins/clzdi2.c | 2 +-
sys/external/bsd/compiler_rt/dist/lib/builtins/ctzdi2.c | 2 +-
sys/modules/Makefile | 3 +-
tests/lib/csu/arch/riscv/h_initfini_align.S | 15 +
tests/lib/libc/gen/t_siginfo.c | 5 +-
127 files changed, 8914 insertions(+), 1098 deletions(-)
diffs (truncated from 13607 to 300 lines):
diff -r ee1a6e54eefc -r b93a3eac229b common/lib/libc/arch/riscv/atomic/atomic_sub_64.S
--- a/common/lib/libc/arch/riscv/atomic/atomic_sub_64.S Sun May 07 12:26:32 2023 +0000
+++ b/common/lib/libc/arch/riscv/atomic/atomic_sub_64.S Sun May 07 12:41:45 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: atomic_sub_64.S,v 1.2 2015/03/27 06:42:37 matt Exp $ */
+/* $NetBSD: atomic_sub_64.S,v 1.3 2023/05/07 12:41:45 skrll Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -75,5 +75,5 @@ CRT_ALIAS(__atomic_sub_fetch_8,_atomic_s
ATOMIC_OP_ALIAS(atomic_dec_64_nv,_atomic_dec_64_nv)
ATOMIC_OP_ALIAS(atomic_dec_ulong_nv,_atomic_dec_64_nv)
STRONG_ALIAS(_atomic_dec_ulong_nv,_atomic_dec_64_nv)
-ATOMIC_OP_ALIAS(atomic_dec_ptr_nv,_atomic_sub_64_nv)
+ATOMIC_OP_ALIAS(atomic_dec_ptr_nv,_atomic_dec_64_nv)
STRONG_ALIAS(_atomic_sub_ptr_nv,_atomic_sub_64_nv)
diff -r ee1a6e54eefc -r b93a3eac229b distrib/sets/lists/debug/module.ad.riscv32
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/sets/lists/debug/module.ad.riscv32 Sun May 07 12:41:45 2023 +0000
@@ -0,0 +1,3 @@
+# $NetBSD: module.ad.riscv32,v 1.1 2023/05/07 12:41:45 skrll Exp $
+./usr/libdata/debug/@MODULEDIR@/exec_elf32 modules-base-kernel kmod,debug
+./usr/libdata/debug/@MODULEDIR@/exec_elf32/exec_elf32.kmod.debug modules-base-kernel kmod,debug
diff -r ee1a6e54eefc -r b93a3eac229b distrib/sets/lists/debug/module.ad.riscv64
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/sets/lists/debug/module.ad.riscv64 Sun May 07 12:41:45 2023 +0000
@@ -0,0 +1,5 @@
+# $NetBSD: module.ad.riscv64,v 1.1 2023/05/07 12:41:45 skrll Exp $
+./usr/libdata/debug/@MODULEDIR@/exec_elf32 modules-base-kernel kmod,debug
+./usr/libdata/debug/@MODULEDIR@/exec_elf32/exec_elf32.kmod.debug modules-base-kernel kmod,debug
+./usr/libdata/debug/@MODULEDIR@/exec_elf64 modules-base-kernel kmod,debug
+./usr/libdata/debug/@MODULEDIR@/exec_elf64/exec_elf64.kmod.debug modules-base-kernel kmod,debug
diff -r ee1a6e54eefc -r b93a3eac229b distrib/sets/lists/modules/ad.riscv32
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/sets/lists/modules/ad.riscv32 Sun May 07 12:41:45 2023 +0000
@@ -0,0 +1,3 @@
+# $NetBSD: ad.riscv32,v 1.1 2023/05/07 12:41:46 skrll Exp $
+./@MODULEDIR@/exec_elf32 modules-base-kernel kmod
+./@MODULEDIR@/exec_elf32/exec_elf32.kmod modules-base-kernel kmod
diff -r ee1a6e54eefc -r b93a3eac229b distrib/sets/lists/modules/ad.riscv64
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/sets/lists/modules/ad.riscv64 Sun May 07 12:41:45 2023 +0000
@@ -0,0 +1,6 @@
+# $NetBSD: ad.riscv64,v 1.1 2023/05/07 12:41:46 skrll Exp $
+./@MODULEDIR@/exec_elf32 modules-base-kernel kmod
+./@MODULEDIR@/exec_elf32/exec_elf32.kmod modules-base-kernel kmod
+./@MODULEDIR@/exec_elf64 modules-base-kernel kmod
+./@MODULEDIR@/exec_elf64/exec_elf64.kmod modules-base-kernel kmod
+
diff -r ee1a6e54eefc -r b93a3eac229b distrib/utils/embedded/conf/riscv.conf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/utils/embedded/conf/riscv.conf Sun May 07 12:41:45 2023 +0000
@@ -0,0 +1,157 @@
+# $NetBSD: riscv.conf,v 1.1 2023/05/07 12:41:46 skrll Exp $
+# riscv shared config
+#
+image=$HOME/${board}.img
+
+extra=48 # spare space
+init=32
+boot=$((192 - ${init}))
+ffsoffset=$(( (${init} + ${boot}) / 2 ))m
+
+size=0 # autocompute
+msdosid=12
+
+if $gpt; then
+ partition_type="gpt"
+else
+ partition_type="disklabel"
+fi
+
+mkdir -p ${mnt}/boot
+
+make_label_riscv() {
+ # compute all sizes in terms of sectors
+ local totalsize=$(( ${size} / 512 ))
+
+ local bootsize=$(( ${boot} * 1024 ))
+
+ local bootoffset=$(( ${init} * 1024 ))
+
+ local asize=$(( ${totalsize} - ${bootsize} - ${bootoffset} ))
+ local aoffset=$(( ${bootoffset} + ${bootsize} ))
+
+ local bps=512
+ local spt=32
+ local tpc=64
+ local spc=2048
+ local cylinders=$(( ${totalsize} / ${spc} ))
+
+ cat << EOF
+type: SCSI
+disk: STORAGE DEVICE
+label: fictitious
+flags: removable
+bytes/sector: ${bps}
+sectors/track: ${spt}
+tracks/cylinder: ${tpc}
+sectors/cylinder: ${spc}
+cylinders: ${cylinders}
+total sectors: ${totalsize}
+rpm: 3600
+interleave: 1
+trackskew: 0
+cylinderskew: 0
+headswitch: 0 # microseconds
+track-to-track seek: 0 # microseconds
+drivedata: 0
+
+8 partitions:
+# size offset fstype [fsize bsize cpg/sgs]
+ a: ${asize} ${aoffset} 4.2BSD ${fsize} ${bsize} 0 #
+ c: ${totalsize} 0 unused 0 0 #
+ e: ${bootsize} ${bootoffset} MSDOS #
+EOF
+}
+
+make_fstab_riscv_gpt() {
+ cat > ${mnt}/etc/fstab << EOF
+# NetBSD /etc/fstab
+# See /usr/share/examples/fstab/ for more examples.
+NAME=${gpt_label_ffs:-netbsd-root} / ffs rw,noatime 1 1
+NAME=${gpt_label_boot:-EFI} /boot msdos rw 1 1
+ptyfs /dev/pts ptyfs rw
+procfs /proc procfs rw
+tmpfs /var/shm tmpfs rw,-m1777,-sram%25
+EOF
+}
+
+make_fstab_riscv_normal() {
+ cat > ${mnt}/etc/fstab << EOF
+# NetBSD /etc/fstab
+# See /usr/share/examples/fstab/ for more examples.
+ROOT.a / ffs rw,noatime 1 1
+ROOT.e /boot msdos rw 1 1
+ptyfs /dev/pts ptyfs rw
+procfs /proc procfs rw
+tmpfs /var/shm tmpfs rw,-m1777,-sram%25
+EOF
+}
+
+make_fstab_riscv() {
+ if $gpt; then
+ make_fstab_riscv_gpt
+ else
+ make_fstab_riscv_normal
+ fi
+ echo "./etc/fstab type=file uname=root gname=wheel mode=0644" \
+ >> "$tmp/selected_sets"
+
+ # Missing mount points from fstab
+ echo "./proc type=dir uname=root gname=wheel mode=0755" \
+ >> "$tmp/selected_sets"
+}
+
+customize_riscv() {
+ cp ${release}/etc/rc.conf ${mnt}/etc/rc.conf
+ cat >> ${mnt}/etc/rc.conf << EOF
+dev_exists() {
+ if /sbin/drvctl -l \$1 >/dev/null 2>&1 ; then
+ printf YES
+ else
+ printf NO
+ fi
+}
+
+rc_configured=YES
+hostname=${hostname:-${board}}
+no_swap=YES
+savecore=NO
+sshd=YES
+dhcpcd=YES
+ntpd=YES
+ntpd_flags="-g"
+creds_msdos=YES
+creds_msdos_partition=/boot
+EOF
+
+ if $resize; then
+ cat >> ${mnt}/etc/rc.conf << EOF
+resize_${partition_type}=YES
+resize_root=YES
+resize_root_flags="-p"
+resize_root_postcmd="/sbin/reboot -n"
+EOF
+ fi
+
+ echo "./etc/rc.conf type=file uname=root gname=wheel mode=0644" \
+ >> "$tmp/selected_sets"
+
+ mkdir ${mnt}/etc/rc.d
+ for _f in resize_${partition_type} creds_msdos; do
+ cp ${DIR}/files/${_f} ${mnt}/etc/rc.d/${_f}
+ echo "./etc/rc.d/${_f} type=file uname=root gname=wheel mode=0555" \
+ >> "$tmp/selected_sets"
+ done
+
+ if [ ! -f ${release}/dev/MAKEDEV ]; then
+ echo ${PROG}: Missing ${release}/dev/MAKEDEV 1>&2
+ exit 1
+ fi
+ echo "${bar} running MAKEDEV ${bar}"
+ ${HOST_SH} ${release}/dev/MAKEDEV -s all | sed -e 's:^\./:\./dev/:' \
+ >> "$tmp/selected_sets"
+
+ echo "${bar} fixing up permissions"
+ echo "./boot type=dir uname=root gname=wheel mode=0755" \
+ >> "$tmp/selected_sets"
+}
diff -r ee1a6e54eefc -r b93a3eac229b distrib/utils/embedded/conf/riscv32.conf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/utils/embedded/conf/riscv32.conf Sun May 07 12:41:45 2023 +0000
@@ -0,0 +1,46 @@
+# $NetBSD: riscv32.conf,v 1.1 2023/05/07 12:41:46 skrll Exp $
+# RISCV32 customization script used by mkimage
+#
+board=riscv64
+console=fb
+resize=true
+gpt=true
+#gpt_hybrid=true
+gpt_create_flags="-p 16"
+gpt_label_boot="EFI"
+gpt_label_ffs="netbsd-root"
+
+. ${DIR}/conf/riscv.conf
+
+kernel_GENERIC="GENERIC"
+
+make_label() {
+ make_label_riscv
+}
+
+make_fstab() {
+ make_fstab_riscv
+}
+
+customize() {
+ customize_riscv
+ cat >> "${mnt}/etc/rc.conf" << EOF
+mdnsd=YES
+devpubd=YES
+wscons=\$(dev_exists wsdisplay0)
+dhcpcd_flags="\$dhcpcd_flags -b"
+EOF
+}
+
+populate_common() {
+ # Install kernel to root of the FFS partition
+ ${GZIP_CMD} -dc ${kernel}/netbsd-${kernel_GENERIC}.gz > "${mnt}/netbsd"
+ echo "./netbsd type=file uname=root gname=wheel mode=0755" \
+ >> "$tmp/selected_sets"
+}
+
+
+populate() {
+ # common configuration
+ populate_common
+}
diff -r ee1a6e54eefc -r b93a3eac229b distrib/utils/embedded/conf/riscv64.conf
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/distrib/utils/embedded/conf/riscv64.conf Sun May 07 12:41:45 2023 +0000
@@ -0,0 +1,51 @@
+# $NetBSD: riscv64.conf,v 1.1 2023/05/07 12:41:46 skrll Exp $
+# RISCV64 customization script used by mkimage
+#
+board=riscv64
+console=fb
+resize=true
+gpt=true
+#gpt_hybrid=true
+gpt_create_flags="-p 16"
+gpt_label_boot="EFI"
+gpt_label_ffs="netbsd-root"
+
+. ${DIR}/conf/riscv.conf
+
+kernel_GENERIC="GENERIC64"
+
+make_label() {
+ make_label_riscv
+}
+
+make_fstab() {
+ make_fstab_riscv
+}
+
+customize() {
+ customize_riscv
+ cat >> "${mnt}/etc/rc.conf" << EOF
+mdnsd=YES
+devpubd=YES
+wscons=\$(dev_exists wsdisplay0)
+dhcpcd_flags="\$dhcpcd_flags -b"
+EOF
+}
+
+populate_common() {
+ # Install EFI bootloader
Home |
Main Index |
Thread Index |
Old Index