* set up the kernel stack and exception frames for a new process
*/
int copy_thread(unsigned long clone_flags,
- unsigned long usp, unsigned long topstk,
+ unsigned long usp, unsigned long arg,
struct task_struct *p, struct pt_regs *regs)
{
struct pt_regs *childregs;
childregs = (struct pt_regs *)
(task_stack_page(p) + THREAD_SIZE - FRV_FRAME0_SIZE);
- /* set up the userspace frame (the only place that the USP is stored) */
- *childregs = *regs;
-
- childregs->sp = usp;
- childregs->next_frame = NULL;
-
- if (unlikely(!user_mode(regs)))
- p->thread.pc = (unsigned long) ret_from_kernel_thread;
- else
- p->thread.pc = (unsigned long) ret_from_fork;
-
p->set_child_tid = p->clear_child_tid = NULL;
p->thread.frame = childregs;
p->thread.lr = 0;
p->thread.frame0 = childregs;
+ if (unlikely(!regs)) {
+ memset(childregs, 0, sizeof(struct pt_regs));
+ childregs->gr9 = usp; /* function */
+ childregs->gr8 = arg;
+ chilregs->psr = PSR_S;
+ p->thread.pc = (unsigned long) ret_from_kernel_thread;
+ save_user_regs(p->thread.user);
+ return 0;
+ }
+
+ /* set up the userspace frame (the only place that the USP is stored) */
+ *childregs = *regs;
+
+ childregs->sp = usp;
+ childregs->next_frame = NULL;
+
+ p->thread.pc = (unsigned long) ret_from_fork;
+
/* the new TLS pointer is passed in as arg #5 to sys_clone() */
if (clone_flags & CLONE_SETTLS)
childregs->gr29 = childregs->gr12;
sizeof(current->thread.user->f));
return 1;
}
-
-int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
-{
- struct pt_regs regs = {
- .gr8 = (unsigned long)arg;
- .gr9 = (unsigned long)fn;
- .psr = PSR_S;
- };
- return do_fork(flags|CLONE_VM|CLONE_UNTRACED, 0, ®s, 0, NULL, NULL);
-}