summaryrefslogtreecommitdiff
path: root/kernel/cpu/syscall.c
diff options
context:
space:
mode:
authorAnton Kling <anton@kling.gg>2024-02-22 17:28:08 +0100
committerAnton Kling <anton@kling.gg>2024-02-22 17:28:55 +0100
commita18da25e7355979d0f26cfd39dc0032172e8b135 (patch)
tree2af66bedd0dff4bbccffc8d82cd06836d7f68e0d /kernel/cpu/syscall.c
parent9b475d3db3275d4c34f02161ae70ced5595a0fdb (diff)
Kernel: Fix undefined behavior and cleanup functions.
The int_syscall caused crashes for higher level of optimizations. To fix this I rewrote the function in assembly as I deemed it to be simpler.
Diffstat (limited to 'kernel/cpu/syscall.c')
-rw-r--r--kernel/cpu/syscall.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/kernel/cpu/syscall.c b/kernel/cpu/syscall.c
index e2ea7e3..193367e 100644
--- a/kernel/cpu/syscall.c
+++ b/kernel/cpu/syscall.c
@@ -182,18 +182,13 @@ int (*syscall_functions[])() = {
(void(*))syscall_tmp_handle_packet,
};
+void int_syscall(reg_t *r);
void syscall_function_handler(u32 eax, u32 arg1, u32 arg2, u32 arg3, u32 arg4,
u32 arg5, u32 ebp, u32 esp) {
assert(eax < sizeof(syscall_functions) / sizeof(syscall_functions[0]));
syscall_functions[eax](arg1, arg2, arg3, arg4, arg5);
}
-void int_syscall(reg_t *r) {
- u32 syscall = r->eax;
- assert(syscall < sizeof(syscall_functions) / sizeof(syscall_functions[0]));
- r->eax = syscall_functions[syscall](r->ebx, r->ecx, r->edx, r->esi, r->edi);
-}
-
void syscalls_init(void) {
install_handler(int_syscall, INT_32_INTERRUPT_GATE(0x3), 0x80);
}