mirror of
https://github.com/apache/nuttx.git
synced 2026-06-02 09:38:37 +08:00
Rename up_rnginitialize to devrandom_register
This commit is contained in:
@@ -260,7 +260,7 @@ void up_initialize(void)
|
|||||||
#ifdef CONFIG_DEV_RANDOM
|
#ifdef CONFIG_DEV_RANDOM
|
||||||
/* Initialize the Random Number Generator (RNG) */
|
/* Initialize the Random Number Generator (RNG) */
|
||||||
|
|
||||||
up_rnginitialize();
|
devrandom_register();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_NETDEV_LATEINIT
|
#ifndef CONFIG_NETDEV_LATEINIT
|
||||||
|
|||||||
@@ -545,12 +545,6 @@ void up_usbuninitialize(void);
|
|||||||
# define up_usbuninitialize()
|
# define up_usbuninitialize()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Random Number Generator (RNG) ********************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_DEV_RANDOM
|
|
||||||
void up_rnginitialize(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Debug ********************************************************************/
|
/* Debug ********************************************************************/
|
||||||
#ifdef CONFIG_STACK_COLORATION
|
#ifdef CONFIG_STACK_COLORATION
|
||||||
void up_stack_color(FAR void *stackbase, size_t nbytes);
|
void up_stack_color(FAR void *stackbase, size_t nbytes);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/sama5/sam_trng.c
|
* arch/arm/src/sama5/sam_trng.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2013, 2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Derives, in part, from Max Holtzberg's STM32 RNG Nuttx driver:
|
* Derives, in part, from Max Holtzberg's STM32 RNG Nuttx driver:
|
||||||
@@ -329,10 +329,10 @@ errout:
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_rnginitialize
|
* Name: devrandom_register
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Initialize the TRNG hardware and register the /dev/randome driver.
|
* Initialize the TRNG hardware and register the /dev/random driver.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* None
|
* None
|
||||||
@@ -342,7 +342,7 @@ errout:
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_rnginitialize(void)
|
int devrandom_register(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -360,10 +360,11 @@ void up_rnginitialize(void)
|
|||||||
|
|
||||||
/* Initialize the TRNG interrupt */
|
/* Initialize the TRNG interrupt */
|
||||||
|
|
||||||
if (irq_attach(SAM_IRQ_TRNG, sam_interrupt))
|
ret = irq_attach(SAM_IRQ_TRNG, sam_interrupt);
|
||||||
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ferr("ERROR: Failed to attach to IRQ%d\n", SAM_IRQ_TRNG);
|
ferr("ERROR: Failed to attach to IRQ%d\n", SAM_IRQ_TRNG);
|
||||||
return;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disable the interrupts at the TRNG */
|
/* Disable the interrupts at the TRNG */
|
||||||
@@ -380,10 +381,11 @@ void up_rnginitialize(void)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ferr("ERROR: Failed to register /dev/random\n");
|
ferr("ERROR: Failed to register /dev/random\n");
|
||||||
return;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable the TRNG interrupt at the AIC */
|
/* Enable the TRNG interrupt at the AIC */
|
||||||
|
|
||||||
up_enable_irq(SAM_IRQ_TRNG);
|
up_enable_irq(SAM_IRQ_TRNG);
|
||||||
|
return OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/samv7/sam_trng.c
|
* arch/arm/src/samv7/sam_trng.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2015-2016 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Derives from the SAMA5D3 TRNG Nuttx driver which, in turn, derives, in
|
* Derives from the SAMA5D3 TRNG Nuttx driver which, in turn, derives, in
|
||||||
@@ -330,10 +330,10 @@ errout:
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_rnginitialize
|
* Name: devrandom_register
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Initialize the TRNG hardware and register the /dev/randome driver.
|
* Initialize the TRNG hardware and register the /dev/random driver.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* None
|
* None
|
||||||
@@ -343,7 +343,7 @@ errout:
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_rnginitialize(void)
|
int devrandom_register(void)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -361,10 +361,11 @@ void up_rnginitialize(void)
|
|||||||
|
|
||||||
/* Initialize the TRNG interrupt */
|
/* Initialize the TRNG interrupt */
|
||||||
|
|
||||||
if (irq_attach(SAM_IRQ_TRNG, sam_interrupt))
|
ret = irq_attach(SAM_IRQ_TRNG, sam_interrupt);
|
||||||
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ferr("ERROR: Failed to attach to IRQ%d\n", SAM_IRQ_TRNG);
|
ferr("ERROR: Failed to attach to IRQ%d\n", SAM_IRQ_TRNG);
|
||||||
return;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disable the interrupts at the TRNG */
|
/* Disable the interrupts at the TRNG */
|
||||||
@@ -381,10 +382,11 @@ void up_rnginitialize(void)
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
ferr("ERROR: Failed to register /dev/random\n");
|
ferr("ERROR: Failed to register /dev/random\n");
|
||||||
return;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable the TRNG interrupt at the AIC */
|
/* Enable the TRNG interrupt at the AIC */
|
||||||
|
|
||||||
up_enable_irq(SAM_IRQ_TRNG);
|
up_enable_irq(SAM_IRQ_TRNG);
|
||||||
|
return OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -258,8 +258,22 @@ static ssize_t stm32_read(struct file *filep, char *buffer, size_t buflen)
|
|||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_rnginitialize()
|
/****************************************************************************
|
||||||
|
* Name: devrandom_register
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize the RNG hardware and register the /dev/random driver.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int devrandom_register(void)
|
||||||
{
|
{
|
||||||
stm32_rnginitialize();
|
stm32_rnginitialize();
|
||||||
register_driver("/dev/random", &g_rngops, 0444, NULL);
|
return register_driver("/dev/random", &g_rngops, 0444, NULL);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -289,10 +289,24 @@ static ssize_t stm32l4_rngread(struct file *filep, char *buffer, size_t buflen)
|
|||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_rnginitialize(void)
|
/****************************************************************************
|
||||||
|
* Name: devrandom_register
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize the RNG hardware and register the /dev/random driver.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* None
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int devrandom_register(void)
|
||||||
{
|
{
|
||||||
stm32l4_rnginitialize();
|
stm32l4_rnginitialize();
|
||||||
register_driver("/dev/random", &g_rngops, 0444, NULL);
|
return register_driver("/dev/random", &g_rngops, 0444, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_STM32L4_RNG */
|
#endif /* CONFIG_STM32L4_RNG */
|
||||||
|
|||||||
@@ -301,7 +301,7 @@ void up_initialize(void)
|
|||||||
#ifdef CONFIG_DEV_RANDOM
|
#ifdef CONFIG_DEV_RANDOM
|
||||||
/* Initialize the Random Number Generator (RNG) */
|
/* Initialize the Random Number Generator (RNG) */
|
||||||
|
|
||||||
up_rnginitialize();
|
devrandom_register();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_NETDEV_LATEINIT
|
#ifndef CONFIG_NETDEV_LATEINIT
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ void up_initialize(void)
|
|||||||
#ifdef CONFIG_DEV_RANDOM
|
#ifdef CONFIG_DEV_RANDOM
|
||||||
/* Initialize the Random Number Generator (RNG) */
|
/* Initialize the Random Number Generator (RNG) */
|
||||||
|
|
||||||
up_rnginitialize();
|
devrandom_register();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_NETDEV_LATEINIT
|
#ifndef CONFIG_NETDEV_LATEINIT
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ void up_initialize(void)
|
|||||||
#ifdef CONFIG_DEV_RANDOM
|
#ifdef CONFIG_DEV_RANDOM
|
||||||
/* Initialize the Random Number Generator (RNG) */
|
/* Initialize the Random Number Generator (RNG) */
|
||||||
|
|
||||||
up_rnginitialize();
|
devrandom_register();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_NETDEV_LATEINIT
|
#ifndef CONFIG_NETDEV_LATEINIT
|
||||||
|
|||||||
@@ -172,7 +172,7 @@ void up_initialize(void)
|
|||||||
#ifdef CONFIG_DEV_RANDOM
|
#ifdef CONFIG_DEV_RANDOM
|
||||||
/* Initialize the Random Number Generator (RNG) */
|
/* Initialize the Random Number Generator (RNG) */
|
||||||
|
|
||||||
up_rnginitialize();
|
devrandom_register();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Enable interrupt */
|
/* Enable interrupt */
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ void up_initialize(void)
|
|||||||
#ifdef CONFIG_DEV_RANDOM
|
#ifdef CONFIG_DEV_RANDOM
|
||||||
/* Initialize the Random Number Generator (RNG) */
|
/* Initialize the Random Number Generator (RNG) */
|
||||||
|
|
||||||
up_rnginitialize();
|
devrandom_register();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_NETDEV_LATEINIT
|
#ifndef CONFIG_NETDEV_LATEINIT
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ void up_initialize(void)
|
|||||||
#ifdef CONFIG_DEV_RANDOM
|
#ifdef CONFIG_DEV_RANDOM
|
||||||
/* Initialize the Random Number Generator (RNG) */
|
/* Initialize the Random Number Generator (RNG) */
|
||||||
|
|
||||||
up_rnginitialize();
|
devrandom_register();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_FS_FAT) && !defined(CONFIG_DISABLE_MOUNTPOINT)
|
#if defined(CONFIG_FS_FAT) && !defined(CONFIG_DISABLE_MOUNTPOINT)
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ void up_initialize(void)
|
|||||||
#ifdef CONFIG_DEV_RANDOM
|
#ifdef CONFIG_DEV_RANDOM
|
||||||
/* Initialize the Random Number Generator (RNG) */
|
/* Initialize the Random Number Generator (RNG) */
|
||||||
|
|
||||||
up_rnginitialize();
|
devrandom_register();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_NETDEV_LATEINIT
|
#ifndef CONFIG_NETDEV_LATEINIT
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ void up_initialize(void)
|
|||||||
#ifdef CONFIG_DEV_RANDOM
|
#ifdef CONFIG_DEV_RANDOM
|
||||||
/* Initialize the Random Number Generator (RNG) */
|
/* Initialize the Random Number Generator (RNG) */
|
||||||
|
|
||||||
up_rnginitialize();
|
devrandom_register();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_NETDEV_LATEINIT
|
#ifndef CONFIG_NETDEV_LATEINIT
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ void up_initialize(void)
|
|||||||
#ifdef CONFIG_DEV_RANDOM
|
#ifdef CONFIG_DEV_RANDOM
|
||||||
/* Initialize the Random Number Generator (RNG) */
|
/* Initialize the Random Number Generator (RNG) */
|
||||||
|
|
||||||
up_rnginitialize();
|
devrandom_register();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_NETDEV_LATEINIT
|
#ifndef CONFIG_NETDEV_LATEINIT
|
||||||
|
|||||||
@@ -424,7 +424,7 @@ static ssize_t pty_read(FAR struct file *filep, FAR char *buffer, size_t len)
|
|||||||
*
|
*
|
||||||
* There is an inherent race condition in this test, but leaving
|
* There is an inherent race condition in this test, but leaving
|
||||||
* a few bytes unnecessarily in the pipe should not be harmful.
|
* a few bytes unnecessarily in the pipe should not be harmful.
|
||||||
* (we could lock the scheduler between the test and the
|
* (we could lock the scheduler before the test and after the
|
||||||
* file_read() below if we wanted to eliminate the race)
|
* file_read() below if we wanted to eliminate the race)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -443,7 +443,9 @@ static ssize_t pty_read(FAR struct file *filep, FAR char *buffer, size_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Break out of the loop and return ntotal if the pipe is
|
/* Break out of the loop and return ntotal if the pipe is
|
||||||
* empty.
|
* empty. This is the race: The fifo was emtpy when we
|
||||||
|
* called file_ioctl() above, but it might not be empty right
|
||||||
|
* now.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (nsrc < 1)
|
if (nsrc < 1)
|
||||||
@@ -495,7 +497,7 @@ static ssize_t pty_read(FAR struct file *filep, FAR char *buffer, size_t len)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
/* NOTE: the source pipe will block is no data is available in
|
/* NOTE: the source pipe will block if no data is available in
|
||||||
* the pipe. Otherwise, it will return data from the pipe. If
|
* the pipe. Otherwise, it will return data from the pipe. If
|
||||||
* there are fewer than 'len' bytes in the, it will return with
|
* there are fewer than 'len' bytes in the, it will return with
|
||||||
* ntotal < len.
|
* ntotal < len.
|
||||||
|
|||||||
@@ -97,11 +97,13 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <assert.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/kmalloc.h>
|
#include <nuttx/kmalloc.h>
|
||||||
#include <nuttx/wireless/cc1101.h>
|
#include <nuttx/wireless/cc1101.h>
|
||||||
@@ -450,6 +452,8 @@ void cc1101_dumpregs(struct cc1101_dev_s * dev, uint8_t addr, uint8_t length)
|
|||||||
|
|
||||||
cc1101_access(dev, addr, (FAR uint8_t *)buf, length);
|
cc1101_access(dev, addr, (FAR uint8_t *)buf, length);
|
||||||
|
|
||||||
|
/* REVISIT: printf() should not be used from within the OS */
|
||||||
|
|
||||||
printf("CC1101[%2x]: ", addr);
|
printf("CC1101[%2x]: ", addr);
|
||||||
for (i = 0; i < length; i++)
|
for (i = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
@@ -814,7 +818,7 @@ int cc1101_read(struct cc1101_dev_s * dev, uint8_t * buf, size_t size)
|
|||||||
|
|
||||||
if (nbytes > size || (nbytes <= size && !(buf[nbytes-1]&0x80)))
|
if (nbytes > size || (nbytes <= size && !(buf[nbytes-1]&0x80)))
|
||||||
{
|
{
|
||||||
printf("Flushing RX FIFO\n");
|
ninfo("Flushing RX FIFO\n");
|
||||||
cc1101_strobe(dev, CC1101_SFRX);
|
cc1101_strobe(dev, CC1101_SFRX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1013,6 +1013,18 @@ int fdesc_poll(int fd, FAR struct pollfd *fds, bool setup);
|
|||||||
|
|
||||||
void devnull_register(void);
|
void devnull_register(void);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: devrandom_register
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize the RNG hardware and register the /dev/random driver.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEV_RANDOM
|
||||||
|
void devrandom_register(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: devurandom_register
|
* Name: devurandom_register
|
||||||
*
|
*
|
||||||
@@ -1021,7 +1033,9 @@ void devnull_register(void);
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEV_URANDOM
|
||||||
void devurandom_register(void);
|
void devurandom_register(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: devcrypto_register
|
* Name: devcrypto_register
|
||||||
|
|||||||
Reference in New Issue
Block a user