<div dir="ltr"><div><div><div><div>Hi,<br></div>Below is the updated patch along with the one for atsam. Please have a look.<br></div>Moreover, in error case(FRO unwanted shutdown), Error bit of status register turns zero, indicating that FRO is no longer running.Untill now, i haven't came across any situation where this bit turns 0. In the <a href="http://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/arch/arm/omap/am335x_trng.c">NETBSD</a> and in <a href="https://github.com/torvalds/linux/blob/68fed41e0ff6c0332520a0d70ac05be2a7d9130e/drivers/char/hw_random/omap-rng.c">linux kernel</a> (line 241 ) implementation of am335x_trng, it seems they aren't checking for this bit. Instead they are only using RNG_STATUS_RDY as an indication of successful random data generation.<br><br></div><b>Patch: atsam</b><br><br>From ae0c79ae4850503259c64387dea69346e7d7b1d4 Mon Sep 17 00:00:00 2001<br>From: Udit agarwal <<a href="mailto:dev.madaari@gmail.com">dev.madaari@gmail.com</a>><br>Date: Thu, 15 Mar 2018 09:43:13 +0530<br>Subject: [PATCH] Fixed mutual exclusion of critical section<br><br>---<br> c/src/lib/libbsp/arm/atsam/startup/getentropy-trng.c | 6 ++++++<br> 1 file changed, 6 insertions(+)<br><br>diff --git a/c/src/lib/libbsp/arm/atsam/startup/getentropy-trng.c b/c/src/lib/libbsp/arm/atsam/startup/getentropy-trng.c<br>index 11e24dc..b26b6a8 100644<br>--- a/c/src/lib/libbsp/arm/atsam/startup/getentropy-trng.c<br>+++ b/c/src/lib/libbsp/arm/atsam/startup/getentropy-trng.c<br>@@ -17,6 +17,8 @@<br> #include <string.h><br> #include <rtems/sysinit.h><br> <br>+static rtems_mutex atsam_trng_reg = RTEMS_MUTEX_INITIALIZER("atsam_trng_reg");<br>+<br> static void atsam_trng_enable(void)<br> {<br> PMC_EnablePeripheral(ID_TRNG);<br>@@ -29,9 +31,12 @@ int getentropy(void *ptr, size_t n)<br> uint32_t random;<br> size_t copy;<br> <br>+ rtems_mutex_lock(&atsam_trng_reg);<br> while ((TRNG_GetStatus() & TRNG_ISR_DATRDY) == 0) {<br> /* wait */<br> }<br>+<br>+ rtems_mutex_unlock(&atsam_trng_reg);<br> random = TRNG_GetRandData();<br> <br> /*<br>@@ -51,6 +56,7 @@ int getentropy(void *ptr, size_t n)<br> ptr += copy;<br> }<br> <br>+ rtems_mutex_destroy(&atsam_trng_reg);<br> return 0;<br> }<br> <br>-- <br>1.9.1<br><br></div><b>Patch BBB</b><br><br>From ea885f9681c14f324917469b295e7489f56c10e7 Mon Sep 17 00:00:00 2001<br>From: Udit agarwal <<a href="mailto:dev.madaari@gmail.com">dev.madaari@gmail.com</a>><br>Date: Thu, 15 Mar 2018 09:24:35 +0530<br>Subject: [PATCH] Added getentropy support to beagle BSP<br><br>---<br> bsps/arm/include/libcpu/am335x.h | 33 ++++++<br> c/src/lib/libbsp/arm/beagle/Makefile.am | 4 +-<br> c/src/lib/libbsp/arm/beagle/dev/bbb_getentropy.c | 126 +++++++++++++++++++++++<br> 3 files changed, 162 insertions(+), 1 deletion(-)<br> create mode 100644 c/src/lib/libbsp/arm/beagle/dev/bbb_getentropy.c<br><br>diff --git a/bsps/arm/include/libcpu/am335x.h b/bsps/arm/include/libcpu/am335x.h<br>index 367e97c..6170ef3 100644<br>--- a/bsps/arm/include/libcpu/am335x.h<br>+++ b/bsps/arm/include/libcpu/am335x.h<br>@@ -14,11 +14,17 @@<br> * Modified by Ben Gras <<a href="mailto:beng@shrike-systems.com">beng@shrike-systems.com</a>> to add lots<br> * of beagleboard/beaglebone definitions, delete lpc32xx specific<br> * ones, and merge with some other header files.<br>+ *<br>+ * Modified by Udit agarwal <<a href="mailto:dev.madaari@gmail.com">dev.madaari@gmail.com</a>> to add random<br>+ * number generating module definitions and TRNG register structure.<br> */<br> <br> #if !defined(_AM335X_H_)<br> #define _AM335X_H_<br> <br>+/* For TRNG register definition */<br>+#include <stdint.h><br>+<br> /* Interrupt controller memory map */<br> #define OMAP3_DM37XX_INTR_BASE 0x48200000 /* INTCPS physical address */<br> <br>@@ -701,4 +707,31 @@<br> #define AM335X_CM_PER_OCPWP_L3_CLKSTCTRL_CLKACTIVITY_OCPWP_L4_GCLK (0x00000020u)<br> #define AM335X_I2C_INT_STOP_CONDITION AM335X_I2C_IRQSTATUS_BF<br> <br>+/* TRNG Register */<br>+<br>+/* RNG base address */<br>+#define RNG_BASE 0x48310000<br>+/* RNG clock control */<br>+#define CM_PER_RNG_CLKCTRL (AM335X_CM_PER_ADDR | (9 << 4))<br>+/* rng module clock status bits */<br>+#define AM335X_CLK_RNG_BIT_MASK (0x30000)<br>+/* Offset from RNG base for output ready flag */<br>+#define RNG_STATUS_RDY (1u << 0)<br>+/* Offset from RNG base for FRO related error */<br>+#define RNG_STATUS_ERR (1u << 1)<br>+/* Offset from RNG base for clock status */<br>+#define RNG_STATUS_CLK (1u << 31)<br>+/* enable module */<br>+#define AM335X_RNG_ENABLE (1 << 10)<br>+<br>+/* TRNG register structure */<br>+typedef struct {<br>+ uint64_t output; /* 00 */<br>+ uint32_t status; /* 08 */<br>+ uint32_t irq_en; /* 0c */<br>+ uint32_t status_clr; /* 10 */<br>+ uint32_t control; /* 14 */<br>+ uint32_t config; /* 18 */<br>+} am335x_trng_register;<br>+<br> #endif<br>diff --git a/c/src/lib/libbsp/arm/beagle/Makefile.am b/c/src/lib/libbsp/arm/beagle/Makefile.am<br>index 8251660..c483dc4 100644<br>--- a/c/src/lib/libbsp/arm/beagle/Makefile.am<br>+++ b/c/src/lib/libbsp/arm/beagle/Makefile.am<br>@@ -40,7 +40,6 @@ libbsp_a_LIBADD =<br> <br> # Shared<br> libbsp_a_SOURCES += ../../shared/bootcard.c<br>-libbsp_a_SOURCES += ../../shared/getentropy-cpucounter.c<br> libbsp_a_SOURCES += ../../shared/src/bsp-fdt.c<br> libbsp_a_SOURCES += ../../shared/bspclean.c<br> libbsp_a_SOURCES += ../../shared/bspgetworkarea.c<br>@@ -88,6 +87,9 @@ libbsp_a_SOURCES += gpio/bbb-gpio.c<br> #pwm<br> libbsp_a_SOURCES += pwm/pwm.c<br> <br>+#getentropy<br>+libbsp_a_SOURCES += dev/bbb_getentropy.c<br>+<br> #RTC<br> libbsp_a_SOURCES += rtc.c<br> libbsp_a_SOURCES += ../../shared/tod.c<br>diff --git a/c/src/lib/libbsp/arm/beagle/dev/bbb_getentropy.c b/c/src/lib/libbsp/arm/beagle/dev/bbb_getentropy.c<br>new file mode 100644<br>index 0000000..5445331<br>--- /dev/null<br>+++ b/c/src/lib/libbsp/arm/beagle/dev/bbb_getentropy.c<br>@@ -0,0 +1,126 @@<br>+/**<br>+* @file<br>+*<br>+* @ingroup arm_beagle<br>+*<br>+* @brief Getentropy implementation on BeagleBone Black BSP<br>+*/<br>+<br>+/*<br>+* Copyright (c) 2018 Udit agarwal <dev.madaari at <a href="http://gmail.com">gmail.com</a>><br>+* All rights reserved.<br>+*<br>+* Redistribution and use in source and binary forms, with or without<br>+* modification, are permitted provided that the following conditions<br>+* are met:<br>+* 1. Redistributions of source code must retain the above copyright<br>+* notice, this list of conditions and the following disclaimer.<br>+* 2. Redistributions in binary form must reproduce the above copyright<br>+* notice, this list of conditions and the following disclaimer in the<br>+* documentation and/or other materials provided with the distribution.<br>+*<br>+* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND<br>+* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE<br>+* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE<br>+* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE<br>+* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL<br>+* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS<br>+* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)<br>+* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT<br>+* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY<br>+* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF<br>+* SUCH DAMAGE.<br>+*/<br>+<br>+#include <libcpu/am335x.h><br>+#include <unistd.h><br>+#include <string.h><br>+#include <rtems/sysinit.h><br>+#include <rtems/thread.h><br>+#include <stdint.h><br>+<br>+/* max refill 34 * 256 cycles */<br>+#define AM335X_RNG_MAX_REFILL (34 << 16)<br>+/* min refill 33 * 64 cycles */<br>+#define AM335X_RNG_MIN_REFILL (33 << 0)<br>+/* startup 33 * 256 cycles */<br>+#define AM335X_RNG_STARTUP_CYCLES (33 << 16)<br>+<br>+static rtems_mutex am335x_trng_reg = RTEMS_MUTEX_INITIALIZER("am335x_trng_reg");<br>+/* maximun and minimum refill cycle sets the number of samples to be taken<br>+ from FRO to generate random number */<br>+static void am335x_rng_enable(volatile am335x_trng_register *rng)<br>+{<br>+ rng->control = rng->config = 0;<br>+ rng->config |= AM335X_RNG_MIN_REFILL | AM335X_RNG_MAX_REFILL ;<br>+ rng->control |= AM335X_RNG_STARTUP_CYCLES | AM335X_RNG_ENABLE ;<br>+}<br>+<br>+static void am335x_rng_clock_enable(void)<br>+{<br>+ volatile am335x_trng_register *rng = (am335x_trng_register*) RNG_BASE;<br>+ *(volatile uint8_t *) CM_PER_RNG_CLKCTRL = 2;<br>+ while(<br>+ *(volatile uint32_t *) CM_PER_RNG_CLKCTRL &<br>+ AM335X_CLK_RNG_BIT_MASK<br>+ ) {<br>+ /* wait */<br>+ }<br>+ am335x_rng_enable(rng);<br>+}<br>+<br>+static uint64_t trng_getranddata(volatile am335x_trng_register *rng)<br>+{<br>+ uint64_t output = rng->output;<br>+ return output;<br>+}<br>+<br>+int getentropy(void *ptr, size_t n)<br>+{<br>+ volatile am335x_trng_register *rng = (am335x_trng_register*) RNG_BASE;<br>+ while (n > 0)<br>+ {<br>+ uint64_t random;<br>+ size_t copy;<br>+<br>+ /* for mutual exclusion synchronization between multiple<br>+ access to TRNG register in different contexts */<br>+ rtems_mutex_lock(&am335x_trng_reg);<br>+<br>+ /* wait untill RNG becomes ready with next set of random data */<br>+ while( ( rng->status & RNG_STATUS_RDY ) == 0 )<br>+ {<br>+ /* wait */<br>+ }<br>+<br>+ rtems_mutex_unlock(&am335x_trng_reg);<br>+ random = trng_getranddata(rng);<br>+<br>+ /* clear the status flag after reading to generate new random<br>+ value */<br>+ rng->status_clr = RNG_STATUS_RDY;<br>+<br>+ /* checking for error by masking all bits other then error bit in<br>+ status register */<br>+ if( ((rng->status & RNG_STATUS_ERR)>>1) == 1)<br>+ {<br>+ copy = sizeof(random);<br>+ if ( n < copy )<br>+ {<br>+ copy = n;<br>+ }<br>+ memcpy(ptr, &random, copy);<br>+ n -= copy;<br>+ ptr = (char*)ptr + copy;<br>+ }<br>+ }<br>+<br>+ rtems_mutex_destroy(&am335x_trng_reg);<br>+ return 0;<br>+}<br>+<br>+RTEMS_SYSINIT_ITEM(<br>+ am335x_rng_clock_enable,<br>+ RTEMS_SYSINIT_DEVICE_DRIVERS,<br>+ RTEMS_SYSINIT_ORDER_LAST<br>+);<br>-- <br>1.9.1<br><br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 14, 2018 at 11:02 AM, Christian Mauderer <span dir="ltr"><<a href="mailto:christian.mauderer@embedded-brains.de" target="_blank">christian.mauderer@embedded-brains.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><br>
Am Mittwoch, 14. März 2018 schrieb Udit agarwal:<br>
> Hi,<br>
> @Joel This seems to be SoC specific.<br>
><br>
><br>
</span><span class="">> So, here is the implementation with mutex, Do let me know if this is okay. I'll then do it for atsam also.<br>
<br>
</span>Atsam should be an extra patch.<br>
<span class=""><br>
><br>
> int getentropy(void *ptr, size_t n)<br>
> {<br>
> volatile am335x_trng_register *rng = (am335x_trng_register*) RNG_BASE;<br>
> rtems_mutex lock_trng_reg = RTEMS_MUTEX_INITIALIZER("lock_<wbr>trng_reg");<br>
<br>
</span>If you create a local variable every thread will have it's own mutex. So they still can access the critical section in parallel. Use a global one in this case.<br>
<span class=""><br>
><br>
> while (n > 0)<br>
> {<br>
> uint64_t random;<br>
> size_t copy;<br>
><br>
> /* for mutual exclusion synchronization between multiple<br>
> access to TRNG register in different contexts */<br>
> rtems_mutex_lock(&lock_trng_<wbr>reg);<br>
><br>
</span><span class="">> /* wait untill RNG becomes ready with next set of random data */<br>
> while( ( rng->status & RNG_STATUS_RDY ) == 0 )<br>
> {<br>
> /* wait */<br>
> }<br>
><br>
> random = trng_getranddata(rng);<br>
> /* clear the status flag after reading to generate new random<br>
> value */<br>
> rng->status_clr = RNG_STATUS_RDY;<br>
> rtems_mutex_unlock(&lock_trng_<wbr>reg);<br>
><br>
> /* checking for error by masking all bits other then error bit in<br>
> status register */<br>
> if( ((rng->status & RNG_STATUS_ERR)>>1) == 1)<br>
> {<br>
> copy = sizeof(random);<br>
> if ( n < copy )<br>
> {<br>
> copy = n;<br>
> }<br>
> memcpy(ptr, &random, copy);<br>
> n -= copy;<br>
> ptr = (char*)ptr + copy;<br>
> }<br>
<br>
</span>Just noted that one: What Value is returned in the error case? Can the error even happen? I think that there is a special function that should be called in that case.<br>
<br>
> }<br>
><br>
> rtems_mutex_destroy(&lock_<wbr>trng_reg);<br>
> return 0;<br>
> }<br>
><br>
><br>
><br>
><br>
> On Wed, Mar 14, 2018 at 2:15 AM, Joel Sherrill <<a href="mailto:joel@rtems.org">joel@rtems.org</a>> wrote:<br>
<span class="">><br>
><br>
><br>
><br>
><br>
> On Mar 13, 2018 1:31 AM, "Sebastian Huber" <<a href="mailto:sebastian.huber@embedded-brains.de">sebastian.huber@embedded-<wbr>brains.de</a>> wrote:<br>
><br>
><br>
><br>
> On 12/03/18 20:02, Udit agarwal wrote:<br>
><br>
> So, It looks like here's the final patch, do let me know if its ready to be pushed. Also, it would be really helpful if someone else also tests this patch before pushing(Although i have done that once).<br>
><br>
> Thanks,<br>
> Udit agarwal<br>
><br>
><br>
> From 454a8ff3e0ea3393818859874705a5<wbr>4b098c6081 Mon Sep 17 00:00:00 2001<br>
><br>
> From: Udit agarwal <<a href="mailto:dev.madaari@gmail.com">dev.madaari@gmail.com</a> <mailto:<a href="mailto:dev.madaari@gmail.com">dev.madaari@gmail.com</a>><wbr>><br>
><br>
</span><span class="">> Date: Tue, 13 Mar 2018 00:20:28 +0530<br>
> Subject: [PATCH] Added Getentropy() support to beagle BSP<br>
><br>
> ---<br>
> bsps/arm/include/libcpu/<wbr>am335x.h | 37 ++++++-<br>
</span>> c/src/lib/libbsp/arm/beagle/<wbr>Makefile.am | 4 +-<br>
<span class="">> .../libbsp/arm/beagle/<wbr>getentropy/bbb_getentropy.c | 116 +++++++++++++++++++++<br>
> 3 files changed, 155 insertions(+), 2 deletions(-)<br>
> create mode 100644 c/src/lib/libbsp/arm/beagle/<wbr>getentropy/bbb_getentropy.c<br>
><br>
> diff --git a/bsps/arm/include/libcpu/<wbr>am335x.h b/bsps/arm/include/libcpu/<wbr>am335x.h<br>
> index 367e97c..cedd637 100644<br>
> --- a/bsps/arm/include/libcpu/<wbr>am335x.h<br>
> +++ b/bsps/arm/include/libcpu/<wbr>am335x.h<br>
> @@ -14,11 +14,17 @@<br>
><br>
</span>> * Modified by Ben Gras <<a href="mailto:beng@shrike-systems.com">beng@shrike-systems.com</a> <mailto:<a href="mailto:beng@shrike-systems.com">beng@shrike-systems.<wbr>com</a>>> to add lots<br>
<span class="">><br>
> * of beagleboard/beaglebone definitions, delete lpc32xx specific<br>
> * ones, and merge with some other header files.<br>
> + *<br>
><br>
</span>> + * Modified by Udit agarwal <<a href="mailto:dev.madaari@gmail.com">dev.madaari@gmail.com</a> <mailto:<a href="mailto:dev.madaari@gmail.com">dev.madaari@gmail.com</a>><wbr>> to add random<br>
<div><div class="h5">><br>
> + * number generating module definitions and TRNG register structure.<br>
> */<br>
><br>
> #if !defined(_AM335X_H_)<br>
> #define _AM335X_H_<br>
><br>
> +/* For TRNG register definition */<br>
> +#include <stdint.h><br>
> +<br>
> /* Interrupt controller memory map */<br>
> #define OMAP3_DM37XX_INTR_BASE 0x48200000 /* INTCPS physical address */<br>
><br>
> @@ -701,4 +707,33 @@<br>
> #define AM335X_CM_PER_OCPWP_L3_<wbr>CLKSTCTRL_CLKACTIVITY_OCPWP_<wbr>L4_GCLK (0x00000020u)<br>
> #define AM335X_I2C_INT_STOP_CONDITION AM335X_I2C_IRQSTATUS_BF<br>
><br>
> -#endif<br>
> +/* TRNG Register */<br>
> +<br>
> +/* RNG base address */<br>
> +#define RNG_BASE 0x48310000<br>
> +/* RNG clock control */<br>
> +#define CM_PER_RNG_CLKCTRL (AM335X_CM_PER_ADDR | (9 << 4))<br>
> +/* rng module clock status bits */<br>
> +#define AM335X_CLK_RNG_BIT_MASK (0x30000)<br>
> +/* Offset from RNG base for output ready flag */<br>
> +#define RNG_STATUS_RDY (1u << 0)<br>
> +/* Offset from RNG base for FRO related error */<br>
> +#define RNG_STATUS_ERR (1u << 1)<br>
> +/* Offset from RNG base for clock status */<br>
> +#define RNG_STATUS_CLK (1u << 31)<br>
> +/* enable module */<br>
> +#define AM335X_RNG_ENABLE (1 << 10)<br>
> +<br>
> +/* TRNG register structure */<br>
> +struct bbb_trng_register<br>
> +{<br>
> + uint64_t output; /* 00 */<br>
> + uint32_t status; /* 08 */<br>
> + uint32_t irq_en; /* 0c */<br>
> + uint32_t status_clr; /* 10 */<br>
> + uint32_t control; /* 14 */<br>
> + uint32_t config; /* 18 */<br>
> +};<br>
> +typedef struct bbb_trng_register bbb_trng_register;<br>
><br>
><br>
> The bbb (Beagle Bone Black) is a particular board and the AM335X is a SoC family. This should be something like this<br>
><br>
> typedef struct {<br>
> ...<br>
> } am335x_trng;<br>
><br>
><br>
><br>
> +<br>
> +#endif<br>
> \ No newline at end of file<br>
><br>
><br>
><br>
> Git thinks that files should have a newline at the end of the file.<br>
><br>
><br>
><br>
> diff --git a/c/src/lib/libbsp/arm/beagle/<wbr>Makefile.am b/c/src/lib/libbsp/arm/beagle/<wbr>Makefile.am<br>
> index 8251660..5d5ade3 100644<br>
> --- a/c/src/lib/libbsp/arm/beagle/<wbr>Makefile.am<br>
> +++ b/c/src/lib/libbsp/arm/beagle/<wbr>Makefile.am<br>
> @@ -40,7 +40,6 @@ libbsp_a_LIBADD =<br>
><br>
> # Shared<br>
> libbsp_a_SOURCES += ../../shared/bootcard.c<br>
> -libbsp_a_SOURCES += ../../shared/getentropy-<wbr>cpucounter.c<br>
> libbsp_a_SOURCES += ../../shared/src/bsp-fdt.c<br>
> libbsp_a_SOURCES += ../../shared/bspclean.c<br>
> libbsp_a_SOURCES += ../../shared/bspgetworkarea.c<br>
> @@ -88,6 +87,9 @@ libbsp_a_SOURCES += gpio/bbb-gpio.c<br>
> #pwm<br>
> libbsp_a_SOURCES += pwm/pwm.c<br>
><br>
> +#getentropy<br>
> +libbsp_a_SOURCES += getentropy/bbb_getentropy.c<br>
> +<br>
><br>
><br>
><br>
> With the new BSP source structure<br>
><br>
> <a href="https://devel.rtems.org/ticket/3285" rel="noreferrer" target="_blank">https://devel.rtems.org/<wbr>ticket/3285</a><br>
><br>
</div></div><div><div class="h5">> this new file could be also placed at<br>
><br>
> bsps/arm/beagle/dev/<wbr>getentropy.c<br>
><br>
><br>
><br>
> Is this specific to the Beagle or the SoC? Or a combination? Earlier you said the structure was SoC specific?<br>
><br>
><br>
> [...]<br>
><br>
> +int getentropy(void *ptr, size_t n)<br>
> +{<br>
> + volatile bbb_trng_register *rng = (bbb_trng_register*) RNG_BASE;<br>
> + am335x_rng_enable(rng);<br>
> + while (n > 0)<br>
> + {<br>
> + uint64_t random;<br>
> + size_t copy;<br>
> +<br>
> + /* wait untill RNG becomes ready with next set of random data */<br>
> + while( ( rng->status & RNG_STATUS_RDY ) == 0 )<br>
> + {<br>
> + /* wait */<br>
> + }<br>
><br>
><br>
> What happens if you call this function in parallel on different processors?<br>
><br>
><br>
> +<br>
> + random = trng_getranddata(rng);<br>
> +<br>
> + /* Checking for error by masking all bits other then error bit in<br>
> + status register */<br>
> + if( ((rng->status & RNG_STATUS_ERR)>>1) == 1)<br>
> + {<br>
> + /* clear the status flag after reading to generate new random<br>
> + value */<br>
> + rng->status_clr = RNG_STATUS_RDY;<br>
> + copy = sizeof(random);<br>
> + if ( n < copy )<br>
> + {<br>
> + copy = n;<br>
> + }<br>
> + memcpy(ptr, &random, copy);<br>
> + n -= copy;<br>
> + ptr = (char*)ptr + copy;<br>
> + }<br>
> + }<br>
> +<br>
> + return 0;<br>
> +}<br>
> +<br>
> +RTEMS_SYSINIT_ITEM(<br>
> + am335x_rng_clock_enable,<br>
> + RTEMS_SYSINIT_DEVICE_DRIVERS,<br>
> + RTEMS_SYSINIT_ORDER_LAST<br>
> +);<br>
> \ No newline at end of file<br>
> --<br>
> 1.9.1<br>
><br>
><br>
><br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> devel mailing list<br>
> <a href="mailto:devel@rtems.org">devel@rtems.org</a><br>
</div></div><span class="">> <a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/<wbr>mailman/listinfo/devel</a><br>
><br>
><br>
> --<br>
> Sebastian Huber, embedded brains GmbH<br>
><br>
> Address : Dornierstr. 4, D-82178 Puchheim, Germany<br>
> Phone : <a href="tel:%2B49%2089%20189%2047%2041-16" value="+4989189474116">+49 89 189 47 41-16</a><br>
> Fax : <a href="tel:%2B49%2089%20189%2047%2041-09" value="+4989189474109">+49 89 189 47 41-09</a><br>
> E-Mail : <a href="mailto:sebastian.huber@embedded-brains.de">sebastian.huber@embedded-<wbr>brains.de</a><br>
> PGP : Public key available on request.<br>
><br>
> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.<br>
><br>
><br>
> ______________________________<wbr>_________________<br>
> devel mailing list<br>
> <a href="mailto:devel@rtems.org">devel@rtems.org</a><br>
> <a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/<wbr>mailman/listinfo/devel</a><br>
><br>
><br>
><br>
><br>
<br>
--<br>
</span>------------------------------<wbr>--------------<br>
embedded brains GmbH<br>
<span class="HOEnZb"><font color="#888888">Christian Mauderer<br>
Dornierstr. 4<br>
D-82178 Puchheim<br>
Germany<br>
email: <a href="mailto:christian.mauderer@embedded-brains.de">christian.mauderer@embedded-<wbr>brains.de</a><br>
Phone: <a href="tel:%2B49-89-18%2094%20741%20-%2018" value="+4989189474118">+49-89-18 94 741 - 18</a><br>
Fax: <a href="tel:%2B49-89-18%2094%20741%20-%2008" value="+4989189474108">+49-89-18 94 741 - 08</a><br>
</font></span><div class="HOEnZb"><div class="h5">PGP: Public key available on request.<br>
<br>
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.</div></div></blockquote></div><br></div>