summaryrefslogtreecommitdiff
path: root/src/kernel/arch/i386/sysenter.s
diff options
context:
space:
mode:
authordzwdz2021-07-21 21:35:20 +0200
committerdzwdz2021-07-21 21:35:20 +0200
commit8a168f2be5d90f972975abf0b40145a75c0231b7 (patch)
treecdfcd84a132a6a9864b01b626cc670e9caf7c4ef /src/kernel/arch/i386/sysenter.s
parent36089d20ca1f7c57f36c4172759a5084bdf87a3a (diff)
syscall parameter & return value passing
Sadly, sysenter on i386 limits me to only 4 arguments (so, 1 for the syscall id + 3 real args). If that turns out to be an issue I'll either just switch to interrupts, or switch to x64.
Diffstat (limited to 'src/kernel/arch/i386/sysenter.s')
-rw-r--r--src/kernel/arch/i386/sysenter.s9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/kernel/arch/i386/sysenter.s b/src/kernel/arch/i386/sysenter.s
index 3fcd4c3..7375e06 100644
--- a/src/kernel/arch/i386/sysenter.s
+++ b/src/kernel/arch/i386/sysenter.s
@@ -49,6 +49,10 @@ sysenter_setup:
sysenter_handler:
pushal
+ push %edi
+ push %esi
+ push %ebx
+ push %eax
mov %cr0, %eax
and $0x7FFFFFFF, %eax // disable paging
@@ -56,9 +60,14 @@ sysenter_handler:
call syscall_handler
+ // save the return value
+ mov %eax, 44(%esp) // 16 [top of eflags] + 7*4 [skip until EAX]
+ mov %edx, 32(%esp) // 16 + 4*4 [skip until EBX]
+
mov %cr0, %eax
or $0x80000000, %eax // enable paging
mov %eax, %cr0
+ add $16, %esp
popal
sysexit