diff options
author | Ian Moffett <ian@osmora.org> | 2024-03-14 20:55:54 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-03-14 20:55:54 -0400 |
commit | 7a32267fcc81af31d595373884911d503b0a9df8 (patch) | |
tree | 31c3393499f598d74c47fc8b3479c5782100b93a /sys/kern/kern_sched.c | |
parent | 5a8915f5b36cf3b21c843ef7959c24ac39318aca (diff) |
kernel: sched: Keep track of stack and privilege
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/kern/kern_sched.c')
-rw-r--r-- | sys/kern/kern_sched.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/sys/kern/kern_sched.c b/sys/kern/kern_sched.c index bc96146..f985f62 100644 --- a/sys/kern/kern_sched.c +++ b/sys/kern/kern_sched.c @@ -208,7 +208,7 @@ sched_init_stack(void *stack_top, char *argvp[], char *envp[], struct auxval aux static uintptr_t sched_create_stack(struct vas vas, bool user, char *argvp[], - char *envp[], struct auxval auxv) + char *envp[], struct auxval auxv, struct proc *td) { int status; uintptr_t stack; @@ -216,10 +216,12 @@ sched_create_stack(struct vas vas, bool user, char *argvp[], if (!user) { stack = (uintptr_t)dynalloc(STACK_SIZE); + td->stack_base = (uintptr_t)stack; return sched_init_stack((void *)(stack + STACK_SIZE), argvp, envp, auxv); } stack = vm_alloc_pageframe(STACK_PAGES); + td->stack_base = stack; status = vm_map_create(vas, stack, stack, USER_STACK_PROT, STACK_SIZE); if (status != 0) { @@ -244,16 +246,17 @@ sched_create_td(uintptr_t rip, char *argvp[], char *envp[], struct auxval auxv, return NULL; } - stack = sched_create_stack(vas, is_user, argvp, envp, auxv); - if (stack == 0) { + td = dynalloc(sizeof(struct proc)); + if (td == NULL) { + /* TODO: Free stack */ dynfree(tf); return NULL; } - td = dynalloc(sizeof(struct proc)); - if (td == NULL) { - /* TODO: Free stack */ + stack = sched_create_stack(vas, is_user, argvp, envp, auxv, td); + if (stack == 0) { dynfree(tf); + dynfree(td); return NULL; } @@ -265,6 +268,7 @@ sched_create_td(uintptr_t rip, char *argvp[], char *envp[], struct auxval auxv, td->cpu = NULL; /* Not yet assigned a core */ td->tf = tf; td->addrsp = vas; + td->is_user = is_user; processor_init_pcb(td); /* Setup trapframe */ |