// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org) // Licensed under the Apache License, Version 2.0 (see LICENSE file) // Official repository: https://github.com/nekernel-org/nekernel #include #include #include #include #include #include #include #include #include #include /* Each error code is attributed with an ID, which will prompt a string onto the * screen. Wait for debugger... */ namespace Kernel { /// @brief Dumping factory class. class RecoveryFactory final { public: STATIC Void Recover(); }; /***********************************************************************************/ /// @brief Stops execution of the kernel. /// @param id kernel stop ID. /***********************************************************************************/ Void ke_panic(const Kernel::Int32& id, const Char* message) { (Void)(kout << "*** STOP ***\r"); (Void)(kout << "Kernel_Panic_MSG: " << message << kendl); (Void)(kout << "Kernel_Panic_ID: " << hex_number(id) << kendl); (Void)(kout << "Kernel_Panic_CR2: " << hex_number((UIntPtr) hal_read_cr2()) << kendl); RecoveryFactory::Recover(); } Void RecoveryFactory::Recover() { while (YES) { HAL::rt_halt(); } } void ke_runtime_check(bool expr, const Char* file, const Char* line) { if (!expr) { (Void)(kout << "*** CHECK ***\r"); (Void)(kout << "Kernel_Panic_FILE: " << file << kendl); (Void)(kout << "Kernel_Panic_LINE: " << line << kendl); ke_panic(RUNTIME_CHECK_FAILED, file); // Runtime Check failed } } } // namespace Kernel