CPU.cpp 843 B

123456789101112131415161718192021222324252627282930313233343536
  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 <Kernel/Arch/x86/CPU.h>
  8. #include <Kernel/Panic.h>
  9. #include <Kernel/Process.h>
  10. void __assertion_failed(const char* msg, const char* file, unsigned line, const char* func)
  11. {
  12. asm volatile("cli");
  13. critical_dmesgln("ASSERTION FAILED: {}", msg);
  14. critical_dmesgln("{}:{} in {}", file, line, func);
  15. abort();
  16. }
  17. [[noreturn]] void abort()
  18. {
  19. // Switch back to the current process's page tables if there are any.
  20. // Otherwise stack walking will be a disaster.
  21. auto process = Process::current();
  22. if (process)
  23. MM.enter_process_paging_scope(*process);
  24. PANIC("Aborted");
  25. }
  26. [[noreturn]] void _abort()
  27. {
  28. asm volatile("ud2");
  29. __builtin_unreachable();
  30. }