drivers entropy: fake_entropy_native_posix rename to _native_sim
Rename the driver files, binding and kconfig options, while deprecating the old binding and kconfig options. Uses in tree are replaced. Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
committed by
Benjamin Cabé
parent
3b1e60da90
commit
4338122248
@@ -702,7 +702,7 @@ host libC (:kconfig:option:`CONFIG_EXTERNAL_LIBC`):
|
||||
CAN, CAN native Linux, :kconfig:option:`CONFIG_CAN_NATIVE_LINUX`, All
|
||||
Console backend, :ref:`POSIX arch console <nsim_back_console>`, :kconfig:option:`CONFIG_POSIX_ARCH_CONSOLE`, All
|
||||
Display, :ref:`Display SDL <nsim_per_disp_sdl>`, :kconfig:option:`CONFIG_SDL_DISPLAY`, All
|
||||
Entropy, :ref:`Native posix entropy <nsim_per_entr>`, :kconfig:option:`CONFIG_FAKE_ENTROPY_NATIVE_POSIX`, All
|
||||
Entropy, :ref:`Native simulator entropy <nsim_per_entr>`, :kconfig:option:`CONFIG_FAKE_ENTROPY_NATIVE_SIM`, All
|
||||
EEPROM, EEPROM simulator, :kconfig:option:`CONFIG_EEPROM_SIMULATOR`, All
|
||||
EEPROM, EEPROM emulator, :kconfig:option:`CONFIG_EEPROM_EMULATOR`, All
|
||||
Ethernet, :ref:`Eth native_tap <nsim_per_ethe>`, :kconfig:option:`CONFIG_ETH_NATIVE_TAP`, All
|
||||
|
||||
@@ -165,7 +165,7 @@
|
||||
|
||||
rng: rng {
|
||||
status = "okay";
|
||||
compatible = "zephyr,native-posix-rng";
|
||||
compatible = "zephyr,native-sim-rng";
|
||||
};
|
||||
|
||||
counter0: counter {
|
||||
|
||||
@@ -18,8 +18,8 @@ zephyr_library_sources_ifdef(CONFIG_ENTROPY_SAM_RNG entropy_sam.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_ENTROPY_SMARTBOND_TRNG entropy_smartbond.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_ENTROPY_STM32_RNG entropy_stm32.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_ENTROPY_LITEX_RNG entropy_litex.c)
|
||||
if(CONFIG_FAKE_ENTROPY_NATIVE_POSIX)
|
||||
zephyr_library_sources(fake_entropy_native_posix.c)
|
||||
if(CONFIG_FAKE_ENTROPY_NATIVE_SIM)
|
||||
zephyr_library_sources(fake_entropy_native_sim.c)
|
||||
if(CONFIG_NATIVE_LIBRARY)
|
||||
target_sources(native_simulator INTERFACE fake_entropy_native_bottom.c)
|
||||
else()
|
||||
|
||||
@@ -30,7 +30,7 @@ source "drivers/entropy/Kconfig.nrf5"
|
||||
source "drivers/entropy/Kconfig.nrf_cracen"
|
||||
source "drivers/entropy/Kconfig.sam"
|
||||
source "drivers/entropy/Kconfig.smartbond"
|
||||
source "drivers/entropy/Kconfig.native_posix"
|
||||
source "drivers/entropy/Kconfig.native_sim"
|
||||
source "drivers/entropy/Kconfig.rv32m1"
|
||||
source "drivers/entropy/Kconfig.litex"
|
||||
source "drivers/entropy/Kconfig.gecko"
|
||||
|
||||
@@ -1,23 +1,37 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
config FAKE_ENTROPY_NATIVE_POSIX
|
||||
bool "Native posix entropy driver"
|
||||
config FAKE_ENTROPY_NATIVE_SIM
|
||||
bool "Native simulator entropy driver"
|
||||
default y
|
||||
depends on DT_HAS_ZEPHYR_NATIVE_POSIX_RNG_ENABLED
|
||||
depends on DT_HAS_ZEPHYR_NATIVE_POSIX_RNG_ENABLED || DT_HAS_ZEPHYR_NATIVE_SIM_RNG_ENABLED
|
||||
select ENTROPY_HAS_DRIVER
|
||||
help
|
||||
This option enables the test random number generator for the
|
||||
native_posix board (ARCH_POSIX). This is based on the host random() API.
|
||||
native_sim board (ARCH_POSIX). This is based on the host random() API.
|
||||
Note that this entropy generator is only meant for test purposes and does
|
||||
not generate real entropy.
|
||||
It actually generates always the same sequence of random numbers if
|
||||
initialized with the same seed.
|
||||
|
||||
config FAKE_ENTROPY_NATIVE_POSIX_SEED_BY_DEFAULT
|
||||
config FAKE_ENTROPY_NATIVE_SIM_SEED_BY_DEFAULT
|
||||
bool "Seed the generator by default"
|
||||
default y
|
||||
depends on FAKE_ENTROPY_NATIVE_POSIX
|
||||
depends on FAKE_ENTROPY_NATIVE_SIM
|
||||
help
|
||||
Apply a seed by default, even if the user does not request it through the command line.
|
||||
Disabling this feature allows some other component to seed the host standard library random
|
||||
generator without this component's default initialization interfering.
|
||||
|
||||
config FAKE_ENTROPY_NATIVE_POSIX
|
||||
bool "Native posix entropy driver (deprecated)"
|
||||
select FAKE_ENTROPY_NATIVE_SIM
|
||||
select DEPRECATED
|
||||
help
|
||||
Deprecated option in favour of FAKE_ENTROPY_NATIVE_SIM
|
||||
|
||||
config FAKE_ENTROPY_NATIVE_POSIX_SEED_BY_DEFAULT
|
||||
bool "Seed the generator by default (deprecated)"
|
||||
depends on FAKE_ENTROPY_NATIVE_POSIX
|
||||
select DEPRECATED
|
||||
help
|
||||
Deprecated option. Replaced by FAKE_ENTROPY_NATIVE_SIM_SEED_BY_DEFAULT
|
||||
@@ -3,8 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Bottom/Linux side of the pseudo-random entropy generator for
|
||||
* ARCH_POSIX architecture
|
||||
* Bottom/Linux side of the pseudo-random entropy generator for the native simulator
|
||||
*/
|
||||
|
||||
#undef _XOPEN_SOURCE
|
||||
|
||||
@@ -3,15 +3,21 @@
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Pseudo-random entropy generator for the ARCH_POSIX architecture:
|
||||
* Following the principle of reproducibility of the native_posix board
|
||||
* Pseudo-random entropy generator for native simulator based target boards:
|
||||
* Following the principle of reproducibility of the native_sim board
|
||||
* this entropy device will always generate the same random sequence when
|
||||
* initialized with the same seed
|
||||
*
|
||||
* This entropy source should only be used for testing.
|
||||
*/
|
||||
|
||||
#include <zephyr/devicetree.h>
|
||||
#if DT_HAS_COMPAT_STATUS_OKAY(zephyr_native_posix_rng)
|
||||
#define DT_DRV_COMPAT zephyr_native_posix_rng
|
||||
#warning "zephyr,native-posix-rng is deprecated in favor of zephyr,native-sim-rng"
|
||||
#else
|
||||
#define DT_DRV_COMPAT zephyr_native_sim_rng
|
||||
#endif
|
||||
|
||||
#include <zephyr/device.h>
|
||||
#include <zephyr/drivers/entropy.h>
|
||||
@@ -21,7 +27,7 @@
|
||||
#include <string.h>
|
||||
#include <zephyr/arch/posix/posix_trace.h>
|
||||
#include "soc.h"
|
||||
#include "cmdline.h" /* native_posix command line options header */
|
||||
#include "cmdline.h" /* native_sim command line options header */
|
||||
#include "nsi_host_trampolines.h"
|
||||
#include "fake_entropy_native_bottom.h"
|
||||
|
||||
@@ -29,7 +35,7 @@ static unsigned int seed = 0x5678;
|
||||
static bool seed_random;
|
||||
static bool seed_set;
|
||||
|
||||
static int entropy_native_posix_get_entropy(const struct device *dev,
|
||||
static int entropy_native_sim_get_entropy(const struct device *dev,
|
||||
uint8_t *buffer,
|
||||
uint16_t length)
|
||||
{
|
||||
@@ -55,26 +61,26 @@ static int entropy_native_posix_get_entropy(const struct device *dev,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int entropy_native_posix_get_entropy_isr(const struct device *dev,
|
||||
static int entropy_native_sim_get_entropy_isr(const struct device *dev,
|
||||
uint8_t *buf,
|
||||
uint16_t len, uint32_t flags)
|
||||
{
|
||||
ARG_UNUSED(flags);
|
||||
|
||||
/*
|
||||
* entropy_native_posix_get_entropy() is also safe for ISRs
|
||||
* entropy_native_sim_get_entropy() is also safe for ISRs
|
||||
* and always produces data.
|
||||
*/
|
||||
entropy_native_posix_get_entropy(dev, buf, len);
|
||||
entropy_native_sim_get_entropy(dev, buf, len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static int entropy_native_posix_init(const struct device *dev)
|
||||
static int entropy_native_sim_init(const struct device *dev)
|
||||
{
|
||||
ARG_UNUSED(dev);
|
||||
if (seed_set || seed_random ||
|
||||
IS_ENABLED(CONFIG_FAKE_ENTROPY_NATIVE_POSIX_SEED_BY_DEFAULT)) {
|
||||
IS_ENABLED(CONFIG_FAKE_ENTROPY_NATIVE_SIM_SEED_BY_DEFAULT)) {
|
||||
entropy_native_seed(seed, seed_random);
|
||||
}
|
||||
posix_print_warning("WARNING: "
|
||||
@@ -82,16 +88,16 @@ static int entropy_native_posix_init(const struct device *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static DEVICE_API(entropy, entropy_native_posix_api_funcs) = {
|
||||
.get_entropy = entropy_native_posix_get_entropy,
|
||||
.get_entropy_isr = entropy_native_posix_get_entropy_isr
|
||||
static DEVICE_API(entropy, entropy_native_sim_api_funcs) = {
|
||||
.get_entropy = entropy_native_sim_get_entropy,
|
||||
.get_entropy_isr = entropy_native_sim_get_entropy_isr
|
||||
};
|
||||
|
||||
DEVICE_DT_INST_DEFINE(0,
|
||||
entropy_native_posix_init, NULL,
|
||||
entropy_native_sim_init, NULL,
|
||||
NULL, NULL,
|
||||
PRE_KERNEL_1, CONFIG_ENTROPY_INIT_PRIORITY,
|
||||
&entropy_native_posix_api_funcs);
|
||||
&entropy_native_sim_api_funcs);
|
||||
|
||||
static void seed_was_set(char *argv, int offset)
|
||||
{
|
||||
@@ -6,3 +6,5 @@ description: Native POSIX RNG/Entropy
|
||||
compatible: "zephyr,native-posix-rng"
|
||||
|
||||
include: base.yaml
|
||||
|
||||
# This binding is deprecated in favor of zephyr,native-sim-rng
|
||||
|
||||
8
dts/bindings/rng/zephyr,native-sim-rng.yaml
Normal file
8
dts/bindings/rng/zephyr,native-sim-rng.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
# Copyright (c) 2025, Nordic Semiconductor ASA
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
description: Native simulator RNG/Entropy
|
||||
|
||||
compatible: "zephyr,native-sim-rng"
|
||||
|
||||
include: base.yaml
|
||||
@@ -1758,8 +1758,8 @@ class ProjectBuilder(FilterBuilder):
|
||||
|
||||
if(self.options.seed is not None and instance.platform.name.startswith("native_")):
|
||||
self.parse_generated()
|
||||
if('CONFIG_FAKE_ENTROPY_NATIVE_POSIX' in self.defconfig and
|
||||
self.defconfig['CONFIG_FAKE_ENTROPY_NATIVE_POSIX'] == 'y'):
|
||||
if('CONFIG_FAKE_ENTROPY_NATIVE_SIM' in self.defconfig and
|
||||
self.defconfig['CONFIG_FAKE_ENTROPY_NATIVE_SIM'] == 'y'):
|
||||
instance.handler.seed = self.options.seed
|
||||
|
||||
if self.options.extra_test_args and instance.platform.arch == "posix":
|
||||
|
||||
@@ -2257,7 +2257,7 @@ TESTDATA_14 = [
|
||||
234,
|
||||
'native_sim',
|
||||
'posix',
|
||||
{'CONFIG_FAKE_ENTROPY_NATIVE_POSIX': 'y'},
|
||||
{'CONFIG_FAKE_ENTROPY_NATIVE_SIM': 'y'},
|
||||
'pytest',
|
||||
True,
|
||||
True,
|
||||
@@ -2272,7 +2272,7 @@ TESTDATA_14 = [
|
||||
None,
|
||||
'native_sim',
|
||||
'not posix',
|
||||
{'CONFIG_FAKE_ENTROPY_NATIVE_POSIX': 'y'},
|
||||
{'CONFIG_FAKE_ENTROPY_NATIVE_SIM': 'y'},
|
||||
'not pytest',
|
||||
False,
|
||||
False,
|
||||
@@ -2287,7 +2287,7 @@ TESTDATA_14 = [
|
||||
234,
|
||||
'native_sim',
|
||||
'posix',
|
||||
{'CONFIG_FAKE_ENTROPY_NATIVE_POSIX': 'y'},
|
||||
{'CONFIG_FAKE_ENTROPY_NATIVE_SIM': 'y'},
|
||||
'pytest',
|
||||
False,
|
||||
False,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# Copyright (c) 2024 Intel Corporation
|
||||
|
||||
config FAKE_ENTROPY_NATIVE_POSIX
|
||||
config FAKE_ENTROPY_NATIVE_SIM
|
||||
default y
|
||||
|
||||
source "Kconfig.zephyr"
|
||||
|
||||
@@ -153,7 +153,7 @@
|
||||
|
||||
rng: rng {
|
||||
status = "okay";
|
||||
compatible = "zephyr,native-posix-rng";
|
||||
compatible = "zephyr,native-sim-rng";
|
||||
};
|
||||
|
||||
counter0: counter {
|
||||
|
||||
Reference in New Issue
Block a user