git: 93fa71ab2499 - stable/14 - kboot: Move _start out of kboot and into libkboot

From: Warner Losh <imp_at_FreeBSD.org>
Date: Tue, 16 Apr 2024 20:12:20 UTC
The branch stable/14 has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=93fa71ab2499dcd8460d472d4b9911de120e2577

commit 93fa71ab2499dcd8460d472d4b9911de120e2577
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2024-01-28 18:53:59 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-04-16 19:54:20 +0000

    kboot: Move _start out of kboot and into libkboot
    
    Move the startup code from kboot/kboot to kboot/libkboot and add the
    necessary infrastructure for it to build. move start_arch.h, a private
    header for libkboot, over as well.
    
    Sponsored by:           Netflix
    
    (cherry picked from commit a03411e84728e9b267056fd31c7d1d9d1dc1b01e)
---
 stand/kboot/Makefile                                        |  2 +-
 stand/kboot/Makefile.inc                                    |  6 ++++++
 stand/kboot/kboot/Makefile                                  |  5 ++---
 stand/kboot/libkboot/Makefile                               | 10 ++++++++++
 stand/kboot/{kboot => libkboot}/arch/aarch64/start_arch.h   |  0
 stand/kboot/{kboot => libkboot}/arch/amd64/start_arch.h     |  0
 stand/kboot/{kboot => libkboot}/arch/powerpc64/start_arch.h |  0
 stand/kboot/{kboot => libkboot}/crt1.c                      |  0
 8 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/stand/kboot/Makefile b/stand/kboot/Makefile
index 2e0b9d7a2e09..72dbabc00568 100644
--- a/stand/kboot/Makefile
+++ b/stand/kboot/Makefile
@@ -2,6 +2,6 @@ NO_OBJ=t
 
 .include <bsd.init.mk>
 
-SUBDIR+=	kboot
+SUBDIR+=	libkboot .WAIT kboot
 
 .include <bsd.subdir.mk>
diff --git a/stand/kboot/Makefile.inc b/stand/kboot/Makefile.inc
index 01b5f23410c8..02aecdad55f1 100644
--- a/stand/kboot/Makefile.inc
+++ b/stand/kboot/Makefile.inc
@@ -1 +1,7 @@
+# Bring in the mini-libc that we wrote
+
+KBOOTSRC=${BOOTSRC}/kboot
+CFLAGS+=-I${KBOOTSRC}/include
+LIBKBOOT=${BOOTOBJ}/kboot/libkboot/libkboot.a
+
 .include "../Makefile.inc"
diff --git a/stand/kboot/kboot/Makefile b/stand/kboot/kboot/Makefile
index b9d68cddf97d..4054bb1da9f2 100644
--- a/stand/kboot/kboot/Makefile
+++ b/stand/kboot/kboot/Makefile
@@ -21,7 +21,6 @@ INSTALLFLAGS=	-b
 SRCS=	\
 		bootinfo.c \
 		conf.c \
-		crt1.c \
 		gfx_fb_stub.c \
 		host_syscalls.c \
 		hostcons.c \
@@ -63,7 +62,7 @@ CFLAGS+=	-I${.CURDIR} -I${.CURDIR}/arch/${MACHINE_ARCH}
 
 CFLAGS+=	-Wall
 
-DPADD=		${LDR_INTERP} ${LIBOFW} ${LIBSAFDT} ${LIBSA}
-LDADD=		${LDR_INTERP} ${LIBOFW} ${LIBSAFDT} ${LIBSA}
+DPADD=		${LDR_INTERP} ${LIBOFW} ${LIBSAFDT} ${LIBSA} ${LIBKBOOT}
+LDADD=		${LDR_INTERP} ${LIBOFW} ${LIBSAFDT} ${LIBSA} ${LIBKBOOT}
 
 .include <bsd.prog.mk>
diff --git a/stand/kboot/libkboot/Makefile b/stand/kboot/libkboot/Makefile
new file mode 100644
index 000000000000..415571617d2a
--- /dev/null
+++ b/stand/kboot/libkboot/Makefile
@@ -0,0 +1,10 @@
+.include <bsd.init.mk>
+
+LIB=	kboot
+WARNS?= 4
+
+CFLAGS+=-I${.CURDIR} -I${.CURDIR}/arch/${MACHINE_ARCH}
+
+SRCS=	crt1.c
+
+.include <bsd.lib.mk>
diff --git a/stand/kboot/kboot/arch/aarch64/start_arch.h b/stand/kboot/libkboot/arch/aarch64/start_arch.h
similarity index 100%
rename from stand/kboot/kboot/arch/aarch64/start_arch.h
rename to stand/kboot/libkboot/arch/aarch64/start_arch.h
diff --git a/stand/kboot/kboot/arch/amd64/start_arch.h b/stand/kboot/libkboot/arch/amd64/start_arch.h
similarity index 100%
rename from stand/kboot/kboot/arch/amd64/start_arch.h
rename to stand/kboot/libkboot/arch/amd64/start_arch.h
diff --git a/stand/kboot/kboot/arch/powerpc64/start_arch.h b/stand/kboot/libkboot/arch/powerpc64/start_arch.h
similarity index 100%
rename from stand/kboot/kboot/arch/powerpc64/start_arch.h
rename to stand/kboot/libkboot/arch/powerpc64/start_arch.h
diff --git a/stand/kboot/kboot/crt1.c b/stand/kboot/libkboot/crt1.c
similarity index 100%
rename from stand/kboot/kboot/crt1.c
rename to stand/kboot/libkboot/crt1.c