aboutsummaryrefslogtreecommitdiff
path: root/kernel/drivers/fb.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/drivers/fb.c')
-rw-r--r--kernel/drivers/fb.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/kernel/drivers/fb.c b/kernel/drivers/fb.c
index 7c02919..2a29eb7 100644
--- a/kernel/drivers/fb.c
+++ b/kernel/drivers/fb.c
@@ -8,6 +8,7 @@
#include <io.h>
#include <mem.h>
#include <mm.h>
+#include <multiboot.h>
#include <str.h>
#include <sys.h>
@@ -21,7 +22,15 @@ struct vbe_basic {
u8 stuff3[212];
};
-PROTECTED static struct vid_info *info = NULL;
+PROTECTED static struct vbe_basic *vbe = NULL;
+
+static void fb_map_buffer(struct page_dir *dir)
+{
+ // TODO: Return virtual mapped address
+ assert(vbe);
+ u32 size = vbe->height * vbe->pitch;
+ memory_map_identity(dir, memory_range_around((u32)vbe->fb, size), MEMORY_USER);
+}
static u32 fb_owner = 0;
static res fb_ioctl(u32 request, void *arg1, void *arg2, void *arg3)
@@ -31,10 +40,11 @@ static res fb_ioctl(u32 request, void *arg1, void *arg2, void *arg3)
switch (request) {
case IOCTL_FB_GET: {
- if (!info)
+ if (!vbe)
return -ENOENT;
- if (!memory_writable_range(memory_range(arg1, sizeof(struct vbe_basic))))
+ u32 size = MIN(sizeof(*vbe), (u32)arg2);
+ if (!memory_writable_range(memory_range(arg1, size)))
return -EFAULT;
if (fb_owner != 0 && proc_from_pid(fb_owner))
@@ -42,10 +52,8 @@ static res fb_ioctl(u32 request, void *arg1, void *arg2, void *arg3)
else
fb_owner = proc_current()->pid;
- stac();
- memcpy(arg1, info->vbe, sizeof(struct vbe_basic));
- clac();
- fb_map_buffer(proc_current()->page_dir, info);
+ memcpy_user(arg1, vbe, size);
+ fb_map_buffer(proc_current()->page_dir);
return EOK;
}
default:
@@ -53,18 +61,13 @@ static res fb_ioctl(u32 request, void *arg1, void *arg2, void *arg3)
}
}
-void fb_map_buffer(struct page_dir *dir, struct vid_info *boot)
-{
- struct vbe_basic *vbe = (struct vbe_basic *)boot->vbe;
- u32 size = vbe->height * vbe->pitch;
- memory_map_identity(dir, memory_range_around((u32)vbe->fb, size), MEMORY_USER);
-}
-
CLEAR void fb_install(void)
{
- //info = boot;
+ vbe = (void *)multiboot_vbe();
struct io_dev *dev = zalloc(sizeof(*dev));
dev->control = fb_ioctl;
io_add(IO_FRAMEBUFFER, dev);
+
+ fb_map_buffer(virtual_kernel_dir());
}