From 8b52d7698e4a9a5abaf730c7da1c4f865cb78f8e Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Wed, 29 Apr 2020 23:26:51 +0200 Subject: Working framebuffer from userspace... Well, it doesn't actually work. I disabled several security measures to get this working and I'll try to fix these soon. --- src/kernel/memory/paging.c | 6 +++--- src/kernel/syscall/actions/sys_pointers.c | 2 +- src/kernel/tasks/process.c | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'src/kernel') diff --git a/src/kernel/memory/paging.c b/src/kernel/memory/paging.c index 19ec11d..add400e 100644 --- a/src/kernel/memory/paging.c +++ b/src/kernel/memory/paging.c @@ -88,11 +88,12 @@ void paging_map(struct page_directory *dir, uint32_t phys, uint32_t virt) short id = virt >> 22; struct page_table *tab = paging_make_table(); - dir->tables[id] = ((struct page_table *)((uint32_t)tab | 3)); // RW + dir->tables[id] = ((struct page_table *)((uint32_t)tab | 3 | 4)); // RW for (int i = 0; i < 1024; i++) { tab->pages[i].frame = phys >> 12; tab->pages[i].present = 1; + tab->pages[i].user = 1; // TODO: Remove all-user paging! phys += 4096; } } @@ -104,8 +105,7 @@ void paging_map_user(struct page_directory *dir, uint32_t phys, uint32_t virt) dir->tables[id] = ((struct page_table *)((uint32_t)tab | 3 | 4)); // RW + usermode - int i; - for (i = 0; i < 1024; i++) { + for (int i = 0; i < 1024; i++) { tab->pages[i].frame = phys >> 12; tab->pages[i].present = 1; tab->pages[i].user = 1; diff --git a/src/kernel/syscall/actions/sys_pointers.c b/src/kernel/syscall/actions/sys_pointers.c index 6cf50ae..1a9a5cf 100644 --- a/src/kernel/syscall/actions/sys_pointers.c +++ b/src/kernel/syscall/actions/sys_pointers.c @@ -12,7 +12,7 @@ struct pointers { uint32_t sys_pointers() { - struct pointers *pointers = umalloc(sizeof(struct pointers)); + struct pointers *pointers = umalloc(sizeof(struct vbe_mode_info) + sizeof(struct font)); pointers->current_mode_info = current_mode_info; pointers->font = font; diff --git a/src/kernel/tasks/process.c b/src/kernel/tasks/process.c index a3bb8d0..87a6ec9 100644 --- a/src/kernel/tasks/process.c +++ b/src/kernel/tasks/process.c @@ -197,8 +197,7 @@ struct process *process_make_new() proc->brk = 0x50000000; - int i; - for (i = 0; i < 1024; i++) + for (int i = 0; i < 1024; i++) proc->cr3->tables[i] = paging_root_directory->tables[i]; proc->pid = pid++; -- cgit v1.2.3