162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * include/asm-xtensa/thread_info.h
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public
562306a36Sopenharmony_ci * License.  See the file "COPYING" in the main directory of this archive
662306a36Sopenharmony_ci * for more details.
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci * Copyright (C) 2001 - 2005 Tensilica Inc.
962306a36Sopenharmony_ci */
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#ifndef _XTENSA_THREAD_INFO_H
1262306a36Sopenharmony_ci#define _XTENSA_THREAD_INFO_H
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci#include <linux/stringify.h>
1562306a36Sopenharmony_ci#include <asm/kmem_layout.h>
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci#define CURRENT_SHIFT KERNEL_STACK_SHIFT
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci#ifndef __ASSEMBLY__
2062306a36Sopenharmony_ci# include <asm/processor.h>
2162306a36Sopenharmony_ci#endif
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci/*
2462306a36Sopenharmony_ci * low level task data that entry.S needs immediate access to
2562306a36Sopenharmony_ci * - this struct should fit entirely inside of one cache line
2662306a36Sopenharmony_ci * - this struct shares the supervisor stack pages
2762306a36Sopenharmony_ci * - if the contents of this structure are changed, the assembly constants
2862306a36Sopenharmony_ci *   must also be changed
2962306a36Sopenharmony_ci */
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci#ifndef __ASSEMBLY__
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci#if XTENSA_HAVE_COPROCESSORS
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_citypedef struct xtregs_coprocessor {
3662306a36Sopenharmony_ci	xtregs_cp0_t cp0;
3762306a36Sopenharmony_ci	xtregs_cp1_t cp1;
3862306a36Sopenharmony_ci	xtregs_cp2_t cp2;
3962306a36Sopenharmony_ci	xtregs_cp3_t cp3;
4062306a36Sopenharmony_ci	xtregs_cp4_t cp4;
4162306a36Sopenharmony_ci	xtregs_cp5_t cp5;
4262306a36Sopenharmony_ci	xtregs_cp6_t cp6;
4362306a36Sopenharmony_ci	xtregs_cp7_t cp7;
4462306a36Sopenharmony_ci} xtregs_coprocessor_t;
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci#endif
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_cistruct thread_info {
4962306a36Sopenharmony_ci	struct task_struct	*task;		/* main task structure */
5062306a36Sopenharmony_ci	unsigned long		flags;		/* low level flags */
5162306a36Sopenharmony_ci	unsigned long		status;		/* thread-synchronous flags */
5262306a36Sopenharmony_ci	__u32			cpu;		/* current CPU */
5362306a36Sopenharmony_ci	__s32			preempt_count;	/* 0 => preemptable,< 0 => BUG*/
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci#if XCHAL_HAVE_EXCLUSIVE
5662306a36Sopenharmony_ci	/* result of the most recent exclusive store */
5762306a36Sopenharmony_ci	unsigned long		atomctl8;
5862306a36Sopenharmony_ci#endif
5962306a36Sopenharmony_ci#ifdef CONFIG_USER_ABI_CALL0_PROBE
6062306a36Sopenharmony_ci	/* Address where PS.WOE was enabled by the ABI probing code */
6162306a36Sopenharmony_ci	unsigned long		ps_woe_fix_addr;
6262306a36Sopenharmony_ci#endif
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ci	/*
6562306a36Sopenharmony_ci	 * If i-th bit is set then coprocessor state is loaded into the
6662306a36Sopenharmony_ci	 * coprocessor i on CPU cp_owner_cpu.
6762306a36Sopenharmony_ci	 */
6862306a36Sopenharmony_ci	unsigned long		cpenable;
6962306a36Sopenharmony_ci	u32			cp_owner_cpu;
7062306a36Sopenharmony_ci	/* Allocate storage for extra user states and coprocessor states. */
7162306a36Sopenharmony_ci#if XTENSA_HAVE_COPROCESSORS
7262306a36Sopenharmony_ci	xtregs_coprocessor_t	xtregs_cp;
7362306a36Sopenharmony_ci#endif
7462306a36Sopenharmony_ci	xtregs_user_t		xtregs_user;
7562306a36Sopenharmony_ci};
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci#endif
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci/*
8062306a36Sopenharmony_ci * macros/functions for gaining access to the thread information structure
8162306a36Sopenharmony_ci */
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ci#ifndef __ASSEMBLY__
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci#define INIT_THREAD_INFO(tsk)			\
8662306a36Sopenharmony_ci{						\
8762306a36Sopenharmony_ci	.task		= &tsk,			\
8862306a36Sopenharmony_ci	.flags		= 0,			\
8962306a36Sopenharmony_ci	.cpu		= 0,			\
9062306a36Sopenharmony_ci	.preempt_count	= INIT_PREEMPT_COUNT,	\
9162306a36Sopenharmony_ci}
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci/* how to get the thread information struct from C */
9462306a36Sopenharmony_cistatic inline struct thread_info *current_thread_info(void)
9562306a36Sopenharmony_ci{
9662306a36Sopenharmony_ci	struct thread_info *ti;
9762306a36Sopenharmony_ci	 __asm__("extui %0, a1, 0, "__stringify(CURRENT_SHIFT)"\n\t"
9862306a36Sopenharmony_ci	         "xor %0, a1, %0" : "=&r" (ti) : );
9962306a36Sopenharmony_ci	return ti;
10062306a36Sopenharmony_ci}
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci#else /* !__ASSEMBLY__ */
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci/* how to get the thread information struct from ASM */
10562306a36Sopenharmony_ci#define GET_THREAD_INFO(reg,sp) \
10662306a36Sopenharmony_ci	extui reg, sp, 0, CURRENT_SHIFT; \
10762306a36Sopenharmony_ci	xor   reg, sp, reg
10862306a36Sopenharmony_ci#endif
10962306a36Sopenharmony_ci
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ci/*
11262306a36Sopenharmony_ci * thread information flags
11362306a36Sopenharmony_ci * - these are process state flags that various assembly files may need to access
11462306a36Sopenharmony_ci */
11562306a36Sopenharmony_ci#define TIF_SYSCALL_TRACE	0	/* syscall trace active */
11662306a36Sopenharmony_ci#define TIF_SIGPENDING		1	/* signal pending */
11762306a36Sopenharmony_ci#define TIF_NEED_RESCHED	2	/* rescheduling necessary */
11862306a36Sopenharmony_ci#define TIF_SINGLESTEP		3	/* restore singlestep on return to user mode */
11962306a36Sopenharmony_ci#define TIF_SYSCALL_TRACEPOINT	4	/* syscall tracepoint instrumentation */
12062306a36Sopenharmony_ci#define TIF_NOTIFY_SIGNAL	5	/* signal notifications exist */
12162306a36Sopenharmony_ci#define TIF_RESTORE_SIGMASK	6	/* restore signal mask in do_signal() */
12262306a36Sopenharmony_ci#define TIF_NOTIFY_RESUME	7	/* callback before returning to user */
12362306a36Sopenharmony_ci#define TIF_DB_DISABLED		8	/* debug trap disabled for syscall */
12462306a36Sopenharmony_ci#define TIF_SYSCALL_AUDIT	9	/* syscall auditing active */
12562306a36Sopenharmony_ci#define TIF_SECCOMP		10	/* secure computing */
12662306a36Sopenharmony_ci#define TIF_MEMDIE		11	/* is terminating due to OOM killer */
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_ci#define _TIF_SYSCALL_TRACE	(1<<TIF_SYSCALL_TRACE)
12962306a36Sopenharmony_ci#define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
13062306a36Sopenharmony_ci#define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
13162306a36Sopenharmony_ci#define _TIF_SINGLESTEP		(1<<TIF_SINGLESTEP)
13262306a36Sopenharmony_ci#define _TIF_SYSCALL_TRACEPOINT	(1<<TIF_SYSCALL_TRACEPOINT)
13362306a36Sopenharmony_ci#define _TIF_NOTIFY_SIGNAL	(1<<TIF_NOTIFY_SIGNAL)
13462306a36Sopenharmony_ci#define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
13562306a36Sopenharmony_ci#define _TIF_SYSCALL_AUDIT	(1<<TIF_SYSCALL_AUDIT)
13662306a36Sopenharmony_ci#define _TIF_SECCOMP		(1<<TIF_SECCOMP)
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_ci#define _TIF_WORK_MASK		(_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \
13962306a36Sopenharmony_ci				 _TIF_SYSCALL_TRACEPOINT | \
14062306a36Sopenharmony_ci				 _TIF_SYSCALL_AUDIT | _TIF_SECCOMP)
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci#define THREAD_SIZE KERNEL_STACK_SIZE
14362306a36Sopenharmony_ci#define THREAD_SIZE_ORDER (KERNEL_STACK_SHIFT - PAGE_SHIFT)
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_ci#endif	/* _XTENSA_THREAD_INFO */
146