panic.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* Copyright (C) 2021 Rain */
  2. /* This file is part of Cunix. */
  3. /*
  4. Cunix is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) and later version.
  8. */
  9. /*
  10. Cunix is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. */
  15. /*
  16. You should have received a copy of the GNU General Public License
  17. along with Cunix. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. #include <kernel/init.h>
  20. #include <kernel/types.h>
  21. #include <kernel/errno.h>
  22. #include <arch/sys.h>
  23. #include <modules/tty.h>
  24. void panic(char *s) {
  25. __uint64_t a, b, c;
  26. a = get_rax(); b = get_rcx(); c = get_rdx();
  27. printf("RAX: %p RCX: %p RDX: %p\n", a, b, c);
  28. a = get_rbx(); b = get_rsp(); c = get_rbp();
  29. printf("RBX: %p RSP: %p RBP: %p\n", a, b, c);
  30. a = get_rsi(); b = get_rdi(); c = get_r8();
  31. printf("RSI: %p RDI: %p R8 : %p\n", a, b, c);
  32. a = get_r9(); b = get_r10(); c = get_r11();
  33. printf("R9: %p R10: %p R11: %p\n", a, b, c);
  34. a = get_r12(); b = get_r13(); c = get_r14();
  35. printf("R12: %p R13: %p R14: %p\n", a, b, c);
  36. a = get_r15();
  37. printf("R15: %p\n", a);
  38. printf("\nKernel panic: %s\n", s);
  39. for (;;);
  40. }