diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-10-10 13:17:31 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-10-14 19:37:40 -0400 |
commit | 557e1995a92d318206910d8b5c62075fe02b37e0 (patch) | |
tree | 8373bada8e8f5306eed59487827265305fa0f1be /arch/h8300/kernel/process.c | |
parent | ddffeb8c4d0331609ef2581d84de4d763607bd37 (diff) |
h8300: generic kernel_thread()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/h8300/kernel/process.c')
-rw-r--r-- | arch/h8300/kernel/process.c | 41 |
1 files changed, 8 insertions, 33 deletions
diff --git a/arch/h8300/kernel/process.c b/arch/h8300/kernel/process.c index e8dc1393a13a..e3dfea71c15f 100644 --- a/arch/h8300/kernel/process.c +++ b/arch/h8300/kernel/process.c | |||
@@ -47,6 +47,7 @@ void (*pm_power_off)(void) = NULL; | |||
47 | EXPORT_SYMBOL(pm_power_off); | 47 | EXPORT_SYMBOL(pm_power_off); |
48 | 48 | ||
49 | asmlinkage void ret_from_fork(void); | 49 | asmlinkage void ret_from_fork(void); |
50 | asmlinkage void ret_from_kernel_thread(void); | ||
50 | 51 | ||
51 | /* | 52 | /* |
52 | * The idle loop on an H8/300.. | 53 | * The idle loop on an H8/300.. |
@@ -122,39 +123,6 @@ void show_regs(struct pt_regs * regs) | |||
122 | printk("\n"); | 123 | printk("\n"); |
123 | } | 124 | } |
124 | 125 | ||
125 | /* | ||
126 | * Create a kernel thread | ||
127 | */ | ||
128 | int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags) | ||
129 | { | ||
130 | long retval; | ||
131 | long clone_arg; | ||
132 | mm_segment_t fs; | ||
133 | |||
134 | fs = get_fs(); | ||
135 | set_fs (KERNEL_DS); | ||
136 | clone_arg = flags | CLONE_VM; | ||
137 | __asm__("mov.l sp,er3\n\t" | ||
138 | "sub.l er2,er2\n\t" | ||
139 | "mov.l %2,er1\n\t" | ||
140 | "mov.l %1,er0\n\t" | ||
141 | "trapa #0\n\t" | ||
142 | "cmp.l sp,er3\n\t" | ||
143 | "beq 1f\n\t" | ||
144 | "mov.l %4,er0\n\t" | ||
145 | "mov.l %3,er1\n\t" | ||
146 | "jsr @er1\n\t" | ||
147 | "mov.l %5,er0\n\t" | ||
148 | "trapa #0\n" | ||
149 | "1:\n\t" | ||
150 | "mov.l er0,%0" | ||
151 | :"=r"(retval) | ||
152 | :"i"(__NR_clone),"g"(clone_arg),"g"(fn),"g"(arg),"i"(__NR_exit) | ||
153 | :"er0","er1","er2","er3"); | ||
154 | set_fs (fs); | ||
155 | return retval; | ||
156 | } | ||
157 | |||
158 | void flush_thread(void) | 126 | void flush_thread(void) |
159 | { | 127 | { |
160 | } | 128 | } |
@@ -198,6 +166,13 @@ int copy_thread(unsigned long clone_flags, | |||
198 | 166 | ||
199 | childregs = (struct pt_regs *) (THREAD_SIZE + task_stack_page(p)) - 1; | 167 | childregs = (struct pt_regs *) (THREAD_SIZE + task_stack_page(p)) - 1; |
200 | 168 | ||
169 | if (unlikely(p->flags & PF_KTHREAD)) { | ||
170 | memset(childregs, 0, sizeof(struct pt_regs)); | ||
171 | childregs->retpc = (unsigned long) ret_from_kernel_thread; | ||
172 | childregs->er4 = topstk; /* arg */ | ||
173 | childregs->er5 = usp; /* fn */ | ||
174 | p->thread.ksp = (unsigned long)childregs; | ||
175 | } | ||
201 | *childregs = *regs; | 176 | *childregs = *regs; |
202 | childregs->retpc = (unsigned long) ret_from_fork; | 177 | childregs->retpc = (unsigned long) ret_from_fork; |
203 | childregs->er0 = 0; | 178 | childregs->er0 = 0; |