[][src]Function sunrise_kernel::i386::process_switch::jump_to_entrypoint

fn jump_to_entrypoint(
    ep: usize,
    userspace_stack_ptr: usize,
    arg1: usize,
    arg2: usize
) -> !

Jumps to Userspace, and run a userspace program.

This function is called on the first schedule of a process or thread, after all the process_switch mechanics is over, and the thread is good to go.

It jumps to ring 3 by pushing the given ep and userspace_stack_ptr on the KernelStack, and executing an iret.

Just before doing the iret, it clears all general-purpose registers.

This way, just after the iret, cpu will be in ring 3, witl all of its registers cleared, $eip pointing to ep, and $esp pointing to userspace_stack_ptr.