1
0
forked from Rativel/BurritOS
Files
BurritOS/src/simulator/interrupt.rs
2023-03-15 11:09:34 +01:00

42 lines
800 B
Rust

#[derive(PartialEq)]
pub struct Interrupt {
level: InterruptStatus
}
impl Interrupt {
pub fn new() -> Self {
Self {
level: InterruptStatus::InterruptOff
}
}
pub fn set_status(&mut self, new_status: InterruptStatus) -> InterruptStatus {
let old = self.level;
self.level = new_status;
if new_status == InterruptStatus::InterruptOn && old == InterruptStatus::InterruptOff {
self.one_tick(1);
}
old
}
fn one_tick(&self, nb_cycle: i32) {
todo!();
}
pub fn get_status(&self) -> InterruptStatus {
self.level
}
pub fn idle(&self) {
// todo!();
}
}
#[derive(PartialEq, Clone, Copy, Debug)]
pub enum InterruptStatus {
InterruptOff,
InterruptOn
}