diff --git a/backend/src/core.rs b/backend/src/core.rs index d50eab0..68ff5d3 100644 --- a/backend/src/core.rs +++ b/backend/src/core.rs @@ -1,11 +1,30 @@ +use utils::error::Error; + +use crate::core::{cpu::Cpu, interpreter::Interpreter, mem::Memory}; + pub mod cpu; pub mod interpreter; pub mod mem; pub mod registers; -pub struct Core {} +pub struct Core { + cpu: Interpreter, + mem: Memory, +} impl Core { + pub fn new() -> Self { + Self { + cpu: Interpreter::new(), + mem: Memory::new(), + } + } + pub fn stop(&mut self) {} pub fn reset(&mut self) {} + pub fn run(&mut self) -> Result { + loop { + let _ = self.cpu.step(&mut self.mem)?; + } + } } diff --git a/backend/src/core/mem.rs b/backend/src/core/mem.rs index d8ca004..96daa76 100644 --- a/backend/src/core/mem.rs +++ b/backend/src/core/mem.rs @@ -1 +1,13 @@ -pub struct Memory {} +use crate::core::mem::mmio::mmio::MMIO; + +pub mod mmio; + +pub struct Memory { + mmio: MMIO, +} + +impl Memory { + pub fn new() -> Self { + Self { mmio: MMIO::new() } + } +} diff --git a/backend/src/core/mem/mmio/mmio.rs b/backend/src/core/mem/mmio/mmio.rs new file mode 100644 index 0000000..02ccbbf --- /dev/null +++ b/backend/src/core/mem/mmio/mmio.rs @@ -0,0 +1,13 @@ +use crate::core::mem::mmio::ri::RDRAMInterface; + +pub struct MMIO { + ri: RDRAMInterface, +} + +impl MMIO { + pub fn new() -> Self { + Self { + ri: RDRAMInterface::new(), + } + } +} diff --git a/backend/src/core/mem/mmio/mod.rs b/backend/src/core/mem/mmio/mod.rs new file mode 100644 index 0000000..9f78f26 --- /dev/null +++ b/backend/src/core/mem/mmio/mod.rs @@ -0,0 +1,2 @@ +pub mod mmio; +pub mod ri; diff --git a/backend/src/core/mem/mmio/ri.rs b/backend/src/core/mem/mmio/ri.rs new file mode 100644 index 0000000..953634d --- /dev/null +++ b/backend/src/core/mem/mmio/ri.rs @@ -0,0 +1,18 @@ +pub struct RDRAMInterface { + rdram: Vec, + cmd_buf: Vec, +} + +impl RDRAMInterface { + pub fn new() -> Self { + Self { + rdram: Vec::with_capacity(0x800000), + cmd_buf: Vec::with_capacity(0xFFFFF), + } + } + + pub fn reset(&mut self) { + self.rdram.fill(0); + self.cmd_buf.fill(0); + } +}