Kernel: Syscalls now get the interrupt stack

This commit is contained in:
Bananymous 2023-07-21 11:01:19 +03:00
parent 5411c5aa4a
commit 2db7cdb71e
3 changed files with 24 additions and 1 deletions

View File

@ -163,7 +163,11 @@ syscall_asm:
movq %rax, %rdi
movq %rbx, %rsi
xchgq %rcx, %rdx
movq %rsp, %rbx
addq $120, %rbx
pushq %rbx
call cpp_syscall_handler
addq $8, %rsp
popaq_no_rax
addq $8, %rsp
iretq

View File

@ -0,0 +1,17 @@
#pragma once
#include <stdint.h>
namespace Kernel
{
struct InterruptStack
{
uint64_t rip;
uint64_t cs;
uint64_t flags;
uint64_t rsp;
uint64_t ss;
};
}

View File

@ -1,4 +1,5 @@
#include <kernel/Debug.h>
#include <kernel/InterruptStack.h>
#include <kernel/Process.h>
#include <kernel/Syscall.h>
@ -17,7 +18,7 @@ namespace Kernel
extern "C" long sys_fork_trampoline();
extern "C" long cpp_syscall_handler(int syscall, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3, uintptr_t arg4, uintptr_t arg5)
extern "C" long cpp_syscall_handler(int syscall, uintptr_t arg1, uintptr_t arg2, uintptr_t arg3, uintptr_t arg4, uintptr_t arg5, InterruptStack& interrupt_stack)
{
Thread::current().set_in_syscall(true);
@ -28,6 +29,7 @@ namespace Kernel
(void)arg3;
(void)arg4;
(void)arg5;
(void)interrupt_stack;
BAN::ErrorOr<long> ret = BAN::Error::from_errno(ENOSYS);