diff --git a/amd64/include/arch/proc.h b/amd64/include/arch/proc.h index 600ed67..bf7cf15 100644 --- a/amd64/include/arch/proc.h +++ b/amd64/include/arch/proc.h @@ -38,5 +38,6 @@ struct cpu_local *tls_get(); struct proc *get_cur_proc(); struct thread *get_cur_thread(); void enter_userspace_init(struct thread *thread, uaddr_t entry); +struct pt_regs *current_pt_regs(); #endif /* _ARCH_PROC_H_ */ diff --git a/amd64/syscall.c b/amd64/syscall.c index 6422f8c..ad7417d 100644 --- a/amd64/syscall.c +++ b/amd64/syscall.c @@ -2,6 +2,11 @@ #include #include +struct pt_regs *current_pt_regs() +{ + return (struct pt_regs *)(tls_get()->kernel_rsp - sizeof(struct pt_regs)); +} + static inline i64 _do_syscall(struct pt_regs *regs) { syscall_t c = get_syscall(regs->rax);