162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci#ifndef _ASM_M68K_THREAD_INFO_H
362306a36Sopenharmony_ci#define _ASM_M68K_THREAD_INFO_H
462306a36Sopenharmony_ci
562306a36Sopenharmony_ci#include <asm/types.h>
662306a36Sopenharmony_ci#include <asm/page.h>
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci/*
962306a36Sopenharmony_ci * On machines with 4k pages we default to an 8k thread size, though we
1062306a36Sopenharmony_ci * allow a 4k with config option. Any other machine page size then
1162306a36Sopenharmony_ci * the thread size must match the page size (which is 8k and larger here).
1262306a36Sopenharmony_ci */
1362306a36Sopenharmony_ci#if PAGE_SHIFT < 13
1462306a36Sopenharmony_ci#ifdef CONFIG_4KSTACKS
1562306a36Sopenharmony_ci#define THREAD_SIZE	4096
1662306a36Sopenharmony_ci#else
1762306a36Sopenharmony_ci#define THREAD_SIZE	8192
1862306a36Sopenharmony_ci#endif
1962306a36Sopenharmony_ci#else
2062306a36Sopenharmony_ci#define THREAD_SIZE	PAGE_SIZE
2162306a36Sopenharmony_ci#endif
2262306a36Sopenharmony_ci#define THREAD_SIZE_ORDER	((THREAD_SIZE / PAGE_SIZE) - 1)
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#ifndef __ASSEMBLY__
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_cistruct thread_info {
2762306a36Sopenharmony_ci	struct task_struct	*task;		/* main task structure */
2862306a36Sopenharmony_ci	unsigned long		flags;
2962306a36Sopenharmony_ci	int			preempt_count;	/* 0 => preemptable, <0 => BUG */
3062306a36Sopenharmony_ci	__u32			cpu;		/* should always be 0 on m68k */
3162306a36Sopenharmony_ci	unsigned long		tp_value;	/* thread pointer */
3262306a36Sopenharmony_ci};
3362306a36Sopenharmony_ci#endif /* __ASSEMBLY__ */
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci#define INIT_THREAD_INFO(tsk)			\
3662306a36Sopenharmony_ci{						\
3762306a36Sopenharmony_ci	.task		= &tsk,			\
3862306a36Sopenharmony_ci	.preempt_count	= INIT_PREEMPT_COUNT,	\
3962306a36Sopenharmony_ci}
4062306a36Sopenharmony_ci
4162306a36Sopenharmony_ci#ifndef __ASSEMBLY__
4262306a36Sopenharmony_ci/* how to get the thread information struct from C */
4362306a36Sopenharmony_cistatic inline struct thread_info *current_thread_info(void)
4462306a36Sopenharmony_ci{
4562306a36Sopenharmony_ci	struct thread_info *ti;
4662306a36Sopenharmony_ci	__asm__(
4762306a36Sopenharmony_ci		"move.l %%sp, %0 \n\t"
4862306a36Sopenharmony_ci		"and.l  %1, %0"
4962306a36Sopenharmony_ci		: "=&d"(ti)
5062306a36Sopenharmony_ci		: "di" (~(THREAD_SIZE-1))
5162306a36Sopenharmony_ci		);
5262306a36Sopenharmony_ci	return ti;
5362306a36Sopenharmony_ci}
5462306a36Sopenharmony_ci#endif
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci/* entry.S relies on these definitions!
5762306a36Sopenharmony_ci * bits 0-7 are tested at every exception exit
5862306a36Sopenharmony_ci * bits 8-15 are also tested at syscall exit
5962306a36Sopenharmony_ci */
6062306a36Sopenharmony_ci#define TIF_NOTIFY_SIGNAL	4
6162306a36Sopenharmony_ci#define TIF_NOTIFY_RESUME	5	/* callback before returning to user */
6262306a36Sopenharmony_ci#define TIF_SIGPENDING		6	/* signal pending */
6362306a36Sopenharmony_ci#define TIF_NEED_RESCHED	7	/* rescheduling necessary */
6462306a36Sopenharmony_ci#define TIF_SECCOMP		13	/* seccomp syscall filtering active */
6562306a36Sopenharmony_ci#define TIF_DELAYED_TRACE	14	/* single step a syscall */
6662306a36Sopenharmony_ci#define TIF_SYSCALL_TRACE	15	/* syscall trace active */
6762306a36Sopenharmony_ci#define TIF_MEMDIE		16	/* is terminating due to OOM killer */
6862306a36Sopenharmony_ci#define TIF_RESTORE_SIGMASK	18	/* restore signal mask in do_signal */
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci#define _TIF_NOTIFY_RESUME	(1 << TIF_NOTIFY_RESUME)
7162306a36Sopenharmony_ci#define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
7262306a36Sopenharmony_ci#define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
7362306a36Sopenharmony_ci#define _TIF_SECCOMP		(1 << TIF_SECCOMP)
7462306a36Sopenharmony_ci#define _TIF_DELAYED_TRACE	(1 << TIF_DELAYED_TRACE)
7562306a36Sopenharmony_ci#define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
7662306a36Sopenharmony_ci#define _TIF_MEMDIE		(1 << TIF_MEMDIE)
7762306a36Sopenharmony_ci#define _TIF_RESTORE_SIGMASK	(1 << TIF_RESTORE_SIGMASK)
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci#endif	/* _ASM_M68K_THREAD_INFO_H */
80