StuBS
|
Functionality required for context switching. More...
#include "types.h"
Classes | |
struct | StackPointer |
Structure for saving the stack pointer when switching coroutines. More... | |
Functions | |
void * | prepareContext (void *tos, void(*kickoff)(void *), void *param1=nullptr) |
Prepares a context for its first activation. More... | |
void | context_switch (StackPointer ¤t, StackPointer &next) |
Executes the context switch. More... | |
void | context_go (StackPointer &next) |
Executes a thread for the very first time. More... | |
void | trampoline_go () |
Helper function to prepare parameters for Thread::kickoff. More... | |
Functionality required for context switching.
void trampoline_go | ( | ) |
Helper function to prepare parameters for Thread::kickoff.
This function will copy the first parameter for the kickoff function from the non-scratch register r15
into the register rdi
(which is the first parameter according to the SystemV ABI).
context_switch as well as context_go jump to this function on the first execution of a new context. The value mentioned above was placed on the stack by prepareContext during initialization and loaded into the register r15
while restoring the context in context_switch or context_go.