diff options
Diffstat (limited to 'kernel/drivers/fb.c')
-rw-r--r-- | kernel/drivers/fb.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/kernel/drivers/fb.c b/kernel/drivers/fb.c index a1a7729..8e73f5b 100644 --- a/kernel/drivers/fb.c +++ b/kernel/drivers/fb.c @@ -1,13 +1,25 @@ // MIT License, Copyright (c) 2021 Marvin Borner +#include <assert.h> #include <def.h> #include <fb.h> #include <fs.h> #include <ioctl.h> #include <mem.h> +#include <mm.h> #include <str.h> #include <sys.h> +struct vbe_basic { + u8 stuff1[16]; + u16 pitch; + u16 width; + u16 height; + u8 stuff2[18]; + u8 *fb; + u8 stuff3[212]; +}; + static u32 dev_id = 0; static struct vid_info *info = NULL; @@ -18,9 +30,16 @@ static s32 fb_ioctl(u32 request, void *arg1, void *arg2, void *arg3, struct devi UNUSED(dev); switch (request) { - case IO_FB_GET: - memcpy(arg1, info->vbe, 256); + case IO_FB_GET: { + if (!info) + return -1; + struct vbe_basic *vbe = (struct vbe_basic *)info->vbe; + memcpy(arg1, info->vbe, sizeof(struct vbe_basic)); + u32 size = vbe->height * vbe->pitch; + memory_map_identity(proc_current()->page_dir, + memory_range_around((u32)vbe->fb, size), MEMORY_USER); return 0; + } default: return -1; } |