runtime, interrupt: print to screen on errors, print CR2 on panic
CR2 is the last accessed address set on page exceptions
This commit is contained in:
@ -27,17 +27,19 @@ noreturn void __Panic_HaltSystem();
|
||||
|
||||
// Panic() aborts the system after printing the message and some other information.
|
||||
noreturn inline static void Panic(const char *message) {
|
||||
io_Printf("Panic: %s\n", message);
|
||||
asm volatile("cli");
|
||||
io_Errorf("Panic: %s\n", message);
|
||||
__Panic_HaltSystem();
|
||||
}
|
||||
|
||||
// Panicf() aborts the system after printing the message using vsnprintf.
|
||||
noreturn inline static void Panicf(const char *fmt, ...) {
|
||||
asm volatile("cli");
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
int ret = vsnprintf(Buffer, HELOS_BUFFER_SIZE, fmt, args);
|
||||
va_end(args);
|
||||
io_Printf("Panic: %s\n", Buffer);
|
||||
io_Errorf("Panic: %s\n", Buffer);
|
||||
__Panic_HaltSystem();
|
||||
}
|
||||
|
||||
|
@ -46,10 +46,7 @@ void __io_WriteConsole_ResizeBuffer(int size) {
|
||||
}
|
||||
}
|
||||
|
||||
void io_WriteConsole(const char *str) {
|
||||
pic_serial_Write(&pic_serial_COM1, str, 0);
|
||||
|
||||
#ifndef HELOS_RUNTIME_QUIET
|
||||
static inline void __io_WriteConsoleUTF8(const char *str) {
|
||||
int size = 0; // don't include the \0 at the end here
|
||||
int len = strlen(str); // left the \0 out here too
|
||||
|
||||
@ -71,13 +68,9 @@ void io_WriteConsole(const char *str) {
|
||||
} else {
|
||||
console_WriteUTF16(&HelosGraphics_Color_White, __io_WriteConsole_buffer, 0);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void io_WriteConsoleASCII(const char *str) {
|
||||
pic_serial_Write(&pic_serial_COM1, str, 0);
|
||||
|
||||
#ifndef HELOS_RUNTIME_QUIET
|
||||
static inline void __io_WriteConsoleASCII(const char *str) {
|
||||
if (!graphics_Framebuffer) {
|
||||
int len = strlen(str);
|
||||
__io_WriteConsole_ResizeBuffer(len + 1);
|
||||
@ -87,6 +80,19 @@ void io_WriteConsoleASCII(const char *str) {
|
||||
} else {
|
||||
console_WriteASCII(&HelosGraphics_Color_White, str, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void io_WriteConsole(const char *str) {
|
||||
pic_serial_Write(&pic_serial_COM1, str, 0);
|
||||
#ifndef HELOS_RUNTIME_QUIET
|
||||
__io_WriteConsoleUTF8(str);
|
||||
#endif
|
||||
}
|
||||
|
||||
void io_WriteConsoleASCII(const char *str) {
|
||||
pic_serial_Write(&pic_serial_COM1, str, 0);
|
||||
#ifndef HELOS_RUNTIME_QUIET
|
||||
__io_WriteConsoleASCII(str);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -104,3 +110,26 @@ int io_Printf(const char *fmt, ...) {
|
||||
INTERRUPT_RESTORE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void io_Error(const char *str) {
|
||||
pic_serial_Write(&pic_serial_COM1, str, 0);
|
||||
__io_WriteConsoleUTF8(str);
|
||||
}
|
||||
|
||||
void io_ErrorASCII(const char *str) {
|
||||
pic_serial_Write(&pic_serial_COM1, str, 0);
|
||||
__io_WriteConsoleASCII(str);
|
||||
}
|
||||
|
||||
int io_Errorf(const char *fmt, ...) {
|
||||
INTERRUPT_DISABLE;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
int ret = vsnprintf(__io_Printf_buffer, sizeof(__io_Printf_buffer), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
io_Error(__io_Printf_buffer);
|
||||
|
||||
INTERRUPT_RESTORE;
|
||||
return ret;
|
||||
}
|
||||
|
@ -20,6 +20,11 @@ void io_WriteConsoleASCII(const char *str);
|
||||
// io_Printf is a printf() replacement, printing to WriteConsole function.
|
||||
int io_Printf(const char *format, ...);
|
||||
|
||||
// io_Error prints error information directly to the screen.
|
||||
void io_Error(const char *str);
|
||||
void io_ErrorASCII(const char *str);
|
||||
int io_Errorf(const char *format, ...);
|
||||
|
||||
|
||||
// Debugging printing marcos
|
||||
#ifndef NDEBUG
|
||||
|
Reference in New Issue
Block a user