git: eca56377601f - main - stand: userboot: allow building on !x86
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 18 Jun 2025 18:42:37 UTC
The branch main has been updated by kevans:
URL: https://cgit.FreeBSD.org/src/commit/?id=eca56377601fb87afb0a001d59adaadb33d137ad
commit eca56377601fb87afb0a001d59adaadb33d137ad
Author: Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2025-06-18 18:42:29 +0000
Commit: Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2025-06-18 18:42:29 +0000
stand: userboot: allow building on !x86
We can still get plenty of use out of a userboot that doesn't know
anything about how to load or boot a kernel; notably, the test harness
in tools/boot can still be used to test lua changes.
Hack out the necessary bits to simply build on other platforms, and add
a small warning with ample time to view the warning on other platforms.
We still won't build userboot by default on these platforms, since the
build product isn't useful for most people.
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D41529
---
stand/userboot/userboot/Makefile | 16 ++++++++++++++++
stand/userboot/userboot/conf.c | 4 ++++
stand/userboot/userboot/main.c | 5 +++++
3 files changed, 25 insertions(+)
diff --git a/stand/userboot/userboot/Makefile b/stand/userboot/userboot/Makefile
index a1ba1b4d700e..2a66c0e3f8fe 100644
--- a/stand/userboot/userboot/Makefile
+++ b/stand/userboot/userboot/Makefile
@@ -13,18 +13,30 @@ SHLIB_NAME= userboot_${LOADER_INTERP}.so
STRIP=
LIBDIR= /boot
+.if ${MACHINE_CPUARCH} == "amd64"
+USERBOOT_KERNEL_SUPPORT= yes
+.else
+USERBOOT_KERNEL_SUPPORT= no
+.endif
+
.PATH: ${.CURDIR}/../userboot
SRCS= autoload.c
SRCS+= bcache.c
+.if ${MACHINE_CPUARCH} == "amd64"
SRCS+= biossmap.c
+.endif
+.if ${USERBOOT_KERNEL_SUPPORT} == "yes"
SRCS+= bootinfo.c
SRCS+= bootinfo32.c
SRCS+= bootinfo64.c
+.endif
SRCS+= conf.c
SRCS+= copy.c
SRCS+= devicename.c
+.if ${USERBOOT_KERNEL_SUPPORT} == "yes"
SRCS+= elf32_freebsd.c
SRCS+= elf64_freebsd.c
+.endif
SRCS+= host.c
SRCS+= main.c
SRCS+= userboot_cons.c
@@ -49,6 +61,10 @@ VERSION_FILE?= ${.CURDIR}/../userboot/version
LINKS+= ${BINDIR}/${SHLIB_NAME} ${BINDIR}/userboot.so
.endif
+.if ${USERBOOT_KERNEL_SUPPORT} == "yes"
+CFLAGS+= -DUSERBOOT_KERNEL_SUPPORT
+.endif
+
.if ${MK_LOADER_ZFS} != "no"
CFLAGS+= -DUSERBOOT_ZFS_SUPPORT
HAVE_ZFS=yes
diff --git a/stand/userboot/userboot/conf.c b/stand/userboot/userboot/conf.c
index abfd16c592e7..63f64cb97fbe 100644
--- a/stand/userboot/userboot/conf.c
+++ b/stand/userboot/userboot/conf.c
@@ -83,16 +83,20 @@ struct netif_driver *netif_drivers[] = {
* Sort formats so that those that can detect based on arguments
* rather than reading the file go first.
*/
+#if defined(__amd64__)
extern struct file_format i386_elf;
extern struct file_format i386_elf_obj;
extern struct file_format amd64_elf;
extern struct file_format amd64_elf_obj;
+#endif
struct file_format *file_formats[] = {
+#if defined(__amd64__)
&i386_elf,
&i386_elf_obj,
&amd64_elf,
&amd64_elf_obj,
+#endif
NULL
};
diff --git a/stand/userboot/userboot/main.c b/stand/userboot/userboot/main.c
index 53b76c685d92..03f226c08bb9 100644
--- a/stand/userboot/userboot/main.c
+++ b/stand/userboot/userboot/main.c
@@ -205,6 +205,11 @@ loader_main(struct loader_callbacks *cb, void *arg, int version, int ndisks)
devinit();
extract_currdev();
+#if !defined(USERBOOT_KERNEL_SUPPORT)
+ printf("WARNING: This userboot does not support loading a kernel\n");
+ delay(1500000);
+#endif
+
/*
* Checking the interpreter isn't worth the overhead unless we
* actually have the swap_interpreter callback, so we actually version