Subversion Repositories HelenOS-historic

Rev

Rev 257 | Rev 309 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 257 Rev 282
Line 58... Line 58...
58
    "Unknown Vendor",
58
    "Unknown Vendor",
59
    "AuthenticAMD",
59
    "AuthenticAMD",
60
    "GenuineIntel"
60
    "GenuineIntel"
61
};
61
};
62
 
62
 
-
 
63
 
-
 
64
/** Setup flags on processor so that we can use the FPU
-
 
65
 *
-
 
66
 * cr0.osfxsr = 1 -> we do support fxstor/fxrestor
-
 
67
 * cr0.em = 0 -> we do not emulate coprocessor
-
 
68
 * cr0.mp = 1 -> we do want lazy context switch
-
 
69
 */
-
 
70
void cpu_setup_fpu(void)
-
 
71
{
-
 
72
    __asm__ volatile (
-
 
73
        "movq %%cr0, %%rax;"
-
 
74
        "btsq $1, %%rax;" /* cr0.mp */
-
 
75
        "btrq $2, %%rax;"  /* cr0.em */
-
 
76
        "movq %%rax, %%cr0;"
-
 
77
 
-
 
78
        "movq %%cr4, %%rax;"
-
 
79
        "bts $9, %%rax;" /* cr4.osfxsr */
-
 
80
        "movq %%rax, %%cr4;"
-
 
81
        :
-
 
82
        :
-
 
83
        :"%rax"
-
 
84
        );
-
 
85
}
-
 
86
 
-
 
87
/** Set the TS flag to 1.
-
 
88
 *
-
 
89
 * If a thread accesses coprocessor, exception is run, which
-
 
90
 * does a lazy fpu context switch.
-
 
91
 *
-
 
92
 */
63
void set_TS_flag(void)
93
void set_TS_flag(void)
64
{
94
{
65
    __asm__ volatile (
95
    __asm__ volatile (
66
        "mov %%cr0,%%rax;"
96
        "mov %%cr0,%%rax;"
67
        "or $8,%%rax;"
97
        "bts $3,%%rax;"
68
        "mov %%rax,%%cr0;"
98
        "mov %%rax,%%cr0;"
69
        :
99
        :
70
        :
100
        :
71
        :"%rax"
101
        :"%rax"
72
        );
102
        );
Line 74... Line 104...
74
 
104
 
75
void reset_TS_flag(void)
105
void reset_TS_flag(void)
76
{
106
{
77
    __asm__ volatile (
107
    __asm__ volatile (
78
        "mov %%cr0,%%rax;"
108
        "mov %%cr0,%%rax;"
79
        "btc $4,%%rax;"
109
        "btr $3,%%rax;"
80
        "mov %%rax,%%cr0;"
110
        "mov %%rax,%%cr0;"
81
        :
111
        :
82
        :
112
        :
83
        :"%rax"
113
        :"%rax"
84
        ); 
114
        );