mirror of
https://github.com/Polprzewodnikowy/SummerCart64.git
synced 2024-11-26 15:44:14 +01:00
warn when console is on
This commit is contained in:
parent
8ba2f95b3a
commit
6dbd773415
@ -852,6 +852,23 @@ fn handle_sd_command(connection: Connection, command: &SDCommands) -> Result<(),
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if sc64.is_console_powered_on()? {
|
||||||
|
println!(
|
||||||
|
"{}\n{}\n{}",
|
||||||
|
"========== [WARNING] ==========".bold().bright_yellow(),
|
||||||
|
"The console is powered on. To avoid potential data corruption it's strongly"
|
||||||
|
.bright_yellow(),
|
||||||
|
"recommended to access the SD card only when the console is powered off."
|
||||||
|
.bright_yellow()
|
||||||
|
);
|
||||||
|
let answer = prompt(format!("{}", "Continue anyways? [y/N] ".bold()));
|
||||||
|
if answer.to_ascii_lowercase() != "y" {
|
||||||
|
sc64.deinit_sd_card()?;
|
||||||
|
println!("{}", "SD card access aborted".red());
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sc64.reset_state()?;
|
sc64.reset_state()?;
|
||||||
|
|
||||||
sc64::ff::run(sc64, |ff| {
|
sc64::ff::run(sc64, |ff| {
|
||||||
|
@ -14,7 +14,7 @@ pub use self::{
|
|||||||
link::list_local_devices,
|
link::list_local_devices,
|
||||||
server::ServerEvent,
|
server::ServerEvent,
|
||||||
types::{
|
types::{
|
||||||
AuxMessage, BootMode, ButtonMode, ButtonState, CicSeed, DataPacket, DdDiskState,
|
AuxMessage, BootMode, ButtonMode, ButtonState, CicSeed, CicStep, DataPacket, DdDiskState,
|
||||||
DdDriveType, DdMode, DebugPacket, DiagnosticData, DiskPacket, DiskPacketKind,
|
DdDriveType, DdMode, DebugPacket, DiagnosticData, DiskPacket, DiskPacketKind,
|
||||||
FpgaDebugData, ISViewer, MemoryTestPattern, MemoryTestPatternResult, SaveType,
|
FpgaDebugData, ISViewer, MemoryTestPattern, MemoryTestPatternResult, SaveType,
|
||||||
SaveWriteback, SdCardInfo, SdCardOpPacket, SdCardResult, SdCardStatus, SpeedTestDirection,
|
SaveWriteback, SdCardInfo, SdCardOpPacket, SdCardResult, SdCardStatus, SpeedTestDirection,
|
||||||
@ -98,7 +98,7 @@ const SRAM_1M_LENGTH: usize = 128 * 1024;
|
|||||||
|
|
||||||
const BOOTLOADER_ADDRESS: u32 = 0x04E0_0000;
|
const BOOTLOADER_ADDRESS: u32 = 0x04E0_0000;
|
||||||
|
|
||||||
const SD_CARD_BUFFER_ADDRESS: u32 = 0x03BA_0000; // Arbitrary offset in SDRAM memory
|
const SD_CARD_BUFFER_ADDRESS: u32 = 0x03FE_0000; // Arbitrary offset in SDRAM memory
|
||||||
const SD_CARD_BUFFER_LENGTH: usize = 128 * 1024; // Arbitrary length in SDRAM memory
|
const SD_CARD_BUFFER_LENGTH: usize = 128 * 1024; // Arbitrary length in SDRAM memory
|
||||||
|
|
||||||
pub const SD_CARD_SECTOR_SIZE: usize = 512;
|
pub const SD_CARD_SECTOR_SIZE: usize = 512;
|
||||||
@ -767,6 +767,14 @@ impl SC64 {
|
|||||||
self.command_state_reset()
|
self.command_state_reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_console_powered_on(&mut self) -> Result<bool, Error> {
|
||||||
|
let debug_data = self.command_fpga_debug_data_get()?;
|
||||||
|
Ok(match debug_data.cic_step {
|
||||||
|
CicStep::Unavailable | CicStep::PowerOff => false,
|
||||||
|
_ => true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
pub fn backup_firmware(&mut self) -> Result<Vec<u8>, Error> {
|
pub fn backup_firmware(&mut self) -> Result<Vec<u8>, Error> {
|
||||||
self.command_state_reset()?;
|
self.command_state_reset()?;
|
||||||
let (status, length) = self.command_firmware_backup(FIRMWARE_ADDRESS_SDRAM)?;
|
let (status, length) = self.command_firmware_backup(FIRMWARE_ADDRESS_SDRAM)?;
|
||||||
|
Loading…
Reference in New Issue
Block a user