[USER] Load and run ELF module in userspace

This commit is contained in:
2016-11-29 09:16:04 +01:00
parent aa50bbcd0f
commit 63b3c3f2c0
11 changed files with 163 additions and 21 deletions

View File

@@ -7,15 +7,8 @@
#include <cpu.h>
#include <timer.h>
#include <string.h>
void thread_function()
{
int i = 0;
while(1)
{
i++;
}
}
#include <cpu.h>
#include <elf.h>
int kmain(uint64_t multiboot_magic, void *multiboot_data)
{
@@ -32,18 +25,11 @@ int kmain(uint64_t multiboot_magic, void *multiboot_data)
pit_init();
process_t *p1 = process_spawn(0);
uint64_t addr = 0x200000;
thread_t *th = new_thread((void *)addr, 1);
// Write thread code to address
procmm_map(p1->mmap, addr, addr+PAGE_SIZE, 0);
vmm_p4_memcpy(p1->mmap->P4, (void *)addr, 0, thread_function, PAGE_SIZE);
procmm_setup(p1);
thread_t *th = exec_elf(p1, mboot_data.init);
scheduler_insert(th);
procmm_print_map(p1->mmap);
process_attach(p1, th);
scheduler_insert(th);
asm("sti");
debug_info("BOOT COMPLETE\n");