LCOV - code coverage report
Current view: top level - dev/ic - ccp.c (source / functions) Hit Total Coverage
Test: 6.4 Lines: 0 12 0.0 %
Date: 2018-10-19 03:25:38 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*      $OpenBSD: ccp.c,v 1.2 2018/04/28 15:44:59 jasper Exp $ */
       2             : 
       3             : /*
       4             :  * Copyright (c) 2018 David Gwynne <dlg@openbsd.org>
       5             :  *
       6             :  * Permission to use, copy, modify, and distribute this software for any
       7             :  * purpose with or without fee is hereby granted, provided that the above
       8             :  * copyright notice and this permission notice appear in all copies.
       9             :  *
      10             :  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
      11             :  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
      12             :  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
      13             :  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
      14             :  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
      15             :  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
      16             :  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
      17             :  */
      18             : 
      19             : #include <sys/param.h>
      20             : #include <sys/systm.h>
      21             : #include <sys/buf.h>
      22             : #include <sys/device.h>
      23             : #include <sys/malloc.h>
      24             : #include <sys/kernel.h>
      25             : #include <sys/timeout.h>
      26             : 
      27             : #include <machine/bus.h>
      28             : 
      29             : #include <dev/rndvar.h>
      30             : 
      31             : #include <dev/ic/ccpvar.h>
      32             : 
      33             : #define CCP_REG_TRNG            0xc
      34             : 
      35             : static void     ccp_rng(void *);
      36             : 
      37             : struct cfdriver ccp_cd = {
      38             :         NULL,
      39             :         "ccp",
      40             :         DV_DULL
      41             : };
      42             : 
      43             : void
      44           0 : ccp_attach(struct ccp_softc *sc)
      45             : {
      46           0 :         timeout_set(&sc->sc_tick, ccp_rng, sc);
      47           0 :         ccp_rng(sc);
      48             : 
      49           0 :         printf("\n");
      50           0 : }
      51             : 
      52             : static void
      53           0 : ccp_rng(void *arg)
      54             : {
      55           0 :         struct ccp_softc *sc = arg;
      56             :         uint32_t trng;
      57             : 
      58           0 :         trng = bus_space_read_4(sc->sc_iot, sc->sc_ioh, CCP_REG_TRNG);
      59           0 :         if (trng != 0)
      60           0 :                 enqueue_randomness(trng);
      61             : 
      62           0 :         timeout_add_msec(&sc->sc_tick, 100);
      63           0 : }

Generated by: LCOV version 1.13