#![allow(non_camel_case_types)]
#[macro_use]
pub mod cop;
pub mod cdrom;
pub mod cop0;
pub mod dma;
pub mod gpu;
pub mod gte;
pub mod irq;
pub mod mmio;
use mmio::MemRegister;
mod private {
use core::fmt::Debug;
use core::ops::{BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Not};
pub trait Primitive:
Copy
+ Debug
+ PartialEq
+ Not<Output = Self>
+ BitAnd<Output = Self>
+ BitOr<Output = Self>
+ BitXor<Output = Self>
+ BitAndAssign
+ BitOrAssign
+ BitXorAssign
+ From<u8> {
}
impl Primitive for u8 {}
impl Primitive for u16 {}
impl Primitive for u32 {}
impl Primitive for i16 {}
impl Primitive for i32 {}
}
pub trait Register<T: private::Primitive>: Sized + AsRef<T> + AsMut<T> {
fn skip_load() -> Self;
fn new() -> Self {
let mut reg = Self::skip_load();
reg.load();
reg
}
fn load(&mut self) -> &mut Self;
fn store(&mut self) -> &mut Self;
fn from_bits(bits: T) -> Self {
let mut reg = Self::skip_load();
reg.assign(bits);
reg
}
fn to_bits(&self) -> T {
*self.as_ref()
}
fn assign(&mut self, bits: T) -> &mut Self {
*self.as_mut() = bits;
self
}
fn any_set(&self, bits: T) -> bool {
*self.as_ref() & bits != T::from(0)
}
fn all_set(&self, bits: T) -> bool {
*self.as_ref() & bits == bits
}
fn all_clear(&self, bits: T) -> bool {
*self.as_ref() & bits == T::from(0)
}
fn set_bits(&mut self, bits: T) -> &mut Self {
*self.as_mut() |= bits;
self
}
fn clear_bits(&mut self, bits: T) -> &mut Self {
*self.as_mut() &= !bits;
self
}
fn toggle_bits(&mut self, bits: T) -> &mut Self {
*self.as_mut() ^= bits;
self
}
fn set_all(&mut self) -> &mut Self {
*self.as_mut() = !T::from(0);
self
}
fn clear_all(&mut self) -> &mut Self {
*self.as_mut() = T::from(0);
self
}
fn toggle_all(&mut self) -> &mut Self {
*self.as_mut() ^= !T::from(0);
self
}
}