Croissant Runtime
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
crsn/runtime/src/fault.rs

59 lines
1.3 KiB

use thiserror::Error;
use super::span::MemorySpan;
use crate::run_thread::ThreadToken;
use crate::mlock::ClaimId;
use asm::data::literal::DebugMsg;
use asm::data::Register;
#[derive(Error,Debug)]
pub enum Fault {
#[error("Bad instruction at addr {addr:#10x}: {cause}")]
BadInstruction {
addr : u32,
cause: InstrError,
},
#[error("Runtime hit a barrier instruction: {msg}")]
Barrier {
msg: DebugMsg,
},
#[error("User fault: {msg}")]
FaultInstr {
msg: DebugMsg,
},
#[error("Memory region {area:?} is locked by thread {owner:?}")]
MemoryLocked {
area: MemorySpan,
owner: ThreadToken
},
#[error("Memory claim {claim:?} owned by thread {owner:?} does not exist")]
ClaimNotExist {
claim: ClaimId,
owner: ThreadToken
},
#[error("Register does not exist: {reg:?}")]
RegisterNotExist {
reg: Register,
},
#[error("Register is read-only: {reg:?}")]
RegisterNotWritable {
reg: Register,
},
}
#[derive(Error,Debug)]
pub enum InstrError {
#[error("Instruction not recognized")]
UnknownInstruction,
#[error("Invalid bit span")]
BadBitSpan,
#[error("Operands data size differs")]
UnevenOperandSize,
}