1 #ifndef _ASMARM_THREAD_INFO_H_ 2 #define _ASMARM_THREAD_INFO_H_ 3 /* 4 * Adapted from arch/arm64/include/asm/thread_info.h 5 * 6 * Copyright (C) 2015, Red Hat Inc, Andrew Jones <drjones@redhat.com> 7 * 8 * This work is licensed under the terms of the GNU LGPL, version 2. 9 */ 10 #include <asm/page.h> 11 12 #define MIN_THREAD_SHIFT 14 /* THREAD_SIZE == 16K */ 13 #if PAGE_SHIFT > MIN_THREAD_SHIFT 14 #define THREAD_SHIFT PAGE_SHIFT 15 #define THREAD_SIZE PAGE_SIZE 16 #define THREAD_MASK PAGE_MASK 17 #else 18 #define THREAD_SHIFT MIN_THREAD_SHIFT 19 #define THREAD_SIZE (_AC(1,UL) << THREAD_SHIFT) 20 #define THREAD_MASK (~(THREAD_SIZE-1)) 21 #endif 22 23 #ifndef __ASSEMBLY__ 24 #include <asm/processor.h> 25 26 #ifdef __arm__ 27 #include <asm/ptrace.h> 28 /* 29 * arm needs room left at the top for the exception stacks, 30 * and the stack needs to be 8-byte aligned 31 */ 32 #define THREAD_START_SP \ 33 ((THREAD_SIZE - (sizeof(struct pt_regs) * 8)) & ~7) 34 #else 35 #define THREAD_START_SP (THREAD_SIZE - 16) 36 #endif 37 38 #define TIF_USER_MODE (1U << 0) 39 40 struct thread_info { 41 int cpu; 42 unsigned int flags; 43 #ifdef __arm__ 44 exception_fn exception_handlers[EXCPTN_MAX]; 45 #else 46 vector_fn vector_handlers[VECTOR_MAX]; 47 exception_fn exception_handlers[VECTOR_MAX][EC_MAX]; 48 #endif 49 char ext[0]; /* allow unit tests to add extended info */ 50 }; 51 52 static inline struct thread_info *thread_info_sp(unsigned long sp) 53 { 54 return (struct thread_info *)(sp & ~(THREAD_SIZE - 1)); 55 } 56 57 register unsigned long current_stack_pointer asm("sp"); 58 59 static inline struct thread_info *current_thread_info(void) 60 { 61 return thread_info_sp(current_stack_pointer); 62 } 63 64 extern void thread_info_init(struct thread_info *ti, unsigned int flags); 65 66 #endif /* !__ASSEMBLY__ */ 67 #endif /* _ASMARM_THREAD_INFO_H_ */ 68