diff --git a/boards/native/nrf_bsim/CMakeLists.txt b/boards/native/nrf_bsim/CMakeLists.txt index d55a52e1a53..6aeb3f01634 100644 --- a/boards/native/nrf_bsim/CMakeLists.txt +++ b/boards/native/nrf_bsim/CMakeLists.txt @@ -24,6 +24,7 @@ zephyr_library_sources( cpu_wait.c argparse.c nsi_if.c + native_remap.c soc/nrfx_coredep.c common/bstests_entry.c common/cmsis/cmsis.c diff --git a/boards/native/nrf_bsim/native_remap.c b/boards/native/nrf_bsim/native_remap.c new file mode 100644 index 00000000000..d8b756a9576 --- /dev/null +++ b/boards/native/nrf_bsim/native_remap.c @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include +#include "NHW_misc.h" + +bool native_emb_addr_remap(void **addr) +{ + return nhw_convert_RAM_addr(addr); +} diff --git a/soc/native/inf_clock/CMakeLists.txt b/soc/native/inf_clock/CMakeLists.txt index 7f9d09b2c34..494ea4de774 100644 --- a/soc/native/inf_clock/CMakeLists.txt +++ b/soc/native/inf_clock/CMakeLists.txt @@ -8,6 +8,7 @@ zephyr_library_compile_definitions(NO_POSIX_CHEATS) zephyr_library_sources( soc.c native_tasks.c + native_remap.c ) zephyr_library_include_directories( diff --git a/soc/native/inf_clock/native_remap.c b/soc/native/inf_clock/native_remap.c new file mode 100644 index 00000000000..4aa6bd1129e --- /dev/null +++ b/soc/native/inf_clock/native_remap.c @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include +#include + +/** + * Dummy version which does nothing + * Boards which do not have a better implementation can use this + */ +__weak bool native_emb_addr_remap(void **addr) +{ + return false; +} diff --git a/soc/native/inf_clock/soc.h b/soc/native/inf_clock/soc.h index 36d54ac3f72..c7de6c22802 100644 --- a/soc/native/inf_clock/soc.h +++ b/soc/native/inf_clock/soc.h @@ -7,6 +7,7 @@ #ifndef _POSIX_SOC_INF_CLOCK_SOC_H #define _POSIX_SOC_INF_CLOCK_SOC_H +#include #include #include "board_soc.h" #include "posix_soc.h" @@ -18,6 +19,20 @@ extern "C" { void posix_soc_clean_up(void); +/** + * Remap an embedded device address, into an address which can be used in the simulated native + * board. + * + * If the provided address is not in a range known to this function it will not be modified and the + * function will return false. + * Otherwise the provided address pointer will be modified, and true returned. + * + * Note: The SOC provides a dummy version of this function which does nothing, + * so all boards will have an implementation. + * It is optional for boards to provide one if desired. + */ +bool native_emb_addr_remap(void **addr); + #ifdef __cplusplus } #endif