diff --git a/src/context.h b/src/context.h new file mode 100644 index 0000000..48af06f --- /dev/null +++ b/src/context.h @@ -0,0 +1,34 @@ +#ifndef _CONTEXT_H +#define _CONTEXT_H + +#include "types.h" +#include "reg.h" +#include "stack.h" +#include "mem.h" + +/* + Task/VM context +*/ +typedef struct context { + index_t index; + stack_t *DS; + stack_t *FS; + reg_t *R; + mem_t *M; + segment_t *S; + index_t task; // task number + int32_t evmask; // events of this task + struct context *next; // task context chaining +} context_t; + +extern context_t *Context[MAXTASKS]; +extern int ContextTop; + +context_t *ContextAllocate(); +context_t* ContextInit(context_t* C, mem_t *M,stack_t *DS, stack_t *FS, reg_t *R); +int ContextReset(context_t *c); +void ContextResetAll(context_t *c0); + +#define CONTEXTID(C) (C->index) + +#endif