Hi *
I'm going to get a bollicking for the formatting in this. Apologies in advance!
M
> On 19 Jul 2016, at 19:07, Mark Murray wrote:
>
> Author: markm
> Date: Tue Jul 19 18:07:47 2016
> New Revision: 303035
> URL: https://svnweb.freebsd.org/changeset/base/303035
>
> Log:
> Random bit generator (RBG) driver for RPi and RPi2.
>
> Summary:
> This driver supports the following methods to trigger gathering random bits
> from the hardware:
> 1. interrupt when the FIFO is full (default) fed into the harvest queue
> 2. callout (when BCM2835_RNG_USE_CALLOUT is defined) every second if hz is
> less than 100, otherwise hz / 100, feeding the random bits into the harvest
> queue
>
> If the kernel is booted with verbose enabled, the contents of the registers
> will be dumped after the RBG is started during the attach routine.
>
> Author: hackagadget_gmail.com (Stephen J. Kiernan)
>
> Test Plan: Built RPI2 kernel and booted on board. Tested the different
> methods to feed the harvest queue (callout, interrupt) and the interrupt
> driven approach seems best. However, keeping the other method for people to
> be able to experiment with.
>
> Reviewed By: adrian, delphij, markm
>
> Differential Revision: https://reviews.freebsd.org/D6888
>
> Added:
> head/sys/arm/broadcom/bcm2835/bcm2835_rng.c (contents, props changed)
> Modified:
> head/sys/arm/broadcom/bcm2835/files.bcm283x
> head/sys/boot/fdt/dts/arm/bcm2835.dtsi
> head/sys/boot/fdt/dts/arm/bcm2836.dtsi
> head/sys/sys/random.h
>
> Added: head/sys/arm/broadcom/bcm2835/bcm2835_rng.c
> ==
> --- /dev/null 00:00:00 1970 (empty, because file is newly added)
> +++ head/sys/arm/broadcom/bcm2835/bcm2835_rng.c Tue Jul 19 18:07:47
> 2016(r303035)
> @@ -0,0 +1,534 @@
> +/*
> + * Copyright (c) 2015, 2016, Stephen J. Kiernan
> + * All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions
> + * are met:
> + * 1. Redistributions of source code must retain the above copyright
> + *notice, this list of conditions and the following disclaimer.
> + * 2. Redistributions in binary form must reproduce the above copyright
> + *notice, this list of conditions and the following disclaimer in the
> + *documentation and/or other materials provided with the distribution.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
> + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
> + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
> + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
> + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
> + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
> + * SUCH DAMAGE.
> + */
> +
> +#include
> +
> +__FBSDID("$FreeBSD$");
> +
> +#include
> +#include
> +#include
> +#include
> +#include
> +#include
> +#include
> +#include
> +#include
> +#include
> +#include
> +#include
> +
> +#include
> +#include
> +
> +#include
> +#include
> +#include
> +
> +#include
> +#include
> +
> +#if !defined(BCM2835_RNG_USE_CALLOUT)
> +#define BCM2835_RNG_USE_INTERRUPT
> +#endif
> +
> +static device_attach_t bcm2835_rng_attach;
> +static device_detach_t bcm2835_rng_detach;
> +static device_probe_t bcm2835_rng_probe;
> +
> +#define RNG_CTRL0x00/* RNG Control Register
> */
> +#define RNG_COMBLK1_OSC 0x003f /* Combiner Blk 1
> Oscillator */
> +#define RNG_COMBLK1_OSC_SHIFT 16
> +#define RNG_COMBLK2_OSC 0x0fc0 /* Combiner Blk 2
> Oscillator */
> +#define RNG_COMBLK2_OSC_SHIFT 22
> +#define RNG_JCLK_BYP_DIV_CNT0xff00 /* Jitter clk bypass
> divider
> + count */
> +#define RNG_JCLK_BYP_DIV_CNT_SHIFT 8
> +#define RNG_JCLK_BYP_SRC0x0020 /* Jitter clk bypass
> source */
> +#define RNG_JCLK_BYP_SEL0x0010 /* Jitter clk bypass
> select */
> +#define RNG_RBG2X 0x0002 /* RBG 2X SPEED */
> +#define RNG_RBGEN_BIT 0x0001 /* Enable RNG bit */
> +
> +#define RNG_STATUS 0x04/* RNG status register
> */
> +#define RND_VAL_SHIFT 24 /* Shift for valid
> words */
> +#define RND_VAL_MASK0x00ff /* Number valid