1 #ifndef _ASM_M32R_THREAD_INFO_H
2 #define _ASM_M32R_THREAD_INFO_H
4 /* thread_info.h: m32r low-level thread information
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>
14 #include <asm/processor.h>
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
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 */
31 int preempt_count; /* 0 => preemptable, <0 => BUG */
33 mm_segment_t addr_limit; /* thread address space:
34 0-0xBFFFFFFF for user-thread
35 0-0xFFFFFFFF for kernel-thread
38 __u8 supervisor_stack[0];
41 #else /* !__ASSEMBLY__ */
43 /* offsets into the thread_info struct for assembly code access */
44 #define TI_TASK 0x00000000
45 #define TI_EXEC_DOMAIN 0x00000004
46 #define TI_FLAGS 0x00000008
47 #define TI_STATUS 0x0000000C
48 #define TI_CPU 0x00000010
49 #define TI_PRE_COUNT 0x00000014
50 #define TI_ADDR_LIMIT 0x00000018
54 #define THREAD_SIZE (PAGE_SIZE << 1)
55 #define THREAD_SIZE_ORDER 1
57 * macros/functions for gaining access to the thread information structure
61 #define INIT_THREAD_INFO(tsk) \
64 .exec_domain = &default_exec_domain, \
67 .preempt_count = INIT_PREEMPT_COUNT, \
68 .addr_limit = KERNEL_DS, \
71 #define init_thread_info (init_thread_union.thread_info)
72 #define init_stack (init_thread_union.stack)
74 /* how to get the thread information struct from C */
75 static inline struct thread_info *current_thread_info(void)
77 struct thread_info *ti;
79 __asm__ __volatile__ (
82 : "=r" (ti) : "i" (~(THREAD_SIZE - 1))
88 #define TI_FLAG_FAULT_CODE_SHIFT 28
90 static inline void set_thread_fault_code(unsigned int val)
92 struct thread_info *ti = current_thread_info();
93 ti->flags = (ti->flags & (~0 >> (32 - TI_FLAG_FAULT_CODE_SHIFT)))
94 | (val << TI_FLAG_FAULT_CODE_SHIFT);
97 static inline unsigned int get_thread_fault_code(void)
99 struct thread_info *ti = current_thread_info();
100 return ti->flags >> TI_FLAG_FAULT_CODE_SHIFT;
106 * thread information flags
107 * - these are process state flags that various assembly files may need to access
108 * - pending work-to-be-done flags are in LSW
109 * - other flags in MSW
111 #define TIF_SYSCALL_TRACE 0 /* syscall trace active */
112 #define TIF_SIGPENDING 1 /* signal pending */
113 #define TIF_NEED_RESCHED 2 /* rescheduling necessary */
114 #define TIF_SINGLESTEP 3 /* restore singlestep on return to user mode */
115 #define TIF_NOTIFY_RESUME 5 /* callback before returning to user */
116 #define TIF_RESTORE_SIGMASK 8 /* restore signal mask in do_signal() */
117 #define TIF_USEDFPU 16 /* FPU was used by this task this quantum (SMP) */
118 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
120 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
121 #define _TIF_SIGPENDING (1<<TIF_SIGPENDING)
122 #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED)
123 #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP)
124 #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME)
125 #define _TIF_USEDFPU (1<<TIF_USEDFPU)
127 #define _TIF_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
128 #define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_SYSCALL_TRACE)
131 * Thread-synchronous status.
133 * This is different from the flags in that nobody else
134 * ever touches our thread-synchronous status, so we don't
135 * have to worry about atomic accesses.
137 #define TS_USEDFPU 0x0001 /* FPU was used by this task this quantum (SMP) */
139 #endif /* __KERNEL__ */
141 #endif /* _ASM_M32R_THREAD_INFO_H */