diff options
Diffstat (limited to 'cpukit/score/cpu/aarch64/include/rtems/score/cpuimpl.h')
-rw-r--r-- | cpukit/score/cpu/aarch64/include/rtems/score/cpuimpl.h | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/cpukit/score/cpu/aarch64/include/rtems/score/cpuimpl.h b/cpukit/score/cpu/aarch64/include/rtems/score/cpuimpl.h index 90fd48ad4e..8a0e476899 100644 --- a/cpukit/score/cpu/aarch64/include/rtems/score/cpuimpl.h +++ b/cpukit/score/cpu/aarch64/include/rtems/score/cpuimpl.h @@ -50,8 +50,11 @@ */ #define CPU_PER_CPU_CONTROL_SIZE 0 + #define CPU_INTERRUPT_FRAME_SIZE 0x2E0 +#define CPU_THREAD_LOCAL_STORAGE_VARIANT 11 + #ifndef ASM #ifdef __cplusplus @@ -125,20 +128,59 @@ typedef struct { uint64_t register_fpcr; } CPU_Interrupt_frame; +#ifdef RTEMS_SMP + +static inline +struct Per_CPU_Control *_AARCH64_Get_current_per_CPU_control( void ) +{ + struct Per_CPU_Control *cpu_self; + uint64_t value; + + __asm__ volatile ( + "mrs %0, TPIDR_EL1" : "=&r" ( value ) : : "memory" + ); + + /* Use EL1 Thread ID Register (TPIDR_EL1) */ + cpu_self = (struct Per_CPU_Control *)(uintptr_t)value; + + return cpu_self; +} + +#define _CPU_Get_current_per_CPU_control() \ + _AARCH64_Get_current_per_CPU_control() + +#endif /* RTEMS_SMP */ + void _CPU_Context_volatile_clobber( uintptr_t pattern ); void _CPU_Context_validate( uintptr_t pattern ); -RTEMS_INLINE_ROUTINE void _CPU_Instruction_illegal( void ) +static inline void _CPU_Instruction_illegal( void ) { __asm__ volatile ( ".inst 0x0" ); } -RTEMS_INLINE_ROUTINE void _CPU_Instruction_no_operation( void ) +static inline void _CPU_Instruction_no_operation( void ) { __asm__ volatile ( "nop" ); } +static inline void _CPU_Use_thread_local_storage( + const Context_Control *context +) +{ + __asm__ volatile ( + "msr TPIDR_EL0, %0" : : "r" ( context->thread_id ) : "memory" + ); +} + +static inline void *_CPU_Get_TLS_thread_pointer( + const Context_Control *context +) +{ + return (void *)(uintptr_t) context->thread_id; +} + #ifdef __cplusplus } #endif |