aboutsummaryrefslogtreecommitdiff
path: root/kernel/drivers
diff options
context:
space:
mode:
authorMarvin Borner2021-04-29 23:59:48 +0200
committerMarvin Borner2021-04-29 23:59:48 +0200
commit3a3d50d7eb0f4fdbb9beaf16bacfa98689cc448c (patch)
treed837ed9ed9470a20b66b28b6083d30865d7e6016 /kernel/drivers
parentf8e47b6b0c0578c52d82c0e243620361b87a4abe (diff)
Alright!
Diffstat (limited to 'kernel/drivers')
-rw-r--r--kernel/drivers/fb.c33
-rw-r--r--kernel/drivers/gdt.c4
-rw-r--r--kernel/drivers/ps2/mouse.c1
3 files changed, 20 insertions, 18 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());
}
diff --git a/kernel/drivers/gdt.c b/kernel/drivers/gdt.c
index 73db111..66a9086 100644
--- a/kernel/drivers/gdt.c
+++ b/kernel/drivers/gdt.c
@@ -56,7 +56,7 @@ void tss_set_stack(u32 ss, u32 esp)
tss.ss0 = ss;
}
-CLEAR void gdt_install(void)
+CLEAR void gdt_install(u32 esp)
{
// Set GDT pointer and limit
gp.limit = (sizeof(struct gdt_entry) * 6) - 1;
@@ -78,7 +78,7 @@ CLEAR void gdt_install(void)
gdt_set_gate(4, 0, 0xffffffff, 0xf2, 0xcf);
// Write TSS
- tss_write(5, GDT_SUPER_DATA_OFFSET, STACK_START);
+ tss_write(5, GDT_SUPER_DATA_OFFSET, esp);
// Remove old GDT and install the new changes!
gdt_flush();
diff --git a/kernel/drivers/ps2/mouse.c b/kernel/drivers/ps2/mouse.c
index 7748c99..abca0a8 100644
--- a/kernel/drivers/ps2/mouse.c
+++ b/kernel/drivers/ps2/mouse.c
@@ -1,7 +1,6 @@
// MIT License, Copyright (c) 2020 Marvin Borner
#include <assert.h>
-#include <boot.h>
#include <cpu.h>
#include <errno.h>
#include <interrupts.h>