aboutsummaryrefslogtreecommitdiffstats
path: root/arch/microblaze/kernel/process.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/microblaze/kernel/process.c')
-rw-r--r--arch/microblaze/kernel/process.c72
1 files changed, 21 insertions, 51 deletions
diff --git a/arch/microblaze/kernel/process.c b/arch/microblaze/kernel/process.c
index 1944e00f07e1..29768c3dc358 100644
--- a/arch/microblaze/kernel/process.c
+++ b/arch/microblaze/kernel/process.c
@@ -119,46 +119,38 @@ void flush_thread(void)
119} 119}
120 120
121int copy_thread(unsigned long clone_flags, unsigned long usp, 121int copy_thread(unsigned long clone_flags, unsigned long usp,
122 unsigned long unused, 122 unsigned long arg,
123 struct task_struct *p, struct pt_regs *regs) 123 struct task_struct *p, struct pt_regs *regs)
124{ 124{
125 struct pt_regs *childregs = task_pt_regs(p); 125 struct pt_regs *childregs = task_pt_regs(p);
126 struct thread_info *ti = task_thread_info(p); 126 struct thread_info *ti = task_thread_info(p);
127 127
128 if (unlikely(p->flags & PF_KTHREAD)) {
129 /* if we're creating a new kernel thread then just zeroing all
130 * the registers. That's OK for a brand new thread.*/
131 memset(childregs, 0, sizeof(struct pt_regs));
132 memset(&ti->cpu_context, 0, sizeof(struct cpu_context));
133 ti->cpu_context.r1 = (unsigned long)childregs;
134 ti->cpu_context.r20 = (unsigned long)usp; /* fn */
135 ti->cpu_context.r19 = (unsigned long)arg;
136 childregs->pt_mode = 1;
137 local_save_flags(childregs->msr);
138#ifdef CONFIG_MMU
139 ti->cpu_context.msr = childregs->msr & ~MSR_IE;
140#endif
141 ti->cpu_context.r15 = (unsigned long)ret_from_kernel_thread - 8;
142 return 0;
143 }
128 *childregs = *regs; 144 *childregs = *regs;
129 if (user_mode(regs)) 145 childregs->r1 = usp;
130 childregs->r1 = usp;
131 else
132 childregs->r1 = ((unsigned long) ti) + THREAD_SIZE;
133 146
134#ifndef CONFIG_MMU
135 memset(&ti->cpu_context, 0, sizeof(struct cpu_context)); 147 memset(&ti->cpu_context, 0, sizeof(struct cpu_context));
136 ti->cpu_context.r1 = (unsigned long)childregs; 148 ti->cpu_context.r1 = (unsigned long)childregs;
149#ifndef CONFIG_MMU
137 ti->cpu_context.msr = (unsigned long)childregs->msr; 150 ti->cpu_context.msr = (unsigned long)childregs->msr;
138#else 151#else
152 childregs->msr |= MSR_UMS;
139 153
140 /* if creating a kernel thread then update the current reg (we don't
141 * want to use the parent's value when restoring by POP_STATE) */
142 if (kernel_mode(regs))
143 /* save new current on stack to use POP_STATE */
144 childregs->CURRENT_TASK = (unsigned long)p;
145 /* if returning to user then use the parent's value of this register */
146
147 /* if we're creating a new kernel thread then just zeroing all
148 * the registers. That's OK for a brand new thread.*/
149 /* Pls. note that some of them will be restored in POP_STATE */
150 if (kernel_mode(regs))
151 memset(&ti->cpu_context, 0, sizeof(struct cpu_context));
152 /* if this thread is created for fork/vfork/clone, then we want to
153 * restore all the parent's context */
154 /* in addition to the registers which will be restored by POP_STATE */
155 else {
156 ti->cpu_context = *(struct cpu_context *)regs;
157 childregs->msr |= MSR_UMS;
158 }
159
160 /* FIXME STATE_SAVE_PT_OFFSET; */
161 ti->cpu_context.r1 = (unsigned long)childregs;
162 /* we should consider the fact that childregs is a copy of the parent 154 /* we should consider the fact that childregs is a copy of the parent
163 * regs which were saved immediately after entering the kernel state 155 * regs which were saved immediately after entering the kernel state
164 * before enabling VM. This MSR will be restored in switch_to and 156 * before enabling VM. This MSR will be restored in switch_to and
@@ -209,29 +201,6 @@ unsigned long thread_saved_pc(struct task_struct *tsk)
209} 201}
210#endif 202#endif
211 203
212static void kernel_thread_helper(int (*fn)(void *), void *arg)
213{
214 fn(arg);
215 do_exit(-1);
216}
217
218int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags)
219{
220 struct pt_regs regs;
221
222 memset(&regs, 0, sizeof(regs));
223 /* store them in non-volatile registers */
224 regs.r5 = (unsigned long)fn;
225 regs.r6 = (unsigned long)arg;
226 local_save_flags(regs.msr);
227 regs.pc = (unsigned long)kernel_thread_helper;
228 regs.pt_mode = 1;
229
230 return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0,
231 &regs, 0, NULL, NULL);
232}
233EXPORT_SYMBOL_GPL(kernel_thread);
234
235unsigned long get_wchan(struct task_struct *p) 204unsigned long get_wchan(struct task_struct *p)
236{ 205{
237/* TBD (used by procfs) */ 206/* TBD (used by procfs) */
@@ -246,6 +215,7 @@ void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long usp)
246 regs->pt_mode = 0; 215 regs->pt_mode = 0;
247#ifdef CONFIG_MMU 216#ifdef CONFIG_MMU
248 regs->msr |= MSR_UMS; 217 regs->msr |= MSR_UMS;
218 regs->msr &= ~MSR_VM;
249#endif 219#endif
250} 220}
251 221