aboutsummaryrefslogtreecommitdiffstats
path: root/arch/h8300/kernel
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2012-10-10 13:17:31 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2012-10-14 19:37:40 -0400
commit557e1995a92d318206910d8b5c62075fe02b37e0 (patch)
tree8373bada8e8f5306eed59487827265305fa0f1be /arch/h8300/kernel
parentddffeb8c4d0331609ef2581d84de4d763607bd37 (diff)
h8300: generic kernel_thread()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/h8300/kernel')
-rw-r--r--arch/h8300/kernel/entry.S10
-rw-r--r--arch/h8300/kernel/h8300_ksyms.c1
-rw-r--r--arch/h8300/kernel/process.c41
3 files changed, 18 insertions, 34 deletions
diff --git a/arch/h8300/kernel/entry.S b/arch/h8300/kernel/entry.S
index ca7431690300..2cdb49a56099 100644
--- a/arch/h8300/kernel/entry.S
+++ b/arch/h8300/kernel/entry.S
@@ -158,6 +158,7 @@ INTERRUPTS = 128
158.globl SYMBOL_NAME(system_call) 158.globl SYMBOL_NAME(system_call)
159.globl SYMBOL_NAME(ret_from_exception) 159.globl SYMBOL_NAME(ret_from_exception)
160.globl SYMBOL_NAME(ret_from_fork) 160.globl SYMBOL_NAME(ret_from_fork)
161.globl SYMBOL_NAME(ret_from_kernel_thread)
161.globl SYMBOL_NAME(ret_from_interrupt) 162.globl SYMBOL_NAME(ret_from_interrupt)
162.globl SYMBOL_NAME(interrupt_redirect_table) 163.globl SYMBOL_NAME(interrupt_redirect_table)
163.globl SYMBOL_NAME(sw_ksp),SYMBOL_NAME(sw_usp) 164.globl SYMBOL_NAME(sw_ksp),SYMBOL_NAME(sw_usp)
@@ -330,6 +331,15 @@ SYMBOL_NAME_LABEL(ret_from_fork)
330 jsr @SYMBOL_NAME(schedule_tail) 331 jsr @SYMBOL_NAME(schedule_tail)
331 jmp @SYMBOL_NAME(ret_from_exception) 332 jmp @SYMBOL_NAME(ret_from_exception)
332 333
334SYMBOL_NAME_LABEL(ret_from_kernel_thread)
335 mov.l er2,er0
336 jsr @SYMBOL_NAME(schedule_tail)
337 mov.l @(LER4:16,sp),er0
338 mov.l @(LER5:16,sp),er1
339 jsr @er1
340 sub.l @er0,@er0
341 jsr @SYMBOL_NAME(sys_exit)
342
333SYMBOL_NAME_LABEL(resume) 343SYMBOL_NAME_LABEL(resume)
334 /* 344 /*
335 * Beware - when entering resume, offset of tss is in d1, 345 * Beware - when entering resume, offset of tss is in d1,
diff --git a/arch/h8300/kernel/h8300_ksyms.c b/arch/h8300/kernel/h8300_ksyms.c
index 6866bd9c7fb4..53d7c0e4bd83 100644
--- a/arch/h8300/kernel/h8300_ksyms.c
+++ b/arch/h8300/kernel/h8300_ksyms.c
@@ -33,7 +33,6 @@ EXPORT_SYMBOL(strncmp);
33 33
34EXPORT_SYMBOL(ip_fast_csum); 34EXPORT_SYMBOL(ip_fast_csum);
35 35
36EXPORT_SYMBOL(kernel_thread);
37EXPORT_SYMBOL(enable_irq); 36EXPORT_SYMBOL(enable_irq);
38EXPORT_SYMBOL(disable_irq); 37EXPORT_SYMBOL(disable_irq);
39 38
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;
47EXPORT_SYMBOL(pm_power_off); 47EXPORT_SYMBOL(pm_power_off);
48 48
49asmlinkage void ret_from_fork(void); 49asmlinkage void ret_from_fork(void);
50asmlinkage 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 */
128int 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
158void flush_thread(void) 126void 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;