1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
use rust_cheri_compressed_cap::Cc128Cap;
use thiserror::Error;
pub type ProcessorResult<T> = anyhow::Result<T>;
#[derive(Debug,Clone,PartialEq,Eq,Error)]
pub enum IllegalInstructionException {
#[error("Unhandled Opcode {0:07b}")]
UnknownOpcode(u8),
#[error("Unsupported parameter: {0}")]
UnsupportedParam(String),
#[error("Haven't implemented instruction {0} yet")]
UnimplementedInstruction(&'static str),
#[error("{0}")]
MiscDecodeException(String)
}
#[derive(Debug,Clone,PartialEq,Eq,Error)]
pub enum MemoryException {
#[error("Address {addr:08x} misaligned, expected alignment on {expected}")]
AddressMisaligned{ addr: usize, expected: usize },
#[error("Jump target address {addr:08x} misaligned, expected alignment on {expected}")]
JumpMisaligned{addr: usize, expected: usize},
#[error("Address {addr:08x} not mapped")]
AddressUnmapped{ addr: usize },
}
#[derive(Debug,Clone,PartialEq,Eq,Error)]
pub enum ProgramHaltedException {
#[error("Program halted by writing to {addr:08x}")]
ResultReturned{addr: usize},
}
#[derive(Debug,Clone,Copy,PartialEq,Eq)]
pub enum CapOrRegister {
Cap(Cc128Cap),
Reg(u8)
}
#[derive(Debug,Clone,PartialEq,Eq,Error)]
pub enum CapabilityException {
#[error("Expected cap {cap:x?} address to be in-bounds for a {size}-byte data type")]
BoundsViolation{ cap: CapOrRegister, size: usize },
#[error("Expected cap {cap:x?} to be tagged")]
TagViolation{ cap: CapOrRegister },
#[error("Expected cap {cap:x?} to have unsealed")]
SealViolation{ cap: CapOrRegister },
#[error("Expected cap {cap:x?} to contain range 0x{base:x}-0x{top:x}")]
LengthViolation{ cap: CapOrRegister, base: u64, top: u128 },
#[error("Capability created from cap {cap:x?} does not have exact bounds")]
InexactBounds{ cap: CapOrRegister },
#[error("Expected cap {cap:x?} to have permissions {perms:b}")]
PermissionViolation{ cap: CapOrRegister, perms: u32 }
}