feat(runtime): implement shared transactional memcard with async saves
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good
Intrepid/Prometeu/Runtime/pipeline/pr-master This commit looks good
This commit is contained in:
@@ -38,6 +38,14 @@ struct Cli {
|
||||
#[arg(long, value_name = "PATH")]
|
||||
games_root: Option<String>,
|
||||
|
||||
/// Install a memory-card image (never converted or overwritten).
|
||||
#[arg(long, value_name = "PATH")]
|
||||
memcard: Option<std::path::PathBuf>,
|
||||
|
||||
/// Create and fully allocate the named new memory card before installation.
|
||||
#[arg(long, requires = "memcard")]
|
||||
create_memcard: bool,
|
||||
|
||||
/// Path to the capability configuration file
|
||||
#[arg(long, value_name = "PATH")]
|
||||
cap: Option<String>,
|
||||
@@ -63,6 +71,11 @@ pub fn run() -> Result<(), Box<dyn std::error::Error>> {
|
||||
if let Some(games_root) = cli.games_root {
|
||||
runner.set_games_root(games_root);
|
||||
}
|
||||
if let Some(path) = cli.memcard {
|
||||
runner
|
||||
.install_memcard(path, cli.create_memcard)
|
||||
.map_err(|e| format!("Cannot install memory card: {e:?}"))?;
|
||||
}
|
||||
runner.set_boot_target(boot_target);
|
||||
|
||||
event_loop.run_app(&mut runner)?;
|
||||
|
||||
@@ -156,6 +156,26 @@ pub struct HostRunner {
|
||||
}
|
||||
|
||||
impl HostRunner {
|
||||
pub fn install_memcard(
|
||||
&mut self,
|
||||
path: std::path::PathBuf,
|
||||
create: bool,
|
||||
) -> prometeu_system::memcard::image::Result<()> {
|
||||
self.firmware.os.memcard().mount_card_with(move || {
|
||||
use prometeu_drivers::memcard::FileMemcard;
|
||||
use prometeu_system::memcard::{image::IMAGE_BYTES, transaction::Card};
|
||||
let storage = if create {
|
||||
FileMemcard::create(&path, IMAGE_BYTES, |storage, id| {
|
||||
Card::format(storage, id)
|
||||
.map_err(|_| prometeu_hal::memcard::MemcardIoError::IoError)
|
||||
})?
|
||||
} else {
|
||||
FileMemcard::open(&path, false)?
|
||||
};
|
||||
Ok(Box::new(storage))
|
||||
})
|
||||
}
|
||||
|
||||
/// Configures the boot target (Hub or specific Cartridge).
|
||||
pub(crate) fn set_boot_target(&mut self, boot_target: BootTarget) {
|
||||
self.firmware.boot_target = boot_target.clone();
|
||||
|
||||
Reference in New Issue
Block a user