Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

rng_driver.c File Reference

Detailed Description

This is the driver code for the hardware Random Number Generator (RNG).

It provides the following functions to callers: fsl_shw_return_t fsl_shw_get_random(fsl_shw_uco_t* user_ctx, uint32_t length, uint8_t* data);

fsl_shw_return_t fsl_shw_add_entropy(fsl_shw_uco_t* user_ctx, uint32_t length, uint8_t* data);

The life of the driver starts at boot (or module load) time, with a call by the kernel to rng_init(). As part of initialization, a background task running rng_entropy_task() will be created.

The life of the driver ends when the kernel is shutting down (or the driver is being unloaded). At this time, rng_shutdown() is called. No function will ever be called after that point. In the case that the driver is reloaded, a new copy of the driver, with fresh global values, etc., is loaded, and there will be a new call to rng_init().

A call to fsl_shw_get_random() gets converted into a work entry which is queued and handed off to a background task for fulfilment. This provides for a single thread of control for reading the RNG's FIFO register, which might otherwise underflow if not carefully managed.

A call to fsl_shw_add_entropy() will cause the additional entropy to be passed directly into the hardware.

In a debug configuration, it provides the following kernel functions: rng_return_t rng_read_register(uint32_t byte_offset, uint32_t* valuep); rng_return_t rng_write_register(uint32_t byte_offset, uint32_t value);

Definition in file rng_driver.c.

#include "portable_os.h"
#include "fsl_shw.h"
#include "rng_internals.h"
#include <linux/mxc_scc_driver.h>

Go to the source code of this file.


#define FALSE   0
#define LOG_KDIAG(diag)
#define LOG_KDIAG_ARGS(fmt,...)
#define TRUE   1


static DECLARE_COMPLETION (rng_seed_done)
static DECLARE_COMPLETION (rng_self_testing)
static uint32_t finish_random (shw_queue_entry_t *gen_entry)
fsl_shw_return_t fsl_shw_add_entropy (fsl_shw_uco_t *user_ctx, uint32_t length, uint8_t *data)
fsl_shw_return_t fsl_shw_get_random (fsl_shw_uco_t *user_ctx, uint32_t length, uint8_t *data)
 OS_DEV_INIT (rng_init)
 OS_DEV_ISR (rng_irq)
 OS_DEV_SHUTDOWN (rng_shutdown)
 OS_DEV_TASK (rng_entropy_task)
 OS_WAIT_OBJECT (rng_wait_queue)
static void rng_cleanup (void)
static fsl_shw_return_t rng_drain_fifo (uint32_t *random_p, int count_words)
static os_error_code rng_grab_config_values (void)
static os_error_code rng_map_RNG_memory (void)
static os_error_code rng_setup_interrupt_handling (void)


static volatile rng_status_t rng_availability = RNG_STATUS_INITIAL
static volatile void * rng_base
static int rng_irq_set = FALSE
static int rng_major
static int rng_output_fifo_size
static os_lock_t rng_queue_lock = NULL
os_driver_reg_t rng_reg_handle
static shw_queue_t rng_work_queue
static unsigned task_started = FALSE

Generated by  Doxygen 1.6.0   Back to index