diff options
-rw-r--r-- | zephyr/Kconfig | 4 | ||||
-rw-r--r-- | zephyr/shim/include/fpu.h | 18 |
2 files changed, 18 insertions, 4 deletions
diff --git a/zephyr/Kconfig b/zephyr/Kconfig index 9d8b53ad03..4170225255 100644 --- a/zephyr/Kconfig +++ b/zephyr/Kconfig @@ -339,7 +339,7 @@ config PLATFORM_EC_FLASH_CROS config PLATFORM_EC_FPU bool "Support floating point" - depends on FPU && CPU_CORTEX_M && !NEWLIB_LIBC + depends on FPU && (CPU_CORTEX_M || RISCV) && !NEWLIB_LIBC default y help This enables support for floating point. This is generally already @@ -347,8 +347,6 @@ config PLATFORM_EC_FPU available which are not available with Zephyr's minimal lib: sqrtf() and fabsf(). Enabling this options defines them. - For now this is only supported on Cortex-M4. - config PLATFORM_EC_HOOKS bool "Hooks and deferred compatibility shim" default y diff --git a/zephyr/shim/include/fpu.h b/zephyr/shim/include/fpu.h index da36f50492..8f78fb587d 100644 --- a/zephyr/shim/include/fpu.h +++ b/zephyr/shim/include/fpu.h @@ -47,9 +47,25 @@ static inline float fabsf(float v) return root; } +#elif CONFIG_RISCV +static inline float sqrtf(float v) +{ + float root; + + __asm__("fsqrt.s %0, %1" : "=f"(root) : "f"(v)); + return root; +} + +static inline float fabsf(float v) +{ + float abs; + + __asm__("fabs.s %0, %1" : "=f"(abs) : "f"(v)); + return abs; +} #else #error "Unsupported core: please add an implementation" -#endif /* CONFIG_CPU_CORTEX_M */ +#endif #endif /* CONFIG_PLATFORM_EC_FPU */ |