Add Userspace Addr Space notion

This commit is contained in:
Mathieu Maret 2022-08-07 23:14:26 +02:00
parent 0e11da855c
commit c59eb339e9
1 changed files with 8 additions and 7 deletions

View File

@ -4,12 +4,13 @@
#include "klibc.h" #include "klibc.h"
#include "list.h" #include "list.h"
#include "mmuContext.h" #include "mmuContext.h"
#include "uaddrspace.h"
struct process { struct process {
char name[PROCESS_NAME_MAX_LENGTH]; char name[PROCESS_NAME_MAX_LENGTH];
int ref; int ref;
int pid; int pid;
struct mmu_context *context; struct uAddrSpace *addrSpace;
struct thread *thList; struct thread *thList;
struct process *prev, *next; struct process *prev, *next;
@ -35,10 +36,9 @@ struct process *processCreate(char *name)
if (new == NULL) if (new == NULL)
return NULL; return NULL;
new->context = mmuContextCreate(); new->addrSpace = uAddrSpaceCreate(new);
if (new->context == NULL) { if(new->addrSpace == NULL){
free(new); free(new);
return NULL; return NULL;
} }
@ -103,6 +103,7 @@ int processRef(struct process *proc)
int processUnref(struct process *proc) int processUnref(struct process *proc)
{ {
uint32_t flags; uint32_t flags;
int ret;
assert(proc->ref > 0); assert(proc->ref > 0);
@ -116,10 +117,10 @@ int processUnref(struct process *proc)
list_delete(processList, proc); list_delete(processList, proc);
restore_IRQs(flags); restore_IRQs(flags);
mmuContextUnref(proc->context); ret = uAddrSpaceDelete(proc->addrSpace);
free(proc); free(proc);
return 0; return ret;
} }
int processAddThread(struct process *proc, struct thread *th) int processAddThread(struct process *proc, struct thread *th)
@ -164,5 +165,5 @@ int processSetName(struct process *proc, char *name)
struct mmu_context *processGetMMUContext(struct process *proc) struct mmu_context *processGetMMUContext(struct process *proc)
{ {
return proc->context; return uAddrSpaceGetMMUContext(proc->addrSpace);
} }