diff options
author | Marvin Borner | 2021-05-04 23:06:50 +0200 |
---|---|---|
committer | Marvin Borner | 2021-05-04 23:06:50 +0200 |
commit | 51016670a24092b6b9ecd0f50d1aaa976e780cc1 (patch) | |
tree | 028f9f0c825719721773e5fc38cf392a9ecc739f /kernel/drivers | |
parent | 028fb44dc7f7b216f35569e232ded4256b517d30 (diff) |
General fixes (see description) - closes #17
Somehow the Grub conversion (or anything before/between that) seems
to have caused a *very* weird memory bug involving the heap/stack/sth
overflowing into the video memory which will obviously result in strange
undefined behaviour when data is written to the video memory.
VERY STRANGE. Well, I need to prepare for my finals (Abitur) so I don't know
whether I can fix this issue in the next few days. We'll see...
Diffstat (limited to 'kernel/drivers')
-rw-r--r-- | kernel/drivers/fb.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/kernel/drivers/fb.c b/kernel/drivers/fb.c index 8831a52..8122654 100644 --- a/kernel/drivers/fb.c +++ b/kernel/drivers/fb.c @@ -12,6 +12,8 @@ #include <str.h> #include <sys.h> +#define FB_SIZE (vbe->height * vbe->pitch) + struct vbe_basic { u8 stuff1[16]; u16 pitch; @@ -27,8 +29,7 @@ PROTECTED static struct vbe_basic *vbe = NULL; static u32 fb_map_buffer(struct page_dir *dir) { assert(vbe); - u32 size = vbe->height * vbe->pitch; - return virtual_alloc(dir, memory_range_around((u32)vbe->fb, size), MEMORY_USER).base; + return virtual_alloc(dir, memory_range_around((u32)vbe->fb, FB_SIZE), MEMORY_USER).base; } static u32 fb_owner = 0; @@ -48,8 +49,7 @@ static res fb_ioctl(u32 request, void *arg1, void *arg2, void *arg3) if (fb_owner != 0 && proc_from_pid(fb_owner)) return -EBUSY; - else - fb_owner = proc_current()->pid; + fb_owner = proc_current()->pid; u32 fb = fb_map_buffer(proc_current()->page_dir); vbe->fb = (u8 *)fb; @@ -69,8 +69,6 @@ CLEAR void fb_install(void) dev->control = fb_ioctl; io_add(IO_FRAMEBUFFER, dev); - // Identity map framebuffer to kernel to prevent unwanted writing - u32 size = vbe->height * vbe->pitch; - memory_map_identity(virtual_kernel_dir(), memory_range_around((u32)vbe->fb, size), - MEMORY_CLEAR); + // Set framebuffer range used to prevent unwanted writing + physical_set_used(memory_range_around((u32)vbe->fb, FB_SIZE)); } |