Implement a GDB stub and fix another huge issue in S-type immediate decoding
This commit is contained in:
38
src/main.rs
38
src/main.rs
@@ -4,33 +4,38 @@
|
||||
// This file is part of TRVE (https://gitea.taitep.se/taitep/trve)
|
||||
// See LICENSE file in the project root for full license text.
|
||||
|
||||
use std::{env, sync::Arc, time::Duration};
|
||||
use std::{env, path::PathBuf, sync::Arc, time::Duration};
|
||||
|
||||
use clap::Parser;
|
||||
|
||||
use trve::{
|
||||
consts::{Addr, Byte, DWord, HWord, Word},
|
||||
core::Core,
|
||||
exceptions::MemoryExceptionType,
|
||||
gdb,
|
||||
mem::{MemConfig, MemDeviceInterface, MmioRoot, Ram},
|
||||
};
|
||||
|
||||
use anyhow::{Result, bail};
|
||||
use anyhow::Result;
|
||||
|
||||
use crate::basic_uart::BasicUart;
|
||||
|
||||
mod execload;
|
||||
|
||||
#[derive(Parser)]
|
||||
struct Args {
|
||||
executable: PathBuf,
|
||||
#[arg(long)]
|
||||
wait: bool,
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let args = Args::parse();
|
||||
|
||||
let mut ram = Ram::try_new(16 * 1024 * 1024)?;
|
||||
let buf = ram.buf_mut();
|
||||
|
||||
let args: Vec<String> = env::args().collect();
|
||||
|
||||
if args.len() != 2 {
|
||||
eprintln!("USAGE: trve <ram_image>");
|
||||
bail!("Wrong number of arguments");
|
||||
}
|
||||
|
||||
let entry_point = execload::load(&args[1], buf)?;
|
||||
let entry_point = execload::load(args.executable, buf)?;
|
||||
|
||||
let mut mmio_root = MmioRoot::default();
|
||||
mmio_root.insert(0, Arc::new(DbgOut));
|
||||
@@ -44,9 +49,18 @@ fn main() -> Result<()> {
|
||||
mmio_root,
|
||||
};
|
||||
|
||||
let mut core = Core::new(mem_cfg);
|
||||
let (cmd_sender, cmd_reciever) = std::sync::mpsc::channel();
|
||||
|
||||
gdb::run_stub(cmd_sender.clone());
|
||||
|
||||
let mut core = Core::new(mem_cfg, cmd_reciever);
|
||||
core.reset(entry_point);
|
||||
core.run();
|
||||
|
||||
if args.wait {
|
||||
core.run_waiting_for_cmd();
|
||||
} else {
|
||||
core.run();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user