diff options
Diffstat (limited to 'src/kernel/panic.c')
-rw-r--r-- | src/kernel/panic.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/kernel/panic.c b/src/kernel/panic.c new file mode 100644 index 0000000..851684a --- /dev/null +++ b/src/kernel/panic.c @@ -0,0 +1,54 @@ +#include <panic.h> +#include <stdint.h> +#include <printf.h> + +void panic(int reason, int type) { // will fill with debugging info latter + + struct stack_frame *frame; + +#ifdef EASTEREGG_BLOATWARE + printf("Kernel PANIC!!!!!!!\n"); + printf( +" _.-^^---....,,-- \n" +" _-- --_ \n" +"< >)\n" +"| BOOM | <------- your computer\n" +" \\._ _./ \n" +" ```--. . , ; .--''' \n" +" | | | \n" +" .-=|| | |=-. \n" +" `-=#$%&%$#=-' \n" +" | ; :| \n" +" _____.,-#%&$@%#&#~,._____\n"); +#else + printf("Kernel Panic!\n"); +#endif + + printf("Reason:\n"); + + switch(reason) { + case KERNEL_PANIC_PMAPSIZE : + printf("\tThe physical map can't fit in the first memory zone.\n" + "\tNote: If you have this issue, please contact me.\n" + "\tIt's a fixable bug caused by an unlikely scenario.\n"); + break; + case KERNEL_PANIC_RSDP_UNFOUND: + printf("\tRSDP unfound!\n"); + break; + case KERNEL_PANIC_KERNEL_RETURNED: + printf("\tThe kernel (almost) reached its return!\n"); + break; + } + printf("\nStack trace:\n"); + + asm("mov %%rbp,%0" : "=r"(frame) ::); + + for(; frame->next != 0; frame = frame->next) { + printf("\t%x\n", frame->function_base); + } + + //It's not public yet, but it will be + printf("\nAfter ensuring your computer meets the requirements specified, if you think this is a bug, please open an issue on the git repo or email me at %s.\n", DEV_EMAIL); + for(;;); + +} |