summaryrefslogtreecommitdiff
path: root/distrib/riscv64
diff options
context:
space:
mode:
authorDale Rahn <drahn@cvs.openbsd.org>2021-04-27 23:57:39 +0000
committerDale Rahn <drahn@cvs.openbsd.org>2021-04-27 23:57:39 +0000
commit8cc6543bade0617ef6dc028341657ad55cfd731e (patch)
tree22b9c01594cd5e18e3c8cba3c64204fa66c2b1fa /distrib/riscv64
parent027e0fd33bd7fe97d584feeba5c8d50f320dc9de (diff)
Riscv64 distrib pieces to buld ramdisk
Copied from arm64 with minimal changes. ok deraadt@
Diffstat (limited to 'distrib/riscv64')
-rw-r--r--distrib/riscv64/Makefile8
-rw-r--r--distrib/riscv64/ramdisk/Makefile95
-rw-r--r--distrib/riscv64/ramdisk/install.md136
-rw-r--r--distrib/riscv64/ramdisk/list97
4 files changed, 336 insertions, 0 deletions
diff --git a/distrib/riscv64/Makefile b/distrib/riscv64/Makefile
new file mode 100644
index 00000000000..512ed7b9b75
--- /dev/null
+++ b/distrib/riscv64/Makefile
@@ -0,0 +1,8 @@
+# $OpenBSD: Makefile,v 1.1 2021/04/27 23:57:38 drahn Exp $
+
+SUBDIR= ramdisk
+
+unconfig:
+ cd ramdisk; ${MAKE} unconfig
+
+.include <bsd.subdir.mk>
diff --git a/distrib/riscv64/ramdisk/Makefile b/distrib/riscv64/ramdisk/Makefile
new file mode 100644
index 00000000000..386a7e95935
--- /dev/null
+++ b/distrib/riscv64/ramdisk/Makefile
@@ -0,0 +1,95 @@
+# $OpenBSD: Makefile,v 1.1 2021/04/27 23:57:38 drahn Exp $
+
+FS= miniroot${OSrev}.img
+FSSIZE= 67584
+FSDISKTYPE= miniroot
+MOUNT_POINT= /mnt
+MTREE= ${UTILS}/mtree.conf
+RAMDISK= RAMDISK
+
+MSDOSSTART= 32768
+MSDOSSIZE= 8192
+FFSSTART!= expr ${MSDOSSTART} + ${MSDOSSIZE}
+
+NEWFS_ARGS_msdos=-L boot -c1 -F16
+MOUNT_ARGS_msdos=-o-l
+
+LISTS= ${.CURDIR}/list
+UTILS= ${.CURDIR}/../../miniroot
+
+MRFSDISKTYPE= rdrootc
+MRMAKEFSARGS= -o disklabel=${MRFSDISKTYPE},minfree=0,density=8192
+
+all: ${FS}
+
+${FS}: bsd.rd
+ dd if=/dev/zero of=${FS} bs=512 count=${FSSIZE}
+ vnconfig -v -t ${FSDISKTYPE} ${FS} > vnd
+ echo 'u\ne 0\nc\nn\n${MSDOSSTART}\n${MSDOSSIZE}\ne 3\nA6\nn\n${FFSSTART}\n*\nf 0\nw\nq\n' \
+ | fdisk -e `cat vnd` >/dev/null
+ echo 'a a\n\n\n\nw\nq\n' | disklabel -E `cat vnd` >/dev/null
+ newfs -t msdos ${NEWFS_ARGS_msdos} /dev/r`cat vnd`i
+ mount ${MOUNT_ARGS_msdos} /dev/`cat vnd`i ${MOUNT_POINT}
+ mkdir -p ${MOUNT_POINT}/efi/boot
+ cp ${DESTDIR}/usr/mdec/BOOTRISCV64.EFI ${MOUNT_POINT}/efi/boot/bootriscv64.efi
+ echo bootriscv64.efi > ${MOUNT_POINT}/efi/boot/startup.nsh
+ umount ${MOUNT_POINT}
+ newfs -O 1 -m 0 -o space -i 524288 -c ${FSSIZE} /dev/r`cat vnd`a
+ mount /dev/`cat vnd`a ${MOUNT_POINT}
+ install -c -m 555 -o root -g wheel bsd.rd ${MOUNT_POINT}/bsd
+ ln ${MOUNT_POINT}/bsd ${MOUNT_POINT}/bsd.rd
+ df -i ${MOUNT_POINT}
+ umount ${MOUNT_POINT}
+ vnconfig -u `cat vnd`
+ rm -f vnd
+
+bsd.rd: mr.fs bsd
+ cp bsd bsd.rd
+ rdsetroot bsd.rd mr.fs
+
+bsd:
+ cd ${.CURDIR}/../../../sys/arch/${MACHINE}/compile/${RAMDISK} && \
+ su ${BUILDUSER} -c '${MAKE} config && ${MAKE} clean && exec ${MAKE}'
+ cp -p ${.CURDIR}/../../../sys/arch/${MACHINE}/compile/${RAMDISK}/obj/bsd bsd
+
+mr.fs: instbin
+ rm -rf $@.d
+ install -d -o root -g wheel $@.d
+.for DIR in ${DIRS}
+ mkdir -p $@.d/usr/mdec/${DIR}
+.endfor
+ mtree -def ${MTREE} -p $@.d -u
+ CURDIR=${.CURDIR} OBJDIR=${.OBJDIR} OSrev=${OSrev} \
+ TARGDIR=$@.d UTILS=${UTILS} RELEASEDIR=${RELEASEDIR} \
+ sh ${UTILS}/runlist.sh ${LISTS}
+ rm $@.d/instbin
+ makefs ${MRMAKEFSARGS} $@ $@.d
+
+instbin.mk instbin.cache instbin.c: instbin.conf
+ crunchgen -O obj.${HOST}.${MACHINE} -E -D ${.CURDIR}/../../.. -L /usr/cross/riscv64/usr/lib \
+ -c instbin.c -e instbin -m instbin.mk instbin.conf
+
+instbin: instbin.mk instbin.cache instbin.c
+ ${MAKE} -f instbin.mk SRCLIBDIR=${.CURDIR}/../../../lib all
+
+instbin.conf: ${LISTS}
+ awk -f ${UTILS}/makeconf.awk ${LISTS} > instbin.conf
+
+unconfig:
+ -umount -f ${MOUNT_POINT}
+ -[ -f vnd ] && vnconfig -u `cat vnd` && rm -f vnd
+
+.ifdef RELEASEDIR
+install:
+ cp bsd.rd ${RELEASEDIR}/bsd.rd
+ chmod a+r ${RELEASEDIR}/bsd.rd
+ cp ${FS} ${RELEASEDIR}
+.endif
+
+clean cleandir:
+ rm -f *.core mr.fs instbin instbin.mk instbin.cache \
+ lib*.a lib*.olist instbin.map *.o *.lo *.c bsd.rd
+ rm -f instbin.conf
+ rm -rf cd-dir mr.fs.d
+
+.include <bsd.obj.mk>
diff --git a/distrib/riscv64/ramdisk/install.md b/distrib/riscv64/ramdisk/install.md
new file mode 100644
index 00000000000..2f3d6562ec5
--- /dev/null
+++ b/distrib/riscv64/ramdisk/install.md
@@ -0,0 +1,136 @@
+# $OpenBSD: install.md,v 1.1 2021/04/27 23:57:38 drahn Exp $
+#
+#
+# Copyright (c) 1996 The NetBSD Foundation, Inc.
+# All rights reserved.
+#
+# This code is derived from software contributed to The NetBSD Foundation
+# by Jason R. Thorpe.
+#
+# 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 REGENTS 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.
+#
+#
+# machine dependent section of installation/upgrade script.
+#
+
+NCPU=$(sysctl -n hw.ncpufound)
+NEWFSARGS_msdos="-F 16 -L boot"
+MOUNT_ARGS_msdos="-o-l"
+
+md_installboot() {
+ local _disk=/dev/$1
+
+ mount ${MOUNT_ARGS_msdos} ${_disk}i /mnt/mnt
+ mkdir -p /mnt/mnt/efi/boot
+ cp /mnt/usr/mdec/BOOTRISCV64.EFI /mnt/mnt/efi/boot/bootriscv64.efi
+ echo bootriscv64.efi > /mnt/mnt/efi/boot/startup.nsh
+}
+
+md_prep_fdisk() {
+ local _disk=$1 _d
+
+ local bootparttype="C"
+ local bootsectorstart="32768"
+ local bootsectorsize="32768"
+ local bootsectorend=$(($bootsectorstart + $bootsectorsize))
+ local bootfstype="msdos"
+ local newfs_args=${NEWFSARGS_msdos}
+
+ while :; do
+ _d=whole
+ if disk_has $_disk mbr; then
+ fdisk $_disk
+ else
+ echo "MBR has invalid signature; not showing it."
+ fi
+ ask "Use (W)hole disk or (E)dit the MBR?" "$_d"
+ case $resp in
+ [wW]*)
+ echo -n "Creating a ${bootfstype} partition and an OpenBSD partition for rest of $_disk..."
+ fdisk -e ${_disk} <<__EOT >/dev/null
+reinit
+e 0
+${bootparttype}
+n
+${bootsectorstart}
+${bootsectorsize}
+f 0
+e 3
+A6
+n
+${bootsectorend}
+
+write
+quit
+__EOT
+ echo "done."
+ disklabel $_disk 2>/dev/null | grep -q "^ i:" || disklabel -w -d $_disk
+ newfs -t ${bootfstype} ${newfs_args} ${_disk}i
+ return ;;
+ [eE]*)
+ # Manually configure the MBR.
+ cat <<__EOT
+
+You will now create one MBR partition to contain your OpenBSD data
+and one MBR partition on which the OpenBSD boot program is located.
+Neither partition will overlap any other partition.
+
+The OpenBSD MBR partition will have an id of 'A6' and the boot MBR
+partition will have an id of '${bootparttype}' (${bootfstype}).
+The boot partition will be at least 16MB and be the first 'MSDOS'
+partition on the disk.
+
+$(fdisk ${_disk})
+__EOT
+ fdisk -e ${_disk}
+ disk_has $_disk mbr openbsd && return
+ echo No OpenBSD partition in MBR, try again. ;;
+ esac
+ done
+}
+
+md_prep_disklabel() {
+ local _disk=$1 _f=/tmp/i/fstab.$1
+
+ md_prep_fdisk $_disk
+
+ disklabel_autolayout $_disk $_f || return
+ [[ -s $_f ]] && return
+
+ # Edit disklabel manually.
+ # Abandon all hope, ye who enter here.
+ disklabel -F $_f -E $_disk
+}
+
+md_congrats() {
+}
+
+md_consoleinfo() {
+ CTTY=console
+ DEFCONS=y
+ case $CSPEED in
+ 9600|19200|38400|57600|115200|1500000)
+ ;;
+ *)
+ CSPEED=115200;;
+ esac
+}
diff --git a/distrib/riscv64/ramdisk/list b/distrib/riscv64/ramdisk/list
new file mode 100644
index 00000000000..4a768750bbf
--- /dev/null
+++ b/distrib/riscv64/ramdisk/list
@@ -0,0 +1,97 @@
+# $OpenBSD: list,v 1.1 2021/04/27 23:57:38 drahn Exp $
+
+SRCDIRS distrib/special
+
+# copy the crunched binary, link to it, and kill it
+COPY ${OBJDIR}/instbin instbin
+LINK instbin bin/arch
+LINK instbin bin/cat
+LINK instbin bin/chmod bin/chgrp sbin/chown
+LINK instbin bin/cp
+LINK instbin bin/date
+LINK instbin bin/dd
+LINK instbin bin/df
+LINK instbin bin/ed
+LINK instbin bin/hostname
+LINK instbin bin/ksh bin/sh
+LINK instbin bin/ln
+LINK instbin bin/ls
+LINK instbin bin/md5 bin/sha256 bin/sha512
+LINK instbin bin/mkdir
+LINK instbin bin/mt bin/eject
+LINK instbin bin/mv
+LINK instbin bin/pax bin/tar
+LINK instbin bin/rm
+LINK instbin bin/sleep
+LINK instbin bin/stty
+LINK instbin bin/sync
+LINK instbin sbin/bioctl
+LINK instbin sbin/dhclient
+LINK instbin sbin/disklabel
+LINK instbin sbin/dmesg
+LINK instbin sbin/fdisk
+LINK instbin sbin/fsck
+LINK instbin sbin/fsck_ext2fs
+LINK instbin sbin/fsck_ffs
+LINK instbin sbin/growfs
+LINK instbin sbin/ifconfig
+LINK instbin sbin/init
+LINK instbin sbin/mknod
+LINK instbin sbin/mount
+LINK instbin sbin/mount_cd9660
+LINK instbin sbin/mount_ext2fs
+LINK instbin sbin/mount_ffs
+LINK instbin sbin/mount_msdos
+LINK instbin sbin/mount_nfs
+LINK instbin sbin/newfs
+LINK instbin sbin/newfs_msdos
+LINK instbin sbin/ping sbin/ping6
+LINK instbin sbin/reboot sbin/halt
+LINK instbin sbin/route
+LINK instbin sbin/slaacd
+LINK instbin sbin/sysctl
+LINK instbin sbin/umount
+LINK instbin usr/bin/doas
+LINK instbin usr/bin/encrypt
+LINK instbin usr/bin/grep usr/bin/egrep usr/bin/fgrep
+LINK instbin usr/bin/gzip usr/bin/gunzip usr/bin/gzcat
+LINK instbin usr/bin/more usr/bin/less
+LINK instbin usr/bin/sed
+LINK instbin usr/bin/signify
+LINK instbin usr/bin/tee
+LINK instbin usr/sbin/chroot
+LINK instbin usr/sbin/pwd_mkdb
+ARGVLINK ksh -sh
+SPECIAL rm bin/md5
+
+SPECIAL awk -f ${UTILS}/trimcerts.awk ${DESTDIR}/etc/ssl/cert.pem etc/ssl/cert.pem
+LINK instbin usr/bin/ftp-ssl usr/bin/ftp
+SPECIAL rm usr/bin/ftp-ssl
+
+# copy the MAKEDEV script and make some devices
+SCRIPT ${DESTDIR}/dev/MAKEDEV dev/MAKEDEV
+SPECIAL cd dev; sh MAKEDEV ramdisk
+
+# various files that we need in /etc for the install
+COPY ${CURDIR}/../../miniroot/group etc/group
+COPY ${CURDIR}/../../miniroot/master.passwd etc/master.passwd
+SPECIAL pwd_mkdb -p -d etc master.passwd; rm etc/master.passwd
+COPY ${DESTDIR}/etc/signify/openbsd-${OSrev}-base.pub etc/signify/openbsd-${OSrev}-base.pub
+COPY ${CURDIR}/../../miniroot/protocols etc/protocols
+COPY ${CURDIR}/../../miniroot/services etc/services
+TERMCAP vt100,vt220,dumb usr/share/misc/termcap
+
+SYMLINK /tmp/i/fstab.shadow etc/fstab
+SYMLINK /tmp/i/resolv.conf.shadow etc/resolv.conf
+SYMLINK /tmp/i/hosts etc/hosts
+
+# and the installation tools
+SCRIPT ${CURDIR}/../../miniroot/dot.profile .profile
+SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub
+SCRIPT ${CURDIR}/install.md install.md
+SPECIAL chmod 755 install.sub
+SYMLINK install.sub autoinstall
+SYMLINK install.sub install
+SYMLINK install.sub upgrade
+
+TZ