CPU.cpp 829 B

1234567891011121314151617181920212223242526272829303132333435
  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. if (Process::has_current())
  22. MM.enter_process_paging_scope(Process::current());
  23. PANIC("Aborted");
  24. }
  25. [[noreturn]] void _abort()
  26. {
  27. asm volatile("ud2");
  28. __builtin_unreachable();
  29. }