Skip to content

Commit

Permalink
Add support for hosted test environments
Browse files Browse the repository at this point in the history
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 <alberto.escolar.piedras@nordicsemi.no>
  • Loading branch information
aescolar committed Oct 13, 2023
1 parent d7c605c commit a126d5b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/processor/hosted/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
collect (PROJECT_LIB_HEADERS atomic.h)
collect (PROJECT_LIB_HEADERS cpu.h)
15 changes: 15 additions & 0 deletions lib/processor/hosted/atomic.h
Original file line number Diff line number Diff line change
@@ -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__ */
22 changes: 22 additions & 0 deletions lib/processor/hosted/cpu.h
Original file line number Diff line number Diff line change
@@ -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 <metal/sys.h>

#ifndef __METAL_HOSTED_CPU__H__
#define __METAL_HOSTED_CPU__H__

static inline void metal_cpu_yield(void)
{
metal_wait_usec();
}

#endif /* __METAL_HOSTED_CPU__H__ */

0 comments on commit a126d5b

Please sign in to comment.