MOS Source Code
Loading...
Searching...
No Matches
fpu_context.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2
4
8
9#include <mos/allocator.hpp>
10#include <mos_stdlib.hpp>
11
12static const u64 RFBM = ~0ULL;
13const reg32_t low = RFBM & 0xFFFFFFFF;
14const reg32_t high = RFBM >> 32;
15
17{
18 if (!thread || thread->mode == THREAD_MODE_KERNEL)
19 return; // no, kernel threads don't have these
20
21 if (!thread->platform_options.xsaveptr)
22 return; // this happens when the thread is being execve'd
23
24 pr_dcont(scheduler, "saved.");
25 __asm__ volatile("xsave %0" ::"m"(*thread->platform_options.xsaveptr), "a"(low), "d"(high));
26}
27
29{
30 if (!thread || thread->mode == THREAD_MODE_KERNEL)
31 return; // no, kernel threads don't have these
32
33 if (!thread->platform_options.xsaveptr)
34 return; // this happens when the thread is being execve'd
35
36 pr_dcont(scheduler, "restored.");
37 __asm__ volatile("xrstor %0" ::"m"(*thread->platform_options.xsaveptr), "a"(low), "d"(high));
38}
const reg32_t low
void x86_xsave_thread(Thread *thread)
const reg32_t high
static const u64 RFBM
void x86_xrstor_thread(Thread *thread)
@ THREAD_MODE_KERNEL
#define pr_dcont(feat, fmt,...)
Definition printk.hpp:33
platform_thread_options_t platform_options
platform-specific thread options
thread_mode mode
user-mode thread or kernel-mode
u32 reg32_t
Definition types.h:49
unsigned long long u64
Definition types.h:19