forked from zephyrproject-rtos/libmetal
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Zephyr's native test environment
Zephyr's native test environment is a setup which allows building the embedded SW with the Zephyr OS and HW models as a Linux executable. When building for this target the Zephyr integration will set METAL_PROCESSOR_HEADERS_ON_SYSTEM. We need to provide appropriate headers for this environment. The "metal_cpu_yield()" call, which in other architectures is handled as either a hint for the CPU to yield to another thread or do nothing, and therefore busy waiting, needs replacing with a call out to the Zephyr API which will cause the CPU to waste 1 microsecond, therefore enabling the other CPU in the system to ready whatever we are waiting for in the meanwhile. Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no> (f) Add support for Zephyr's POSIX architecture (f) Add support for Zephyr's native
- Loading branch information
Showing
5 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright (c) 2023 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
/* | ||
* @file cpu.h | ||
* @brief Zephyr native test environment CPU specific primitives | ||
*/ | ||
|
||
#ifndef __METAL_ZEPHYR_CPU__H__ | ||
#define __METAL_ZEPHYR_CPU__H__ | ||
|
||
#include <zephyr/kernel.h> | ||
|
||
static inline void metal_cpu_yield(void) | ||
{ | ||
/* | ||
* In Zephyr's native test environment let 1 microsecond pass | ||
* to allow other threads to run | ||
*/ | ||
k_busy_wait(1); | ||
}; | ||
|
||
#endif /* __METAL_ZEPHYR_CPU__H__ */ |