blob: 1f8c72959fb6c7a1a9891833ae8d9b037cb179d5 [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>
Al Viro3185bd22012-10-20 15:52:23 +010010#include <asm/sysinfo.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#endif
12
13#ifndef __ASSEMBLY__
14struct thread_info {
15 struct pcb_struct pcb; /* palcode state */
16
17 struct task_struct *task; /* main task structure */
18 unsigned int flags; /* low level flags */
19 unsigned int ieee_state; /* see fpu.h */
20
21 struct exec_domain *exec_domain; /* execution domain */
22 mm_segment_t addr_limit; /* thread address space */
23 unsigned cpu; /* current CPU */
24 int preempt_count; /* 0 => preemptable, <0 => BUG */
Al Viro3185bd22012-10-20 15:52:23 +010025 unsigned int status; /* thread-synchronous flags */
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
27 int bpt_nsaved;
28 unsigned long bpt_addr[2]; /* breakpoint handling */
29 unsigned int bpt_insn[2];
30
31 struct restart_block restart_block;
32};
33
34/*
35 * Macros/functions for gaining access to the thread information structure.
36 */
37#define INIT_THREAD_INFO(tsk) \
38{ \
39 .task = &tsk, \
40 .exec_domain = &default_exec_domain, \
41 .addr_limit = KERNEL_DS, \
Peter Zijlstrac99e6ef2009-07-10 14:57:56 +020042 .preempt_count = INIT_PREEMPT_COUNT, \
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 .restart_block = { \
44 .fn = do_no_restart_syscall, \
45 }, \
46}
47
48#define init_thread_info (init_thread_union.thread_info)
49#define init_stack (init_thread_union.stack)
50
51/* How to get the thread information struct from C. */
52register struct thread_info *__current_thread_info __asm__("$8");
53#define current_thread_info() __current_thread_info
54
Andrew Morton15f3c472009-11-11 14:26:30 -080055#endif /* __ASSEMBLY__ */
56
Linus Torvalds1da177e2005-04-16 15:20:36 -070057/* Thread information allocation. */
FUJITA Tomonorib69c49b2008-07-25 01:45:40 -070058#define THREAD_SIZE_ORDER 1
Linus Torvalds1da177e2005-04-16 15:20:36 -070059#define THREAD_SIZE (2*PAGE_SIZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
Linus Torvalds1da177e2005-04-16 15:20:36 -070061#define PREEMPT_ACTIVE 0x40000000
62
63/*
64 * Thread information flags:
65 * - these are process state flags and used from assembly
Michael Cree745dd2402009-11-30 22:44:40 -050066 * - pending work-to-be-done flags come first and must be assigned to be
67 * within bits 0 to 7 to fit in and immediate operand.
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 *
69 * TIF_SYSCALL_TRACE is known to be 0 via blbs.
70 */
71#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
Michael Cree745dd2402009-11-30 22:44:40 -050072#define TIF_NOTIFY_RESUME 1 /* callback before returning to user */
73#define TIF_SIGPENDING 2 /* signal pending */
74#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
Michael Cree745dd2402009-11-30 22:44:40 -050075#define TIF_DIE_IF_KERNEL 9 /* dik recursion lock */
Andreas Dilger0ddc9322010-05-14 11:13:27 +020076#define TIF_MEMDIE 13 /* is terminating due to OOM killer */
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
78#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
Linus Torvalds1da177e2005-04-16 15:20:36 -070079#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
80#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
David Howellsd0420c82009-09-02 09:14:16 +010081#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83/* Work to do on interrupt/exception return. */
David Howellsd0420c82009-09-02 09:14:16 +010084#define _TIF_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
85 _TIF_NOTIFY_RESUME)
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
87/* Work to do on any return to userspace. */
88#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK \
89 | _TIF_SYSCALL_TRACE)
90
Al Viro3185bd22012-10-20 15:52:23 +010091#define TS_UAC_NOPRINT 0x0001 /* ! Preserve the following three */
92#define TS_UAC_NOFIX 0x0002 /* ! flags as they match */
93#define TS_UAC_SIGBUS 0x0004 /* ! userspace part of 'osf_sysinfo' */
94#define TS_RESTORE_SIGMASK 0x0008 /* restore signal mask in do_signal() */
95#define TS_POLLING 0x0010 /* idle task polling need_resched,
96 skip sending interrupt */
Ivan Kokshayskyed58a592007-05-06 14:50:38 -070097
Al Viro3185bd22012-10-20 15:52:23 +010098#define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING)
99
100#ifndef __ASSEMBLY__
101#define HAVE_SET_RESTORE_SIGMASK 1
102static inline void set_restore_sigmask(void)
103{
104 struct thread_info *ti = current_thread_info();
105 ti->status |= TS_RESTORE_SIGMASK;
106 WARN_ON(!test_bit(TIF_SIGPENDING, (unsigned long *)&ti->flags));
107}
108static inline void clear_restore_sigmask(void)
109{
110 current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
111}
112static inline bool test_restore_sigmask(void)
113{
114 return current_thread_info()->status & TS_RESTORE_SIGMASK;
115}
116static inline bool test_and_clear_restore_sigmask(void)
117{
118 struct thread_info *ti = current_thread_info();
119 if (!(ti->status & TS_RESTORE_SIGMASK))
120 return false;
121 ti->status &= ~TS_RESTORE_SIGMASK;
122 return true;
123}
124#endif
125
126#define SET_UNALIGN_CTL(task,value) ({ \
127 __u32 status = task_thread_info(task)->status & ~UAC_BITMASK; \
128 if (value & PR_UNALIGN_NOPRINT) \
129 status |= TS_UAC_NOPRINT; \
130 if (value & PR_UNALIGN_SIGBUS) \
131 status |= TS_UAC_SIGBUS; \
132 if (value & 4) /* alpha-specific */ \
133 status |= TS_UAC_NOFIX; \
134 task_thread_info(task)->status = status; \
Ivan Kokshayskyed58a592007-05-06 14:50:38 -0700135 0; })
136
137#define GET_UNALIGN_CTL(task,value) ({ \
Al Viro3185bd22012-10-20 15:52:23 +0100138 __u32 status = task_thread_info(task)->status & ~UAC_BITMASK; \
139 __u32 res = 0; \
140 if (status & TS_UAC_NOPRINT) \
141 res |= PR_UNALIGN_NOPRINT; \
142 if (status & TS_UAC_SIGBUS) \
143 res |= PR_UNALIGN_SIGBUS; \
144 if (status & TS_UAC_NOFIX) \
145 res |= 4; \
146 put_user(res, (int __user *)(value)); \
Ivan Kokshayskyed58a592007-05-06 14:50:38 -0700147 })
148
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149#endif /* __KERNEL__ */
150#endif /* _ALPHA_THREAD_INFO_H */