summaryrefslogtreecommitdiff
path: root/src/kernel/arch/i386/sysenter.c
diff options
context:
space:
mode:
authordzwdz2021-07-24 16:55:15 +0200
committerdzwdz2021-07-24 16:55:15 +0200
commit4d5e930c48cded790f77497911706aa8f5ff0965 (patch)
treeb256d379f5841d28a74fb28b6d01720cb14a5878 /src/kernel/arch/i386/sysenter.c
parent67a359d8c4b9f5cb3d2e1fb9602ebe5dfd3978cf (diff)
save all registers on syscalls
Diffstat (limited to 'src/kernel/arch/i386/sysenter.c')
-rw-r--r--src/kernel/arch/i386/sysenter.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/kernel/arch/i386/sysenter.c b/src/kernel/arch/i386/sysenter.c
new file mode 100644
index 0000000..91dac2e
--- /dev/null
+++ b/src/kernel/arch/i386/sysenter.c
@@ -0,0 +1,27 @@
+#include <kernel/arch/generic.h>
+#include <kernel/proc.h>
+
+void sysenter_stage2(int edi, int esi, void *ebp, void *esp,
+ int ebx, int edx, int ecx, int eax)
+{
+ uint64_t val;
+ process_current->regs = (struct registers) {
+ // EAX and EDX will get overriden with the return value later on
+
+ .eax = eax,
+ .ecx = ecx,
+ .edx = edx,
+ .ebx = ebx,
+ .esi = esi,
+ .edi = edi,
+
+ .esp = (void*) ecx, // not a typo, part of my calling convention
+ .eip = (void*) edx, // ^
+ .ebp = ebp,
+ };
+
+ val = syscall_handler(eax, ebx, esi, edi);
+ regs_savereturn(&process_current->regs, val);
+
+ process_switch(process_current); // TODO process_resume
+}