aboutsummaryrefslogtreecommitdiff
path: root/kernel/drivers
diff options
context:
space:
mode:
authorMarvin Borner2021-03-13 13:33:26 +0100
committerMarvin Borner2021-03-13 13:33:50 +0100
commit8176351e1a3d1598bedbc007897d530475942275 (patch)
treed7745b95abf8e7af9cee1fcfc387137f607c735f /kernel/drivers
parent606774e6b0e0a2d36139983b85c8675b2228a9ff (diff)
Nicü
Diffstat (limited to 'kernel/drivers')
-rw-r--r--kernel/drivers/fb.c23
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;
}