xref: /OK3568_Linux_fs/kernel/arch/sparc/include/asm/thread_info_32.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * thread_info.h: sparc low-level thread information
4*4882a593Smuzhiyun  * adapted from the ppc version by Pete Zaitcev, which was
5*4882a593Smuzhiyun  * adapted from the i386 version by Paul Mackerras
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  * Copyright (C) 2002  David Howells (dhowells@redhat.com)
8*4882a593Smuzhiyun  * Copyright (c) 2002  Pete Zaitcev (zaitcev@yahoo.com)
9*4882a593Smuzhiyun  * - Incorporating suggestions made by Linus Torvalds and Dave Miller
10*4882a593Smuzhiyun  */
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun #ifndef _ASM_THREAD_INFO_H
13*4882a593Smuzhiyun #define _ASM_THREAD_INFO_H
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun #ifdef __KERNEL__
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun #ifndef __ASSEMBLY__
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun #include <asm/ptrace.h>
20*4882a593Smuzhiyun #include <asm/page.h>
21*4882a593Smuzhiyun 
22*4882a593Smuzhiyun /*
23*4882a593Smuzhiyun  * Low level task data.
24*4882a593Smuzhiyun  *
25*4882a593Smuzhiyun  * If you change this, change the TI_* offsets below to match.
26*4882a593Smuzhiyun  */
27*4882a593Smuzhiyun #define NSWINS 8
28*4882a593Smuzhiyun struct thread_info {
29*4882a593Smuzhiyun 	unsigned long		uwinmask;
30*4882a593Smuzhiyun 	struct task_struct	*task;		/* main task structure */
31*4882a593Smuzhiyun 	unsigned long		flags;		/* low level flags */
32*4882a593Smuzhiyun 	int			cpu;		/* cpu we're on */
33*4882a593Smuzhiyun 	int			preempt_count;	/* 0 => preemptable,
34*4882a593Smuzhiyun 						   <0 => BUG */
35*4882a593Smuzhiyun 	int			softirq_count;
36*4882a593Smuzhiyun 	int			hardirq_count;
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun 	u32 __unused;
39*4882a593Smuzhiyun 
40*4882a593Smuzhiyun 	/* Context switch saved kernel state. */
41*4882a593Smuzhiyun 	unsigned long ksp;	/* ... ksp __attribute__ ((aligned (8))); */
42*4882a593Smuzhiyun 	unsigned long kpc;
43*4882a593Smuzhiyun 	unsigned long kpsr;
44*4882a593Smuzhiyun 	unsigned long kwim;
45*4882a593Smuzhiyun 
46*4882a593Smuzhiyun 	/* A place to store user windows and stack pointers
47*4882a593Smuzhiyun 	 * when the stack needs inspection.
48*4882a593Smuzhiyun 	 */
49*4882a593Smuzhiyun 	struct reg_window32	reg_window[NSWINS];	/* align for ldd! */
50*4882a593Smuzhiyun 	unsigned long		rwbuf_stkptrs[NSWINS];
51*4882a593Smuzhiyun 	unsigned long		w_saved;
52*4882a593Smuzhiyun };
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun /*
55*4882a593Smuzhiyun  * macros/functions for gaining access to the thread information structure
56*4882a593Smuzhiyun  */
57*4882a593Smuzhiyun #define INIT_THREAD_INFO(tsk)				\
58*4882a593Smuzhiyun {							\
59*4882a593Smuzhiyun 	.uwinmask	=	0,			\
60*4882a593Smuzhiyun 	.task		=	&tsk,			\
61*4882a593Smuzhiyun 	.flags		=	0,			\
62*4882a593Smuzhiyun 	.cpu		=	0,			\
63*4882a593Smuzhiyun 	.preempt_count	=	INIT_PREEMPT_COUNT,	\
64*4882a593Smuzhiyun }
65*4882a593Smuzhiyun 
66*4882a593Smuzhiyun /* how to get the thread information struct from C */
67*4882a593Smuzhiyun register struct thread_info *current_thread_info_reg asm("g6");
68*4882a593Smuzhiyun #define current_thread_info()   (current_thread_info_reg)
69*4882a593Smuzhiyun 
70*4882a593Smuzhiyun /*
71*4882a593Smuzhiyun  * thread information allocation
72*4882a593Smuzhiyun  */
73*4882a593Smuzhiyun #define THREAD_SIZE_ORDER  1
74*4882a593Smuzhiyun 
75*4882a593Smuzhiyun #endif /* __ASSEMBLY__ */
76*4882a593Smuzhiyun 
77*4882a593Smuzhiyun /* Size of kernel stack for each process */
78*4882a593Smuzhiyun #define THREAD_SIZE		(2 * PAGE_SIZE)
79*4882a593Smuzhiyun 
80*4882a593Smuzhiyun /*
81*4882a593Smuzhiyun  * Offsets in thread_info structure, used in assembly code
82*4882a593Smuzhiyun  * The "#define REGWIN_SZ 0x40" was abolished, so no multiplications.
83*4882a593Smuzhiyun  */
84*4882a593Smuzhiyun #define TI_UWINMASK	0x00	/* uwinmask */
85*4882a593Smuzhiyun #define TI_TASK		0x04
86*4882a593Smuzhiyun #define TI_FLAGS	0x08
87*4882a593Smuzhiyun #define TI_CPU		0x0c
88*4882a593Smuzhiyun #define TI_PREEMPT	0x10	/* preempt_count */
89*4882a593Smuzhiyun #define TI_SOFTIRQ	0x14	/* softirq_count */
90*4882a593Smuzhiyun #define TI_HARDIRQ	0x18	/* hardirq_count */
91*4882a593Smuzhiyun #define TI_KSP		0x20	/* ksp */
92*4882a593Smuzhiyun #define TI_KPC		0x24	/* kpc (ldd'ed with kpc) */
93*4882a593Smuzhiyun #define TI_KPSR		0x28	/* kpsr */
94*4882a593Smuzhiyun #define TI_KWIM		0x2c	/* kwim (ldd'ed with kpsr) */
95*4882a593Smuzhiyun #define TI_REG_WINDOW	0x30
96*4882a593Smuzhiyun #define TI_RWIN_SPTRS	0x230
97*4882a593Smuzhiyun #define TI_W_SAVED	0x250
98*4882a593Smuzhiyun 
99*4882a593Smuzhiyun /*
100*4882a593Smuzhiyun  * thread information flag bit numbers
101*4882a593Smuzhiyun  */
102*4882a593Smuzhiyun #define TIF_SYSCALL_TRACE	0	/* syscall trace active */
103*4882a593Smuzhiyun #define TIF_NOTIFY_RESUME	1	/* callback before returning to user */
104*4882a593Smuzhiyun #define TIF_SIGPENDING		2	/* signal pending */
105*4882a593Smuzhiyun #define TIF_NEED_RESCHED	3	/* rescheduling necessary */
106*4882a593Smuzhiyun #define TIF_RESTORE_SIGMASK	4	/* restore signal mask in do_signal() */
107*4882a593Smuzhiyun #define TIF_NOTIFY_SIGNAL	5	/* signal notifications exist */
108*4882a593Smuzhiyun #define TIF_USEDFPU		8	/* FPU was used by this task
109*4882a593Smuzhiyun 					 * this quantum (SMP) */
110*4882a593Smuzhiyun #define TIF_POLLING_NRFLAG	9	/* true if poll_idle() is polling
111*4882a593Smuzhiyun 					 * TIF_NEED_RESCHED */
112*4882a593Smuzhiyun #define TIF_MEMDIE		10	/* is terminating due to OOM killer */
113*4882a593Smuzhiyun 
114*4882a593Smuzhiyun /* as above, but as bit values */
115*4882a593Smuzhiyun #define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
116*4882a593Smuzhiyun #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
117*4882a593Smuzhiyun #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
118*4882a593Smuzhiyun #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
119*4882a593Smuzhiyun #define _TIF_NOTIFY_SIGNAL	(1<<TIF_NOTIFY_SIGNAL)
120*4882a593Smuzhiyun #define _TIF_USEDFPU		(1<<TIF_USEDFPU)
121*4882a593Smuzhiyun #define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
122*4882a593Smuzhiyun 
123*4882a593Smuzhiyun #define _TIF_DO_NOTIFY_RESUME_MASK	(_TIF_NOTIFY_RESUME | \
124*4882a593Smuzhiyun 					 _TIF_SIGPENDING | _TIF_NOTIFY_SIGNAL)
125*4882a593Smuzhiyun 
126*4882a593Smuzhiyun #define is_32bit_task()	(1)
127*4882a593Smuzhiyun 
128*4882a593Smuzhiyun #endif /* __KERNEL__ */
129*4882a593Smuzhiyun 
130*4882a593Smuzhiyun #endif /* _ASM_THREAD_INFO_H */
131