summaryrefslogtreecommitdiff
path: root/libcpu
diff options
context:
space:
mode:
authorShell <[email protected]>2024-06-11 17:21:47 +0800
committerGitHub <[email protected]>2024-06-11 17:21:47 +0800
commita12736e4c8e81178ac0cb8639f820028b0d23230 (patch)
tree53c56ca7d61a8821a8c32b2ab99180ff27cf7d85 /libcpu
parent47ee23510c081ad1e098d4d7a17da309d773940b (diff)
[libcpu] arm64: implement cpuid get by assembly (#9052)
Diffstat (limited to 'libcpu')
-rw-r--r--libcpu/aarch64/common/context_gcc.S15
-rw-r--r--libcpu/aarch64/common/cpu.c18
2 files changed, 12 insertions, 21 deletions
diff --git a/libcpu/aarch64/common/context_gcc.S b/libcpu/aarch64/common/context_gcc.S
index 9399467935..0233806d96 100644
--- a/libcpu/aarch64/common/context_gcc.S
+++ b/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
diff --git a/libcpu/aarch64/common/cpu.c b/libcpu/aarch64/common/cpu.c
index b9fedefdd3..72ccccac24 100644
--- a/libcpu/aarch64/common/cpu.c
+++ b/libcpu/aarch64/common/cpu.c
@@ -232,24 +232,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
*/
/*@{*/