1024b246eSLinus Torvalds #ifndef _ALPHA_THREAD_INFO_H 2024b246eSLinus Torvalds #define _ALPHA_THREAD_INFO_H 3024b246eSLinus Torvalds 4024b246eSLinus Torvalds #ifdef __KERNEL__ 5024b246eSLinus Torvalds 6024b246eSLinus Torvalds #ifndef __ASSEMBLY__ 7024b246eSLinus Torvalds #include <asm/processor.h> 8024b246eSLinus Torvalds #include <asm/types.h> 9024b246eSLinus Torvalds #include <asm/hwrpb.h> 103185bd26SAl Viro #include <asm/sysinfo.h> 11024b246eSLinus Torvalds #endif 12024b246eSLinus Torvalds 13024b246eSLinus Torvalds #ifndef __ASSEMBLY__ 14024b246eSLinus Torvalds struct thread_info { 15024b246eSLinus Torvalds struct pcb_struct pcb; /* palcode state */ 16024b246eSLinus Torvalds 17024b246eSLinus Torvalds struct task_struct *task; /* main task structure */ 18024b246eSLinus Torvalds unsigned int flags; /* low level flags */ 19024b246eSLinus Torvalds unsigned int ieee_state; /* see fpu.h */ 20024b246eSLinus Torvalds 21024b246eSLinus Torvalds struct exec_domain *exec_domain; /* execution domain */ 22024b246eSLinus Torvalds mm_segment_t addr_limit; /* thread address space */ 23024b246eSLinus Torvalds unsigned cpu; /* current CPU */ 24024b246eSLinus Torvalds int preempt_count; /* 0 => preemptable, <0 => BUG */ 253185bd26SAl Viro unsigned int status; /* thread-synchronous flags */ 26024b246eSLinus Torvalds 27024b246eSLinus Torvalds int bpt_nsaved; 28024b246eSLinus Torvalds unsigned long bpt_addr[2]; /* breakpoint handling */ 29024b246eSLinus Torvalds unsigned int bpt_insn[2]; 30024b246eSLinus Torvalds 31024b246eSLinus Torvalds struct restart_block restart_block; 32024b246eSLinus Torvalds }; 33024b246eSLinus Torvalds 34024b246eSLinus Torvalds /* 35024b246eSLinus Torvalds * Macros/functions for gaining access to the thread information structure. 36024b246eSLinus Torvalds */ 37024b246eSLinus Torvalds #define INIT_THREAD_INFO(tsk) \ 38024b246eSLinus Torvalds { \ 39024b246eSLinus Torvalds .task = &tsk, \ 40024b246eSLinus Torvalds .exec_domain = &default_exec_domain, \ 41024b246eSLinus Torvalds .addr_limit = KERNEL_DS, \ 42c99e6efeSPeter Zijlstra .preempt_count = INIT_PREEMPT_COUNT, \ 43024b246eSLinus Torvalds .restart_block = { \ 44024b246eSLinus Torvalds .fn = do_no_restart_syscall, \ 45024b246eSLinus Torvalds }, \ 46024b246eSLinus Torvalds } 47024b246eSLinus Torvalds 48024b246eSLinus Torvalds #define init_thread_info (init_thread_union.thread_info) 49024b246eSLinus Torvalds #define init_stack (init_thread_union.stack) 50024b246eSLinus Torvalds 51024b246eSLinus Torvalds /* How to get the thread information struct from C. */ 52024b246eSLinus Torvalds register struct thread_info *__current_thread_info __asm__("$8"); 53024b246eSLinus Torvalds #define current_thread_info() __current_thread_info 54024b246eSLinus Torvalds 5515f3c476SAndrew Morton #endif /* __ASSEMBLY__ */ 5615f3c476SAndrew Morton 57024b246eSLinus Torvalds /* Thread information allocation. */ 58024b246eSLinus Torvalds #define THREAD_SIZE_ORDER 1 59024b246eSLinus Torvalds #define THREAD_SIZE (2*PAGE_SIZE) 60024b246eSLinus Torvalds 61024b246eSLinus Torvalds /* 62024b246eSLinus Torvalds * Thread information flags: 63024b246eSLinus Torvalds * - these are process state flags and used from assembly 64745dd240SMichael Cree * - pending work-to-be-done flags come first and must be assigned to be 65745dd240SMichael Cree * within bits 0 to 7 to fit in and immediate operand. 66024b246eSLinus Torvalds * 67024b246eSLinus Torvalds * TIF_SYSCALL_TRACE is known to be 0 via blbs. 68024b246eSLinus Torvalds */ 69024b246eSLinus Torvalds #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 70745dd240SMichael Cree #define TIF_NOTIFY_RESUME 1 /* callback before returning to user */ 71745dd240SMichael Cree #define TIF_SIGPENDING 2 /* signal pending */ 72745dd240SMichael Cree #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 73*a9302e84S蔡正龙 #define TIF_SYSCALL_AUDIT 4 /* syscall audit active */ 74745dd240SMichael Cree #define TIF_DIE_IF_KERNEL 9 /* dik recursion lock */ 750ddc9324SAndreas Dilger #define TIF_MEMDIE 13 /* is terminating due to OOM killer */ 76024b246eSLinus Torvalds 77024b246eSLinus Torvalds #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 78024b246eSLinus Torvalds #define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 79024b246eSLinus Torvalds #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 80d0420c83SDavid Howells #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) 81*a9302e84S蔡正龙 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) 82024b246eSLinus Torvalds 83024b246eSLinus Torvalds /* Work to do on interrupt/exception return. */ 84d0420c83SDavid Howells #define _TIF_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \ 85d0420c83SDavid Howells _TIF_NOTIFY_RESUME) 86024b246eSLinus Torvalds 87024b246eSLinus Torvalds /* Work to do on any return to userspace. */ 88024b246eSLinus Torvalds #define _TIF_ALLWORK_MASK (_TIF_WORK_MASK \ 89024b246eSLinus Torvalds | _TIF_SYSCALL_TRACE) 90024b246eSLinus Torvalds 913185bd26SAl Viro #define TS_UAC_NOPRINT 0x0001 /* ! Preserve the following three */ 923185bd26SAl Viro #define TS_UAC_NOFIX 0x0002 /* ! flags as they match */ 933185bd26SAl Viro #define TS_UAC_SIGBUS 0x0004 /* ! userspace part of 'osf_sysinfo' */ 943185bd26SAl Viro #define TS_RESTORE_SIGMASK 0x0008 /* restore signal mask in do_signal() */ 953185bd26SAl Viro #define TS_POLLING 0x0010 /* idle task polling need_resched, 963185bd26SAl Viro skip sending interrupt */ 973185bd26SAl Viro 983185bd26SAl Viro #ifndef __ASSEMBLY__ 993185bd26SAl Viro #define HAVE_SET_RESTORE_SIGMASK 1 1003185bd26SAl Viro static inline void set_restore_sigmask(void) 1013185bd26SAl Viro { 1023185bd26SAl Viro struct thread_info *ti = current_thread_info(); 1033185bd26SAl Viro ti->status |= TS_RESTORE_SIGMASK; 1043185bd26SAl Viro WARN_ON(!test_bit(TIF_SIGPENDING, (unsigned long *)&ti->flags)); 1053185bd26SAl Viro } 1063185bd26SAl Viro static inline void clear_restore_sigmask(void) 1073185bd26SAl Viro { 1083185bd26SAl Viro current_thread_info()->status &= ~TS_RESTORE_SIGMASK; 1093185bd26SAl Viro } 1103185bd26SAl Viro static inline bool test_restore_sigmask(void) 1113185bd26SAl Viro { 1123185bd26SAl Viro return current_thread_info()->status & TS_RESTORE_SIGMASK; 1133185bd26SAl Viro } 1143185bd26SAl Viro static inline bool test_and_clear_restore_sigmask(void) 1153185bd26SAl Viro { 1163185bd26SAl Viro struct thread_info *ti = current_thread_info(); 1173185bd26SAl Viro if (!(ti->status & TS_RESTORE_SIGMASK)) 1183185bd26SAl Viro return false; 1193185bd26SAl Viro ti->status &= ~TS_RESTORE_SIGMASK; 1203185bd26SAl Viro return true; 1213185bd26SAl Viro } 1223185bd26SAl Viro #endif 123024b246eSLinus Torvalds 124024b246eSLinus Torvalds #define SET_UNALIGN_CTL(task,value) ({ \ 1253185bd26SAl Viro __u32 status = task_thread_info(task)->status & ~UAC_BITMASK; \ 1263185bd26SAl Viro if (value & PR_UNALIGN_NOPRINT) \ 1273185bd26SAl Viro status |= TS_UAC_NOPRINT; \ 1283185bd26SAl Viro if (value & PR_UNALIGN_SIGBUS) \ 1293185bd26SAl Viro status |= TS_UAC_SIGBUS; \ 1303185bd26SAl Viro if (value & 4) /* alpha-specific */ \ 1313185bd26SAl Viro status |= TS_UAC_NOFIX; \ 1323185bd26SAl Viro task_thread_info(task)->status = status; \ 133024b246eSLinus Torvalds 0; }) 134024b246eSLinus Torvalds 135024b246eSLinus Torvalds #define GET_UNALIGN_CTL(task,value) ({ \ 1363185bd26SAl Viro __u32 status = task_thread_info(task)->status & ~UAC_BITMASK; \ 1373185bd26SAl Viro __u32 res = 0; \ 1383185bd26SAl Viro if (status & TS_UAC_NOPRINT) \ 1393185bd26SAl Viro res |= PR_UNALIGN_NOPRINT; \ 1403185bd26SAl Viro if (status & TS_UAC_SIGBUS) \ 1413185bd26SAl Viro res |= PR_UNALIGN_SIGBUS; \ 1423185bd26SAl Viro if (status & TS_UAC_NOFIX) \ 1433185bd26SAl Viro res |= 4; \ 1443185bd26SAl Viro put_user(res, (int __user *)(value)); \ 145024b246eSLinus Torvalds }) 146024b246eSLinus Torvalds 147024b246eSLinus Torvalds #endif /* __KERNEL__ */ 148024b246eSLinus Torvalds #endif /* _ALPHA_THREAD_INFO_H */ 149