Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 333661
b: refs/heads/master
c: 46f1506
h: refs/heads/master
i:
  333659: 496939d
v: v3
  • Loading branch information
Mark Salter authored and Al Viro committed Oct 1, 2012
1 parent 3d9c8df commit 13c77d0
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 27 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 61b7fbc3f4ebdcfd34f9438adfab8df936a19e33
refs/heads/master: 46f15067c020a0ce712cb2d3ef38c0589a521c15
20 changes: 20 additions & 0 deletions trunk/arch/c6x/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,26 @@ ret_from_fork_2:
STW .D2T2 B0,*+SP(REGS_A4+8)
ENDPROC(ret_from_fork)

ENTRY(ret_from_kernel_thread)
#ifdef CONFIG_C6X_BIG_KERNEL
MVKL .S1 schedule_tail,A0
MVKH .S1 schedule_tail,A0
B .S2X A0
#else
B .S2 schedule_tail
#endif
LDW .D2T2 *+SP(REGS_A0+8),B10 /* get fn */
ADDKPC .S2 0f,B3,3
0:
B .S2 B10 /* call fn */
LDW .D2T1 *+SP(REGS_A1+8),A4 /* get arg */
MVKL .S2 sys_exit,B11
MVKH .S2 sys_exit,B11
ADDKPC .S2 0f,B3,1
0:
BNOP .S2 B11,5 /* jump to sys_exit */
ENDPROC(ret_from_kernel_thread)

;;
;; These are the interrupt handlers, responsible for calling __do_IRQ()
;; int6 is used for syscalls (see _system_call entry)
Expand Down
38 changes: 12 additions & 26 deletions trunk/arch/c6x/kernel/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ void (*c6x_restart)(void);
void (*c6x_halt)(void);

extern asmlinkage void ret_from_fork(void);
extern asmlinkage void ret_from_kernel_thread(void);

/*
* power off function, if any
Expand Down Expand Up @@ -103,36 +104,21 @@ void machine_power_off(void)
halt_loop();
}

static void kernel_thread_helper(int dummy, void *arg, int (*fn)(void *))
{
do_exit(fn(arg));
}

/*
* Create a kernel thread
*/
int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags)
{
struct pt_regs regs;

/*
* copy_thread sets a4 to zero (child return from fork)
* so we can't just set things up to directly return to
* fn.
*/
memset(&regs, 0, sizeof(regs));
regs.b4 = (unsigned long) arg;
regs.a6 = (unsigned long) fn;
regs.pc = (unsigned long) kernel_thread_helper;
local_save_flags(regs.csr);
regs.csr |= 1;
regs.tsr = 5; /* Set GEE and GIE in TSR */
struct pt_regs regs = {
.a0 = (unsigned long)fn,
.a1 = (unsigned long)arg,
.tsr = 0, /* kernel mode */
};

/* Ok, create the new process.. */
return do_fork(flags | CLONE_VM | CLONE_UNTRACED, -1, &regs,
0, NULL, NULL);
}
EXPORT_SYMBOL(kernel_thread);

void flush_thread(void)
{
Expand Down Expand Up @@ -192,21 +178,21 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
childregs = task_pt_regs(p);

*childregs = *regs;
childregs->a4 = 0;

if (usp == -1)
if (usp == -1) {
/* case of __kernel_thread: we return to supervisor space */
childregs->sp = (unsigned long)(childregs + 1);
else
p->thread.pc = (unsigned long) ret_from_kernel_thread;
} else {
/* Otherwise use the given stack */
childregs->sp = usp;
p->thread.pc = (unsigned long) ret_from_fork;
}

/* Set usp/ksp */
p->thread.usp = childregs->sp;
/* switch_to uses stack to save/restore 14 callee-saved regs */
thread_saved_ksp(p) = (unsigned long)childregs - 8;
p->thread.pc = (unsigned int) ret_from_fork;
p->thread.wchan = (unsigned long) ret_from_fork;
p->thread.wchan = p->thread.pc;
#ifdef __DSBT__
{
unsigned long dp;
Expand Down

0 comments on commit 13c77d0

Please sign in to comment.