]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
refactor: move syscall_init arch dispatch to arch/x86/sysenter_init.c
authorTulio A M Mendes <[email protected]>
Fri, 13 Feb 2026 19:48:51 +0000 (16:48 -0300)
committerTulio A M Mendes <[email protected]>
Fri, 13 Feb 2026 19:48:51 +0000 (16:48 -0300)
- Add arch_syscall_init() that registers INT 0x80 handler and calls x86_sysenter_init()
- syscall_init() now just calls arch_syscall_init() — zero #ifdef in syscall.c
- x86_sysenter_init() made static (internal to sysenter_init.c)
- syscall.c contains ZERO architecture-specific code or #ifdefs

20/20 smoke, cppcheck clean

include/arch_syscall.h
src/arch/x86/sysenter_init.c
src/kernel/syscall.c

index 2e23c02afe96331f82ac5a3e8343cd95fcced934..0ff3b7817b608ddc7bc600d7ff9d33e6b9a79c5a 100644 (file)
@@ -42,4 +42,11 @@ extern uint32_t __arch_syscall_stub_sink;
 
 #endif
 
+/*
+ * arch_syscall_init — Register the syscall entry point(s) for this
+ *                     architecture (e.g. INT 0x80 + SYSENTER on x86).
+ *                     Called once from the generic syscall_init().
+ */
+void arch_syscall_init(void);
+
 #endif /* ARCH_SYSCALL_H */
index 942c261cc168b8b1473493c438e0735e4c3a9b1e..f983731ecb873469edea9486fa25c796c23b4e67 100644 (file)
@@ -1,4 +1,5 @@
 #include "hal/cpu_features.h"
+#include "interrupts.h"
 #include "console.h"
 
 #include <stdint.h>
@@ -29,7 +30,17 @@ static inline uint64_t rdmsr(uint32_t msr) {
 static uint8_t sysenter_stack[4096] __attribute__((aligned(16)));
 static int sysenter_enabled = 0;
 
-void x86_sysenter_init(void) {
+static void x86_sysenter_init(void);
+
+/* Generic syscall_handler defined in src/kernel/syscall.c */
+extern void syscall_handler(struct registers*);
+
+void arch_syscall_init(void) {
+    register_interrupt_handler(128, syscall_handler);
+    x86_sysenter_init();
+}
+
+static void x86_sysenter_init(void) {
     const struct cpu_features* f = hal_cpu_get_features();
     if (!f->has_sysenter) {
         kprintf("[SYSENTER] CPU does not support SYSENTER/SYSEXIT.\n");
index 8c92023bc9bf945f64797032785a4f454689b0ad..5ab2e7f0e5e44e9671f1264afaf046b2095175a2 100644 (file)
@@ -16,9 +16,6 @@
 #include "shm.h"
 #include "socket.h"
 
-#if defined(__i386__)
-extern void x86_sysenter_init(void);
-#endif
 #include "elf.h"
 #include "stat.h"
 #include "vmm.h"
@@ -2763,8 +2760,5 @@ static void socket_syscall_dispatch(struct registers* regs, uint32_t syscall_no)
 }
 
 void syscall_init(void) {
-#if defined(__i386__)
-    register_interrupt_handler(128, syscall_handler);
-    x86_sysenter_init();
-#endif
+    arch_syscall_init();
 }