very rudimentary pddb dumper for debugging.

yah, I know. :-/

anyways.
This commit is contained in:
bunnie 2021-11-12 22:57:37 +08:00
parent f5a5211851
commit 1ed606fa7d
4 changed files with 33 additions and 1 deletions

View file

@ -271,7 +271,7 @@ impl minifb::InputCallback for XousKeyboardHandler {
return;
}
log::info!("GFX|hosted: sending key {:?}", key);
log::debug!("GFX|hosted: sending key {:?}", key);
let c = self.decode_key(key);
if c != '\u{0000}' {
self.kbd.hostmode_inject_key(c);

View file

@ -4,6 +4,9 @@ use crate::api::*;
use std::sync::Once;
use std::mem::MaybeUninit;
use std::fs::File;
use std::io::prelude::*;
// This is considered bad practice for Rust to use a global singleton.
// However, this hack puts the burden of emulation on the emulator, while
// keeping the production code clean (otherwise we'd have large sections
@ -47,6 +50,20 @@ impl EmuStorage {
pub fn as_mut_slice(&mut self) -> &mut [u8] {
flashmem().memory.as_mut_slice()
}
pub fn dump_fs(&self) {
let mut f = File::create("../pddb.bin").unwrap();
f.write_all(flashmem().memory.as_slice()).unwrap();
f.flush().unwrap();
}
pub fn dump_keys(&self, known_keys: &[[u8; 32]]) {
//new().write(true).truncate(true).open
let mut f = File::create("../pddb.key").unwrap();
f.write_all(&(known_keys.len() as u32).to_le_bytes()).unwrap();
for key in known_keys {
f.write_all(key).unwrap();
}
f.flush().unwrap();
}
}
pub struct HostedSpinor {

View file

@ -147,6 +147,18 @@ impl PddbOs {
ret
}
#[cfg(not(any(target_os = "none", target_os = "xous")))]
pub fn dbg_dump(&self) {
self.pddb_mr.dump_fs();
if let Some(key) = self.system_basis_key {
self.pddb_mr.dump_keys(&[key]);
}
}
#[cfg(any(target_os = "none", target_os = "xous"))]
pub fn dbg_dump(&self) {
// placeholder
}
/// patches data at an offset starting from the data physical base address, which corresponds
/// exactly to the first entry in the page table
fn patch_data(&self, data: &[u8], offset: u32) {

View file

@ -371,6 +371,9 @@ fn xmain() -> ! {
pddb_os.pddb_format().unwrap();
log::info!("Done initializing disk");
#[cfg(not(any(target_os = "none", target_os = "xous")))]
pddb_os.dbg_dump();
// register a suspend/resume listener
let sr_cid = xous::connect(pddb_sid).expect("couldn't create suspend callback connection");
let susres = susres::Susres::new(&xns, api::Opcode::SuspendResume as u32, sr_cid).expect("couldn't create suspend/resume object");