/* ------------------------------------------- Copyright ZKA Technologies. ------------------------------------------- */ #include #include #include #include #include #include #include #include #include #define SetMem(dst, byte, sz) Kernel::rt_set_memory((Kernel::VoidPtr)dst, byte, sz) #define CopyMem(dst, src, sz) Kernel::rt_copy_memory((Kernel::VoidPtr)src, (Kernel::VoidPtr)dst, sz) #define MoveMem(dst, src, sz) Kernel::rt_copy_memory((Kernel::VoidPtr)src, (Kernel::VoidPtr)dst, sz) #define cWebsiteMacro "https://zka.nl/help" #include /* Each error code is attributed with an ID, which will prompt a string onto the * screen. Wait for debugger... */ namespace Kernel { void ke_stop(const Kernel::Int& id) { CGInit(); auto panicBack = RGB(0xff, 0x3a, 0x3a); auto panicTxt = RGB(0xff, 0xff, 0xff); CGDrawInRegion(panicBack, UIAccessibilty::The().Height(), UIAccessibilty::The().Width(), 0, 0); auto start_y = 10; auto x = 10; cg_write_text("newoskrnl.dll stopped working properly so we had to stop.", start_y, x, panicTxt); CGFini(); // Show the QR code now. constexpr auto cVer = 4; const auto cECC = qr::Ecc::H; const auto cInput = cWebsiteMacro; const auto cInputLen = rt_string_len(cWebsiteMacro); qr::Qr encoder; qr::QrDelegate encoderDelegate; encoder.encode(cInput, cInputLen, cECC, 0); // Manual mask 0 const auto cWhereStartX = (kHandoverHeader->f_GOP.f_Width - encoder.side_size()) - 20; const auto cWhereStartY = (kHandoverHeader->f_GOP.f_Height - encoder.side_size()) / 2; // tell delegate to draw encoded QR now. encoderDelegate.draw(encoder, cWhereStartX, cWhereStartY); start_y += 10; // show text according to error id. switch (id) { case RUNTIME_CHECK_PROCESS: { cg_write_text("0x00000008 Process scheduler error (Catasrophic failure).", start_y, x, panicTxt); break; } case RUNTIME_CHECK_ACPI: { cg_write_text("0x00000006 ACPI error.", start_y, x, panicTxt); break; } case RUNTIME_CHECK_POINTER: { cg_write_text("0x00000000 Kernel heap error.", start_y, x, panicTxt); break; } case RUNTIME_CHECK_BAD_BEHAVIOR: { cg_write_text("0x00000009 Undefined Behavior error.", start_y, x, panicTxt); break; } case RUNTIME_CHECK_BOOTSTRAP: { cg_write_text("0x0000000A End of code.", start_y, x, panicTxt); break; } case RUNTIME_CHECK_HANDSHAKE: { cg_write_text("0x00000005 Handshake error.", start_y, x, panicTxt); break; } case RUNTIME_CHECK_IPC: { cg_write_text("0x00000003 Kernel IPC error.", start_y, x, panicTxt); break; } case RUNTIME_CHECK_INVALID_PRIVILEGE: { cg_write_text("0x00000007 Kernel privilege violation.", start_y, x, panicTxt); break; case RUNTIME_CHECK_UNEXCPECTED: { cg_write_text("0x0000000B Catasrophic failure.", start_y, x, panicTxt); break; } case RUNTIME_CHECK_FAILED: { cg_write_text("0x10000001 Assertion failed.", start_y, x, panicTxt); break; } default: { cg_write_text("0xFFFFFFFF Unknown error.", start_y, x, panicTxt); break; } } }; RecoveryFactory::Recover(); } Void RecoveryFactory::Recover() noexcept { while (Yes) { asm volatile("cli; hlt"); } } void ke_runtime_check(bool expr, const char* file, const char* line) { if (!expr) { ke_stop(RUNTIME_CHECK_FAILED); // Runtime Check failed } } } // namespace Kernel