FreeBSD/sys/mips/mips/vm_machdep.c
/*
 * Set that machine state for performing an upcall that starts
 * the entry function with the given argument.
 */
Set that machine state for performing an upcall that starts
the entry function with the given argument.
Set that machine state for performing an upcall that starts the entry function with the given argument .
void
cpu_set_upcall(struct thread *td, void (*entry)(void *), void *arg,
    stack_t *stack)
{
	struct trapframe *tf;
	register_t sp;
	sp = (((intptr_t)stack->ss_sp + stack->ss_size) & ~0x7) -
	    CALLFRAME_SIZ;
	tf = td->td_frame;
	bzero(tf, sizeof(struct trapframe));
	tf->sp = sp;
	tf->pc = (register_t)(intptr_t)entry;
	tf->t9 = (register_t)(intptr_t)entry; 
	tf->a0 = (register_t)(intptr_t)arg;
	td->td_frame->sr = MIPS_SR_KSU_USER | MIPS_SR_EXL | MIPS_SR_INT_IE |
	    (mips_rd_status() & MIPS_SR_INT_MASK);
#if defined(__mips_n32) 
	td->td_frame->sr |= MIPS_SR_PX;
#elif  defined(__mips_n64)
	td->td_frame->sr |= MIPS_SR_PX | MIPS_SR_UX | MIPS_SR_KX;
#endif
}
void cpu_set_upcall ( struct thread * td , void ( * entry ) ( void * ) , void * arg , stack_t * stack ) { struct trapframe * tf ; register_t sp ; sp = ( ( ( intptr_t ) stack -> ss_sp + stack -> ss_size ) & ~ 0x7 ) - CALLFRAME_SIZ ; tf = td -> td_frame ; bzero ( tf , sizeof ( struct trapframe ) ) ; tf -> sp = sp ; tf -> pc = ( register_t ) ( intptr_t ) entry ; tf -> t9 = ( register_t ) ( intptr_t ) entry ; tf -> a0 = ( register_t ) ( intptr_t ) arg ; td -> td_frame -> sr = MIPS_SR_KSU_USER | MIPS_SR_EXL | MIPS_SR_INT_IE | ( mips_rd_status ( ) & MIPS_SR_INT_MASK ) ; #if defined ( __mips_n32 ) td -> td_frame -> sr |= MIPS_SR_PX ; #elif defined ( __mips_n64 ) td -> td_frame -> sr |= MIPS_SR_PX | MIPS_SR_UX | MIPS_SR_KX ; #endif }
Set that machine state for performing an upcall that starts
 the entry function with the given argument.
Set that machine state for performing an upcall that starts the entry function with the given argument .
/*
	 * At the point where a function is called, sp must be 8
	 * byte aligned[for compatibility with 64-bit CPUs]
	 * in ``See MIPS Run'' by D. Sweetman, p. 269
	 * align stack
	 */ /*
	 * Set the trap frame to point at the beginning of the uts
	 * function.
	 */ /* 
	 * MIPS ABI requires T9 to be the same as PC 
	 * in subroutine entry point
	 */ /*
	 * Keep interrupt mask
	 */ /*	tf->sr |= (ALL_INT_MASK & idle_mask) | SR_INT_ENAB; */ /**XXX the above may now be wrong -- mips2 implements this as panic */ /*
	 * FREEBSD_DEVELOPERS_FIXME:
	 * Setup any other CPU-Specific registers (Not MIPS Standard)
	 * that are needed.
	 */