summaryrefslogtreecommitdiff
path: root/src/kernel/arch/amd64/sysenter.c
blob: 2f83e3d0423c519eddba89f5e7acf63528f29039 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <camellia/syscalls.h>
#include <kernel/arch/amd64/sysenter.h>
#include <kernel/arch/generic.h>
#include <kernel/proc.h>
#include <shared/mem.h>

SysexitRegs _sysexit_regs;

_Noreturn void sysexit(UserRegs *regs, char sse[512]) {
	_sysexit_regs.u = *regs;
	memcpy(_sysexit_regs.sse, sse, 512);
	_sysexit_real();
}

_Noreturn void sysenter_stage2(void) {
	UserRegs *regs = &proc_cur->regs;
	*regs = _sysexit_regs.u;
	memcpy(proc_cur->sse, _sysexit_regs.sse, 512);
	_syscall(regs->rdi, regs->rsi, regs->rdx, regs->r10, regs->r8, regs->r9);
	proc_switch_any();
}