Linux Audio

Check our new training course

Loading...
v3.5.6
  1/*
  2 * Copyright (C) 2002  David Howells (dhowells@redhat.com)
  3 * Copyright 2010 Tilera Corporation. All Rights Reserved.
  4 *
  5 *   This program is free software; you can redistribute it and/or
  6 *   modify it under the terms of the GNU General Public License
  7 *   as published by the Free Software Foundation, version 2.
  8 *
  9 *   This program is distributed in the hope that it will be useful, but
 10 *   WITHOUT ANY WARRANTY; without even the implied warranty of
 11 *   MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
 12 *   NON INFRINGEMENT.  See the GNU General Public License for
 13 *   more details.
 14 */
 15
 16#ifndef _ASM_TILE_THREAD_INFO_H
 17#define _ASM_TILE_THREAD_INFO_H
 18
 19#include <asm/processor.h>
 20#include <asm/page.h>
 21#ifndef __ASSEMBLY__
 22
 23/*
 24 * Low level task data that assembly code needs immediate access to.
 25 * The structure is placed at the bottom of the supervisor stack.
 26 */
 27struct thread_info {
 28	struct task_struct	*task;		/* main task structure */
 29	struct exec_domain	*exec_domain;	/* execution domain */
 30	unsigned long		flags;		/* low level flags */
 31	unsigned long		status;		/* thread-synchronous flags */
 32	__u32			homecache_cpu;	/* CPU we are homecached on */
 33	__u32			cpu;		/* current CPU */
 34	int			preempt_count;	/* 0 => preemptable,
 35						   <0 => BUG */
 36
 37	mm_segment_t		addr_limit;	/* thread address space
 38						   (KERNEL_DS or USER_DS) */
 39	struct restart_block	restart_block;
 40	struct single_step_state *step_state;	/* single step state
 41						   (if non-zero) */
 
 
 
 
 
 
 42};
 43
 44/*
 45 * macros/functions for gaining access to the thread information structure.
 46 */
 47#define INIT_THREAD_INFO(tsk)			\
 48{						\
 49	.task		= &tsk,			\
 50	.exec_domain	= &default_exec_domain,	\
 51	.flags		= 0,			\
 52	.cpu		= 0,			\
 53	.preempt_count	= INIT_PREEMPT_COUNT,	\
 54	.addr_limit	= KERNEL_DS,		\
 55	.restart_block	= {			\
 56		.fn = do_no_restart_syscall,	\
 57	},					\
 58	.step_state	= NULL,			\
 
 59}
 60
 61#define init_thread_info	(init_thread_union.thread_info)
 62#define init_stack		(init_thread_union.stack)
 63
 64#endif /* !__ASSEMBLY__ */
 65
 66#if PAGE_SIZE < 8192
 67#define THREAD_SIZE_ORDER (13 - PAGE_SHIFT)
 68#else
 69#define THREAD_SIZE_ORDER (0)
 70#endif
 71#define THREAD_SIZE_PAGES (1 << THREAD_SIZE_ORDER)
 72
 73#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
 74#define LOG2_THREAD_SIZE (PAGE_SHIFT + THREAD_SIZE_ORDER)
 75
 76#define STACK_WARN             (THREAD_SIZE/8)
 77
 78#ifndef __ASSEMBLY__
 79
 80void arch_release_thread_info(struct thread_info *info);
 81
 82/* How to get the thread information struct from C. */
 83register unsigned long stack_pointer __asm__("sp");
 84
 85#define current_thread_info() \
 86  ((struct thread_info *)(stack_pointer & -THREAD_SIZE))
 87
 88/* Sit on a nap instruction until interrupted. */
 89extern void smp_nap(void);
 90
 91/* Enable interrupts racelessly and nap forever: helper for cpu_idle(). */
 92extern void _cpu_idle(void);
 93
 94#else /* __ASSEMBLY__ */
 95
 96/*
 97 * How to get the thread information struct from assembly.
 98 * Note that we use different macros since different architectures
 99 * have different semantics in their "mm" instruction and we would
100 * like to guarantee that the macro expands to exactly one instruction.
101 */
102#ifdef __tilegx__
103#define EXTRACT_THREAD_INFO(reg) mm reg, zero, LOG2_THREAD_SIZE, 63
104#else
105#define GET_THREAD_INFO(reg) mm reg, sp, zero, LOG2_THREAD_SIZE, 31
106#endif
107
108#endif /* !__ASSEMBLY__ */
109
110#define PREEMPT_ACTIVE		0x10000000
111
112/*
113 * Thread information flags that various assembly files may need to access.
114 * Keep flags accessed frequently in low bits, particular since it makes
115 * it easier to build constants in assembly.
116 */
117#define TIF_SIGPENDING		0	/* signal pending */
118#define TIF_NEED_RESCHED	1	/* rescheduling necessary */
119#define TIF_SINGLESTEP		2	/* restore singlestep on return to
120					   user mode */
121#define TIF_ASYNC_TLB		3	/* got an async TLB fault in kernel */
122#define TIF_SYSCALL_TRACE	4	/* syscall trace active */
123#define TIF_SYSCALL_AUDIT	5	/* syscall auditing active */
124#define TIF_SECCOMP		6	/* secure computing */
125#define TIF_MEMDIE		7	/* OOM killer at work */
126#define TIF_NOTIFY_RESUME	8	/* callback before returning to user */
 
 
 
127
128#define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
129#define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
130#define _TIF_SINGLESTEP		(1<<TIF_SINGLESTEP)
131#define _TIF_ASYNC_TLB		(1<<TIF_ASYNC_TLB)
132#define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
133#define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
134#define _TIF_SECCOMP		(1<<TIF_SECCOMP)
135#define _TIF_MEMDIE		(1<<TIF_MEMDIE)
136#define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
 
 
 
 
 
 
 
 
137
138/* Work to do on any return to user space. */
139#define _TIF_ALLWORK_MASK \
140  (_TIF_SIGPENDING|_TIF_NEED_RESCHED|_TIF_SINGLESTEP|\
141   _TIF_ASYNC_TLB|_TIF_NOTIFY_RESUME)
 
 
 
 
 
 
142
143/*
144 * Thread-synchronous status.
145 *
146 * This is different from the flags in that nobody else
147 * ever touches our thread-synchronous status, so we don't
148 * have to worry about atomic accesses.
149 */
150#ifdef __tilegx__
151#define TS_COMPAT		0x0001	/* 32-bit compatibility mode */
152#endif
153#define TS_POLLING		0x0004	/* in idle loop but not sleeping */
154#define TS_RESTORE_SIGMASK	0x0008	/* restore signal mask in do_signal */
155
156#define tsk_is_polling(t) (task_thread_info(t)->status & TS_POLLING)
157
158#ifndef __ASSEMBLY__
159#define HAVE_SET_RESTORE_SIGMASK	1
160static inline void set_restore_sigmask(void)
161{
162	struct thread_info *ti = current_thread_info();
163	ti->status |= TS_RESTORE_SIGMASK;
164	WARN_ON(!test_bit(TIF_SIGPENDING, &ti->flags));
165}
166static inline void clear_restore_sigmask(void)
167{
168	current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
169}
170static inline bool test_restore_sigmask(void)
171{
172	return current_thread_info()->status & TS_RESTORE_SIGMASK;
173}
174static inline bool test_and_clear_restore_sigmask(void)
175{
176	struct thread_info *ti = current_thread_info();
177	if (!(ti->status & TS_RESTORE_SIGMASK))
178		return false;
179	ti->status &= ~TS_RESTORE_SIGMASK;
180	return true;
181}
182#endif	/* !__ASSEMBLY__ */
183
184#endif /* _ASM_TILE_THREAD_INFO_H */
v4.6
  1/*
  2 * Copyright (C) 2002  David Howells (dhowells@redhat.com)
  3 * Copyright 2010 Tilera Corporation. All Rights Reserved.
  4 *
  5 *   This program is free software; you can redistribute it and/or
  6 *   modify it under the terms of the GNU General Public License
  7 *   as published by the Free Software Foundation, version 2.
  8 *
  9 *   This program is distributed in the hope that it will be useful, but
 10 *   WITHOUT ANY WARRANTY; without even the implied warranty of
 11 *   MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
 12 *   NON INFRINGEMENT.  See the GNU General Public License for
 13 *   more details.
 14 */
 15
 16#ifndef _ASM_TILE_THREAD_INFO_H
 17#define _ASM_TILE_THREAD_INFO_H
 18
 19#include <asm/processor.h>
 20#include <asm/page.h>
 21#ifndef __ASSEMBLY__
 22
 23/*
 24 * Low level task data that assembly code needs immediate access to.
 25 * The structure is placed at the bottom of the supervisor stack.
 26 */
 27struct thread_info {
 28	struct task_struct	*task;		/* main task structure */
 
 29	unsigned long		flags;		/* low level flags */
 30	unsigned long		status;		/* thread-synchronous flags */
 31	__u32			homecache_cpu;	/* CPU we are homecached on */
 32	__u32			cpu;		/* current CPU */
 33	int			preempt_count;	/* 0 => preemptable,
 34						   <0 => BUG */
 35
 36	mm_segment_t		addr_limit;	/* thread address space
 37						   (KERNEL_DS or USER_DS) */
 
 38	struct single_step_state *step_state;	/* single step state
 39						   (if non-zero) */
 40	int			align_ctl;	/* controls unaligned access */
 41#ifdef __tilegx__
 42	unsigned long		unalign_jit_tmp[4]; /* temp r0..r3 storage */
 43	void __user		*unalign_jit_base; /* unalign fixup JIT base */
 44#endif
 45	bool in_backtrace;			/* currently doing backtrace? */
 46};
 47
 48/*
 49 * macros/functions for gaining access to the thread information structure.
 50 */
 51#define INIT_THREAD_INFO(tsk)			\
 52{						\
 53	.task		= &tsk,			\
 
 54	.flags		= 0,			\
 55	.cpu		= 0,			\
 56	.preempt_count	= INIT_PREEMPT_COUNT,	\
 57	.addr_limit	= KERNEL_DS,		\
 
 
 
 58	.step_state	= NULL,			\
 59	.align_ctl	= 0,			\
 60}
 61
 62#define init_thread_info	(init_thread_union.thread_info)
 63#define init_stack		(init_thread_union.stack)
 64
 65#endif /* !__ASSEMBLY__ */
 66
 67#if PAGE_SIZE < 8192
 68#define THREAD_SIZE_ORDER (13 - PAGE_SHIFT)
 69#else
 70#define THREAD_SIZE_ORDER (0)
 71#endif
 72#define THREAD_SIZE_PAGES (1 << THREAD_SIZE_ORDER)
 73
 74#define THREAD_SIZE (PAGE_SIZE << THREAD_SIZE_ORDER)
 75#define LOG2_THREAD_SIZE (PAGE_SHIFT + THREAD_SIZE_ORDER)
 76
 77#define STACK_WARN             (THREAD_SIZE/8)
 78
 79#ifndef __ASSEMBLY__
 80
 81void arch_release_thread_info(struct thread_info *info);
 82
 83/* How to get the thread information struct from C. */
 84register unsigned long stack_pointer __asm__("sp");
 85
 86#define current_thread_info() \
 87  ((struct thread_info *)(stack_pointer & -THREAD_SIZE))
 88
 89/* Sit on a nap instruction until interrupted. */
 90extern void smp_nap(void);
 91
 92/* Enable interrupts racelessly and nap forever: helper for arch_cpu_idle(). */
 93extern void _cpu_idle(void);
 94
 95#else /* __ASSEMBLY__ */
 96
 97/*
 98 * How to get the thread information struct from assembly.
 99 * Note that we use different macros since different architectures
100 * have different semantics in their "mm" instruction and we would
101 * like to guarantee that the macro expands to exactly one instruction.
102 */
103#ifdef __tilegx__
104#define EXTRACT_THREAD_INFO(reg) mm reg, zero, LOG2_THREAD_SIZE, 63
105#else
106#define GET_THREAD_INFO(reg) mm reg, sp, zero, LOG2_THREAD_SIZE, 31
107#endif
108
109#endif /* !__ASSEMBLY__ */
110
 
 
111/*
112 * Thread information flags that various assembly files may need to access.
113 * Keep flags accessed frequently in low bits, particular since it makes
114 * it easier to build constants in assembly.
115 */
116#define TIF_SIGPENDING		0	/* signal pending */
117#define TIF_NEED_RESCHED	1	/* rescheduling necessary */
118#define TIF_SINGLESTEP		2	/* restore singlestep on return to
119					   user mode */
120#define TIF_ASYNC_TLB		3	/* got an async TLB fault in kernel */
121#define TIF_SYSCALL_TRACE	4	/* syscall trace active */
122#define TIF_SYSCALL_AUDIT	5	/* syscall auditing active */
123#define TIF_SECCOMP		6	/* secure computing */
124#define TIF_MEMDIE		7	/* OOM killer at work */
125#define TIF_NOTIFY_RESUME	8	/* callback before returning to user */
126#define TIF_SYSCALL_TRACEPOINT	9	/* syscall tracepoint instrumentation */
127#define TIF_POLLING_NRFLAG	10	/* idle is polling for TIF_NEED_RESCHED */
128#define TIF_NOHZ		11	/* in adaptive nohz mode */
129
130#define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
131#define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
132#define _TIF_SINGLESTEP		(1<<TIF_SINGLESTEP)
133#define _TIF_ASYNC_TLB		(1<<TIF_ASYNC_TLB)
134#define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
135#define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
136#define _TIF_SECCOMP		(1<<TIF_SECCOMP)
137#define _TIF_MEMDIE		(1<<TIF_MEMDIE)
138#define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
139#define _TIF_SYSCALL_TRACEPOINT	(1<<TIF_SYSCALL_TRACEPOINT)
140#define _TIF_POLLING_NRFLAG	(1<<TIF_POLLING_NRFLAG)
141#define _TIF_NOHZ		(1<<TIF_NOHZ)
142
143/* Work to do as we loop to exit to user space. */
144#define _TIF_WORK_MASK \
145	(_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
146	 _TIF_ASYNC_TLB | _TIF_NOTIFY_RESUME)
147
148/* Work to do on any return to user space. */
149#define _TIF_ALLWORK_MASK \
150	(_TIF_WORK_MASK | _TIF_SINGLESTEP | _TIF_NOHZ)
151
152/* Work to do at syscall entry. */
153#define _TIF_SYSCALL_ENTRY_WORK \
154	(_TIF_SYSCALL_TRACE | _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
155
156/* Work to do at syscall exit. */
157#define _TIF_SYSCALL_EXIT_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_TRACEPOINT)
158
159/*
160 * Thread-synchronous status.
161 *
162 * This is different from the flags in that nobody else
163 * ever touches our thread-synchronous status, so we don't
164 * have to worry about atomic accesses.
165 */
166#ifdef __tilegx__
167#define TS_COMPAT		0x0001	/* 32-bit compatibility mode */
168#endif
 
169#define TS_RESTORE_SIGMASK	0x0008	/* restore signal mask in do_signal */
 
 
170
171#ifndef __ASSEMBLY__
172#define HAVE_SET_RESTORE_SIGMASK	1
173static inline void set_restore_sigmask(void)
174{
175	struct thread_info *ti = current_thread_info();
176	ti->status |= TS_RESTORE_SIGMASK;
177	WARN_ON(!test_bit(TIF_SIGPENDING, &ti->flags));
178}
179static inline void clear_restore_sigmask(void)
180{
181	current_thread_info()->status &= ~TS_RESTORE_SIGMASK;
182}
183static inline bool test_restore_sigmask(void)
184{
185	return current_thread_info()->status & TS_RESTORE_SIGMASK;
186}
187static inline bool test_and_clear_restore_sigmask(void)
188{
189	struct thread_info *ti = current_thread_info();
190	if (!(ti->status & TS_RESTORE_SIGMASK))
191		return false;
192	ti->status &= ~TS_RESTORE_SIGMASK;
193	return true;
194}
195#endif	/* !__ASSEMBLY__ */
196
197#endif /* _ASM_TILE_THREAD_INFO_H */