blob: 0227dba44068b87b8e4406f05d57340fcdec3c87 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _ASM_M32R_THREAD_INFO_H
2#define _ASM_M32R_THREAD_INFO_H
3
4/* thread_info.h: m32r low-level thread information
5 *
6 * Copyright (C) 2002 David Howells (dhowells@redhat.com)
7 * - Incorporating suggestions made by Linus Torvalds and Dave Miller
8 * Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org>
9 */
10
11#ifdef __KERNEL__
12
13#ifndef __ASSEMBLY__
14#include <asm/processor.h>
15#endif
16
17/*
18 * low level task data that entry.S needs immediate access to
19 * - this struct should fit entirely inside of one cache line
20 * - this struct shares the supervisor stack pages
21 * - if the contents of this structure are changed, the assembly constants must also be changed
22 */
23#ifndef __ASSEMBLY__
24
25struct thread_info {
26 struct task_struct *task; /* main task structure */
27 struct exec_domain *exec_domain; /* execution domain */
28 unsigned long flags; /* low level flags */
29 unsigned long status; /* thread-synchronous flags */
30 __u32 cpu; /* current CPU */
Jesper Juhldcd497f2005-06-23 00:09:07 -070031 int preempt_count; /* 0 => preemptable, <0 => BUG */
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33 mm_segment_t addr_limit; /* thread address space:
34 0-0xBFFFFFFF for user-thread
35 0-0xFFFFFFFF for kernel-thread
36 */
37 struct restart_block restart_block;
38
39 __u8 supervisor_stack[0];
40};
41
42#else /* !__ASSEMBLY__ */
43
44/* offsets into the thread_info struct for assembly code access */
45#define TI_TASK 0x00000000
46#define TI_EXEC_DOMAIN 0x00000004
47#define TI_FLAGS 0x00000008
48#define TI_STATUS 0x0000000C
49#define TI_CPU 0x00000010
50#define TI_PRE_COUNT 0x00000014
51#define TI_ADDR_LIMIT 0x00000018
52#define TI_RESTART_BLOCK 0x000001C
53
54#endif
55
56#define PREEMPT_ACTIVE 0x10000000
57
Tim Abbotta7efb872009-09-18 16:32:45 -040058#define THREAD_SIZE (PAGE_SIZE << 1)
59
Linus Torvalds1da177e2005-04-16 15:20:36 -070060/*
61 * macros/functions for gaining access to the thread information structure
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 */
63#ifndef __ASSEMBLY__
64
65#define INIT_THREAD_INFO(tsk) \
66{ \
67 .task = &tsk, \
68 .exec_domain = &default_exec_domain, \
69 .flags = 0, \
70 .cpu = 0, \
Peter Zijlstrac99e6ef2009-07-10 14:57:56 +020071 .preempt_count = INIT_PREEMPT_COUNT, \
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 .addr_limit = KERNEL_DS, \
73 .restart_block = { \
74 .fn = do_no_restart_syscall, \
75 }, \
76}
77
78#define init_thread_info (init_thread_union.thread_info)
79#define init_stack (init_thread_union.stack)
80
Linus Torvalds1da177e2005-04-16 15:20:36 -070081/* how to get the thread information struct from C */
82static inline struct thread_info *current_thread_info(void)
83{
84 struct thread_info *ti;
85
86 __asm__ __volatile__ (
87 "ldi %0, #%1 \n\t"
88 "and %0, sp \n\t"
89 : "=r" (ti) : "i" (~(THREAD_SIZE - 1))
90 );
91
92 return ti;
93}
94
FUJITA Tomonorib69c49b2008-07-25 01:45:40 -070095#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
96
Linus Torvalds1da177e2005-04-16 15:20:36 -070097/* thread information allocation */
Hirokazu Takatac978b012005-10-30 15:00:04 -080098#ifdef CONFIG_DEBUG_STACK_USAGE
Eric Dumazetb6a84012011-03-22 16:30:42 -070099#define alloc_thread_info_node(tsk, node) \
100 kzalloc_node(THREAD_SIZE, GFP_KERNEL, node)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101#else
Eric Dumazetb6a84012011-03-22 16:30:42 -0700102#define alloc_thread_info_node(tsk, node) \
103 kmalloc_node(THREAD_SIZE, GFP_KERNEL, node)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104#endif
105
106#define free_thread_info(info) kfree(info)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107
108#define TI_FLAG_FAULT_CODE_SHIFT 28
109
110static inline void set_thread_fault_code(unsigned int val)
111{
112 struct thread_info *ti = current_thread_info();
113 ti->flags = (ti->flags & (~0 >> (32 - TI_FLAG_FAULT_CODE_SHIFT)))
114 | (val << TI_FLAG_FAULT_CODE_SHIFT);
115}
116
117static inline unsigned int get_thread_fault_code(void)
118{
119 struct thread_info *ti = current_thread_info();
120 return ti->flags >> TI_FLAG_FAULT_CODE_SHIFT;
121}
122
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123#endif
124
125/*
126 * thread information flags
127 * - these are process state flags that various assembly files may need to access
128 * - pending work-to-be-done flags are in LSW
129 * - other flags in MSW
130 */
131#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
Stephane Eraniana583f1b2007-07-31 00:38:00 -0700132#define TIF_SIGPENDING 1 /* signal pending */
133#define TIF_NEED_RESCHED 2 /* rescheduling necessary */
134#define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */
135#define TIF_IRET 4 /* return with iret */
David Howellsd0420c82009-09-02 09:14:16 +0100136#define TIF_NOTIFY_RESUME 5 /* callback before returning to user */
Hirokazu Takatac37a3302007-09-12 17:51:35 +0900137#define TIF_RESTORE_SIGMASK 8 /* restore signal mask in do_signal() */
138#define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
139#define TIF_POLLING_NRFLAG 17 /* true if poll_idle() is polling TIF_NEED_RESCHED */
Andreas Dilger0ddc9322010-05-14 11:13:27 +0200140#define TIF_MEMDIE 18 /* is terminating due to OOM killer */
Hirokazu Takatac37a3302007-09-12 17:51:35 +0900141#define TIF_FREEZE 19 /* is freezing for suspend */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142
143#define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144#define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
145#define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
146#define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
147#define _TIF_IRET (1<<TIF_IRET)
David Howellsd0420c82009-09-02 09:14:16 +0100148#define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
Hirokazu Takatac37a3302007-09-12 17:51:35 +0900149#define _TIF_RESTORE_SIGMASK (1<<TIF_RESTORE_SIGMASK)
150#define _TIF_USEDFPU (1<<TIF_USEDFPU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151#define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
Hirokazu Takatac37a3302007-09-12 17:51:35 +0900152#define _TIF_FREEZE (1<<TIF_FREEZE)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153
154#define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */
155#define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */
156
157/*
158 * Thread-synchronous status.
159 *
160 * This is different from the flags in that nobody else
161 * ever touches our thread-synchronous status, so we don't
162 * have to worry about atomic accesses.
163 */
164#define TS_USEDFPU 0x0001 /* FPU was used by this task this quantum (SMP) */
165
166#endif /* __KERNEL__ */
167
168#endif /* _ASM_M32R_THREAD_INFO_H */