Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #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 | ||
25 | struct 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 */ | |
dcd497f9 | 31 | int preempt_count; /* 0 => preemptable, <0 => BUG */ |
1da177e4 LT |
32 | |
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 | ||
58 | /* | |
59 | * macros/functions for gaining access to the thread information structure | |
60 | * | |
61 | * preempt_count needs to be 1 initially, until the scheduler is functional. | |
62 | */ | |
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, \ | |
71 | .preempt_count = 1, \ | |
72 | .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 | ||
81 | #define THREAD_SIZE (2*PAGE_SIZE) | |
82 | ||
83 | /* how to get the thread information struct from C */ | |
84 | static inline struct thread_info *current_thread_info(void) | |
85 | { | |
86 | struct thread_info *ti; | |
87 | ||
88 | __asm__ __volatile__ ( | |
89 | "ldi %0, #%1 \n\t" | |
90 | "and %0, sp \n\t" | |
91 | : "=r" (ti) : "i" (~(THREAD_SIZE - 1)) | |
92 | ); | |
93 | ||
94 | return ti; | |
95 | } | |
96 | ||
97 | /* thread information allocation */ | |
c978b017 | 98 | #ifdef CONFIG_DEBUG_STACK_USAGE |
1da177e4 LT |
99 | #define alloc_thread_info(tsk) \ |
100 | ({ \ | |
101 | struct thread_info *ret; \ | |
102 | \ | |
103 | ret = kmalloc(THREAD_SIZE, GFP_KERNEL); \ | |
104 | if (ret) \ | |
105 | memset(ret, 0, THREAD_SIZE); \ | |
106 | ret; \ | |
107 | }) | |
108 | #else | |
109 | #define alloc_thread_info(tsk) kmalloc(THREAD_SIZE, GFP_KERNEL) | |
110 | #endif | |
111 | ||
112 | #define free_thread_info(info) kfree(info) | |
1da177e4 LT |
113 | |
114 | #define TI_FLAG_FAULT_CODE_SHIFT 28 | |
115 | ||
116 | static inline void set_thread_fault_code(unsigned int val) | |
117 | { | |
118 | struct thread_info *ti = current_thread_info(); | |
119 | ti->flags = (ti->flags & (~0 >> (32 - TI_FLAG_FAULT_CODE_SHIFT))) | |
120 | | (val << TI_FLAG_FAULT_CODE_SHIFT); | |
121 | } | |
122 | ||
123 | static inline unsigned int get_thread_fault_code(void) | |
124 | { | |
125 | struct thread_info *ti = current_thread_info(); | |
126 | return ti->flags >> TI_FLAG_FAULT_CODE_SHIFT; | |
127 | } | |
128 | ||
129 | #else /* !__ASSEMBLY__ */ | |
130 | ||
131 | #define THREAD_SIZE 8192 | |
132 | ||
133 | /* how to get the thread information struct from ASM */ | |
134 | #define GET_THREAD_INFO(reg) GET_THREAD_INFO reg | |
135 | .macro GET_THREAD_INFO reg | |
136 | ldi \reg, #-THREAD_SIZE | |
137 | and \reg, sp | |
138 | .endm | |
139 | ||
140 | #endif | |
141 | ||
142 | /* | |
143 | * thread information flags | |
144 | * - these are process state flags that various assembly files may need to access | |
145 | * - pending work-to-be-done flags are in LSW | |
146 | * - other flags in MSW | |
147 | */ | |
148 | #define TIF_SYSCALL_TRACE 0 /* syscall trace active */ | |
149 | #define TIF_NOTIFY_RESUME 1 /* resumption notification requested */ | |
150 | #define TIF_SIGPENDING 2 /* signal pending */ | |
151 | #define TIF_NEED_RESCHED 3 /* rescheduling necessary */ | |
152 | #define TIF_SINGLESTEP 4 /* restore singlestep on return to user mode */ | |
153 | #define TIF_IRET 5 /* return with iret */ | |
154 | #define TIF_POLLING_NRFLAG 16 /* true if poll_idle() is polling TIF_NEED_RESCHED */ | |
155 | /* 31..28 fault code */ | |
156 | #define TIF_MEMDIE 17 | |
157 | ||
158 | #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE) | |
159 | #define _TIF_NOTIFY_RESUME (1<<TIF_NOTIFY_RESUME) | |
160 | #define _TIF_SIGPENDING (1<<TIF_SIGPENDING) | |
161 | #define _TIF_NEED_RESCHED (1<<TIF_NEED_RESCHED) | |
162 | #define _TIF_SINGLESTEP (1<<TIF_SINGLESTEP) | |
163 | #define _TIF_IRET (1<<TIF_IRET) | |
164 | #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG) | |
165 | ||
166 | #define _TIF_WORK_MASK 0x0000FFFE /* work to do on interrupt/exception return */ | |
167 | #define _TIF_ALLWORK_MASK 0x0000FFFF /* work to do on any return to u-space */ | |
168 | ||
169 | /* | |
170 | * Thread-synchronous status. | |
171 | * | |
172 | * This is different from the flags in that nobody else | |
173 | * ever touches our thread-synchronous status, so we don't | |
174 | * have to worry about atomic accesses. | |
175 | */ | |
176 | #define TS_USEDFPU 0x0001 /* FPU was used by this task this quantum (SMP) */ | |
177 | ||
178 | #endif /* __KERNEL__ */ | |
179 | ||
180 | #endif /* _ASM_M32R_THREAD_INFO_H */ |