diff --git a/kernel/Makefile b/kernel/Makefile index fc419f62..c37a2b88 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -5,7 +5,7 @@ AS=x86_64-elf-as THOR_FLAGS=-DCONFIG_HISTORY=y WARNING_FLAGS=-Wall -Wextra -pedantic -Wold-style-cast -Wshadow -CPP_FLAGS=-masm=intel -Iinclude/ -nostdlib -Os -std=c++11 -fno-exceptions -fno-rtti -ffreestanding -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow $(WARNING_FLAGS) +CPP_FLAGS=-masm=intel -Iinclude/ -nostdlib -Os -std=c++11 -fno-exceptions -fno-rtti -ffreestanding -mno-red-zone -mno-3dnow -mno-mmx -mno-sse3 -mno-sse4 -mno-sse4.1 -mno-sse4.2 $(WARNING_FLAGS) KERNEL_FLAGS=$(CPP_FLAGS) $(THOR_FLAGS) KERNEL_LINK_FLAGS=-lgcc -T linker.ld $(CPP_FLAGS) diff --git a/micro_kernel/micro_kernel.asm b/micro_kernel/micro_kernel.asm index 450c9b4a..07113378 100644 --- a/micro_kernel/micro_kernel.asm +++ b/micro_kernel/micro_kernel.asm @@ -172,12 +172,37 @@ lm_start: ; Install custom syscalls call install_syscalls + call enable_sse + sti call 0x5000 jmp $ +; Functions + +enable_sse: + ; Test if SSE is supported by the processor + mov eax, 0x1 + cpuid + test edx, 1<<25 + jz .no_sse + + ; Enable SSE support + xor rax, rax + mov rax, cr0 + and ax, 0xFFFB ;clear coprocessor emulation CR0.EM + or ax, 0x2 ;set coprocessor monitoring CR0.MP + mov cr0, rax + mov rax, cr4 + or ax, 3 << 9 ;set CR4.OSFXSR and CR4.OSXMMEXCPT + mov cr4, rax + + .no_sse: + + ret + ; Includes %include "utils/macros.asm"