From dafb78443a5e5dcdc45667822907bc7980fab4cd Mon Sep 17 00:00:00 2001 From: Alberto Escolar Piedras Date: Fri, 13 Oct 2023 18:30:13 +0200 Subject: [PATCH] Add support for hosted test environments Add a new hosted test environment "processor". This is meant as a build target used when the code is not built for a real target but as part of a test in a hosted environment (for ex. as a test environment like Zephyr's native_sim target). When building for this target PROJECT_PROCESSOR should be set as "hosted". In this, the "metal_sleep_usec()" call is expected to be provided by the system folder headers. Signed-off-by: Alberto Escolar Piedras --- lib/processor/hosted/CMakeLists.txt | 2 ++ lib/processor/hosted/atomic.h | 15 +++++++++++++++ lib/processor/hosted/cpu.h | 22 ++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 lib/processor/hosted/CMakeLists.txt create mode 100644 lib/processor/hosted/atomic.h create mode 100644 lib/processor/hosted/cpu.h diff --git a/lib/processor/hosted/CMakeLists.txt b/lib/processor/hosted/CMakeLists.txt new file mode 100644 index 00000000..13ce0230 --- /dev/null +++ b/lib/processor/hosted/CMakeLists.txt @@ -0,0 +1,2 @@ +collect (PROJECT_LIB_HEADERS atomic.h) +collect (PROJECT_LIB_HEADERS cpu.h) diff --git a/lib/processor/hosted/atomic.h b/lib/processor/hosted/atomic.h new file mode 100644 index 00000000..ed153c30 --- /dev/null +++ b/lib/processor/hosted/atomic.h @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * @file hosted/atomic.h + * @brief Hosted environment atomic primitives for libmetal. + */ + +#ifndef __METAL_HOSTED_ATOMIC__H__ +#define __METAL_HOSTED_ATOMIC__H__ + +#endif /* __METAL_HOSTED_ATOMIC__H__ */ diff --git a/lib/processor/hosted/cpu.h b/lib/processor/hosted/cpu.h new file mode 100644 index 00000000..be8a1680 --- /dev/null +++ b/lib/processor/hosted/cpu.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2023 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/* + * @file hosted/cpu.h + * @brief Hosted environment CPU specific primitives + */ + +#include + +#ifndef __METAL_HOSTED_CPU__H__ +#define __METAL_HOSTED_CPU__H__ + +static inline void metal_cpu_yield(void) +{ + metal_wait_usec(10); +} + +#endif /* __METAL_HOSTED_CPU__H__ */