diff options
author | Marvin Borner | 2020-04-29 23:26:51 +0200 |
---|---|---|
committer | Marvin Borner | 2020-04-29 23:26:51 +0200 |
commit | 8b52d7698e4a9a5abaf730c7da1c4f865cb78f8e (patch) | |
tree | 873f2ae99b369f4db809fe1cd2684ae0e60c6144 /src | |
parent | 0f54f0de1004c6e9a455c295dc76879ac37a408f (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/kernel/memory/paging.c | 6 | ||||
-rw-r--r-- | src/kernel/syscall/actions/sys_pointers.c | 2 | ||||
-rw-r--r-- | src/kernel/tasks/process.c | 3 | ||||
-rw-r--r-- | src/userspace/libgui/draw.c | 1 | ||||
-rw-r--r-- | src/userspace/libgui/init.c | 8 | ||||
-rw-r--r-- | src/userspace/programs/init.c | 11 |
6 files changed, 15 insertions, 16 deletions
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++; diff --git a/src/userspace/libgui/draw.c b/src/userspace/libgui/draw.c index adcdec2..ee35d3c 100644 --- a/src/userspace/libgui/draw.c +++ b/src/userspace/libgui/draw.c @@ -1,4 +1,5 @@ #include <stdint.h> +#include <stdio.h> #include <gui.h> void gui_draw_rectangle(int x1, int y1, int x2, int y2, const u32 color[3]) diff --git a/src/userspace/libgui/init.c b/src/userspace/libgui/init.c index 7cd1fc3..04d7ac3 100644 --- a/src/userspace/libgui/init.c +++ b/src/userspace/libgui/init.c @@ -1,4 +1,5 @@ #include <stdint.h> +#include <stdio.h> #include <syscall.h> #include <gui.h> @@ -11,12 +12,15 @@ void gui_init() { pointers = syscall_pointers(); - return; // TODO: Fix GUI page fault vbe_width = pointers->mode_info->width; vbe_height = pointers->mode_info->height; vbe_pitch = pointers->mode_info->pitch; vbe_bpl = pointers->mode_info->bpp >> 3; - fb = pointers->mode_info->framebuffer; + + // TODO: Why tf is the kheap magic stored in the first few bytes?! + fb = (pointers->mode_info->framebuffer << 16); gui_screen_clear(); + printf("%dx%dx%d\n", vbe_width, vbe_height, vbe_bpl << 3); + printf("0x%x\n", fb); }
\ No newline at end of file diff --git a/src/userspace/programs/init.c b/src/userspace/programs/init.c index a669249..3c1d51f 100644 --- a/src/userspace/programs/init.c +++ b/src/userspace/programs/init.c @@ -5,14 +5,9 @@ void main() { - u32 *buf = malloc(4096); - for (int i = 0; i < 4; i++) - buf[i] = 42; - syscall_halt(); - - //printf("Initializing userspace...\n"); - //gui_init(); - //syscall_exec("/bin/sh"); + printf("Initializing userspace...\n"); + gui_init(); + syscall_exec("/bin/sh"); while (1) { }; |