blob: ff6ccb3d24c6121bb1c1da217ee3075f3da033a2 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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/btfixup.h>
19#include <asm/ptrace.h>
20#include <asm/page.h>
21
22/*
23 * Low level task data.
24 *
25 * If you change this, change the TI_* offsets below to match.
26 */
27#define NSWINS 8
28struct thread_info {
29 unsigned long uwinmask;
30 struct task_struct *task; /* main task structure */
31 struct exec_domain *exec_domain; /* execution domain */
32 unsigned long flags; /* low level flags */
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 int cpu; /* cpu we're on */
Jesper Juhldcd497f2005-06-23 00:09:07 -070034 int preempt_count; /* 0 => preemptable,
35 <0 => BUG */
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 int softirq_count;
37 int hardirq_count;
38
39 /* Context switch saved kernel state. */
40 unsigned long ksp; /* ... ksp __attribute__ ((aligned (8))); */
41 unsigned long kpc;
42 unsigned long kpsr;
43 unsigned long kwim;
44
45 /* A place to store user windows and stack pointers
46 * when the stack needs inspection.
47 */
48 struct reg_window reg_window[NSWINS]; /* align for ldd! */
49 unsigned long rwbuf_stkptrs[NSWINS];
50 unsigned long w_saved;
51
52 struct restart_block restart_block;
53};
54
55/*
56 * macros/functions for gaining access to the thread information structure
57 *
58 * preempt_count needs to be 1 initially, until the scheduler is functional.
59 */
60#define INIT_THREAD_INFO(tsk) \
61{ \
62 .uwinmask = 0, \
63 .task = &tsk, \
64 .exec_domain = &default_exec_domain, \
65 .flags = 0, \
66 .cpu = 0, \
67 .preempt_count = 1, \
68 .restart_block = { \
69 .fn = do_no_restart_syscall, \
70 }, \
71}
72
73#define init_thread_info (init_thread_union.thread_info)
74#define init_stack (init_thread_union.stack)
75
76/* how to get the thread information struct from C */
77register struct thread_info *current_thread_info_reg asm("g6");
78#define current_thread_info() (current_thread_info_reg)
79
80/*
81 * thread information allocation
82 */
83#if PAGE_SHIFT == 13
84#define THREAD_INFO_ORDER 0
85#else /* PAGE_SHIFT */
86#define THREAD_INFO_ORDER 1
87#endif
88
89BTFIXUPDEF_CALL(struct thread_info *, alloc_thread_info, void)
90#define alloc_thread_info(tsk) BTFIXUP_CALL(alloc_thread_info)()
91
92BTFIXUPDEF_CALL(void, free_thread_info, struct thread_info *)
93#define free_thread_info(ti) BTFIXUP_CALL(free_thread_info)(ti)
94
95#define get_thread_info(ti) get_task_struct((ti)->task)
96#define put_thread_info(ti) put_task_struct((ti)->task)
97
98#endif /* __ASSEMBLY__ */
99
100/*
101 * Size of kernel stack for each process.
102 * Observe the order of get_free_pages() in alloc_thread_info().
103 * The sun4 has 8K stack too, because it's short on memory, and 16K is a waste.
104 */
105#define THREAD_SIZE 8192
106
107/*
108 * Offsets in thread_info structure, used in assembly code
109 * The "#define REGWIN_SZ 0x40" was abolished, so no multiplications.
110 */
111#define TI_UWINMASK 0x00 /* uwinmask */
112#define TI_TASK 0x04
113#define TI_EXECDOMAIN 0x08 /* exec_domain */
114#define TI_FLAGS 0x0c
115#define TI_CPU 0x10
116#define TI_PREEMPT 0x14 /* preempt_count */
117#define TI_SOFTIRQ 0x18 /* softirq_count */
118#define TI_HARDIRQ 0x1c /* hardirq_count */
119#define TI_KSP 0x20 /* ksp */
120#define TI_KPC 0x24 /* kpc (ldd'ed with kpc) */
121#define TI_KPSR 0x28 /* kpsr */
122#define TI_KWIM 0x2c /* kwim (ldd'ed with kpsr) */
123#define TI_REG_WINDOW 0x30
124#define TI_RWIN_SPTRS 0x230
125#define TI_W_SAVED 0x250
126/* #define TI_RESTART_BLOCK 0x25n */ /* Nobody cares */
127
128#define PREEMPT_ACTIVE 0x4000000
129
130/*
131 * thread information flag bit numbers
132 */
133#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
134#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
135#define TIF_SIGPENDING 2 /* signal pending */
136#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
137#define TIF_USEDFPU 8 /* FPU was used by this task
138 * this quantum (SMP) */
139#define TIF_POLLING_NRFLAG 9 /* true if poll_idle() is polling
140 * TIF_NEED_RESCHED */
141#define TIF_MEMDIE 10
142
143/* as above, but as bit values */
144#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
145#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
146#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
147#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
148#define _TIF_USEDFPU (1<<TIF_USEDFPU)
149#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
150
151#endif /* __KERNEL__ */
152
153#endif /* _ASM_THREAD_INFO_H */