wrote instruction logic, just need a new assembler now :)
This commit is contained in:
+13
-42
@@ -1,61 +1,32 @@
|
||||
use arc_swap::ArcSwap;
|
||||
use clap::Parser;
|
||||
use std::{
|
||||
fs,
|
||||
path::PathBuf,
|
||||
sync::{
|
||||
Arc,
|
||||
atomic::{AtomicBool, AtomicU8},
|
||||
},
|
||||
thread,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use dsa::{Emulator, FastStore, MainStore, MemoryMap, SharedState};
|
||||
use dsa::{BulkAllocStore, Emulator, MemoryMap, SharedState, args::DsaArgs};
|
||||
use std::{sync::Arc, thread};
|
||||
|
||||
fn main() {
|
||||
let args = DsaArgs::parse();
|
||||
|
||||
let mut emulator = Emulator::new(FastStore::new());
|
||||
|
||||
let mmap = match args.get_memory_map() {
|
||||
Some(m) => m,
|
||||
None => MemoryMap::default(),
|
||||
};
|
||||
|
||||
emulator.apply_memory_map(mmap);
|
||||
let mut emulator = Emulator::new(BulkAllocStore::new());
|
||||
emulator.apply_memory_map(args.get_memory_map().unwrap_or_default());
|
||||
|
||||
let state = emulator.state_handle();
|
||||
let runner = thread::spawn(move || emulator.run());
|
||||
|
||||
const STACK_SIZE: usize = 1024 * 1024 * 16;
|
||||
let runner = thread::Builder::new()
|
||||
.stack_size(STACK_SIZE)
|
||||
.spawn(move || emulator.run())
|
||||
.unwrap();
|
||||
|
||||
let observer = thread::spawn(|| observe(state));
|
||||
|
||||
runner.join().unwrap();
|
||||
observer.join().unwrap();
|
||||
}
|
||||
|
||||
/// todo: remove this!
|
||||
fn observe(state: Arc<SharedState>) {
|
||||
loop {
|
||||
thread::sleep(std::time::Duration::from_millis(100));
|
||||
let state = state.proc.load();
|
||||
println!("GP Registers: {:?}", state.gp_registers);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about, long_about = None)]
|
||||
struct DsaArgs {
|
||||
/// Memory map to use on boot.
|
||||
/// Overrides default value.
|
||||
#[arg(long = "mmap")]
|
||||
memory_map: Option<PathBuf>,
|
||||
}
|
||||
|
||||
impl DsaArgs {
|
||||
pub fn get_memory_map(&self) -> Option<MemoryMap> {
|
||||
self.memory_map.as_ref().and_then(|m| {
|
||||
fs::read_to_string(m)
|
||||
.ok()
|
||||
.and_then(|map| ron::from_str(&map).ok())
|
||||
})
|
||||
println!("GP Registers: {:?}", state.registers);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user