Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb make ucom into a random source, type TTY



details:   https://anonhg.NetBSD.org/src/rev/f848520e2cc4
branches:  trunk
changeset: 498399:f848520e2cc4
user:      explorer <explorer%NetBSD.org@localhost>
date:      Sun Oct 22 19:01:44 2000 +0000

description:
make ucom into a random source, type TTY

diffstat:

 sys/dev/usb/ucom.c |  28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)

diffs (77 lines):

diff -r 71675fe477c5 -r f848520e2cc4 sys/dev/usb/ucom.c
--- a/sys/dev/usb/ucom.c        Sun Oct 22 17:17:08 2000 +0000
+++ b/sys/dev/usb/ucom.c        Sun Oct 22 19:01:44 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ucom.c,v 1.30 2000/09/23 04:33:04 augustss Exp $       */
+/*     $NetBSD: ucom.c,v 1.31 2000/10/22 19:01:44 explorer Exp $       */
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -52,6 +52,12 @@
 #include <sys/vnode.h>
 #include <sys/device.h>
 #include <sys/poll.h>
+#if defined(__NetBSD__)
+#include "rnd.h"
+#if NRND > 0
+#include <sys/rnd.h>
+#endif
+#endif
 
 #include <dev/usb/usb.h>
 
@@ -118,6 +124,10 @@
        u_char                  sc_opening;     /* lock during open */
        int                     sc_refcnt;
        u_char                  sc_dying;       /* disconnecting */
+
+#if defined(__NetBSD__) && NRND > 0
+       rndsource_element_t     sc_rndsource;   /* random source */
+#endif
 };
 
 cdev_decl(ucom);
@@ -175,6 +185,11 @@
        DPRINTF(("ucom_attach: tty_attach %p\n", tp));
        tty_attach(tp);
 
+#if defined(__NetBSD__) && NRND > 0
+       rnd_attach_source(&sc->sc_rndsource, USBDEVNAME(sc->sc_dev),
+                         RND_TYPE_TTY, 0);
+#endif
+
        USB_ATTACH_SUCCESS_RETURN;
 }
 
@@ -221,6 +236,11 @@
        ttyfree(sc->sc_tty);
        sc->sc_tty = 0;
 
+       /* Detach the random source */
+#if defined(__NetBSD__) && NRND > 0
+       rnd_detach_source(&sc->sc_rndsource);
+#endif
+
        return (0);
 }
 
@@ -934,6 +954,9 @@
        }
 
        usbd_get_xfer_status(xfer, NULL, NULL, &cc, NULL);
+#if defined(__NetBSD__) && NRND > 0
+       rnd_add_uint32(&sc->sc_rndsource, cc);
+#endif
        DPRINTFN(5,("ucomwritecb: cc=%d\n", cc));
        /* convert from USB bytes to tty bytes */
        cc -= sc->sc_opkthdrlen;
@@ -989,6 +1012,9 @@
        }
 
        usbd_get_xfer_status(xfer, NULL, (void **)&cp, &cc, NULL);
+#if defined(__NetBSD__) && NRND > 0
+       rnd_add_uint32(&sc->sc_rndsource, cc);
+#endif
        DPRINTFN(5,("ucomreadcb: got %d chars, tp=%p\n", cc, tp));
        if (sc->sc_methods->ucom_read != NULL)
                sc->sc_methods->ucom_read(sc->sc_parent, sc->sc_portno,



Home | Main Index | Thread Index | Old Index