1# Copyright (c) 2023 Nordic Semiconductor ASA
2# Copyright (c) 2018 Oticon A/S
3# SPDX-License-Identifier: Apache-2.0
4
5find_package(BabbleSim)
6
7zephyr_library()
8
9# Due to the BLE controller assumption about enum size
10zephyr_compile_options(
11  -fshort-enums
12)
13# Structures layouts needs to match in the interface between the runner and the embedded SW
14# The nrfx HAL uses enums in its definitions,so they need to have the same size in both,
15# as both the HW models and embedded SW use them.
16target_compile_options(native_simulator INTERFACE -fshort-enums)
17
18zephyr_library_sources(
19	irq_handler.c
20	cpu_wait.c
21	argparse.c
22	nsi_if.c
23	soc/nrfx_coredep.c
24	common/bstests_entry.c
25	common/cmsis/cmsis.c
26	common/trace_hook.c
27)
28
29# Include sync_rtc from real SOC code if enabled
30zephyr_library_sources_ifdef(CONFIG_NRF53_SYNC_RTC
31  ${ZEPHYR_BASE}/soc/arm/nordic_nrf/nrf53/sync_rtc.c
32  )
33
34target_sources(native_simulator INTERFACE
35	common/bsim_args_runner.c
36	common/bsim_extra_cpu_if_stubs.c
37	common/phy_sync_ctrl.c
38	common/runner_hooks.c
39	common/posix_arch_if.c
40	common/trace_hook.c
41)
42
43if (CONFIG_IPC_SERVICE AND CONFIG_BOARD_NRF5340BSIM_NRF5340_CPUAPP)
44	zephyr_library_sources(
45		ipc_backend.c
46	)
47endif()
48
49zephyr_include_directories(
50  soc
51  common
52  common/cmsis
53  ${NSI_DIR}/common/src/include
54)
55
56zephyr_library_include_directories(
57  ${BSIM_COMPONENTS_PATH}/libUtilv1/src/
58  ${BSIM_COMPONENTS_PATH}/libPhyComv1/src/
59  ${BSIM_COMPONENTS_PATH}/libRandv2/src/
60  ${ZEPHYR_BASE}/kernel/include
61  ${ZEPHYR_BASE}/arch/posix/include
62  common/
63)
64
65set(libpath ${BSIM_OUT_PATH}/lib)
66set_property(TARGET native_simulator APPEND PROPERTY RUNNER_LINK_LIBRARIES
67	${libpath}/libUtilv1.32.a
68	${libpath}/libPhyComv1.32.a
69	${libpath}/lib2G4PhyComv1.32.a
70	${libpath}/libRandv2.32.a
71)
72
73target_compile_options(native_simulator INTERFACE
74                       "-DNSI_PRIMARY_MCU_N=${CONFIG_NATIVE_SIMULATOR_PRIMARY_MCU_INDEX}")
75
76add_subdirectory(${ZEPHYR_BASE}/boards/${ARCH}/common/extra_args/
77	${CMAKE_CURRENT_BINARY_DIR}/extra_args
78)
79
80include(../common/natsim_config.cmake)
81