[USER] Load and run ELF module in userspace
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user