2 * Copyright (C) 2006 Atmark Techno, Inc.
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License. See the file "COPYING" in the main directory of this archive
9 #ifndef _ASM_MICROBLAZE_THREAD_INFO_H
10 #define _ASM_MICROBLAZE_THREAD_INFO_H
14 /* we have 8k stack */
15 #define THREAD_SHIFT 13
16 #define THREAD_SIZE (1 << THREAD_SHIFT)
17 #define THREAD_SIZE_ORDER 1
20 # include <linux/types.h>
21 # include <asm/processor.h>
24 * low level task data that entry.S needs immediate access to
25 * - this struct should fit entirely inside of one cache line
26 * - this struct shares the supervisor stack pages
27 * - if the contents of this structure are changed, the assembly constants
28 * must also be changed
32 __u32 r1
; /* stack pointer */
34 /* dedicated registers */
41 /* non-volatile registers */
54 /* r31 is used as current task pointer */
55 /* special purpose registers */
67 struct task_struct
*task
; /* main task structure */
68 struct exec_domain
*exec_domain
; /* execution domain */
69 unsigned long flags
; /* low level flags */
70 unsigned long status
; /* thread-synchronous flags */
71 __u32 cpu
; /* current CPU */
72 __s32 preempt_count
; /* 0 => preemptable,< 0 => BUG*/
73 mm_segment_t addr_limit
; /* thread address space */
75 struct cpu_context cpu_context
;
79 * macros/functions for gaining access to the thread information structure
81 #define INIT_THREAD_INFO(tsk) \
84 .exec_domain = &default_exec_domain, \
87 .preempt_count = INIT_PREEMPT_COUNT, \
88 .addr_limit = KERNEL_DS, \
91 #define init_thread_info (init_thread_union.thread_info)
92 #define init_stack (init_thread_union.stack)
94 /* how to get the thread information struct from C */
95 static inline struct thread_info
*current_thread_info(void)
97 register unsigned long sp
asm("r1");
99 return (struct thread_info
*)(sp
& ~(THREAD_SIZE
-1));
102 /* thread information allocation */
103 #endif /* __ASSEMBLY__ */
106 * thread information flags
107 * - these are process state flags that various assembly files may
109 * - pending work-to-be-done flags are in LSW
110 * - other flags in MSW
112 #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
113 #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
114 #define TIF_SIGPENDING 2 /* signal pending */
115 #define TIF_NEED_RESCHED 3 /* rescheduling necessary */
116 /* restore singlestep on return to user mode */
117 #define TIF_SINGLESTEP 4
118 #define TIF_MEMDIE 6 /* is terminating due to OOM killer */
119 #define TIF_SYSCALL_AUDIT 9 /* syscall auditing active */
120 #define TIF_SECCOMP 10 /* secure computing */
122 /* true if poll_idle() is polling TIF_NEED_RESCHED */
123 #define TIF_POLLING_NRFLAG 16
125 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
126 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
127 #define _TIF_SIGPENDING (1 << TIF_SIGPENDING)
128 #define _TIF_NEED_RESCHED (1 << TIF_NEED_RESCHED)
129 #define _TIF_SINGLESTEP (1 << TIF_SINGLESTEP)
130 #define _TIF_POLLING_NRFLAG (1 << TIF_POLLING_NRFLAG)
131 #define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
132 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
134 /* work to do in syscall trace */
135 #define _TIF_WORK_SYSCALL_MASK (_TIF_SYSCALL_TRACE | _TIF_SINGLESTEP | \
136 _TIF_SYSCALL_AUDIT | _TIF_SECCOMP)
138 /* work to do on interrupt/exception return */
139 #define _TIF_WORK_MASK 0x0000FFFE
141 /* work to do on any return to u-space */
142 #define _TIF_ALLWORK_MASK 0x0000FFFF
145 * Thread-synchronous status.
147 * This is different from the flags in that nobody else
148 * ever touches our thread-synchronous status, so we don't
149 * have to worry about atomic accesses.
151 /* FPU was used by this task this quantum (SMP) */
152 #define TS_USEDFPU 0x0001
153 #define TS_RESTORE_SIGMASK 0x0002
156 #define HAVE_SET_RESTORE_SIGMASK 1
157 static inline void set_restore_sigmask(void)
159 struct thread_info
*ti
= current_thread_info();
160 ti
->status
|= TS_RESTORE_SIGMASK
;
161 WARN_ON(!test_bit(TIF_SIGPENDING
, (unsigned long *)&ti
->flags
));
163 static inline void clear_restore_sigmask(void)
165 current_thread_info()->status
&= ~TS_RESTORE_SIGMASK
;
167 static inline bool test_restore_sigmask(void)
169 return current_thread_info()->status
& TS_RESTORE_SIGMASK
;
171 static inline bool test_and_clear_restore_sigmask(void)
173 struct thread_info
*ti
= current_thread_info();
174 if (!(ti
->status
& TS_RESTORE_SIGMASK
))
176 ti
->status
&= ~TS_RESTORE_SIGMASK
;
181 #endif /* __KERNEL__ */
182 #endif /* _ASM_MICROBLAZE_THREAD_INFO_H */