vulcanos/kernel/cpu/assert.c

31 lines
909 B
C
Raw Normal View History

2019-09-19 12:04:12 +02:00
#include "assert.h"
// We panic when we find a critical error, this function is called by assert macro
extern void panic(const char *message, const char *file, uint32_t line) {
asm volatile("cli"); // Disable interrupts
2019-09-24 12:39:05 +02:00
kprint((uint8_t*)"PANIC(");
kprint((uint8_t*)message);
kprint((uint8_t*)") at ");
kprint((uint8_t*)file);
kprint((uint8_t*)":");
2019-09-19 12:04:12 +02:00
kprint_dec(line);
2019-09-24 12:39:05 +02:00
kprint((uint8_t*)"\n");
2019-09-19 12:04:12 +02:00
// Now hang on for ever
for(;;);
}
// Check for assertion failed, this function call by assert macro
extern void panic_assert(const char *file, uint32_t line, const char *desc) {
asm volatile("cli"); // Disable interrupts
2019-09-24 12:39:05 +02:00
kprint((uint8_t*)"ASSERTION-FAILED(");
kprint((uint8_t*)desc);
kprint((uint8_t*)") at ");
kprint((uint8_t*)file);
kprint((uint8_t*)":");
2019-09-19 12:04:12 +02:00
kprint_dec(line);
2019-09-24 12:39:05 +02:00
kprint((uint8_t*)"\n");
2019-09-19 12:04:12 +02:00
// Now hang on forever
for(;;);
}