native simulator: Align with latest upstream version
Align with native_simulator's upstream main 5fc61e22e7a5b35a1c721c2503da5ff8eaadbfd5 Including: * 5fc61e2 Typo fixes * 4888ec2 Add default empty embedded images * a318045 Add hooks for up to 16 embedded CPUs * 0546c59 Makefile: Fix typo Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
This commit is contained in:
parent
d27b7f354f
commit
65c9288901
5 changed files with 158 additions and 1 deletions
|
@ -54,7 +54,7 @@ NSI_OBJCOPY?=objcopy
|
|||
NSI_DEBUG?=-g
|
||||
# Build optimization level (by default disabled to ease debugging)
|
||||
NSI_OPT?=-O0
|
||||
# Warnings swtiches (for the runner itself)
|
||||
# Warnings switches (for the runner itself)
|
||||
NSI_WARNINGS?=-Wall -Wpedantic
|
||||
# Preprocessor flags
|
||||
NSI_CPPFLAGS?=-D_POSIX_C_SOURCE=200809 -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED
|
||||
|
|
|
@ -93,6 +93,32 @@ NATIVE_SIMULATOR_IF void nsif_cpu0_irq_raised(void);
|
|||
*/
|
||||
NATIVE_SIMULATOR_IF void nsif_cpu0_irq_raised_from_sw(void);
|
||||
|
||||
#define NSI_CPU_IF_N(i) \
|
||||
NATIVE_SIMULATOR_IF void nsif_cpu##i##_pre_cmdline_hooks(void); \
|
||||
NATIVE_SIMULATOR_IF void nsif_cpu##i##_pre_hw_init_hooks(void); \
|
||||
NATIVE_SIMULATOR_IF void nsif_cpu##i##_boot(void); \
|
||||
NATIVE_SIMULATOR_IF int nsif_cpu##i##_cleanup(void); \
|
||||
NATIVE_SIMULATOR_IF void nsif_cpu##i##_irq_raised(void); \
|
||||
NATIVE_SIMULATOR_IF void nsif_cpu##i##_irq_raised_from_sw(void);
|
||||
|
||||
NSI_CPU_IF_N(1)
|
||||
NSI_CPU_IF_N(2)
|
||||
NSI_CPU_IF_N(3)
|
||||
NSI_CPU_IF_N(4)
|
||||
NSI_CPU_IF_N(5)
|
||||
NSI_CPU_IF_N(6)
|
||||
NSI_CPU_IF_N(7)
|
||||
NSI_CPU_IF_N(8)
|
||||
NSI_CPU_IF_N(9)
|
||||
NSI_CPU_IF_N(10)
|
||||
NSI_CPU_IF_N(11)
|
||||
NSI_CPU_IF_N(12)
|
||||
NSI_CPU_IF_N(13)
|
||||
NSI_CPU_IF_N(14)
|
||||
NSI_CPU_IF_N(15)
|
||||
|
||||
#undef NSI_CPU_IF_N
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
58
scripts/native_simulator/common/src/nsi_cpun_if.c
Normal file
58
scripts/native_simulator/common/src/nsi_cpun_if.c
Normal file
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "nsi_cpu_if.h"
|
||||
|
||||
/*
|
||||
* These trampolines forward a call from the runner into the corresponding embedded CPU hook
|
||||
* for ex., nsif_cpun_boot(4) -> nsif_cpu4_boot()
|
||||
*/
|
||||
|
||||
#define FUNCT(i, pre, post) \
|
||||
pre##i##post
|
||||
|
||||
#define F_TABLE(pre, post) \
|
||||
FUNCT(0, pre, post), \
|
||||
FUNCT(1, pre, post), \
|
||||
FUNCT(2, pre, post), \
|
||||
FUNCT(3, pre, post), \
|
||||
FUNCT(4, pre, post), \
|
||||
FUNCT(5, pre, post), \
|
||||
FUNCT(6, pre, post), \
|
||||
FUNCT(7, pre, post), \
|
||||
FUNCT(8, pre, post), \
|
||||
FUNCT(9, pre, post), \
|
||||
FUNCT(10, pre, post), \
|
||||
FUNCT(11, pre, post), \
|
||||
FUNCT(12, pre, post), \
|
||||
FUNCT(13, pre, post), \
|
||||
FUNCT(14, pre, post), \
|
||||
FUNCT(15, pre, post)
|
||||
|
||||
#define TRAMPOLINES(pre, post) \
|
||||
void pre ## n ## post(int n) \
|
||||
{ \
|
||||
void(*fptrs[])(void) = { \
|
||||
F_TABLE(pre, post) \
|
||||
}; \
|
||||
fptrs[n](); \
|
||||
}
|
||||
|
||||
#define TRAMPOLINES_i(pre, post) \
|
||||
int pre ## n ## post(int n) \
|
||||
{ \
|
||||
int(*fptrs[])(void) = { \
|
||||
F_TABLE(pre, post) \
|
||||
}; \
|
||||
return fptrs[n](); \
|
||||
}
|
||||
|
||||
TRAMPOLINES(nsif_cpu, _pre_cmdline_hooks)
|
||||
TRAMPOLINES(nsif_cpu, _pre_hw_init_hooks)
|
||||
TRAMPOLINES(nsif_cpu, _boot)
|
||||
TRAMPOLINES_i(nsif_cpu, _cleanup)
|
||||
TRAMPOLINES(nsif_cpu, _irq_raised)
|
||||
TRAMPOLINES(nsif_cpu, _irq_raised_from_sw)
|
29
scripts/native_simulator/common/src/nsi_cpun_if.h
Normal file
29
scripts/native_simulator/common/src/nsi_cpun_if.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef NSI_COMMON_SRC_NSI_CPUN_IF_H
|
||||
#define NSI_COMMON_SRC_NSI_CPUN_IF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Equivalent interfaces to nsi_cpu<n>_* but for the native simulator internal use
|
||||
*/
|
||||
|
||||
void nsif_cpun_pre_cmdline_hooks(int n);
|
||||
void nsif_cpun_pre_hw_init_hooks(int n);
|
||||
void nsif_cpun_boot(int n);
|
||||
int nsif_cpun_cleanup(int n);
|
||||
void nsif_cpun_irq_raised(int n);
|
||||
void nsif_cpun_irq_raised_from_sw(int n);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* NSI_COMMON_SRC_NSI_CPUN_IF_H */
|
44
scripts/native_simulator/common/src/nsi_weak_stubs.c
Normal file
44
scripts/native_simulator/common/src/nsi_weak_stubs.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2023 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "nsi_cpu_if.h"
|
||||
#include "nsi_tracing.h"
|
||||
|
||||
/*
|
||||
* Stubbed embedded CPU images, which do nothing:
|
||||
* The CPU does not boot, and interrupts are just ignored
|
||||
* These are all defined as weak, so if an actual image is present for that CPU,
|
||||
* that will be linked against.
|
||||
*/
|
||||
|
||||
#define NSI_CPU_STUBBED_IMAGE(i) \
|
||||
__attribute__((weak)) void nsif_cpu##i##_pre_cmdline_hooks(void) { } \
|
||||
__attribute__((weak)) void nsif_cpu##i##_pre_hw_init_hooks(void) { } \
|
||||
__attribute__((weak)) void nsif_cpu##i##_boot(void) \
|
||||
{ \
|
||||
nsi_print_trace("Attempted boot of CPU %i without image. "\
|
||||
"CPU %i shut down permanently\n", i, i); \
|
||||
} \
|
||||
__attribute__((weak)) int nsif_cpu##i##_cleanup(void) { return 0; } \
|
||||
__attribute__((weak)) void nsif_cpu##i##_irq_raised(void) { } \
|
||||
__attribute__((weak)) void nsif_cpu##i##_irq_raised_from_sw(void) { }
|
||||
|
||||
NSI_CPU_STUBBED_IMAGE(0)
|
||||
NSI_CPU_STUBBED_IMAGE(1)
|
||||
NSI_CPU_STUBBED_IMAGE(2)
|
||||
NSI_CPU_STUBBED_IMAGE(3)
|
||||
NSI_CPU_STUBBED_IMAGE(4)
|
||||
NSI_CPU_STUBBED_IMAGE(5)
|
||||
NSI_CPU_STUBBED_IMAGE(6)
|
||||
NSI_CPU_STUBBED_IMAGE(7)
|
||||
NSI_CPU_STUBBED_IMAGE(8)
|
||||
NSI_CPU_STUBBED_IMAGE(9)
|
||||
NSI_CPU_STUBBED_IMAGE(10)
|
||||
NSI_CPU_STUBBED_IMAGE(11)
|
||||
NSI_CPU_STUBBED_IMAGE(12)
|
||||
NSI_CPU_STUBBED_IMAGE(13)
|
||||
NSI_CPU_STUBBED_IMAGE(14)
|
||||
NSI_CPU_STUBBED_IMAGE(15)
|
Loading…
Add table
Add a link
Reference in a new issue