MOS Source Code
Loading...
Searching...
No Matches
fpu_context.c
Go to the documentation of this file.
1
// SPDX-License-Identifier: GPL-3.0-or-later
2
3
#include "
mos/x86/tasks/fpu_context.h
"
4
5
#include "
mos/misc/setup.h
"
6
#include "
mos/mm/slab.h
"
7
#include "
mos/platform/platform.h
"
8
#include "
mos/syslog/printk.h
"
9
#include "
mos/tasks/task_types.h
"
10
11
#include <
mos_stdlib.h
>
12
13
slab_t
*
xsave_area_slab
=
NULL
;
14
15
static
void
setup_xsave_slab
(
void
)
16
{
17
xsave_area_slab
=
kmemcache_create
(
"x86.xsave"
,
platform_info
->
arch_info
.
xsave_size
);
18
}
19
20
MOS_INIT
(
SLAB_AUTOINIT
,
setup_xsave_slab
);
21
22
static
const
u64
RFBM
= ~0ULL;
23
const
reg32_t
low
=
RFBM
& 0xFFFFFFFF;
24
const
reg32_t
high
=
RFBM
>> 32;
25
26
void
x86_xsave_thread
(
thread_t
*thread)
27
{
28
if
(!thread || thread->
mode
==
THREAD_MODE_KERNEL
)
29
return
;
// no, kernel threads don't have these
30
31
if
(!thread->
platform_options
.
xsaveptr
)
32
return
;
// this happens when the thread is being execve'd
33
34
pr_dcont
(scheduler,
"saved."
);
35
__asm__
volatile
(
"xsave %0"
::
"m"
(*thread->
platform_options
.
xsaveptr
),
"a"
(
low
),
"d"
(
high
));
36
}
37
38
void
x86_xrstor_thread
(
thread_t
*thread)
39
{
40
if
(!thread || thread->
mode
==
THREAD_MODE_KERNEL
)
41
return
;
// no, kernel threads don't have these
42
43
if
(!thread->
platform_options
.
xsaveptr
)
44
return
;
// this happens when the thread is being execve'd
45
46
pr_dcont
(scheduler,
"restored."
);
47
__asm__
volatile
(
"xrstor %0"
::
"m"
(*thread->
platform_options
.
xsaveptr
),
"a"
(
low
),
"d"
(
high
));
48
}
low
const reg32_t low
Definition
fpu_context.c:23
setup_xsave_slab
static void setup_xsave_slab(void)
Definition
fpu_context.c:15
high
const reg32_t high
Definition
fpu_context.c:24
x86_xrstor_thread
void x86_xrstor_thread(thread_t *thread)
Definition
fpu_context.c:38
xsave_area_slab
slab_t * xsave_area_slab
Definition
fpu_context.c:13
RFBM
static const u64 RFBM
Definition
fpu_context.c:22
x86_xsave_thread
void x86_xsave_thread(thread_t *thread)
Definition
fpu_context.c:26
fpu_context.h
THREAD_MODE_KERNEL
@ THREAD_MODE_KERNEL
Definition
task_types.h:21
mos_stdlib.h
NULL
#define NULL
Definition
pb_syshdr.h:46
platform.h
printk.h
pr_dcont
#define pr_dcont(feat, fmt,...)
Definition
printk.h:33
platform_info
mos_platform_info_t *const platform_info
Definition
riscv64_platform.c:15
setup.h
MOS_INIT
#define MOS_INIT(_comp, _fn)
Definition
setup.h:40
slab.h
kmemcache_create
slab_t * kmemcache_create(const char *name, size_t ent_size)
Definition
slab.c:219
SLAB_AUTOINIT
#define SLAB_AUTOINIT(name, var, type)
Definition
slab_autoinit.h:14
mos_platform_info_t::arch_info
platform_arch_info_t arch_info
Definition
platform.h:132
platform_arch_info_t::xsave_size
size_t xsave_size
Definition
platform_defs.h:75
platform_thread_options_t::xsaveptr
u8 * xsaveptr
Definition
platform_defs.h:65
slab_t
Definition
slab.h:45
thread_t
Definition
task_types.h:75
thread_t::platform_options
platform_thread_options_t platform_options
platform-specific thread options
Definition
task_types.h:87
thread_t::mode
thread_mode mode
user-mode thread or kernel-mode
Definition
task_types.h:81
task_types.h
reg32_t
u32 reg32_t
Definition
types.h:53
u64
unsigned long long u64
Definition
types.h:23
kernel
arch
x86_64
tasks
fpu_context.c
Generated on Sun Sep 1 2024 18:22:52 for MOS Source Code by
1.12.0