xref: /openbmc/linux/arch/microblaze/include/asm/thread_info.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
14726dd60SMichal Simek /* SPDX-License-Identifier: GPL-2.0 */
24684dadeSMichal Simek /*
34684dadeSMichal Simek  * Copyright (C) 2006 Atmark Techno, Inc.
44684dadeSMichal Simek  */
54684dadeSMichal Simek 
64684dadeSMichal Simek #ifndef _ASM_MICROBLAZE_THREAD_INFO_H
74684dadeSMichal Simek #define _ASM_MICROBLAZE_THREAD_INFO_H
84684dadeSMichal Simek 
94684dadeSMichal Simek #ifdef __KERNEL__
104684dadeSMichal Simek 
114684dadeSMichal Simek /* we have 8k stack */
124684dadeSMichal Simek #define THREAD_SHIFT		13
134684dadeSMichal Simek #define THREAD_SIZE		(1 << THREAD_SHIFT)
144684dadeSMichal Simek #define THREAD_SIZE_ORDER	1
154684dadeSMichal Simek 
164684dadeSMichal Simek #ifndef __ASSEMBLY__
174684dadeSMichal Simek # include <linux/types.h>
184684dadeSMichal Simek # include <asm/processor.h>
194684dadeSMichal Simek 
204684dadeSMichal Simek /*
214684dadeSMichal Simek  * low level task data that entry.S needs immediate access to
224684dadeSMichal Simek  * - this struct should fit entirely inside of one cache line
234684dadeSMichal Simek  * - this struct shares the supervisor stack pages
244684dadeSMichal Simek  * - if the contents of this structure are changed, the assembly constants
254684dadeSMichal Simek  *	 must also be changed
264684dadeSMichal Simek  */
274684dadeSMichal Simek 
284684dadeSMichal Simek struct cpu_context {
294684dadeSMichal Simek 	__u32	r1; /* stack pointer */
304684dadeSMichal Simek 	__u32	r2;
314684dadeSMichal Simek 	/* dedicated registers */
324684dadeSMichal Simek 	__u32	r13;
334684dadeSMichal Simek 	__u32	r14;
344684dadeSMichal Simek 	__u32	r15;
354684dadeSMichal Simek 	__u32	r16;
364684dadeSMichal Simek 	__u32	r17;
374684dadeSMichal Simek 	__u32	r18;
384684dadeSMichal Simek 	/* non-volatile registers */
394684dadeSMichal Simek 	__u32	r19;
404684dadeSMichal Simek 	__u32	r20;
414684dadeSMichal Simek 	__u32	r21;
424684dadeSMichal Simek 	__u32	r22;
434684dadeSMichal Simek 	__u32	r23;
444684dadeSMichal Simek 	__u32	r24;
454684dadeSMichal Simek 	__u32	r25;
464684dadeSMichal Simek 	__u32	r26;
474684dadeSMichal Simek 	__u32	r27;
484684dadeSMichal Simek 	__u32	r28;
494684dadeSMichal Simek 	__u32	r29;
504684dadeSMichal Simek 	__u32	r30;
514684dadeSMichal Simek 	/* r31 is used as current task pointer */
524684dadeSMichal Simek 	/* special purpose registers */
534684dadeSMichal Simek 	__u32	msr;
544684dadeSMichal Simek 	__u32	ear;
554684dadeSMichal Simek 	__u32	esr;
564684dadeSMichal Simek 	__u32	fsr;
574684dadeSMichal Simek };
584684dadeSMichal Simek 
594684dadeSMichal Simek struct thread_info {
604684dadeSMichal Simek 	struct task_struct	*task; /* main task structure */
614684dadeSMichal Simek 	unsigned long		flags; /* low level flags */
624684dadeSMichal Simek 	unsigned long		status; /* thread-synchronous flags */
634684dadeSMichal Simek 	__u32			cpu; /* current CPU */
644684dadeSMichal Simek 	__s32			preempt_count; /* 0 => preemptable,< 0 => BUG*/
654684dadeSMichal Simek 
664684dadeSMichal Simek 	struct cpu_context	cpu_context;
674684dadeSMichal Simek };
684684dadeSMichal Simek 
694684dadeSMichal Simek /*
704684dadeSMichal Simek  * macros/functions for gaining access to the thread information structure
714684dadeSMichal Simek  */
724684dadeSMichal Simek #define INIT_THREAD_INFO(tsk)			\
734684dadeSMichal Simek {						\
744684dadeSMichal Simek 	.task		= &tsk,			\
754684dadeSMichal Simek 	.flags		= 0,			\
764684dadeSMichal Simek 	.cpu		= 0,			\
77c99e6efeSPeter Zijlstra 	.preempt_count	= INIT_PREEMPT_COUNT,	\
784684dadeSMichal Simek }
794684dadeSMichal Simek 
804684dadeSMichal Simek /* how to get the thread information struct from C */
current_thread_info(void)814684dadeSMichal Simek static inline struct thread_info *current_thread_info(void)
824684dadeSMichal Simek {
834684dadeSMichal Simek 	register unsigned long sp asm("r1");
844684dadeSMichal Simek 
854684dadeSMichal Simek 	return (struct thread_info *)(sp & ~(THREAD_SIZE-1));
864684dadeSMichal Simek }
874684dadeSMichal Simek 
884684dadeSMichal Simek /* thread information allocation */
894684dadeSMichal Simek #endif /* __ASSEMBLY__ */
904684dadeSMichal Simek 
914684dadeSMichal Simek /*
924684dadeSMichal Simek  * thread information flags
934684dadeSMichal Simek  * - these are process state flags that various assembly files may
944684dadeSMichal Simek  *   need to access
954684dadeSMichal Simek  * - pending work-to-be-done flags are in LSW
964684dadeSMichal Simek  * - other flags in MSW
974684dadeSMichal Simek  */
984684dadeSMichal Simek #define TIF_SYSCALL_TRACE	0 /* syscall trace active */
994684dadeSMichal Simek #define TIF_NOTIFY_RESUME	1 /* resumption notification requested */
1004684dadeSMichal Simek #define TIF_SIGPENDING		2 /* signal pending */
1014684dadeSMichal Simek #define TIF_NEED_RESCHED	3 /* rescheduling necessary */
1024684dadeSMichal Simek /* restore singlestep on return to user mode */
1034684dadeSMichal Simek #define TIF_SINGLESTEP		4
104*ed2124c0SJens Axboe #define TIF_NOTIFY_SIGNAL	5	/* signal notifications exist */
1050ddc9324SAndreas Dilger #define TIF_MEMDIE		6	/* is terminating due to OOM killer */
1060945f98bSEdgar E. Iglesias #define TIF_SYSCALL_AUDIT	9       /* syscall auditing active */
1070945f98bSEdgar E. Iglesias #define TIF_SECCOMP		10      /* secure computing */
1084684dadeSMichal Simek 
1094684dadeSMichal Simek /* true if poll_idle() is polling TIF_NEED_RESCHED */
1104684dadeSMichal Simek #define TIF_POLLING_NRFLAG	16
1114684dadeSMichal Simek 
1124684dadeSMichal Simek #define _TIF_SYSCALL_TRACE	(1 << TIF_SYSCALL_TRACE)
1134684dadeSMichal Simek #define _TIF_NOTIFY_RESUME	(1 << TIF_NOTIFY_RESUME)
1144684dadeSMichal Simek #define _TIF_SIGPENDING		(1 << TIF_SIGPENDING)
1154684dadeSMichal Simek #define _TIF_NEED_RESCHED	(1 << TIF_NEED_RESCHED)
1164684dadeSMichal Simek #define _TIF_SINGLESTEP		(1 << TIF_SINGLESTEP)
117*ed2124c0SJens Axboe #define _TIF_NOTIFY_SIGNAL	(1 << TIF_NOTIFY_SIGNAL)
1184684dadeSMichal Simek #define _TIF_POLLING_NRFLAG	(1 << TIF_POLLING_NRFLAG)
1190945f98bSEdgar E. Iglesias #define _TIF_SYSCALL_AUDIT	(1 << TIF_SYSCALL_AUDIT)
1200945f98bSEdgar E. Iglesias #define _TIF_SECCOMP		(1 << TIF_SECCOMP)
1214684dadeSMichal Simek 
1220945f98bSEdgar E. Iglesias /* work to do in syscall trace */
1230945f98bSEdgar E. Iglesias #define _TIF_WORK_SYSCALL_MASK  (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \
1240945f98bSEdgar E. Iglesias 				 _TIF_SYSCALL_AUDIT | _TIF_SECCOMP)
1250945f98bSEdgar E. Iglesias 
1264684dadeSMichal Simek /* work to do on interrupt/exception return */
1274684dadeSMichal Simek #define _TIF_WORK_MASK		0x0000FFFE
1280945f98bSEdgar E. Iglesias 
1294684dadeSMichal Simek /* work to do on any return to u-space */
1304684dadeSMichal Simek #define _TIF_ALLWORK_MASK	0x0000FFFF
1314684dadeSMichal Simek 
1324684dadeSMichal Simek /*
1334684dadeSMichal Simek  * Thread-synchronous status.
1344684dadeSMichal Simek  *
1354684dadeSMichal Simek  * This is different from the flags in that nobody else
1364684dadeSMichal Simek  * ever touches our thread-synchronous status, so we don't
1374684dadeSMichal Simek  * have to worry about atomic accesses.
1384684dadeSMichal Simek  */
1394684dadeSMichal Simek /* FPU was used by this task this quantum (SMP) */
1404684dadeSMichal Simek #define TS_USEDFPU		0x0001
1414684dadeSMichal Simek 
1424684dadeSMichal Simek #endif /* __KERNEL__ */
1434684dadeSMichal Simek #endif /* _ASM_MICROBLAZE_THREAD_INFO_H */
144