diff options
author | Vic Yang <victoryang@chromium.org> | 2012-02-12 10:42:22 +0800 |
---|---|---|
committer | Vic Yang <victoryang@chromium.org> | 2012-02-16 05:43:29 +0800 |
commit | 94fb8ee096e46da8a50d4c087ba9ab0652d0317d (patch) | |
tree | 21f1abdb88ce9f7352c6f1eefe1810df33921535 /core/cortex-m/include | |
parent | 502613771e5239e5494f9f06ffecc6f61c711f1c (diff) | |
download | chrome-ec-94fb8ee096e46da8a50d4c087ba9ab0652d0317d.tar.gz |
Sqrt function for Cortex-M
Add an arch include folder. Implement sqrtf for Cortex-M in math.h.
BUG=chrome-os-partner:7920
TEST=none
Change-Id: Ib7b480b6a0bf7760f014a1f73df54673a9016cb6
Signed-off-by: Vic Yang <victoryang@chromium.org>
Diffstat (limited to 'core/cortex-m/include')
-rw-r--r-- | core/cortex-m/include/math.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/core/cortex-m/include/math.h b/core/cortex-m/include/math.h new file mode 100644 index 0000000000..485f28ba23 --- /dev/null +++ b/core/cortex-m/include/math.h @@ -0,0 +1,24 @@ +/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/* Math utility functions for ARMv7 */ + +#ifndef __EC_MATH_H +#define __EC_MATH_H + +#ifdef CONFIG_FPU +static inline float sqrtf(float v) +{ + float root; + asm volatile( + "fsqrts %0, %1" + : "=w" (root) + : "w" (v) + ); + return root; +} +#endif /* CONFIG_FPU */ + +#endif /* __EC_MATH_H */ |