xref: /linux/arch/csky/include/asm/thread_info.h (revision 95298d63c67673c654c08952672d016212b26054)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 // Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd.
3 
4 #ifndef _ASM_CSKY_THREAD_INFO_H
5 #define _ASM_CSKY_THREAD_INFO_H
6 
7 #ifndef __ASSEMBLY__
8 
9 #include <linux/version.h>
10 #include <asm/types.h>
11 #include <asm/page.h>
12 #include <asm/processor.h>
13 #include <abi/switch_context.h>
14 
15 struct thread_info {
16 	struct task_struct	*task;
17 	void			*dump_exec_domain;
18 	unsigned long		flags;
19 	int			preempt_count;
20 	unsigned long		tp_value;
21 	mm_segment_t		addr_limit;
22 	struct restart_block	restart_block;
23 	struct pt_regs		*regs;
24 	unsigned int		cpu;
25 };
26 
27 #define INIT_THREAD_INFO(tsk)			\
28 {						\
29 	.task		= &tsk,			\
30 	.preempt_count  = INIT_PREEMPT_COUNT,	\
31 	.addr_limit     = KERNEL_DS,		\
32 	.cpu		= 0,			\
33 	.restart_block = {			\
34 		.fn = do_no_restart_syscall,	\
35 	},					\
36 }
37 
38 #define THREAD_SIZE_ORDER (THREAD_SHIFT - PAGE_SHIFT)
39 
40 #define thread_saved_fp(tsk) \
41 	((unsigned long)(((struct switch_stack *)(tsk->thread.sp))->r8))
42 
43 #define thread_saved_sp(tsk) \
44 	((unsigned long)(tsk->thread.sp))
45 
46 #define thread_saved_lr(tsk) \
47 	((unsigned long)(((struct switch_stack *)(tsk->thread.sp))->r15))
48 
49 static inline struct thread_info *current_thread_info(void)
50 {
51 	unsigned long sp;
52 
53 	asm volatile("mov %0, sp\n":"=r"(sp));
54 
55 	return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
56 }
57 
58 #endif /* !__ASSEMBLY__ */
59 
60 #define TIF_SIGPENDING		0	/* signal pending */
61 #define TIF_NOTIFY_RESUME	1       /* callback before returning to user */
62 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
63 #define TIF_UPROBE		3	/* uprobe breakpoint or singlestep */
64 #define TIF_SYSCALL_TRACE	4	/* syscall trace active */
65 #define TIF_SYSCALL_TRACEPOINT	5       /* syscall tracepoint instrumentation */
66 #define TIF_SYSCALL_AUDIT	6	/* syscall auditing */
67 #define TIF_POLLING_NRFLAG	16	/* poll_idle() is TIF_NEED_RESCHED */
68 #define TIF_MEMDIE		18      /* is terminating due to OOM killer */
69 #define TIF_RESTORE_SIGMASK	20	/* restore signal mask in do_signal() */
70 #define TIF_SECCOMP		21	/* secure computing */
71 
72 #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
73 #define _TIF_NOTIFY_RESUME	(1 << TIF_NOTIFY_RESUME)
74 #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
75 #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
76 #define _TIF_SYSCALL_TRACEPOINT	(1 << TIF_SYSCALL_TRACEPOINT)
77 #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
78 #define _TIF_UPROBE		(1 << TIF_UPROBE)
79 #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
80 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
81 #define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
82 #define _TIF_SECCOMP		(1 << TIF_SECCOMP)
83 
84 #define _TIF_WORK_MASK		(_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
85 				 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
86 
87 #define _TIF_SYSCALL_WORK	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
88 				 _TIF_SYSCALL_TRACEPOINT)
89 
90 #endif	/* _ASM_CSKY_THREAD_INFO_H */
91