diff options
Diffstat (limited to 'arch/microblaze/kernel/process.c')
-rw-r--r-- | arch/microblaze/kernel/process.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/arch/microblaze/kernel/process.c b/arch/microblaze/kernel/process.c index 07d4fa339eda..00b12c6d5326 100644 --- a/arch/microblaze/kernel/process.c +++ b/arch/microblaze/kernel/process.c | |||
@@ -126,9 +126,54 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, | |||
126 | else | 126 | else |
127 | childregs->r1 = ((unsigned long) ti) + THREAD_SIZE; | 127 | childregs->r1 = ((unsigned long) ti) + THREAD_SIZE; |
128 | 128 | ||
129 | #ifndef CONFIG_MMU | ||
129 | memset(&ti->cpu_context, 0, sizeof(struct cpu_context)); | 130 | memset(&ti->cpu_context, 0, sizeof(struct cpu_context)); |
130 | ti->cpu_context.r1 = (unsigned long)childregs; | 131 | ti->cpu_context.r1 = (unsigned long)childregs; |
131 | ti->cpu_context.msr = (unsigned long)childregs->msr; | 132 | ti->cpu_context.msr = (unsigned long)childregs->msr; |
133 | #else | ||
134 | |||
135 | /* if creating a kernel thread then update the current reg (we don't | ||
136 | * want to use the parent's value when restoring by POP_STATE) */ | ||
137 | if (kernel_mode(regs)) | ||
138 | /* save new current on stack to use POP_STATE */ | ||
139 | childregs->CURRENT_TASK = (unsigned long)p; | ||
140 | /* if returning to user then use the parent's value of this register */ | ||
141 | |||
142 | /* if we're creating a new kernel thread then just zeroing all | ||
143 | * the registers. That's OK for a brand new thread.*/ | ||
144 | /* Pls. note that some of them will be restored in POP_STATE */ | ||
145 | if (kernel_mode(regs)) | ||
146 | memset(&ti->cpu_context, 0, sizeof(struct cpu_context)); | ||
147 | /* if this thread is created for fork/vfork/clone, then we want to | ||
148 | * restore all the parent's context */ | ||
149 | /* in addition to the registers which will be restored by POP_STATE */ | ||
150 | else { | ||
151 | ti->cpu_context = *(struct cpu_context *)regs; | ||
152 | childregs->msr |= MSR_UMS; | ||
153 | } | ||
154 | |||
155 | /* FIXME STATE_SAVE_PT_OFFSET; */ | ||
156 | ti->cpu_context.r1 = (unsigned long)childregs - STATE_SAVE_ARG_SPACE; | ||
157 | /* we should consider the fact that childregs is a copy of the parent | ||
158 | * regs which were saved immediately after entering the kernel state | ||
159 | * before enabling VM. This MSR will be restored in switch_to and | ||
160 | * RETURN() and we want to have the right machine state there | ||
161 | * specifically this state must have INTs disabled before and enabled | ||
162 | * after performing rtbd | ||
163 | * compose the right MSR for RETURN(). It will work for switch_to also | ||
164 | * excepting for VM and UMS | ||
165 | * don't touch UMS , CARRY and cache bits | ||
166 | * right now MSR is a copy of parent one */ | ||
167 | childregs->msr |= MSR_BIP; | ||
168 | childregs->msr &= ~MSR_EIP; | ||
169 | childregs->msr |= MSR_IE; | ||
170 | childregs->msr &= ~MSR_VM; | ||
171 | childregs->msr |= MSR_VMS; | ||
172 | childregs->msr |= MSR_EE; /* exceptions will be enabled*/ | ||
173 | |||
174 | ti->cpu_context.msr = (childregs->msr|MSR_VM); | ||
175 | ti->cpu_context.msr &= ~MSR_UMS; /* switch_to to kernel mode */ | ||
176 | #endif | ||
132 | ti->cpu_context.r15 = (unsigned long)ret_from_fork - 8; | 177 | ti->cpu_context.r15 = (unsigned long)ret_from_fork - 8; |
133 | 178 | ||
134 | if (clone_flags & CLONE_SETTLS) | 179 | if (clone_flags & CLONE_SETTLS) |
@@ -137,6 +182,7 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, | |||
137 | return 0; | 182 | return 0; |
138 | } | 183 | } |
139 | 184 | ||
185 | #ifndef CONFIG_MMU | ||
140 | /* | 186 | /* |
141 | * Return saved PC of a blocked thread. | 187 | * Return saved PC of a blocked thread. |
142 | */ | 188 | */ |
@@ -151,6 +197,7 @@ unsigned long thread_saved_pc(struct task_struct *tsk) | |||
151 | else | 197 | else |
152 | return ctx->r14; | 198 | return ctx->r14; |
153 | } | 199 | } |
200 | #endif | ||
154 | 201 | ||
155 | static void kernel_thread_helper(int (*fn)(void *), void *arg) | 202 | static void kernel_thread_helper(int (*fn)(void *), void *arg) |
156 | { | 203 | { |
@@ -173,6 +220,7 @@ int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags) | |||
173 | return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, | 220 | return do_fork(flags | CLONE_VM | CLONE_UNTRACED, 0, |
174 | ®s, 0, NULL, NULL); | 221 | ®s, 0, NULL, NULL); |
175 | } | 222 | } |
223 | EXPORT_SYMBOL_GPL(kernel_thread); | ||
176 | 224 | ||
177 | unsigned long get_wchan(struct task_struct *p) | 225 | unsigned long get_wchan(struct task_struct *p) |
178 | { | 226 | { |
@@ -188,3 +236,14 @@ void start_thread(struct pt_regs *regs, unsigned long pc, unsigned long usp) | |||
188 | regs->r1 = usp; | 236 | regs->r1 = usp; |
189 | regs->pt_mode = 0; | 237 | regs->pt_mode = 0; |
190 | } | 238 | } |
239 | |||
240 | #ifdef CONFIG_MMU | ||
241 | #include <linux/elfcore.h> | ||
242 | /* | ||
243 | * Set up a thread for executing a new program | ||
244 | */ | ||
245 | int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpregs) | ||
246 | { | ||
247 | return 0; /* MicroBlaze has no separate FPU registers */ | ||
248 | } | ||
249 | #endif /* CONFIG_MMU */ | ||