Linux Audio

Check our new training course

Loading...
v3.1
  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>
 
 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,		\
 40	.preempt_count	= INIT_PREEMPT_COUNT,	\
 41	.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#endif /* __ASSEMBLY__ */
 54
 55/* Thread information allocation.  */
 56#define THREAD_SIZE_ORDER 1
 57#define THREAD_SIZE (2*PAGE_SIZE)
 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 and must be assigned to be
 65 *   within bits 0 to 7 to fit in and immediate operand.
 66 * - ALPHA_UAC_SHIFT below must be kept consistent with the unaligned
 67 *   control flags.
 68 *
 69 * TIF_SYSCALL_TRACE is known to be 0 via blbs.
 70 */
 71#define TIF_SYSCALL_TRACE	0	/* syscall trace active */
 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 */
 75#define TIF_POLLING_NRFLAG	8	/* poll_idle is polling NEED_RESCHED */
 76#define TIF_DIE_IF_KERNEL	9	/* dik recursion lock */
 77#define TIF_UAC_NOPRINT		10	/* ! Preserve sequence of following */
 78#define TIF_UAC_NOFIX		11	/* ! flags as they match            */
 79#define TIF_UAC_SIGBUS		12	/* ! userspace part of 'osf_sysinfo' */
 80#define TIF_MEMDIE		13	/* is terminating due to OOM killer */
 81#define TIF_RESTORE_SIGMASK	14	/* restore signal mask in do_signal */
 82#define TIF_FREEZE		16	/* is freezing for suspend */
 83
 84#define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 85#define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 86#define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 87#define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 88#define _TIF_RESTORE_SIGMASK	(1<<TIF_RESTORE_SIGMASK)
 89#define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 90#define _TIF_FREEZE		(1<<TIF_FREEZE)
 
 91
 92/* Work to do on interrupt/exception return.  */
 93#define _TIF_WORK_MASK		(_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
 94				 _TIF_NOTIFY_RESUME)
 95
 96/* Work to do on any return to userspace.  */
 97#define _TIF_ALLWORK_MASK	(_TIF_WORK_MASK		\
 98				 | _TIF_SYSCALL_TRACE)
 99
100#define ALPHA_UAC_SHIFT		TIF_UAC_NOPRINT
101#define ALPHA_UAC_MASK		(1 << TIF_UAC_NOPRINT | 1 << TIF_UAC_NOFIX | \
102				 1 << TIF_UAC_SIGBUS)
103
104#define SET_UNALIGN_CTL(task,value)	({				     \
105	task_thread_info(task)->flags = ((task_thread_info(task)->flags &    \
106		~ALPHA_UAC_MASK)					     \
107		| (((value) << ALPHA_UAC_SHIFT)       & (1<<TIF_UAC_NOPRINT))\
108		| (((value) << (ALPHA_UAC_SHIFT + 1)) & (1<<TIF_UAC_SIGBUS)) \
109		| (((value) << (ALPHA_UAC_SHIFT - 1)) & (1<<TIF_UAC_NOFIX)));\
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110	0; })
111
112#define GET_UNALIGN_CTL(task,value)	({				\
113	put_user((task_thread_info(task)->flags & (1 << TIF_UAC_NOPRINT))\
114		  >> ALPHA_UAC_SHIFT					\
115		 | (task_thread_info(task)->flags & (1 << TIF_UAC_SIGBUS))\
116		 >> (ALPHA_UAC_SHIFT + 1)				\
117		 | (task_thread_info(task)->flags & (1 << TIF_UAC_NOFIX))\
118		 >> (ALPHA_UAC_SHIFT - 1),				\
119		 (int __user *)(value));				\
 
 
120	})
121
122#endif /* __KERNEL__ */
123#endif /* _ALPHA_THREAD_INFO_H */
v4.6
  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>
 10#include <asm/sysinfo.h>
 11#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	mm_segment_t		addr_limit;	/* thread address space */
 22	unsigned		cpu;		/* current CPU */
 23	int			preempt_count; /* 0 => preemptable, <0 => BUG */
 24	unsigned int		status;		/* thread-synchronous flags */
 25
 26	int bpt_nsaved;
 27	unsigned long bpt_addr[2];		/* breakpoint handling  */
 28	unsigned int bpt_insn[2];
 
 
 29};
 30
 31/*
 32 * Macros/functions for gaining access to the thread information structure.
 33 */
 34#define INIT_THREAD_INFO(tsk)			\
 35{						\
 36	.task		= &tsk,			\
 
 37	.addr_limit	= KERNEL_DS,		\
 38	.preempt_count	= INIT_PREEMPT_COUNT,	\
 
 
 
 39}
 40
 41#define init_thread_info	(init_thread_union.thread_info)
 42#define init_stack		(init_thread_union.stack)
 43
 44/* How to get the thread information struct from C.  */
 45register struct thread_info *__current_thread_info __asm__("$8");
 46#define current_thread_info()  __current_thread_info
 47
 48#endif /* __ASSEMBLY__ */
 49
 50/* Thread information allocation.  */
 51#define THREAD_SIZE_ORDER 1
 52#define THREAD_SIZE (2*PAGE_SIZE)
 53
 
 
 54/*
 55 * Thread information flags:
 56 * - these are process state flags and used from assembly
 57 * - pending work-to-be-done flags come first and must be assigned to be
 58 *   within bits 0 to 7 to fit in and immediate operand.
 
 
 59 *
 60 * TIF_SYSCALL_TRACE is known to be 0 via blbs.
 61 */
 62#define TIF_SYSCALL_TRACE	0	/* syscall trace active */
 63#define TIF_NOTIFY_RESUME	1	/* callback before returning to user */
 64#define TIF_SIGPENDING		2	/* signal pending */
 65#define TIF_NEED_RESCHED	3	/* rescheduling necessary */
 66#define TIF_SYSCALL_AUDIT	4	/* syscall audit active */
 67#define TIF_DIE_IF_KERNEL	9	/* dik recursion lock */
 
 
 
 68#define TIF_MEMDIE		13	/* is terminating due to OOM killer */
 69#define TIF_POLLING_NRFLAG	14	/* idle is polling for TIF_NEED_RESCHED */
 
 70
 71#define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
 72#define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 73#define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
 
 
 74#define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 75#define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
 76#define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
 77
 78/* Work to do on interrupt/exception return.  */
 79#define _TIF_WORK_MASK		(_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
 80				 _TIF_NOTIFY_RESUME)
 81
 82/* Work to do on any return to userspace.  */
 83#define _TIF_ALLWORK_MASK	(_TIF_WORK_MASK		\
 84				 | _TIF_SYSCALL_TRACE)
 85
 86#define TS_UAC_NOPRINT		0x0001	/* ! Preserve the following three */
 87#define TS_UAC_NOFIX		0x0002	/* ! flags as they match          */
 88#define TS_UAC_SIGBUS		0x0004	/* ! userspace part of 'osf_sysinfo' */
 89#define TS_RESTORE_SIGMASK	0x0008	/* restore signal mask in do_signal() */
 90
 91#ifndef __ASSEMBLY__
 92#define HAVE_SET_RESTORE_SIGMASK	1
 93static inline void set_restore_sigmask(void)
 94{
 95	struct thread_info *ti = current_thread_info();
 96	ti->status |= TS_RESTORE_SIGMASK;
 97	WARN_ON(!test_bit(TIF_SIGPENDING, (unsigned long *)&ti->flags));
 98}
 99static inline void clear_restore_sigmask(void)
100{
101	current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
102}
103static inline bool test_restore_sigmask(void)
104{
105	return current_thread_info()->status & TS_RESTORE_SIGMASK;
106}
107static inline bool test_and_clear_restore_sigmask(void)
108{
109	struct thread_info *ti = current_thread_info();
110	if (!(ti->status & TS_RESTORE_SIGMASK))
111		return false;
112	ti->status &= ~TS_RESTORE_SIGMASK;
113	return true;
114}
115#endif
116
117#define SET_UNALIGN_CTL(task,value)	({				\
118	__u32 status = task_thread_info(task)->status & ~UAC_BITMASK;	\
119	if (value & PR_UNALIGN_NOPRINT)					\
120		status |= TS_UAC_NOPRINT;				\
121	if (value & PR_UNALIGN_SIGBUS)					\
122		status |= TS_UAC_SIGBUS;				\
123	if (value & 4)	/* alpha-specific */				\
124		status |= TS_UAC_NOFIX;					\
125	task_thread_info(task)->status = status;			\
126	0; })
127
128#define GET_UNALIGN_CTL(task,value)	({				\
129	__u32 status = task_thread_info(task)->status & ~UAC_BITMASK;	\
130	__u32 res = 0;							\
131	if (status & TS_UAC_NOPRINT)					\
132		res |= PR_UNALIGN_NOPRINT;				\
133	if (status & TS_UAC_SIGBUS)					\
134		res |= PR_UNALIGN_SIGBUS;				\
135	if (status & TS_UAC_NOFIX)					\
136		res |= 4;						\
137	put_user(res, (int __user *)(value));				\
138	})
139
140#endif /* __KERNEL__ */
141#endif /* _ALPHA_THREAD_INFO_H */