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.ksp))->r8))
42 
43 static inline struct thread_info *current_thread_info(void)
44 {
45 	unsigned long sp;
46 
47 	asm volatile("mov %0, sp\n":"=r"(sp));
48 
49 	return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
50 }
51 
52 #endif /* !__ASSEMBLY__ */
53 
54 /* entry.S relies on these definitions!
55  * bits 0-5 are tested at every exception exit
56  */
57 #define TIF_SIGPENDING		0	/* signal pending */
58 #define TIF_NOTIFY_RESUME	1       /* callback before returning to user */
59 #define TIF_NEED_RESCHED	2	/* rescheduling necessary */
60 #define TIF_SYSCALL_TRACE	5	/* syscall trace active */
61 #define TIF_DELAYED_TRACE	14	/* single step a syscall */
62 #define TIF_POLLING_NRFLAG	16	/* poll_idle() is TIF_NEED_RESCHED */
63 #define TIF_MEMDIE		18      /* is terminating due to OOM killer */
64 #define TIF_FREEZE		19	/* thread is freezing for suspend */
65 #define TIF_RESTORE_SIGMASK	20	/* restore signal mask in do_signal() */
66 #define TIF_SECCOMP		21	/* secure computing */
67 
68 #define _TIF_SIGPENDING         (1 << TIF_SIGPENDING)
69 #define _TIF_NOTIFY_RESUME      (1 << TIF_NOTIFY_RESUME)
70 #define _TIF_NEED_RESCHED       (1 << TIF_NEED_RESCHED)
71 #define _TIF_SYSCALL_TRACE      (1 << TIF_SYSCALL_TRACE)
72 #define _TIF_DELAYED_TRACE	(1 << TIF_DELAYED_TRACE)
73 #define _TIF_POLLING_NRFLAG     (1 << TIF_POLLING_NRFLAG)
74 #define _TIF_MEMDIE		(1 << TIF_MEMDIE)
75 #define _TIF_FREEZE             (1 << TIF_FREEZE)
76 #define _TIF_RESTORE_SIGMASK    (1 << TIF_RESTORE_SIGMASK)
77 #define _TIF_SECCOMP            (1 << TIF_SECCOMP)
78 
79 #endif	/* _ASM_CSKY_THREAD_INFO_H */
80