Skip to content

Commit

Permalink
zephyr: Enable support for RISCV
Browse files Browse the repository at this point in the history
Make libmetal usable also for RISCV targets.

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
  • Loading branch information
carlocaione authored and arnopo committed Jan 4, 2022
1 parent 210b9ec commit c6ae2c6
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmake/syscheck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ if (WITH_ZEPHYR)
if (CONFIG_ARM)
set (MACHINE "arm" CACHE STRING "")
endif(CONFIG_ARM)
if (CONFIG_RISCV)
set (MACHINE "riscv" CACHE STRING "")
endif (CONFIG_RISCV)

endif (WITH_ZEPHYR)
2 changes: 2 additions & 0 deletions lib/system/zephyr/riscv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
collect (PROJECT_LIB_HEADERS sys.h)
collect (PROJECT_LIB_SOURCES sys.c)
22 changes: 22 additions & 0 deletions lib/system/zephyr/riscv/sys.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright (c) 2021 Carlo Caione <ccaione@baylibre.com>
*
* SPDX-License-Identifier: BSD-3-Clause
*/

/*
* @file zephyr/riscv/sys.c
* @brief machine specific system primitives implementation.
*/

#include <metal/io.h>
#include <metal/sys.h>
#include <stdint.h>

/**
* @brief poll function until some event happens
*/
void metal_weak metal_generic_default_poll(void)
{
metal_asm __volatile__("wfi");
}
27 changes: 27 additions & 0 deletions lib/system/zephyr/riscv/sys.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2021 Carlo Caione <ccaione@baylibre.com>
*
* SPDX-License-Identifier: BSD-3-Clause
*/

/*
* @file zephyr/riscv/sys.h
* @brief Zephyr riscv system primitives for libmetal.
*/

#ifndef __METAL_ZEPHYR_SYS__H__
#error "Include metal/sys.h instead of metal/generic/@PROJECT_MACHINE@/sys.h"
#endif

#ifndef __METAL_ZEPHYR_RISCV_SYS__H__
#define __METAL_ZEPHYR_RISCV_SYS__H__

#ifdef __cplusplus
extern "C" {
#endif

#ifdef __cplusplus
}
#endif

#endif /* __METAL_ZEPHYR_RISCV_SYS__H__ */

0 comments on commit c6ae2c6

Please sign in to comment.