18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * thread_info.h: sparc low-level thread information
48c2ecf20Sopenharmony_ci * adapted from the ppc version by Pete Zaitcev, which was
58c2ecf20Sopenharmony_ci * adapted from the i386 version by Paul Mackerras
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Copyright (C) 2002  David Howells (dhowells@redhat.com)
88c2ecf20Sopenharmony_ci * Copyright (c) 2002  Pete Zaitcev (zaitcev@yahoo.com)
98c2ecf20Sopenharmony_ci * - Incorporating suggestions made by Linus Torvalds and Dave Miller
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#ifndef _ASM_THREAD_INFO_H
138c2ecf20Sopenharmony_ci#define _ASM_THREAD_INFO_H
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#ifdef __KERNEL__
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci#include <asm/ptrace.h>
208c2ecf20Sopenharmony_ci#include <asm/page.h>
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci/*
238c2ecf20Sopenharmony_ci * Low level task data.
248c2ecf20Sopenharmony_ci *
258c2ecf20Sopenharmony_ci * If you change this, change the TI_* offsets below to match.
268c2ecf20Sopenharmony_ci */
278c2ecf20Sopenharmony_ci#define NSWINS 8
288c2ecf20Sopenharmony_cistruct thread_info {
298c2ecf20Sopenharmony_ci	unsigned long		uwinmask;
308c2ecf20Sopenharmony_ci	struct task_struct	*task;		/* main task structure */
318c2ecf20Sopenharmony_ci	unsigned long		flags;		/* low level flags */
328c2ecf20Sopenharmony_ci	int			cpu;		/* cpu we're on */
338c2ecf20Sopenharmony_ci	int			preempt_count;	/* 0 => preemptable,
348c2ecf20Sopenharmony_ci						   <0 => BUG */
358c2ecf20Sopenharmony_ci	int			softirq_count;
368c2ecf20Sopenharmony_ci	int			hardirq_count;
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci	u32 __unused;
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci	/* Context switch saved kernel state. */
418c2ecf20Sopenharmony_ci	unsigned long ksp;	/* ... ksp __attribute__ ((aligned (8))); */
428c2ecf20Sopenharmony_ci	unsigned long kpc;
438c2ecf20Sopenharmony_ci	unsigned long kpsr;
448c2ecf20Sopenharmony_ci	unsigned long kwim;
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci	/* A place to store user windows and stack pointers
478c2ecf20Sopenharmony_ci	 * when the stack needs inspection.
488c2ecf20Sopenharmony_ci	 */
498c2ecf20Sopenharmony_ci	struct reg_window32	reg_window[NSWINS];	/* align for ldd! */
508c2ecf20Sopenharmony_ci	unsigned long		rwbuf_stkptrs[NSWINS];
518c2ecf20Sopenharmony_ci	unsigned long		w_saved;
528c2ecf20Sopenharmony_ci};
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ci/*
558c2ecf20Sopenharmony_ci * macros/functions for gaining access to the thread information structure
568c2ecf20Sopenharmony_ci */
578c2ecf20Sopenharmony_ci#define INIT_THREAD_INFO(tsk)				\
588c2ecf20Sopenharmony_ci{							\
598c2ecf20Sopenharmony_ci	.uwinmask	=	0,			\
608c2ecf20Sopenharmony_ci	.task		=	&tsk,			\
618c2ecf20Sopenharmony_ci	.flags		=	0,			\
628c2ecf20Sopenharmony_ci	.cpu		=	0,			\
638c2ecf20Sopenharmony_ci	.preempt_count	=	INIT_PREEMPT_COUNT,	\
648c2ecf20Sopenharmony_ci}
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci/* how to get the thread information struct from C */
678c2ecf20Sopenharmony_ciregister struct thread_info *current_thread_info_reg asm("g6");
688c2ecf20Sopenharmony_ci#define current_thread_info()   (current_thread_info_reg)
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci/*
718c2ecf20Sopenharmony_ci * thread information allocation
728c2ecf20Sopenharmony_ci */
738c2ecf20Sopenharmony_ci#define THREAD_SIZE_ORDER  1
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci/* Size of kernel stack for each process */
788c2ecf20Sopenharmony_ci#define THREAD_SIZE		(2 * PAGE_SIZE)
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci/*
818c2ecf20Sopenharmony_ci * Offsets in thread_info structure, used in assembly code
828c2ecf20Sopenharmony_ci * The "#define REGWIN_SZ 0x40" was abolished, so no multiplications.
838c2ecf20Sopenharmony_ci */
848c2ecf20Sopenharmony_ci#define TI_UWINMASK	0x00	/* uwinmask */
858c2ecf20Sopenharmony_ci#define TI_TASK		0x04
868c2ecf20Sopenharmony_ci#define TI_FLAGS	0x08
878c2ecf20Sopenharmony_ci#define TI_CPU		0x0c
888c2ecf20Sopenharmony_ci#define TI_PREEMPT	0x10	/* preempt_count */
898c2ecf20Sopenharmony_ci#define TI_SOFTIRQ	0x14	/* softirq_count */
908c2ecf20Sopenharmony_ci#define TI_HARDIRQ	0x18	/* hardirq_count */
918c2ecf20Sopenharmony_ci#define TI_KSP		0x20	/* ksp */
928c2ecf20Sopenharmony_ci#define TI_KPC		0x24	/* kpc (ldd'ed with kpc) */
938c2ecf20Sopenharmony_ci#define TI_KPSR		0x28	/* kpsr */
948c2ecf20Sopenharmony_ci#define TI_KWIM		0x2c	/* kwim (ldd'ed with kpsr) */
958c2ecf20Sopenharmony_ci#define TI_REG_WINDOW	0x30
968c2ecf20Sopenharmony_ci#define TI_RWIN_SPTRS	0x230
978c2ecf20Sopenharmony_ci#define TI_W_SAVED	0x250
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci/*
1008c2ecf20Sopenharmony_ci * thread information flag bit numbers
1018c2ecf20Sopenharmony_ci */
1028c2ecf20Sopenharmony_ci#define TIF_SYSCALL_TRACE	0	/* syscall trace active */
1038c2ecf20Sopenharmony_ci#define TIF_NOTIFY_RESUME	1	/* callback before returning to user */
1048c2ecf20Sopenharmony_ci#define TIF_SIGPENDING		2	/* signal pending */
1058c2ecf20Sopenharmony_ci#define TIF_NEED_RESCHED	3	/* rescheduling necessary */
1068c2ecf20Sopenharmony_ci#define TIF_RESTORE_SIGMASK	4	/* restore signal mask in do_signal() */
1078c2ecf20Sopenharmony_ci#define TIF_NOTIFY_SIGNAL	5	/* signal notifications exist */
1088c2ecf20Sopenharmony_ci#define TIF_USEDFPU		8	/* FPU was used by this task
1098c2ecf20Sopenharmony_ci					 * this quantum (SMP) */
1108c2ecf20Sopenharmony_ci#define TIF_POLLING_NRFLAG	9	/* true if poll_idle() is polling
1118c2ecf20Sopenharmony_ci					 * TIF_NEED_RESCHED */
1128c2ecf20Sopenharmony_ci#define TIF_MEMDIE		10	/* is terminating due to OOM killer */
1138c2ecf20Sopenharmony_ci
1148c2ecf20Sopenharmony_ci/* as above, but as bit values */
1158c2ecf20Sopenharmony_ci#define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
1168c2ecf20Sopenharmony_ci#define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
1178c2ecf20Sopenharmony_ci#define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
1188c2ecf20Sopenharmony_ci#define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
1198c2ecf20Sopenharmony_ci#define _TIF_NOTIFY_SIGNAL	(1<<TIF_NOTIFY_SIGNAL)
1208c2ecf20Sopenharmony_ci#define _TIF_USEDFPU		(1<<TIF_USEDFPU)
1218c2ecf20Sopenharmony_ci#define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci#define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | \
1248c2ecf20Sopenharmony_ci					 _TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci#define is_32bit_task()	(1)
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci#endif /* _ASM_THREAD_INFO_H */
131