0001
0002
0003
0004
0005
0006
0007 #ifndef _ASM_ARM_CURRENT_H
0008 #define _ASM_ARM_CURRENT_H
0009
0010 #ifndef __ASSEMBLY__
0011 #include <asm/insn.h>
0012
0013 struct task_struct;
0014
0015 extern struct task_struct *__current;
0016
0017 static __always_inline __attribute_const__ struct task_struct *get_current(void)
0018 {
0019 struct task_struct *cur;
0020
0021 #if __has_builtin(__builtin_thread_pointer) && \
0022 defined(CONFIG_CURRENT_POINTER_IN_TPIDRURO) && \
0023 !(defined(CONFIG_THUMB2_KERNEL) && \
0024 defined(CONFIG_CC_IS_CLANG) && CONFIG_CLANG_VERSION < 130001)
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 cur = __builtin_thread_pointer();
0035 #elif defined(CONFIG_CURRENT_POINTER_IN_TPIDRURO) || defined(CONFIG_SMP)
0036 asm("0: mrc p15, 0, %0, c13, c0, 3 \n\t"
0037 #ifdef CONFIG_CPU_V6
0038 "1: \n\t"
0039 " .subsection 1 \n\t"
0040 #if defined(CONFIG_ARM_HAS_GROUP_RELOCS) && \
0041 !(defined(MODULE) && defined(CONFIG_ARM_MODULE_PLTS))
0042 "2: " LOAD_SYM_ARMV6(%0, __current) " \n\t"
0043 " b 1b \n\t"
0044 #else
0045 "2: ldr %0, 3f \n\t"
0046 " ldr %0, [%0] \n\t"
0047 " b 1b \n\t"
0048 "3: .long __current \n\t"
0049 #endif
0050 " .previous \n\t"
0051 " .pushsection \".alt.smp.init\", \"a\" \n\t"
0052 " .long 0b - . \n\t"
0053 " b . + (2b - 0b) \n\t"
0054 " .popsection \n\t"
0055 #endif
0056 : "=r"(cur));
0057 #elif __LINUX_ARM_ARCH__>= 7 || \
0058 !defined(CONFIG_ARM_HAS_GROUP_RELOCS) || \
0059 (defined(MODULE) && defined(CONFIG_ARM_MODULE_PLTS))
0060 cur = __current;
0061 #else
0062 asm(LOAD_SYM_ARMV6(%0, __current) : "=r"(cur));
0063 #endif
0064 return cur;
0065 }
0066
0067 #define current get_current()
0068
0069 #endif
0070
0071 #endif