2022-09-20 17:58:04 +00:00
|
|
|
#include "thread/Task.h"
|
|
|
|
#include "std/string.h"
|
|
|
|
|
|
|
|
void set_context_from_task(Task& task, Context* ctx)
|
|
|
|
{
|
|
|
|
memcpy(ctx, &task.regs, sizeof(Context));
|
|
|
|
}
|
|
|
|
|
|
|
|
void get_context_to_task(Task& task, Context* ctx)
|
|
|
|
{
|
|
|
|
memcpy(&task.regs, ctx, sizeof(Context));
|
2022-10-02 16:53:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void task_save_floating(Task& task)
|
|
|
|
{
|
|
|
|
task.floating_saved = true;
|
|
|
|
asm volatile("fxsave (%0)" : : "r"(&task.floating_region));
|
|
|
|
}
|
|
|
|
|
|
|
|
void task_restore_floating(Task& task)
|
|
|
|
{
|
|
|
|
if (!task.floating_saved) return;
|
|
|
|
asm volatile("fxrstor (%0)" : : "r"(&task.floating_region));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Task::is_user_task()
|
|
|
|
{
|
2022-10-12 15:07:39 +00:00
|
|
|
return user_task;
|
2022-09-20 17:58:04 +00:00
|
|
|
}
|