Module-ize the 'core' crypto stuff. This may still need to be compiled

into the kernel by default (if required), but other modules can now
depend() on this.

Fix inter-module dependancy.

Earlier version OK'ed by:	sam
This commit is contained in:
markm 2002-10-16 14:31:34 +00:00
parent 98e716a4fe
commit 658a7ab8f2
6 changed files with 59 additions and 4 deletions

View File

@ -108,6 +108,7 @@ static driver_t hifn_driver = {
static devclass_t hifn_devclass;
DRIVER_MODULE(hifn, pci, hifn_driver, hifn_devclass, 0, 0);
MODULE_DEPEND(hifn, crypto, 1, 1, 1);
static void hifn_reset_board(struct hifn_softc *, int);
static void hifn_reset_puc(struct hifn_softc *);

View File

@ -124,6 +124,7 @@ static driver_t ubsec_driver = {
static devclass_t ubsec_devclass;
DRIVER_MODULE(ubsec, pci, ubsec_driver, ubsec_devclass, 0, 0);
MODULE_DEPEND(ubsec, crypto, 1, 1, 1);
static void ubsec_intr(void *);
static int ubsec_newsession(void *, u_int32_t *, struct cryptoini *);

View File

@ -1,5 +1,9 @@
# $FreeBSD$
.if exists(${.CURDIR}/../opencrypto) && !defined(NOCRYPT)
_crypto= crypto
_cryptodev= cryptodev
.endif
.if exists(${.CURDIR}/../crypto) && !defined(NOCRYPT)
_random= random
.endif
@ -19,7 +23,8 @@ SUBDIR= 3dfx \
ccd \
cd9660 \
coda \
cryptodev \
${_crypto} \
${_cryptodev} \
cue \
dc \
de \

View File

@ -0,0 +1,20 @@
# $FreeBSD$
.PATH: ${.CURDIR}/../../opencrypto
.PATH: ${.CURDIR}/../../crypto
.PATH: ${.CURDIR}/../../crypto/blowfish
.PATH: ${.CURDIR}/../../crypto/des
.PATH: ${.CURDIR}/../../crypto/sha2
.PATH: ${.CURDIR}/../../net
KMOD = crypto
SRCS = crypto.c
SRCS += criov.c crmbuf.c cryptosoft.c xform.c
SRCS += cast.c deflate.c rmd160.c rijndael.c skipjack.c
SRCS += bf_enc.c bf_skey.c
SRCS += des_ecb.c des_enc.c des_setkey.c
SRCS += sha1.c sha2.c
SRCS += zlib.c
SRCS += opt_param.h
.include <bsd.kmod.mk>

View File

@ -123,7 +123,34 @@ crypto_init(void)
TAILQ_INIT(&crp_ret_kq);
mtx_init(&crypto_ret_q_mtx, "crypto return queues", NULL, MTX_DEF);
}
SYSINIT(crypto_init, SI_SUB_DRIVERS, SI_ORDER_FIRST, crypto_init, NULL)
/*
* Initialization code, both for static and dynamic loading.
*/
static int
crypto_modevent(module_t mod, int type, void *unused)
{
switch (type) {
case MOD_LOAD:
crypto_init();
if (bootverbose)
printf("crypto: <crypto core>\n");
return 0;
case MOD_UNLOAD:
/*XXX disallow if active sessions */
/*XXX kill kthreads */
return 0;
}
return EINVAL;
}
static moduledata_t crypto_mod = {
"crypto",
crypto_modevent,
0
};
MODULE_VERSION(crypto, 1);
DECLARE_MODULE(crypto, crypto_mod, SI_SUB_PSEUDO, SI_ORDER_SECOND);
/*
* Create a new session.
@ -910,7 +937,7 @@ static struct kproc_desc crypto_kp = {
crypto_proc,
&cryptoproc
};
SYSINIT(crypto_proc, SI_SUB_KTHREAD_IDLE, SI_ORDER_ANY,
SYSINIT(crypto_proc, SI_SUB_KTHREAD_IDLE, SI_ORDER_THIRD,
kproc_start, &crypto_kp)
static struct proc *cryptoretproc;
@ -972,5 +999,5 @@ static struct kproc_desc crypto_ret_kp = {
crypto_ret_proc,
&cryptoretproc
};
SYSINIT(crypto_ret_proc, SI_SUB_KTHREAD_IDLE, SI_ORDER_ANY,
SYSINIT(crypto_ret_proc, SI_SUB_KTHREAD_IDLE, SI_ORDER_THIRD,
kproc_start, &crypto_ret_kp)

View File

@ -794,3 +794,4 @@ static moduledata_t cryptodev_mod = {
};
MODULE_VERSION(cryptodev, 1);
DECLARE_MODULE(cryptodev, cryptodev_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
MODULE_DEPEND(cryptodev, crypto, 1, 1, 1);