arch: arc: add macros to get current cpu id

add macros for assembly and C to get current cpu id

Signed-off-by: Wayne Ren <wei.ren@synopsys.com>
This commit is contained in:
Wayne Ren 2019-07-25 11:17:34 +08:00 committed by Carles Cufí
commit 83dfe5eac4
2 changed files with 16 additions and 0 deletions

View file

@ -295,6 +295,11 @@ extern "C" {
cmp \reg1, \reg2
.endm
.macro _get_cpu_id reg
lr \reg, [_ARC_V2_IDENTITY]
xbfu \reg, \reg, 0xe8
.endm
#endif /* _ASMLANGUAGE */
#ifdef __cplusplus

View file

@ -177,8 +177,19 @@ extern "C" {
: "ir"(val), "i"(reg)); \
})
#endif /* __GNUC__ */
#endif /* _ASMLANGUAGE */
#define z_arc_v2_core_id() \
({ \
unsigned int __ret; \
__asm__ __volatile__("lr %0, [%1]\n" \
"xbfu %0, %0, 0xe8\n" \
: "=r"(__ret) \
: "i"(_ARC_V2_IDENTITY)); \
__ret; \
})
#ifdef __cplusplus
}
#endif