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

This commit is contained in:
Shell 2024-06-11 17:21:47 +08:00 committed by GitHub
parent 47ee23510c
commit a12736e4c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 21 deletions

View File

@ -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
#ifdef ARCH_USING_GENERIC_CPUID
mrs x0, tpidrro_el0
#else /* !ARCH_USING_GENERIC_CPUID */
mrs x0, tpidr_el1
#else
#endif /* ARCH_USING_GENERIC_CPUID */
#else /* RT_CPUS_NR == 1 */
mov x0, xzr
#endif
ret

View File

@ -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
*/