summaryrefslogtreecommitdiff
path: root/src/kernel/panic.c
diff options
context:
space:
mode:
authorBrett Weiland <brett_weiland@bpcspace.com>2021-04-18 16:00:17 -0500
committerBrett Weiland <brett_weiland@bpcspace.com>2021-04-18 16:00:17 -0500
commit774e3796b252383aafb8b3f30d51a19400c74516 (patch)
tree20ad93c125d4f6bad755e6a898ddb4259818b4fa /src/kernel/panic.c
parentf0602964daa20ad9cd05f097b943c8edbf2df2e2 (diff)
modified: src/bootloader/bios_functions/bios_disk.asm
modified: src/bootloader/bootloader.asm new file: src/include/kernel.h modified: src/include/libc.h modified: src/include/paging.h new file: src/include/panic.h modified: src/kernel/kernel.c modified: src/kernel/libc.c modified: src/kernel/page.c new file: src/kernel/panic.c modified: src/link.ld modified: src/makefile modified: tools/page/page.py
Diffstat (limited to 'src/kernel/panic.c')
-rw-r--r--src/kernel/panic.c54
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(;;);
+
+}