[Zion] Enable SSE instructions at the start of boot.
These aren't ready to be used yet as we need to save them on task switch.
This commit is contained in:
parent
9b43d615a9
commit
a1e1e1c2d8
5 changed files with 48 additions and 0 deletions
|
|
@ -2,6 +2,7 @@ add_executable(zion
|
|||
boot/acpi.cpp
|
||||
boot/boot_info.cpp
|
||||
capability/capability_table.cpp
|
||||
common/cpu.cpp
|
||||
common/gdt.cpp
|
||||
common/load_gdt.s
|
||||
common/msr.cpp
|
||||
|
|
|
|||
30
zion/common/cpu.cpp
Normal file
30
zion/common/cpu.cpp
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#include "common/cpu.h"
|
||||
|
||||
#include <cpuid.h>
|
||||
|
||||
#include "debug/debug.h"
|
||||
|
||||
void ProbeCpuAndEnableFeatures() {
|
||||
dbgln("CPUID");
|
||||
uint32_t eax, ebx, ecx, edx;
|
||||
__get_cpuid(1, &eax, &ebx, &ecx, &edx);
|
||||
|
||||
if (!(edx & (0x3 << 25))) {
|
||||
panic("SSE & SSE2 not available.");
|
||||
}
|
||||
|
||||
if (!(ecx & (0x1 | (0x1 << 9)))) {
|
||||
panic("SSE3, SSSE3 not available.");
|
||||
}
|
||||
|
||||
dbgln("Setting SSE");
|
||||
asm volatile(
|
||||
"mov %%cr0, %%rax;"
|
||||
"and $0xFFFB, %%ax;" // Clear EM
|
||||
"or $0x2, %%ax;" // Set MP
|
||||
"mov %%rax, %%cr0;"
|
||||
"mov %%cr4, %%rax;"
|
||||
"or $0x600, %%ax;" // Set OSFXSR, OSXMMEXCPT
|
||||
"mov %%rax, %%cr4;" ::
|
||||
: "rax");
|
||||
}
|
||||
3
zion/common/cpu.h
Normal file
3
zion/common/cpu.h
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
#pragma once
|
||||
|
||||
void ProbeCpuAndEnableFeatures();
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#include "boot/acpi.h"
|
||||
#include "common/cpu.h"
|
||||
#include "common/gdt.h"
|
||||
#include "debug/debug.h"
|
||||
#include "interrupt/apic.h"
|
||||
|
|
@ -22,6 +23,8 @@ extern "C" void zion() {
|
|||
InitGdt();
|
||||
InitIdt();
|
||||
|
||||
ProbeCpuAndEnableFeatures();
|
||||
|
||||
dbgln("[boot] Init Physical Memory Manager.");
|
||||
phys_mem::InitBootstrapPageAllocation();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue