Modularize the opencrypto components and link to the build
This commit is contained in:
parent
06537b934f
commit
2dd4f4d91a
@ -1,4 +1,4 @@
|
||||
# $NetBSD: Makefile,v 1.133 2014/01/01 15:18:57 pgoyette Exp $
|
||||
# $NetBSD: Makefile,v 1.134 2014/01/01 16:06:00 pgoyette Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
@ -16,6 +16,7 @@ SUBDIR+= ccd
|
||||
SUBDIR+= cd9660
|
||||
SUBDIR+= cgd
|
||||
SUBDIR+= chfs
|
||||
SUBDIR+= crypto
|
||||
SUBDIR+= coda
|
||||
SUBDIR+= coda5
|
||||
SUBDIR+= compat
|
||||
@ -67,6 +68,7 @@ SUBDIR+= npf_ext_rndblock
|
||||
SUBDIR+= ntfs
|
||||
SUBDIR+= null
|
||||
SUBDIR+= onewire
|
||||
SUBDIR+= opencrypto
|
||||
SUBDIR+= overlay
|
||||
SUBDIR+= pciverbose
|
||||
SUBDIR+= pf
|
||||
@ -87,6 +89,7 @@ SUBDIR+= smbfs
|
||||
SUBDIR+= spdmem
|
||||
SUBDIR+= sysvbfs
|
||||
SUBDIR+= suser
|
||||
SUBDIR+= swcrypto
|
||||
SUBDIR+= swsensor
|
||||
SUBDIR+= tmpfs
|
||||
SUBDIR+= uatp
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: crypto.c,v 1.41 2011/06/09 14:41:24 drochner Exp $ */
|
||||
/* $NetBSD: crypto.c,v 1.42 2014/01/01 16:06:01 pgoyette Exp $ */
|
||||
/* $FreeBSD: src/sys/opencrypto/crypto.c,v 1.4.2.5 2003/02/26 00:14:05 sam Exp $ */
|
||||
/* $OpenBSD: crypto.c,v 1.41 2002/07/17 23:52:38 art Exp $ */
|
||||
|
||||
@ -53,7 +53,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.41 2011/06/09 14:41:24 drochner Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.42 2014/01/01 16:06:01 pgoyette Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/reboot.h>
|
||||
@ -65,8 +65,13 @@ __KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.41 2011/06/09 14:41:24 drochner Exp $")
|
||||
#include <sys/once.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/intr.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/module.h>
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_ocf.h"
|
||||
#endif
|
||||
|
||||
#include <opencrypto/cryptodev.h>
|
||||
#include <opencrypto/xform.h> /* XXX for M_XDATA */
|
||||
|
||||
@ -1329,3 +1334,21 @@ cryptoret(void)
|
||||
mutex_spin_enter(&crypto_ret_q_mtx);
|
||||
}
|
||||
}
|
||||
|
||||
/* NetBSD module interface */
|
||||
|
||||
MODULE(MODULE_CLASS_MISC, opencrypto, NULL);
|
||||
|
||||
static int
|
||||
opencrypto_modcmd(modcmd_t cmd, void *opaque)
|
||||
{
|
||||
|
||||
switch (cmd) {
|
||||
case MODULE_CMD_INIT:
|
||||
return 0;
|
||||
case MODULE_CMD_FINI:
|
||||
return 0;
|
||||
default:
|
||||
return ENOTTY;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cryptodev.c,v 1.69 2013/09/12 13:02:37 martin Exp $ */
|
||||
/* $NetBSD: cryptodev.c,v 1.70 2014/01/01 16:06:01 pgoyette Exp $ */
|
||||
/* $FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $ */
|
||||
/* $OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $ */
|
||||
|
||||
@ -64,7 +64,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.69 2013/09/12 13:02:37 martin Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.70 2014/01/01 16:06:01 pgoyette Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -85,9 +85,13 @@ __KERNEL_RCSID(0, "$NetBSD: cryptodev.c,v 1.69 2013/09/12 13:02:37 martin Exp $"
|
||||
#include <sys/poll.h>
|
||||
#include <sys/atomic.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/module.h>
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_ocf.h"
|
||||
#include "opt_compat_netbsd.h"
|
||||
#endif
|
||||
|
||||
#include <opencrypto/cryptodev.h>
|
||||
#include <opencrypto/cryptodev_internal.h>
|
||||
#include <opencrypto/xform.h>
|
||||
@ -2090,3 +2094,120 @@ cryptoattach(int num)
|
||||
pool_prime(&fcrpl, 64);
|
||||
pool_prime(&csepl, 64 * 5);
|
||||
}
|
||||
|
||||
void crypto_attach(device_t, device_t, void *);
|
||||
|
||||
void
|
||||
crypto_attach(device_t parent, device_t self, void * opaque)
|
||||
{
|
||||
|
||||
cryptoattach(0);
|
||||
}
|
||||
|
||||
int crypto_detach(device_t, int);
|
||||
|
||||
int
|
||||
crypto_detach(device_t self, int num)
|
||||
{
|
||||
pool_destroy(&fcrpl);
|
||||
pool_destroy(&csepl);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int crypto_match(device_t, cfdata_t, void *);
|
||||
|
||||
int
|
||||
crypto_match(device_t parent, cfdata_t data, void *opaque)
|
||||
{
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
MODULE(MODULE_CLASS_DRIVER, crypto, NULL);
|
||||
|
||||
CFDRIVER_DECL(crypto, DV_DULL, NULL);
|
||||
|
||||
CFATTACH_DECL2_NEW(crypto, 0, crypto_match, crypto_attach, crypto_detach,
|
||||
NULL, NULL, NULL);
|
||||
|
||||
static int cryptoloc[] = { -1, -1 };
|
||||
|
||||
static struct cfdata crypto_cfdata[] = {
|
||||
{
|
||||
.cf_name = "crypto",
|
||||
.cf_atname = "crypto",
|
||||
.cf_unit = 0,
|
||||
.cf_fstate = 0,
|
||||
.cf_loc = cryptoloc,
|
||||
.cf_flags = 0,
|
||||
.cf_pspec = NULL,
|
||||
},
|
||||
{ NULL, NULL, 0, 0, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
static int
|
||||
crypto_modcmd(modcmd_t cmd, void *arg)
|
||||
{
|
||||
devmajor_t cmajor = NODEVMAJOR, bmajor = NODEVMAJOR;
|
||||
int error;
|
||||
|
||||
switch (cmd) {
|
||||
case MODULE_CMD_INIT:
|
||||
error = config_cfdriver_attach(&crypto_cd);
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
error = config_cfattach_attach(crypto_cd.cd_name, &crypto_ca);
|
||||
if (error) {
|
||||
config_cfdriver_detach(&crypto_cd);
|
||||
aprint_error("%s: unable to register cfattach\n",
|
||||
crypto_cd.cd_name);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
error = config_cfdata_attach(crypto_cfdata, 1);
|
||||
if (error) {
|
||||
config_cfattach_detach(crypto_cd.cd_name, &crypto_ca);
|
||||
config_cfdriver_detach(&crypto_cd);
|
||||
aprint_error("%s: unable to register cfdata\n",
|
||||
crypto_cd.cd_name);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
error = devsw_attach(crypto_cd.cd_name, NULL, &bmajor,
|
||||
&crypto_cdevsw, &cmajor);
|
||||
if (error) {
|
||||
error = config_cfdata_detach(crypto_cfdata);
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
config_cfattach_detach(crypto_cd.cd_name, &crypto_ca);
|
||||
config_cfdriver_detach(&crypto_cd);
|
||||
aprint_error("%s: unable to register devsw\n",
|
||||
crypto_cd.cd_name);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
(void)config_attach_pseudo(crypto_cfdata);
|
||||
|
||||
return 0;
|
||||
case MODULE_CMD_FINI:
|
||||
error = config_cfdata_detach(crypto_cfdata);
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
config_cfattach_detach(crypto_cd.cd_name, &crypto_ca);
|
||||
config_cfdriver_detach(&crypto_cd);
|
||||
devsw_detach(NULL, &crypto_cdevsw);
|
||||
|
||||
return 0;
|
||||
default:
|
||||
return ENOTTY;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: cryptosoft.c,v 1.43 2013/09/12 13:12:35 martin Exp $ */
|
||||
/* $NetBSD: cryptosoft.c,v 1.44 2014/01/01 16:06:01 pgoyette Exp $ */
|
||||
/* $FreeBSD: src/sys/opencrypto/cryptosoft.c,v 1.2.2.1 2002/11/21 23:34:23 sam Exp $ */
|
||||
/* $OpenBSD: cryptosoft.c,v 1.35 2002/04/26 08:43:50 deraadt Exp $ */
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: cryptosoft.c,v 1.43 2013/09/12 13:12:35 martin Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: cryptosoft.c,v 1.44 2014/01/01 16:06:01 pgoyette Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -33,8 +33,13 @@ __KERNEL_RCSID(0, "$NetBSD: cryptosoft.c,v 1.43 2013/09/12 13:12:35 martin Exp $
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/cprng.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/device.h>
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_ocf.h"
|
||||
#endif
|
||||
|
||||
#include <opencrypto/cryptodev.h>
|
||||
#include <opencrypto/cryptosoft.h>
|
||||
#include <opencrypto/xform.h>
|
||||
@ -1320,3 +1325,105 @@ swcryptoattach(int num)
|
||||
|
||||
swcr_init();
|
||||
}
|
||||
|
||||
void swcrypto_attach(device_t, device_t, void *);
|
||||
|
||||
void
|
||||
swcrypto_attach(device_t parent, device_t self, void *opaque)
|
||||
{
|
||||
|
||||
swcr_init();
|
||||
}
|
||||
|
||||
int swcrypto_detach(device_t, int);
|
||||
|
||||
int
|
||||
swcrypto_detach(device_t self, int flag)
|
||||
{
|
||||
if (swcr_id >= 0)
|
||||
crypto_unregister_all(swcr_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int swcrypto_match(device_t, cfdata_t, void *);
|
||||
|
||||
int
|
||||
swcrypto_match(device_t parent, cfdata_t data, void *opaque)
|
||||
{
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
MODULE(MODULE_CLASS_DRIVER, swcrypto,
|
||||
"opencrypto,zlib,blowfish,des,cast128,camellia,skipjack");
|
||||
|
||||
CFDRIVER_DECL(swcrypto, DV_DULL, NULL);
|
||||
|
||||
CFATTACH_DECL2_NEW(swcrypto, 0, swcrypto_match, swcrypto_attach,
|
||||
swcrypto_detach, NULL, NULL, NULL);
|
||||
|
||||
static int swcryptoloc[] = { -1, -1 };
|
||||
|
||||
static struct cfdata swcrypto_cfdata[] = {
|
||||
{
|
||||
.cf_name = "swcrypto",
|
||||
.cf_atname = "swcrypto",
|
||||
.cf_unit = 0,
|
||||
.cf_fstate = 0,
|
||||
.cf_loc = swcryptoloc,
|
||||
.cf_flags = 0,
|
||||
.cf_pspec = NULL,
|
||||
},
|
||||
{ NULL, NULL, 0, 0, NULL, 0, NULL }
|
||||
};
|
||||
|
||||
static int
|
||||
swcrypto_modcmd(modcmd_t cmd, void *arg)
|
||||
{
|
||||
int error;
|
||||
|
||||
switch (cmd) {
|
||||
case MODULE_CMD_INIT:
|
||||
error = config_cfdriver_attach(&swcrypto_cd);
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
error = config_cfattach_attach(swcrypto_cd.cd_name,
|
||||
&swcrypto_ca);
|
||||
if (error) {
|
||||
config_cfdriver_detach(&swcrypto_cd);
|
||||
aprint_error("%s: unable to register cfattach\n",
|
||||
swcrypto_cd.cd_name);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
error = config_cfdata_attach(swcrypto_cfdata, 1);
|
||||
if (error) {
|
||||
config_cfattach_detach(swcrypto_cd.cd_name,
|
||||
&swcrypto_ca);
|
||||
config_cfdriver_detach(&swcrypto_cd);
|
||||
aprint_error("%s: unable to register cfdata\n",
|
||||
swcrypto_cd.cd_name);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
(void)config_attach_pseudo(swcrypto_cfdata);
|
||||
|
||||
return 0;
|
||||
case MODULE_CMD_FINI:
|
||||
error = config_cfdata_detach(swcrypto_cfdata);
|
||||
if (error) {
|
||||
return error;
|
||||
}
|
||||
|
||||
config_cfattach_detach(swcrypto_cd.cd_name, &swcrypto_ca);
|
||||
config_cfdriver_detach(&swcrypto_cd);
|
||||
|
||||
return 0;
|
||||
default:
|
||||
return ENOTTY;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: ocryptodev.c,v 1.4 2011/05/16 10:27:49 drochner Exp $ */
|
||||
/* $NetBSD: ocryptodev.c,v 1.5 2014/01/01 16:06:01 pgoyette Exp $ */
|
||||
/* $FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $ */
|
||||
/* $OpenBSD: cryptodev.c,v 1.53 2002/07/10 22:21:30 mickey Exp $ */
|
||||
|
||||
@ -69,7 +69,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: ocryptodev.c,v 1.4 2011/05/16 10:27:49 drochner Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: ocryptodev.c,v 1.5 2014/01/01 16:06:01 pgoyette Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
@ -90,7 +90,10 @@ __KERNEL_RCSID(0, "$NetBSD: ocryptodev.c,v 1.4 2011/05/16 10:27:49 drochner Exp
|
||||
#include <sys/poll.h>
|
||||
#include <sys/atomic.h>
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_ocf.h"
|
||||
#endif
|
||||
|
||||
#include <opencrypto/cryptodev.h>
|
||||
#include <opencrypto/cryptodev_internal.h>
|
||||
#include <opencrypto/ocryptodev.h>
|
||||
|
Loading…
Reference in New Issue
Block a user