Source-Changes-HG archive

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

[src/trunk]: src/sys/arch modularize VIA PadLock support



details:   https://anonhg.NetBSD.org/src/rev/ac79a8b4d172
branches:  trunk
changeset: 762330:ac79a8b4d172
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Feb 19 13:52:27 2011 +0000

description:
modularize VIA PadLock support
 - retire options VIA_PADLOCK, replace with 'padlock0 at cpu0'
 - driver supports attach & detach
 - support building as a module

diffstat:

 sys/arch/i386/conf/ALL             |    6 +-
 sys/arch/i386/conf/GENERIC         |    6 +-
 sys/arch/i386/i386/autoconf.c      |   10 +-
 sys/arch/x86/conf/files.x86        |   13 +-
 sys/arch/x86/include/cpu.h         |    4 +-
 sys/arch/x86/include/cpuvar.h      |    7 +-
 sys/arch/x86/include/via_padlock.h |    8 +-
 sys/arch/x86/x86/cpu.c             |   44 +++++++-
 sys/arch/x86/x86/identcpu.c        |    6 +-
 sys/arch/x86/x86/via_padlock.c     |  209 ++++++++++++++++++++++++++----------
 10 files changed, 218 insertions(+), 95 deletions(-)

diffs (truncated from 626 to 300 lines):

diff -r fa3f9df19fe0 -r ac79a8b4d172 sys/arch/i386/conf/ALL
--- a/sys/arch/i386/conf/ALL    Sat Feb 19 13:34:38 2011 +0000
+++ b/sys/arch/i386/conf/ALL    Sat Feb 19 13:52:27 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: ALL,v 1.288 2011/02/16 07:30:27 jruoho Exp $
+# $NetBSD: ALL,v 1.289 2011/02/19 13:52:27 jmcneill Exp $
 # From NetBSD: GENERIC,v 1.787 2006/10/01 18:37:54 bouyer Exp
 #
 # ALL machine description file
@@ -17,7 +17,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "ALL-$Revision: 1.288 $"
+#ident                 "ALL-$Revision: 1.289 $"
 
 maxusers       64              # estimated number of users
 
@@ -40,7 +40,7 @@
 options        POWERNOW_K8
 
 # VIA PadLock
-options        VIA_PADLOCK
+padlock0       at cpu0
 
 # Intel(R) On Demand Clock Modulation (aka ODCM)
 options        INTEL_ONDEMAND_CLOCKMOD
diff -r fa3f9df19fe0 -r ac79a8b4d172 sys/arch/i386/conf/GENERIC
--- a/sys/arch/i386/conf/GENERIC        Sat Feb 19 13:34:38 2011 +0000
+++ b/sys/arch/i386/conf/GENERIC        Sat Feb 19 13:52:27 2011 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.1017 2011/02/19 00:13:55 jmcneill Exp $
+# $NetBSD: GENERIC,v 1.1018 2011/02/19 13:52:27 jmcneill Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options        INCLUDE_CONFIG_FILE     # embed config file in kernel binary
 
-#ident                 "GENERIC-$Revision: 1.1017 $"
+#ident                 "GENERIC-$Revision: 1.1018 $"
 
 maxusers       64              # estimated number of users
 
@@ -48,7 +48,7 @@
 options        POWERNOW_K8
 
 # VIA PadLock
-#options       VIA_PADLOCK
+#padlock0      at cpu0
 
 # Intel(R) On Demand Clock Modulation (aka ODCM)
 #options       INTEL_ONDEMAND_CLOCKMOD
diff -r fa3f9df19fe0 -r ac79a8b4d172 sys/arch/i386/i386/autoconf.c
--- a/sys/arch/i386/i386/autoconf.c     Sat Feb 19 13:34:38 2011 +0000
+++ b/sys/arch/i386/i386/autoconf.c     Sat Feb 19 13:52:27 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: autoconf.c,v 1.95 2009/11/21 03:11:00 rmind Exp $      */
+/*     $NetBSD: autoconf.c,v 1.96 2011/02/19 13:52:28 jmcneill Exp $   */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -46,7 +46,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.95 2009/11/21 03:11:00 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.96 2011/02/19 13:52:28 jmcneill Exp $");
 
 #include "opt_compat_oldboot.h"
 #include "opt_intrdebug.h"
@@ -94,8 +94,6 @@
 #include <machine/kvm86.h>
 #endif
 
-#include "opt_viapadlock.h"
-
 /*
  * Determine i/o configuration for a machine.
  */
@@ -140,8 +138,4 @@
 #if NLAPIC > 0
        lapic_tpr = 0;
 #endif
-
-#if defined(VIA_PADLOCK)
-       via_padlock_attach();
-#endif
 }
diff -r fa3f9df19fe0 -r ac79a8b4d172 sys/arch/x86/conf/files.x86
--- a/sys/arch/x86/conf/files.x86       Sat Feb 19 13:34:38 2011 +0000
+++ b/sys/arch/x86/conf/files.x86       Sat Feb 19 13:52:27 2011 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.x86,v 1.57 2011/02/05 14:00:34 yamt Exp $
+#      $NetBSD: files.x86,v 1.58 2011/02/19 13:52:28 jmcneill Exp $
 
 # options for MP configuration through the MP spec
 defflag opt_mpbios.h MPBIOS MPVERBOSE MPDEBUG MPBIOS_SCANPCI
@@ -29,24 +29,25 @@
 # VIA C7 Temperature sensor
 defflag        opt_via_c7temp.h        VIA_C7TEMP: sysmon_envsys
 
-# VIA PadLock support
-defflag        opt_viapadlock.h        VIA_PADLOCK:    opencrypto
-file   arch/x86/x86/via_padlock.c      via_padlock
-
 # To be able to test for NetBSD/xen in shared files
 defflag        opt_xen.h               DO_NOT_DEFINE
 
 define  cpubus { [apid = -1] }
+define cpufeaturebus {}
 define  ioapicbus { [apid = -1] }
 define  ipmibus {}
 
 #
 # CPUs
 #
-device cpu
+device cpu: cpufeaturebus
 attach cpu at cpubus
 file   arch/x86/x86/cpu.c              cpu
 
+device padlock: opencrypto
+attach padlock at cpufeaturebus
+file   arch/x86/x86/via_padlock.c      padlock
+
 file   arch/x86/x86/apic.c             ioapic | lapic
 file   arch/x86/x86/bus_dma.c
 file   arch/x86/x86/bus_space.c
diff -r fa3f9df19fe0 -r ac79a8b4d172 sys/arch/x86/include/cpu.h
--- a/sys/arch/x86/include/cpu.h        Sat Feb 19 13:34:38 2011 +0000
+++ b/sys/arch/x86/include/cpu.h        Sat Feb 19 13:52:27 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.h,v 1.26 2010/12/22 04:15:01 christos Exp $        */
+/*     $NetBSD: cpu.h,v 1.27 2011/02/19 13:52:28 jmcneill Exp $        */
 
 /*-
  * Copyright (c) 1990 The Regents of the University of California.
@@ -180,7 +180,7 @@
 
        struct evcnt ci_ipi_events[X86_NIPI];
 
-       struct via_padlock      ci_vp;  /* VIA PadLock private storage */
+       device_t        ci_padlock;     /* VIA PadLock private storage */
 
        struct i386tss  ci_tss;         /* Per-cpu TSS; shared among LWPs */
        char            ci_iomap[IOMAPSIZE]; /* I/O Bitmap */
diff -r fa3f9df19fe0 -r ac79a8b4d172 sys/arch/x86/include/cpuvar.h
--- a/sys/arch/x86/include/cpuvar.h     Sat Feb 19 13:34:38 2011 +0000
+++ b/sys/arch/x86/include/cpuvar.h     Sat Feb 19 13:52:27 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpuvar.h,v 1.38 2010/08/20 06:34:32 jruoho Exp $ */
+/*     $NetBSD: cpuvar.h,v 1.39 2011/02/19 13:52:28 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc.
@@ -85,6 +85,11 @@
        const struct cpu_functions *cpu_func;
 };
 
+struct cpufeature_attach_args {
+       struct cpu_info *ci;
+       const char *name;
+};
+
 #ifdef _KERNEL
 
 #if defined(_KERNEL_OPT)
diff -r fa3f9df19fe0 -r ac79a8b4d172 sys/arch/x86/include/via_padlock.h
--- a/sys/arch/x86/include/via_padlock.h        Sat Feb 19 13:34:38 2011 +0000
+++ b/sys/arch/x86/include/via_padlock.h        Sat Feb 19 13:52:27 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: via_padlock.h,v 1.5 2009/04/01 21:15:45 drochner Exp $ */
+/*     $NetBSD: via_padlock.h,v 1.6 2011/02/19 13:52:28 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2003 Jason Wright
@@ -53,6 +53,8 @@
 };
 
 struct via_padlock_softc {
+       device_t        sc_dev;
+
        uint32_t        op_cw[4];       /* 128 bit aligned */
        uint8_t op_iv[16];      /* 128 bit aligned */
        void            *op_buf;
@@ -60,9 +62,11 @@
        int                     sc_rnd_hz;
        struct callout          sc_rnd_co;
        rndsource_element_t     sc_rnd_source;
+       bool                    sc_rnd_attached;
 
        /* normal softc stuff */
        int32_t         sc_cid;
+       bool            sc_cid_attached;
        int             sc_nsessions;
        struct via_padlock_session *sc_sessions;
 };
@@ -72,8 +76,6 @@
 
 #define VIAC3_RNG_BUFSIZ       16
 
-void    via_padlock_attach(void);
-
 #endif /* _KERNEL */
 
 #if defined(_KERNEL) || defined(_KMEMUSER)
diff -r fa3f9df19fe0 -r ac79a8b4d172 sys/arch/x86/x86/cpu.c
--- a/sys/arch/x86/x86/cpu.c    Sat Feb 19 13:34:38 2011 +0000
+++ b/sys/arch/x86/x86/cpu.c    Sat Feb 19 13:52:27 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu.c,v 1.80 2011/02/02 12:26:42 bouyer Exp $  */
+/*     $NetBSD: cpu.c,v 1.81 2011/02/19 13:52:28 jmcneill Exp $        */
 
 /*-
  * Copyright (c) 2000, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.80 2011/02/02 12:26:42 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu.c,v 1.81 2011/02/19 13:52:28 jmcneill Exp $");
 
 #include "opt_ddb.h"
 #include "opt_mpbios.h"                /* for MPDEBUG */
@@ -119,6 +119,9 @@
 
 int     cpu_match(device_t, cfdata_t, void *);
 void    cpu_attach(device_t, device_t, void *);
+int    cpu_rescan(device_t, const char *, const int *);
+void   cpu_childdetached(device_t, device_t);
+
 
 static bool    cpu_suspend(device_t, const pmf_qual_t *);
 static bool    cpu_resume(device_t, const pmf_qual_t *);
@@ -136,8 +139,8 @@
                                            mp_cpu_start_cleanup };
 
 
-CFATTACH_DECL_NEW(cpu, sizeof(struct cpu_softc),
-    cpu_match, cpu_attach, NULL, NULL);
+CFATTACH_DECL2_NEW(cpu, sizeof(struct cpu_softc),
+    cpu_match, cpu_attach, NULL, NULL, cpu_rescan, cpu_childdetached);
 
 /*
  * Statically-allocated CPU info for the primary CPU (or the only
@@ -445,6 +448,39 @@
 #endif
                );
        }
+
+       cpu_rescan(self, NULL, NULL);
+}
+
+int
+cpu_rescan(device_t self, const char *ifattr, const int *locators)
+{
+       struct cpufeature_attach_args cfaa;
+       struct cpu_softc *sc = device_private(self);
+       struct cpu_info *ci = sc->sc_info;
+
+       memset(&cfaa, 0, sizeof(cfaa));
+       cfaa.ci = ci;
+
+       if (ifattr_match(ifattr, "cpufeaturebus")) {
+               if (ci->ci_padlock == NULL) {
+                       cfaa.name = "padlock";
+                       ci->ci_padlock = config_found_ia(self,
+                           "cpufeaturebus", &cfaa, NULL);
+               }
+       }
+
+       return 0;
+}
+
+void
+cpu_childdetached(device_t self, device_t child)
+{
+       struct cpu_softc *sc = device_private(self);
+       struct cpu_info *ci = sc->sc_info;
+
+       if (ci->ci_padlock == child)
+               ci->ci_padlock = NULL;
 }
 
 /*
diff -r fa3f9df19fe0 -r ac79a8b4d172 sys/arch/x86/x86/identcpu.c
--- a/sys/arch/x86/x86/identcpu.c       Sat Feb 19 13:34:38 2011 +0000
+++ b/sys/arch/x86/x86/identcpu.c       Sat Feb 19 13:52:27 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: identcpu.c,v 1.22 2011/01/27 18:44:40 bouyer Exp $     */
+/*     $NetBSD: identcpu.c,v 1.23 2011/02/19 13:52:28 jmcneill Exp $   */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>



Home | Main Index | Thread Index | Old Index