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
3
#include "
mos/x86/tasks/fpu_context.hpp
"
4
5
#include "
mos/platform/platform.hpp
"
6
#include "
mos/syslog/printk.hpp
"
7
#include "
mos/tasks/task_types.hpp
"
8
9
#include <
mos/allocator.hpp
>
10
#include <
mos_stdlib.hpp
>
11
12
static
const
u64
RFBM
= ~0ULL;
13
const
reg32_t
low
=
RFBM
& 0xFFFFFFFF;
14
const
reg32_t
high
=
RFBM
>> 32;
15
16
void
x86_xsave_thread
(
Thread
*thread)
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
28
void
x86_xrstor_thread
(
Thread
*thread)
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
}
allocator.hpp
low
const reg32_t low
Definition
fpu_context.cpp:13
x86_xsave_thread
void x86_xsave_thread(Thread *thread)
Definition
fpu_context.cpp:16
high
const reg32_t high
Definition
fpu_context.cpp:14
RFBM
static const u64 RFBM
Definition
fpu_context.cpp:12
x86_xrstor_thread
void x86_xrstor_thread(Thread *thread)
Definition
fpu_context.cpp:28
fpu_context.hpp
THREAD_MODE_KERNEL
@ THREAD_MODE_KERNEL
Definition
task_types.hpp:26
mos_stdlib.hpp
platform.hpp
printk.hpp
pr_dcont
#define pr_dcont(feat, fmt,...)
Definition
printk.hpp:33
Thread
Definition
task_types.hpp:94
Thread::platform_options
platform_thread_options_t platform_options
platform-specific thread options
Definition
task_types.hpp:106
Thread::mode
thread_mode mode
user-mode thread or kernel-mode
Definition
task_types.hpp:100
platform_thread_options_t::xsaveptr
u8 * xsaveptr
Definition
platform_defs.hpp:65
task_types.hpp
reg32_t
u32 reg32_t
Definition
types.h:49
u64
unsigned long long u64
Definition
types.h:19
kernel
arch
x86_64
tasks
fpu_context.cpp
Generated on Tue Feb 18 2025 16:41:40 for MOS Source Code by
1.13.2