Add option to peek to read from physical memory
This commit is contained in:
parent
303c07138b
commit
9be3153a7b
36
src/main.rs
36
src/main.rs
@ -268,6 +268,13 @@ fn main() -> Result<(), anyhow::Error> {
|
||||
|
||||
.help("The format to print the values in (<fmt><size>)"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new("phys")
|
||||
.long("phys")
|
||||
.short('p')
|
||||
.action(ArgAction::SetTrue)
|
||||
.help("Peek physical memory instead of virtual memory"),
|
||||
)
|
||||
.arg(Arg::new("addr").required(true))
|
||||
.about("Peek a memory address"),
|
||||
|args, state| {
|
||||
@ -291,14 +298,27 @@ fn main() -> Result<(), anyhow::Error> {
|
||||
}
|
||||
let mut data = Vec::new();
|
||||
let bus = state.cpu.bus_mut();
|
||||
for i in 0..count {
|
||||
match size {
|
||||
peek::Size::Byte => data.push(bus.read_byte(addr + i)? as u32),
|
||||
peek::Size::Word => data.push(bus.read_word(addr + (i * 2))? as u32),
|
||||
peek::Size::LongWord => data.push(
|
||||
(bus.read_word(addr + (i * 4))? as u32) << 16
|
||||
| (bus.read_word(addr + (i * 4) + 2)? as u32),
|
||||
),
|
||||
if args.get_flag("phys") {
|
||||
for i in 0..count {
|
||||
match size {
|
||||
peek::Size::Byte => data.push(bus.read_byte_phys(addr + i)? as u32),
|
||||
peek::Size::Word => data.push(bus.read_word_phys(addr + (i * 2))? as u32),
|
||||
peek::Size::LongWord => data.push(
|
||||
(bus.read_word_phys(addr + (i * 4))? as u32) << 16
|
||||
| (bus.read_word_phys(addr + (i * 4) + 2)? as u32),
|
||||
),
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for i in 0..count {
|
||||
match size {
|
||||
peek::Size::Byte => data.push(bus.read_byte(addr + i)? as u32),
|
||||
peek::Size::Word => data.push(bus.read_word(addr + (i * 2))? as u32),
|
||||
peek::Size::LongWord => data.push(
|
||||
(bus.read_word(addr + (i * 4))? as u32) << 16
|
||||
| (bus.read_word(addr + (i * 4) + 2)? as u32),
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(Some(
|
||||
|
Loading…
Reference in New Issue
Block a user