Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Move the initialization of the crypto framework from the...



details:   https://anonhg.NetBSD.org/src/rev/fe59edf45e28
branches:  trunk
changeset: 550126:fe59edf45e28
user:      jonathan <jonathan%NetBSD.org@localhost>
date:      Wed Jul 30 18:45:31 2003 +0000

description:
Move the initialization of the crypto framework from the userland
pseudo-device to init_main(), so the framework is ready for
registration requests at autoconfiguration time.

Thanks to Quentin Garnier for confirming the change was required, and
for testing a similar fix.

diffstat:

 sys/kern/init_main.c       |  13 ++++++++++---
 sys/opencrypto/crypto.c    |  11 +++++------
 sys/opencrypto/cryptodev.h |  12 +++++++++++-
 3 files changed, 26 insertions(+), 10 deletions(-)

diffs (127 lines):

diff -r f44ea4c7c35c -r fe59edf45e28 sys/kern/init_main.c
--- a/sys/kern/init_main.c      Wed Jul 30 18:28:58 2003 +0000
+++ b/sys/kern/init_main.c      Wed Jul 30 18:45:31 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: init_main.c,v 1.221 2003/06/29 22:31:17 fvdl Exp $     */
+/*     $NetBSD: init_main.c,v 1.222 2003/07/30 18:45:32 jonathan Exp $ */
 
 /*
  * Copyright (c) 1995 Christopher G. Demetriou.  All rights reserved.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.221 2003/06/29 22:31:17 fvdl Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_main.c,v 1.222 2003/07/30 18:45:32 jonathan Exp $");
 
 #include "fs_nfs.h"
 #include "opt_nfsserver.h"
@@ -54,6 +54,7 @@
 #include "opt_systrace.h"
 #include "opt_posix.h"
 
+#include "opencrypto.h"
 #include "rnd.h"
 
 #include <sys/param.h>
@@ -101,6 +102,9 @@
 #include <sys/domain.h>
 #include <sys/mbuf.h>
 #include <sys/namei.h>
+#if NOPENCRYPTO > 0
+#include <opencrypto/cryptodev.h>      /* XXX really  the framework */
+#endif
 #if NRND > 0
 #include <sys/rnd.h>
 #endif
@@ -243,7 +247,10 @@
 #if NRND > 0
        rnd_init();             /* initialize RNG */
 #endif
-
+#if NOPENCRYPTO > 0
+       /* Initialize crypto subsystem before configuring crypto hardware. */
+       (void)crypto_init();
+#endif
        /* Initialize the sysctl subsystem. */
        sysctl_init();
 
diff -r f44ea4c7c35c -r fe59edf45e28 sys/opencrypto/crypto.c
--- a/sys/opencrypto/crypto.c   Wed Jul 30 18:28:58 2003 +0000
+++ b/sys/opencrypto/crypto.c   Wed Jul 30 18:45:31 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: crypto.c,v 1.1 2003/07/25 21:12:43 jonathan Exp $ */
+/*     $NetBSD: crypto.c,v 1.2 2003/07/30 18:45:31 jonathan 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 $ */
 
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.1 2003/07/25 21:12:43 jonathan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: crypto.c,v 1.2 2003/07/30 18:45:31 jonathan Exp $");
 
 /* XXX FIXME: should be defopt'ed */
 #define CRYPTO_TIMING                  /* enable cryptop timing stuff */
@@ -35,6 +35,7 @@
 #include <sys/malloc.h>
 #include <sys/proc.h>
 #include <sys/pool.h>
+#include <opencrypto/crypto.h>
 #include <opencrypto/cryptodev.h>
 #include <opencrypto/cryptosoft.h>             /* swcr_init() */
 #include <sys/kthread.h>
@@ -90,7 +91,7 @@
 int crypto_pool_initialized = 0;
 
 #ifdef __NetBSD__
-void   cryptoattach(int); void opencryptoattach(int);
+void   opencryptoattach(int);
 static void deferred_crypto_thread(void *arg);
 #endif
 
@@ -154,7 +155,7 @@
            cryptostats, "Crypto system statistics");
 #endif __FreeBSD__
 
-static int
+int
 crypto_init(void)
 {
        int error;
@@ -1190,8 +1191,6 @@
 opencryptoattach(int n)
 {
        /* XXX in absence of FreeBSD mod_init(), call init hooks here */
-       printf("cryptoattach\n");
-       crypto_init();
        swcr_init();
 }
 
diff -r f44ea4c7c35c -r fe59edf45e28 sys/opencrypto/cryptodev.h
--- a/sys/opencrypto/cryptodev.h        Wed Jul 30 18:28:58 2003 +0000
+++ b/sys/opencrypto/cryptodev.h        Wed Jul 30 18:45:31 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cryptodev.h,v 1.2 2003/07/27 03:34:39 jonathan Exp $ */
+/*     $NetBSD: cryptodev.h,v 1.3 2003/07/30 18:45:31 jonathan Exp $ */
 /*     $FreeBSD: src/sys/opencrypto/cryptodev.h,v 1.2.2.4 2003/02/26 00:14:05 sam Exp $        */
 /*     $OpenBSD: cryptodev.h,v 1.33 2002/07/17 23:52:39 art Exp $      */
 
@@ -365,6 +365,16 @@
 extern int crypto_userasymcrypto;      /* userland may do asym crypto reqs */
 extern int crypto_devallowsoft;        /* only use hardware crypto */
 
+
+/*
+ * initialize the crypto framework subsystem (not the pseudo-device).
+ * This must be called very early in boot, so the framework is ready
+ * to handle registration requests when crpto hardware is autoconfigured.
+ * (This declaration doesnt really belong here but there's no header
+ * for the raw framework.)
+ */
+int    crypto_init(void);
+
 /*
  * Crypto-related utility routines used mainly by drivers.
  *



Home | Main Index | Thread Index | Old Index