aboutsummaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorMarvin Borner2020-09-04 15:50:21 +0200
committerMarvin Borner2020-09-04 15:50:21 +0200
commitb8f00b77e965c73a047e71193c8c6e2d7488f34d (patch)
tree168354a8cd9b8a69a2f06a09e8ce73aadd4e2521 /kernel
parent15a8cb8fa64b12d6c0b65eafb226971cd66dc3cd (diff)
Added mandelbrot demo and fpu driver
Diffstat (limited to 'kernel')
-rw-r--r--kernel/Makefile1
-rw-r--r--kernel/drivers/fpu.c24
-rw-r--r--kernel/inc/fpu.h8
-rw-r--r--kernel/main.c2
4 files changed, 35 insertions, 0 deletions
diff --git a/kernel/Makefile b/kernel/Makefile
index 07f985a..98060df 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -3,6 +3,7 @@
COBJS = main.o \
drivers/interrupts.o \
drivers/interrupts_asm.o \
+ drivers/fpu.o \
drivers/keyboard.o \
drivers/mouse.o \
drivers/ide.o \
diff --git a/kernel/drivers/fpu.c b/kernel/drivers/fpu.c
new file mode 100644
index 0000000..d8a2b79
--- /dev/null
+++ b/kernel/drivers/fpu.c
@@ -0,0 +1,24 @@
+// MIT License, Copyright (c) 2020 Marvin Borner
+
+#include <def.h>
+
+void set_fpu_cw(const u16 cw)
+{
+ __asm__ volatile("fldcw %0" ::"m"(cw));
+}
+
+void fpu_install()
+{
+ __asm__ volatile("clts");
+ u32 t;
+ __asm__ volatile("mov %%cr0, %0" : "=r"(t));
+ t &= ~(1 << 2);
+ t |= (1 << 1);
+ __asm__ volatile("mov %0, %%cr0" ::"r"(t));
+
+ __asm__ volatile("mov %%cr4, %0" : "=r"(t));
+ t |= 3 << 9;
+ __asm__ volatile("mov %0, %%cr4" ::"r"(t));
+
+ __asm__ volatile("fninit");
+}
diff --git a/kernel/inc/fpu.h b/kernel/inc/fpu.h
new file mode 100644
index 0000000..d747708
--- /dev/null
+++ b/kernel/inc/fpu.h
@@ -0,0 +1,8 @@
+// MIT License, Copyright (c) 2020 Marvin Borner
+
+#ifndef FPU_H
+#define FPU_H
+
+void fpu_install();
+
+#endif
diff --git a/kernel/main.c b/kernel/main.c
index 7d87be5..4792d75 100644
--- a/kernel/main.c
+++ b/kernel/main.c
@@ -2,6 +2,7 @@
#include <boot.h>
#include <cpu.h>
+#include <fpu.h>
#include <fs.h>
#include <keyboard.h>
#include <load.h>
@@ -23,6 +24,7 @@ void kernel_main(struct vid_info *vid_info)
// Install drivers
interrupts_install();
+ fpu_install();
timer_install();
keyboard_install();
mouse_install();