Subversion Repositories HelenOS

Rev

Rev 2787 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2787 Rev 4377
Line 75... Line 75...
75
 * cr0.mp = 1 -> we do want lazy context switch
75
 * cr0.mp = 1 -> we do want lazy context switch
76
 */
76
 */
77
void cpu_setup_fpu(void)
77
void cpu_setup_fpu(void)
78
{
78
{
79
    asm volatile (
79
    asm volatile (
80
        "movq %%cr0, %%rax;"
80
        "movq %%cr0, %%rax\n"
81
        "btsq $1, %%rax;" /* cr0.mp */
81
        "btsq $1, %%rax\n"  /* cr0.mp */
82
        "btrq $2, %%rax;"  /* cr0.em */
82
        "btrq $2, %%rax\n"  /* cr0.em */
83
        "movq %%rax, %%cr0;"
83
        "movq %%rax, %%cr0\n"
84
 
84
       
85
        "movq %%cr4, %%rax;"
85
        "movq %%cr4, %%rax\n"
86
        "bts $9, %%rax;" /* cr4.osfxsr */
86
        "bts $9, %%rax\n"   /* cr4.osfxsr */
87
        "movq %%rax, %%cr4;"
87
        "movq %%rax, %%cr4\n"
88
        :
-
 
89
        :
-
 
90
        :"%rax"
88
        ::: "%rax"
91
        );
89
    );
92
}
90
}
93
 
91
 
94
/** Set the TS flag to 1.
92
/** Set the TS flag to 1.
95
 *
93
 *
96
 * If a thread accesses coprocessor, exception is run, which
94
 * If a thread accesses coprocessor, exception is run, which
97
 * does a lazy fpu context switch.
95
 * does a lazy fpu context switch.
98
 *
96
 *
99
 */
97
 */
100
void fpu_disable(void)
98
void fpu_disable(void)
101
{
99
{
102
    asm volatile (
100
    asm volatile (
103
        "mov %%cr0,%%rax;"
101
        "mov %%cr0, %%rax\n"
104
        "bts $3,%%rax;"
102
        "bts $3, %%rax\n"
105
        "mov %%rax,%%cr0;"
103
        "mov %%rax, %%cr0\n"
106
        :
-
 
107
        :
-
 
108
        :"%rax"
104
        ::: "%rax"
109
        );
105
    );
110
}
106
}
111
 
107
 
112
void fpu_enable(void)
108
void fpu_enable(void)
113
{
109
{
114
    asm volatile (
110
    asm volatile (
115
        "mov %%cr0,%%rax;"
111
        "mov %%cr0, %%rax\n"
116
        "btr $3,%%rax;"
112
        "btr $3, %%rax\n"
117
        "mov %%rax,%%cr0;"
113
        "mov %%rax, %%cr0\n"
118
        :
-
 
119
        :
-
 
120
        :"%rax"
114
        ::: "%rax"
121
        ); 
115
    );
122
}
116
}
123
 
117
 
124
void cpu_arch_init(void)
118
void cpu_arch_init(void)
125
{
119
{
126
    CPU->arch.tss = tss_p;
120
    CPU->arch.tss = tss_p;