Use installboot(8) in install.md of riscv64.
authorvisa <visa@openbsd.org>
Thu, 3 Feb 2022 10:27:33 +0000 (10:27 +0000)
committervisa <visa@openbsd.org>
Thu, 3 Feb 2022 10:27:33 +0000 (10:27 +0000)
OK kettenis@ deraadt@

distrib/riscv64/ramdisk/install.md
distrib/riscv64/ramdisk/list
distrib/special/installboot/Makefile

index 426f91e..5c83395 100644 (file)
@@ -1,4 +1,4 @@
-#      $OpenBSD: install.md,v 1.3 2021/08/02 21:46:39 kettenis Exp $
+#      $OpenBSD: install.md,v 1.4 2022/02/03 10:27:33 visa Exp $
 #
 #
 # Copyright (c) 1996 The NetBSD Foundation, Inc.
 #
 
 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
+       if ! installboot -r /mnt ${1}; then
+               echo "\nFailed to install bootblocks."
+               echo "You will not be able to boot OpenBSD from ${1}."
+               exit
+       fi
 }
 
 md_prep_fdisk() {
@@ -53,7 +50,6 @@ md_prep_fdisk() {
        local bootsectorsize="32768"
        local bootsectorend=$(($bootsectorstart + $bootsectorsize))
        local bootfstype="msdos"
-       local newfs_args=${NEWFSARGS_msdos}
 
        while :; do
                _d=whole
@@ -83,8 +79,7 @@ write
 quit
 __EOT
                        echo "done."
-                       disklabel $_disk 2>/dev/null | grep -q "^  i:" || disklabel -w -d $_disk
-                       newfs -t ${bootfstype} ${newfs_args} ${_disk}i
+                       installboot -p $_disk
                        return ;;
                [eE]*)
                        # Manually configure the MBR.
index 23a2fb5..b765f96 100644 (file)
@@ -1,4 +1,4 @@
-#      $OpenBSD: list,v 1.5 2021/10/04 01:34:29 kevlo Exp $
+#      $OpenBSD: list,v 1.6 2022/02/03 10:27:33 visa Exp $
 
 SRCDIRS distrib/special
 
@@ -62,6 +62,7 @@ LINK  instbin                                 usr/bin/sed
 LINK   instbin                                 usr/bin/signify
 LINK   instbin                                 usr/bin/tee
 LINK   instbin                                 usr/sbin/chroot
+LINK   instbin                                 usr/sbin/installboot
 LINK   instbin                                 usr/sbin/pwd_mkdb
 ARGVLINK ksh                                   -sh
 SPECIAL        rm bin/md5
index 8b00e1c..4ab1041 100644 (file)
@@ -1,4 +1,4 @@
-#      $OpenBSD: Makefile,v 1.15 2022/02/03 10:21:13 visa Exp $
+#      $OpenBSD: Makefile,v 1.16 2022/02/03 10:27:33 visa Exp $
 
 .PATH: ${.CURDIR}/../../../usr.sbin/installboot
 
@@ -15,7 +15,7 @@ CFLAGS += -DSOFTRAID
 SRCS += i386_installboot.c
 SRCS += i386_nlist.c
 SRCS += i386_softraid.c
-.elif ${MACHINE} == "armv7" || ${MACHINE} == "arm64"
+.elif ${MACHINE} == "armv7" || ${MACHINE} == "arm64" || ${MACHINE} == "riscv64"
 SRCS += efi_installboot.c
 .elif ${MACHINE} == "hppa"
 CFLAGS += -DBOOTSTRAP