drivers: entropy native: Refactor to support embedded libCs
Refactor the host libC accesses to use the native simulator host trampolines. In this way we support building this driver with embedded libCs. Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
parent
265010a4b6
commit
8252e99608
|
@ -109,7 +109,7 @@ host libC (:kconfig:option:`CONFIG_EXTERNAL_LIBC`).
|
|||
can, can native posix, :kconfig:option:`CONFIG_CAN_NATIVE_POSIX_LINUX`, host libC
|
||||
console backend, POSIX arch console, :kconfig:option:`CONFIG_POSIX_ARCH_CONSOLE`, all
|
||||
display, display SDL, :kconfig:option:`CONFIG_SDL_DISPLAY`, all
|
||||
entropy, native posix entropy, :kconfig:option:`CONFIG_FAKE_ENTROPY_NATIVE_POSIX`, host libC
|
||||
entropy, native posix entropy, :kconfig:option:`CONFIG_FAKE_ENTROPY_NATIVE_POSIX`, all
|
||||
eprom, eprom emulator, :kconfig:option:`CONFIG_EEPROM_EMULATOR`, host libC
|
||||
ethernet, eth native_posix, :kconfig:option:`CONFIG_ETH_NATIVE_POSIX`, host libC
|
||||
flash, flash simulator, :kconfig:option:`CONFIG_FLASH_SIMULATOR`, host libC
|
||||
|
|
|
@ -4,7 +4,6 @@ config FAKE_ENTROPY_NATIVE_POSIX
|
|||
bool "Native posix entropy driver"
|
||||
default y
|
||||
depends on DT_HAS_ZEPHYR_NATIVE_POSIX_RNG_ENABLED
|
||||
depends on EXTERNAL_LIBC
|
||||
select ENTROPY_HAS_DRIVER
|
||||
help
|
||||
This option enables the test random number generator for the
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <zephyr/arch/posix/posix_trace.h>
|
||||
#include "soc.h"
|
||||
#include "cmdline.h" /* native_posix command line options header */
|
||||
#include "nsi_host_trampolines.h"
|
||||
|
||||
static unsigned int seed = 0x5678;
|
||||
|
||||
|
@ -36,7 +37,7 @@ static int entropy_native_posix_get_entropy(const struct device *dev,
|
|||
* Note that only 1 thread (Zephyr thread or HW models), runs at
|
||||
* a time, therefore there is no need to use random_r()
|
||||
*/
|
||||
long int value = random();
|
||||
long value = nsi_host_random();
|
||||
|
||||
size_t to_copy = MIN(length, sizeof(long int));
|
||||
|
||||
|
@ -64,7 +65,7 @@ static int entropy_native_posix_get_entropy_isr(const struct device *dev,
|
|||
static int entropy_native_posix_init(const struct device *dev)
|
||||
{
|
||||
ARG_UNUSED(dev);
|
||||
srandom(seed);
|
||||
nsi_host_srandom(seed);
|
||||
posix_print_warning("WARNING: "
|
||||
"Using a test - not safe - entropy source\n");
|
||||
return 0;
|
||||
|
|
Loading…
Reference in a new issue