diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/amd64/amd64/proc_machdep.c | 14 | ||||
-rw-r--r-- | sys/include/sys/exec.h | 1 |
2 files changed, 15 insertions, 0 deletions
diff --git a/sys/arch/amd64/amd64/proc_machdep.c b/sys/arch/amd64/amd64/proc_machdep.c index 7609379..ee38f21 100644 --- a/sys/arch/amd64/amd64/proc_machdep.c +++ b/sys/arch/amd64/amd64/proc_machdep.c @@ -38,6 +38,20 @@ #include <vm/map.h> #include <string.h> +void +setregs(struct proc *td, struct exec_prog *prog, uintptr_t stack) +{ + struct trapframe *tfp = &td->tf; + struct auxval *auxvalp = &prog->auxval; + + memset(tfp, 0, sizeof(*tfp)); + tfp->rip = auxvalp->at_entry; + tfp->cs = USER_CS | 3; + tfp->ss = USER_DS | 3; + tfp->rsp = stack; + tfp->rflags = 0x202; +} + /* * MD thread init code * diff --git a/sys/include/sys/exec.h b/sys/include/sys/exec.h index 1291479..4910ff2 100644 --- a/sys/include/sys/exec.h +++ b/sys/include/sys/exec.h @@ -58,6 +58,7 @@ struct exec_prog { int elf64_load(const char *pathname, struct proc *td, struct exec_prog *prog); void elf_unload(struct proc *td, struct exec_prog *prog); +void setregs(struct proc *td, struct exec_prog *prog, uintptr_t stack); #endif /* _KERNEL */ #endif /* !_SYS_EXEC_H_ */ |