aboutsummaryrefslogtreecommitdiffstats
path: root/arch/c6x
diff options
context:
space:
mode:
Diffstat (limited to 'arch/c6x')
-rw-r--r--arch/c6x/Kconfig1
-rw-r--r--arch/c6x/include/asm/processor.h2
-rw-r--r--arch/c6x/include/asm/syscalls.h5
-rw-r--r--arch/c6x/include/asm/thread_info.h1
-rw-r--r--arch/c6x/include/asm/unistd.h3
-rw-r--r--arch/c6x/kernel/asm-offsets.c1
-rw-r--r--arch/c6x/kernel/entry.S56
-rw-r--r--arch/c6x/kernel/process.c72
8 files changed, 41 insertions, 100 deletions
diff --git a/arch/c6x/Kconfig b/arch/c6x/Kconfig
index 983c859e40b7..45268b50c0c8 100644
--- a/arch/c6x/Kconfig
+++ b/arch/c6x/Kconfig
@@ -17,6 +17,7 @@ config C6X
17 select OF 17 select OF
18 select OF_EARLY_FLATTREE 18 select OF_EARLY_FLATTREE
19 select GENERIC_CLOCKEVENTS 19 select GENERIC_CLOCKEVENTS
20 select GENERIC_KERNEL_THREAD
20 21
21config MMU 22config MMU
22 def_bool n 23 def_bool n
diff --git a/arch/c6x/include/asm/processor.h b/arch/c6x/include/asm/processor.h
index c50af7ef1c96..b9eb3da7f278 100644
--- a/arch/c6x/include/asm/processor.h
+++ b/arch/c6x/include/asm/processor.h
@@ -92,8 +92,6 @@ static inline void release_thread(struct task_struct *dead_task)
92{ 92{
93} 93}
94 94
95extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
96
97#define copy_segments(tsk, mm) do { } while (0) 95#define copy_segments(tsk, mm) do { } while (0)
98#define release_segments(mm) do { } while (0) 96#define release_segments(mm) do { } while (0)
99 97
diff --git a/arch/c6x/include/asm/syscalls.h b/arch/c6x/include/asm/syscalls.h
index aed53da703c9..e7b8991dc07c 100644
--- a/arch/c6x/include/asm/syscalls.h
+++ b/arch/c6x/include/asm/syscalls.h
@@ -44,11 +44,6 @@ extern int sys_cache_sync(unsigned long s, unsigned long e);
44struct pt_regs; 44struct pt_regs;
45 45
46extern asmlinkage long sys_c6x_clone(struct pt_regs *regs); 46extern asmlinkage long sys_c6x_clone(struct pt_regs *regs);
47extern asmlinkage long sys_c6x_execve(const char __user *name,
48 const char __user *const __user *argv,
49 const char __user *const __user *envp,
50 struct pt_regs *regs);
51
52 47
53#include <asm-generic/syscalls.h> 48#include <asm-generic/syscalls.h>
54 49
diff --git a/arch/c6x/include/asm/thread_info.h b/arch/c6x/include/asm/thread_info.h
index 1710bcbb8d09..4c8dc562bd90 100644
--- a/arch/c6x/include/asm/thread_info.h
+++ b/arch/c6x/include/asm/thread_info.h
@@ -97,7 +97,6 @@ struct thread_info *current_thread_info(void)
97#define TIF_NEED_RESCHED 3 /* rescheduling necessary */ 97#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
98#define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */ 98#define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */
99 99
100#define TIF_POLLING_NRFLAG 16 /* true if polling TIF_NEED_RESCHED */
101#define TIF_MEMDIE 17 /* OOM killer killed process */ 100#define TIF_MEMDIE 17 /* OOM killer killed process */
102 101
103#define TIF_WORK_MASK 0x00007FFE /* work on irq/exception return */ 102#define TIF_WORK_MASK 0x00007FFE /* work on irq/exception return */
diff --git a/arch/c6x/include/asm/unistd.h b/arch/c6x/include/asm/unistd.h
index ed2259043eec..4ff747d12dad 100644
--- a/arch/c6x/include/asm/unistd.h
+++ b/arch/c6x/include/asm/unistd.h
@@ -14,6 +14,9 @@
14 * more details. 14 * more details.
15 */ 15 */
16 16
17#define __ARCH_WANT_KERNEL_EXECVE
18#define __ARCH_WANT_SYS_EXECVE
19
17/* Use the standard ABI for syscalls. */ 20/* Use the standard ABI for syscalls. */
18#include <asm-generic/unistd.h> 21#include <asm-generic/unistd.h>
19 22
diff --git a/arch/c6x/kernel/asm-offsets.c b/arch/c6x/kernel/asm-offsets.c
index 759ad6d207b6..60f1e437745d 100644
--- a/arch/c6x/kernel/asm-offsets.c
+++ b/arch/c6x/kernel/asm-offsets.c
@@ -116,7 +116,6 @@ void foo(void)
116 DEFINE(_TIF_NOTIFY_RESUME, (1<<TIF_NOTIFY_RESUME)); 116 DEFINE(_TIF_NOTIFY_RESUME, (1<<TIF_NOTIFY_RESUME));
117 DEFINE(_TIF_SIGPENDING, (1<<TIF_SIGPENDING)); 117 DEFINE(_TIF_SIGPENDING, (1<<TIF_SIGPENDING));
118 DEFINE(_TIF_NEED_RESCHED, (1<<TIF_NEED_RESCHED)); 118 DEFINE(_TIF_NEED_RESCHED, (1<<TIF_NEED_RESCHED));
119 DEFINE(_TIF_POLLING_NRFLAG, (1<<TIF_POLLING_NRFLAG));
120 119
121 DEFINE(_TIF_ALLWORK_MASK, TIF_ALLWORK_MASK); 120 DEFINE(_TIF_ALLWORK_MASK, TIF_ALLWORK_MASK);
122 DEFINE(_TIF_WORK_MASK, TIF_WORK_MASK); 121 DEFINE(_TIF_WORK_MASK, TIF_WORK_MASK);
diff --git a/arch/c6x/kernel/entry.S b/arch/c6x/kernel/entry.S
index 30b37e5f4a61..5449c36018fe 100644
--- a/arch/c6x/kernel/entry.S
+++ b/arch/c6x/kernel/entry.S
@@ -400,6 +400,32 @@ ret_from_fork_2:
400 STW .D2T2 B0,*+SP(REGS_A4+8) 400 STW .D2T2 B0,*+SP(REGS_A4+8)
401ENDPROC(ret_from_fork) 401ENDPROC(ret_from_fork)
402 402
403ENTRY(ret_from_kernel_thread)
404#ifdef CONFIG_C6X_BIG_KERNEL
405 MVKL .S1 schedule_tail,A0
406 MVKH .S1 schedule_tail,A0
407 B .S2X A0
408#else
409 B .S2 schedule_tail
410#endif
411 LDW .D2T2 *+SP(REGS_A0+8),B10 /* get fn */
412 ADDKPC .S2 0f,B3,3
4130:
414 B .S2 B10 /* call fn */
415 LDW .D2T1 *+SP(REGS_A1+8),A4 /* get arg */
416 MVKL .S2 sys_exit,B11
417 MVKH .S2 sys_exit,B11
418 ADDKPC .S2 0f,B3,1
4190:
420 BNOP .S2 B11,5 /* jump to sys_exit */
421ENDPROC(ret_from_kernel_thread)
422
423ENTRY(ret_from_kernel_execve)
424 GET_THREAD_INFO A12
425 BNOP .S2 syscall_exit,4
426 ADD .D2X A4,-8,SP
427ENDPROC(ret_from_kernel_execve)
428
403 ;; 429 ;;
404 ;; These are the interrupt handlers, responsible for calling __do_IRQ() 430 ;; These are the interrupt handlers, responsible for calling __do_IRQ()
405 ;; int6 is used for syscalls (see _system_call entry) 431 ;; int6 is used for syscalls (see _system_call entry)
@@ -593,13 +619,6 @@ ENTRY(sys_sigaltstack)
593 NOP 4 619 NOP 4
594ENDPROC(sys_sigaltstack) 620ENDPROC(sys_sigaltstack)
595 621
596 ;; kernel_execve
597ENTRY(kernel_execve)
598 MVK .S2 __NR_execve,B0
599 SWE
600 BNOP .S2 B3,5
601ENDPROC(kernel_execve)
602
603 ;; 622 ;;
604 ;; Special system calls 623 ;; Special system calls
605 ;; return address is in B3 624 ;; return address is in B3
@@ -628,29 +647,6 @@ ENTRY(sys_rt_sigreturn)
628#endif 647#endif
629ENDPROC(sys_rt_sigreturn) 648ENDPROC(sys_rt_sigreturn)
630 649
631ENTRY(sys_execve)
632 ADDAW .D2 SP,2,B6 ; put regs addr in 4th parameter
633 ; & adjust regs stack addr
634 LDW .D2T2 *+SP(REGS_B4+8),B4
635
636 ;; c6x_execve(char *name, char **argv,
637 ;; char **envp, struct pt_regs *regs)
638#ifdef CONFIG_C6X_BIG_KERNEL
639 || MVKL .S1 sys_c6x_execve,A0
640 MVKH .S1 sys_c6x_execve,A0
641 B .S2X A0
642#else
643 || B .S2 sys_c6x_execve
644#endif
645 STW .D2T2 B3,*SP--[2]
646 ADDKPC .S2 ret_from_c6x_execve,B3,3
647
648ret_from_c6x_execve:
649 LDW .D2T2 *++SP[2],B3
650 NOP 4
651 BNOP .S2 B3,5
652ENDPROC(sys_execve)
653
654ENTRY(sys_pread_c6x) 650ENTRY(sys_pread_c6x)
655 MV .D2X A8,B7 651 MV .D2X A8,B7
656#ifdef CONFIG_C6X_BIG_KERNEL 652#ifdef CONFIG_C6X_BIG_KERNEL
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);
25void (*c6x_halt)(void); 25void (*c6x_halt)(void);
26 26
27extern asmlinkage void ret_from_fork(void); 27extern asmlinkage void ret_from_fork(void);
28extern 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
106static 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 */
114int 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(&regs, 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, &regs,
133 0, NULL, NULL);
134}
135EXPORT_SYMBOL(kernel_thread);
136
137void flush_thread(void) 107void 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 */
227SYSCALL_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);
242out:
243 return error;
244}
245
246unsigned long get_wchan(struct task_struct *p) 196unsigned long get_wchan(struct task_struct *p)
247{ 197{
248 return p->thread.wchan; 198 return p->thread.wchan;