mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Merge pull request #5428 from ligfx/makedspdumpconsistent
Make DSP code dumping consistent between DSP-LLE and DSP-HLE
This commit is contained in:
commit
6a599e2796
@ -90,7 +90,6 @@ set(SRCS
|
||||
HW/DSPLLE/DSPSymbols.cpp
|
||||
HW/DSPLLE/DSPLLEGlobals.cpp
|
||||
HW/DSPLLE/DSPLLE.cpp
|
||||
HW/DSPLLE/DSPLLETools.cpp
|
||||
HW/DVD/DVDInterface.cpp
|
||||
HW/DVD/DVDMath.cpp
|
||||
HW/DVD/DVDThread.cpp
|
||||
|
@ -117,7 +117,6 @@
|
||||
<ClCompile Include="HW\DSPLLE\DSPHost.cpp" />
|
||||
<ClCompile Include="HW\DSPLLE\DSPLLE.cpp" />
|
||||
<ClCompile Include="HW\DSPLLE\DSPLLEGlobals.cpp" />
|
||||
<ClCompile Include="HW\DSPLLE\DSPLLETools.cpp" />
|
||||
<ClCompile Include="HW\DSPLLE\DSPSymbols.cpp" />
|
||||
<ClCompile Include="HW\DVD\DVDInterface.cpp" />
|
||||
<ClCompile Include="HW\DVD\DVDMath.cpp" />
|
||||
@ -363,7 +362,6 @@
|
||||
<ClInclude Include="HW\DSPLLE\DSPDebugInterface.h" />
|
||||
<ClInclude Include="HW\DSPLLE\DSPLLE.h" />
|
||||
<ClInclude Include="HW\DSPLLE\DSPLLEGlobals.h" />
|
||||
<ClInclude Include="HW\DSPLLE\DSPLLETools.h" />
|
||||
<ClInclude Include="HW\DSPLLE\DSPSymbols.h" />
|
||||
<ClInclude Include="HW\DVD\DVDInterface.h" />
|
||||
<ClInclude Include="HW\DVD\DVDMath.h" />
|
||||
|
@ -395,9 +395,6 @@
|
||||
<ClCompile Include="HW\DSPLLE\DSPLLEGlobals.cpp">
|
||||
<Filter>HW %28Flipper/Hollywood%29\DSP Interface + HLE\LLE</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="HW\DSPLLE\DSPLLETools.cpp">
|
||||
<Filter>HW %28Flipper/Hollywood%29\DSP Interface + HLE\LLE</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="HW\DSPLLE\DSPSymbols.cpp">
|
||||
<Filter>HW %28Flipper/Hollywood%29\DSP Interface + HLE\LLE</Filter>
|
||||
</ClCompile>
|
||||
@ -1039,9 +1036,6 @@
|
||||
<ClInclude Include="HW\DSPLLE\DSPLLEGlobals.h">
|
||||
<Filter>HW %28Flipper/Hollywood%29\DSP Interface + HLE\LLE</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="HW\DSPLLE\DSPLLETools.h">
|
||||
<Filter>HW %28Flipper/Hollywood%29\DSP Interface + HLE\LLE</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="HW\DSPLLE\DSPSymbols.h">
|
||||
<Filter>HW %28Flipper/Hollywood%29\DSP Interface + HLE\LLE</Filter>
|
||||
</ClInclude>
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Common/Swap.h"
|
||||
|
||||
#include "Core/DSP/DSPAssembler.h"
|
||||
#include "Core/DSP/DSPCodeUtil.h"
|
||||
@ -218,4 +219,30 @@ bool SaveBinary(const std::vector<u16>& code, const std::string& filename)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DumpDSPCode(const u8* code_be, int size_in_bytes, u32 crc)
|
||||
{
|
||||
const std::string root_name =
|
||||
File::GetUserPath(D_DUMPDSP_IDX) + StringFromFormat("DSP_UC_%08X", crc);
|
||||
const std::string binary_file = root_name + ".bin";
|
||||
const std::string text_file = root_name + ".txt";
|
||||
|
||||
if (!File::IOFile(binary_file, "wb").WriteBytes(code_be, size_in_bytes))
|
||||
{
|
||||
PanicAlert("Can't dump UCode to file '%s'!!", binary_file.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// The disassembler works in native endian
|
||||
std::vector<u16> code(size_in_bytes / 2);
|
||||
for (size_t i = 0; i < code.size(); i++)
|
||||
code[i] = Common::swap16(&code_be[i * 2]);
|
||||
|
||||
std::string text;
|
||||
if (!Disassemble(code, true, text))
|
||||
return false;
|
||||
|
||||
return File::WriteStringToFile(text, text_file);
|
||||
}
|
||||
|
||||
} // namespace DSP
|
||||
|
@ -27,4 +27,6 @@ void BinaryStringBEToCode(const std::string& str, std::vector<u16>& code);
|
||||
// Load code (big endian binary).
|
||||
bool LoadBinary(const std::string& filename, std::vector<u16>& code);
|
||||
bool SaveBinary(const std::vector<u16>& code, const std::string& filename);
|
||||
|
||||
bool DumpDSPCode(const u8* code_be, int size_in_bytes, u32 crc);
|
||||
} // namespace DSP
|
||||
|
@ -5,8 +5,12 @@
|
||||
|
||||
#include "Core/DSP/DSPHWInterface.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
|
||||
#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,22 +231,22 @@ u16 gdsp_ifx_read(u16 addr)
|
||||
|
||||
static const u8* gdsp_idma_in(u16 dsp_addr, u32 addr, u32 size)
|
||||
{
|
||||
Common::UnWriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false);
|
||||
u16* dst = g_dsp.iram + (dsp_addr / 2);
|
||||
|
||||
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]);
|
||||
}
|
||||
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);
|
||||
memcpy(dst, code, size);
|
||||
for (size_t i = 0; i < size / 2; i++)
|
||||
dst[i] = Common::swap16(dst[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);
|
||||
|
||||
return dst + dsp_addr;
|
||||
return reinterpret_cast<u8*>(dst);
|
||||
}
|
||||
|
||||
static const u8* gdsp_idma_out(u16 dsp_addr, u32 addr, u32 size)
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/DSP/DSPCodeUtil.h"
|
||||
#include "Core/HW/DSPHLE/DSPHLE.h"
|
||||
#include "Core/HW/DSPHLE/MailHandler.h"
|
||||
#include "Core/HW/DSPHLE/UCodes/UCodes.h"
|
||||
@ -107,15 +108,8 @@ void ROMUCode::BootUCode()
|
||||
|
||||
if (SConfig::GetInstance().m_DumpUCode)
|
||||
{
|
||||
std::string ucode_dump_path =
|
||||
StringFromFormat("%sDSP_UC_%08X.bin", File::GetUserPath(D_DUMPDSP_IDX).c_str(), ector_crc);
|
||||
|
||||
File::IOFile fp(ucode_dump_path, "wb");
|
||||
if (fp)
|
||||
{
|
||||
fp.WriteArray((u8*)HLEMemory_Get_Pointer(m_current_ucode.m_ram_address),
|
||||
m_current_ucode.m_length);
|
||||
}
|
||||
DSP::DumpDSPCode(static_cast<u8*>(HLEMemory_Get_Pointer(m_current_ucode.m_ram_address)),
|
||||
m_current_ucode.m_length, ector_crc);
|
||||
}
|
||||
|
||||
INFO_LOG(DSPHLE, "CurrentUCode SOURCE Addr: 0x%08x", m_current_ucode.m_ram_address);
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Common/Swap.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/DSP/DSPCodeUtil.h"
|
||||
#include "Core/HW/DSPHLE/DSPHLE.h"
|
||||
#include "Core/HW/DSPHLE/UCodes/AX.h"
|
||||
#include "Core/HW/DSPHLE/UCodes/AXWii.h"
|
||||
@ -187,14 +188,8 @@ void UCodeInterface::PrepareBootUCode(u32 mail)
|
||||
|
||||
if (SConfig::GetInstance().m_DumpUCode)
|
||||
{
|
||||
std::string ucode_dump_path = StringFromFormat(
|
||||
"%sDSP_UC_%08X.bin", File::GetUserPath(D_DUMPDSP_IDX).c_str(), ector_crc);
|
||||
|
||||
File::IOFile fp(ucode_dump_path, "wb");
|
||||
if (fp)
|
||||
{
|
||||
fp.WriteArray((u8*)Memory::GetPointer(m_next_ucode.iram_mram_addr), m_next_ucode.iram_size);
|
||||
}
|
||||
DSP::DumpDSPCode(static_cast<u8*>(Memory::GetPointer(m_next_ucode.iram_mram_addr)),
|
||||
m_next_ucode.iram_size, ector_crc);
|
||||
}
|
||||
|
||||
DEBUG_LOG(DSPHLE, "PrepareBootUCode 0x%08x", ector_crc);
|
||||
|
@ -8,10 +8,10 @@
|
||||
#include "Common/Logging/Log.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/DSP/DSPAnalyzer.h"
|
||||
#include "Core/DSP/DSPCodeUtil.h"
|
||||
#include "Core/DSP/DSPCore.h"
|
||||
#include "Core/DSP/Jit/DSPEmitter.h"
|
||||
#include "Core/HW/DSP.h"
|
||||
#include "Core/HW/DSPLLE/DSPLLETools.h"
|
||||
#include "Core/HW/DSPLLE/DSPSymbols.h"
|
||||
#include "Core/Host.h"
|
||||
#include "VideoCommon/OnScreenDisplay.h"
|
||||
@ -58,11 +58,10 @@ void InterruptRequest()
|
||||
|
||||
void CodeLoaded(const u8* ptr, int size)
|
||||
{
|
||||
g_dsp.iram_crc = HashEctor(ptr, size);
|
||||
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
LLE::DumpDSPCode(ptr, size, g_dsp.iram_crc);
|
||||
#endif
|
||||
if (SConfig::GetInstance().m_DumpUCode)
|
||||
{
|
||||
DSP::DumpDSPCode(ptr, size, g_dsp.iram_crc);
|
||||
}
|
||||
|
||||
Symbols::Clear();
|
||||
|
||||
|
@ -1,84 +0,0 @@
|
||||
// Copyright 2008 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/StringUtil.h"
|
||||
#include "Core/DSP/DSPCodeUtil.h"
|
||||
#include "Core/DSP/DSPCore.h"
|
||||
#include "Core/DSP/DSPDisassembler.h"
|
||||
#include "Core/HW/DSPLLE/DSPLLETools.h"
|
||||
|
||||
namespace DSP
|
||||
{
|
||||
namespace LLE
|
||||
{
|
||||
bool DumpDSPCode(const u8* code_be, int size_in_bytes, u32 crc)
|
||||
{
|
||||
const std::string binFile =
|
||||
StringFromFormat("%sDSP_UC_%08X.bin", File::GetUserPath(D_DUMPDSP_IDX).c_str(), crc);
|
||||
const std::string txtFile =
|
||||
StringFromFormat("%sDSP_UC_%08X.txt", File::GetUserPath(D_DUMPDSP_IDX).c_str(), crc);
|
||||
|
||||
File::IOFile pFile(binFile, "wb");
|
||||
if (pFile)
|
||||
{
|
||||
pFile.WriteBytes(code_be, size_in_bytes);
|
||||
pFile.Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
PanicAlert("Can't open file (%s) to dump UCode!!", binFile.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Load the binary back in.
|
||||
std::vector<u16> code;
|
||||
LoadBinary(binFile, code);
|
||||
|
||||
AssemblerSettings settings;
|
||||
settings.show_hex = true;
|
||||
settings.show_pc = true;
|
||||
settings.ext_separator = '\'';
|
||||
settings.decode_names = true;
|
||||
settings.decode_registers = true;
|
||||
|
||||
std::string text;
|
||||
DSPDisassembler disasm(settings);
|
||||
|
||||
if (!disasm.Disassemble(0, code, 0x0000, text))
|
||||
return false;
|
||||
|
||||
return File::WriteStringToFile(text, txtFile);
|
||||
}
|
||||
|
||||
// TODO make this useful :p
|
||||
bool DumpCWCode(u32 _Address, u32 _Length)
|
||||
{
|
||||
std::string filename = File::GetUserPath(D_DUMPDSP_IDX) + "DSP_UCode.bin";
|
||||
File::IOFile pFile(filename, "wb");
|
||||
|
||||
if (pFile)
|
||||
{
|
||||
for (size_t i = _Address; i != _Address + _Length; ++i)
|
||||
{
|
||||
u16 val = g_dsp.iram[i];
|
||||
fprintf(pFile.GetHandle(), " cw 0x%04x \n", val);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
} // namespace LLE
|
||||
} // namespace DSP
|
@ -1,16 +0,0 @@
|
||||
// Copyright 2008 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
namespace DSP
|
||||
{
|
||||
namespace LLE
|
||||
{
|
||||
bool DumpDSPCode(const u8* code_be, int size_in_bytes, u32 crc);
|
||||
bool DumpCWCode(u32 _Address, u32 _Length);
|
||||
} // namespace DSP
|
||||
} // namespace LLE
|
Loading…
Reference in New Issue
Block a user