diff options
author | Ting Shen <phoenixshen@google.com> | 2019-07-24 16:24:54 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-07-29 11:55:27 +0000 |
commit | b1adf987395577737781b10ef96581cff8381d1a (patch) | |
tree | 6980098871fbfd3aa38cdeac3567e2bdd47f92ba /core | |
parent | af8d9a859dce4da8e90700e8378aba78c9a5a015 (diff) | |
download | chrome-ec-b1adf987395577737781b10ef96581cff8381d1a.tar.gz |
cortex-m0: implement __ffssi2
The file is copied from riscv-rv32i/__builtin.c.
bc12_update_charge_manager() in pi3usb9201 driver uses this
function.
BUG=b:135895590
TEST=combined with CL:1673955, build and deploy on jacuzzi
BRANCH=master
Change-Id: If8b8cc8e4a3acdad7285c23e2f3627c7d05bf3b8
Signed-off-by: Ting Shen <phoenixshen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1715951
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Reviewed-by: Alexandru M Stan <amstan@chromium.org>
Commit-Queue: Ting Shen <phoenixshen@chromium.org>
Tested-by: Ting Shen <phoenixshen@chromium.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/cortex-m0/__builtin.c | 16 | ||||
-rw-r--r-- | core/cortex-m0/build.mk | 2 |
2 files changed, 17 insertions, 1 deletions
diff --git a/core/cortex-m0/__builtin.c b/core/cortex-m0/__builtin.c new file mode 100644 index 0000000000..4bf495a011 --- /dev/null +++ b/core/cortex-m0/__builtin.c @@ -0,0 +1,16 @@ +/* Copyright 2019 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. + */ + +#include "common.h" + +/* + * __builtin_ffs: + * Returns one plus the index of the least significant 1-bit of x, + * or if x is zero, returns zero. + */ +int __keep __ffssi2(int x) +{ + return 32 - __builtin_clz(x & -x); +} diff --git a/core/cortex-m0/build.mk b/core/cortex-m0/build.mk index f199b09361..a314976bce 100644 --- a/core/cortex-m0/build.mk +++ b/core/cortex-m0/build.mk @@ -21,7 +21,7 @@ LDFLAGS_EXTRA+=-flto endif core-y=cpu.o init.o thumb_case.o div.o lmul.o ldivmod.o mula.o uldivmod.o -core-y+=vecttable.o +core-y+=vecttable.o __builtin.o core-$(CONFIG_COMMON_PANIC_OUTPUT)+=panic.o core-$(CONFIG_COMMON_RUNTIME)+=switch.o task.o |