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>
This commit is contained in:
Vic Yang
2012-02-12 10:42:22 +08:00
parent 502613771e
commit 94fb8ee096
2 changed files with 25 additions and 1 deletions

View File

@@ -43,6 +43,6 @@ all-y+=$(call objs_from_dir,board/$(BOARD),$(board-y))
all-y+=$(call objs_from_dir,common,$(common-y))
all-y+=$(call objs_from_dir,test,$($(PROJECT)-y))
dirs=core/$(CORE) chip/$(CHIP) board/$(BOARD) common test util
includes=include $(dirs)
includes=include core/$(CORE)/include $(dirs)
include Makefile.rules

View File

@@ -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 */