Infrastructure for putting kernel+modules in /netbsd/kernel and
/netbsd/modules respectively instead of /netbsd and /stand/<arch>/<version>/modules. This is only supported for x86, and is turned off by default. To try it, add KERNEL_DIR=yes in your /mk.conf and install a system from that build.
This commit is contained in:
parent
f6bfb0c4d8
commit
d8e96a2d4f
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile.minirootkmod,v 1.3 2014/08/05 15:40:58 apb Exp $
|
||||
# $NetBSD: Makefile.minirootkmod,v 1.4 2020/04/04 19:50:53 christos Exp $
|
||||
#
|
||||
# Makefile snippet to build a miniroot kernel module (e.g. miniroot.kmod)
|
||||
#
|
||||
@ -36,7 +36,11 @@ PROG= ${MINIROOT}.kmod
|
||||
# RAMDISKFS is the ramdisk image to be included inside DSTMOD. It should
|
||||
# already have been created by the Makefile in RAMDISKSRCDIR.
|
||||
#
|
||||
.if ${KERNEL_DIR:U*no} == "yes"
|
||||
SRCMOD= ${DESTDIR}/netbsd/modules/miniroot/miniroot.kmod
|
||||
.else
|
||||
SRCMOD= ${DESTDIR}/stand/${MACHINE}/${MODULEVER}/modules/miniroot/miniroot.kmod
|
||||
.endif
|
||||
DSTMOD= ${.OBJDIR}/${MINIROOT}.kmod
|
||||
RAMDISKSRCDIR= ${.CURDIR}/../ramdisks/${RAMDISK}
|
||||
RAMDISKOBJDIR!= cd ${RAMDISKSRCDIR} && ${PRINTOBJDIR}
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: mi,v 1.1238 2020/04/04 15:39:15 jdolecek Exp $
|
||||
# $NetBSD: mi,v 1.1239 2020/04/04 19:50:53 christos Exp $
|
||||
#
|
||||
# Note: Don't delete entries from here - mark them as "obsolete" instead,
|
||||
# unless otherwise stated below.
|
||||
@ -660,6 +660,7 @@
|
||||
./sbin/zfs base-zfs-bin zfs
|
||||
./sbin/zpool base-zfs-bin zfs
|
||||
./stand base-sys-root
|
||||
./netbsd base-sys-root kernel_dir
|
||||
./tmp base-sys-root
|
||||
./usr base-sys-root
|
||||
./usr/bin base-sys-usr
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: mi,v 1.135 2020/04/04 15:39:16 jdolecek Exp $
|
||||
# $NetBSD: mi,v 1.136 2020/04/04 19:50:53 christos Exp $
|
||||
#
|
||||
# Note: don't delete entries from here - mark them as "obsolete" instead.
|
||||
#
|
||||
@ -481,5 +481,6 @@
|
||||
./@MODULEDIR@/zlib modules-base-kernel kmod
|
||||
./@MODULEDIR@/zlib/zlib.kmod modules-base-kernel kmod
|
||||
./etc/mtree/set.modules modules-sys-root kmod
|
||||
./stand/@MACHINE@ modules-base-kernel kmod
|
||||
./stand/@MACHINE@/@OSRELEASE@ modules-base-kernel kmod
|
||||
./stand/@MACHINE@ modules-base-kernel kmod,!kernel_dir
|
||||
./stand/@MACHINE@/@OSRELEASE@ modules-base-kernel kmod,!kernel_dir
|
||||
./netbsd kmod,kernel_dir
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: mkvars.mk,v 1.37 2019/04/16 21:20:51 mrg Exp $
|
||||
# $NetBSD: mkvars.mk,v 1.38 2020/04/04 19:50:53 christos Exp $
|
||||
|
||||
MKEXTRAVARS= \
|
||||
MACHINE \
|
||||
@ -16,6 +16,7 @@ MKEXTRAVARS= \
|
||||
OBJECT_FMT \
|
||||
TOOLCHAIN_MISSING \
|
||||
EXTSRCS \
|
||||
KERNEL_DIR \
|
||||
MKMANZ \
|
||||
MKBFD \
|
||||
MKCOMPAT \
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: sets.subr,v 1.187 2019/10/02 11:16:00 maya Exp $
|
||||
# $NetBSD: sets.subr,v 1.188 2020/04/04 19:50:53 christos Exp $
|
||||
#
|
||||
|
||||
#
|
||||
@ -168,7 +168,11 @@ xlists="xbase xcomp $xdebugset xetc xfont xserver"
|
||||
extlists="extbase extcomp extetc"
|
||||
|
||||
OSRELEASE=$(${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh -k)
|
||||
MODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules"
|
||||
if [ "${KERNEL_DIR}" = "yes" ]; then
|
||||
MODULEDIR="netbsd/modules"
|
||||
else
|
||||
MODULEDIR="stand/${MACHINE}/${OSRELEASE}/modules"
|
||||
fi
|
||||
SUBST="s#@MODULEDIR@#${MODULEDIR}#g"
|
||||
SUBST="${SUBST};s#@OSRELEASE@#${OSRELEASE}#g"
|
||||
SUBST="${SUBST};s#@MACHINE@#${MACHINE}#g"
|
||||
@ -180,7 +184,7 @@ SUBST="${SUBST};s#@MACHINE@#${MACHINE}#g"
|
||||
# In each file, a record consists of a path and a System Package name,
|
||||
# separated by whitespace. E.g.,
|
||||
#
|
||||
# # $NetBSD: sets.subr,v 1.187 2019/10/02 11:16:00 maya Exp $
|
||||
# # $NetBSD: sets.subr,v 1.188 2020/04/04 19:50:53 christos Exp $
|
||||
# . base-sys-root [keyword[,...]]
|
||||
# ./altroot base-sys-root
|
||||
# ./bin base-sys-root
|
||||
|
35
etc/Makefile
35
etc/Makefile
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.441 2019/10/02 11:16:00 maya Exp $
|
||||
# $NetBSD: Makefile,v 1.442 2020/04/04 19:50:53 christos Exp $
|
||||
# from: @(#)Makefile 8.7 (Berkeley) 5/25/95
|
||||
|
||||
# Environment variables without default values:
|
||||
@ -621,21 +621,46 @@ kernset-${configfile}: .PHONY build_kernels snap_pre
|
||||
ks="$${kernel}$${s}"; \
|
||||
[ -f $${ks} ] || continue; \
|
||||
kernels="$${kernels} $${ks}"; \
|
||||
[ -z "$${newest}" -o $${ks} -nt "$${newest}" ] && \
|
||||
newest=$${ks}; \
|
||||
[ -z "$${newest}" -o $${ks} \
|
||||
-nt "$${newest}" ] && newest=$${ks}; \
|
||||
done; \
|
||||
done; \
|
||||
[ $${kern_tgz} -nt "$${newest}" ] || { \
|
||||
echo "echo $${kernels} | $${pax_cmd}"; \
|
||||
if [ ${KERNELDIR} = "yes" ]; them \
|
||||
tmpdir=kernel$$; \
|
||||
trap "rm -fr $${tmpdir}" 0 1 2 3 15; \
|
||||
mkdir -p $${tmpdir}/netbsd; \
|
||||
d=./netbsd; \
|
||||
cd $${tmpdir}; \
|
||||
else \
|
||||
d=.; \
|
||||
fi; \
|
||||
( echo "/set uname=${BINOWN} gname=${BINGRP}"; \
|
||||
echo ". type=dir optional"; \
|
||||
if [ ${KERNEL_DIR} = "yes" ]; then \
|
||||
echo "./netbsd type=dir optional"; \
|
||||
fi; \
|
||||
dtblist=$$(${MAKE} -v DTB); \
|
||||
for dtb in $${dtblist}; do \
|
||||
echo "./$${dtb} type=file"; \
|
||||
if [ ${KERNEL_DIR} = "yes" ]; then \
|
||||
ln ../$${dtb} ./netbsd/$${dtb}; \
|
||||
fi; \
|
||||
echo "$${d}/$${dtb} type=file"; \
|
||||
done; \
|
||||
for kernel in $${kernels}; do \
|
||||
echo "./$${kernel} type=file"; \
|
||||
if [ ${KERNEL_DIR} = "yes" ]; then \
|
||||
newname=$$(echo $${kernel} | \
|
||||
${TOOL_SED} -e s/netbsd/kernel/); \
|
||||
ln ../$${kernel} ./netbsd/$${newname}; \
|
||||
else \
|
||||
newname=$${kernel}; \
|
||||
fi; \
|
||||
echo "$${d}/$${newname} type=file"; \
|
||||
done ) | eval $${pax_cmd}; \
|
||||
if [ ${KERNEL_DIR} = "yes" ]; then \
|
||||
mv $${kern_tgz} ..; \
|
||||
fi; \
|
||||
} \
|
||||
}
|
||||
.endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: bsd.kmodule.mk,v 1.63 2019/12/01 20:24:47 jmcneill Exp $
|
||||
# $NetBSD: bsd.kmodule.mk,v 1.64 2020/04/04 19:50:53 christos Exp $
|
||||
|
||||
# We are not building this with PIE
|
||||
MKPIE=no
|
||||
@ -172,7 +172,13 @@ ${PROG}: ${OBJS} ${DPADD} ${KMODSCRIPT}
|
||||
##### Install rules
|
||||
.if !target(kmodinstall)
|
||||
.if !defined(KMODULEDIR)
|
||||
.if ${KERNEL_DIR:Uno} == "yes"
|
||||
KMODULEDIR= ${DESTDIR}/netbsd/modules/${KMOD}
|
||||
_INST_DIRS= ${DESTDIR}/netbsd
|
||||
_INST_DIRS+= ${DESTDIR}/netbsd/modules
|
||||
_INST_DIRS+= ${DESTDIR}/netbsd/modules/${KMOD}
|
||||
_OSRELEASE!= ${HOST_SH} $S/conf/osrelease.sh -k
|
||||
.else
|
||||
# Ensure these are recorded properly in METALOG on unprived installes:
|
||||
KMODULEARCHDIR?= ${MACHINE}
|
||||
_INST_DIRS= ${DESTDIR}/stand/${KMODULEARCHDIR}
|
||||
@ -180,6 +186,7 @@ _INST_DIRS+= ${DESTDIR}/stand/${KMODULEARCHDIR}/${_OSRELEASE}
|
||||
_INST_DIRS+= ${DESTDIR}/stand/${KMODULEARCHDIR}/${_OSRELEASE}/modules
|
||||
KMODULEDIR= ${DESTDIR}/stand/${KMODULEARCHDIR}/${_OSRELEASE}/modules/${KMOD}
|
||||
.endif
|
||||
.endif
|
||||
_PROG:= ${KMODULEDIR}/${PROG} # installed path
|
||||
|
||||
.if ${MKUPDATE} == "no"
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile.boot,v 1.73 2019/09/13 02:19:45 manu Exp $
|
||||
# $NetBSD: Makefile.boot,v 1.74 2020/04/04 19:50:54 christos Exp $
|
||||
|
||||
S= ${.CURDIR}/../../../../..
|
||||
|
||||
@ -53,6 +53,10 @@ CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes
|
||||
CPPFLAGS+= -nostdinc -D_STANDALONE
|
||||
CPPFLAGS+= -I$S
|
||||
|
||||
.if ${KERNEL_DIR:Uno} == "yes"
|
||||
CPPFLAGS+= -DKERNEL_DIR
|
||||
.endif
|
||||
|
||||
CPPFLAGS+= -DSUPPORT_PS2
|
||||
CPPFLAGS+= -DDIRECT_SERIAL
|
||||
CPPFLAGS+= -DSUPPORT_SERIAL=boot_params.bp_consdev
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: boot2.c,v 1.72 2019/09/02 06:10:24 manu Exp $ */
|
||||
/* $NetBSD: boot2.c,v 1.73 2020/04/04 19:50:54 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
|
||||
@ -279,6 +279,12 @@ bootit(const char *filename, int howto)
|
||||
if (howto & AB_VERBOSE)
|
||||
printf("booting %s (howto 0x%x)\n", sprint_bootsel(filename),
|
||||
howto);
|
||||
#ifdef KERNEL_DIR
|
||||
char path[512];
|
||||
strcpy(path, filename);
|
||||
strcat(path, "/kernel");
|
||||
(void)exec_netbsd(path, 0, howto, boot_biosdev < 0x80, clearit);
|
||||
#endif
|
||||
|
||||
if (exec_netbsd(filename, 0, howto, boot_biosdev < 0x80, clearit) < 0)
|
||||
printf("boot: %s: %s\n", sprint_bootsel(filename),
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: exec.c,v 1.75 2019/12/07 02:29:03 christos Exp $ */
|
||||
/* $NetBSD: exec.c,v 1.76 2020/04/04 19:50:54 christos Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
|
||||
@ -151,7 +151,7 @@ static void module_add_common(const char *, uint8_t);
|
||||
static void userconf_init(void);
|
||||
|
||||
static void extract_device(const char *, char *, size_t);
|
||||
static void module_base_path(char *, size_t);
|
||||
static void module_base_path(char *, size_t, const char *);
|
||||
static int module_open(boot_module_t *, int, const char *, const char *,
|
||||
bool);
|
||||
|
||||
@ -653,8 +653,15 @@ module_open(boot_module_t *bm, int mode, const char *kdev,
|
||||
}
|
||||
|
||||
static void
|
||||
module_base_path(char *buf, size_t bufsize)
|
||||
module_base_path(char *buf, size_t bufsize, const char *kernel_path)
|
||||
{
|
||||
#ifdef KERNEL_DIR
|
||||
/* we cheat here, because %.* does not work with the mini printf */
|
||||
char *ptr = strrchr(kernel_path, '/');
|
||||
if (ptr) *ptr = '\0';
|
||||
snprintf(buf, bufsize, "%s/modules", kernel_path);
|
||||
if (ptr) *ptr = '/';
|
||||
#else
|
||||
const char *machine;
|
||||
|
||||
switch (netbsd_elf_class) {
|
||||
@ -682,6 +689,7 @@ module_base_path(char *buf, size_t bufsize)
|
||||
netbsd_version / 100000000,
|
||||
netbsd_version / 1000000 % 100);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
@ -697,7 +705,7 @@ module_init(const char *kernel_path)
|
||||
int err, fd, nfail = 0;
|
||||
|
||||
extract_device(kernel_path, kdev, sizeof(kdev));
|
||||
module_base_path(module_base, sizeof(module_base));
|
||||
module_base_path(module_base, sizeof(module_base), kernel_path);
|
||||
|
||||
/* First, see which modules are valid and calculate btinfo size */
|
||||
len = sizeof(struct btinfo_modulelist);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: x86_machdep.c,v 1.136 2020/04/04 14:49:35 ad Exp $ */
|
||||
/* $NetBSD: x86_machdep.c,v 1.137 2020/04/04 19:50:54 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2002, 2006, 2007 YAMAMOTO Takashi,
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.136 2020/04/04 14:49:35 ad Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: x86_machdep.c,v 1.137 2020/04/04 19:50:54 christos Exp $");
|
||||
|
||||
#include "opt_modular.h"
|
||||
#include "opt_physmem.h"
|
||||
@ -1160,6 +1160,13 @@ x86_startup(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *
|
||||
get_booted_kernel(void)
|
||||
{
|
||||
const struct btinfo_bootpath *bibp = lookup_bootinfo(BTINFO_BOOTPATH);
|
||||
return bibp ? bibp->bootpath : NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* machine dependent system variables.
|
||||
*/
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile.kern.inc,v 1.268 2019/02/05 08:33:25 mrg Exp $
|
||||
# $NetBSD: Makefile.kern.inc,v 1.269 2020/04/04 19:50:54 christos Exp $
|
||||
#
|
||||
# This file contains common `MI' targets and definitions and it is included
|
||||
# at the bottom of each `MD' ${MACHINE}/conf/Makefile.${MACHINE}.
|
||||
@ -66,6 +66,9 @@ CPPFLAGS+= ${INCLUDES} ${IDENT} -D_KERNEL -D_KERNEL_OPT
|
||||
.if !defined(COVERITY_TOP_CONFIG)
|
||||
CPPFLAGS+= -std=gnu99
|
||||
.endif
|
||||
.if ${KERNEL_DIR:Uno} == "yes"
|
||||
CPPFLAGS+= -DKERNEL_DIR
|
||||
.endif
|
||||
DEFCOPTS?= -O2
|
||||
COPTS?= ${DEFCOPTS}
|
||||
DBG= # might contain unwanted -Ofoo
|
||||
@ -413,10 +416,17 @@ install: install-kernel-${MACHINE_NAME}
|
||||
.if !target(install-kernel-${MACHINE_NAME})
|
||||
install-kernel-${MACHINE_NAME}:
|
||||
.for _K in ${KERNIMAGES}
|
||||
.if ${KERNEL_DIR:Uno} == "yes"
|
||||
rm -fr ${DESTDIR}/o${_K}
|
||||
mv ${DESTDIR}/${_K} ${DESTDIR}/o${_K}
|
||||
mkdir -p ${DESTDIR}/${_K}
|
||||
cp ${_K} ${DESTDIR}/${_K}/kernel
|
||||
.else
|
||||
rm -f ${DESTDIR}/o${_K}
|
||||
ln ${DESTDIR}/${_K} ${DESTDIR}/o${_K}
|
||||
cp ${_K} ${DESTDIR}/n${_K}
|
||||
mv ${DESTDIR}/n${_K} ${DESTDIR}/${_K}
|
||||
.endif
|
||||
.endfor
|
||||
.endif
|
||||
.endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: kern_module.c,v 1.148 2020/03/20 23:09:01 pgoyette Exp $ */
|
||||
/* $NetBSD: kern_module.c,v 1.149 2020/04/04 19:50:54 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
@ -34,7 +34,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.148 2020/03/20 23:09:01 pgoyette Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: kern_module.c,v 1.149 2020/04/04 19:50:54 christos Exp $");
|
||||
|
||||
#define _MODULE_INTERNAL
|
||||
|
||||
@ -421,6 +421,18 @@ module_init(void)
|
||||
module_init_md();
|
||||
#endif
|
||||
|
||||
#ifdef KERNEL_DIR
|
||||
const char *booted_kernel = get_booted_kernel();
|
||||
if (booted_kernel) {
|
||||
char *ptr = strrchr(booted_kernel, '/');
|
||||
snprintf(module_base, sizeof(module_base), "/%.*s/modules",
|
||||
(int)(ptr - booted_kernel), booted_kernel);
|
||||
} else {
|
||||
strlcpy(module_base, "/netbsd/modules", sizeof(module_base));
|
||||
printf("Cannot find kernel name, loading modules from \"%s\"\n",
|
||||
module_base);
|
||||
}
|
||||
#else
|
||||
if (!module_machine)
|
||||
module_machine = machine;
|
||||
#if __NetBSD_Version__ / 1000000 % 100 == 99 /* -current */
|
||||
@ -430,6 +442,7 @@ module_init(void)
|
||||
snprintf(module_base, sizeof(module_base), "/stand/%s/%d.%d/modules",
|
||||
module_machine, __NetBSD_Version__ / 100000000,
|
||||
__NetBSD_Version__ / 1000000 % 100);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
module_listener = kauth_listen_scope(KAUTH_SCOPE_SYSTEM,
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: systm.h,v 1.293 2020/02/08 07:07:07 maxv Exp $ */
|
||||
/* $NetBSD: systm.h,v 1.294 2020/04/04 19:50:54 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1988, 1991, 1993
|
||||
@ -166,6 +166,8 @@ extern int boothowto; /* reboot flags, from console subsystem */
|
||||
#define bootverbose (boothowto & AB_VERBOSE)
|
||||
#define bootquiet (boothowto & AB_QUIET)
|
||||
|
||||
extern const char *get_booted_kernel(void);
|
||||
|
||||
extern void (*v_putc)(int); /* Virtual console putc routine */
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user