kernel/lib/
panic_codes.rs1macro_rules! panic_codes {
8 ($( $(#[$attr:meta])* $name:ident = $value:expr, $kind:expr; )*) => {
9 #[repr(u16)]
10 pub enum PanicCode {
11 $( $(#[$attr])* $name = $value, )*
12 }
13
14 impl PanicCode {
15 pub fn as_str(&self) -> &'static str {
16 match self {
17 $( $(#[$attr])* PanicCode::$name => stringify!($name), )*
18 }
19 }
20
21 pub fn get_error_type_str(&self) -> &'static str {
22 match self {
23 $( $(#[$attr])* PanicCode::$name => $kind, )*
24 }
25 }
26 }
27 };
28}
29
30panic_codes! {
31 Unknown = 0x0000, "Unknown";
33 ManuallyTriggeredPanic = 0x0001, "IntendedPanic";
34 InitFailure = 0x0002, "RuntimeError";
35 InitProcessDied = 0x0003, "RuntimeError";
36
37 InternalKernelError = 0x0030, "ProgrammerError";
39 UninitializedAccess = 0x0031, "ProgrammerError";
40 DoubleInitialization = 0x0032, "ProgrammerError";
41
42 #[cfg(target_arch = "x86_64")] IllegalInterrupt = 0x0099, "CpuException";
45 #[cfg(target_arch = "x86_64")] DivideError = 0x0100, "CpuException";
46 #[cfg(target_arch = "x86_64")] NmiHardwareFailure = 0x0102, "CpuException";
47 #[cfg(target_arch = "x86_64")] Overflow = 0x0104, "CpuException";
48 #[cfg(target_arch = "x86_64")] InvalidOpcode = 0x0106, "CpuException";
49 #[cfg(target_arch = "x86_64")] DeviceNotAvail = 0x0107, "CpuException";
50 #[cfg(target_arch = "x86_64")] DoubleFault = 0x0108, "CpuException";
51 #[cfg(target_arch = "x86_64")] InvalidTss = 0x0110, "CpuException";
52 #[cfg(target_arch = "x86_64")] SegmentNotPresent = 0x0111, "CpuException";
53 #[cfg(target_arch = "x86_64")] StackSegmentFault = 0x0112, "CpuException";
54 #[cfg(target_arch = "x86_64")] GeneralProtectionFault = 0x0113, "CpuException";
55 #[cfg(target_arch = "x86_64")] PageFault = 0x0114, "CpuException";
56 #[cfg(target_arch = "x86_64")] X87FloatingPoint = 0x0116, "CpuException";
57 #[cfg(target_arch = "x86_64")] AlignmentCheck = 0x0117, "CpuException";
58 #[cfg(target_arch = "x86_64")] MachineCheck = 0x0118, "CpuException";
59 #[cfg(target_arch = "x86_64")] SimdFloatingPoint = 0x0119, "CpuException";
60 #[cfg(target_arch = "x86_64")] Virtualization = 0x0120, "CpuException";
61 #[cfg(target_arch = "x86_64")] VmmCommunicationException = 0x0129, "CpuException";
62 #[cfg(target_arch = "x86_64")] SecurityException = 0x0130, "CpuException";
63
64 NoValidMemMapEntry = 0x0300, "RuntimeError";
66 DoubleFree = 0x0301, "ProgrammerError";
67 IllegalFree = 0x0302, "ProgrammerError";
68 OutOfMemory = 0x0303, "RuntimeError";
69 OutOfVirtualMemory = 0x0304, "RuntimeError";
70 MemoryMappingCollision = 0x0305, "ProgrammerError";
71 MisalignedAddress = 0x0306, "ProgrammerError";
72 InvalidPageOperation = 0x0370, "RuntimeError";
74
75 NoWorkingInit = 0x0400, "RuntimeError";
77 ProcessNotFound = 0x401, "RuntimeError";
78
79 MalformedPsf2Font = 0x1000, "RuntimeError / ProgrammerError";
81}