Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Modularize the opencrypto components and link to the build
details: https://anonhg.NetBSD.org/src/rev/2abeebd81bf8
branches: trunk
changeset: 325625:2abeebd81bf8
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Wed Jan 01 16:06:00 2014 +0000
description:
Modularize the opencrypto components and link to the build
diffstat:
sys/modules/Makefile | 5 +-
sys/opencrypto/crypto.c | 27 ++++++++-
sys/opencrypto/cryptodev.c | 125 +++++++++++++++++++++++++++++++++++++++++++-
sys/opencrypto/cryptosoft.c | 111 ++++++++++++++++++++++++++++++++++++++-
sys/opencrypto/ocryptodev.c | 7 +-
5 files changed, 266 insertions(+), 9 deletions(-)
diffs (truncated from 407 to 300 lines):
diff -r fd906665bfdc -r 2abeebd81bf8 sys/modules/Makefile
--- a/sys/modules/Makefile Wed Jan 01 15:22:33 2014 +0000
+++ b/sys/modules/Makefile Wed Jan 01 16:06:00 2014 +0000
@@ -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+= cd9660
SUBDIR+= cgd
SUBDIR+= chfs
+SUBDIR+= crypto
SUBDIR+= coda
SUBDIR+= coda5
SUBDIR+= compat
@@ -67,6 +68,7 @@
SUBDIR+= ntfs
SUBDIR+= null
SUBDIR+= onewire
+SUBDIR+= opencrypto
SUBDIR+= overlay
SUBDIR+= pciverbose
SUBDIR+= pf
@@ -87,6 +89,7 @@
SUBDIR+= spdmem
SUBDIR+= sysvbfs
SUBDIR+= suser
+SUBDIR+= swcrypto
SUBDIR+= swsensor
SUBDIR+= tmpfs
SUBDIR+= uatp
diff -r fd906665bfdc -r 2abeebd81bf8 sys/opencrypto/crypto.c
--- a/sys/opencrypto/crypto.c Wed Jan 01 15:22:33 2014 +0000
+++ b/sys/opencrypto/crypto.c Wed Jan 01 16:06:00 2014 +0000
@@ -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 @@
#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 @@
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;
+ }
+}
diff -r fd906665bfdc -r 2abeebd81bf8 sys/opencrypto/cryptodev.c
--- a/sys/opencrypto/cryptodev.c Wed Jan 01 15:22:33 2014 +0000
+++ b/sys/opencrypto/cryptodev.c Wed Jan 01 16:06:00 2014 +0000
@@ -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 @@
#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 @@
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;
+ }
+}
diff -r fd906665bfdc -r 2abeebd81bf8 sys/opencrypto/cryptosoft.c
--- a/sys/opencrypto/cryptosoft.c Wed Jan 01 15:22:33 2014 +0000
+++ b/sys/opencrypto/cryptosoft.c Wed Jan 01 16:06:00 2014 +0000
@@ -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 @@
#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 @@
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)
Home |
Main Index |
Thread Index |
Old Index