xref: /linux/arch/microblaze/include/asm/thread_info.h (revision 02680c23d7b3febe45ea3d4f9818c2b2dc89020a)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * Copyright (C) 2006 Atmark Techno, Inc.
4  */
5 
6 #ifndef _ASM_MICROBLAZE_THREAD_INFO_H
7 #define _ASM_MICROBLAZE_THREAD_INFO_H
8 
9 #ifdef __KERNEL__
10 
11 /* we have 8k stack */
12 #define THREAD_SHIFT		13
13 #define THREAD_SIZE		(1 << THREAD_SHIFT)
14 #define THREAD_SIZE_ORDER	1
15 
16 #ifndef __ASSEMBLY__
17 # include <linux/types.h>
18 # include <asm/processor.h>
19 
20 /*
21  * low level task data that entry.S needs immediate access to
22  * - this struct should fit entirely inside of one cache line
23  * - this struct shares the supervisor stack pages
24  * - if the contents of this structure are changed, the assembly constants
25  *	 must also be changed
26  */
27 
28 struct cpu_context {
29 	__u32	r1; /* stack pointer */
30 	__u32	r2;
31 	/* dedicated registers */
32 	__u32	r13;
33 	__u32	r14;
34 	__u32	r15;
35 	__u32	r16;
36 	__u32	r17;
37 	__u32	r18;
38 	/* non-volatile registers */
39 	__u32	r19;
40 	__u32	r20;
41 	__u32	r21;
42 	__u32	r22;
43 	__u32	r23;
44 	__u32	r24;
45 	__u32	r25;
46 	__u32	r26;
47 	__u32	r27;
48 	__u32	r28;
49 	__u32	r29;
50 	__u32	r30;
51 	/* r31 is used as current task pointer */
52 	/* special purpose registers */
53 	__u32	msr;
54 	__u32	ear;
55 	__u32	esr;
56 	__u32	fsr;
57 };
58 
59 typedef struct {
60 	unsigned long seg;
61 } mm_segment_t;
62 
63 struct thread_info {
64 	struct task_struct	*task; /* main task structure */
65 	unsigned long		flags; /* low level flags */
66 	unsigned long		status; /* thread-synchronous flags */
67 	__u32			cpu; /* current CPU */
68 	__s32			preempt_count; /* 0 => preemptable,< 0 => BUG*/
69 	mm_segment_t		addr_limit; /* thread address space */
70 
71 	struct cpu_context	cpu_context;
72 };
73 
74 /*
75  * macros/functions for gaining access to the thread information structure
76  */
77 #define INIT_THREAD_INFO(tsk)			\
78 {						\
79 	.task		= &tsk,			\
80 	.flags		= 0,			\
81 	.cpu		= 0,			\
82 	.preempt_count	= INIT_PREEMPT_COUNT,	\
83 	.addr_limit	= KERNEL_DS,		\
84 }
85 
86 /* how to get the thread information struct from C */
87 static inline struct thread_info *current_thread_info(void)
88 {
89 	register unsigned long sp asm("r1");
90 
91 	return (struct thread_info *)(sp & ~(THREAD_SIZE-1));
92 }
93 
94 /* thread information allocation */
95 #endif /* __ASSEMBLY__ */
96 
97 /*
98  * thread information flags
99  * - these are process state flags that various assembly files may
100  *   need to access
101  * - pending work-to-be-done flags are in LSW
102  * - other flags in MSW
103  */
104 #define TIF_SYSCALL_TRACE	0 /* syscall trace active */
105 #define TIF_NOTIFY_RESUME	1 /* resumption notification requested */
106 #define TIF_SIGPENDING		2 /* signal pending */
107 #define TIF_NEED_RESCHED	3 /* rescheduling necessary */
108 /* restore singlestep on return to user mode */
109 #define TIF_SINGLESTEP		4
110 #define TIF_NOTIFY_SIGNAL	5	/* signal notifications exist */
111 #define TIF_MEMDIE		6	/* is terminating due to OOM killer */
112 #define TIF_SYSCALL_AUDIT	9       /* syscall auditing active */
113 #define TIF_SECCOMP		10      /* secure computing */
114 
115 /* true if poll_idle() is polling TIF_NEED_RESCHED */
116 #define TIF_POLLING_NRFLAG	16
117 
118 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
119 #define _TIF_NOTIFY_RESUME	(1 << TIF_NOTIFY_RESUME)
120 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
121 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
122 #define _TIF_SINGLESTEP		(1 << TIF_SINGLESTEP)
123 #define _TIF_NOTIFY_SIGNAL	(1 << TIF_NOTIFY_SIGNAL)
124 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
125 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
126 #define _TIF_SECCOMP		(1 << TIF_SECCOMP)
127 
128 /* work to do in syscall trace */
129 #define _TIF_WORK_SYSCALL_MASK  (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \
130 				 _TIF_SYSCALL_AUDIT | _TIF_SECCOMP)
131 
132 /* work to do on interrupt/exception return */
133 #define _TIF_WORK_MASK		0x0000FFFE
134 
135 /* work to do on any return to u-space */
136 #define _TIF_ALLWORK_MASK	0x0000FFFF
137 
138 /*
139  * Thread-synchronous status.
140  *
141  * This is different from the flags in that nobody else
142  * ever touches our thread-synchronous status, so we don't
143  * have to worry about atomic accesses.
144  */
145 /* FPU was used by this task this quantum (SMP) */
146 #define TS_USEDFPU		0x0001
147 
148 #endif /* __KERNEL__ */
149 #endif /* _ASM_MICROBLAZE_THREAD_INFO_H */
150