subsys: Add random subsystem
Some "random" drivers are not drivers at all: they just implement the function `sys_rand32_get()`. Move those to a random subsystem in preparation for a reorganization. Signed-off-by: Leandro Pereira <leandro.pereira@intel.com>
This commit is contained in:
parent
e08a5b0200
commit
adce1d1888
36 changed files with 70 additions and 64 deletions
|
@ -31,7 +31,7 @@
|
|||
#ifndef _ASMLANGUAGE
|
||||
|
||||
#include <misc/util.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
|
||||
#define ARCV2_TIMER0_INT_LVL IRQ_TIMER0
|
||||
#define ARCV2_TIMER0_INT_PRI 0
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
#ifndef _ASMLANGUAGE
|
||||
|
||||
#include <misc/util.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
|
||||
#define ARCV2_TIMER0_INT_LVL IRQ_TIMER0
|
||||
#define ARCV2_TIMER0_INT_PRI 0
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#ifndef _ASMLANGUAGE
|
||||
|
||||
#include <misc/util.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
|
||||
#define ARCV2_TIMER0_INT_LVL IRQ_TIMER0
|
||||
#define ARCV2_TIMER0_INT_PRI 0
|
||||
|
|
|
@ -105,7 +105,7 @@
|
|||
#ifndef _ASMLANGUAGE
|
||||
|
||||
#include <misc/util.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
#include <quark_se/shared_mem.h>
|
||||
|
||||
#define INT_ENABLE_ARC ~(0x00000001 << 8)
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <nrf.h>
|
||||
#include <device.h>
|
||||
#include <misc/util.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
|
||||
#endif /* !_ASMLANGUAGE */
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include <nrf.h>
|
||||
#include <device.h>
|
||||
#include <misc/util.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
|
||||
#endif /* !_ASMLANGUAGE */
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ extern "C" {
|
|||
#include <fsl_common.h>
|
||||
#include <device.h>
|
||||
#include <misc/util.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
|
||||
/* For IMG_MANAGER */
|
||||
#if defined(CONFIG_SOC_FLASH_MCUX)
|
||||
|
|
|
@ -54,7 +54,7 @@ extern "C" {
|
|||
|
||||
#include <device.h>
|
||||
#include <misc/util.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
|
||||
#endif /* !_ASMLANGUAGE */
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ extern "C" {
|
|||
#include <fsl_common.h>
|
||||
#include <device.h>
|
||||
#include <misc/util.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
|
||||
#endif /* !_ASMLANGUAGE */
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <device.h>
|
||||
#include <misc/util.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
|
||||
#include <stm32f0xx.h>
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <device.h>
|
||||
#include <misc/util.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
|
||||
#include <stm32f1xx.h>
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
#include <device.h>
|
||||
#include <misc/util.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
|
||||
#include <stm32f3xx.h>
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include <device.h>
|
||||
#include <misc/util.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
|
||||
#include <stm32f4xx.h>
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ extern "C" {
|
|||
|
||||
#include <device.h>
|
||||
#include <misc/util.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
|
||||
/* uart configuration settings */
|
||||
#if defined(CONFIG_UART_STELLARIS)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#ifndef _ASMLANGUAGE
|
||||
#include <device.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
#endif
|
||||
|
||||
#define INT_VEC_IRQ0 0x20 /* vector number for IRQ0 */
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#ifndef _ASMLANGUAGE
|
||||
#include <device.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#ifndef _ASMLANGUAGE
|
||||
#include <device.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_IOAPIC
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include <misc/byteorder.h>
|
||||
#include <string.h>
|
||||
#include <rand32.h>
|
||||
#include <random/rand32.h>
|
||||
|
||||
#include <gpio.h>
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include <net/net_if.h>
|
||||
#include <net/net_pkt.h>
|
||||
#include <misc/byteorder.h>
|
||||
#include <rand32.h>
|
||||
#include <random/rand32.h>
|
||||
|
||||
#include "fsl_xcvr.h"
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include <misc/byteorder.h>
|
||||
#include <string.h>
|
||||
#include <rand32.h>
|
||||
#include <random/rand32.h>
|
||||
|
||||
#include <gpio.h>
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
#include <misc/byteorder.h>
|
||||
#include <string.h>
|
||||
#include <rand32.h>
|
||||
#include <random/rand32.h>
|
||||
|
||||
#include <net/ieee802154_radio.h>
|
||||
#include <drivers/clock_control/nrf5_clock_control.h>
|
||||
|
|
|
@ -17,7 +17,6 @@ if RANDOM_GENERATOR
|
|||
|
||||
source "drivers/random/Kconfig.mcux"
|
||||
source "drivers/random/Kconfig.stm32"
|
||||
|
||||
source "drivers/random/Kconfig.esp32"
|
||||
|
||||
config RANDOM_HAS_DRIVER
|
||||
|
@ -48,35 +47,4 @@ config SYS_LOG_RANDOM_LEVEL
|
|||
- 3 INFO: write SYS_LOG_INF in addition to previous levels
|
||||
- 4 DEBUG: write SYS_LOG_DBG in addition to previous levels
|
||||
|
||||
config TEST_RANDOM_GENERATOR
|
||||
bool
|
||||
prompt "Non-random number generator"
|
||||
depends on RANDOM_GENERATOR && ! RANDOM_HAS_DRIVER
|
||||
default n
|
||||
help
|
||||
This option signifies that the kernel's random number APIs are
|
||||
permitted to return values that are not truly random.
|
||||
This capability is provided for testing purposes, when a truly random
|
||||
number generator is not available. The non-random number generator
|
||||
should not be used in a production environment.
|
||||
|
||||
config X86_TSC_RANDOM_GENERATOR
|
||||
bool
|
||||
prompt "x86 timestamp counter based number generator"
|
||||
depends on TEST_RANDOM_GENERATOR && X86
|
||||
default y
|
||||
help
|
||||
This options enables number generator based on timestamp counter
|
||||
of x86 boards, obtained with rdtsc instruction.
|
||||
|
||||
config TIMER_RANDOM_GENERATOR
|
||||
bool
|
||||
prompt "System timer clock based number generator"
|
||||
depends on TEST_RANDOM_GENERATOR && !X86_TSC_RANDOM_GENERATOR
|
||||
default y
|
||||
help
|
||||
This options enables number generator based on system timer
|
||||
clock. This number generator is not random and used for
|
||||
testing only.
|
||||
|
||||
endif
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
obj-$(CONFIG_RANDOM_MCUX_RNGA) += random_mcux_rnga.o
|
||||
obj-$(CONFIG_RANDOM_MCUX_TRNG) += random_mcux_trng.o
|
||||
obj-$(CONFIG_TIMER_RANDOM_GENERATOR) = rand32_timer.o
|
||||
obj-$(CONFIG_X86_TSC_RANDOM_GENERATOR) += rand32_timestamp.o
|
||||
obj-$(CONFIG_RANDOM_STM32_RNG) += random_stm32_rng.o
|
||||
obj-$(CONFIG_RANDOM_ESP32_RNG) += random_esp32.o
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <device.h>
|
||||
#include <random.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
#include <init.h>
|
||||
|
||||
#include "fsl_rnga.h"
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#include <device.h>
|
||||
#include <random.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
#include <init.h>
|
||||
|
||||
#include "fsl_trng.h"
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <kernel.h>
|
||||
#include <device.h>
|
||||
#include <random.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
#include <init.h>
|
||||
#include <misc/__assert.h>
|
||||
#include <misc/util.h>
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#include <misc/slist.h>
|
||||
#include <misc/util.h>
|
||||
#include <kernel_version.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
#include <kernel_arch_thread.h>
|
||||
#include <syscall.h>
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
#include <kernel.h>
|
||||
#include <misc/printk.h>
|
||||
#include <misc/stack.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
#include <linker/sections.h>
|
||||
#include <toolchain.h>
|
||||
#include <kernel_structs.h>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#include <logging/sys_log.h>
|
||||
|
||||
#include <board.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
#include <errno.h>
|
||||
#include <gpio.h>
|
||||
#include <net/net_app.h>
|
||||
|
|
|
@ -26,3 +26,5 @@ source "subsys/shell/Kconfig"
|
|||
source "subsys/usb/Kconfig"
|
||||
|
||||
source "subsys/dfu/Kconfig"
|
||||
|
||||
source "subsys/random/Kconfig"
|
||||
|
|
|
@ -6,6 +6,7 @@ obj-$(CONFIG_CONSOLE_SHELL) += shell/
|
|||
obj-$(CONFIG_CONSOLE_PULL) += console/
|
||||
obj-$(CONFIG_DISK_ACCESS) += disk/
|
||||
obj-$(CONFIG_CPLUSPLUS) += cpp/
|
||||
obj-$(CONFIG_MCUBOOT_IMG_MANAGER) += dfu/
|
||||
obj-y += logging/
|
||||
obj-y += debug/
|
||||
obj-$(CONFIG_MCUBOOT_IMG_MANAGER) += dfu/
|
||||
obj-y += random/
|
||||
|
|
35
subsys/random/Kconfig
Normal file
35
subsys/random/Kconfig
Normal file
|
@ -0,0 +1,35 @@
|
|||
# Kconfig - random configuration options
|
||||
#
|
||||
# Copyright (c) 2017 Intel Corporation
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
config TEST_RANDOM_GENERATOR
|
||||
bool
|
||||
prompt "Non-random number generator"
|
||||
depends on RANDOM_GENERATOR && ! RANDOM_HAS_DRIVER
|
||||
default n
|
||||
help
|
||||
This option signifies that the kernel's random number APIs are
|
||||
permitted to return values that are not truly random.
|
||||
This capability is provided for testing purposes, when a truly random
|
||||
number generator is not available. The non-random number generator
|
||||
should not be used in a production environment.
|
||||
|
||||
config X86_TSC_RANDOM_GENERATOR
|
||||
bool
|
||||
prompt "x86 timestamp counter based number generator"
|
||||
depends on TEST_RANDOM_GENERATOR && X86
|
||||
help
|
||||
This options enables number generator based on timestamp counter
|
||||
of x86 boards, obtained with rdtsc instruction.
|
||||
|
||||
config TIMER_RANDOM_GENERATOR
|
||||
bool
|
||||
prompt "System timer clock based number generator"
|
||||
depends on TEST_RANDOM_GENERATOR
|
||||
help
|
||||
This options enables number generator based on system timer
|
||||
clock. This number generator is not random and used for
|
||||
testing only.
|
2
subsys/random/Makefile
Normal file
2
subsys/random/Makefile
Normal file
|
@ -0,0 +1,2 @@
|
|||
obj-$(CONFIG_TIMER_RANDOM_GENERATOR) = rand32_timer.o
|
||||
obj-$(CONFIG_X86_TSC_RANDOM_GENERATOR) += rand32_timestamp.o
|
|
@ -14,7 +14,7 @@
|
|||
* provide a random number generator.
|
||||
*/
|
||||
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
#include <drivers/system_timer.h>
|
||||
#include <kernel.h>
|
||||
#include <atomic.h>
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
#include <kernel.h>
|
||||
#include <arch/cpu.h>
|
||||
#include <drivers/rand32.h>
|
||||
#include <random/rand32.h>
|
||||
|
||||
/**
|
||||
*
|
Loading…
Add table
Add a link
Reference in a new issue