5-malloc.md (#25)
[lunaix-os.git] / lunaix-os / kernel / spike.c
index 4686b12ce3667f3b51f26ae609b78a0acf246a1c..ad751e137a32bd1ed6bb964baeb26baaa831a7e5 100644 (file)
@@ -1,10 +1,10 @@
-#include <arch/x86/interrupts.h>
-#include <klibc/stdio.h>
+#include <klibc/strfmt.h>
 #include <lunaix/spike.h>
+#include <lunaix/pcontext.h>
 
 static char buffer[1024];
 
-void
+void noret
 __assert_fail(const char* expr, const char* file, unsigned int line)
 {
     ksprintf(buffer, "%s (%s:%u)", expr, file, line);
@@ -13,16 +13,16 @@ __assert_fail(const char* expr, const char* file, unsigned int line)
     //  This is a convention we made that the LUNAIX_SYS_PANIC syscall will
     //  print the panic message passed via %edi. (see
     //  kernel/asm/x86/interrupts.c)
-    asm("int %0" ::"i"(LUNAIX_SYS_PANIC), "D"(buffer));
+    cpu_trap_panic(buffer);
 
-    DO_SPIN // never reach
+    spin(); // never reach
 }
 
-void
+void noret
 panick(const char* msg)
 {
-    asm("int %0" ::"i"(LUNAIX_SYS_PANIC), "D"(msg));
-    DO_SPIN
+    cpu_trap_panic(msg);
+    spin();
 }
 
 void
@@ -30,9 +30,9 @@ panickf(const char* fmt, ...)
 {
     va_list args;
     va_start(args, fmt);
-    __ksprintf_internal(buffer, fmt, 1024, args);
+    ksnprintfv(buffer, fmt, 1024, args);
     va_end(args);
 
     asm("int %0" ::"i"(LUNAIX_SYS_PANIC), "D"(buffer));
-    DO_SPIN
+    spin();
 }