Complete (almost!) printf fmt support
[lunaix-os.git] / lunaix-os / kernel / spike.c
1 #include <lunaix/spike.h>
2 #include <arch/x86/interrupts.h>
3 #include <libc/stdio.h>
4
5 static char buffer[1024];
6
7 void __assert_fail(const char* expr, const char* file, unsigned int line) {
8     sprintf(buffer, "Assert %s failed (%s:%u)", expr, file, line);
9
10     // Here we load the buffer's address into %edi ("D" constraint)
11     //  This is a convention we made that the LUNAIX_SYS_PANIC syscall will
12     //  print the panic message passed via %edi. (see kernel/asm/x86/interrupts.c)
13     asm(
14         "int %0"
15         ::"i"(LUNAIX_SYS_PANIC), "D"(buffer)
16     );
17
18     spin();     // never reach
19 }