xref: /OK3568_Linux_fs/kernel/arch/xtensa/include/asm/thread_info.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * include/asm-xtensa/thread_info.h
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * This file is subject to the terms and conditions of the GNU General Public
5*4882a593Smuzhiyun  * License.  See the file "COPYING" in the main directory of this archive
6*4882a593Smuzhiyun  * for more details.
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  * Copyright (C) 2001 - 2005 Tensilica Inc.
9*4882a593Smuzhiyun  */
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun #ifndef _XTENSA_THREAD_INFO_H
12*4882a593Smuzhiyun #define _XTENSA_THREAD_INFO_H
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun #include <linux/stringify.h>
15*4882a593Smuzhiyun #include <asm/kmem_layout.h>
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun #define CURRENT_SHIFT KERNEL_STACK_SHIFT
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun #ifndef __ASSEMBLY__
20*4882a593Smuzhiyun # include <asm/processor.h>
21*4882a593Smuzhiyun #endif
22*4882a593Smuzhiyun 
23*4882a593Smuzhiyun /*
24*4882a593Smuzhiyun  * low level task data that entry.S needs immediate access to
25*4882a593Smuzhiyun  * - this struct should fit entirely inside of one cache line
26*4882a593Smuzhiyun  * - this struct shares the supervisor stack pages
27*4882a593Smuzhiyun  * - if the contents of this structure are changed, the assembly constants
28*4882a593Smuzhiyun  *   must also be changed
29*4882a593Smuzhiyun  */
30*4882a593Smuzhiyun 
31*4882a593Smuzhiyun #ifndef __ASSEMBLY__
32*4882a593Smuzhiyun 
33*4882a593Smuzhiyun #if XTENSA_HAVE_COPROCESSORS
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun typedef struct xtregs_coprocessor {
36*4882a593Smuzhiyun 	xtregs_cp0_t cp0;
37*4882a593Smuzhiyun 	xtregs_cp1_t cp1;
38*4882a593Smuzhiyun 	xtregs_cp2_t cp2;
39*4882a593Smuzhiyun 	xtregs_cp3_t cp3;
40*4882a593Smuzhiyun 	xtregs_cp4_t cp4;
41*4882a593Smuzhiyun 	xtregs_cp5_t cp5;
42*4882a593Smuzhiyun 	xtregs_cp6_t cp6;
43*4882a593Smuzhiyun 	xtregs_cp7_t cp7;
44*4882a593Smuzhiyun } xtregs_coprocessor_t;
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun #endif
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun struct thread_info {
49*4882a593Smuzhiyun 	struct task_struct	*task;		/* main task structure */
50*4882a593Smuzhiyun 	unsigned long		flags;		/* low level flags */
51*4882a593Smuzhiyun 	unsigned long		status;		/* thread-synchronous flags */
52*4882a593Smuzhiyun 	__u32			cpu;		/* current CPU */
53*4882a593Smuzhiyun 	__s32			preempt_count;	/* 0 => preemptable,< 0 => BUG*/
54*4882a593Smuzhiyun 
55*4882a593Smuzhiyun 	mm_segment_t		addr_limit;	/* thread address space */
56*4882a593Smuzhiyun 
57*4882a593Smuzhiyun 	unsigned long		cpenable;
58*4882a593Smuzhiyun #if XCHAL_HAVE_EXCLUSIVE
59*4882a593Smuzhiyun 	/* result of the most recent exclusive store */
60*4882a593Smuzhiyun 	unsigned long		atomctl8;
61*4882a593Smuzhiyun #endif
62*4882a593Smuzhiyun 
63*4882a593Smuzhiyun 	/* Allocate storage for extra user states and coprocessor states. */
64*4882a593Smuzhiyun #if XTENSA_HAVE_COPROCESSORS
65*4882a593Smuzhiyun 	xtregs_coprocessor_t	xtregs_cp;
66*4882a593Smuzhiyun #endif
67*4882a593Smuzhiyun 	xtregs_user_t		xtregs_user;
68*4882a593Smuzhiyun };
69*4882a593Smuzhiyun 
70*4882a593Smuzhiyun #endif
71*4882a593Smuzhiyun 
72*4882a593Smuzhiyun /*
73*4882a593Smuzhiyun  * macros/functions for gaining access to the thread information structure
74*4882a593Smuzhiyun  */
75*4882a593Smuzhiyun 
76*4882a593Smuzhiyun #ifndef __ASSEMBLY__
77*4882a593Smuzhiyun 
78*4882a593Smuzhiyun #define INIT_THREAD_INFO(tsk)			\
79*4882a593Smuzhiyun {						\
80*4882a593Smuzhiyun 	.task		= &tsk,			\
81*4882a593Smuzhiyun 	.flags		= 0,			\
82*4882a593Smuzhiyun 	.cpu		= 0,			\
83*4882a593Smuzhiyun 	.preempt_count	= INIT_PREEMPT_COUNT,	\
84*4882a593Smuzhiyun 	.addr_limit	= KERNEL_DS,		\
85*4882a593Smuzhiyun }
86*4882a593Smuzhiyun 
87*4882a593Smuzhiyun /* how to get the thread information struct from C */
current_thread_info(void)88*4882a593Smuzhiyun static inline struct thread_info *current_thread_info(void)
89*4882a593Smuzhiyun {
90*4882a593Smuzhiyun 	struct thread_info *ti;
91*4882a593Smuzhiyun 	 __asm__("extui %0, a1, 0, "__stringify(CURRENT_SHIFT)"\n\t"
92*4882a593Smuzhiyun 	         "xor %0, a1, %0" : "=&r" (ti) : );
93*4882a593Smuzhiyun 	return ti;
94*4882a593Smuzhiyun }
95*4882a593Smuzhiyun 
96*4882a593Smuzhiyun #else /* !__ASSEMBLY__ */
97*4882a593Smuzhiyun 
98*4882a593Smuzhiyun /* how to get the thread information struct from ASM */
99*4882a593Smuzhiyun #define GET_THREAD_INFO(reg,sp) \
100*4882a593Smuzhiyun 	extui reg, sp, 0, CURRENT_SHIFT; \
101*4882a593Smuzhiyun 	xor   reg, sp, reg
102*4882a593Smuzhiyun #endif
103*4882a593Smuzhiyun 
104*4882a593Smuzhiyun 
105*4882a593Smuzhiyun /*
106*4882a593Smuzhiyun  * thread information flags
107*4882a593Smuzhiyun  * - these are process state flags that various assembly files may need to access
108*4882a593Smuzhiyun  */
109*4882a593Smuzhiyun #define TIF_SYSCALL_TRACE	0	/* syscall trace active */
110*4882a593Smuzhiyun #define TIF_SIGPENDING		1	/* signal pending */
111*4882a593Smuzhiyun #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
112*4882a593Smuzhiyun #define TIF_SINGLESTEP		3	/* restore singlestep on return to user mode */
113*4882a593Smuzhiyun #define TIF_SYSCALL_TRACEPOINT	4	/* syscall tracepoint instrumentation */
114*4882a593Smuzhiyun #define TIF_NOTIFY_SIGNAL	5	/* signal notifications exist */
115*4882a593Smuzhiyun #define TIF_RESTORE_SIGMASK	6	/* restore signal mask in do_signal() */
116*4882a593Smuzhiyun #define TIF_NOTIFY_RESUME	7	/* callback before returning to user */
117*4882a593Smuzhiyun #define TIF_DB_DISABLED		8	/* debug trap disabled for syscall */
118*4882a593Smuzhiyun #define TIF_SYSCALL_AUDIT	9	/* syscall auditing active */
119*4882a593Smuzhiyun #define TIF_SECCOMP		10	/* secure computing */
120*4882a593Smuzhiyun #define TIF_MEMDIE		11	/* is terminating due to OOM killer */
121*4882a593Smuzhiyun 
122*4882a593Smuzhiyun #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
123*4882a593Smuzhiyun #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
124*4882a593Smuzhiyun #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
125*4882a593Smuzhiyun #define _TIF_SINGLESTEP		(1<<TIF_SINGLESTEP)
126*4882a593Smuzhiyun #define _TIF_SYSCALL_TRACEPOINT	(1<<TIF_SYSCALL_TRACEPOINT)
127*4882a593Smuzhiyun #define _TIF_NOTIFY_SIGNAL	(1<<TIF_NOTIFY_SIGNAL)
128*4882a593Smuzhiyun #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
129*4882a593Smuzhiyun #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
130*4882a593Smuzhiyun #define _TIF_SECCOMP		(1<<TIF_SECCOMP)
131*4882a593Smuzhiyun 
132*4882a593Smuzhiyun #define _TIF_WORK_MASK		(_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \
133*4882a593Smuzhiyun 				 _TIF_SYSCALL_TRACEPOINT | \
134*4882a593Smuzhiyun 				 _TIF_SYSCALL_AUDIT | _TIF_SECCOMP)
135*4882a593Smuzhiyun 
136*4882a593Smuzhiyun #define THREAD_SIZE KERNEL_STACK_SIZE
137*4882a593Smuzhiyun #define THREAD_SIZE_ORDER (KERNEL_STACK_SHIFT - PAGE_SHIFT)
138*4882a593Smuzhiyun 
139*4882a593Smuzhiyun #endif	/* _XTENSA_THREAD_INFO */
140