diff options
Diffstat (limited to 'arch/c6x/kernel/process.c')
| -rw-r--r-- | arch/c6x/kernel/process.c | 72 |
1 files changed, 11 insertions, 61 deletions
diff --git a/arch/c6x/kernel/process.c b/arch/c6x/kernel/process.c index 45e924a636a0..2770d9a9a84e 100644 --- a/arch/c6x/kernel/process.c +++ b/arch/c6x/kernel/process.c | |||
| @@ -25,6 +25,7 @@ void (*c6x_restart)(void); | |||
| 25 | void (*c6x_halt)(void); | 25 | void (*c6x_halt)(void); |
| 26 | 26 | ||
| 27 | extern asmlinkage void ret_from_fork(void); | 27 | extern asmlinkage void ret_from_fork(void); |
| 28 | extern asmlinkage void ret_from_kernel_thread(void); | ||
| 28 | 29 | ||
| 29 | /* | 30 | /* |
| 30 | * power off function, if any | 31 | * power off function, if any |
| @@ -103,37 +104,6 @@ void machine_power_off(void) | |||
| 103 | halt_loop(); | 104 | halt_loop(); |
| 104 | } | 105 | } |
| 105 | 106 | ||
| 106 | static void kernel_thread_helper(int dummy, void *arg, int (*fn)(void *)) | ||
| 107 | { | ||
| 108 | do_exit(fn(arg)); | ||
| 109 | } | ||
| 110 | |||
| 111 | /* | ||
| 112 | * Create a kernel thread | ||
| 113 | */ | ||
| 114 | int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) | ||
| 115 | { | ||
| 116 | struct pt_regs regs; | ||
| 117 | |||
| 118 | /* | ||
| 119 | * copy_thread sets a4 to zero (child return from fork) | ||
| 120 | * so we can't just set things up to directly return to | ||
| 121 | * fn. | ||
| 122 | */ | ||
| 123 | memset(®s, 0, sizeof(regs)); | ||
| 124 | regs.b4 = (unsigned long) arg; | ||
| 125 | regs.a6 = (unsigned long) fn; | ||
| 126 | regs.pc = (unsigned long) kernel_thread_helper; | ||
| 127 | local_save_flags(regs.csr); | ||
| 128 | regs.csr |= 1; | ||
| 129 | regs.tsr = 5; /* Set GEE and GIE in TSR */ | ||
| 130 | |||
| 131 | /* Ok, create the new process.. */ | ||
| 132 | return do_fork(flags | CLONE_VM | CLONE_UNTRACED, -1, ®s, | ||
| 133 | 0, NULL, NULL); | ||
| 134 | } | ||
| 135 | EXPORT_SYMBOL(kernel_thread); | ||
| 136 | |||
| 137 | void flush_thread(void) | 107 | void flush_thread(void) |
| 138 | { | 108 | { |
| 139 | } | 109 | } |
| @@ -191,22 +161,24 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, | |||
| 191 | 161 | ||
| 192 | childregs = task_pt_regs(p); | 162 | childregs = task_pt_regs(p); |
| 193 | 163 | ||
| 194 | *childregs = *regs; | 164 | if (!regs) { |
| 195 | childregs->a4 = 0; | ||
| 196 | |||
| 197 | if (usp == -1) | ||
| 198 | /* case of __kernel_thread: we return to supervisor space */ | 165 | /* case of __kernel_thread: we return to supervisor space */ |
| 166 | memset(childregs, 0, sizeof(struct pt_regs)); | ||
| 199 | childregs->sp = (unsigned long)(childregs + 1); | 167 | childregs->sp = (unsigned long)(childregs + 1); |
| 200 | else | 168 | p->thread.pc = (unsigned long) ret_from_kernel_thread; |
| 169 | childregs->a0 = usp; /* function */ | ||
| 170 | childregs->a1 = ustk_size; /* argument */ | ||
| 171 | } else { | ||
| 201 | /* Otherwise use the given stack */ | 172 | /* Otherwise use the given stack */ |
| 173 | *childregs = *regs; | ||
| 202 | childregs->sp = usp; | 174 | childregs->sp = usp; |
| 175 | p->thread.pc = (unsigned long) ret_from_fork; | ||
| 176 | } | ||
| 203 | 177 | ||
| 204 | /* Set usp/ksp */ | 178 | /* Set usp/ksp */ |
| 205 | p->thread.usp = childregs->sp; | 179 | p->thread.usp = childregs->sp; |
| 206 | /* switch_to uses stack to save/restore 14 callee-saved regs */ | ||
| 207 | thread_saved_ksp(p) = (unsigned long)childregs - 8; | 180 | thread_saved_ksp(p) = (unsigned long)childregs - 8; |
| 208 | p->thread.pc = (unsigned int) ret_from_fork; | 181 | p->thread.wchan = p->thread.pc; |
| 209 | p->thread.wchan = (unsigned long) ret_from_fork; | ||
| 210 | #ifdef __DSBT__ | 182 | #ifdef __DSBT__ |
| 211 | { | 183 | { |
| 212 | unsigned long dp; | 184 | unsigned long dp; |
| @@ -221,28 +193,6 @@ int copy_thread(unsigned long clone_flags, unsigned long usp, | |||
| 221 | return 0; | 193 | return 0; |
| 222 | } | 194 | } |
| 223 | 195 | ||
| 224 | /* | ||
| 225 | * c6x_execve() executes a new program. | ||
| 226 | */ | ||
| 227 | SYSCALL_DEFINE4(c6x_execve, const char __user *, name, | ||
| 228 | const char __user *const __user *, argv, | ||
| 229 | const char __user *const __user *, envp, | ||
| 230 | struct pt_regs *, regs) | ||
| 231 | { | ||
| 232 | int error; | ||
| 233 | char *filename; | ||
| 234 | |||
| 235 | filename = getname(name); | ||
| 236 | error = PTR_ERR(filename); | ||
| 237 | if (IS_ERR(filename)) | ||
| 238 | goto out; | ||
| 239 | |||
| 240 | error = do_execve(filename, argv, envp, regs); | ||
| 241 | putname(filename); | ||
| 242 | out: | ||
| 243 | return error; | ||
| 244 | } | ||
| 245 | |||
| 246 | unsigned long get_wchan(struct task_struct *p) | 196 | unsigned long get_wchan(struct task_struct *p) |
| 247 | { | 197 | { |
| 248 | return p->thread.wchan; | 198 | return p->thread.wchan; |
