blob: 5076a8860b18ff4440ee9d9187e57d696406321d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _ALPHA_THREAD_INFO_H
2#define _ALPHA_THREAD_INFO_H
3
4#ifdef __KERNEL__
5
6#ifndef __ASSEMBLY__
7#include <asm/processor.h>
8#include <asm/types.h>
9#include <asm/hwrpb.h>
10#endif
11
12#ifndef __ASSEMBLY__
13struct thread_info {
14 struct pcb_struct pcb; /* palcode state */
15
16 struct task_struct *task; /* main task structure */
17 unsigned int flags; /* low level flags */
18 unsigned int ieee_state; /* see fpu.h */
19
20 struct exec_domain *exec_domain; /* execution domain */
21 mm_segment_t addr_limit; /* thread address space */
22 unsigned cpu; /* current CPU */
23 int preempt_count; /* 0 => preemptable, <0 => BUG */
24
25 int bpt_nsaved;
26 unsigned long bpt_addr[2]; /* breakpoint handling */
27 unsigned int bpt_insn[2];
28
29 struct restart_block restart_block;
30};
31
32/*
33 * Macros/functions for gaining access to the thread information structure.
34 */
35#define INIT_THREAD_INFO(tsk) \
36{ \
37 .task = &tsk, \
38 .exec_domain = &default_exec_domain, \
39 .addr_limit = KERNEL_DS, \
Peter Zijlstrac99e6ef2009-07-10 14:57:56 +020040 .preempt_count = INIT_PREEMPT_COUNT, \
Linus Torvalds1da177e2005-04-16 15:20:36 -070041 .restart_block = { \
42 .fn = do_no_restart_syscall, \
43 }, \
44}
45
46#define init_thread_info (init_thread_union.thread_info)
47#define init_stack (init_thread_union.stack)
48
49/* How to get the thread information struct from C. */
50register struct thread_info *__current_thread_info __asm__("$8");
51#define current_thread_info() __current_thread_info
52
53/* Thread information allocation. */
FUJITA Tomonorib69c49b2008-07-25 01:45:40 -070054#define THREAD_SIZE_ORDER 1
Linus Torvalds1da177e2005-04-16 15:20:36 -070055#define THREAD_SIZE (2*PAGE_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
57#endif /* __ASSEMBLY__ */
58
59#define PREEMPT_ACTIVE 0x40000000
60
61/*
62 * Thread information flags:
63 * - these are process state flags and used from assembly
64 * - pending work-to-be-done flags come first to fit in and immediate operand.
65 *
66 * TIF_SYSCALL_TRACE is known to be 0 via blbs.
67 */
68#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
Stephane Eraniana583f1b2007-07-31 00:38:00 -070069#define TIF_SIGPENDING 1 /* signal pending */
70#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
71#define TIF_POLLING_NRFLAG 3 /* poll_idle is polling NEED_RESCHED */
72#define TIF_DIE_IF_KERNEL 4 /* dik recursion lock */
73#define TIF_UAC_NOPRINT 5 /* see sysinfo.h */
74#define TIF_UAC_NOFIX 6
75#define TIF_UAC_SIGBUS 7
76#define TIF_MEMDIE 8
77#define TIF_RESTORE_SIGMASK 9 /* restore signal mask in do_signal */
David Howellsd0420c82009-09-02 09:14:16 +010078#define TIF_NOTIFY_RESUME 10 /* callback before returning to user */
Matt Helsley83224b02008-10-18 20:27:18 -070079#define TIF_FREEZE 16 /* is freezing for suspend */
Linus Torvalds1da177e2005-04-16 15:20:36 -070080
81#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
Linus Torvalds1da177e2005-04-16 15:20:36 -070082#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
83#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
84#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
Richard Hendersonb927b3e2007-05-29 16:03:28 -070085#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
David Howellsd0420c82009-09-02 09:14:16 +010086#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
Matt Helsley83224b02008-10-18 20:27:18 -070087#define _TIF_FREEZE (1<<TIF_FREEZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
89/* Work to do on interrupt/exception return. */
David Howellsd0420c82009-09-02 09:14:16 +010090#define _TIF_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
91 _TIF_NOTIFY_RESUME)
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
93/* Work to do on any return to userspace. */
94#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK \
95 | _TIF_SYSCALL_TRACE)
96
Ivan Kokshayskyed58a592007-05-06 14:50:38 -070097#define ALPHA_UAC_SHIFT 6
98#define ALPHA_UAC_MASK (1 << TIF_UAC_NOPRINT | 1 << TIF_UAC_NOFIX | \
99 1 << TIF_UAC_SIGBUS)
100
101#define SET_UNALIGN_CTL(task,value) ({ \
Roman Zippelf7e42172007-05-09 02:35:17 -0700102 task_thread_info(task)->flags = ((task_thread_info(task)->flags & \
Ivan Kokshayskyed58a592007-05-06 14:50:38 -0700103 ~ALPHA_UAC_MASK) \
104 | (((value) << ALPHA_UAC_SHIFT) & (1<<TIF_UAC_NOPRINT))\
105 | (((value) << (ALPHA_UAC_SHIFT + 1)) & (1<<TIF_UAC_SIGBUS)) \
106 | (((value) << (ALPHA_UAC_SHIFT - 1)) & (1<<TIF_UAC_NOFIX)));\
107 0; })
108
109#define GET_UNALIGN_CTL(task,value) ({ \
Roman Zippelf7e42172007-05-09 02:35:17 -0700110 put_user((task_thread_info(task)->flags & (1 << TIF_UAC_NOPRINT))\
Ivan Kokshayskyed58a592007-05-06 14:50:38 -0700111 >> ALPHA_UAC_SHIFT \
Roman Zippelf7e42172007-05-09 02:35:17 -0700112 | (task_thread_info(task)->flags & (1 << TIF_UAC_SIGBUS))\
Ivan Kokshayskyed58a592007-05-06 14:50:38 -0700113 >> (ALPHA_UAC_SHIFT + 1) \
Roman Zippelf7e42172007-05-09 02:35:17 -0700114 | (task_thread_info(task)->flags & (1 << TIF_UAC_NOFIX))\
Ivan Kokshayskyed58a592007-05-06 14:50:38 -0700115 >> (ALPHA_UAC_SHIFT - 1), \
116 (int __user *)(value)); \
117 })
118
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119#endif /* __KERNEL__ */
120#endif /* _ALPHA_THREAD_INFO_H */