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