1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 2024b246eSLinus Torvalds #ifndef _ALPHA_THREAD_INFO_H 3024b246eSLinus Torvalds #define _ALPHA_THREAD_INFO_H 4024b246eSLinus Torvalds 5024b246eSLinus Torvalds #ifdef __KERNEL__ 6024b246eSLinus Torvalds 7024b246eSLinus Torvalds #ifndef __ASSEMBLY__ 8024b246eSLinus Torvalds #include <asm/processor.h> 9024b246eSLinus Torvalds #include <asm/types.h> 10024b246eSLinus Torvalds #include <asm/hwrpb.h> 113185bd26SAl Viro #include <asm/sysinfo.h> 12024b246eSLinus Torvalds #endif 13024b246eSLinus Torvalds 14024b246eSLinus Torvalds #ifndef __ASSEMBLY__ 15024b246eSLinus Torvalds struct thread_info { 16024b246eSLinus Torvalds struct pcb_struct pcb; /* palcode state */ 17024b246eSLinus Torvalds 18024b246eSLinus Torvalds struct task_struct *task; /* main task structure */ 19024b246eSLinus Torvalds unsigned int flags; /* low level flags */ 20024b246eSLinus Torvalds unsigned int ieee_state; /* see fpu.h */ 21024b246eSLinus Torvalds 22024b246eSLinus Torvalds unsigned cpu; /* current CPU */ 23024b246eSLinus Torvalds int preempt_count; /* 0 => preemptable, <0 => BUG */ 243185bd26SAl Viro unsigned int status; /* thread-synchronous flags */ 25024b246eSLinus Torvalds 26024b246eSLinus Torvalds int bpt_nsaved; 27024b246eSLinus Torvalds unsigned long bpt_addr[2]; /* breakpoint handling */ 28024b246eSLinus Torvalds unsigned int bpt_insn[2]; 29*05096666SAl Viro unsigned long fp[32]; 30024b246eSLinus Torvalds }; 31024b246eSLinus Torvalds 32024b246eSLinus Torvalds /* 33024b246eSLinus Torvalds * Macros/functions for gaining access to the thread information structure. 34024b246eSLinus Torvalds */ 35024b246eSLinus Torvalds #define INIT_THREAD_INFO(tsk) \ 36024b246eSLinus Torvalds { \ 37024b246eSLinus Torvalds .task = &tsk, \ 38c99e6efeSPeter Zijlstra .preempt_count = INIT_PREEMPT_COUNT, \ 39024b246eSLinus Torvalds } 40024b246eSLinus Torvalds 41024b246eSLinus Torvalds /* How to get the thread information struct from C. */ 42024b246eSLinus Torvalds register struct thread_info *__current_thread_info __asm__("$8"); 43024b246eSLinus Torvalds #define current_thread_info() __current_thread_info 44024b246eSLinus Torvalds 45bd1912deSKees Cook register unsigned long *current_stack_pointer __asm__ ("$30"); 46bd1912deSKees Cook 4715f3c476SAndrew Morton #endif /* __ASSEMBLY__ */ 4815f3c476SAndrew Morton 49024b246eSLinus Torvalds /* Thread information allocation. */ 50024b246eSLinus Torvalds #define THREAD_SIZE_ORDER 1 51024b246eSLinus Torvalds #define THREAD_SIZE (2*PAGE_SIZE) 52024b246eSLinus Torvalds 53024b246eSLinus Torvalds /* 54024b246eSLinus Torvalds * Thread information flags: 55024b246eSLinus Torvalds * - these are process state flags and used from assembly 56745dd240SMichael Cree * - pending work-to-be-done flags come first and must be assigned to be 57745dd240SMichael Cree * within bits 0 to 7 to fit in and immediate operand. 58024b246eSLinus Torvalds * 59024b246eSLinus Torvalds * TIF_SYSCALL_TRACE is known to be 0 via blbs. 60024b246eSLinus Torvalds */ 61024b246eSLinus Torvalds #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ 62745dd240SMichael Cree #define TIF_NOTIFY_RESUME 1 /* callback before returning to user */ 63745dd240SMichael Cree #define TIF_SIGPENDING 2 /* signal pending */ 64745dd240SMichael Cree #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 65a9302e84S蔡正龙 #define TIF_SYSCALL_AUDIT 4 /* syscall audit active */ 665a9a8897SJens Axboe #define TIF_NOTIFY_SIGNAL 5 /* signal notifications exist */ 67745dd240SMichael Cree #define TIF_DIE_IF_KERNEL 9 /* dik recursion lock */ 680ddc9324SAndreas Dilger #define TIF_MEMDIE 13 /* is terminating due to OOM killer */ 692a705ad6SPeter Zijlstra #define TIF_POLLING_NRFLAG 14 /* idle is polling for TIF_NEED_RESCHED */ 70024b246eSLinus Torvalds 71024b246eSLinus Torvalds #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) 72024b246eSLinus Torvalds #define _TIF_SIGPENDING (1<<TIF_SIGPENDING) 73024b246eSLinus Torvalds #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) 74d0420c83SDavid Howells #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) 75a9302e84S蔡正龙 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT) 765a9a8897SJens Axboe #define _TIF_NOTIFY_SIGNAL (1<<TIF_NOTIFY_SIGNAL) 772a705ad6SPeter Zijlstra #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) 78024b246eSLinus Torvalds 79024b246eSLinus Torvalds /* Work to do on interrupt/exception return. */ 80d0420c83SDavid Howells #define _TIF_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \ 81e2c7554cSAl Viro _TIF_NOTIFY_RESUME | _TIF_NOTIFY_SIGNAL) 82024b246eSLinus Torvalds 833185bd26SAl Viro #define TS_UAC_NOPRINT 0x0001 /* ! Preserve the following three */ 843185bd26SAl Viro #define TS_UAC_NOFIX 0x0002 /* ! flags as they match */ 853185bd26SAl Viro #define TS_UAC_SIGBUS 0x0004 /* ! userspace part of 'osf_sysinfo' */ 86024b246eSLinus Torvalds 87*05096666SAl Viro #define TS_SAVED_FP 0x0008 88*05096666SAl Viro #define TS_RESTORE_FP 0x0010 89*05096666SAl Viro 90024b246eSLinus Torvalds #define SET_UNALIGN_CTL(task,value) ({ \ 913185bd26SAl Viro __u32 status = task_thread_info(task)->status & ~UAC_BITMASK; \ 923185bd26SAl Viro if (value & PR_UNALIGN_NOPRINT) \ 933185bd26SAl Viro status |= TS_UAC_NOPRINT; \ 943185bd26SAl Viro if (value & PR_UNALIGN_SIGBUS) \ 953185bd26SAl Viro status |= TS_UAC_SIGBUS; \ 963185bd26SAl Viro if (value & 4) /* alpha-specific */ \ 973185bd26SAl Viro status |= TS_UAC_NOFIX; \ 983185bd26SAl Viro task_thread_info(task)->status = status; \ 99024b246eSLinus Torvalds 0; }) 100024b246eSLinus Torvalds 101024b246eSLinus Torvalds #define GET_UNALIGN_CTL(task,value) ({ \ 1023185bd26SAl Viro __u32 status = task_thread_info(task)->status & ~UAC_BITMASK; \ 1033185bd26SAl Viro __u32 res = 0; \ 1043185bd26SAl Viro if (status & TS_UAC_NOPRINT) \ 1053185bd26SAl Viro res |= PR_UNALIGN_NOPRINT; \ 1063185bd26SAl Viro if (status & TS_UAC_SIGBUS) \ 1073185bd26SAl Viro res |= PR_UNALIGN_SIGBUS; \ 1083185bd26SAl Viro if (status & TS_UAC_NOFIX) \ 1093185bd26SAl Viro res |= 4; \ 1103185bd26SAl Viro put_user(res, (int __user *)(value)); \ 111024b246eSLinus Torvalds }) 112024b246eSLinus Torvalds 113*05096666SAl Viro #ifndef __ASSEMBLY__ 114*05096666SAl Viro extern void __save_fpu(void); 115*05096666SAl Viro save_fpu(void)116*05096666SAl Virostatic inline void save_fpu(void) 117*05096666SAl Viro { 118*05096666SAl Viro if (!(current_thread_info()->status & TS_SAVED_FP)) { 119*05096666SAl Viro current_thread_info()->status |= TS_SAVED_FP; 120*05096666SAl Viro __save_fpu(); 121*05096666SAl Viro } 122*05096666SAl Viro } 123*05096666SAl Viro #endif 124*05096666SAl Viro 125024b246eSLinus Torvalds #endif /* __KERNEL__ */ 126024b246eSLinus Torvalds #endif /* _ALPHA_THREAD_INFO_H */ 127