Skip to content

Commit 4338122

Browse files
aescolarkartben
authored andcommitted
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>
1 parent 3b1e60d commit 4338122

File tree

13 files changed

+63
-34
lines changed

13 files changed

+63
-34
lines changed

boards/native/native_sim/doc/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ host libC (:kconfig:option:`CONFIG_EXTERNAL_LIBC`):
702702
CAN, CAN native Linux, :kconfig:option:`CONFIG_CAN_NATIVE_LINUX`, All
703703
Console backend, :ref:`POSIX arch console <nsim_back_console>`, :kconfig:option:`CONFIG_POSIX_ARCH_CONSOLE`, All
704704
Display, :ref:`Display SDL <nsim_per_disp_sdl>`, :kconfig:option:`CONFIG_SDL_DISPLAY`, All
705-
Entropy, :ref:`Native posix entropy <nsim_per_entr>`, :kconfig:option:`CONFIG_FAKE_ENTROPY_NATIVE_POSIX`, All
705+
Entropy, :ref:`Native simulator entropy <nsim_per_entr>`, :kconfig:option:`CONFIG_FAKE_ENTROPY_NATIVE_SIM`, All
706706
EEPROM, EEPROM simulator, :kconfig:option:`CONFIG_EEPROM_SIMULATOR`, All
707707
EEPROM, EEPROM emulator, :kconfig:option:`CONFIG_EEPROM_EMULATOR`, All
708708
Ethernet, :ref:`Eth native_tap <nsim_per_ethe>`, :kconfig:option:`CONFIG_ETH_NATIVE_TAP`, All

boards/native/native_sim/native_sim.dts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@
165165

166166
rng: rng {
167167
status = "okay";
168-
compatible = "zephyr,native-posix-rng";
168+
compatible = "zephyr,native-sim-rng";
169169
};
170170

171171
counter0: counter {

drivers/entropy/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ zephyr_library_sources_ifdef(CONFIG_ENTROPY_SAM_RNG entropy_sam.c)
1818
zephyr_library_sources_ifdef(CONFIG_ENTROPY_SMARTBOND_TRNG entropy_smartbond.c)
1919
zephyr_library_sources_ifdef(CONFIG_ENTROPY_STM32_RNG entropy_stm32.c)
2020
zephyr_library_sources_ifdef(CONFIG_ENTROPY_LITEX_RNG entropy_litex.c)
21-
if(CONFIG_FAKE_ENTROPY_NATIVE_POSIX)
22-
zephyr_library_sources(fake_entropy_native_posix.c)
21+
if(CONFIG_FAKE_ENTROPY_NATIVE_SIM)
22+
zephyr_library_sources(fake_entropy_native_sim.c)
2323
if(CONFIG_NATIVE_LIBRARY)
2424
target_sources(native_simulator INTERFACE fake_entropy_native_bottom.c)
2525
else()

drivers/entropy/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ source "drivers/entropy/Kconfig.nrf5"
3030
source "drivers/entropy/Kconfig.nrf_cracen"
3131
source "drivers/entropy/Kconfig.sam"
3232
source "drivers/entropy/Kconfig.smartbond"
33-
source "drivers/entropy/Kconfig.native_posix"
33+
source "drivers/entropy/Kconfig.native_sim"
3434
source "drivers/entropy/Kconfig.rv32m1"
3535
source "drivers/entropy/Kconfig.litex"
3636
source "drivers/entropy/Kconfig.gecko"
Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,37 @@
11
# SPDX-License-Identifier: Apache-2.0
22

3-
config FAKE_ENTROPY_NATIVE_POSIX
4-
bool "Native posix entropy driver"
3+
config FAKE_ENTROPY_NATIVE_SIM
4+
bool "Native simulator entropy driver"
55
default y
6-
depends on DT_HAS_ZEPHYR_NATIVE_POSIX_RNG_ENABLED
6+
depends on DT_HAS_ZEPHYR_NATIVE_POSIX_RNG_ENABLED || DT_HAS_ZEPHYR_NATIVE_SIM_RNG_ENABLED
77
select ENTROPY_HAS_DRIVER
88
help
99
This option enables the test random number generator for the
10-
native_posix board (ARCH_POSIX). This is based on the host random() API.
10+
native_sim board (ARCH_POSIX). This is based on the host random() API.
1111
Note that this entropy generator is only meant for test purposes and does
1212
not generate real entropy.
1313
It actually generates always the same sequence of random numbers if
1414
initialized with the same seed.
1515

16-
config FAKE_ENTROPY_NATIVE_POSIX_SEED_BY_DEFAULT
16+
config FAKE_ENTROPY_NATIVE_SIM_SEED_BY_DEFAULT
1717
bool "Seed the generator by default"
1818
default y
19-
depends on FAKE_ENTROPY_NATIVE_POSIX
19+
depends on FAKE_ENTROPY_NATIVE_SIM
2020
help
2121
Apply a seed by default, even if the user does not request it through the command line.
2222
Disabling this feature allows some other component to seed the host standard library random
2323
generator without this component's default initialization interfering.
24+
25+
config FAKE_ENTROPY_NATIVE_POSIX
26+
bool "Native posix entropy driver (deprecated)"
27+
select FAKE_ENTROPY_NATIVE_SIM
28+
select DEPRECATED
29+
help
30+
Deprecated option in favour of FAKE_ENTROPY_NATIVE_SIM
31+
32+
config FAKE_ENTROPY_NATIVE_POSIX_SEED_BY_DEFAULT
33+
bool "Seed the generator by default (deprecated)"
34+
depends on FAKE_ENTROPY_NATIVE_POSIX
35+
select DEPRECATED
36+
help
37+
Deprecated option. Replaced by FAKE_ENTROPY_NATIVE_SIM_SEED_BY_DEFAULT

drivers/entropy/fake_entropy_native_bottom.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
6-
* Bottom/Linux side of the pseudo-random entropy generator for
7-
* ARCH_POSIX architecture
6+
* Bottom/Linux side of the pseudo-random entropy generator for the native simulator
87
*/
98

109
#undef _XOPEN_SOURCE

drivers/entropy/fake_entropy_native_posix.c renamed to drivers/entropy/fake_entropy_native_sim.c

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,21 @@
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
6-
* Pseudo-random entropy generator for the ARCH_POSIX architecture:
7-
* Following the principle of reproducibility of the native_posix board
6+
* Pseudo-random entropy generator for native simulator based target boards:
7+
* Following the principle of reproducibility of the native_sim board
88
* this entropy device will always generate the same random sequence when
99
* initialized with the same seed
1010
*
1111
* This entropy source should only be used for testing.
1212
*/
1313

14+
#include <zephyr/devicetree.h>
15+
#if DT_HAS_COMPAT_STATUS_OKAY(zephyr_native_posix_rng)
1416
#define DT_DRV_COMPAT zephyr_native_posix_rng
17+
#warning "zephyr,native-posix-rng is deprecated in favor of zephyr,native-sim-rng"
18+
#else
19+
#define DT_DRV_COMPAT zephyr_native_sim_rng
20+
#endif
1521

1622
#include <zephyr/device.h>
1723
#include <zephyr/drivers/entropy.h>
@@ -21,15 +27,15 @@
2127
#include <string.h>
2228
#include <zephyr/arch/posix/posix_trace.h>
2329
#include "soc.h"
24-
#include "cmdline.h" /* native_posix command line options header */
30+
#include "cmdline.h" /* native_sim command line options header */
2531
#include "nsi_host_trampolines.h"
2632
#include "fake_entropy_native_bottom.h"
2733

2834
static unsigned int seed = 0x5678;
2935
static bool seed_random;
3036
static bool seed_set;
3137

32-
static int entropy_native_posix_get_entropy(const struct device *dev,
38+
static int entropy_native_sim_get_entropy(const struct device *dev,
3339
uint8_t *buffer,
3440
uint16_t length)
3541
{
@@ -55,43 +61,43 @@ static int entropy_native_posix_get_entropy(const struct device *dev,
5561
return 0;
5662
}
5763

58-
static int entropy_native_posix_get_entropy_isr(const struct device *dev,
64+
static int entropy_native_sim_get_entropy_isr(const struct device *dev,
5965
uint8_t *buf,
6066
uint16_t len, uint32_t flags)
6167
{
6268
ARG_UNUSED(flags);
6369

6470
/*
65-
* entropy_native_posix_get_entropy() is also safe for ISRs
71+
* entropy_native_sim_get_entropy() is also safe for ISRs
6672
* and always produces data.
6773
*/
68-
entropy_native_posix_get_entropy(dev, buf, len);
74+
entropy_native_sim_get_entropy(dev, buf, len);
6975

7076
return len;
7177
}
7278

73-
static int entropy_native_posix_init(const struct device *dev)
79+
static int entropy_native_sim_init(const struct device *dev)
7480
{
7581
ARG_UNUSED(dev);
7682
if (seed_set || seed_random ||
77-
IS_ENABLED(CONFIG_FAKE_ENTROPY_NATIVE_POSIX_SEED_BY_DEFAULT)) {
83+
IS_ENABLED(CONFIG_FAKE_ENTROPY_NATIVE_SIM_SEED_BY_DEFAULT)) {
7884
entropy_native_seed(seed, seed_random);
7985
}
8086
posix_print_warning("WARNING: "
8187
"Using a test - not safe - entropy source\n");
8288
return 0;
8389
}
8490

85-
static DEVICE_API(entropy, entropy_native_posix_api_funcs) = {
86-
.get_entropy = entropy_native_posix_get_entropy,
87-
.get_entropy_isr = entropy_native_posix_get_entropy_isr
91+
static DEVICE_API(entropy, entropy_native_sim_api_funcs) = {
92+
.get_entropy = entropy_native_sim_get_entropy,
93+
.get_entropy_isr = entropy_native_sim_get_entropy_isr
8894
};
8995

9096
DEVICE_DT_INST_DEFINE(0,
91-
entropy_native_posix_init, NULL,
97+
entropy_native_sim_init, NULL,
9298
NULL, NULL,
9399
PRE_KERNEL_1, CONFIG_ENTROPY_INIT_PRIORITY,
94-
&entropy_native_posix_api_funcs);
100+
&entropy_native_sim_api_funcs);
95101

96102
static void seed_was_set(char *argv, int offset)
97103
{

dts/bindings/rng/zephyr,native-posix-rng.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ description: Native POSIX RNG/Entropy
66
compatible: "zephyr,native-posix-rng"
77

88
include: base.yaml
9+
10+
# This binding is deprecated in favor of zephyr,native-sim-rng
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2025, Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
description: Native simulator RNG/Entropy
5+
6+
compatible: "zephyr,native-sim-rng"
7+
8+
include: base.yaml

scripts/pylib/twister/twisterlib/runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1758,8 +1758,8 @@ def run(self):
17581758

17591759
if(self.options.seed is not None and instance.platform.name.startswith("native_")):
17601760
self.parse_generated()
1761-
if('CONFIG_FAKE_ENTROPY_NATIVE_POSIX' in self.defconfig and
1762-
self.defconfig['CONFIG_FAKE_ENTROPY_NATIVE_POSIX'] == 'y'):
1761+
if('CONFIG_FAKE_ENTROPY_NATIVE_SIM' in self.defconfig and
1762+
self.defconfig['CONFIG_FAKE_ENTROPY_NATIVE_SIM'] == 'y'):
17631763
instance.handler.seed = self.options.seed
17641764

17651765
if self.options.extra_test_args and instance.platform.arch == "posix":

0 commit comments

Comments
 (0)