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

77 lines
1.7 KiB

use thiserror::Error;
// use super::span::MemorySpan;
// use crate::run_thread::ThreadToken;
// use crate::mlock::ClaimId;
use asm::data::literal::{DebugMsg, RoutineName, Label};
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,
},
#[error("Called undefined routine: {routine}")]
NoSuchRoutine {
routine: RoutineName,
},
#[error("Jump to undefined far label: {label}")]
NoSuchFarLabel {
label: Label,
},
#[error("Crossed a barrier: {msg}")]
JumpThroughBarrier {
msg: DebugMsg,
},
#[error("Call stack underflow")]
CallStackUnderflow,
}
#[derive(Error,Debug)]
pub enum InstrError {
#[error("Instruction not recognized")]
UnknownInstruction,
#[error("Invalid bit span")]
BadBitSpan,
#[error("Operands data size differs")]
UnevenOperandSize,
}