Added functions to portably manipulate process context
This commit is contained in:
@@ -2,10 +2,25 @@
|
|||||||
|
|
||||||
struct process_context_t;
|
struct process_context_t;
|
||||||
|
|
||||||
void *initialize_context(void *task_entry);
|
/**
|
||||||
|
* @brief Allocates a new process context and initializes it with the given
|
||||||
|
* program counter.
|
||||||
|
*
|
||||||
|
* @param task_entry
|
||||||
|
* @return void*
|
||||||
|
*/
|
||||||
|
void *initialize_context(void *pc);
|
||||||
|
|
||||||
void destroy_context(void *ctx);
|
void destroy_context(void *ctx);
|
||||||
|
|
||||||
void save_context(struct process_context_t *context);
|
void save_context(struct process_context_t *context);
|
||||||
|
|
||||||
void load_context(struct process_context_t *context);
|
void load_context(struct process_context_t *context);
|
||||||
|
|
||||||
|
void set_context_pc(struct process_context_t *context, void *pc);
|
||||||
|
|
||||||
|
void set_context_stack(struct process_context_t *context, void *stack);
|
||||||
|
|
||||||
|
void set_context_flags(struct process_context_t *context, unsigned long flags);
|
||||||
|
|
||||||
|
void set_context_return(struct process_context_t *context, unsigned long value);
|
||||||
|
|||||||
@@ -43,3 +43,23 @@ void save_context(struct process_context_t *context)
|
|||||||
{
|
{
|
||||||
store_active_context(context, sizeof(*context));
|
store_active_context(context, sizeof(*context));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_context_pc(struct process_context_t *context, void *pc)
|
||||||
|
{
|
||||||
|
context->eip = pc;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_context_stack(struct process_context_t *context, void *stack)
|
||||||
|
{
|
||||||
|
context->esp = stack;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_context_flags(struct process_context_t *context, unsigned long flags)
|
||||||
|
{
|
||||||
|
context->flags = flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_context_return(struct process_context_t *context, unsigned long value)
|
||||||
|
{
|
||||||
|
context->eax = value;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user