2024-10-18 08:45:37 -04:00
|
|
|
#include "alloc.h"
|
2024-09-22 03:54:56 -04:00
|
|
|
#include "debug.h"
|
|
|
|
#include "keyboard.h"
|
|
|
|
#include "kprintf.h"
|
2024-10-18 08:45:37 -04:00
|
|
|
#include "memory.h"
|
2024-09-22 03:54:56 -04:00
|
|
|
#include "power.h"
|
|
|
|
#include "terminal.h"
|
|
|
|
|
2024-10-18 08:45:37 -04:00
|
|
|
extern uint32_t page_table1[1024];
|
|
|
|
|
2024-09-22 03:54:56 -04:00
|
|
|
void kpanic(const char *format, ...)
|
|
|
|
{
|
|
|
|
va_list va;
|
|
|
|
|
2024-10-17 10:11:40 -04:00
|
|
|
/* terminal_set_bg_color(VGA_COLOR_BLUE); */
|
|
|
|
/* terminal_clear(); */
|
2024-09-22 03:54:56 -04:00
|
|
|
va_start(va, format);
|
2024-10-19 17:20:13 -04:00
|
|
|
kvprintf(format, &va);
|
2024-09-22 03:54:56 -04:00
|
|
|
va_end(va);
|
2024-11-18 09:12:46 -05:00
|
|
|
uint32_t faulting_address;
|
|
|
|
__asm__ __volatile__("mov %%cr2, %0" : "=r"(faulting_address));
|
|
|
|
kprintf("fault at address: %p\n", faulting_address);
|
2024-10-18 08:45:37 -04:00
|
|
|
/* for (int i = 16; i < 32; i++) */
|
|
|
|
/* kprintf("%p\n", page_table1[i]); */
|
2024-10-21 07:36:42 -04:00
|
|
|
/* show_valloc_mem(); */
|
2024-10-17 10:11:40 -04:00
|
|
|
/* kprintf("\n\n"); */
|
|
|
|
/* print_stack(); */
|
|
|
|
/* kprintf("\n\n"); */
|
|
|
|
/* kprintf("PRESS SPACE TO REBOOT"); */
|
2024-09-22 03:54:56 -04:00
|
|
|
while (terminal_getkey().scan_code != KEY_SPACE)
|
|
|
|
;
|
|
|
|
reboot();
|
2024-09-26 10:18:06 -04:00
|
|
|
}
|