mirror of
https://github.com/Polprzewodnikowy/SummerCart64.git
synced 2024-11-22 05:59:15 +01:00
[SC64][SW] Added firmware update overwrite safeguard
This commit is contained in:
parent
4795e23890
commit
ce957faaa9
@ -356,6 +356,12 @@ bool cfg_update (uint32_t *args) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool cfg_set_rom_write_enable (bool value) {
|
||||
uint32_t scr = fpga_reg_get(REG_CFG_SCR);
|
||||
cfg_change_scr_bits(CFG_SCR_ROM_WRITE_ENABLED, value);
|
||||
return (scr & CFG_SCR_ROM_WRITE_ENABLED);
|
||||
}
|
||||
|
||||
save_type_t cfg_get_save_type (void) {
|
||||
return p.save_type;
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ typedef enum {
|
||||
uint32_t cfg_get_version (void);
|
||||
bool cfg_query (uint32_t *args);
|
||||
bool cfg_update (uint32_t *args);
|
||||
bool cfg_set_rom_write_enable (bool value);
|
||||
save_type_t cfg_get_save_type (void);
|
||||
void cfg_get_time (uint32_t *args);
|
||||
void cfg_set_time (uint32_t *args);
|
||||
|
@ -252,15 +252,19 @@ static void usb_rx_process (void) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
case 'f': {
|
||||
bool rom_write_enable_restore = cfg_set_rom_write_enable(false);
|
||||
p.response_info.data[0] = update_backup(p.rx_args[0], &p.response_info.data[1]);
|
||||
p.rx_state = RX_STATE_IDLE;
|
||||
p.response_pending = true;
|
||||
p.response_error = (p.response_info.data[0] != UPDATE_OK);
|
||||
p.response_info.data_length = 8;
|
||||
cfg_set_rom_write_enable(rom_write_enable_restore);
|
||||
break;
|
||||
}
|
||||
|
||||
case 'F':
|
||||
case 'F': {
|
||||
bool rom_write_enable_restore = cfg_set_rom_write_enable(false);
|
||||
p.response_info.data[0] = update_prepare(p.rx_args[0], p.rx_args[1]);
|
||||
p.rx_state = RX_STATE_IDLE;
|
||||
p.response_pending = true;
|
||||
@ -269,8 +273,10 @@ static void usb_rx_process (void) {
|
||||
p.response_info.done_callback = update_start;
|
||||
} else {
|
||||
p.response_error = true;
|
||||
cfg_set_rom_write_enable(rom_write_enable_restore);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case 'p':
|
||||
if (p.rx_args[0]) {
|
||||
|
Loading…
Reference in New Issue
Block a user