user thread/process and elf loader stub

This commit is contained in:
Matheus
2022-08-13 23:16:34 -03:00
parent e7f4245c6d
commit 33a516a611
14 changed files with 399 additions and 7 deletions
+33
View File
@@ -7,6 +7,7 @@
#include <stdbool.h>
#include <limine.h>
#include <arch/cls.h>
#include <kernel/alloc.h>
vmm_cache* caches;
int klock;
@@ -489,6 +490,38 @@ bool vmm_dealwithrequest(void* addr){
}
void vmm_switchcontext(vmm_context* context){
arch_getcls()->context = context;
arch_mmu_switchcontext(context->context);
}
vmm_context* vmm_newcontext(){
vmm_context* context = alloc(sizeof(vmm_context));
if(!context)
return NULL;
vmm_mapping* map = allocatefirst(caches);
if(!map){
free(context);
return NULL;
}
context->context = arch_mmu_newcontext();
if(!context->context){
free(context);
freeentry(map);
return NULL;
}
map->start = USER_SPACE_START;
map->end = USER_SPACE_END;
context->userstart = map;
return context;
}
void vmm_init(){
printf("%lu mappings per cache\n", VMM_CACHE_ENTRY_COUNT);
caches = newcache();