/* * TerminationCodes.hpp * MontaukOS process termination codes. * Copyright (c) 2026 Daniel Hammer */ #pragma once #include // Exit code recorded when the kernel ends a process, as opposed to the // process calling SYS_EXIT (which is masked to 0..255). Encoded as // 256 + POSIX signal number so libc waitpid can report WTERMSIG. // Mirrored in userspace at programs/include/montauk/statuscodes.h. enum TerminationCodes { TerminationBase = 256, TerminatedIllegalInstruction = TerminationBase + 4, // SIGILL TerminatedBreakpoint = TerminationBase + 5, // SIGTRAP TerminatedAborted = TerminationBase + 6, // SIGABRT TerminatedArithmeticError = TerminationBase + 8, // SIGFPE TerminatedKilled = TerminationBase + 9, // SIGKILL TerminatedAccessViolation = TerminationBase + 11 // SIGSEGV }; // Termination code for a user-mode CPU exception. The exact vector is // kept in the crash report; this is only the category. inline TerminationCodes TerminationFromVector(uint8_t vector) { switch (vector) { case 0x06: return TerminatedIllegalInstruction; // #UD case 0x01: // #DB case 0x03: return TerminatedBreakpoint; // #BP case 0x00: // #DE case 0x10: // #MF case 0x13: return TerminatedArithmeticError; // #XM default: return TerminatedAccessViolation; // #PF, #GP, #SS, #NP, #AC, #OF, #BR, #CP, ... } }