aboutsummaryrefslogtreecommitdiff
path: root/tools/boot
diff options
context:
space:
mode:
Diffstat (limited to 'tools/boot')
-rw-r--r--tools/boot/TEST-NOTES22
-rwxr-xr-xtools/boot/ci-qemu-test.sh26
-rw-r--r--tools/boot/full-test.readme37
-rw-r--r--tools/boot/full-test.sh668
-rwxr-xr-xtools/boot/install-boot.sh89
-rwxr-xr-xtools/boot/lua-img.sh1
-rwxr-xr-xtools/boot/lua-lint.sh3
-rwxr-xr-xtools/boot/lua-test.sh1
-rwxr-xr-xtools/boot/rootgen.sh438
-rw-r--r--tools/boot/smbios/Makefile9
-rw-r--r--tools/boot/smbios/main.c96
-rw-r--r--tools/boot/smbios/stand.h18
-rwxr-xr-xtools/boot/universe.sh42
13 files changed, 1070 insertions, 380 deletions
diff --git a/tools/boot/TEST-NOTES b/tools/boot/TEST-NOTES
new file mode 100644
index 000000000000..9c1debca5376
--- /dev/null
+++ b/tools/boot/TEST-NOTES
@@ -0,0 +1,22 @@
+New test script
+
+o Assumes univerese has run.
+o Will create a test tree somewhere outside of the source tree
+ o trees has the different trees we use to create images
+ o trees/${ARCH}/$PART have each architecture's tree images
+ for the different partitions we need.
+ o bios has cached BIOSes needed for tests
+ o images has the images to test
+ o tests has the test scripts
+ o linux has cached copies off kernels for the kboot tests
+o Assumes qemu port installed
+ o will use firmware from there
+o Will use 3 linux kernels, amd64 and aarch64 built with CONFIG_EFI_STUB
+o Will test
+ o armv7 UEFI+uboot booting on MBR and GPT
+ o aarch64 Will test UEFI+ACPI on MBR/GPT, UEFI+ACPI+kboot, DTB+kboot
+ o amd64 <big matrix here>
+ o i386 legacy + {gpt,mbr} and cdrom boot (also the isoboot unified?)
+ o powerpc <who knows> but kboot+dtb
+ o riscv UEFI+ACPI with GPT and serial console
+
diff --git a/tools/boot/ci-qemu-test.sh b/tools/boot/ci-qemu-test.sh
index e6481c794af5..63f0fc2c64b2 100755
--- a/tools/boot/ci-qemu-test.sh
+++ b/tools/boot/ci-qemu-test.sh
@@ -8,7 +8,6 @@
# rootgen.sh and related scripts generate much more extensive tests for many
# combinations of boot env (ufs, zfs, geli, etc).
#
-# $FreeBSD$
set -e
@@ -21,7 +20,7 @@ die()
tempdir_cleanup()
{
trap - EXIT SIGINT SIGHUP SIGTERM SIGQUIT
- rm -rf ${ROOTDIR}
+ rm -rf ${WORKDIR}
}
tempdir_setup()
@@ -85,7 +84,7 @@ amd64)
if [ ! -r "${OVMF}" ]; then
die "Cannot read UEFI firmware file ${OVMF}"
fi
- QEMU="qemu-system-x86_64 -drive if=pflash,format=raw,readonly,file=${OVMF}"
+ QEMU="qemu-system-x86_64 -drive if=pflash,format=raw,readonly=on,file=${OVMF}"
EFIBOOT=BOOTx64.EFI
ROOTDEV=ada0s1
;;
@@ -99,22 +98,35 @@ arm64)
esac
# Create a temp dir to hold the boot image.
-ROOTDIR=$(mktemp -d -t ci-qemu-test-fat-root)
+WORKDIR=$(mktemp -d -t ci-qemu-test-fat-root)
+ROOTDIR=${WORKDIR}/stage-root
trap tempdir_cleanup EXIT SIGINT SIGHUP SIGTERM SIGQUIT
# Populate the boot image in a temp dir.
( cd ${SRCTOP} && tempdir_setup )
+# Using QEMU's virtual FAT support is much faster than creating a disk image,
+# but only supports about 500MB. Fall back to creating a disk image if the
+# staged root is too large.
+hda="fat:${ROOTDIR}"
+rootsize=$(du -skA ${ROOTDIR} | sed 's/[[:space:]].*$//')
+if [ $rootsize -gt 512000 ]; then
+ echo "Root size ${rootsize}K too large for QEMU virtual FAT" >&2
+ makefs -t msdos -s 1g $WORKDIR/image.fat $ROOTDIR
+ mkimg -s mbr -p efi:=$WORKDIR/image.fat -o $WORKDIR/image.mbr
+ hda="$WORKDIR/image.mbr"
+fi
+
# And, boot in QEMU.
: ${BOOTLOG:=${TMPDIR:-/tmp}/ci-qemu-test-boot.log}
timeout 300 \
$QEMU -m 256M -nodefaults \
-serial stdio -vga none -nographic -monitor none \
- -snapshot -hda fat:${ROOTDIR} 2>&1 | tee ${BOOTLOG}
+ -snapshot -hda $hda 2>&1 | tee ${BOOTLOG}
# Check whether we succesfully booted...
-if grep -q 'Hello world.' ${BOOTLOG}; then
- echo "OK"
+if grep -q 'Hello world.' ${BOOTLOG} && egrep -q '^Uptime: ' ${BOOTLOG}; then
+ echo "Boot successful"
else
die "Did not boot successfully, see ${BOOTLOG}"
fi
diff --git a/tools/boot/full-test.readme b/tools/boot/full-test.readme
new file mode 100644
index 000000000000..db1f12c7024b
--- /dev/null
+++ b/tools/boot/full-test.readme
@@ -0,0 +1,37 @@
+First, you will need a few things.
+
+(1) a small cache of binaries. You'll need to put these into
+ ~/stand-test-root/cache. You can find the tarball at
+ freefall.freebsd.org:~imp/cache.tar. You can just extract this in ~. These are
+ the linux kernels I'm testing with.
+
+(2) The latest qemu-system-aarch64 (I think ports/pkg version of emulators/qemu
+ is recent enough). If not, I know the latest master of qemu project works.
+
+(3) A recent enough universe that the building of stand will work for all the
+ architectures that I build. You can hack the ARCHES line near the top of
+ tools/boot/full-test.sh if need be, but you'll need at least amd64, arm64 and
+ maybe riscv (I don't have a good way to filter arches in this script yet, since
+ it's at an early state of development.
+
+(4) Build the kernel for at least arm64 and use it as an 'override'. I do this
+ by sudo -E make installkernel
+ DESTDIR=$HOME/stand-test-root/override/arm64-aarch64 TARGET=arm64 after
+ building the kernel. The script is designed to use kernels and binaries from
+ the latest CDs to do the testing, but has a way to override the kernel and
+ since we need to fix arm64...
+
+(5) You'll need to build the images. If you've done 1-5 correctly (and I've not
+ missed anything), then "cd <mumble>/src; sh tools/boot/full-test.sh" will create
+ all the images and scripts to run qemu. There should be no errors, though
+ warnings about zfs.ko etc missing from powerpc is fine (and ignored by the
+ script already).
+
+(6) There will be a script to recreate this created in
+ $HOME/stand-test-root/scripts/arm64-aarch64/linuxboot-test.sh. Just run it with
+ 'sh'. And extra args are passed to qemu, so '-s -S' for gdb and
+ '-d trace:gicv3\* -D /tmp/gic.log' for verbose gic tracing (spaces are important).
+
+There's also a linuxboot-test-raw.sh which boots w/o EDK2+Linux.efi but loads
+the kernel directly. and freebsd-test.sh which uses EDK2+loader.efi to boot FreeBSD
+w/o kboot at all.
diff --git a/tools/boot/full-test.sh b/tools/boot/full-test.sh
new file mode 100644
index 000000000000..1160861316dc
--- /dev/null
+++ b/tools/boot/full-test.sh
@@ -0,0 +1,668 @@
+#!/bin/sh
+
+# STAND_ROOT is the root of a tree:
+# cache - Cached binaries that we have downloaded
+# trees - binary trees that we use to make image
+# trees/${ARCH}/$thing
+# images - bootable images that we use to test
+# images/${ARCH}/$thing
+# bios - cached bios images (as well as 'vars' files when we start testing
+# different booting scenarios in the precense / absence of variables).
+# scripts - generated scripts that uses images to run the tests.
+#
+# Strategy:
+# Download FreeBSD release isos, Linux kernels (for the kboot tests) and
+# other misc things. We use these to generate dozens of test images that we
+# use qemu-system-XXXX to boot. They all boot the same thing at the moment:
+# an /etc/rc script that prints the boot method, echos success and then
+# halts.
+
+# What version of FreeBSD to we snag the ISOs from to extract the binaries
+# we are testing
+FREEBSD_VERSION=14.2
+# eg https://download.freebsd.org/releases/amd64/amd64/ISO-IMAGES/14.2/FreeBSD-14.2-RELEASE-amd64-bootonly.iso.xz
+URLBASE="https://download.freebsd.org/releases"
+: ${STAND_ROOT:="${HOME}/stand-test-root"}
+CACHE=${STAND_ROOT}/cache
+TREES=${STAND_ROOT}/trees
+IMAGES=${STAND_ROOT}/images
+BIOS=${STAND_ROOT}/bios
+SCRIPTS=${STAND_ROOT}/scripts
+OVERRIDE=${STAND_ROOT}/override
+
+# Find make
+case $(uname) in
+ Darwin)
+ t=$(realpath $(dirname $0)/../..)
+ # Use the python wrapper to find make
+ if [ -f ${t}/tools/build/make.py ]; then
+ MAKE="${t}/tools/build/make.py"
+ case $(uname -m) in
+ arm64)
+ DEFARCH="TARGET_ARCH=aarch64 TARGET=arm64"
+ ;;
+ x86_64)
+ DEFARCH="TARGET_ARCH=amd64 TARGET=amd64"
+ ;;
+ *)
+ die "Do not know about $(uanme -p)"
+ ;;
+ esac
+ else
+ die "Can't find the make wrapper"
+ fi
+ qemu_bin=/opt/homebrew/bin
+ ;;
+ FreeBSD)
+ MAKE=make
+ qemu_bin=/usr/local/bin
+ ;;
+ # linux) not yet
+ *)
+ die "Do not know about system $(uname)"
+ ;;
+esac
+
+SRCTOP=$(${MAKE} ${DEFARCH} -v SRCTOP)
+echo $SRCTOP
+
+# Find makefs and mkimg
+MAKEFS=$(SHELL="which makefs" ${MAKE} ${DEFARCH} buildenv | tail -1) || die "No makefs try WITH_DISK_IMAGE_TOOLS_BOOTSTRAP=y"
+MKIMG=$(SHELL="which mkimg" ${MAKE} ${DEFARCH} buildenv | tail -1) || die "No mkimg, try buildworld first"
+MTREE=$(SHELL="which mtree" ${MAKE} ${DEFARCH} buildenv | tail -1) || die "No mtree, try buildworld first"
+
+# MAKE=$(SHELL="which make" ${MAKE} ${DEFARCH} buildenv | tail -1) || die "No make, try buildworld first"
+
+
+# All the architectures under test
+# Note: we can't yet do armv7 because we don't have a good iso for it and would
+# need root to extract the files.
+#ARCHES="amd64:amd64 i386:i386 powerpc:powerpc powerpc:powerpc64 powerpc:powerpc64le powerpc:powerpcspe arm64:aarch64 riscv:riscv64"
+ARCHES="amd64:amd64 arm64:aarch64"
+
+# The smallest FAT32 filesystem is 33292 KB
+espsize=33292
+
+mkdir -p ${CACHE} ${TREES} ${IMAGES} ${BIOS}
+
+die()
+{
+ echo Fatal Error: $*
+ exit 1
+}
+
+ma_combo()
+{
+ local m=$1
+ local ma=$2
+ local ma_combo="${m}"
+
+ [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
+ echo ${ma_combo}
+}
+
+fetch_one()
+{
+ local m=$1
+ local ma=$2
+ local v=$3
+ local flavor=$4
+ local ma_combo=$(ma_combo $m $ma)
+ local file="FreeBSD-${v}-RELEASE-${ma_combo}-${flavor}"
+ local url="${URLBASE}/${m}/${ma}/ISO-IMAGES/${v}/${file}.xz"
+
+ mkdir -p ${CACHE}
+ [ -r ${CACHE}/${file} ] && echo "Using cached ${file}" && return
+ cd ${CACHE}
+ echo "Fetching ${url}"
+ fetch ${url} || die "Can't fetch ${file} from ${url}"
+ xz -d ${file}.xz || die "Can't uncompress ${file}.xz"
+ cd ..
+}
+
+update_freebsd_img_cache()
+{
+ local a m ma
+
+ for a in $ARCHES; do
+ m=${a%%:*}
+ ma=${a##*:}
+ fetch_one $m $ma ${FREEBSD_VERSION} bootonly.iso
+ done
+
+ fetch_one arm armv7 ${FREEBSD_VERSION} GENERICSD.img
+}
+
+make_minimal_freebsd_tree()
+{
+ local m=$1
+ local ma=$2
+ local v=$3
+ local flavor=$4
+ local file d
+ local ma_combo="${m}"
+ [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
+
+ file="FreeBSD-${v}-RELEASE-${ma_combo}-${flavor}"
+ dir=${TREES}/${ma_combo}/freebsd
+ rm -rf ${dir}
+
+ # Make a super simple userland. It has just enough to print a santiy value,
+ # then say test succeeded, and then halt the system. We assume that /bin/sh
+ # has all the library prereqs for the rest...
+ mkdir -p ${dir}
+ # Make required dirs
+ for d in boot/kernel boot/defaults boot/lua boot/loader.conf.d \
+ sbin bin lib libexec etc dev; do
+ mkdir -p ${dir}/${d}
+ done
+ # Pretend we don't have a separate /usr
+ ln -s . ${dir}/usr
+ # snag the binaries for my simple /etc/rc file
+ tar -C ${dir} -xf ${CACHE}/$file sbin/fastboot sbin/reboot sbin/halt sbin/init bin/sh sbin/sysctl \
+ lib/libtinfow.so.9 lib/libncursesw.so.9 lib/libc.so.7 lib/libedit.so.8 libexec/ld-elf.so.1
+ # My simple etc/rc
+ cat > ${dir}/etc/rc <<EOF
+#!/bin/sh
+
+sysctl machdep.bootmethod
+echo "RC COMMAND RUNNING -- SUCCESS!!!!!"
+halt -p
+EOF
+ chmod +x ${dir}/etc/rc
+
+ # Check to see if we have overrides here... So we can insert our own kernel
+ # instead of the one from the release.
+ echo "CHECKING ${OVERRIDE}/${ma_combo}/boot"
+ if [ -d ${OVERRIDE}/${ma_combo}/boot ]; then
+ o=${OVERRIDE}/${ma_combo}
+ for i in \
+ boot/device.hints \
+ boot/kernel/kernel \
+ boot/kernel/acl_nfs4.ko \
+ boot/kernel/cryptodev.ko \
+ boot/kernel/zfs.ko \
+ boot/kernel/geom_eli.ko; do
+ [ -r $o/$i ] && echo Copying override $i && cp $o/$i ${dir}/$i
+ done
+ else
+ # Copy the kernel (but not the boot loader, we'll add the one to test later)
+ # This will take care of both UFS and ZFS boots as well as geli
+ # Note: It's OK for device.hints to be missing. It's mostly for legacy platforms.
+ tar -C ${dir} -xf ${CACHE}/$file \
+ boot/device.hints \
+ boot/kernel/kernel \
+ boot/kernel/acl_nfs4.ko \
+ boot/kernel/cryptodev.ko \
+ boot/kernel/zfs.ko \
+ boot/kernel/geom_eli.ko || true
+ # XXX WHAT TO DO ABOUT LINKER HINTS -- PUNT FOR NOW
+ # XXX also, ZFS not supported on 32-bit powerpc platforms
+ fi
+
+ # Setup some common settings for serial console, etc
+ echo -h -D -S115200 > ${dir}/boot.config
+ cat > ${dir}/boot/loader.conf <<EOF
+comconsole_speed=115200
+autoboot_delay=2
+zfs_load="YES"
+boot_verbose=yes
+kern.cfg.order="acpi,fdt"
+boot_serial="YES"
+hw.uart.console="io:1016,br:115200"
+vfs.root.mountfrom="ufs:/dev/ufs/root"
+vfs.root.mountfrom.options="rw"
+EOF
+}
+
+make_freebsd_minimal_trees()
+{
+ for a in $ARCHES; do
+ m=${a%%:*}
+ ma=${a##*:}
+ make_minimal_freebsd_tree $m $ma ${FREEBSD_VERSION} bootonly.iso
+ done
+ # Note: armv7 isn't done yet as its the odd-man out -- we need to extract things
+ # in a special way, so punt for the moment
+}
+
+make_freebsd_test_trees()
+{
+ for a in $ARCHES; do
+ m=${a%%:*}
+ ma=${a##*:}
+ ma_combo="${m}"
+ [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
+ dir=${TREES}/${ma_combo}/test-stand
+ mkdir -p ${dir}
+ ${MTREE} -deUW -f ${SRCTOP}/etc/mtree/BSD.root.dist -p ${dir}
+ echo "Creating tree for ${m}:${ma}"
+ cd ${SRCTOP}
+ # Indirection needed because our build system is too complex
+ # Also, bare make for 'inside' the buildenv ${MAKE} for outside
+# SHELL="make clean" ${MAKE} buildenv TARGET=${m} TARGET_ARCH=${ma}
+ SHELL="sh -c 'cd stand ; make -j 100 all'" ${MAKE} TARGET=${m} TARGET_ARCH=${ma} buildenv
+ DESTDIR=${dir} SHELL="sh -c 'cd stand ; make install MK_MAN=no MK_INSTALL_AS_USER=yes WITHOUT_DEBUG_FILES=yes'" \
+ ${MAKE} buildenv TARGET=${m} TARGET_ARCH=${ma}
+ rm -rf ${dir}/bin ${dir}/[ac-z]* # Don't care about anything here
+ done
+}
+
+make_linux_initrds()
+{
+ # At the moment, we have just two
+ for a in amd64:amd64 arm64:aarch64; do
+ m=${a%%:*}
+ ma=${a##*:}
+ ma_combo="${m}"
+ [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
+ dir=${TREES}/${ma_combo}/linuxboot
+ dir2=${TREES}/${ma_combo}/test-stand
+ dir3=${TREES}/${ma_combo}/freebsd
+ initrd=${TREES}/${ma_combo}/initrd.img
+ rm -rf ${dir}
+ mkdir -p ${dir}
+ cp ${dir2}/boot/loader.kboot ${dir}/init
+ # Copy the boot loader
+ tar -c -f - -C ${dir2} boot | tar -xf - -C ${dir}
+ # Copy the boot kernel
+ tar -c -f - -C ${dir3} boot | tar -xf - -C ${dir}
+ (cd ${dir} ; find . | LC_ALL=C sort | cpio -o -H newc | gzip > ${initrd})
+ done
+}
+
+make_linux_esps()
+{
+ # At the moment, we have just two
+ for a in amd64:amd64 arm64:aarch64; do
+ m=${a%%:*}
+ ma=${a##*:}
+ ma_combo="${m}"
+ [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
+ dir=${TREES}/${ma_combo}/linuxboot-esp
+ initrd=${TREES}/${ma_combo}/initrd.img
+ mkdir -p ${dir}
+ case ${ma} in
+ amd64) bin=x64 cons="console=ttyS0,115200" ;;
+ aarch64) bin=aa64 ;;
+ esac
+ mkdir -p ${dir}/efi/boot
+ cp ${CACHE}/linux/linux${bin}.efi ${dir}
+ cp ${CACHE}/linux/shell${bin}.efi ${dir}/efi/boot/boot${bin}.efi
+ cat > ${dir}/startup.nsh <<EOF
+# Run linux
+# Tell it to run with out special initrd that then boot FreeBSD
+
+\linux${bin} ${cons} initrd=\initrd.img
+EOF
+ cp $initrd ${dir}
+ done
+}
+
+make_linuxboot_images()
+{
+ # ESP variant: In this variant, amd64 and arm64 are both created more or
+ # less the same way. Both are EFI + ACPI implementations
+ for a in amd64:amd64 arm64:aarch64; do
+ m=${a%%:*}
+ ma=${a##*:}
+ ma_combo="${m}"
+ [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
+ src=${TREES}/${ma_combo}/linuxboot-esp
+ dir=${TREES}/${ma_combo}/freebsd
+ dir2=${TREES}/${ma_combo}/test-stand
+ esp=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}.esp
+ ufs=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}.ufs
+ zfs=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}.zfs
+ img=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}.img
+ img2=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}-zfs.img
+ pool="linuxboot"
+ mkdir -p ${IMAGES}/${ma_combo}
+ ${MAKEFS} -t msdos -o fat_type=32 -o sectors_per_cluster=1 \
+ -o volume_label=EFISYS -s80m ${esp} ${src}
+ ${MAKEFS} -t ffs -B little -s 200m -o label=root ${ufs} ${dir} ${dir2}
+ ${MKIMG} -s gpt -p efi:=${esp} -p freebsd-ufs:=${ufs} -o ${img}
+ ${MAKEFS} -t zfs -s 200m \
+ -o poolname=${pool} -o bootfs=${pool} -o rootpath=/ \
+ ${zfs} ${dir} ${dir2}
+ ${MKIMG} -s gpt \
+ -p efi:=${esp} \
+ -p freebsd-zfs:=${zfs} -o ${img2}
+ rm -f ${esp} # Don't need to keep this around
+ done
+
+ # The raw variant, currently used only on arm64. It boots with the raw interface of qemu
+ # for testing purposes. This means it makes a good test for the DTB variation, but not ACPI
+ # since qemu doesn't currently provide that...
+ for a in arm64:aarch64; do
+ m=${a%%:*}
+ ma=${a##*:}
+ ma_combo="${m}"
+ [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
+ linux="${CACHE}/linux/vmlinux-${m}*"
+ initrd=${TREES}/${ma_combo}/initrd.img
+ img=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}-raw
+ cp ${linux} ${img}.kernel
+ cp ${initrd} ${img}.initrd
+ done
+}
+
+make_linuxboot_scripts()
+{
+ # At the moment, we have just two -- and the images we've built so far are just
+ # the hostfs boot. The boot off anything more complex isn't here.
+ for a in amd64:amd64 arm64:aarch64; do
+ m=${a%%:*}
+ ma=${a##*:}
+ ma_combo="${m}"
+ [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
+
+ # First off, update the edk firmware
+ bios_code=${BIOS}/edk2-${ma_combo}-code.fd
+ bios_vars=${BIOS}/edk2-${ma_combo}-vars.fd
+ case ${ma} in
+ amd64)
+ if [ ${bios_code} -ot /usr/local/share/qemu/edk2-x86_64-code.fd ]; then
+ cp /usr/local/share/qemu/edk2-x86_64-code.fd ${bios_code}
+ # vars file works on both 32 and 64 bit x86
+# cp /usr/local/share/qemu/edk2-i386-vars.fd ${bios_vars}
+ fi
+ ;;
+ aarch64)
+ if [ ${bios_code} -ot /usr/local/share/qemu/edk2-aarch64-code.fd ]; then
+ # aarch64 vars starts as an empty file
+ dd if=/dev/zero of=${bios_code} bs=1M count=64
+ dd if=/dev/zero of=${bios_vars} bs=1M count=64
+ dd if=/usr/local/share/qemu/edk2-aarch64-code.fd of=${bios_code} conv=notrunc
+ fi
+ ;;
+ esac
+
+ # Now make me a script
+ img=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}.img
+ img2=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}-raw
+ img3=${IMAGES}/${ma_combo}/linuxboot-${ma_combo}-zfs.img
+ out=${SCRIPTS}/${ma_combo}/linuxboot-test.sh
+ out2=${SCRIPTS}/${ma_combo}/linuxboot-test-raw.sh
+ out3=${SCRIPTS}/${ma_combo}/linuxboot-test-zfs.sh
+ cd=${CACHE}/FreeBSD-13.1-RELEASE-arm64-aarch64-bootonly.iso
+ mkdir -p ${SCRIPTS}/${ma_combo}
+ case ${ma} in
+ amd64)
+ cat > ${out} <<EOF
+${qemu_bin}/qemu-system-x86_64 -nographic -m 512M \\
+ -drive file=${img},if=none,id=drive0,cache=writeback,format=raw \\
+ -device virtio-blk,drive=drive0,bootindex=0 \\
+ -drive file=${bios_code},format=raw,if=pflash \\
+ -drive file=${bios_vars},format=raw,if=pflash \\
+ -monitor telnet::4444,server,nowait \\
+ -serial stdio \$*
+EOF
+ ;;
+ aarch64)
+ # ESP version
+ raw=${IMAGES}/${ma_combo}/freebsd-arm64-aarch64.img
+ cat > ${out} <<EOF
+${qemu_bin}/qemu-system-aarch64 -nographic -machine virt,gic-version=3 -m 512M -smp 4 \\
+ -cpu cortex-a57 \\
+ -drive file=${img},if=none,id=drive0,cache=writeback \\
+ -device virtio-blk,drive=drive0,bootindex=0 \\
+ -drive file=${raw},if=none,id=drive1,cache=writeback \\
+ -device nvme,serial=fboot,drive=drive1,bootindex=1 \\
+ -drive file=${bios_code},format=raw,if=pflash \\
+ -drive file=${bios_vars},format=raw,if=pflash \\
+ -monitor telnet::4444,server,nowait \\
+ -serial stdio \$*
+EOF
+ # RAW version
+ # Note: We have to use cortex-a57 for raw mode because the
+ # kernel we use has issues with max.
+ cat > ${out2} <<EOF
+${qemu_bin}/qemu-system-aarch64 -m 1024 -cpu cortex-a57 -M virt \\
+ -kernel ${img2}.kernel -initrd ${img2}.initrd \\
+ -append "console=ttyAMA0" \\
+ -drive file=${cd},if=none,id=drive0,cache=writeback,format=raw \\
+ -device virtio-blk,drive=drive0,bootindex=0 \\
+ -nographic -monitor telnet::4444,server,nowait \\
+ -serial stdio \$*
+EOF
+ # ZFS version
+ # Note: We have to use cortex-a57 for raw mode because the
+ # kernel we use has issues with max.
+ cat > ${out3} <<EOF
+${qemu_bin}/qemu-system-aarch64 -nographic -machine virt,gic-version=3 -m 512M -smp 4 \\
+ -cpu cortex-a57 \\
+ -drive file=${img3},if=none,id=drive0,cache=writeback \\
+ -device virtio-blk,drive=drive0,bootindex=0 \\
+ -drive file=${bios_code},format=raw,if=pflash \\
+ -drive file=${bios_vars},format=raw,if=pflash \\
+ -monitor telnet::4444,server,nowait \\
+ -serial stdio \$*
+EOF
+ ;;
+ esac
+ done
+}
+
+make_freebsd_esps()
+{
+ # At the moment, we have just three (armv7 could also be here too, but we're not doing that)
+# for a in amd64:amd64 arm64:aarch64 riscv:riscv64; do
+ for a in amd64:amd64 arm64:aarch64; do
+ m=${a%%:*}
+ ma=${a##*:}
+ ma_combo="${m}"
+ [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
+ dir=${TREES}/${ma_combo}/freebsd-esp
+ dir2=${TREES}/${ma_combo}/test-stand
+ rm -rf ${dir}
+ mkdir -p ${dir}
+ case ${ma} in
+ amd64) bin=x64 ;;
+ aarch64) bin=aa64 ;;
+ esac
+ mkdir -p ${dir}/efi/boot
+ cp ${dir2}/boot/loader.efi ${dir}/efi/boot/boot${bin}.efi
+ done
+}
+
+make_freebsd_images()
+{
+ # ESP variant: In this variant, riscv, amd64 and arm64 are created more or
+ # less the same way. UEFI + ACPI implementations
+# for a in amd64:amd64 arm64:aarch64 riscv:riscv64; do
+ for a in amd64:amd64 arm64:aarch64; do
+ m=${a%%:*}
+ ma=${a##*:}
+ ma_combo="${m}"
+ [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
+ src=${TREES}/${ma_combo}/freebsd-esp
+ dir=${TREES}/${ma_combo}/freebsd
+ dir2=${TREES}/${ma_combo}/test-stand
+ esp=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.esp
+ ufs=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.ufs
+ img=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.img
+ mkdir -p ${IMAGES}/${ma_combo}
+ mkdir -p ${dir2}/etc
+ cat > ${dir2}/etc/fstab <<EOF
+/dev/ufs/root / ufs rw 1 1
+EOF
+ ${MAKEFS} -t msdos -o fat_type=32 -o sectors_per_cluster=1 \
+ -o volume_label=EFISYS -s100m ${esp} ${src}
+ ${MAKEFS} -t ffs -B little -s 200m -o label=root ${ufs} ${dir} ${dir2}
+ ${MKIMG} -s gpt -p efi:=${esp} -p freebsd-ufs:=${ufs} -o ${img}
+ # rm -f ${esp} ${ufs} # Don't need to keep this around
+ done
+
+ set -x
+
+if false; then
+ # BIOS i386
+ a=i386:i386
+ m=${a%%:*}
+ ma=${a##*:}
+ ma_combo="${m}"
+ [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
+ dir=${TREES}/${ma_combo}/freebsd
+ dir2=${TREES}/${ma_combo}/test-stand
+ ufs=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.ufs
+ img=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.img
+ mkdir -p ${IMAGES}/${ma_combo}
+ mkdir -p ${dir2}/etc
+ cat > ${dir2}/etc/fstab <<EOF
+/dev/ufs/root / ufs rw 1 1
+EOF
+ ${MAKEFS} -t ffs -B little -s 200m \
+ -o label=root,version=2,bsize=32768,fsize=4096,density=16384 \
+ ${ufs} ${dir} ${dir2}
+ ${MKIMG} -s gpt -b ${dir2}/boot/pmbr \
+ -p freebsd-boot:=${dir2}/boot/gptboot \
+ -p freebsd-ufs:=${ufs} \
+ -o ${img}
+ rm -f ${src}/etc/fstab
+
+ # PowerPC for 32-bit mac
+ a=powerpc:powerpc
+ m=${a%%:*}
+ ma=${a##*:}
+ ma_combo="${m}"
+ [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
+ dir=${TREES}/${ma_combo}/freebsd
+ dir2=${TREES}/${ma_combo}/test-stand
+ ufs=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.ufs
+ img=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.img
+ mkdir -p ${IMAGES}/${ma_combo}
+ mkdir -p ${dir2}/etc
+ cat > ${dir2}/etc/fstab <<EOF
+/dev/ufs/root / ufs rw 1 1
+EOF
+ ${MAKEFS} -t ffs -B big -s 200m \
+ -o label=root,version=2,bsize=32768,fsize=4096,density=16384 \
+ ${ufs} ${dir} ${dir2}
+ ${MKIMG} -a 1 -s apm \
+ -p freebsd-boot:=${dir2}/boot/boot1.hfs \
+ -p freebsd-ufs:=${ufs} \
+ -o ${img}
+fi
+
+ set +x
+}
+
+make_freebsd_scripts()
+{
+ # At the moment, we have just two
+ for a in amd64:amd64 arm64:aarch64; do
+ m=${a%%:*}
+ ma=${a##*:}
+ ma_combo="${m}"
+ [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
+
+ # First off, update the edk firmware
+ bios_code=${BIOS}/edk2-${ma_combo}-code.fd
+ bios_vars=${BIOS}/edk2-${ma_combo}-vars.fd
+ case ${ma} in
+ amd64)
+ if [ ${bios_code} -ot /usr/local/share/qemu/edk2-x86_64-code.fd ]; then
+ cp /usr/local/share/qemu/edk2-x86_64-code.fd ${bios_code}
+ # vars file works on both 32 and 64 bit x86
+# cp /usr/local/share/qemu/edk2-i386-vars.fd ${bios_vars}
+ fi
+ ;;
+ aarch64)
+ if [ ${bios_code} -ot /usr/local/share/qemu/edk2-aarch64-code.fd ]; then
+ # aarch64 vars starts as an empty file
+ dd if=/dev/zero of=${bios_code} bs=1M count=64
+ dd if=/dev/zero of=${bios_vars} bs=1M count=64
+ dd if=/usr/local/share/qemu/edk2-aarch64-code.fd of=${bios_code} conv=notrunc
+ fi
+ ;;
+ esac
+
+ # Now make me a script
+ img=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.img
+ out=${SCRIPTS}/${ma_combo}/freebsd-test.sh
+ mkdir -p ${SCRIPTS}/${ma_combo}
+ case ${ma} in
+ amd64)
+ cat > ${out} <<EOF
+${qemu_bin}/qemu-system-x86_64 -nographic -m 512M \\
+ -drive file=${img},if=none,id=drive0,cache=writeback,format=raw \\
+ -device virtio-blk,drive=drive0,bootindex=0 \\
+ -drive file=${bios_code},format=raw,if=pflash \\
+ -drive file=${bios_vars},format=raw,if=pflash \\
+ -monitor telnet::4444,server,nowait \\
+ -serial stdio \$*
+EOF
+ ;;
+ aarch64)
+ # ESP version
+ raw=${IMAGES}/${ma_combo}/nvme-test-empty.raw
+ cat > ${out} <<EOF
+${qemu_bin}/qemu-system-aarch64 -nographic -machine virt,gic-version=3 -m 512M \\
+ -cpu cortex-a57 -drive file=${img},if=none,id=drive0,cache=writeback -smp 4 \\
+ -device virtio-blk,drive=drive0,bootindex=0 \\
+ -drive file=${bios_code},format=raw,if=pflash \\
+ -drive file=${bios_vars},format=raw,if=pflash \\
+ -drive file=${raw},if=none,id=drive1,cache=writeback,format=raw \\
+ -device nvme,serial=deadbeef,drive=drive1 \\
+ -monitor telnet::4444,server,nowait \\
+ -serial stdio \$*
+EOF
+ ;;
+ esac
+ done
+
+if false; then
+ set -x
+ a=powerpc:powerpc
+ m=${a%%:*}
+ ma=${a##*:}
+ ma_combo="${m}"
+ [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
+ img=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.img
+ out=${SCRIPTS}/${ma_combo}/freebsd-test.sh
+ mkdir -p ${SCRIPTS}/${ma_combo}
+ cat > ${out} <<EOF
+${qemu_bin}/qemu-system-ppc -m 1g -M mac99,via=pmu \\
+ -vga none -nographic \\
+ -drive file=${img},if=virtio \\
+ -prom-env "boot-device=/pci@f2000000/scsi/disk@0:,\\\\\\:tbxi" \\
+ -monitor telnet::4444,server,nowait \\
+ -serial stdio \$*
+EOF
+
+ set -x
+ a=i386:i386
+ m=${a%%:*}
+ ma=${a##*:}
+ ma_combo="${m}"
+ [ "${m}" != "${ma}" ] && ma_combo="${m}-${ma}"
+ img=${IMAGES}/${ma_combo}/freebsd-${ma_combo}.img
+ out=${SCRIPTS}/${ma_combo}/freebsd-test.sh
+ mkdir -p ${SCRIPTS}/${ma_combo}
+ cat > ${out} <<EOF
+${qemu_bin}/qemu-system-i386 -m 1g \\
+ -vga none -nographic \\
+ -drive file=${img},format=raw \\
+ -nographic \\
+ -monitor telnet::4444,server,nowait \\
+ -serial stdio \$*
+EOF
+fi
+}
+
+# The smallest FAT32 filesystem is 33292 KB
+espsize=33292
+
+set -e
+echo "src/stand test in ${STAND_ROOT}"
+update_freebsd_img_cache
+make_freebsd_minimal_trees
+make_freebsd_test_trees
+make_linux_initrds
+make_linux_esps
+make_freebsd_esps
+make_freebsd_images
+make_freebsd_scripts
+make_linuxboot_images
+make_linuxboot_scripts
diff --git a/tools/boot/install-boot.sh b/tools/boot/install-boot.sh
index d86441f23259..10e62dd32ba8 100755
--- a/tools/boot/install-boot.sh
+++ b/tools/boot/install-boot.sh
@@ -1,7 +1,5 @@
#!/bin/sh
-# $FreeBSD$
-
#
# Installs/updates the necessary boot blocks for the desired boot environment
#
@@ -44,11 +42,10 @@ get_uefi_bootname() {
}
make_esp_file() {
- local file sizekb loader device stagedir fatbits efibootname
+ local file sizekb device stagedir fatbits efibootname
file=$1
sizekb=$2
- loader=$3
if [ "$sizekb" -ge "$fat32min" ]; then
fatbits=32
@@ -60,8 +57,25 @@ make_esp_file() {
stagedir=$(mktemp -d /tmp/stand-test.XXXXXX)
mkdir -p "${stagedir}/EFI/BOOT"
- efibootname=$(get_uefi_bootname)
- cp "${loader}" "${stagedir}/EFI/BOOT/${efibootname}.efi"
+
+ # Allow multiple files to be copied.
+ # We do this in pairs, e.g:
+ # make_esp_file ... loader1.efi bootx64 loader2.efi bootia32
+ #
+ # If the second argument is left out,
+ # determine it automatically.
+ shift; shift # Skip $file and $sizekb
+ while [ ! -z $1 ]; do
+ if [ ! -z $2 ]; then
+ efibootname=$2
+ else
+ efibootname=$(get_uefi_bootname)
+ fi
+ cp "$1" "${stagedir}/EFI/BOOT/${efibootname}.efi"
+
+ shift; shift || : # Ignore failure to shift
+ done
+
makefs -t msdos \
-o fat_type=${fatbits} \
-o sectors_per_cluster=1 \
@@ -72,13 +86,20 @@ make_esp_file() {
}
make_esp_device() {
- local dev file mntpt fstype efibootname kbfree loadersize efibootfile
+ local dev file dst mntpt fstype efibootname kbfree loadersize efibootfile
local isboot1 existingbootentryloaderfile bootorder bootentry
# ESP device node
dev=$1
file=$2
+ # Allow caller to override the default
+ if [ ! -z $3 ]; then
+ efibootname=$3
+ else
+ efibootname=$(get_uefi_bootname)
+ fi
+ dst=$(basename ${file%.efi})
mntpt=$(mktemp -d /tmp/stand-test.XXXXXX)
# See if we're using an existing (formatted) ESP
@@ -95,7 +116,6 @@ make_esp_device() {
echo "Mounted ESP ${dev} on ${mntpt}"
- efibootname=$(get_uefi_bootname)
kbfree=$(df -k "${mntpt}" | tail -1 | cut -w -f 4)
loadersize=$(stat -f %z "${file}")
loadersize=$((loadersize / 1024))
@@ -116,7 +136,7 @@ make_esp_device() {
fi
fi
- if [ ! -f "${mntpt}/EFI/freebsd/loader.efi" ] && [ "$kbfree" -lt "$loadersize" ]; then
+ if [ ! -f "${mntpt}/EFI/freebsd/${dst}.efi" ] && [ "$kbfree" -lt "$loadersize" ]; then
umount "${mntpt}"
rmdir "${mntpt}"
echo "Failed to update the EFI System Partition ${dev}"
@@ -128,24 +148,26 @@ make_esp_device() {
mkdir -p "${mntpt}/EFI/freebsd"
# Keep a copy of the existing loader.efi in case there's a problem with the new one
- if [ -f "${mntpt}/EFI/freebsd/loader.efi" ] && [ "$kbfree" -gt "$((loadersize * 2))" ]; then
- cp "${mntpt}/EFI/freebsd/loader.efi" "${mntpt}/EFI/freebsd/loader-old.efi"
+ if [ -f "${mntpt}/EFI/freebsd/${dst}.efi" ] && [ "$kbfree" -gt "$((loadersize * 2))" ]; then
+ cp "${mntpt}/EFI/freebsd/${dst}.efi" "${mntpt}/EFI/freebsd/${dst}-old.efi"
fi
echo "Copying loader to /EFI/freebsd on ESP"
- cp "${file}" "${mntpt}/EFI/freebsd/loader.efi"
+ cp "${file}" "${mntpt}/EFI/freebsd/${dst}.efi"
- if [ -n "${updatesystem}" ]; then
- existingbootentryloaderfile=$(efibootmgr -v | grep "${mntpt}//EFI/freebsd/loader.efi")
+ # efibootmgr won't work on systems with ia32 UEFI firmware
+ # since we only use it to boot the 64-bit kernel
+ if [ -n "${updatesystem}" ] && [ ${efibootname} != "bootia32" ]; then
+ existingbootentryloaderfile=$(efibootmgr -v | grep "${mntpt}//EFI/freebsd/${dst}.efi")
if [ -z "$existingbootentryloaderfile" ]; then
# Try again without the double forward-slash in the path
- existingbootentryloaderfile=$(efibootmgr -v | grep "${mntpt}/EFI/freebsd/loader.efi")
+ existingbootentryloaderfile=$(efibootmgr -v | grep "${mntpt}/EFI/freebsd/${dst}.efi")
fi
if [ -z "$existingbootentryloaderfile" ]; then
echo "Creating UEFI boot entry for FreeBSD"
- efibootmgr --create --label FreeBSD --loader "${mntpt}/EFI/freebsd/loader.efi" > /dev/null
+ efibootmgr --create --label FreeBSD --loader "${mntpt}/EFI/freebsd/${dst}.efi" > /dev/null
if [ $? -ne 0 ]; then
die "Failed to create new boot entry"
fi
@@ -272,27 +294,9 @@ boot_nogeli_mbr_ufs_both() {
boot_nogeli_mbr_ufs_uefi $1 $2 $3
}
+# ZFS+MBR+BIOS is not a supported configuration
boot_nogeli_mbr_zfs_legacy() {
- dev=$1
- dst=$2
-
- # search to find the BSD slice
- s=$(find_part $dev "freebsd")
- if [ -z "$s" ] ; then
- die "No BSD slice found"
- fi
- idx=$(find_part ${dev}s${s} "freebsd-zfs")
- if [ -z "$idx" ] ; then
- die "No freebsd-zfs slice found"
- fi
- # search to find the freebsd-zfs partition within the slice
- # Or just assume it is 'a' because it has to be since it fails otherwise
- doit gpart bootcode -b ${dst}/boot/mbr ${dev}
- dd if=${dst}/boot/zfsboot of=/tmp/zfsboot1 count=1
- doit gpart bootcode -b /tmp/zfsboot1 ${dev}s${s} # Put boot1 into the start of part
- sysctl kern.geom.debugflags=0x10 # Put boot2 into ZFS boot slot
- doit dd if=${dst}/boot/zfsboot of=/dev/${dev}s${s}a skip=1 seek=1024
- sysctl kern.geom.debugflags=0x0
+ exit 1
}
boot_nogeli_mbr_zfs_uefi() {
@@ -300,7 +304,6 @@ boot_nogeli_mbr_zfs_uefi() {
}
boot_nogeli_mbr_zfs_both() {
- boot_nogeli_mbr_zfs_legacy $1 $2 $3
boot_nogeli_mbr_zfs_uefi $1 $2 $3
}
@@ -353,15 +356,6 @@ boot_geli_mbr_zfs_both() {
exit 1
}
-boot_nogeli_vtoc8_ufs_ofw() {
- dev=$1
- dst=$2
-
- # For non-native builds, ensure that geom_part(4) supports VTOC8.
- kldload geom_part_vtoc8.ko
- doit gpart bootcode -p ${vtoc8} ${dev}
-}
-
usage() {
printf 'Usage: %s -b bios [-d destdir] -f fs [-g geli] [-h] [-o optargs] -s scheme <bootdev>\n' "$0"
printf 'Options:\n'
@@ -431,9 +425,6 @@ gptzfs2=${srcroot}/boot/gptzfsboot
mbr0=${srcroot}/boot/mbr
mbr2=${srcroot}/boot/boot
-# VTOC8
-vtoc8=${srcroot}/boot/boot1
-
# sanity check here
# Check if we've been given arguments. If not, this script is probably being
diff --git a/tools/boot/lua-img.sh b/tools/boot/lua-img.sh
index 85e4cfc304d9..c0c1d0a41ac7 100755
--- a/tools/boot/lua-img.sh
+++ b/tools/boot/lua-img.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
# Quick script to build a suitable /boot dir somewhere in the tree for testing.
# dir may be passed in, will default to /tmp/loadertest if not specified
diff --git a/tools/boot/lua-lint.sh b/tools/boot/lua-lint.sh
index c6bc89da3330..60d7c567dab4 100755
--- a/tools/boot/lua-lint.sh
+++ b/tools/boot/lua-lint.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
# Run linter on the lua scripts in stand/lua. luacheck, available in ports as
# devel/lua-luacheck, must be installed as a dependency of this script.
@@ -18,4 +17,4 @@ cd $(make -V SRCTOP)/stand
${LUACHECK} . --globals loader --globals lfs --globals io.getchar \
--globals io.ischar --globals printc --globals cli_execute \
--globals cli_execute_unparsed --globals try_include \
- --globals pager --std lua53
+ --globals pager --globals gfx --globals hash --std lua53
diff --git a/tools/boot/lua-test.sh b/tools/boot/lua-test.sh
index 3ce5fa6bd54a..8b6bfd9d66c8 100755
--- a/tools/boot/lua-test.sh
+++ b/tools/boot/lua-test.sh
@@ -1,5 +1,4 @@
#!/bin/sh
-# $FreeBSD$
# Will image the test directory (default /tmp/loadertest) if it doesn't exist
diff --git a/tools/boot/rootgen.sh b/tools/boot/rootgen.sh
index b61fff647b5c..2cd65bdd180d 100755
--- a/tools/boot/rootgen.sh
+++ b/tools/boot/rootgen.sh
@@ -1,29 +1,23 @@
#!/bin/sh
-# $FreeBSD$
-
passphrase=passphrase
iterations=50000
# The smallest FAT32 filesystem is 33292 KB
espsize=33292
-dev=vtbd0
#
# Builds all the bat-shit crazy combinations we support booting from,
# at least for amd64. It assume you have a ~sane kernel in /boot/kernel
# and copies that into the ~150MB root images we create (we create the du
-# size of the kernel + 20MB
+# size of the kernel + 20MB).
#
-# Sad panda sez: this runs as root, but could be userland if someone
-# creates userland geli and zfs tools.
+# Sad panda sez: this runs as root, but could be any user if someone
+# creates userland geli.
#
# This assumes an external program install-boot.sh which will install
# the appropriate boot files in the appropriate locations.
#
-# These images assume ${dev} will be the root image. We should likely
-# use labels, but we don't.
-#
# Assumes you've already rebuilt... maybe bad? Also maybe bad: the env
# vars should likely be conditionally set to allow better automation.
#
@@ -38,14 +32,20 @@ cpsys() {
(cd $src ; tar cf - .) | (cd $dst; tar xf -)
}
+ufs_fstab() {
+ dir=$1
+
+ cat > ${dir}/etc/fstab <<EOF
+/dev/ufs/root / ufs rw 1 1
+EOF
+}
+
mk_nogeli_gpt_ufs_legacy() {
src=$1
img=$2
- cat > ${src}/etc/fstab <<EOF
-/dev/${dev}p2 / ufs rw 1 1
-EOF
- makefs -t ffs -B little -s 200m ${img}.p2 ${src}
+ ufs_fstab ${src}
+ makefs -t ffs -B little -s 200m -o label=root ${img}.p2 ${src}
mkimg -s gpt -b ${src}/boot/pmbr \
-p freebsd-boot:=${src}/boot/gptboot \
-p freebsd-ufs:=${img}.p2 -o ${img}
@@ -56,11 +56,9 @@ mk_nogeli_gpt_ufs_uefi() {
src=$1
img=$2
- cat > ${src}/etc/fstab <<EOF
-/dev/${dev}p2 / ufs rw 1 1
-EOF
+ ufs_fstab ${src}
make_esp_file ${img}.p1 ${espsize} ${src}/boot/loader.efi
- makefs -t ffs -B little -s 200m ${img}.p2 ${src}
+ makefs -t ffs -B little -s 200m -o label=root ${img}.p2 ${src}
mkimg -s gpt \
-p efi:=${img}.p1 \
-p freebsd-ufs:=${img}.p2 -o ${img}
@@ -71,11 +69,9 @@ mk_nogeli_gpt_ufs_both() {
src=$1
img=$2
- cat > ${src}/etc/fstab <<EOF
-/dev/${dev}p3 / ufs rw 1 1
-EOF
+ ufs_fstab ${src}
make_esp_file ${img}.p1 ${espsize} ${src}/boot/loader.efi
- makefs -t ffs -B little -s 200m ${img}.p3 ${src}
+ makefs -t ffs -B little -s 200m -o label=root ${img}.p3 ${src}
# p1 is boot for uefi, p2 is boot for gpt, p3 is /
mkimg -b ${src}/boot/pmbr -s gpt \
-p efi:=${img}.p1 \
@@ -85,6 +81,23 @@ EOF
rm -f ${src}/etc/fstab
}
+# XXX should not assume host == target
+zfs_extra()
+{
+ src=$1
+ dst=$2
+
+ mkdir -p $dst
+ mkdir -p $dst/boot/kernel
+ cat > ${dst}/boot/loader.conf.local <<EOF
+cryptodev_load=YES
+zfs_load=YES
+EOF
+ cp /boot/kernel/acl_nfs4.ko ${dst}/boot/kernel/acl_nfs4.ko
+ cp /boot/kernel/cryptodev.ko ${dst}/boot/kernel/cryptodev.ko
+ cp /boot/kernel/zfs.ko ${dst}/boot/kernel/zfs.ko
+}
+
mk_nogeli_gpt_zfs_legacy() {
src=$1
img=$2
@@ -94,34 +107,17 @@ mk_nogeli_gpt_zfs_legacy() {
fs=$6
bios=$7
pool=nogeli-gpt-zfs-legacy
+ dst=$img.extra
- dd if=/dev/zero of=${img} count=1 seek=$((200 * 1024 * 1024 / 512))
- md=$(mdconfig -f ${img})
- gpart create -s gpt ${md}
- gpart add -t freebsd-boot -s 400k -a 4k ${md} # <= ~540k
- gpart add -t freebsd-zfs -l root $md
- # install-boot will make this bootable
- zpool create -O mountpoint=none -R ${mntpt} ${pool} ${md}p2
- zpool set bootfs=${pool} ${pool}
- zfs create -po mountpoint=/ ${pool}/ROOT/default
- # NB: The online guides go nuts customizing /var and other mountpoints here, no need
- cpsys ${src} ${mntpt}
- # need to make a couple of tweaks
- cat >> ${mntpt}/boot/loader.conf <<EOF
-cryptodev_load=YES
-zfs_load=YES
-EOF
- cp /boot/kernel/acl_nfs4.ko ${mntpt}/boot/kernel/acl_nfs4.ko
- cp /boot/kernel/cryptodev.ko ${mntpt}/boot/kernel/cryptodev.ko
- cp /boot/kernel/zfs.ko ${mntpt}/boot/kernel/zfs.ko
- # end tweaks
- zfs umount -f ${pool}/ROOT/default
- zfs set mountpoint=none ${pool}/ROOT/default
- zpool set bootfs=${pool}/ROOT/default ${pool}
- zpool set autoexpand=on ${pool}
- zpool export ${pool}
- ${SRCTOP}/tools/boot/install-boot.sh -g ${geli} -s ${scheme} -f ${fs} -b ${bios} -d ${src} ${md}
- mdconfig -d -u ${md}
+ zfs_extra $src $dst
+ makefs -t zfs -s 200m \
+ -o poolname=${pool} -o bootfs=${pool} -o rootpath=/ \
+ ${img}.p2 ${src} ${dst}
+ mkimg -b ${src}/boot/pmbr -s gpt \
+ -p freebsd-boot:=/boot/gptzfsboot \
+ -p freebsd-zfs:=${img}.p2 \
+ -o ${img}
+ rm -rf ${dst}
}
mk_nogeli_gpt_zfs_uefi() {
@@ -133,34 +129,18 @@ mk_nogeli_gpt_zfs_uefi() {
fs=$6
bios=$7
pool=nogeli-gpt-zfs-uefi
+ dst=$img.extra
- dd if=/dev/zero of=${img} count=1 seek=$((200 * 1024 * 1024 / 512))
- md=$(mdconfig -f ${img})
- gpart create -s gpt ${md}
- gpart add -t efi -s ${espsize}k -a 4k ${md}
- gpart add -t freebsd-zfs -l root $md
- # install-boot will make this bootable
- zpool create -O mountpoint=none -R ${mntpt} ${pool} ${md}p2
- zpool set bootfs=${pool} ${pool}
- zfs create -po mountpoint=/ ${pool}/ROOT/default
- # NB: The online guides go nuts customizing /var and other mountpoints here, no need
- cpsys ${src} ${mntpt}
- # need to make a couple of tweaks
- cat >> ${mntpt}/boot/loader.conf <<EOF
-cryptodev_load=YES
-zfs_load=YES
-EOF
- cp /boot/kernel/acl_nfs4.ko ${mntpt}/boot/kernel/acl_nfs4.ko
- cp /boot/kernel/cryptodev.ko ${mntpt}/boot/kernel/cryptodev.ko
- cp /boot/kernel/zfs.ko ${mntpt}/boot/kernel/zfs.ko
- # end tweaks
- zfs umount -f ${pool}/ROOT/default
- zfs set mountpoint=none ${pool}/ROOT/default
- zpool set bootfs=${pool}/ROOT/default ${pool}
- zpool set autoexpand=on ${pool}
- zpool export ${pool}
- ${SRCTOP}/tools/boot/install-boot.sh -g ${geli} -s ${scheme} -f ${fs} -b ${bios} -d ${src} ${md}
- mdconfig -d -u ${md}
+ zfs_extra $src $dst
+ make_esp_file ${img}.p1 ${espsize} ${src}/boot/loader.efi
+ makefs -t zfs -s 200m \
+ -o poolname=${pool} -o bootfs=${pool} -o rootpath=/ \
+ ${img}.p2 ${src} ${dst}
+ mkimg -b ${src}/boot/pmbr -s gpt \
+ -p efi:=${img}.p1 \
+ -p freebsd-zfs:=${img}.p2 \
+ -o ${img}
+ rm -rf ${dst}
}
mk_nogeli_gpt_zfs_both() {
@@ -172,45 +152,27 @@ mk_nogeli_gpt_zfs_both() {
fs=$6
bios=$7
pool=nogeli-gpt-zfs-both
+ dst=$img.extra
- dd if=/dev/zero of=${img} count=1 seek=$((200 * 1024 * 1024 / 512))
- md=$(mdconfig -f ${img})
- gpart create -s gpt ${md}
- gpart add -t efi -s ${espsize}k -a 4k ${md}
- gpart add -t freebsd-boot -s 400k -a 4k ${md} # <= ~540k
- gpart add -t freebsd-zfs -l root $md
- # install-boot will make this bootable
- zpool create -O mountpoint=none -R ${mntpt} ${pool} ${md}p3
- zpool set bootfs=${pool} ${pool}
- zfs create -po mountpoint=/ ${pool}/ROOT/default
- # NB: The online guides go nuts customizing /var and other mountpoints here, no need
- cpsys ${src} ${mntpt}
- # need to make a couple of tweaks
- cat >> ${mntpt}/boot/loader.conf <<EOF
-cryptodev_load=YES
-zfs_load=YES
-EOF
- cp /boot/kernel/acl_nfs4.ko ${mntpt}/boot/kernel/acl_nfs4.ko
- cp /boot/kernel/cryptodev.ko ${mntpt}/boot/kernel/cryptodev.ko
- cp /boot/kernel/zfs.ko ${mntpt}/boot/kernel/zfs.ko
- # end tweaks
- zfs umount -f ${pool}/ROOT/default
- zfs set mountpoint=none ${pool}/ROOT/default
- zpool set bootfs=${pool}/ROOT/default ${pool}
- zpool set autoexpand=on ${pool}
- zpool export ${pool}
- ${SRCTOP}/tools/boot/install-boot.sh -g ${geli} -s ${scheme} -f ${fs} -b ${bios} -d ${src} ${md}
- mdconfig -d -u ${md}
+ zfs_extra $src $dst
+ make_esp_file ${img}.p2 ${espsize} ${src}/boot/loader.efi
+ makefs -t zfs -s 200m \
+ -o poolname=${pool} -o bootfs=${pool} -o rootpath=/ \
+ ${img}.p3 ${src} ${dst}
+ mkimg -b ${src}/boot/pmbr -s gpt \
+ -p freebsd-boot:=/boot/gptzfsboot \
+ -p efi:=${img}.p2 \
+ -p freebsd-zfs:=${img}.p3 \
+ -o ${img}
+ rm -rf ${dst}
}
mk_nogeli_mbr_ufs_legacy() {
src=$1
img=$2
- cat > ${src}/etc/fstab <<EOF
-/dev/${dev}s1a / ufs rw 1 1
-EOF
- makefs -t ffs -B little -s 200m ${img}.s1a ${src}
+ ufs_fstab ${src}
+ makefs -t ffs -B little -s 200m -o label=root ${img}.s1a ${src}
mkimg -s bsd -b ${src}/boot/boot -p freebsd-ufs:=${img}.s1a -o ${img}.s1
mkimg -a 1 -s mbr -b ${src}/boot/boot0sio -p freebsd:=${img}.s1 -o ${img}
rm -f ${src}/etc/fstab
@@ -220,11 +182,9 @@ mk_nogeli_mbr_ufs_uefi() {
src=$1
img=$2
- cat > ${src}/etc/fstab <<EOF
-/dev/${dev}s2a / ufs rw 1 1
-EOF
+ ufs_fstab ${src}
make_esp_file ${img}.s1 ${espsize} ${src}/boot/loader.efi
- makefs -t ffs -B little -s 200m ${img}.s2a ${src}
+ makefs -t ffs -B little -s 200m -o label=root ${img}.s2a ${src}
mkimg -s bsd -p freebsd-ufs:=${img}.s2a -o ${img}.s2
mkimg -a 1 -s mbr -p efi:=${img}.s1 -p freebsd:=${img}.s2 -o ${img}
rm -f ${src}/etc/fstab
@@ -234,57 +194,14 @@ mk_nogeli_mbr_ufs_both() {
src=$1
img=$2
- cat > ${src}/etc/fstab <<EOF
-/dev/${dev}s2a / ufs rw 1 1
-EOF
+ ufs_fstab ${src}
make_esp_file ${img}.s1 ${espsize} ${src}/boot/loader.efi
- makefs -t ffs -B little -s 200m ${img}.s2a ${src}
+ makefs -t ffs -B little -s 200m -o label=root ${img}.s2a ${src}
mkimg -s bsd -b ${src}/boot/boot -p freebsd-ufs:=${img}.s2a -o ${img}.s2
mkimg -a 2 -s mbr -b ${src}/boot/mbr -p efi:=${img}.s1 -p freebsd:=${img}.s2 -o ${img}
rm -f ${src}/etc/fstab
}
-mk_nogeli_mbr_zfs_legacy() {
- src=$1
- img=$2
- mntpt=$3
- geli=$4
- scheme=$5
- fs=$6
- bios=$7
- pool=nogeli-mbr-zfs-legacy
-
- dd if=/dev/zero of=${img} count=1 seek=$((200 * 1024 * 1024 / 512))
- md=$(mdconfig -f ${img})
- gpart create -s mbr ${md}
- gpart add -t freebsd ${md}
- gpart set -a active -i 1 ${md}
- gpart create -s bsd ${md}s1
- gpart add -t freebsd-zfs ${md}s1
- # install-boot will make this bootable
- zpool create -O mountpoint=none -R ${mntpt} ${pool} ${md}s1a
- zpool set bootfs=${pool} ${pool}
- zfs create -po mountpoint=/ ${pool}/ROOT/default
- # NB: The online guides go nuts customizing /var and other mountpoints here, no need
- cpsys ${src} ${mntpt}
- # need to make a couple of tweaks
- cat >> ${mntpt}/boot/loader.conf <<EOF
-cryptodev_load=YES
-zfs_load=YES
-EOF
- cp /boot/kernel/acl_nfs4.ko ${mntpt}/boot/kernel/acl_nfs4.ko
- cp /boot/kernel/cryptodev.ko ${mntpt}/boot/kernel/cryptodev.ko
- cp /boot/kernel/zfs.ko ${mntpt}/boot/kernel/zfs.ko
- # end tweaks
- zfs umount -f ${pool}/ROOT/default
- zfs set mountpoint=none ${pool}/ROOT/default
- zpool set bootfs=${pool}/ROOT/default ${pool}
- zpool set autoexpand=on ${pool}
- zpool export ${pool}
- ${SRCTOP}/tools/boot/install-boot.sh -g ${geli} -s ${scheme} -f ${fs} -b ${bios} -d ${src} ${md}
- mdconfig -d -u ${md}
-}
-
mk_nogeli_mbr_zfs_uefi() {
src=$1
img=$2
@@ -295,78 +212,14 @@ mk_nogeli_mbr_zfs_uefi() {
bios=$7
pool=nogeli-mbr-zfs-uefi
- dd if=/dev/zero of=${img} count=1 seek=$((200 * 1024 * 1024 / 512))
- md=$(mdconfig -f ${img})
- gpart create -s mbr ${md}
- gpart add -t efi -s ${espsize}k ${md}
- gpart add -t freebsd ${md}
- gpart set -a active -i 2 ${md}
- gpart create -s bsd ${md}s2
- gpart add -t freebsd-zfs ${md}s2
- # install-boot will make this bootable
- zpool create -O mountpoint=none -R ${mntpt} ${pool} ${md}s2a
- zpool set bootfs=${pool} ${pool}
- zfs create -po mountpoint=/ ${pool}/ROOT/default
- # NB: The online guides go nuts customizing /var and other mountpoints here, no need
- cpsys ${src} ${mntpt}
- # need to make a couple of tweaks
- cat >> ${mntpt}/boot/loader.conf <<EOF
-cryptodev_load=YES
-zfs_load=YES
-EOF
- cp /boot/kernel/acl_nfs4.ko ${mntpt}/boot/kernel/acl_nfs4.ko
- cp /boot/kernel/cryptodev.ko ${mntpt}/boot/kernel/cryptodev.ko
- cp /boot/kernel/zfs.ko ${mntpt}/boot/kernel/zfs.ko
- # end tweaks
- zfs umount -f ${pool}/ROOT/default
- zfs set mountpoint=none ${pool}/ROOT/default
- zpool set bootfs=${pool}/ROOT/default ${pool}
- zpool set autoexpand=on ${pool}
- zpool export ${pool}
- ${SRCTOP}/tools/boot/install-boot.sh -g ${geli} -s ${scheme} -f ${fs} -b ${bios} -d ${src} ${md}
- mdconfig -d -u ${md}
-}
-
-mk_nogeli_mbr_zfs_both() {
- src=$1
- img=$2
- mntpt=$3
- geli=$4
- scheme=$5
- fs=$6
- bios=$7
- pool=nogeli-mbr-zfs-both
-
- dd if=/dev/zero of=${img} count=1 seek=$((200 * 1024 * 1024 / 512))
- md=$(mdconfig -f ${img})
- gpart create -s mbr ${md}
- gpart add -t efi -s ${espsize}k ${md}
- gpart add -t freebsd ${md}
- gpart set -a active -i 2 ${md}
- gpart create -s bsd ${md}s2
- gpart add -t freebsd-zfs ${md}s2
- # install-boot will make this bootable
- zpool create -O mountpoint=none -R ${mntpt} ${pool} ${md}s2a
- zpool set bootfs=${pool} ${pool}
- zfs create -po mountpoint=/ ${pool}/ROOT/default
- # NB: The online guides go nuts customizing /var and other mountpoints here, no need
- cpsys ${src} ${mntpt}
- # need to make a couple of tweaks
- cat >> ${mntpt}/boot/loader.conf <<EOF
-cryptodev_load=YES
-zfs_load=YES
-EOF
- cp /boot/kernel/acl_nfs4.ko ${mntpt}/boot/kernel/acl_nfs4.ko
- cp /boot/kernel/cryptodev.ko ${mntpt}/boot/kernel/cryptodev.ko
- cp /boot/kernel/zfs.ko ${mntpt}/boot/kernel/zfs.ko
- # end tweaks
- zfs umount -f ${pool}/ROOT/default
- zfs set mountpoint=none ${pool}/ROOT/default
- zpool set bootfs=${pool}/ROOT/default ${pool}
- zpool set autoexpand=on ${pool}
- zpool export ${pool}
- ${SRCTOP}/tools/boot/install-boot.sh -g ${geli} -s ${scheme} -f ${fs} -b ${bios} -d ${src} ${md}
- mdconfig -d -u ${md}
+ zfs_extra $src $dst
+ make_esp_file ${img}.s1 ${espsize} ${src}/boot/loader.efi
+ makefs -t zfs -s 200m \
+ -o poolname=${pool} -o bootfs=${pool} -o rootpath=/ \
+ ${img}.s2a ${src} ${dst}
+ mkimg -s bsd -p freebsd-zfs:=${img}.s2a -o ${img}.s2
+ mkimg -a 1 -s mbr -b ${src}/boot/mbr -p efi:=${img}.s1 -p freebsd:=${img}.s2 -o ${img}
+ rm -rf ${dst}
}
mk_geli_gpt_ufs_legacy() {
@@ -386,16 +239,14 @@ mk_geli_gpt_ufs_legacy() {
# install-boot will make this bootable
echo ${passphrase} | geli init -bg -e AES-XTS -i ${iterations} -J - -l 256 -s 4096 ${md}p2
echo ${passphrase} | geli attach -j - ${md}p2
- newfs /dev/${md}p2.eli
+ newfs -L root /dev/${md}p2.eli
mount /dev/${md}p2.eli ${mntpt}
cpsys ${src} ${mntpt}
# need to make a couple of tweaks
cat > ${mntpt}/boot/loader.conf <<EOF
geom_eli_load=YES
EOF
- cat > ${mntpt}/etc/fstab <<EOF
-/dev/${dev}p2.eli / ufs rw 1 1
-EOF
+ ufs_fstab ${mntpt}
cp /boot/kernel/geom_eli.ko ${mntpt}/boot/kernel/geom_eli.ko
# end tweaks
@@ -422,16 +273,14 @@ mk_geli_gpt_ufs_uefi() {
# install-boot will make this bootable
echo ${passphrase} | geli init -bg -e AES-XTS -i ${iterations} -J - -l 256 -s 4096 ${md}p2
echo ${passphrase} | geli attach -j - ${md}p2
- newfs /dev/${md}p2.eli
+ newfs -L root /dev/${md}p2.eli
mount /dev/${md}p2.eli ${mntpt}
cpsys ${src} ${mntpt}
# need to make a couple of tweaks
cat > ${mntpt}/boot/loader.conf <<EOF
geom_eli_load=YES
EOF
- cat > ${mntpt}/etc/fstab <<EOF
-/dev/${dev}p2.eli / ufs rw 1 1
-EOF
+ ufs_fstab ${mntpt}
cp /boot/kernel/geom_eli.ko ${mntpt}/boot/kernel/geom_eli.ko
# end tweaks
@@ -459,16 +308,14 @@ mk_geli_gpt_ufs_both() {
# install-boot will make this bootable
echo ${passphrase} | geli init -bg -e AES-XTS -i ${iterations} -J - -l 256 -s 4096 ${md}p3
echo ${passphrase} | geli attach -j - ${md}p3
- newfs /dev/${md}p3.eli
+ newfs -L root /dev/${md}p3.eli
mount /dev/${md}p3.eli ${mntpt}
cpsys ${src} ${mntpt}
# need to make a couple of tweaks
cat > ${mntpt}/boot/loader.conf <<EOF
geom_eli_load=YES
EOF
- cat > ${mntpt}/etc/fstab <<EOF
-/dev/${dev}p3.eli / ufs rw 1 1
-EOF
+ ufs_fstab ${mntpt}
cp /boot/kernel/geom_eli.ko ${mntpt}/boot/kernel/geom_eli.ko
# end tweaks
@@ -645,30 +492,7 @@ mk_geli_mbr_zfs_both() {
# u-boot
# powerpc
-mk_sparc64_nogeli_vtoc8_ufs_ofw() {
- src=$1
- img=$2
- mntpt=$3
- geli=$4
- scheme=$5
- fs=$6
- bios=$7
-
- cat > ${src}/etc/fstab <<EOF
-/dev/${dev}a / ufs rw 1 1
-EOF
- makefs -t ffs -B big -s 200m ${img} ${src}
- md=$(mdconfig -f ${img})
- # For non-native builds, ensure that geom_part(4) supports VTOC8.
- kldload geom_part_vtoc8.ko
- gpart create -s VTOC8 ${md}
- gpart add -t freebsd-ufs ${md}
- ${SRCTOP}/tools/boot/install-boot.sh -g ${geli} -s ${scheme} -f ${fs} -b ${bios} -d ${src} ${md}
- mdconfig -d -u ${md}
- rm -f ${src}/etc/fstab
-}
-
-qser="-serial telnet::4444,server -nographic"
+qser="-monitor telnet::4444,server,nowait -serial stdio -nographic"
# https://wiki.freebsd.org/QemuRecipes
# aarch64
@@ -687,13 +511,22 @@ qemu_aarch64_uefi()
# -netdev user,id=net0
}
+log_for()
+{
+ dir=$(dirname $1)
+ fn=$(basename $1 .sh)
+ echo $dir/$fn.log
+}
+
# Amd64 qemu
qemu_amd64_legacy()
{
img=$1
sh=$2
+ log=$(log_for $2)
- echo "qemu-system-x86_64 -m 256m --drive file=${img},format=raw ${qser}" > $sh
+ echo "echo -n $(basename $sh .sh):' '" > $sh
+ echo "(qemu-system-x86_64 -m 256m --drive file=${img},format=raw ${qser} | tee $log 2>&1 | grep -q SUCCESS) && echo legacy pass || echo legacy fail" >> $sh
chmod 755 $sh
}
@@ -701,8 +534,10 @@ qemu_amd64_uefi()
{
img=$1
sh=$2
+ log=$(log_for $2)
- echo "qemu-system-x86_64 -m 256m -bios ~/bios/OVMF-X64.fd --drive file=${img},format=raw ${qser}" > $sh
+ echo "echo -n $(basename $sh .sh):' '" > $sh
+ echo "(qemu-system-x86_64 -m 256m -bios ~/bios/OVMF-X64.fd --drive file=${img},format=raw ${qser} | tee $log 2>&1 | grep -q SUCCESS) && echo uefi pass || echo uefi fail" >> $sh
chmod 755 $sh
}
@@ -710,9 +545,12 @@ qemu_amd64_both()
{
img=$1
sh=$2
+ log=$(log_for $2)
- echo "qemu-system-x86_64 -m 256m --drive file=${img},format=raw ${qser}" > $sh
- echo "qemu-system-x86_64 -m 256m -bios ~/bios/OVMF-X64.fd --drive file=${img},format=raw ${qser}" >> $sh
+ echo "echo -n $(basename $sh .sh):' '" > $sh
+ echo "(qemu-system-x86_64 -m 256m --drive file=${img},format=raw ${qser} | tee $log 2>&1 | grep -q SUCCESS) && echo legacy pass || echo legacy fail" >> $sh
+ echo "echo -n $(basename $sh .sh):' '" >> $sh
+ echo "(qemu-system-x86_64 -m 256m -bios ~/bios/OVMF-X64.fd --drive file=${img},format=raw ${qser} | tee -a $log 2>&1 | grep -q SUCCESS) && echo uefi pass || echo uefi fail" >> $sh
chmod 755 $sh
}
@@ -761,6 +599,8 @@ make_one_image()
# Create sparse file and mount newly created filesystem(s) on it
img=${IMGDIR}/${arch}-${geli}-${scheme}-${fs}-${bios}.img
sh=${IMGDIR}/${arch}-${geli}-${scheme}-${fs}-${bios}.sh
+ echo "$sh" >> ${IMGDIR}/all.sh
+ echo date >> ${IMGDIR}/all.sh
echo "vvvvvvvvvvvvvv Creating $img vvvvvvvvvvvvvvv"
rm -f ${img}*
eval mk_${geli}_${scheme}_${fs}_${bios} ${DESTDIR} ${img} ${MNTPT} ${geli} ${scheme} ${fs} ${bios}
@@ -769,16 +609,10 @@ make_one_image()
echo "^^^^^^^^^^^^^^ Created $img ^^^^^^^^^^^^^^^"
}
-# mips
-# qemu-system-mips -kernel /path/to/rootfs/boot/kernel/kernel -nographic -hda /path/to/disk.img -m 2048
-
# Powerpc -- doesn't work but maybe it would enough for testing -- needs details
# powerpc64
# qemu-system-ppc64 -drive file=/path/to/disk.img,format=raw
-# sparc64
-# qemu-system-sparc64 -drive file=/path/to/disk.img,format=raw
-
# Misc variables
SRCTOP=$(make -v SRCTOP)
cd ${SRCTOP}/stand
@@ -796,6 +630,7 @@ cp /boot/kernel/kernel ${DESTDIR}/boot/kernel
echo -h -D -S115200 > ${DESTDIR}/boot.config
cat > ${DESTDIR}/boot/loader.conf <<EOF
comconsole_speed=115200
+autoboot_delay=0
EOF
# XXX
cp /boot/device.hints ${DESTDIR}/boot/device.hints
@@ -822,24 +657,35 @@ EOF
# If we were given exactly 5 args, go make that one image.
+rm -f ${IMGDIR}/all.sh
+echo date > ${IMGDIR}/all.sh
+chmod +x ${IMGDIR}/all.sh
+
if [ $# -eq 5 ]; then
make_one_image $*
+ echo ${IMGDIR}/all.sh
exit
fi
# OK. Let the games begin
for arch in amd64; do
- for geli in nogeli geli; do
+ for geli in nogeli; do # geli
for scheme in gpt mbr; do
for fs in ufs zfs; do
for bios in legacy uefi both; do
+ # ZFS+MBR+BIOS is not supported
+ if [ "$scheme" = "mbr" -a "$fs" = "zfs" -a "$bios" != "uefi" ]; then
+ continue
+ fi
make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios}
done
done
done
done
done
+ # We should also do a cd image for amd64 here
+echo ${IMGDIR}/all.sh
rmdir ${MNTPT}
@@ -852,39 +698,47 @@ for arch in i386; do
for scheme in gpt mbr; do
for fs in ufs zfs; do
for bios in legacy; do
+ # The legacy boot is shared with amd64 so those routines could
+ # likely be used here.
+
+ # ZFS+MBR+BIOS is not supported
+ if [ "$scheme" = "mbr" -a "$fs" = "zfs" -a "$bios" != "uefi" ]; then
+ continue
+ fi
make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios}
done
done
done
done
done
+ # We should also do a cd image for i386 here
for arch in arm aarch64; do
+ geli=nogeli # I don't think geli boot works / is supported on arm
for scheme in gpt mbr; do
- fs=ufs
- for bios in uboot efi; do
- make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios}
- done
+ for fs in ufs zfs; do
+ bios=efi # Note: arm has some uboot support with ufs, what to do?
+ make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios}
+ done
done
done
-for arch in powerpc powerpc64; do
- for scheme in ppc-wtf; do
- fs=ufs
+# It's not clear that the nested looping paradigm is best for powerpc
+# due to its diversity.
+for arch in powerpc powerpc64 powerpc64le; do
+ geli=nogeli
+ for scheme in apm gpt; do
+ fs=ufs # zfs + gpt might be supported?
for bios in ofw uboot chrp; do
make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios}
done
done
done
-for arch in sparc64; do
- for geli in nogeli; do
- for scheme in vtoc8; do
- for fs in ufs; do
- for bios in ofw; do
- make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios}
- done
- done
- done
- done
+for arch in riscv; do
+ geli=nogeli
+ fs=ufs # Generic ZFS booting support with efi?
+ scheme=gpt
+ bios=efi
+ make_one_image ${arch} ${geli} ${scheme} ${fs} ${bios}
done
diff --git a/tools/boot/smbios/Makefile b/tools/boot/smbios/Makefile
new file mode 100644
index 000000000000..42a17aa54b5a
--- /dev/null
+++ b/tools/boot/smbios/Makefile
@@ -0,0 +1,9 @@
+PROG= smbios
+MAN=
+.PATH: ${SRCTOP}/stand/libsa
+SRCS= main.c
+CFLAGS+= -I${.CURDIR} -I${SRCTOP}/stand/libsa
+
+.include <bsd.prog.mk>
+
+CFLAGS+= -Wno-cast-align
diff --git a/tools/boot/smbios/main.c b/tools/boot/smbios/main.c
new file mode 100644
index 000000000000..60263d2ea8d9
--- /dev/null
+++ b/tools/boot/smbios/main.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2023 Warner Losh
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+/*
+ * Test program for smbios support in the boot loader. This program will mmap
+ * physical memory, and print the smbios table at the passed in PA. This is
+ * intended to test the code and debug problems in a debugger friendly
+ * environment.
+ */
+
+#include <sys/param.h>
+#define setenv my_setenv
+
+#define SMBIOS_SERIAL_NUMBERS 1
+#define SMBIOS_LITTLE_ENDIAN_UUID 1
+
+#include <arpa/inet.h>
+
+#include "smbios.h"
+#include "smbios.c"
+
+#include <sys/mman.h>
+
+#define MAX_MAP 10
+#define PAGE (64<<10)
+
+static struct mapping
+{
+ uintptr_t pa;
+ caddr_t va;
+} map[MAX_MAP];
+static int fd;
+static int nmap;
+
+caddr_t ptov(uintptr_t pa)
+{
+ caddr_t va;
+ uintptr_t pa2;
+ struct mapping *m = map;
+
+ pa2 = rounddown(pa, PAGE);
+ for (int i = 0; i < nmap; i++, m++) {
+ if (m->pa == pa2) {
+ return (m->va + pa - m->pa);
+ }
+ }
+ if (nmap == MAX_MAP)
+ errx(1, "Too many maps");
+ va = mmap(0, PAGE, PROT_READ, MAP_SHARED, fd, pa2);
+ if (va == MAP_FAILED)
+ err(1, "mmap offset %#lx", (long)pa2);
+ m = &map[nmap++];
+ m->pa = pa2;
+ m->va = va;
+ return (m->va + pa - m->pa);
+}
+
+static void
+cleanup(void)
+{
+ for (int i = 0; i < nmap; i++) {
+ munmap(map[i].va, PAGE);
+ }
+}
+
+int
+my_setenv(const char *name, const char *value, int overwrite __unused)
+{
+ printf("%s=%s\n", name, value);
+ return 0;
+}
+
+static void
+usage(void)
+{
+ errx(1, "smbios address");
+}
+
+int
+main(int argc, char **argv)
+{
+ uintptr_t addr;
+
+ if (argc != 2)
+ usage();
+ addr = strtoull(argv[1], NULL, 0);
+ /* For mmap later */
+ fd = open("/dev/mem", O_RDONLY);
+ if (fd < 0)
+ err(1, "Opening /dev/mem");
+ smbios_detect(ptov(addr));
+ cleanup();
+}
diff --git a/tools/boot/smbios/stand.h b/tools/boot/smbios/stand.h
new file mode 100644
index 000000000000..d754189fad13
--- /dev/null
+++ b/tools/boot/smbios/stand.h
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2023 Warner Losh
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <sys/types.h>
+
+#include <err.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+caddr_t ptov(uintptr_t pa);
diff --git a/tools/boot/universe.sh b/tools/boot/universe.sh
index a23678100705..80a9cc0b90ff 100755
--- a/tools/boot/universe.sh
+++ b/tools/boot/universe.sh
@@ -1,15 +1,9 @@
#!/bin/sh
-# $FreeBSD$
-
#
-# Full list of all arches, but we only build a subset. All different mips add any
-# value, and there's a few others we just don't support.
+# Full list of all arches we don't build.
#
-# mips/mipsel mips/mips mips/mips64el mips/mips64 mips/mipsn32 \
-# mips/mipselhf mips/mipshf mips/mips64elhf mips/mips64hf \
-# powerpc/powerpc powerpc/powerpc64 powerpc/powerpcspe \
-# riscv/riscv64 riscv/riscv64sf
+# powerpc/powerpcspe
#
# This script is expected to be run in stand (though you could run it anywhere
# in the tree). It does a full clean build. For stand you can do all the archs in
@@ -45,7 +39,7 @@ dobuild()
echo "Fail (cleanup)"
continue
fi
- if ! make buildenv TARGET_ARCH=$ta BUILDENV_SHELL="make ${opt} -j 20 all" \
+ if ! make buildenv TARGET_ARCH=$ta BUILDENV_SHELL="make ${opt} -j 40 all" \
>> $lf 2>&1; then
echo "Fail (build)"
continue
@@ -58,6 +52,7 @@ cd $top/stand
# Build without forth
for i in \
+ arm64/aarch64 \
amd64/amd64 \
i386/i386 \
; do
@@ -67,6 +62,7 @@ done
# Build without GELI
for i in \
+ arm64/aarch64 \
amd64/amd64 \
i386/i386 \
; do
@@ -74,46 +70,36 @@ for i in \
dobuild $ta _.boot.${ta}.no_geli.log "WITHOUT_LOADER_GEIL=yes"
done
-# Default build for a goodly selection of architectures
+# Default build for a almost all architectures
for i in \
amd64/amd64 \
arm/armv7 \
arm64/aarch64 \
i386/i386 \
- mips/mips mips/mips64 \
- powerpc/powerpc powerpc/powerpc64 \
+ powerpc/powerpc \
+ powerpc/powerpc64 \
+ powerpc/powerpc64le \
+ riscv/riscv64 \
; do
ta=${i##*/}
dobuild $ta _.boot.${ta}.log ""
done
-# Default build for a goodly selection of architectures with Lua
-for i in \
- amd64/amd64 \
- arm/armv7 \
- arm64/aarch64 \
- i386/i386 \
- mips/mips mips/mips64 \
- powerpc/powerpc powerpc/powerpc64 \
- ; do
- ta=${i##*/}
- dobuild $ta _.boot.${ta}.lua.log "MK_LOADER_LUA=yes MK_FORTH=no"
-done
-
# Build w/o ZFS
for i in \
+ arm64/aarch64 \
amd64/amd64 \
i386/i386 \
; do
ta=${i##*/}
- dobuild $ta _.boot.${ta}.no_zfs.log "MK_ZFS=no"
+ dobuild $ta _.boot.${ta}.no_zfs.log "MK_LOADER_ZFS=no"
done
-# Build with firewire
+# Build w/o LOADER_BIOS_TEXTONLY
for i in \
amd64/amd64 \
i386/i386 \
; do
ta=${i##*/}
- dobuild $ta _.boot.${ta}.firewire.log "MK_LOADER_FIREWIRE=yes"
+ dobuild $ta _.boot.${ta}.no_zfs.log "MK_LOADER_BIOS_TEXTONLY=no"
done