summaryrefslogtreecommitdiff
path: root/libcpu
diff options
context:
space:
mode:
author张衍 <[email protected]>2024-07-22 02:33:39 +0000
committer张衍 <[email protected]>2024-07-22 02:33:39 +0000
commit0e3c4bd26b34a54910db4da6b0a99bc470c65b08 (patch)
tree2647ed4c4d6f182eb8f3176dc689a156d2920a38 /libcpu
parentca4645000a3d64c260bd6b15200bdcce5ae8b330 (diff)
[BSP/Phytium]适配最新裸机驱动
Diffstat (limited to 'libcpu')
-rw-r--r--libcpu/aarch64/common/cpuport.c43
-rw-r--r--libcpu/aarch64/common/include/cpuport.h30
2 files changed, 43 insertions, 30 deletions
diff --git a/libcpu/aarch64/common/cpuport.c b/libcpu/aarch64/common/cpuport.c
new file mode 100644
index 0000000000..4c1bf01cf3
--- /dev/null
+++ b/libcpu/aarch64/common/cpuport.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2006-2021, RT-Thread Development Team
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Change Logs:
+ * Date Author Notes
+ * 2024-06-21 Zhangyan first version
+ */
+
+#include <rthw.h>
+#include <rtthread.h>
+#include <board.h>
+
+#ifdef RT_USING_CPU_FFS
+/**
+ * This function finds the first bit set (beginning with the least significant bit)
+ * in value and return the index of that bit.
+ *
+ * Bits are numbered starting at 1 (the least significant bit). A return value of
+ * zero from any of these functions means that the argument was zero.
+ *
+ * @return return the index of the first bit set. If value is 0, then this function
+ * shall return 0.
+ */
+int __rt_ffs(int value)
+{
+#ifdef __GNUC__
+ return __builtin_ffs(value);
+#else
+ __asm__ volatile (
+ "rbit w1, %w0\n"
+ "cmp %w0, 0\n"
+ "clz w1, w1\n"
+ "csinc %w0, wzr, w1, eq\n"
+ : "=r"(value)
+ : "0"(value)
+ );
+ return value;
+#endif
+}
+
+#endif /* RT_USING_CPU_FFS */ \ No newline at end of file
diff --git a/libcpu/aarch64/common/include/cpuport.h b/libcpu/aarch64/common/include/cpuport.h
index 217f477aaf..cbd04500a0 100644
--- a/libcpu/aarch64/common/include/cpuport.h
+++ b/libcpu/aarch64/common/include/cpuport.h
@@ -53,36 +53,6 @@ typedef struct
void _thread_start(void);
-#ifdef RT_USING_CPU_FFS
-/**
- * This function finds the first bit set (beginning with the least significant bit)
- * in value and return the index of that bit.
- *
- * Bits are numbered starting at 1 (the least significant bit). A return value of
- * zero from any of these functions means that the argument was zero.
- *
- * @return return the index of the first bit set. If value is 0, then this function
- * shall return 0.
- */
-rt_inline int __rt_ffs(int value)
-{
-#ifdef __GNUC__
- return __builtin_ffs(value);
-#else
- __asm__ volatile (
- "rbit w1, %w0\n"
- "cmp %w0, 0\n"
- "clz w1, w1\n"
- "csinc %w0, wzr, w1, eq\n"
- : "=r"(value)
- : "0"(value)
- );
- return value;
-#endif
-}
-
-#endif /* RT_USING_CPU_FFS */
-
#ifdef ARCH_USING_HW_THREAD_SELF
rt_inline struct rt_thread *rt_hw_thread_self(void)
{