diff options
author | Ian Moffett <ian@osmora.org> | 2024-06-30 23:49:05 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-06-30 23:49:05 -0400 |
commit | 582ed742216fd87bb3f4103d795dca19e3357ff4 (patch) | |
tree | 4e9dbb560cd2b0ffdae610a1eb6a1e9672da8c08 /sys/arch | |
parent | 974d7ce527c9220fcdad44b27b4a2b44054502c2 (diff) |
kernel/amd64: proc: Add setregs()
This function will be useful for things like exec in order to setup
registers which are machine dependent.
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/amd64/proc_machdep.c | 14 |
1 files changed, 14 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 * |