Firmware: Fix a data corruption bug with firmware.dfc that could occur with a rare and specific sequence of events.

This commit is contained in:
rogerman 2022-05-16 01:30:31 -07:00
parent 7cccf90976
commit 1bbb065786
3 changed files with 11 additions and 8 deletions

View File

@ -1,7 +1,7 @@
/*
Copyright (C) 2006 yopyop
Copyright (C) 2007 shash
Copyright (C) 2007-2021 DeSmuME team
Copyright (C) 2007-2022 DeSmuME team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -5199,7 +5199,7 @@ void FASTCALL _MMU_ARM7_write08(u32 adr, u8 val)
if (NDS_ARM7.instruct_adr > 0x3FFF) return;
#ifdef HAVE_JIT
// hack for firmware boot in JIT mode
if (CommonSettings.UseExtFirmware && CommonSettings.BootFromFirmware && extFirmwareObj->loaded() && val == 1)
if (CommonSettings.UseExtFirmware && CommonSettings.BootFromFirmware && extFirmwareObj->isLoaded() && val == 1)
CommonSettings.jit_max_block_size = saveBlockSizeJIT;
#endif
break;

View File

@ -1,5 +1,5 @@
/*
Copyright (C) 2009-2019 DeSmuME Team
Copyright (C) 2009-2022 DeSmuME Team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -531,7 +531,7 @@ std::string CFIRMWARE::GetUserSettingsFilePath(const char *firmwareFilePath)
return finalPath;
}
bool CFIRMWARE::loaded()
bool CFIRMWARE::isLoaded()
{
return this->_isLoaded;
}
@ -1319,9 +1319,12 @@ bool NDS_ReadFirmwareDataFromFile(const char *fileName, NDSFirmwareData *outFirm
void fw_reset_com(fw_memory_chip *mc)
{
if(mc->com == FW_CMD_PAGEWRITE)
if (mc->com == FW_CMD_PAGEWRITE)
{
if (mc->isFirmware && CommonSettings.UseExtFirmware && CommonSettings.UseExtFirmwareSettings && (extFirmwareObj != NULL))
if (mc->isFirmware &&
CommonSettings.UseExtFirmware &&
CommonSettings.UseExtFirmwareSettings &&
(extFirmwareObj != NULL) && extFirmwareObj->isLoaded())
{
extFirmwareObj->saveSettings(CommonSettings.ExtFirmwareUserSettingsPath);
}

View File

@ -1,5 +1,5 @@
/*
Copyright (C) 2009-2019 DeSmuME Team
Copyright (C) 2009-2022 DeSmuME Team
This file is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -439,7 +439,7 @@ public:
bool loadSettings(const char *firmwareUserSettingsFilePath);
bool saveSettings(const char *firmwareUserSettingsFilePath);
bool loaded();
bool isLoaded();
void* getTouchCalibrate();
static std::string GetUserSettingsFilePath(const char *firmwareFilePath);