arch POSIX: provide a bottom which uses natsim's thread emul
This allows building with embedded libCs in the Zephyr side, as the POSIX arch bottom is not anymore built in Zephyr context. Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
parent
850fc2f22f
commit
945429e8c3
2 changed files with 73 additions and 6 deletions
|
@ -6,13 +6,21 @@ zephyr_library_sources(
|
|||
cpuhalt.c
|
||||
fatal.c
|
||||
irq.c
|
||||
nsi_compat/nsi_compat.c
|
||||
nsi_compat/nce.c
|
||||
posix_core.c
|
||||
swap.c
|
||||
thread.c
|
||||
)
|
||||
|
||||
zephyr_include_directories(
|
||||
nsi_compat/
|
||||
)
|
||||
if(CONFIG_NATIVE_APPLICATION)
|
||||
zephyr_include_directories(
|
||||
nsi_compat/
|
||||
)
|
||||
zephyr_library_sources(
|
||||
posix_core.c
|
||||
nsi_compat/nsi_compat.c
|
||||
nsi_compat/nce.c
|
||||
)
|
||||
else()
|
||||
zephyr_library_sources(
|
||||
posix_core_nsi.c
|
||||
)
|
||||
endif()
|
||||
|
|
59
arch/posix/core/posix_core_nsi.c
Normal file
59
arch/posix/core/posix_core_nsi.c
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
* Interfacing between the POSIX arch and the Native Simulator (nsi) CPU thread emulator
|
||||
*
|
||||
* This posix architecture "bottom" will be used when building with the native simulator.
|
||||
*/
|
||||
|
||||
#include "nct_if.h"
|
||||
|
||||
static void *te_state;
|
||||
|
||||
/*
|
||||
* Initialize the posix architecture
|
||||
*/
|
||||
void posix_arch_init(void)
|
||||
{
|
||||
extern void posix_arch_thread_entry(void *pa_thread_status);
|
||||
te_state = nct_init(posix_arch_thread_entry);
|
||||
}
|
||||
|
||||
/*
|
||||
* Clear the state of the POSIX architecture
|
||||
* free whatever memory it may have allocated, etc.
|
||||
*/
|
||||
void posix_arch_clean_up(void)
|
||||
{
|
||||
nct_clean_up(te_state);
|
||||
}
|
||||
|
||||
void posix_swap(int next_allowed_thread_nbr, int this_th_nbr)
|
||||
{
|
||||
(void) this_th_nbr;
|
||||
nct_swap_threads(te_state, next_allowed_thread_nbr);
|
||||
}
|
||||
|
||||
void posix_main_thread_start(int next_allowed_thread_nbr)
|
||||
{
|
||||
nct_first_thread_start(te_state, next_allowed_thread_nbr);
|
||||
}
|
||||
|
||||
int posix_new_thread(void *payload)
|
||||
{
|
||||
return nct_new_thread(te_state, payload);
|
||||
}
|
||||
|
||||
void posix_abort_thread(int thread_idx)
|
||||
{
|
||||
nct_abort_thread(te_state, thread_idx);
|
||||
}
|
||||
|
||||
int posix_arch_get_unique_thread_id(int thread_idx)
|
||||
{
|
||||
return nct_get_unique_thread_id(te_state, thread_idx);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue