CPU.cpp 988 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <AK/Assertions.h>
  7. #include <AK/Types.h>
  8. #include <Kernel/Arch/x86/CPU.h>
  9. #include <Kernel/Arch/x86/Processor.h>
  10. #include <Kernel/Arch/x86/TrapFrame.h>
  11. #include <Kernel/KSyms.h>
  12. #include <Kernel/Process.h>
  13. void __assertion_failed(const char* msg, const char* file, unsigned line, const char* func)
  14. {
  15. asm volatile("cli");
  16. critical_dmesgln("ASSERTION FAILED: {}", msg);
  17. critical_dmesgln("{}:{} in {}", file, line, func);
  18. abort();
  19. }
  20. [[noreturn]] void abort()
  21. {
  22. // Switch back to the current process's page tables if there are any.
  23. // Otherwise stack walking will be a disaster.
  24. auto process = Process::current();
  25. if (process)
  26. MM.enter_process_paging_scope(*process);
  27. Kernel::dump_backtrace();
  28. Processor::halt();
  29. abort();
  30. }
  31. [[noreturn]] void _abort()
  32. {
  33. asm volatile("ud2");
  34. __builtin_unreachable();
  35. }