aboutsummaryrefslogtreecommitdiff
path: root/kernel/features/fb.c
diff options
context:
space:
mode:
authorMarvin Borner2021-05-20 22:18:35 +0200
committerMarvin Borner2021-05-20 22:19:20 +0200
commitd8d17375291f89d37cad43df36c11d9c132e23be (patch)
treeed6ba70ac6bd6b4e50dde6e1a0b2d62b7881e721 /kernel/features/fb.c
parent298aaf63f15350e6248d5a96e8c6a63b0ec93e0f (diff)
Added BGA driver and generic FB wrapper
Diffstat (limited to 'kernel/features/fb.c')
-rw-r--r--kernel/features/fb.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/kernel/features/fb.c b/kernel/features/fb.c
new file mode 100644
index 0000000..08d99df
--- /dev/null
+++ b/kernel/features/fb.c
@@ -0,0 +1,32 @@
+// MIT License, Copyright (c) 2021 Marvin Borner
+
+#include <def.h>
+#include <drivers/bga.h>
+#include <drivers/vbe.h>
+#include <fb.h>
+#include <multiboot.h>
+#include <print.h>
+
+#define FB_SIZE (generic->height * generic->pitch)
+
+u32 fb_map_buffer(struct page_dir *dir, struct fb_generic *generic)
+{
+ struct memory_range r =
+ virtual_alloc(dir, memory_range_around((u32)generic->fb, FB_SIZE), MEMORY_USER);
+ return r.base;
+}
+
+CLEAR void fb_protect(struct fb_generic *generic)
+{
+ physical_set_used(memory_range_around((u32)generic->fb, FB_SIZE));
+}
+
+CLEAR void fb_install(void)
+{
+ if (bga_available())
+ bga_install();
+ else if (multiboot_vbe())
+ vbe_install(multiboot_vbe());
+ else
+ panic("No framebuffer driver found!\n");
+}