Browse Source

cortex-r4: add __rt_ffs

Grissiom 12 years ago
parent
commit
228a6be077
2 changed files with 14 additions and 0 deletions
  1. 1 0
      bsp/rm48x50/rtconfig.h
  2. 13 0
      libcpu/arm/cortex-r4/cpu.c

+ 1 - 0
bsp/rm48x50/rtconfig.h

@@ -212,6 +212,7 @@
 // </section>
 
 #define RT_VFP_LAZY_STACKING
+#define RT_USING_CPU_FFS
 // </RDTConfigurator>
 
 #endif

+ 13 - 0
libcpu/arm/cortex-r4/cpu.c

@@ -39,4 +39,17 @@ void rt_hw_cpu_shutdown()
 	while (1);
 }
 
+#ifdef RT_USING_CPU_FFS
+int __rt_ffs(int value)
+{
+	if (value == 0)
+		return value;
+
+	__asm("    rsb r1, r0, #0");
+	__asm("    and r1, r1, r0");
+	__asm("    clz r1, r1");
+	__asm("    rsb r0, r1, #32");
+}
+#endif
+
 /*@}*/