Skip to content

Commit d4023b7

Browse files
committed
Add errors::Exception enumeration
This enumeration covers the exception cases supported by AMD and Intel. Signed-off-by: Nathaniel McCallum <[email protected]>
1 parent 27ab505 commit d4023b7

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

src/errors.rs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
//! This module contains errors and exception types.
2+
3+
/// Exception Error Codes
4+
///
5+
/// This structure is defined by the following manual sections:
6+
/// * AMD Volume 2: 8.2
7+
/// * Intel Volume 3A: 6.3.1
8+
#[repr(u8)]
9+
#[non_exhaustive]
10+
#[derive(Copy, Clone, Debug, PartialEq)]
11+
pub enum Exception {
12+
/// Divide-by-zero Error
13+
DivideByZero = 0x00,
14+
15+
/// Debug
16+
Debug = 0x01,
17+
18+
/// Non-Maskable Interrupt
19+
NonMaskableInterrupt = 0x02,
20+
21+
/// Breakpoint
22+
Breakpoint = 0x03,
23+
24+
/// Overflow
25+
Overflow = 0x04,
26+
27+
/// Bound Range Exceeded
28+
BoundRange = 0x05,
29+
30+
/// Invalid Opcode
31+
InvalidOpcode = 0x06,
32+
33+
/// Device Not Available
34+
DeviceNotAvailable = 0x07,
35+
36+
/// Double Fault
37+
DoubleFault = 0x08,
38+
39+
/// Invalid TSS
40+
InvalidTss = 0x0A,
41+
42+
/// Segment Not Present
43+
SegmentNotPresent = 0x0B,
44+
45+
/// Stack Fault
46+
Stack = 0x0C,
47+
48+
/// General Protection Fault
49+
GeneralProtection = 0x0D,
50+
51+
/// Page Fault
52+
Page = 0x0E,
53+
54+
/// x87 Floating-Point Exception
55+
FloatingPoint = 0x10,
56+
57+
/// Alignment Check
58+
AlignmentCheck = 0x11,
59+
60+
/// Machine Check
61+
MachineCheck = 0x12,
62+
63+
/// SIMD Floating-Point Exception
64+
SimdFloatingPoint = 0x13,
65+
66+
/// Virtualization Exception (Intel-only)
67+
Virtualization = 0x14,
68+
69+
/// Control Protection Exception (AMD-only)
70+
ControlProtection = 0x15,
71+
72+
/// Hypervisor Injection (AMD-only)
73+
HypervisorInjection = 0x1C,
74+
75+
/// VMM Communication (AMD-only)
76+
VmmCommunication = 0x1D,
77+
78+
/// Security Exception
79+
Security = 0x1E,
80+
}

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ macro_rules! const_assert {
6262
pub(crate) mod asm;
6363

6464
pub mod addr;
65+
pub mod errors;
6566
pub mod instructions;
6667
pub mod registers;
6768
pub mod structures;

0 commit comments

Comments
 (0)