Skip to content

Commit 64aa257

Browse files
aescolargmarull
authored andcommitted
[nrf fromtree] boards native: Add function to remap embedded address
Add a function which can be used to remap embedded device address, into addresses which can be used in the simulated native boards. For the nrf_bsim boards we provide an actual implementation. For other boards, we provide an optional dummy version which does nothing. It is up to each board implementation to decide if they want to provide one or use the dummy. Signed-off-by: Alberto Escolar Piedras <[email protected]> (cherry picked from commit 5efe751)
1 parent dd15aca commit 64aa257

File tree

5 files changed

+45
-0
lines changed

5 files changed

+45
-0
lines changed

boards/native/nrf_bsim/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ zephyr_library_sources(
2424
cpu_wait.c
2525
argparse.c
2626
nsi_if.c
27+
native_remap.c
2728
soc/nrfx_coredep.c
2829
common/bstests_entry.c
2930
common/cmsis/cmsis.c
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#include <stdbool.h>
7+
#include "NHW_misc.h"
8+
9+
bool native_emb_addr_remap(void **addr)
10+
{
11+
return nhw_convert_RAM_addr(addr);
12+
}

soc/native/inf_clock/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ zephyr_library_compile_definitions(NO_POSIX_CHEATS)
88
zephyr_library_sources(
99
soc.c
1010
native_tasks.c
11+
native_remap.c
1112
)
1213

1314
zephyr_library_include_directories(
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
#include <stdbool.h>
7+
#include <zephyr/toolchain.h>
8+
9+
/**
10+
* Dummy version which does nothing
11+
* Boards which do not have a better implementation can use this
12+
*/
13+
__weak bool native_emb_addr_remap(void **addr)
14+
{
15+
return false;
16+
}

soc/native/inf_clock/soc.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef _POSIX_SOC_INF_CLOCK_SOC_H
88
#define _POSIX_SOC_INF_CLOCK_SOC_H
99

10+
#include <stdbool.h>
1011
#include <zephyr/toolchain.h>
1112
#include "board_soc.h"
1213
#include "posix_soc.h"
@@ -18,6 +19,20 @@ extern "C" {
1819

1920
void posix_soc_clean_up(void);
2021

22+
/**
23+
* Remap an embedded device address, into an address which can be used in the simulated native
24+
* board.
25+
*
26+
* If the provided address is not in a range known to this function it will not be modified and the
27+
* function will return false.
28+
* Otherwise the provided address pointer will be modified, and true returned.
29+
*
30+
* Note: The SOC provides a dummy version of this function which does nothing,
31+
* so all boards will have an implementation.
32+
* It is optional for boards to provide one if desired.
33+
*/
34+
bool native_emb_addr_remap(void **addr);
35+
2136
#ifdef __cplusplus
2237
}
2338
#endif

0 commit comments

Comments
 (0)