summaryrefslogtreecommitdiff
path: root/src/kernel/panic.c
blob: 851684a0675d6a7ee3d842bd623400f2c9830dd3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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(;;);

}