From 59c863329d22d41ec1ed6be00d5d3c2fdfaa261d Mon Sep 17 00:00:00 2001 From: Michael Maltese Date: Sun, 14 May 2017 21:00:08 -0700 Subject: [PATCH] DSP-LLE: calculate code CRC _before_ swapping endianness - Makes DSP-LLE code checksums the same as those from DSP-HLE. I'm assuming DSP-HLE was doing it correctly, since there are numerous references to these pre-endian-swapped checksums (including in DSPHost.cpp itself). - Fixes disassembly when dumping code from DSP-LLE, which was using the wrong endianness and giving totally bogus output. - Reveals error messages of the format, "Bah! ReadAnnotatedAssembly couldn't find the file ../../docs/DSP/DSP_UC_AX_07F88145.txt," which seems to be intended behavior that was previously hidden. --- Source/Core/Core/DSP/DSPHWInterface.cpp | 10 ++++++---- Source/Core/Core/HW/DSPLLE/DSPHost.cpp | 2 -- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Core/Core/DSP/DSPHWInterface.cpp b/Source/Core/Core/DSP/DSPHWInterface.cpp index 9c73e69388..c5fb7a3397 100644 --- a/Source/Core/Core/DSP/DSPHWInterface.cpp +++ b/Source/Core/Core/DSP/DSPHWInterface.cpp @@ -7,6 +7,7 @@ #include "Common/CPUDetect.h" #include "Common/CommonTypes.h" +#include "Common/Hash.h" #include "Common/Intrinsics.h" #include "Common/Logging/Log.h" #include "Common/MemoryUtil.h" @@ -227,18 +228,19 @@ u16 gdsp_ifx_read(u16 addr) static const u8* gdsp_idma_in(u16 dsp_addr, u32 addr, u32 size) { + const u8* code = &g_dsp.cpu_ram[addr & 0x0fffffff]; + g_dsp.iram_crc = HashEctor(code, size); + Common::UnWriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false); u8* dst = ((u8*)g_dsp.iram); for (u32 i = 0; i < size; i += 2) { - *(u16*)&dst[dsp_addr + i] = - Common::swap16(*(const u16*)&g_dsp.cpu_ram[(addr + i) & 0x0fffffff]); + *(u16*)&dst[dsp_addr + i] = Common::swap16(*(const u16*)&code[i]); } Common::WriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false); - Host::CodeLoaded((const u8*)g_dsp.iram + dsp_addr, size); - + Host::CodeLoaded(code, size); NOTICE_LOG(DSPLLE, "*** Copy new UCode from 0x%08x to 0x%04x (crc: %8x)", addr, dsp_addr, g_dsp.iram_crc); diff --git a/Source/Core/Core/HW/DSPLLE/DSPHost.cpp b/Source/Core/Core/HW/DSPLLE/DSPHost.cpp index b723705044..892d0d245e 100644 --- a/Source/Core/Core/HW/DSPLLE/DSPHost.cpp +++ b/Source/Core/Core/HW/DSPLLE/DSPHost.cpp @@ -58,8 +58,6 @@ void InterruptRequest() void CodeLoaded(const u8* ptr, int size) { - g_dsp.iram_crc = HashEctor(ptr, size); - if (SConfig::GetInstance().m_DumpUCode) { DSP::DumpDSPCode(ptr, size, g_dsp.iram_crc);