- Add a bsd.kmodule.mk to build new style modules.
- Set the file suffix to .kmod
This commit is contained in:
parent
2830fe3488
commit
3ba209837a
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: mi,v 1.1136 2008/05/01 15:41:16 jmmv Exp $
|
||||
# $NetBSD: mi,v 1.1137 2008/05/02 14:20:50 ad Exp $
|
||||
#
|
||||
# Note: don't delete entries from here - mark them as "obsolete" instead.
|
||||
#
|
||||
|
@ -13500,6 +13500,7 @@
|
|||
./usr/share/mk/bsd.kinc.mk comp-util-share share
|
||||
./usr/share/mk/bsd.klinks.mk comp-util-share share
|
||||
./usr/share/mk/bsd.kmod.mk comp-util-share share
|
||||
./usr/share/mk/bsd.kmodule.mk comp-util-share share
|
||||
./usr/share/mk/bsd.lib.mk comp-util-share share
|
||||
./usr/share/mk/bsd.links.mk comp-util-share share
|
||||
./usr/share/mk/bsd.man.mk comp-util-share share
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: mi,v 1.21 2008/05/01 15:41:16 jmmv Exp $
|
||||
# $NetBSD: mi,v 1.22 2008/05/02 14:20:50 ad Exp $
|
||||
#
|
||||
# Note: don't delete entries from here - mark them as "obsolete" instead.
|
||||
#
|
||||
|
@ -388,7 +388,8 @@
|
|||
./usr/tests/games/t_factor tests-games-tests
|
||||
./usr/tests/modules tests-sys-tests
|
||||
./usr/tests/modules/Atffile tests-sys-tests
|
||||
./usr/tests/modules/k_helper.o tests-sys-tests modular
|
||||
./usr/tests/modules/k_helper.kmod tests-sys-tests modular
|
||||
./usr/tests/modules/k_helper.o tests-obsolete obsolete
|
||||
./usr/tests/modules/t_modctl tests-sys-tests modular
|
||||
./usr/tests/modules/t_modload tests-sys-tests modular
|
||||
./usr/tests/net tests-net-tests
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: Makefile,v 1.40 2007/11/12 15:05:16 jmmv Exp $
|
||||
# $NetBSD: Makefile,v 1.41 2008/05/02 14:20:50 ad Exp $
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/8/93
|
||||
|
||||
NOOBJ= # defined
|
||||
|
@ -9,6 +9,7 @@ NOOBJ= # defined
|
|||
FILES= bsd.README bsd.doc.mk bsd.dep.mk bsd.endian.mk bsd.files.mk \
|
||||
bsd.gcc.mk bsd.hostlib.mk bsd.hostprog.mk bsd.inc.mk bsd.info.mk \
|
||||
bsd.init.mk bsd.kernobj.mk bsd.kinc.mk bsd.klinks.mk bsd.kmod.mk \
|
||||
bsd.kmodule.mk \
|
||||
bsd.lib.mk bsd.links.mk bsd.man.mk bsd.nls.mk bsd.obj.mk bsd.own.mk \
|
||||
bsd.prog.mk bsd.rpc.mk bsd.shlib.mk bsd.subdir.mk bsd.sys.mk \
|
||||
bsd.test.mk bsd.x11.mk sys.mk
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
# $NetBSD: bsd.kmodule.mk,v 1.1 2008/05/02 14:20:50 ad Exp $
|
||||
|
||||
.include <bsd.init.mk>
|
||||
.include <bsd.klinks.mk>
|
||||
|
||||
##### Basic targets
|
||||
clean: cleankmod
|
||||
realinstall: kmodinstall
|
||||
|
||||
KERN= $S/kern
|
||||
|
||||
CFLAGS+= -ffreestanding -fno-zero-initialized-in-bss ${COPTS}
|
||||
CPPFLAGS+= -nostdinc -I. -I${.CURDIR} -isystem $S -isystem $S/arch
|
||||
CPPFLAGS+= -isystem ${S}/../common/include
|
||||
CPPFLAGS+= -D_KERNEL -D_LKM -D_MODULE
|
||||
|
||||
# XXX until the kernel is fixed again...
|
||||
.if ${HAVE_GCC} == 4
|
||||
CFLAGS+= -fno-strict-aliasing -Wno-pointer-sign
|
||||
.endif
|
||||
|
||||
_YKMSRCS= ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}}
|
||||
DPSRCS+= ${_YKMSRCS}
|
||||
CLEANFILES+= ${_YKMSRCS}
|
||||
CLEANFILES+= tmp.o
|
||||
|
||||
.if \
|
||||
${MACHINE_CPU} == "arm" || \
|
||||
${MACHINE_CPU} == "hppa" || \
|
||||
${MACHINE_CPU} == "powerpc"
|
||||
CLEANFILES+= ${KMOD}_tramp.o ${KMOD}_tramp.S tmp.S ${KMOD}_tmp.o
|
||||
.endif
|
||||
|
||||
OBJS+= ${SRCS:N*.h:N*.sh:R:S/$/.o/g}
|
||||
PROG?= ${KMOD}.kmod
|
||||
|
||||
##### Build rules
|
||||
realall: ${PROG}
|
||||
|
||||
${OBJS} ${LOBJS}: ${DPSRCS}
|
||||
|
||||
.if \
|
||||
${MACHINE_CPU} == "arm" || \
|
||||
${MACHINE_CPU} == "hppa" || \
|
||||
${MACHINE_CPU} == "powerpc"
|
||||
${KMOD}_tmp.o: ${OBJS} ${DPADD}
|
||||
${_MKTARGET_COMPILE}
|
||||
${LD} -r -o tmp.o ${OBJS}
|
||||
mv tmp.o ${.TARGET}
|
||||
|
||||
${KMOD}_tramp.S: ${KMOD}_tmp.o $S/lkm/arch/${MACHINE_CPU}/lkmtramp.awk
|
||||
${_MKTARGET_CREATE}
|
||||
${OBJDUMP} --syms --reloc ${KMOD}_tmp.o | \
|
||||
awk -f $S/lkm/arch/${MACHINE_CPU}/lkmtramp.awk > tmp.S
|
||||
mv tmp.S ${.TARGET}
|
||||
|
||||
${PROG}: ${KMOD}_tmp.o ${KMOD}_tramp.o
|
||||
${_MKTARGET_LINK}
|
||||
${LD} -r \
|
||||
`${OBJDUMP} --syms --reloc ${KMOD}_tmp.o | \
|
||||
awk -f $S/lkm/arch/${MACHINE_CPU}/lkmwrap.awk` \
|
||||
-o tmp.o ${KMOD}_tmp.o ${KMOD}_tramp.o
|
||||
.if exists($S/lkm/arch/${MACHINE_CPU}/lkmhide.awk)
|
||||
${OBJCOPY} \
|
||||
`${NM} tmp.o | awk -f $S/lkm/arch/${MACHINE_CPU}/lkmhide.awk` \
|
||||
tmp.o tmp1.o
|
||||
mv tmp1.o tmp.o
|
||||
.endif
|
||||
mv tmp.o ${.TARGET}
|
||||
.else
|
||||
${PROG}: ${OBJS} ${DPADD}
|
||||
${_MKTARGET_LINK}
|
||||
${LD} -r -o tmp.o ${OBJS}
|
||||
mv tmp.o ${.TARGET}
|
||||
.endif
|
||||
|
||||
##### Install rules
|
||||
.if !target(kmodinstall)
|
||||
_PROG:= ${DESTDIR}${KMODDIR}/${PROG} # installed path
|
||||
|
||||
.if ${MKUPDATE} == "no"
|
||||
${_PROG}! ${PROG} # install rule
|
||||
.if !defined(BUILD) && !make(all) && !make(${PROG})
|
||||
${_PROG}! .MADE # no build at install
|
||||
.endif
|
||||
.else
|
||||
${_PROG}: ${PROG} # install rule
|
||||
.if !defined(BUILD) && !make(all) && !make(${PROG})
|
||||
${_PROG}: .MADE # no build at install
|
||||
.endif
|
||||
.endif
|
||||
${_MKTARGET_INSTALL}
|
||||
${INSTALL_FILE} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
|
||||
${.ALLSRC} ${.TARGET}
|
||||
|
||||
kmodinstall:: ${_PROG}
|
||||
.PHONY: kmodinstall
|
||||
.PRECIOUS: ${_PROG} # keep if install fails
|
||||
|
||||
.undef _PROG
|
||||
.endif # !target(kmodinstall)
|
||||
|
||||
##### Clean rules
|
||||
cleankmod: .PHONY
|
||||
rm -f a.out [Ee]rrs mklog core *.core \
|
||||
${PROG} ${OBJS} ${LOBJS} ${CLEANFILES}
|
||||
|
||||
##### Custom rules
|
||||
lint: ${LOBJS}
|
||||
.if defined(LOBJS) && !empty(LOBJS)
|
||||
${LINT} ${LINTFLAGS} ${LDFLAGS:C/-L[ ]*/-L/Wg:M-L*} ${LOBJS} ${LDADD}
|
||||
.endif
|
||||
|
||||
.if !target(load)
|
||||
load: ${PROG}
|
||||
/sbin/modload ${KMOD_LOADFLAGS} -o ${KMOD} ${PROG}
|
||||
.endif
|
||||
.PHONY: load
|
||||
|
||||
.if !target(unload)
|
||||
unload:
|
||||
/sbin/modunload -n ${KMOD}
|
||||
.endif
|
||||
.PHONY: unload
|
||||
|
||||
##### Pull in related .mk logic
|
||||
.include <bsd.man.mk>
|
||||
.include <bsd.links.mk>
|
||||
.include <bsd.sys.mk>
|
||||
.include <bsd.dep.mk>
|
||||
|
||||
.-include "$S/arch/${MACHINE_CPU}/include/Makefile.inc"
|
||||
.-include "$S/arch/${MACHINE}/include/Makefile.inc"
|
|
@ -1,12 +1,6 @@
|
|||
# $NetBSD: Makefile,v 1.2 2008/02/10 10:51:18 jmmv Exp $
|
||||
# $NetBSD: Makefile,v 1.3 2008/05/02 14:20:50 ad Exp $
|
||||
|
||||
KMOD= example
|
||||
SRCS= example.c
|
||||
|
||||
SRCS= real-example.c
|
||||
# XXX A hack to workaround the fact that the final module is named
|
||||
# example.o. To be removed once we change the extension of modules.
|
||||
BUILDSYMLINKS= ${.CURDIR}/example.c real-example.c
|
||||
|
||||
NOMAN= # defined
|
||||
|
||||
.include <bsd.kmod.mk>
|
||||
.include <bsd.kmodule.mk>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# $NetBSD: Makefile,v 1.1 2008/05/02 13:03:58 ad Exp $
|
||||
# $NetBSD: Makefile,v 1.2 2008/05/02 14:20:50 ad Exp $
|
||||
|
||||
KMOD= miniroot
|
||||
SRCS= miniroot.c
|
||||
|
||||
.include <bsd.kmod.mk>
|
||||
.include <bsd.kmodule.mk>
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
# $NetBSD: Makefile,v 1.1 2008/02/10 12:40:10 jmmv Exp $
|
||||
# $NetBSD: Makefile,v 1.2 2008/05/02 14:20:50 ad Exp $
|
||||
|
||||
KMOD= k_helper
|
||||
KMODDIR= ${TESTSBASE}/modules
|
||||
|
||||
SRCS= real-k_helper.c
|
||||
# XXX A hack to workaround the fact that the final module is named
|
||||
# k_helper.o. To be removed once we change the extension of modules.
|
||||
BUILDSYMLINKS= ${.CURDIR}/k_helper.c real-k_helper.c
|
||||
SRCS= k_helper.c
|
||||
|
||||
NOATFFILE= # defined
|
||||
NOMAN= # defined
|
||||
|
||||
.include <bsd.test.mk>
|
||||
.include <bsd.kmod.mk>
|
||||
.include <bsd.kmodule.mk>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: t_modctl.c,v 1.1 2008/05/01 15:38:17 jmmv Exp $ */
|
||||
/* $NetBSD: t_modctl.c,v 1.2 2008/05/02 14:20:50 ad Exp $ */
|
||||
/*
|
||||
* Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
|
@ -27,7 +27,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: t_modctl.c,v 1.1 2008/05/01 15:38:17 jmmv Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: t_modctl.c,v 1.2 2008/05/02 14:20:50 ad Exp $");
|
||||
|
||||
#include <sys/module.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
@ -316,7 +316,7 @@ ATF_TC_BODY(cmd_load, tc)
|
|||
ATF_CHECK(load(NULL, false, longname) == ENAMETOOLONG);
|
||||
|
||||
ATF_CHECK(!k_helper_is_present(stat_check));
|
||||
load(NULL, true, "%s/k_helper.o", atf_tc_get_config_var(tc, "srcdir"));
|
||||
load(NULL, true, "%s/k_helper.kmod", atf_tc_get_config_var(tc, "srcdir"));
|
||||
printf("Checking if load was successful\n");
|
||||
ATF_CHECK(k_helper_is_present(stat_check));
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ ATF_TC_BODY(cmd_load_props, tc)
|
|||
|
||||
printf("Loading module without properties\n");
|
||||
props = prop_dictionary_create();
|
||||
load(props, true, "%s/k_helper.o", atf_tc_get_config_var(tc, "srcdir"));
|
||||
load(props, true, "%s/k_helper.kmod", atf_tc_get_config_var(tc, "srcdir"));
|
||||
prop_object_release(props);
|
||||
{
|
||||
int ok;
|
||||
|
@ -354,7 +354,7 @@ ATF_TC_BODY(cmd_load_props, tc)
|
|||
props = prop_dictionary_create();
|
||||
prop_dictionary_set(props, "prop_str",
|
||||
prop_string_create_cstring("1st string"));
|
||||
load(props, true, "%s/k_helper.o", atf_tc_get_config_var(tc, "srcdir"));
|
||||
load(props, true, "%s/k_helper.kmod", atf_tc_get_config_var(tc, "srcdir"));
|
||||
prop_object_release(props);
|
||||
{
|
||||
int ok;
|
||||
|
@ -373,7 +373,7 @@ ATF_TC_BODY(cmd_load_props, tc)
|
|||
props = prop_dictionary_create();
|
||||
prop_dictionary_set(props, "prop_str",
|
||||
prop_string_create_cstring("2nd string"));
|
||||
load(props, true, "%s/k_helper.o", atf_tc_get_config_var(tc, "srcdir"));
|
||||
load(props, true, "%s/k_helper.kmod", atf_tc_get_config_var(tc, "srcdir"));
|
||||
prop_object_release(props);
|
||||
{
|
||||
int ok;
|
||||
|
@ -405,7 +405,7 @@ ATF_TC_BODY(cmd_stat, tc)
|
|||
|
||||
ATF_CHECK(!k_helper_is_present(both_checks));
|
||||
|
||||
load(NULL, true, "%s/k_helper.o", atf_tc_get_config_var(tc, "srcdir"));
|
||||
load(NULL, true, "%s/k_helper.kmod", atf_tc_get_config_var(tc, "srcdir"));
|
||||
ATF_CHECK(k_helper_is_present(both_checks));
|
||||
{
|
||||
modstat_t ms;
|
||||
|
@ -434,11 +434,11 @@ ATF_TC_BODY(cmd_unload, tc)
|
|||
{
|
||||
require_modular();
|
||||
|
||||
load(NULL, true, "%s/k_helper.o", atf_tc_get_config_var(tc, "srcdir"));
|
||||
load(NULL, true, "%s/k_helper.kmod", atf_tc_get_config_var(tc, "srcdir"));
|
||||
|
||||
ATF_CHECK(unload("", false) == ENOENT);
|
||||
ATF_CHECK(unload("non-existent.o", false) == ENOENT);
|
||||
ATF_CHECK(unload("k_helper.o", false) == ENOENT);
|
||||
ATF_CHECK(unload("non-existent.kmod", false) == ENOENT);
|
||||
ATF_CHECK(unload("k_helper.kmod", false) == ENOENT);
|
||||
|
||||
ATF_CHECK(k_helper_is_present(stat_check));
|
||||
unload("k_helper", true);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $NetBSD: t_modload.sh,v 1.2 2008/04/30 13:11:00 martin Exp $
|
||||
# $NetBSD: t_modload.sh,v 1.3 2008/05/02 14:20:50 ad Exp $
|
||||
#
|
||||
# Copyright (c) 2008 The NetBSD Foundation, Inc.
|
||||
# All rights reserved.
|
||||
|
@ -41,7 +41,7 @@ modload: No such file or directory
|
|||
EOF
|
||||
atf_check "modload non-existent.o" 1 null experr
|
||||
|
||||
atf_check "modload $(atf_get_srcdir)/k_helper.o" 0 null null
|
||||
atf_check "modload $(atf_get_srcdir)/k_helper.kmod" 0 null null
|
||||
check_sysctl vendor.k_helper.present 1
|
||||
check_sysctl vendor.k_helper.prop_int_ok 0
|
||||
check_sysctl vendor.k_helper.prop_str_ok 0
|
||||
|
@ -59,19 +59,19 @@ bflag_head() {
|
|||
bflag_body() {
|
||||
echo "Checking error conditions"
|
||||
|
||||
atf_check "modload -b foo k_helper.o" 1 null stderr
|
||||
atf_check "modload -b foo k_helper.kmod" 1 null stderr
|
||||
atf_check "grep 'Invalid parameter.*foo' stderr" 0 ignore null
|
||||
|
||||
atf_check "modload -b foo= k_helper.o" 1 null stderr
|
||||
atf_check "modload -b foo= k_helper.kmod" 1 null stderr
|
||||
atf_check "grep 'Invalid boolean value' stderr" 0 ignore null
|
||||
|
||||
atf_check "modload -b foo=bar k_helper.o" 1 null stderr
|
||||
atf_check "modload -b foo=bar k_helper.kmod" 1 null stderr
|
||||
atf_check "grep 'Invalid boolean value.*bar' stderr" 0 ignore null
|
||||
|
||||
atf_check "modload -b foo=falsea k_helper.o" 1 null stderr
|
||||
atf_check "modload -b foo=falsea k_helper.kmod" 1 null stderr
|
||||
atf_check "grep 'Invalid boolean value.*falsea' stderr" 0 ignore null
|
||||
|
||||
atf_check "modload -b foo=truea k_helper.o" 1 null stderr
|
||||
atf_check "modload -b foo=truea k_helper.kmod" 1 null stderr
|
||||
atf_check "grep 'Invalid boolean value.*truea' stderr" 0 ignore null
|
||||
|
||||
# TODO Once sysctl(8) supports CTLTYPE_BOOL nodes.
|
||||
|
@ -89,23 +89,23 @@ iflag_head() {
|
|||
iflag_body() {
|
||||
echo "Checking error conditions"
|
||||
|
||||
atf_check "modload -i foo k_helper.o" 1 null stderr
|
||||
atf_check "modload -i foo k_helper.kmod" 1 null stderr
|
||||
atf_check "grep 'Invalid parameter.*foo' stderr" 0 ignore null
|
||||
|
||||
atf_check "modload -i foo= k_helper.o" 1 null stderr
|
||||
atf_check "modload -i foo= k_helper.kmod" 1 null stderr
|
||||
atf_check "grep 'Invalid integer value' stderr" 0 ignore null
|
||||
|
||||
atf_check "modload -i foo=bar k_helper.o" 1 null stderr
|
||||
atf_check "modload -i foo=bar k_helper.kmod" 1 null stderr
|
||||
atf_check "grep 'Invalid integer value.*bar' stderr" 0 ignore null
|
||||
|
||||
atf_check "modload -i foo=123a k_helper.o" 1 null stderr
|
||||
atf_check "modload -i foo=123a k_helper.kmod" 1 null stderr
|
||||
atf_check "grep 'Invalid integer value.*123a' stderr" 0 ignore null
|
||||
|
||||
echo "Checking valid values"
|
||||
|
||||
for v in 5 10; do
|
||||
atf_check "modload -i prop_int='${v}' \
|
||||
$(atf_get_srcdir)/k_helper.o" 0 null null
|
||||
$(atf_get_srcdir)/k_helper.kmod" 0 null null
|
||||
check_sysctl vendor.k_helper.prop_int_ok 1
|
||||
check_sysctl vendor.k_helper.prop_int_val "${v}"
|
||||
atf_check "modunload k_helper" 0 null null
|
||||
|
@ -123,14 +123,14 @@ sflag_head() {
|
|||
sflag_body() {
|
||||
echo "Checking error conditions"
|
||||
|
||||
atf_check "modload -s foo k_helper.o" 1 null stderr
|
||||
atf_check "modload -s foo k_helper.kmod" 1 null stderr
|
||||
atf_check "grep 'Invalid parameter.*foo' stderr" 0 ignore null
|
||||
|
||||
echo "Checking valid values"
|
||||
|
||||
for v in '1st string' '2nd string'; do
|
||||
atf_check "modload -s prop_str='${v}' \
|
||||
$(atf_get_srcdir)/k_helper.o" 0 null null
|
||||
$(atf_get_srcdir)/k_helper.kmod" 0 null null
|
||||
check_sysctl vendor.k_helper.prop_str_ok 1
|
||||
check_sysctl vendor.k_helper.prop_str_val "${v}"
|
||||
atf_check "modunload k_helper" 0 null null
|
||||
|
|
Loading…
Reference in New Issue