1
0
Эх сурвалжийг харах

[libcpu] arm64: implement cpuid get by assembly (#9052)

Shell 1 жил өмнө
parent
commit
a12736e4c8

+ 12 - 3
libcpu/aarch64/common/context_gcc.S

@@ -62,12 +62,21 @@ rt_hw_cpu_id_set:
 /*
 int rt_hw_cpu_id(void)
 */
-.weak rt_hw_cpu_id
 .type rt_hw_cpu_id, @function
 rt_hw_cpu_id:
+#ifdef ARCH_USING_GENERIC_CPUID
+    .globl rt_hw_cpu_id
+#else /* !ARCH_USING_GENERIC_CPUID */
+    .weak rt_hw_cpu_id
+#endif /* ARCH_USING_GENERIC_CPUID */
+
 #if RT_CPUS_NR > 1
-    mrs x0, tpidr_el1
-#else
+    #ifdef ARCH_USING_GENERIC_CPUID
+        mrs x0, tpidrro_el0
+    #else /* !ARCH_USING_GENERIC_CPUID */
+        mrs x0, tpidr_el1
+    #endif /* ARCH_USING_GENERIC_CPUID */
+#else /* RT_CPUS_NR == 1 */
     mov x0, xzr
 #endif
     ret

+ 0 - 18
libcpu/aarch64/common/cpu.c

@@ -231,24 +231,6 @@ int rt_hw_cpu_boot_secondary(int num_cpus, rt_uint64_t *cpu_hw_ids, struct cpu_o
 
 #endif /*RT_USING_SMP*/
 
-/**
- * Generic hw-cpu-id
- */
-#ifdef ARCH_USING_GENERIC_CPUID
-
-int rt_hw_cpu_id(void)
-{
-#if RT_CPUS_NR > 1
-    long cpuid;
-    __asm__ volatile("mrs %0, tpidrro_el0":"=r"(cpuid));
-    return cpuid;
-#else
-    return 0;
-#endif /* RT_CPUS_NR > 1 */
-}
-
-#endif /* ARCH_USING_GENERIC_CPUID */
-
 /**
  * @addtogroup ARM CPU
  */