proc: enter into userspace
Signed-off-by: Michael Shaw <m@michaelsshaw.com>
This commit is contained in:
parent
1a8061e3b3
commit
cd916f624b
12 changed files with 138 additions and 29 deletions
|
|
@ -1,3 +1,4 @@
|
|||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
obj-y += atomic.o
|
||||
obj-y += spinlock.o
|
||||
obj-y += proc.o
|
||||
|
|
|
|||
|
|
@ -9,12 +9,37 @@ struct cpu_local *tls_get()
|
|||
return (void *)rdmsr(IA32_GS_BASE);
|
||||
}
|
||||
|
||||
struct proc *get_cur_proc()
|
||||
struct thread *get_cur_thread()
|
||||
{
|
||||
struct cpu_local *l = tls_get();
|
||||
if (!l)
|
||||
return NULL;
|
||||
if (!l->cur_thread)
|
||||
return NULL;
|
||||
return l->cur_thread->proc;
|
||||
return l->cur_thread;
|
||||
}
|
||||
|
||||
struct proc *get_cur_proc()
|
||||
{
|
||||
struct thread *t = get_cur_thread();
|
||||
if (!t)
|
||||
return NULL;
|
||||
return t->proc;
|
||||
}
|
||||
|
||||
/* the thread that calls this will be lost, so it should only be called
|
||||
* on the initial process, and while doing an exec
|
||||
*/
|
||||
void enter_userspace_init(struct thread *thread, uaddr_t entry)
|
||||
{
|
||||
struct cpu_local *tls = tls_get();
|
||||
|
||||
tls->cur_thread = thread;
|
||||
|
||||
pgd_load(thread->proc->pgd);
|
||||
|
||||
thread->state = PROC_STATE_RUNNING;
|
||||
|
||||
void _enter_userspace_init(uaddr_t entry, u64 flags, uaddr_t stack_top);
|
||||
_enter_userspace_init(entry, 0x202, thread->stack_addr);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue