]> 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 2a6f8bb37cfbe4e066e77bc2ef74441925bc60f5..07cbe946ea3630f17d3c9065bce19eaf44898815 100644 (file)
@@ -51,4 +51,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 265e1bd79e57b422e4ece086f9d1c35ea0b4635c..01a688801525e0f94931f245e42e4620d26e2654 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include "hal/cpu_features.h"
+#include "interrupts.h"
 #include "console.h"
 
 #include <stdint.h>
@@ -38,7 +39,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 d554db704dc59823d23d8fdf0d611a12cc8831cd..6b1b9b4b12cc14af59d6b21beeff8fdc5331c11c 100644 (file)
@@ -25,9 +25,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"
@@ -2772,8 +2769,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();
 }