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_MEMDIE		6	/* is terminating due to OOM killer */
111 #define TIF_SYSCALL_AUDIT	9       /* syscall auditing active */
112 #define TIF_SECCOMP		10      /* secure computing */
113 
114 /* true if poll_idle() is polling TIF_NEED_RESCHED */
115 #define TIF_POLLING_NRFLAG	16
116 
117 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
118 #define _TIF_NOTIFY_RESUME	(1 << TIF_NOTIFY_RESUME)
119 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
120 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
121 #define _TIF_SINGLESTEP		(1 << TIF_SINGLESTEP)
122 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
123 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
124 #define _TIF_SECCOMP		(1 << TIF_SECCOMP)
125 
126 /* work to do in syscall trace */
127 #define _TIF_WORK_SYSCALL_MASK  (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \
128 				 _TIF_SYSCALL_AUDIT | _TIF_SECCOMP)
129 
130 /* work to do on interrupt/exception return */
131 #define _TIF_WORK_MASK		0x0000FFFE
132 
133 /* work to do on any return to u-space */
134 #define _TIF_ALLWORK_MASK	0x0000FFFF
135 
136 /*
137  * Thread-synchronous status.
138  *
139  * This is different from the flags in that nobody else
140  * ever touches our thread-synchronous status, so we don't
141  * have to worry about atomic accesses.
142  */
143 /* FPU was used by this task this quantum (SMP) */
144 #define TS_USEDFPU		0x0001
145 
146 #endif /* __KERNEL__ */
147 #endif /* _ASM_MICROBLAZE_THREAD_INFO_H */
148