diff options
author | Marvin Borner | 2020-09-04 15:50:21 +0200 |
---|---|---|
committer | Marvin Borner | 2020-09-04 15:50:21 +0200 |
commit | b8f00b77e965c73a047e71193c8c6e2d7488f34d (patch) | |
tree | 168354a8cd9b8a69a2f06a09e8ce73aadd4e2521 /kernel/drivers | |
parent | 15a8cb8fa64b12d6c0b65eafb226971cd66dc3cd (diff) |
Added mandelbrot demo and fpu driver
Diffstat (limited to 'kernel/drivers')
-rw-r--r-- | kernel/drivers/fpu.c | 24 |
1 files changed, 24 insertions, 0 deletions
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"); +} |