40 lines
941 B
C
40 lines
941 B
C
#ifndef RT_CONTEXT_H
|
|
#define RT_CONTEXT_H
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*
|
|
* Initialize the given stack with a new context that will execute fn().
|
|
*/
|
|
void *rt_context_init(void (*fn)(void), void *stack, size_t stack_size);
|
|
|
|
/*
|
|
* Initialize the given stack with a new context that will execute fn(arg).
|
|
*/
|
|
void *rt_context_init_arg(void (*fn)(uintptr_t), uintptr_t arg, void *stack,
|
|
size_t stack_size);
|
|
|
|
/*
|
|
* Start execution from the given context. An implementation can assume that
|
|
* the context represents the beginning of a function call. This should only be
|
|
* called by rt_start.
|
|
*/
|
|
__attribute__((noreturn)) void rt_context_start(void *ctx);
|
|
|
|
/*
|
|
* Pointer to the previous task's context field, used to store the suspending
|
|
* context during a context switch.
|
|
*/
|
|
extern void **rt_context_prev;
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* RT_CONTEXT_H */
|