#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)); } 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() { return (regs.cs & 3) > 0; }