aboutsummaryrefslogtreecommitdiffstats
path: root/xen-2.4.16/arch/i386/i387.c
blob: dc94cc1dadf1343e59f98574425be07dc4506039 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
 *  linux/arch/i386/kernel/i387.c
 *
 *  Copyright (C) 1994 Linus Torvalds
 *
 *  Pentium III FXSR, SSE support
 *  General FPU state handling cleanups
 *	Gareth Hughes <gareth@valinux.com>, May 2000
 */

#include <xeno/config.h>
#include <xeno/sched.h>
#include <asm/processor.h>
#include <asm/i387.h>

void init_fpu(void)
{
    __asm__("fninit");
    if ( cpu_has_xmm ) load_mxcsr(0x1f80);
    current->flags |= PF_DONEFPUINIT;
}

static inline void __save_init_fpu( struct task_struct *tsk )
{
	if ( cpu_has_fxsr ) {
		asm volatile( "fxsave %0 ; fnclex"
			      : "=m" (tsk->thread.i387.fxsave) );
	} else {
		asm volatile( "fnsave %0 ; fwait"
			      : "=m" (tsk->thread.i387.fsave) );
	}
	tsk->flags &= ~PF_USEDFPU;
}

void save_init_fpu( struct task_struct *tsk )
{
	__save_init_fpu(tsk);
	stts();
}

void restore_fpu( struct task_struct *tsk )
{
    if ( cpu_has_fxsr ) {
        asm volatile( "fxrstor %0"
                      : : "m" (tsk->thread.i387.fxsave) );
    } else {
        asm volatile( "frstor %0"
                      : : "m" (tsk->thread.i387.fsave) );
    }
}