FreeBSD/sys/amd64/amd64/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)
{
	cpu_thread_clean(td);
#ifdef COMPAT_FREEBSD32
	if (SV_PROC_FLAG(td->td_proc, SV_ILP32)) {
		td->td_frame->tf_rbp = 0;
		td->td_frame->tf_rsp =
		   (((uintptr_t)stack->ss_sp + stack->ss_size - 4) & ~0x0f) - 4;
		td->td_frame->tf_rip = (uintptr_t)entry;
		suword32((void *)(td->td_frame->tf_rsp + sizeof(int32_t)),
		    (uint32_t)(uintptr_t)arg);
		return;
	}
#endif
	td->td_frame->tf_rbp = 0;
	td->td_frame->tf_rsp =
	    ((register_t)stack->ss_sp + stack->ss_size) & ~0x0f;
	td->td_frame->tf_rsp -= 8;
	td->td_frame->tf_rip = (register_t)entry;
	td->td_frame->tf_ds = _udatasel;
	td->td_frame->tf_es = _udatasel;
	td->td_frame->tf_fs = _ufssel;
	td->td_frame->tf_gs = _ugssel;
	td->td_frame->tf_flags = TF_HASSEGS;
	td->td_frame->tf_rdi = (register_t)arg;
}
void cpu_set_upcall ( struct thread * td , void ( * entry ) ( void * ) , void * arg , stack_t * stack ) { cpu_thread_clean ( td ) ; #ifdef COMPAT_FREEBSD32 if ( SV_PROC_FLAG ( td -> td_proc , SV_ILP32 ) ) { td -> td_frame -> tf_rbp = 0 ; td -> td_frame -> tf_rsp = ( ( ( uintptr_t ) stack -> ss_sp + stack -> ss_size - 4 ) & ~ 0x0f ) - 4 ; td -> td_frame -> tf_rip = ( uintptr_t ) entry ; suword32 ( ( void * ) ( td -> td_frame -> tf_rsp + sizeof ( int32_t ) ) , ( uint32_t ) ( uintptr_t ) arg ) ; return ; } #endif td -> td_frame -> tf_rbp = 0 ; td -> td_frame -> tf_rsp = ( ( register_t ) stack -> ss_sp + stack -> ss_size ) & ~ 0x0f ; td -> td_frame -> tf_rsp -= 8 ; td -> td_frame -> tf_rip = ( register_t ) entry ; td -> td_frame -> tf_ds = _udatasel ; td -> td_frame -> tf_es = _udatasel ; td -> td_frame -> tf_fs = _ufssel ; td -> td_frame -> tf_gs = _ugssel ; td -> td_frame -> tf_flags = TF_HASSEGS ; td -> td_frame -> tf_rdi = ( register_t ) arg ; }
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 .
/* 
	 * Do any extra cleaning that needs to be done.
	 * The thread may have optional components
	 * that are not present in a fresh thread.
	 * This may be a recycled thread so make it look
	 * as though it's newly allocated.
	 */ /*
		 * Set the trap frame to point at the beginning of the entry
		 * function.
		 */ /* Pass the argument to the entry point. */ /*
	 * Set the trap frame to point at the beginning of the uts
	 * function.
	 */ /* Pass the argument to the entry point. */