Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #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> | |
3185bd26 | 10 | #include <asm/sysinfo.h> |
1da177e4 LT |
11 | #endif |
12 | ||
13 | #ifndef __ASSEMBLY__ | |
14 | struct 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 */ | |
3185bd26 | 25 | unsigned int status; /* thread-synchronous flags */ |
1da177e4 LT |
26 | |
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, \ | |
c99e6efe | 42 | .preempt_count = INIT_PREEMPT_COUNT, \ |
1da177e4 LT |
43 | .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. */ | |
52 | register struct thread_info *__current_thread_info __asm__("$8"); | |
53 | #define current_thread_info() __current_thread_info | |
54 | ||
15f3c476 AM |
55 | #endif /* __ASSEMBLY__ */ |
56 | ||
1da177e4 | 57 | /* Thread information allocation. */ |
b69c49b7 | 58 | #define THREAD_SIZE_ORDER 1 |
1da177e4 | 59 | #define THREAD_SIZE (2*PAGE_SIZE) |
1da177e4 | 60 | |
1da177e4 LT |
61 | #define PREEMPT_ACTIVE 0x40000000 |
62 | ||
63 | /* | |
64 | * Thread information flags: | |
65 | * - these are process state flags and used from assembly | |
745dd240 MC |
66 | * - 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. | |
1da177e4 LT |
68 | * |
69 | * TIF_SYSCALL_TRACE is known to be 0 via blbs. | |
70 | */ | |
71 | #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ | |
745dd240 MC |
72 | #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 */ | |
745dd240 | 75 | #define TIF_DIE_IF_KERNEL 9 /* dik recursion lock */ |
0ddc9324 | 76 | #define TIF_MEMDIE 13 /* is terminating due to OOM killer */ |
1da177e4 LT |
77 | |
78 | #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) | |
1da177e4 LT |
79 | #define _TIF_SIGPENDING (1<<TIF_SIGPENDING) |
80 | #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) | |
d0420c83 | 81 | #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) |
1da177e4 LT |
82 | |
83 | /* Work to do on interrupt/exception return. */ | |
d0420c83 DH |
84 | #define _TIF_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \ |
85 | _TIF_NOTIFY_RESUME) | |
1da177e4 LT |
86 | |
87 | /* Work to do on any return to userspace. */ | |
88 | #define _TIF_ALLWORK_MASK (_TIF_WORK_MASK \ | |
89 | | _TIF_SYSCALL_TRACE) | |
90 | ||
3185bd26 AV |
91 | #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 */ | |
ed58a593 | 97 | |
3185bd26 AV |
98 | #ifndef __ASSEMBLY__ |
99 | #define HAVE_SET_RESTORE_SIGMASK 1 | |
100 | static inline void set_restore_sigmask(void) | |
101 | { | |
102 | struct thread_info *ti = current_thread_info(); | |
103 | ti->status |= TS_RESTORE_SIGMASK; | |
104 | WARN_ON(!test_bit(TIF_SIGPENDING, (unsigned long *)&ti->flags)); | |
105 | } | |
106 | static inline void clear_restore_sigmask(void) | |
107 | { | |
108 | current_thread_info()->status &= ~TS_RESTORE_SIGMASK; | |
109 | } | |
110 | static inline bool test_restore_sigmask(void) | |
111 | { | |
112 | return current_thread_info()->status & TS_RESTORE_SIGMASK; | |
113 | } | |
114 | static inline bool test_and_clear_restore_sigmask(void) | |
115 | { | |
116 | struct thread_info *ti = current_thread_info(); | |
117 | if (!(ti->status & TS_RESTORE_SIGMASK)) | |
118 | return false; | |
119 | ti->status &= ~TS_RESTORE_SIGMASK; | |
120 | return true; | |
121 | } | |
122 | #endif | |
123 | ||
124 | #define SET_UNALIGN_CTL(task,value) ({ \ | |
125 | __u32 status = task_thread_info(task)->status & ~UAC_BITMASK; \ | |
126 | if (value & PR_UNALIGN_NOPRINT) \ | |
127 | status |= TS_UAC_NOPRINT; \ | |
128 | if (value & PR_UNALIGN_SIGBUS) \ | |
129 | status |= TS_UAC_SIGBUS; \ | |
130 | if (value & 4) /* alpha-specific */ \ | |
131 | status |= TS_UAC_NOFIX; \ | |
132 | task_thread_info(task)->status = status; \ | |
ed58a593 IK |
133 | 0; }) |
134 | ||
135 | #define GET_UNALIGN_CTL(task,value) ({ \ | |
3185bd26 AV |
136 | __u32 status = task_thread_info(task)->status & ~UAC_BITMASK; \ |
137 | __u32 res = 0; \ | |
138 | if (status & TS_UAC_NOPRINT) \ | |
139 | res |= PR_UNALIGN_NOPRINT; \ | |
140 | if (status & TS_UAC_SIGBUS) \ | |
141 | res |= PR_UNALIGN_SIGBUS; \ | |
142 | if (status & TS_UAC_NOFIX) \ | |
143 | res |= 4; \ | |
144 | put_user(res, (int __user *)(value)); \ | |
ed58a593 IK |
145 | }) |
146 | ||
1da177e4 LT |
147 | #endif /* __KERNEL__ */ |
148 | #endif /* _ALPHA_THREAD_INFO_H */ |