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
4
5#include "mos/misc/setup.h"
6#include "mos/mm/slab.h"
8#include "mos/syslog/printk.h"
10
11#include <mos_stdlib.h>
12
14
19
21
22static const u64 RFBM = ~0ULL;
23const reg32_t low = RFBM & 0xFFFFFFFF;
24const reg32_t high = RFBM >> 32;
25
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
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}
const reg32_t low
Definition fpu_context.c:23
static void setup_xsave_slab(void)
Definition fpu_context.c:15
const reg32_t high
Definition fpu_context.c:24
void x86_xrstor_thread(thread_t *thread)
Definition fpu_context.c:38
slab_t * xsave_area_slab
Definition fpu_context.c:13
static const u64 RFBM
Definition fpu_context.c:22
void x86_xsave_thread(thread_t *thread)
Definition fpu_context.c:26
@ THREAD_MODE_KERNEL
Definition task_types.h:21
#define NULL
Definition pb_syshdr.h:46
#define pr_dcont(feat, fmt,...)
Definition printk.h:33
mos_platform_info_t *const platform_info
#define MOS_INIT(_comp, _fn)
Definition setup.h:40
slab_t * kmemcache_create(const char *name, size_t ent_size)
Definition slab.c:219
#define SLAB_AUTOINIT(name, var, type)
platform_arch_info_t arch_info
Definition platform.h:132
Definition slab.h:45
platform_thread_options_t platform_options
platform-specific thread options
Definition task_types.h:87
thread_mode mode
user-mode thread or kernel-mode
Definition task_types.h:81
u32 reg32_t
Definition types.h:53
unsigned long long u64
Definition types.h:23