ax_cpu/uspace_common.rs
1use ax_memory_addr::VirtAddr;
2
3use crate::{trap::PageFaultFlags, uspace::ExceptionInfo};
4
5/// A reason as to why the control of the CPU is returned from
6/// the user space to the kernel.
7#[derive(Debug, Clone, Copy)]
8pub enum ReturnReason {
9 /// An interrupt.
10 Interrupt,
11 /// A system call.
12 Syscall,
13 /// A page fault.
14 PageFault(VirtAddr, PageFaultFlags),
15 /// Other kinds of exceptions.
16 Exception(ExceptionInfo),
17 /// Unknown reason.
18 Unknown,
19}
20
21/// A generalized kind for [`ExceptionInfo`].
22#[derive(Debug, Clone, Copy, PartialEq, Eq)]
23pub enum ExceptionKind {
24 #[cfg(target_arch = "x86_64")]
25 /// A debug exception.
26 Debug,
27 /// A breakpoint exception.
28 Breakpoint,
29 /// An illegal instruction exception.
30 IllegalInstruction,
31 /// A misaligned access exception.
32 Misaligned,
33 /// Other kinds of exceptions.
34 Other,
35}