xref: /linux/arch/hexagon/include/asm/thread_info.h (revision e0bf6c5ca2d3281f231c5f0c9bf145e9513644de)
1 /*
2  * Thread support for the Hexagon architecture
3  *
4  * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 and
8  * only version 2 as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18  * 02110-1301, USA.
19  */
20 
21 #ifndef _ASM_THREAD_INFO_H
22 #define _ASM_THREAD_INFO_H
23 
24 #ifdef __KERNEL__
25 
26 #ifndef __ASSEMBLY__
27 #include <asm/processor.h>
28 #include <asm/registers.h>
29 #include <asm/page.h>
30 #endif
31 
32 #define THREAD_SHIFT		12
33 #define THREAD_SIZE		(1<<THREAD_SHIFT)
34 #define THREAD_SIZE_ORDER	(THREAD_SHIFT - PAGE_SHIFT)
35 
36 #ifndef __ASSEMBLY__
37 
38 typedef struct {
39 	unsigned long seg;
40 } mm_segment_t;
41 
42 /*
43  * This is union'd with the "bottom" of the kernel stack.
44  * It keeps track of thread info which is handy for routines
45  * to access quickly.
46  */
47 
48 struct thread_info {
49 	struct task_struct	*task;		/* main task structure */
50 	struct exec_domain      *exec_domain;   /* execution domain */
51 	unsigned long		flags;          /* low level flags */
52 	__u32                   cpu;            /* current cpu */
53 	int                     preempt_count;  /* 0=>preemptible,<0=>BUG */
54 	mm_segment_t            addr_limit;     /* segmentation sux */
55 	/*
56 	 * used for syscalls somehow;
57 	 * seems to have a function pointer and four arguments
58 	 */
59 	/* Points to the current pt_regs frame  */
60 	struct pt_regs		*regs;
61 	/*
62 	 * saved kernel sp at switch_to time;
63 	 * not sure if this is used (it's not in the VM model it seems;
64 	 * see thread_struct)
65 	 */
66 	unsigned long		sp;
67 };
68 
69 #else /* !__ASSEMBLY__ */
70 
71 #include <asm/asm-offsets.h>
72 
73 #endif  /* __ASSEMBLY__  */
74 
75 #ifndef __ASSEMBLY__
76 
77 #define INIT_THREAD_INFO(tsk)                   \
78 {                                               \
79 	.task           = &tsk,                 \
80 	.exec_domain    = &default_exec_domain, \
81 	.flags          = 0,                    \
82 	.cpu            = 0,                    \
83 	.preempt_count  = 1,                    \
84 	.addr_limit     = KERNEL_DS,            \
85 	.sp = 0,				\
86 	.regs = NULL,			\
87 }
88 
89 #define init_thread_info        (init_thread_union.thread_info)
90 #define init_stack              (init_thread_union.stack)
91 
92 /* Tacky preprocessor trickery */
93 #define	qqstr(s) qstr(s)
94 #define qstr(s) #s
95 #define QUOTED_THREADINFO_REG qqstr(THREADINFO_REG)
96 
97 register struct thread_info *__current_thread_info asm(QUOTED_THREADINFO_REG);
98 #define current_thread_info()  __current_thread_info
99 
100 #endif /* __ASSEMBLY__ */
101 
102 /*
103  * thread information flags
104  * - these are process state flags that various assembly files
105  *   may need to access
106  * - pending work-to-be-done flags are in LSW
107  * - other flags in MSW
108  */
109 
110 #define TIF_SYSCALL_TRACE       0       /* syscall trace active */
111 #define TIF_NOTIFY_RESUME       1       /* resumption notification requested */
112 #define TIF_SIGPENDING          2       /* signal pending */
113 #define TIF_NEED_RESCHED        3       /* rescheduling necessary */
114 #define TIF_SINGLESTEP          4       /* restore ss @ return to usr mode */
115 #define TIF_RESTORE_SIGMASK     6       /* restore sig mask in do_signal() */
116 /* true if poll_idle() is polling TIF_NEED_RESCHED */
117 #define TIF_MEMDIE              17      /* OOM killer killed process */
118 
119 #define _TIF_SYSCALL_TRACE      (1 << TIF_SYSCALL_TRACE)
120 #define _TIF_NOTIFY_RESUME      (1 << TIF_NOTIFY_RESUME)
121 #define _TIF_SIGPENDING         (1 << TIF_SIGPENDING)
122 #define _TIF_NEED_RESCHED       (1 << TIF_NEED_RESCHED)
123 #define _TIF_SINGLESTEP         (1 << TIF_SINGLESTEP)
124 
125 /* work to do on interrupt/exception return - All but TIF_SYSCALL_TRACE */
126 #define _TIF_WORK_MASK          (0x0000FFFF & ~_TIF_SYSCALL_TRACE)
127 
128 /* work to do on any return to u-space */
129 #define _TIF_ALLWORK_MASK       0x0000FFFF
130 
131 #endif /* __KERNEL__ */
132 
133 #endif
134