mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-22 08:06:17 +04:00
Setup x87 FPU control word correctly
This commit is contained in:
parent
e32597ac82
commit
71015ef63c
@ -43,10 +43,13 @@ pub fn init() {
|
||||
// enable FPU, the manual Volume 3 Chapter 13
|
||||
unsafe {
|
||||
Cr4::update(|cr4| {
|
||||
// enable fxsave/fxrstor
|
||||
cr4.insert(Cr4Flags::OSFXSR);
|
||||
// sse
|
||||
cr4.insert(Cr4Flags::OSXMMEXCPT_ENABLE);
|
||||
});
|
||||
Cr0::update(|cr0| {
|
||||
// enable fpu
|
||||
cr0.remove(Cr0Flags::EMULATE_COPROCESSOR);
|
||||
cr0.insert(Cr0Flags::MONITOR_COPROCESSOR);
|
||||
});
|
||||
|
@ -5,7 +5,10 @@
|
||||
#[derive(Debug, Copy, Clone, Default)]
|
||||
pub struct FpState {
|
||||
// 0
|
||||
word1: u64,
|
||||
fcw: u16,
|
||||
fsw: u16,
|
||||
ftw: u16,
|
||||
fop: u16,
|
||||
word2: u64,
|
||||
// 16
|
||||
word3: u64,
|
||||
@ -23,8 +26,11 @@ impl FpState {
|
||||
pub fn new() -> Self {
|
||||
assert!(core::mem::size_of::<Self>() == 512);
|
||||
Self {
|
||||
// default value
|
||||
// default values
|
||||
// intel manual 11.6.4 Initialization of SSE/SSE2 Extensions
|
||||
mxcsr: 0x1f80,
|
||||
// intel manual 8.1.5 x87 FPU Control Word
|
||||
fcw: 0x03f7,
|
||||
..Self::default()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user