Skip to content

Commit 7084b5c

Browse files
Nicolas Pitrecarlescufi
authored andcommitted
arm64: native arch_proc_id() implementation
Return the hardware mpid value directly. Guard against values that wouldn't fit in the returned uint32_t. If that ever happens then reverting to the Zephyr sequential CPU number should be considered. Signed-off-by: Nicolas Pitre <[email protected]>
1 parent 27179a5 commit 7084b5c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

include/zephyr/arch/arm64/arch_inlines.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <zephyr/kernel_structs.h>
1313
#include <zephyr/arch/arm64/lib_helpers.h>
1414
#include <zephyr/arch/arm64/tpidrro_el0.h>
15+
#include <zephyr/sys/__assert.h>
1516

1617
static ALWAYS_INLINE _cpu_t *arch_curr_cpu(void)
1718
{
@@ -25,11 +26,11 @@ static ALWAYS_INLINE int arch_exception_depth(void)
2526

2627
static ALWAYS_INLINE uint32_t arch_proc_id(void)
2728
{
28-
/*
29-
* Placeholder implementation to be replaced with an architecture
30-
* specific call to get processor ID
31-
*/
32-
return arch_curr_cpu()->id;
29+
uint64_t cpu_mpid = read_mpidr_el1();
30+
31+
__ASSERT(cpu_mpid == (uint32_t)cpu_mpid, "mpid extends past 32 bits");
32+
33+
return (uint32_t)cpu_mpid;
3334
}
3435

3536
#endif /* !_ASMLANGUAGE */

0 commit comments

Comments
 (0)