diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-09-22 18:18:23 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-10-01 00:54:29 -0400 |
commit | 61b7fbc3f4ebdcfd34f9438adfab8df936a19e33 (patch) | |
tree | 95d590708d5f156f11ed891f9a88b296a2b89f22 /arch/mn10300/kernel/process.c | |
parent | 6e75421014cd02cc66298d35c4667e493da78914 (diff) |
mn10300: convert to generic kernel_thread()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/mn10300/kernel/process.c')
-rw-r--r-- | arch/mn10300/kernel/process.c | 49 |
1 files changed, 18 insertions, 31 deletions
diff --git a/arch/mn10300/kernel/process.c b/arch/mn10300/kernel/process.c index 49af5ca89343..8ee09d828c43 100644 --- a/arch/mn10300/kernel/process.c +++ b/arch/mn10300/kernel/process.c | |||
@@ -162,24 +162,6 @@ void show_regs(struct pt_regs *regs) | |||
162 | } | 162 | } |
163 | 163 | ||
164 | /* | 164 | /* |
165 | * create a kernel thread | ||
166 | */ | ||
167 | int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags) | ||
168 | { | ||
169 | struct pt_regs regs = { | ||
170 | .a0 = (unsigned long) fn; | ||
171 | .d0 = (unsigned long) arg; | ||
172 | }; | ||
173 | |||
174 | local_save_flags(regs.epsw); | ||
175 | regs.epsw |= EPSW_IE | EPSW_IM_7; | ||
176 | |||
177 | /* Ok, create the new process.. */ | ||
178 | return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, ®s, 0, | ||
179 | NULL, NULL); | ||
180 | } | ||
181 | |||
182 | /* | ||
183 | * free current thread data structures etc.. | 165 | * free current thread data structures etc.. |
184 | */ | 166 | */ |
185 | void exit_thread(void) | 167 | void exit_thread(void) |
@@ -232,29 +214,34 @@ int copy_thread(unsigned long clone_flags, | |||
232 | /* allocate the userspace exception frame and set it up */ | 214 | /* allocate the userspace exception frame and set it up */ |
233 | c_ksp -= sizeof(struct pt_regs); | 215 | c_ksp -= sizeof(struct pt_regs); |
234 | c_regs = (struct pt_regs *) c_ksp; | 216 | c_regs = (struct pt_regs *) c_ksp; |
217 | c_ksp -= 12; /* allocate function call ABI slack */ | ||
235 | 218 | ||
219 | /* set up things up so the scheduler can start the new task */ | ||
236 | p->thread.uregs = c_regs; | 220 | p->thread.uregs = c_regs; |
221 | ti->frame = c_regs; | ||
222 | p->thread.a3 = (unsigned long) c_regs; | ||
223 | p->thread.sp = c_ksp; | ||
224 | p->thread.wchan = p->thread.pc; | ||
225 | p->thread.usp = c_usp; | ||
226 | |||
227 | if (unlikely(!kregs)) { | ||
228 | memset(c_regs, 0, sizeof(struct pt_regs)); | ||
229 | c_regs->a0 = c_usp; /* function */ | ||
230 | c_regs->d0 = ustk_size; /* argument */ | ||
231 | local_save_flags(c_regs->epsw); | ||
232 | c_regs->epsw |= EPSW_IE | EPSW_IM_7; | ||
233 | p->thread.pc = (unsigned long) ret_from_kernel_thread; | ||
234 | return 0; | ||
235 | } | ||
237 | *c_regs = *kregs; | 236 | *c_regs = *kregs; |
238 | c_regs->sp = c_usp; | 237 | c_regs->sp = c_usp; |
239 | c_regs->epsw &= ~EPSW_FE; /* my FPU */ | 238 | c_regs->epsw &= ~EPSW_FE; /* my FPU */ |
240 | 239 | ||
241 | c_ksp -= 12; /* allocate function call ABI slack */ | ||
242 | |||
243 | /* the new TLS pointer is passed in as arg #5 to sys_clone() */ | 240 | /* the new TLS pointer is passed in as arg #5 to sys_clone() */ |
244 | if (clone_flags & CLONE_SETTLS) | 241 | if (clone_flags & CLONE_SETTLS) |
245 | c_regs->e2 = current_frame()->d3; | 242 | c_regs->e2 = current_frame()->d3; |
246 | 243 | ||
247 | if (unlikely(!user_mode(kregs))) | 244 | p->thread.pc = (unsigned long) ret_from_fork; |
248 | p->thread.pc = (unsigned long) ret_from_kernel_thread; | ||
249 | else | ||
250 | p->thread.pc = (unsigned long) ret_from_fork; | ||
251 | |||
252 | /* set up things up so the scheduler can start the new task */ | ||
253 | ti->frame = c_regs; | ||
254 | p->thread.a3 = (unsigned long) c_regs; | ||
255 | p->thread.sp = c_ksp; | ||
256 | p->thread.wchan = p->thread.pc; | ||
257 | p->thread.usp = c_usp; | ||
258 | 245 | ||
259 | return 0; | 246 | return 0; |
260 | } | 247 | } |