Linux 6.9-rc4
[sfrench/cifs-2.6.git] / arch / microblaze / include / asm / thread_info.h
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 struct thread_info {
60         struct task_struct      *task; /* main task structure */
61         unsigned long           flags; /* low level flags */
62         unsigned long           status; /* thread-synchronous flags */
63         __u32                   cpu; /* current CPU */
64         __s32                   preempt_count; /* 0 => preemptable,< 0 => BUG*/
65
66         struct cpu_context      cpu_context;
67 };
68
69 /*
70  * macros/functions for gaining access to the thread information structure
71  */
72 #define INIT_THREAD_INFO(tsk)                   \
73 {                                               \
74         .task           = &tsk,                 \
75         .flags          = 0,                    \
76         .cpu            = 0,                    \
77         .preempt_count  = INIT_PREEMPT_COUNT,   \
78 }
79
80 /* how to get the thread information struct from C */
81 static inline struct thread_info *current_thread_info(void)
82 {
83         register unsigned long sp asm("r1");
84
85         return (struct thread_info *)(sp & ~(THREAD_SIZE-1));
86 }
87
88 /* thread information allocation */
89 #endif /* __ASSEMBLY__ */
90
91 /*
92  * thread information flags
93  * - these are process state flags that various assembly files may
94  *   need to access
95  * - pending work-to-be-done flags are in LSW
96  * - other flags in MSW
97  */
98 #define TIF_SYSCALL_TRACE       0 /* syscall trace active */
99 #define TIF_NOTIFY_RESUME       1 /* resumption notification requested */
100 #define TIF_SIGPENDING          2 /* signal pending */
101 #define TIF_NEED_RESCHED        3 /* rescheduling necessary */
102 /* restore singlestep on return to user mode */
103 #define TIF_SINGLESTEP          4
104 #define TIF_NOTIFY_SIGNAL       5       /* signal notifications exist */
105 #define TIF_MEMDIE              6       /* is terminating due to OOM killer */
106 #define TIF_SYSCALL_AUDIT       9       /* syscall auditing active */
107 #define TIF_SECCOMP             10      /* secure computing */
108
109 /* true if poll_idle() is polling TIF_NEED_RESCHED */
110 #define TIF_POLLING_NRFLAG      16
111
112 #define _TIF_SYSCALL_TRACE      (1 << TIF_SYSCALL_TRACE)
113 #define _TIF_NOTIFY_RESUME      (1 << TIF_NOTIFY_RESUME)
114 #define _TIF_SIGPENDING         (1 << TIF_SIGPENDING)
115 #define _TIF_NEED_RESCHED       (1 << TIF_NEED_RESCHED)
116 #define _TIF_SINGLESTEP         (1 << TIF_SINGLESTEP)
117 #define _TIF_NOTIFY_SIGNAL      (1 << TIF_NOTIFY_SIGNAL)
118 #define _TIF_POLLING_NRFLAG     (1 << TIF_POLLING_NRFLAG)
119 #define _TIF_SYSCALL_AUDIT      (1 << TIF_SYSCALL_AUDIT)
120 #define _TIF_SECCOMP            (1 << TIF_SECCOMP)
121
122 /* work to do in syscall trace */
123 #define _TIF_WORK_SYSCALL_MASK  (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \
124                                  _TIF_SYSCALL_AUDIT | _TIF_SECCOMP)
125
126 /* work to do on interrupt/exception return */
127 #define _TIF_WORK_MASK          0x0000FFFE
128
129 /* work to do on any return to u-space */
130 #define _TIF_ALLWORK_MASK       0x0000FFFF
131
132 /*
133  * Thread-synchronous status.
134  *
135  * This is different from the flags in that nobody else
136  * ever touches our thread-synchronous status, so we don't
137  * have to worry about atomic accesses.
138  */
139 /* FPU was used by this task this quantum (SMP) */
140 #define TS_USEDFPU              0x0001
141
142 #endif /* __KERNEL__ */
143 #endif /* _ASM_MICROBLAZE_THREAD_INFO_H */