RNG Compile Flags

Defines

#define RNG_MAX_TRIES   100
#define RNG_NO_FORCE_HIGH_ASSURANCE
#define RNG_READ_REGISTER(offset)   os_read32(rng_base+(offset))
#define RNG_WRITE_REGISTER(offset, value)   (void)os_write32(rng_base+(offset), value)
#define RNG_DRIVER_NAME   "rng"
#define BYTES_TO_WORDS(byte_count)   (((byte_count)+sizeof(uint32_t)-1)/sizeof(uint32_t))
#define RNG_CHECK_READ   0
#define RNG_CHECK_WRITE   1
#define RNG_BASE_ADDR   RNGC_BASE_ADDR
#define RNG_GET_STATUS()   RNG_READ_REGISTER(RNGC_ERROR)
#define RNG_GET_RNG_TYPE()
#define RNG_VERIFY_TYPE(type)   ((type) == RNG_TYPE_RNGC)
#define RNG_HAS_ERROR()   (RNG_READ_REGISTER(RNGC_STATUS) & RNGC_STATUS_ERROR)
#define RNG_HAS_BAD_KEY()   (RNG_READ_REGISTER(RNGC_ERROR) & RNGC_ERROR_STATUS_BAD_KEY)
#define RNG_OSCILLATOR_FAILED()   (RNG_READ_REGISTER(RNGC_ERROR) & RNGC_ERROR_STATUS_OSC_ERR)
#define RNG_GET_FIFO_SIZE()
#define RNG_GET_WORDS_IN_FIFO()
#define RNG_READ_FIFO()   RNG_READ_REGISTER(RNGC_FIFO)
#define RNG_ADD_ENTROPY(value)
#define RNG_WAKE()   1
#define RNG_GO()
#define RNG_SET_HIGH_ASSURANCE()
#define RNG_CHECK_SELF_ERR()   (RNG_READ_REGISTER(RNGC_ERROR) & RNGC_ERROR_STATUS_ST_ERR)
#define RNG_CHECK_SEED_ERR()   (RNG_READ_REGISTER(RNGC_ERROR) & RNGC_ERROR_STATUS_STAT_ERR)
#define RNG_SELF_TEST()
#define RNG_CLEAR_ERR()
#define RNG_SELF_TEST_DONE()   (RNG_READ_REGISTER(RNGC_STATUS) & RNGC_STATUS_ST_DONE)
#define RNG_GET_HIGH_ASSURANCE()
#define RNG_CLEAR_ALL_STATUS()
#define RNG_WORKING()
#define RNG_SEED_DONE()   ((RNG_READ_REGISTER(RNGC_STATUS) & RNGC_STATUS_SEED_DONE) != 0)
#define RNG_SLEEP()
#define RNG_MASK_ALL_INTERRUPTS()
#define RNG_AUTO_SEED()
#define RNG_UNMASK_ALL_INTERRUPTS()
#define RNG_PUT_RNG_TO_SLEEP()
#define RNG_WAKE_FROM_SLEEP()

Typedefs

typedef enum rng_status rng_status_t

Enumerations

enum  rng_status {
  RNG_STATUS_INITIAL,
  RNG_STATUS_CHECKING,
  RNG_STATUS_UNIMPLEMENTED,
  RNG_STATUS_OK,
  RNG_STATUS_FAILED
}

Functions

static void RNG_ADD_WORK_ENTRY (rng_work_entry_t *work)

Detailed Description

These are flags which are used to configure the RNG driver at compilation time.

Most of them default to good values for normal operation, but some (INT_RNG and RNG_BASE_ADDR) need to be provided.

The terms 'defined' and 'undefined' refer to whether a #define (or -D on a compile command) has defined a given preprocessor symbol. If a given symbol is defined, then #ifdef <symbol> will succeed. Some symbols described below default to not having a definition, i.e. they are undefined.


Define Documentation

#define BYTES_TO_WORDS ( byte_count   )     (((byte_count)+sizeof(uint32_t)-1)/sizeof(uint32_t))

Calculate number of words needed to hold the given number of bytes.

Parameters:
byte_count Number of bytes
Returns:
Number of words

Referenced by OS_DEV_TASK().

#define RNG_ADD_ENTROPY ( value   ) 

Put entropy into the RNG's algorithm.

Parameters:
value 32-bit value to add to RNG's entropy.

Referenced by fsl_shw_add_entropy().

 
#define RNG_AUTO_SEED (  ) 
Value:
{                                                                             \
    register uint32_t control = RNG_READ_REGISTER(RNGC_CONTROL);              \
    RNG_WRITE_REGISTER(RNGC_CONTROL, control                                  \
                                    | RNGC_CONTROL_AUTO_SEED);                \
}

Configuring RNGC for self Test.

#define RNG_BASE_ADDR   RNGC_BASE_ADDR

Interrupt number for driver.

Base address of RNG component.

Referenced by rng_map_RNG_memory().

#define RNG_CHECK_READ   0

For rng_check_register_accessible(), check read permission on given register.

 
#define RNG_CHECK_SEED_ERR (  )     (RNG_READ_REGISTER(RNGC_ERROR) & RNGC_ERROR_STATUS_STAT_ERR)

Return non-zero in case of Error during Seed Generation

Referenced by OS_DEV_INIT(), and rng_drain_fifo().

 
#define RNG_CHECK_SELF_ERR (  )     (RNG_READ_REGISTER(RNGC_ERROR) & RNGC_ERROR_STATUS_ST_ERR)

Returns non-zero in case of Error during Self Test

Referenced by OS_DEV_INIT().

#define RNG_CHECK_WRITE   1

For rng_check_register_accessible(), check write permission on given register.

 
#define RNG_CLEAR_ALL_STATUS (  ) 
Value:

Clear all status, error and otherwise.

Referenced by OS_DEV_INIT(), and OS_DEV_ISR().

 
#define RNG_CLEAR_ERR (  ) 
Value:
{                                                                             \
    register uint32_t command = RNG_READ_REGISTER(RNGC_COMMAND);              \
    RNG_WRITE_REGISTER(RNGC_COMMAND, command                                  \
                                    | RNGC_COMMAND_CLEAR_ERROR);              \
}

Clearing the Error bits in Error Status Register

Referenced by OS_DEV_INIT(), and rng_drain_fifo().

#define RNG_DRIVER_NAME   "rng"

Name the driver will use to register itself to the kernel as the driver.

Referenced by OS_DEV_INIT(), and rng_setup_interrupt_handling().

 
#define RNG_GET_FIFO_SIZE (  ) 
Value:

Returns maximum number of 32-bit words in the RNG's output fifo.

Referenced by rng_grab_config_values().

 
#define RNG_GET_HIGH_ASSURANCE (  ) 
Value:

Return non-zero if the RNG is in High Assurance mode.

Referenced by OS_DEV_INIT(), and OS_DEV_ISR().

 
#define RNG_GET_RNG_TYPE (  ) 
Value:

Return RNG Type value. Should be RNG_TYPE_RNGA or RNG_TYPE_RNGC.

Referenced by rng_grab_config_values().

 
#define RNG_GET_STATUS (  )     RNG_READ_REGISTER(RNGC_ERROR)

Read and return the status register.

Referenced by OS_DEV_INIT().

 
#define RNG_GET_WORDS_IN_FIFO (  ) 
Value:

Returns number of 32-bit words currently in the RNG's output fifo.

Referenced by rng_drain_fifo().

 
#define RNG_GO (  ) 

Get the RNG started at generating output.

Referenced by OS_DEV_INIT().

 
#define RNG_HAS_BAD_KEY (  )     (RNG_READ_REGISTER(RNGC_ERROR) & RNGC_ERROR_STATUS_BAD_KEY)

Returns non-zero if Bad Key is selected

Referenced by OS_DEV_INIT().

 
#define RNG_HAS_ERROR (  )     (RNG_READ_REGISTER(RNGC_STATUS) & RNGC_STATUS_ERROR)

Returns non-zero if RNG device is reporting an error.

Referenced by OS_DEV_INIT(), and OS_DEV_ISR().

 
#define RNG_MASK_ALL_INTERRUPTS (  ) 
Value:

Wake the RNG from sleep (low-power) mode.

Mask interrupts so that the driver/OS will not see them.

Referenced by OS_DEV_INIT(), OS_DEV_ISR(), and rng_cleanup().

#define RNG_MAX_TRIES   100

This is the maximum number of times the driver will loop waiting for the RNG hardware to say that it has generated random data. It prevents the driver from stalling forever should there be a hardware problem.

Default value is 100. It should be revisited as CPU clocks speed up.

Referenced by rng_drain_fifo().

#define RNG_NO_FORCE_HIGH_ASSURANCE

If this flag is defined, the driver will not attempt to put the RNG into High Assurance mode.

If it is undefined, the driver will attempt to put the RNG into High Assurance mode. If RNG fails to go into High Assurance mode, the driver will fail to initialize.

In either case, if the RNG is already in this mode, the driver will operate normally.

 
#define RNG_OSCILLATOR_FAILED (  )     (RNG_READ_REGISTER(RNGC_ERROR) & RNGC_ERROR_STATUS_OSC_ERR)

Returns non-zero if RNG ring oscillators have failed.

Referenced by OS_DEV_INIT().

 
#define RNG_PUT_RNG_TO_SLEEP (  ) 

Put RNG to sleep if appropriate.

Referenced by OS_DEV_INIT().

 
#define RNG_READ_FIFO (  )     RNG_READ_REGISTER(RNGC_FIFO)

Get a random value from the RNG's output FIFO.

Referenced by rng_drain_fifo().

#define RNG_READ_REGISTER ( offset   )     os_read32(rng_base+(offset))

Read a 32-bit value from an RNG register. This macro depends upon rng_base. The os_read32() macro operates on 32-bit quantities, as do all RNG register reads.

Parameters:
offset Register byte offset within RNG.
Returns:
The value from the RNG's register.

Referenced by OS_DEV_INIT().

 
#define RNG_SEED_DONE (  )     ((RNG_READ_REGISTER(RNGC_STATUS) & RNGC_STATUS_SEED_DONE) != 0)

Return Non zero if SEEDING is DONE

Referenced by OS_DEV_ISR().

 
#define RNG_SELF_TEST (  ) 
Value:
{                                                                             \
    register uint32_t command = RNG_READ_REGISTER(RNGC_COMMAND);              \
    RNG_WRITE_REGISTER(RNGC_COMMAND, command                                  \
                                    | RNGC_COMMAND_SELF_TEST);                \
}

Configure RNG for Self Test

Referenced by OS_DEV_INIT().

 
#define RNG_SELF_TEST_DONE (  )     (RNG_READ_REGISTER(RNGC_STATUS) & RNGC_STATUS_ST_DONE)

Return non-zero if Self Test Done

Referenced by OS_DEV_ISR().

 
#define RNG_SET_HIGH_ASSURANCE (  ) 

Put RNG into High Assurance mode.

Referenced by OS_DEV_INIT().

 
#define RNG_SLEEP (  ) 

Put the RNG into sleep (low-power) mode.

Referenced by OS_DEV_ISR(), and rng_cleanup().

 
#define RNG_UNMASK_ALL_INTERRUPTS (  ) 
Value:

Unmask interrupts so that the driver/OS will see them.

Referenced by OS_DEV_INIT(), and rng_setup_interrupt_handling().

#define RNG_VERIFY_TYPE ( type   )     ((type) == RNG_TYPE_RNGC)

Verify Type value of RNG.

Returns true of OK, false if not.

Referenced by rng_grab_config_values().

 
#define RNG_WAKE (  )     1

Wake the RNG from sleep (low-power) mode.

Referenced by OS_DEV_INIT().

 
#define RNG_WAKE_FROM_SLEEP (  ) 

Wake RNG from sleep if necessary.

 
#define RNG_WORKING (  ) 
#define RNG_WRITE_REGISTER ( offset,
value   )     (void)os_write32(rng_base+(offset), value)

Write a 32-bit value to an RNG register. This macro depends upon rng_base. The os_write32() macro operates on 32-bit quantities, as do all RNG register writes.

Parameters:
offset Register byte offset within RNG.
value 32-bit value to store into the register
Returns:
(void)

Typedef Documentation

typedef enum rng_status rng_status_t

Gives high-level view of state of the RNG


Enumeration Type Documentation

enum rng_status

Gives high-level view of state of the RNG

Enumerator:
RNG_STATUS_INITIAL 

Driver status before ever starting.

RNG_STATUS_CHECKING 

During driver initialization.

RNG_STATUS_UNIMPLEMENTED 

Hardware is non-existent / unreachable.

RNG_STATUS_OK 

Hardware is In Secure or Default state.

RNG_STATUS_FAILED 

Hardware is In Failed state / other fatal problem. Driver is still able to read/write some registers, but cannot get Random data.


Function Documentation

static void RNG_ADD_WORK_ENTRY ( rng_work_entry_t work  )  [inline, static]

Add an work item to a work list. Item will be marked incomplete.

Parameters:
work Work entry to place at tail of list.
Returns:
none

References rng_work_entry::completed, os_dev_schedule_task, and rng_work_queue.

Referenced by fsl_shw_get_random().

footer
©  Freescale Semiconductor, Inc., 2007.  All rights reserved.
Freescale Confidential Proprietary
NDA Required
doxygen