Added support for SRAM 1M save type

This commit is contained in:
Mateusz Faderewski 2023-03-31 22:04:58 +02:00
parent 009f41d87f
commit d2eaa38df0
10 changed files with 36 additions and 14 deletions

View File

@ -59,7 +59,8 @@ typedef enum {
SAVE_TYPE_EEPROM_16K = 2,
SAVE_TYPE_SRAM = 3,
SAVE_TYPE_FLASHRAM = 4,
SAVE_TYPE_SRAM_BANKED = 5
SAVE_TYPE_SRAM_BANKED = 5,
SAVE_TYPE_SRAM_1M = 6
} sc64_save_type_t;
typedef enum {

View File

@ -210,6 +210,9 @@ static bool cfg_set_save_type (save_type_t save_type) {
case SAVE_TYPE_SRAM_BANKED:
cfg_change_scr_bits(CFG_SCR_SRAM_BANKED | CFG_SCR_SRAM_ENABLED, true);
break;
case SAVE_TYPE_SRAM_1M:
cfg_change_scr_bits(CFG_SCR_SRAM_ENABLED, true);
break;
default:
save_type = SAVE_TYPE_NONE;
break;

View File

@ -12,7 +12,8 @@ typedef enum {
SAVE_TYPE_EEPROM_16K = 2,
SAVE_TYPE_SRAM = 3,
SAVE_TYPE_FLASHRAM = 4,
SAVE_TYPE_SRAM_BANKED = 5
SAVE_TYPE_SRAM_BANKED = 5,
SAVE_TYPE_SRAM_1M = 6,
} save_type_t;

View File

@ -14,6 +14,7 @@
#define SRAM_LENGTH (32 * 1024)
#define FLASHRAM_LENGTH (128 * 1024)
#define SRAM_BANKED_LENGTH (3 * 32 * 1024)
#define SRAM_1M_LENGTH (128 * 1024)
#define WRITEBACK_DELAY_TICKS (100)
@ -53,6 +54,10 @@ static save_type_t writeback_get_address_length (uint32_t *address, uint32_t *le
*address = SRAM_FLASHRAM_ADDRESS;
*length = SRAM_BANKED_LENGTH;
break;
case SAVE_TYPE_SRAM_1M:
*address = SRAM_FLASHRAM_ADDRESS;
*length = SRAM_1M_LENGTH;
break;
default:
*address = 0;
*length = 0;

View File

@ -7,6 +7,7 @@ use std::{
io::{stdin, ErrorKind, Read, Write},
net::{TcpListener, TcpStream},
panic,
path::PathBuf,
sync::mpsc::{channel, Receiver, Sender},
thread::{sleep, spawn},
time::Duration,
@ -285,7 +286,9 @@ impl Handler {
"save",
match save_writeback.save {
sc64::SaveType::Eeprom4k | sc64::SaveType::Eeprom16k => "eep",
sc64::SaveType::Sram | sc64::SaveType::SramBanked => "srm",
sc64::SaveType::Sram | sc64::SaveType::SramBanked | sc64::SaveType::Sram1m => {
"srm"
}
sc64::SaveType::Flashram => "fla",
_ => "sav",
},

View File

@ -217,6 +217,7 @@ enum SaveType {
Eeprom16k,
Sram,
SramBanked,
Sram1m,
Flashram,
}
@ -228,8 +229,8 @@ impl From<n64::SaveType> for SaveType {
n64::SaveType::Eeprom16k => Self::Eeprom16k,
n64::SaveType::Sram => Self::Sram,
n64::SaveType::SramBanked => Self::SramBanked,
n64::SaveType::Sram1m => Self::Sram1m,
n64::SaveType::Flashram => Self::Flashram,
n64::SaveType::Sram128kB => Self::Sram,
}
}
}
@ -242,6 +243,7 @@ impl From<SaveType> for sc64::SaveType {
SaveType::Eeprom16k => Self::Eeprom16k,
SaveType::Sram => Self::Sram,
SaveType::SramBanked => Self::SramBanked,
SaveType::Sram1m => Self::Sram1m,
SaveType::Flashram => Self::Flashram,
}
}

View File

@ -10,7 +10,7 @@ pub enum SaveType {
Sram,
SramBanked,
Flashram,
Sram128kB,
Sram1m,
}
const HASH_CHUNK_LENGTH: usize = 1 * 1024 * 1024;
@ -31,7 +31,7 @@ pub fn guess_save_type<T: Read + Seek>(
3 => SaveType::Sram,
4 => SaveType::SramBanked,
5 => SaveType::Flashram,
6 => SaveType::Sram128kB,
6 => SaveType::Sram1m,
_ => SaveType::None,
},
None,

View File

@ -3,8 +3,8 @@ mod error;
pub mod firmware;
mod link;
mod server;
mod time;
mod types;
mod utils;
pub use self::{
error::Error,
@ -20,10 +20,10 @@ pub use self::{
use self::{
cic::{calculate_ipl3_checksum, guess_ipl3_seed, IPL3_LENGTH, IPL3_OFFSET},
link::{Command, Link},
time::{convert_from_datetime, convert_to_datetime},
types::{
get_config, get_setting, Config, ConfigId, FirmwareStatus, Setting, SettingId, UpdateStatus,
},
utils::{convert_from_datetime, convert_to_datetime},
};
use chrono::{DateTime, Local};
use std::{
@ -83,8 +83,9 @@ const EEPROM_ADDRESS: u32 = 0x0500_2000;
const EEPROM_4K_LENGTH: usize = 512;
const EEPROM_16K_LENGTH: usize = 2 * 1024;
const SRAM_LENGTH: usize = 32 * 1024;
const SRAM_BANKED_LENGTH: usize = 3 * 32 * 1024;
const FLASHRAM_LENGTH: usize = 128 * 1024;
const SRAM_BANKED_LENGTH: usize = 3 * 32 * 1024;
const SRAM_1M_LENGTH: usize = 128 * 1024;
const BOOTLOADER_ADDRESS: u32 = 0x04E0_0000;
@ -450,8 +451,9 @@ impl SC64 {
SaveType::Eeprom4k => (EEPROM_ADDRESS, EEPROM_4K_LENGTH),
SaveType::Eeprom16k => (EEPROM_ADDRESS, EEPROM_16K_LENGTH),
SaveType::Sram => (SAVE_ADDRESS, SRAM_LENGTH),
SaveType::SramBanked => (SAVE_ADDRESS, SRAM_BANKED_LENGTH),
SaveType::Flashram => (SAVE_ADDRESS, FLASHRAM_LENGTH),
SaveType::SramBanked => (SAVE_ADDRESS, SRAM_BANKED_LENGTH),
SaveType::Sram1m => (SAVE_ADDRESS, SRAM_1M_LENGTH),
};
if length != save_length {
@ -473,8 +475,9 @@ impl SC64 {
SaveType::Eeprom4k => (EEPROM_ADDRESS, EEPROM_4K_LENGTH),
SaveType::Eeprom16k => (EEPROM_ADDRESS, EEPROM_16K_LENGTH),
SaveType::Sram => (SAVE_ADDRESS, SRAM_LENGTH),
SaveType::SramBanked => (SAVE_ADDRESS, SRAM_BANKED_LENGTH),
SaveType::Flashram => (SAVE_ADDRESS, FLASHRAM_LENGTH),
SaveType::SramBanked => (SAVE_ADDRESS, SRAM_BANKED_LENGTH),
SaveType::Sram1m => (SAVE_ADDRESS, SRAM_1M_LENGTH),
};
self.memory_read_chunked(writer, address, save_length)

View File

@ -253,6 +253,7 @@ pub enum SaveType {
Sram,
Flashram,
SramBanked,
Sram1m,
}
impl Display for SaveType {
@ -261,9 +262,10 @@ impl Display for SaveType {
Self::None => "None",
Self::Eeprom4k => "EEPROM 4k",
Self::Eeprom16k => "EEPROM 16k",
Self::Sram => "SRAM",
Self::SramBanked => "SRAM banked",
Self::Flashram => "FlashRAM",
Self::Sram => "SRAM 256k",
Self::SramBanked => "SRAM 768k",
Self::Flashram => "FlashRAM 1M",
Self::Sram1m => "SRAM 1M",
})
}
}
@ -278,6 +280,7 @@ impl TryFrom<u32> for SaveType {
3 => Self::Sram,
4 => Self::Flashram,
5 => Self::SramBanked,
6 => Self::Sram1m,
_ => return Err(Error::new("Unknown save type code")),
})
}
@ -292,6 +295,7 @@ impl From<SaveType> for u32 {
SaveType::Sram => 3,
SaveType::Flashram => 4,
SaveType::SramBanked => 5,
SaveType::Sram1m => 6,
}
}
}