From d8d17375291f89d37cad43df36c11d9c132e23be Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Thu, 20 May 2021 22:18:35 +0200 Subject: Added BGA driver and generic FB wrapper --- kernel/features/fb.c | 32 ++++++++++++++++++++++++++++++++ kernel/features/io.c | 11 +++-------- kernel/features/mm.c | 4 ++-- 3 files changed, 37 insertions(+), 10 deletions(-) create mode 100644 kernel/features/fb.c (limited to 'kernel/features') 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 +#include +#include +#include +#include +#include + +#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"); +} diff --git a/kernel/features/io.c b/kernel/features/io.c index 4bbc4e0..28388ae 100644 --- a/kernel/features/io.c +++ b/kernel/features/io.c @@ -3,12 +3,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -231,18 +233,11 @@ CLEAR void io_install(void) ps2_mouse_install(ps2_mouse); } - /** - * Framebuffer detection - */ - - u32 vbe = multiboot_vbe(); - if (vbe) - vbe_install(vbe); - /** * Other devices */ + fb_install(); timer_install(); logger_install(); bus_install(); diff --git a/kernel/features/mm.c b/kernel/features/mm.c index 81645af..227ba0a 100644 --- a/kernel/features/mm.c +++ b/kernel/features/mm.c @@ -2,10 +2,10 @@ // MIT License, Copyright (c) 2021 Marvin Borner #include -#include #include -#include +#include #include +#include #include #include #include -- cgit v1.2.3