xref: /OK3568_Linux_fs/kernel/arch/alpha/include/asm/thread_info.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef _ALPHA_THREAD_INFO_H
3*4882a593Smuzhiyun #define _ALPHA_THREAD_INFO_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #ifdef __KERNEL__
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun #ifndef __ASSEMBLY__
8*4882a593Smuzhiyun #include <asm/processor.h>
9*4882a593Smuzhiyun #include <asm/types.h>
10*4882a593Smuzhiyun #include <asm/hwrpb.h>
11*4882a593Smuzhiyun #include <asm/sysinfo.h>
12*4882a593Smuzhiyun #endif
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun #ifndef __ASSEMBLY__
15*4882a593Smuzhiyun struct thread_info {
16*4882a593Smuzhiyun 	struct pcb_struct	pcb;		/* palcode state */
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun 	struct task_struct	*task;		/* main task structure */
19*4882a593Smuzhiyun 	unsigned int		flags;		/* low level flags */
20*4882a593Smuzhiyun 	unsigned int		ieee_state;	/* see fpu.h */
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun 	mm_segment_t		addr_limit;	/* thread address space */
23*4882a593Smuzhiyun 	unsigned		cpu;		/* current CPU */
24*4882a593Smuzhiyun 	int			preempt_count; /* 0 => preemptable, <0 => BUG */
25*4882a593Smuzhiyun 	unsigned int		status;		/* thread-synchronous flags */
26*4882a593Smuzhiyun 
27*4882a593Smuzhiyun 	int bpt_nsaved;
28*4882a593Smuzhiyun 	unsigned long bpt_addr[2];		/* breakpoint handling  */
29*4882a593Smuzhiyun 	unsigned int bpt_insn[2];
30*4882a593Smuzhiyun };
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun /*
33*4882a593Smuzhiyun  * Macros/functions for gaining access to the thread information structure.
34*4882a593Smuzhiyun  */
35*4882a593Smuzhiyun #define INIT_THREAD_INFO(tsk)			\
36*4882a593Smuzhiyun {						\
37*4882a593Smuzhiyun 	.task		= &tsk,			\
38*4882a593Smuzhiyun 	.addr_limit	= KERNEL_DS,		\
39*4882a593Smuzhiyun 	.preempt_count	= INIT_PREEMPT_COUNT,	\
40*4882a593Smuzhiyun }
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun /* How to get the thread information struct from C.  */
43*4882a593Smuzhiyun register struct thread_info *__current_thread_info __asm__("$8");
44*4882a593Smuzhiyun #define current_thread_info()  __current_thread_info
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun #endif /* __ASSEMBLY__ */
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun /* Thread information allocation.  */
49*4882a593Smuzhiyun #define THREAD_SIZE_ORDER 1
50*4882a593Smuzhiyun #define THREAD_SIZE (2*PAGE_SIZE)
51*4882a593Smuzhiyun 
52*4882a593Smuzhiyun /*
53*4882a593Smuzhiyun  * Thread information flags:
54*4882a593Smuzhiyun  * - these are process state flags and used from assembly
55*4882a593Smuzhiyun  * - pending work-to-be-done flags come first and must be assigned to be
56*4882a593Smuzhiyun  *   within bits 0 to 7 to fit in and immediate operand.
57*4882a593Smuzhiyun  *
58*4882a593Smuzhiyun  * TIF_SYSCALL_TRACE is known to be 0 via blbs.
59*4882a593Smuzhiyun  */
60*4882a593Smuzhiyun #define TIF_SYSCALL_TRACE	0	/* syscall trace active */
61*4882a593Smuzhiyun #define TIF_NOTIFY_RESUME	1	/* callback before returning to user */
62*4882a593Smuzhiyun #define TIF_SIGPENDING		2	/* signal pending */
63*4882a593Smuzhiyun #define TIF_NEED_RESCHED	3	/* rescheduling necessary */
64*4882a593Smuzhiyun #define TIF_SYSCALL_AUDIT	4	/* syscall audit active */
65*4882a593Smuzhiyun #define TIF_NOTIFY_SIGNAL	5	/* signal notifications exist */
66*4882a593Smuzhiyun #define TIF_DIE_IF_KERNEL	9	/* dik recursion lock */
67*4882a593Smuzhiyun #define TIF_MEMDIE		13	/* is terminating due to OOM killer */
68*4882a593Smuzhiyun #define TIF_POLLING_NRFLAG	14	/* idle is polling for TIF_NEED_RESCHED */
69*4882a593Smuzhiyun 
70*4882a593Smuzhiyun #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
71*4882a593Smuzhiyun #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
72*4882a593Smuzhiyun #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
73*4882a593Smuzhiyun #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
74*4882a593Smuzhiyun #define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
75*4882a593Smuzhiyun #define _TIF_NOTIFY_SIGNAL	(1<<TIF_NOTIFY_SIGNAL)
76*4882a593Smuzhiyun #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
77*4882a593Smuzhiyun 
78*4882a593Smuzhiyun /* Work to do on interrupt/exception return.  */
79*4882a593Smuzhiyun #define _TIF_WORK_MASK		(_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
80*4882a593Smuzhiyun 				 _TIF_NOTIFY_RESUME | _TIF_NOTIFY_SIGNAL)
81*4882a593Smuzhiyun 
82*4882a593Smuzhiyun /* Work to do on any return to userspace.  */
83*4882a593Smuzhiyun #define _TIF_ALLWORK_MASK	(_TIF_WORK_MASK		\
84*4882a593Smuzhiyun 				 | _TIF_SYSCALL_TRACE)
85*4882a593Smuzhiyun 
86*4882a593Smuzhiyun #define TS_UAC_NOPRINT		0x0001	/* ! Preserve the following three */
87*4882a593Smuzhiyun #define TS_UAC_NOFIX		0x0002	/* ! flags as they match          */
88*4882a593Smuzhiyun #define TS_UAC_SIGBUS		0x0004	/* ! userspace part of 'osf_sysinfo' */
89*4882a593Smuzhiyun 
90*4882a593Smuzhiyun #define SET_UNALIGN_CTL(task,value)	({				\
91*4882a593Smuzhiyun 	__u32 status = task_thread_info(task)->status & ~UAC_BITMASK;	\
92*4882a593Smuzhiyun 	if (value & PR_UNALIGN_NOPRINT)					\
93*4882a593Smuzhiyun 		status |= TS_UAC_NOPRINT;				\
94*4882a593Smuzhiyun 	if (value & PR_UNALIGN_SIGBUS)					\
95*4882a593Smuzhiyun 		status |= TS_UAC_SIGBUS;				\
96*4882a593Smuzhiyun 	if (value & 4)	/* alpha-specific */				\
97*4882a593Smuzhiyun 		status |= TS_UAC_NOFIX;					\
98*4882a593Smuzhiyun 	task_thread_info(task)->status = status;			\
99*4882a593Smuzhiyun 	0; })
100*4882a593Smuzhiyun 
101*4882a593Smuzhiyun #define GET_UNALIGN_CTL(task,value)	({				\
102*4882a593Smuzhiyun 	__u32 status = task_thread_info(task)->status & ~UAC_BITMASK;	\
103*4882a593Smuzhiyun 	__u32 res = 0;							\
104*4882a593Smuzhiyun 	if (status & TS_UAC_NOPRINT)					\
105*4882a593Smuzhiyun 		res |= PR_UNALIGN_NOPRINT;				\
106*4882a593Smuzhiyun 	if (status & TS_UAC_SIGBUS)					\
107*4882a593Smuzhiyun 		res |= PR_UNALIGN_SIGBUS;				\
108*4882a593Smuzhiyun 	if (status & TS_UAC_NOFIX)					\
109*4882a593Smuzhiyun 		res |= 4;						\
110*4882a593Smuzhiyun 	put_user(res, (int __user *)(value));				\
111*4882a593Smuzhiyun 	})
112*4882a593Smuzhiyun 
113*4882a593Smuzhiyun #endif /* __KERNEL__ */
114*4882a593Smuzhiyun #endif /* _ALPHA_THREAD_INFO_H */
115