summaryrefslogtreecommitdiff
path: root/src/arch/amd64/fpu.c
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2024-02-02 16:41:19 -0500
committerFreya Murphy <freya@freyacat.org>2024-02-02 16:41:19 -0500
commit72df91d99ba7e9a032d6cb171571e075d0f6ce53 (patch)
tree5ccba5a02821a54f953d85a092429939e6c577f0 /src/arch/amd64/fpu.c
parentcheck for bochs (diff)
downloadcorn-72df91d99ba7e9a032d6cb171571e075d0f6ce53.tar.gz
corn-72df91d99ba7e9a032d6cb171571e075d0f6ce53.tar.bz2
corn-72df91d99ba7e9a032d6cb171571e075d0f6ce53.zip
pretty colors
Diffstat (limited to 'src/arch/amd64/fpu.c')
-rw-r--r--src/arch/amd64/fpu.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/arch/amd64/fpu.c b/src/arch/amd64/fpu.c
new file mode 100644
index 0000000..551485e
--- /dev/null
+++ b/src/arch/amd64/fpu.c
@@ -0,0 +1,12 @@
+#include <fpu.h>
+#include <stddef.h>
+#include <stdint.h>
+
+void enable_fpu() {
+ size_t cr4;
+ uint16_t cw = 0x37F;
+ __asm__ volatile ("mov %%cr4, %0" : "=r"(cr4));
+ cr4 |= 0x200;
+ __asm__ volatile ("mov %0, %%cr4" :: "r"(cr4));
+ __asm__ volatile("fldcw %0" :: "m"(cw));
+}