Source-Changes-HG archive

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

[src/netbsd-3]: src/sys/arch/i386/pci Apply patch (requested by tron in ticke...



details:   https://anonhg.NetBSD.org/src/rev/d8bd05c6542b
branches:  netbsd-3
changeset: 577853:d8bd05c6542b
user:      riz <riz%NetBSD.org@localhost>
date:      Sun Feb 26 21:23:45 2006 +0000

description:
Apply patch (requested by tron in ticket #1181):
        sys/arch/i386/pci/pchb_rnd.c
Improve code probing for the Intel hardware RNG to avoid false detections

diffstat:

 sys/arch/i386/pci/pchb_rnd.c |  29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)

diffs (72 lines):

diff -r 57d59280769c -r d8bd05c6542b sys/arch/i386/pci/pchb_rnd.c
--- a/sys/arch/i386/pci/pchb_rnd.c      Mon Feb 20 23:12:56 2006 +0000
+++ b/sys/arch/i386/pci/pchb_rnd.c      Sun Feb 26 21:23:45 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pchb_rnd.c,v 1.13.14.3 2006/02/15 19:27:53 riz Exp $   */
+/*     $NetBSD: pchb_rnd.c,v 1.13.14.4 2006/02/26 21:23:45 riz Exp $   */
 
 /*
  * Copyright (c) 2000 Michael Shalayeff
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pchb_rnd.c,v 1.13.14.3 2006/02/15 19:27:53 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pchb_rnd.c,v 1.13.14.4 2006/02/26 21:23:45 riz Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -50,7 +50,9 @@
 #include <arch/i386/pci/i82802reg.h>
 #include <arch/i386/pci/pchbvar.h>
 
-void pchb_rnd_callout(void *v);
+static void pchb_rnd_callout(void *v);
+
+#define        PCHB_RNG_RETRIES        1000
 
 void
 pchb_attach_rnd(struct pchb_softc *sc, struct pci_attach_args *pa)
@@ -116,20 +118,27 @@
                        }
 
                        /* Check to see if we can read data from the RNG. */
-                       for (i = 0; i < 1000; i++) {
+                       for (i = 0; i < PCHB_RNG_RETRIES; i++) {
                                reg8 = bus_space_read_1(sc->sc_st, sc->sc_sh,
                                    I82802_RNG_RNGST);
-                               if (reg8 & I82802_RNG_RNGST_DATAV)
+                               if (!(reg8 & I82802_RNG_RNGST_DATAV)) {
+                                       delay(10);
+                                       continue;
+                               }
+                               if (bus_space_read_1(sc->sc_st, sc->sc_sh,
+                                   I82802_RNG_DATA) != 0xff) {
                                        break;
-                               delay(10);
+                               }
                        }
 
-                       if ((reg8 & I82802_RNG_RNGST_DATAV) == 0) {
+                       if (i == PCHB_RNG_RETRIES) {
                                bus_space_unmap(sc->sc_st, sc->sc_sh,
                                    I82802_IOSIZE);
-                               printf("%s: unable to read from random "
-                                   "number generator.\n",
+#ifdef DIAGNOSTIC
+                               aprint_verbose("%s: unable to read from "
+                                   "random number generator.\n",
                                    sc->sc_dev.dv_xname);
+#endif
                                return;
                        }
 
@@ -162,7 +171,7 @@
        }
 }
 
-void
+static void
 pchb_rnd_callout(void *v)
 {
        struct pchb_softc *sc = v;



Home | Main Index | Thread Index | Old Index