DSP: Namespace remaining un-namespaced DSP code

This commit is contained in:
Lioncash
2016-12-31 17:20:14 -05:00
parent a2e191649d
commit 3eb25cea6f
70 changed files with 672 additions and 414 deletions
+12 -9
View File
@@ -11,6 +11,8 @@
#include "Core/DSP/DSPCore.h"
#include "Core/DSP/DSPHost.h"
namespace DSP
{
// The hardware adpcm decoder :)
static s16 ADPCM_Step(u32& _rSamplePos)
{
@@ -18,7 +20,7 @@ static s16 ADPCM_Step(u32& _rSamplePos)
if ((_rSamplePos & 15) == 0)
{
g_dsp.ifx_regs[DSP_PRED_SCALE] = DSPHost::ReadHostMemory((_rSamplePos & ~15) >> 1);
g_dsp.ifx_regs[DSP_PRED_SCALE] = Host::ReadHostMemory((_rSamplePos & ~15) >> 1);
_rSamplePos += 2;
}
@@ -28,8 +30,8 @@ static s16 ADPCM_Step(u32& _rSamplePos)
s32 coef1 = pCoefTable[coef_idx * 2 + 0];
s32 coef2 = pCoefTable[coef_idx * 2 + 1];
int temp = (_rSamplePos & 1) ? (DSPHost::ReadHostMemory(_rSamplePos >> 1) & 0xF) :
(DSPHost::ReadHostMemory(_rSamplePos >> 1) >> 4);
int temp = (_rSamplePos & 1) ? (Host::ReadHostMemory(_rSamplePos >> 1) & 0xF) :
(Host::ReadHostMemory(_rSamplePos >> 1) >> 4);
if (temp >= 8)
temp -= 16;
@@ -60,11 +62,11 @@ u16 dsp_read_aram_d3()
switch (g_dsp.ifx_regs[DSP_FORMAT])
{
case 0x5: // u8 reads
val = DSPHost::ReadHostMemory(Address);
val = Host::ReadHostMemory(Address);
Address++;
break;
case 0x6: // u16 reads
val = (DSPHost::ReadHostMemory(Address * 2) << 8) | DSPHost::ReadHostMemory(Address * 2 + 1);
val = (Host::ReadHostMemory(Address * 2) << 8) | Host::ReadHostMemory(Address * 2 + 1);
Address++;
break;
default:
@@ -94,8 +96,8 @@ void dsp_write_aram_d3(u16 value)
switch (g_dsp.ifx_regs[DSP_FORMAT])
{
case 0xA: // u16 writes
DSPHost::WriteHostMemory(value >> 8, Address * 2);
DSPHost::WriteHostMemory(value & 0xFF, Address * 2 + 1);
Host::WriteHostMemory(value >> 8, Address * 2);
Host::WriteHostMemory(value & 0xFF, Address * 2 + 1);
Address++;
break;
default:
@@ -138,14 +140,14 @@ u16 dsp_read_accelerator()
val = ADPCM_Step(Address);
break;
case 0x0A: // 16-bit PCM audio
val = (DSPHost::ReadHostMemory(Address * 2) << 8) | DSPHost::ReadHostMemory(Address * 2 + 1);
val = (Host::ReadHostMemory(Address * 2) << 8) | Host::ReadHostMemory(Address * 2 + 1);
g_dsp.ifx_regs[DSP_YN2] = g_dsp.ifx_regs[DSP_YN1];
g_dsp.ifx_regs[DSP_YN1] = val;
step_size_bytes = 2;
Address++;
break;
case 0x19: // 8-bit PCM audio
val = DSPHost::ReadHostMemory(Address) << 8;
val = Host::ReadHostMemory(Address) << 8;
g_dsp.ifx_regs[DSP_YN2] = g_dsp.ifx_regs[DSP_YN1];
g_dsp.ifx_regs[DSP_YN1] = val;
step_size_bytes = 2;
@@ -179,3 +181,4 @@ u16 dsp_read_accelerator()
g_dsp.ifx_regs[DSP_ACCAL] = Address & 0xffff;
return val;
}
} // namespace DSP
+3
View File
@@ -6,7 +6,10 @@
#include "Common/CommonTypes.h"
namespace DSP
{
u16 dsp_read_accelerator();
u16 dsp_read_aram_d3();
void dsp_write_aram_d3(u16 value);
} // namespace DSP
+5 -2
View File
@@ -12,7 +12,9 @@
#include "Core/DSP/DSPMemoryMap.h"
#include "Core/DSP/DSPTables.h"
namespace DSPAnalyzer
namespace DSP
{
namespace Analyzer
{
namespace
{
@@ -165,4 +167,5 @@ u8 GetCodeFlags(u16 address)
return code_flags[address];
}
} // namespace DSPAnalyzer
} // namespace Analyzer
} // namespace DSP
+5 -2
View File
@@ -7,7 +7,9 @@
#include "Common/CommonTypes.h"
// Basic code analysis.
namespace DSPAnalyzer
namespace DSP
{
namespace Analyzer
{
// Useful things to detect:
// * Loop endpoints - so that we can avoid checking for loops every cycle.
@@ -33,4 +35,5 @@ void Analyze();
// Retrieves the flags set during analysis for code in memory.
u8 GetCodeFlags(u16 address);
} // namespace DSPAnalyzer
} // namespace Analyzer
} // namespace DSP
+3
View File
@@ -19,6 +19,8 @@
#include "Core/DSP/DSPDisassembler.h"
#include "Core/DSP/DSPTables.h"
namespace DSP
{
static const char* err_string[] = {"",
"Unknown Error",
"Unknown opcode",
@@ -1031,3 +1033,4 @@ bool DSPAssembler::AssembleFile(const char* fname, int pass)
return !failed;
}
} // namespace DSP
+3
View File
@@ -14,6 +14,8 @@
#include "Core/DSP/DSPTables.h"
#include "Core/DSP/LabelMap.h"
namespace DSP
{
enum err_t
{
ERR_OK = 0,
@@ -116,3 +118,4 @@ private:
int m_current_param;
const AssemblerSettings settings_;
};
} // namespace DSP
+3
View File
@@ -7,6 +7,8 @@
#include <cstring>
#include "Common/CommonTypes.h"
namespace DSP
{
// super fast breakpoints for a limited range.
// To be used interchangeably with the BreakPoints class.
class DSPBreakpoints
@@ -44,3 +46,4 @@ public:
private:
u8 b[65536];
};
} // namespace DSP
@@ -11,6 +11,8 @@
#include "Core/DSP/DSPCaptureLogger.h"
namespace DSP
{
// Definition of the packet structures stored in PCAP capture files.
const u8 IFX_ACCESS_PACKET_MAGIC = 0;
@@ -77,3 +79,4 @@ void PCAPDSPCaptureLogger::LogDMA(u16 control, u32 gc_address, u16 dsp_address,
m_pcap->AddPacket(buffer, sizeof(DMAPacket) + length);
}
} // namespace DSP
+3
View File
@@ -12,6 +12,8 @@
class PCAP;
namespace DSP
{
// An interface used to capture and log structured data about internal DSP
// data transfers.
//
@@ -70,3 +72,4 @@ private:
std::unique_ptr<PCAP> m_pcap;
};
} // namespace DSP
+3
View File
@@ -15,6 +15,8 @@
#include "Core/DSP/DSPCodeUtil.h"
#include "Core/DSP/DSPDisassembler.h"
namespace DSP
{
bool Assemble(const std::string& text, std::vector<u16>& code, bool force)
{
AssemblerSettings settings;
@@ -216,3 +218,4 @@ bool SaveBinary(const std::vector<u16>& code, const std::string& filename)
return false;
return true;
}
} // namespace DSP
+3
View File
@@ -9,6 +9,8 @@
#include "Common/CommonTypes.h"
namespace DSP
{
bool Assemble(const std::string& text, std::vector<u16>& code, bool force = false);
bool Disassemble(const std::vector<u16>& code, bool line_numbers, std::string& text);
bool Compare(const std::vector<u16>& code1, const std::vector<u16>& code2);
@@ -25,3 +27,4 @@ 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);
} // namespace DSP
+3
View File
@@ -6,4 +6,7 @@
#include "Common/CommonTypes.h"
namespace DSP
{
typedef u16 UDSPInstruction;
} // namespace DSP
+21 -17
View File
@@ -24,12 +24,14 @@
#include "Core/DSP/Interpreter/DSPInterpreter.h"
#include "Core/DSP/Jit/DSPEmitter.h"
namespace DSP
{
SDSP g_dsp;
DSPBreakpoints g_dsp_breakpoints;
static DSPCoreState core_state = DSPCORE_STOP;
u16 g_cycles_left = 0;
bool g_init_hax = false;
std::unique_ptr<DSP::JIT::x86::DSPEmitter> g_dsp_jit;
std::unique_ptr<JIT::x86::DSPEmitter> g_dsp_jit;
std::unique_ptr<DSPCaptureLogger> g_dsp_cap;
static Common::Event step_event;
@@ -77,14 +79,14 @@ static bool VerifyRoms()
if (rom_idx == 1)
{
DSPHost::OSD_AddMessage("You are using an old free DSP ROM made by the Dolphin Team.", 6000);
DSPHost::OSD_AddMessage("Only games using the Zelda UCode will work correctly.", 6000);
Host::OSD_AddMessage("You are using an old free DSP ROM made by the Dolphin Team.", 6000);
Host::OSD_AddMessage("Only games using the Zelda UCode will work correctly.", 6000);
}
else if (rom_idx == 2 || rom_idx == 3)
{
DSPHost::OSD_AddMessage("You are using a free DSP ROM made by the Dolphin Team.", 8000);
DSPHost::OSD_AddMessage("All Wii games will work correctly, and most GC games should ", 8000);
DSPHost::OSD_AddMessage("also work fine, but the GBA/IPL/CARD UCodes will not work.", 8000);
Host::OSD_AddMessage("You are using a free DSP ROM made by the Dolphin Team.", 8000);
Host::OSD_AddMessage("All Wii games will work correctly, and most GC games should ", 8000);
Host::OSD_AddMessage("also work fine, but the GBA/IPL/CARD UCodes will not work.", 8000);
}
return true;
@@ -148,7 +150,7 @@ bool DSPCore_Init(const DSPInitOptions& opts)
// Initialize JIT, if necessary
if (opts.core_type == DSPInitOptions::CORE_JIT)
g_dsp_jit = std::make_unique<DSP::JIT::x86::DSPEmitter>();
g_dsp_jit = std::make_unique<JIT::x86::DSPEmitter>();
g_dsp_cap.reset(opts.capture_logger);
@@ -176,7 +178,7 @@ void DSPCore_Reset()
std::fill(std::begin(g_dsp.r.wr), std::end(g_dsp.r.wr), 0xffff);
DSPAnalyzer::Analyze();
Analyzer::Analyze();
}
void DSPCore_SetException(u8 level)
@@ -193,7 +195,7 @@ void DSPCore_SetExternalInterrupt(bool val)
// Coming from the CPU
void DSPCore_CheckExternalInterrupt()
{
if (!DSP::Interpreter::dsp_SR_is_flag_set(SR_EXT_INT_ENABLE))
if (!Interpreter::dsp_SR_is_flag_set(SR_EXT_INT_ENABLE))
return;
// Signal the SPU about new mail
@@ -213,7 +215,7 @@ void DSPCore_CheckExceptions()
// Seems exp int are not masked by sr_int_enable
if (g_dsp.exceptions & (1 << i))
{
if (DSP::Interpreter::dsp_SR_is_flag_set(SR_INT_ENABLE) || (i == EXP_INT))
if (Interpreter::dsp_SR_is_flag_set(SR_INT_ENABLE) || (i == EXP_INT))
{
// store pc and sr until RTI
dsp_reg_store_stack(DSP_STACK_C, g_dsp.pc);
@@ -251,7 +253,7 @@ int DSPCore_RunCycles(int cycles)
}
g_cycles_left = cycles;
auto exec_addr = (DSP::JIT::x86::DSPEmitter::DSPCompiledCode)g_dsp_jit->enterDispatcher;
auto exec_addr = (JIT::x86::DSPEmitter::DSPCompiledCode)g_dsp_jit->enterDispatcher;
exec_addr();
if (g_dsp.reset_dspjit_codespace)
@@ -267,9 +269,9 @@ int DSPCore_RunCycles(int cycles)
case DSPCORE_RUNNING:
// Seems to slow things down
#if defined(_DEBUG) || defined(DEBUGFAST)
cycles = DSP::Interpreter::RunCyclesDebug(cycles);
cycles = Interpreter::RunCyclesDebug(cycles);
#else
cycles = DSP::Interpreter::RunCycles(cycles);
cycles = Interpreter::RunCycles(cycles);
#endif
break;
@@ -278,10 +280,10 @@ int DSPCore_RunCycles(int cycles)
if (core_state != DSPCORE_STEPPING)
continue;
DSP::Interpreter::Step();
Interpreter::Step();
cycles--;
DSPHost::UpdateDebugger();
Host::UpdateDebugger();
break;
case DSPCORE_STOP:
break;
@@ -293,11 +295,12 @@ int DSPCore_RunCycles(int cycles)
void DSPCore_SetState(DSPCoreState new_state)
{
core_state = new_state;
// kick the event, in case we are waiting
if (new_state == DSPCORE_RUNNING)
step_event.Set();
// Sleep(10);
DSPHost::UpdateDebugger();
Host::UpdateDebugger();
}
DSPCoreState DSPCore_GetState()
@@ -458,3 +461,4 @@ void DSPCore_WriteRegister(size_t reg, u16 val)
break;
}
}
} // namespace DSP
+2 -2
View File
@@ -23,7 +23,6 @@ namespace x86
class DSPEmitter;
}
}
}
enum : u32
{
@@ -311,7 +310,7 @@ extern SDSP g_dsp;
extern DSPBreakpoints g_dsp_breakpoints;
extern u16 g_cycles_left;
extern bool g_init_hax;
extern std::unique_ptr<DSP::JIT::x86::DSPEmitter> g_dsp_jit;
extern std::unique_ptr<JIT::x86::DSPEmitter> g_dsp_jit;
extern std::unique_ptr<DSPCaptureLogger> g_dsp_cap;
struct DSPInitOptions
@@ -371,3 +370,4 @@ void DSPCore_Step();
u16 DSPCore_ReadRegister(size_t reg);
void DSPCore_WriteRegister(size_t reg, u16 val);
} // namespace DSP
+3
View File
@@ -17,6 +17,8 @@
#include "Core/DSP/DSPTables.h"
#include "Core/DSP/Interpreter/DSPInterpreter.h"
namespace DSP
{
DSPDisassembler::DSPDisassembler(const AssemblerSettings& settings) : settings_(settings)
{
}
@@ -335,3 +337,4 @@ bool DSPDisassembler::DisassembleFile(const std::string& name, int base_addr, in
return true;
}
} // namespace DSP
+3
View File
@@ -14,6 +14,8 @@
#include "Core/DSP/DSPTables.h"
#include "Core/DSP/LabelMap.h"
namespace DSP
{
struct AssemblerSettings
{
AssemblerSettings()
@@ -57,3 +59,4 @@ private:
LabelMap labels;
};
} // namespace DSP
+5 -2
View File
@@ -16,6 +16,8 @@
#include "Core/DSP/DSPHost.h"
#include "Core/DSP/DSPTables.h"
namespace DSP
{
static void gdsp_do_dma();
void gdsp_ifx_init()
@@ -98,7 +100,7 @@ void gdsp_ifx_write(u32 addr, u32 val)
{
case DSP_DIRQ:
if (val & 0x1)
DSPHost::InterruptRequest();
Host::InterruptRequest();
else
WARN_LOG(DSPLLE, "Unknown Interrupt Request pc=%04x (%04x)", g_dsp.pc, val);
break;
@@ -234,7 +236,7 @@ static const u8* gdsp_idma_in(u16 dsp_addr, u32 addr, u32 size)
}
Common::WriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false);
DSPHost::CodeLoaded((const u8*)g_dsp.iram + dsp_addr, size);
Host::CodeLoaded((const u8*)g_dsp.iram + dsp_addr, size);
NOTICE_LOG(DSPLLE, "*** Copy new UCode from 0x%08x to 0x%04x (crc: %8x)", addr, dsp_addr,
g_dsp.iram_crc);
@@ -356,3 +358,4 @@ static void gdsp_do_dma()
if (copied_data_ptr)
g_dsp_cap->LogDMA(ctl, addr, dsp_addr, len, copied_data_ptr);
}
} // namespace DSP
+3
View File
@@ -7,6 +7,8 @@
#include "Common/CommonTypes.h"
namespace DSP
{
enum Mailbox
{
MAILBOX_CPU,
@@ -22,3 +24,4 @@ u16 gdsp_mbox_read_l(Mailbox mbx);
void gdsp_ifx_init();
void gdsp_ifx_write(u32 addr, u32 val);
u16 gdsp_ifx_read(u16 addr);
} // namespace DSP
+5 -2
View File
@@ -13,7 +13,9 @@
// core isn't used, for example in an asm/disasm tool, then most of these
// can be stubbed out.
namespace DSPHost
namespace DSP
{
namespace Host
{
u8 ReadHostMemory(u32 addr);
void WriteHostMemory(u8 value, u32 addr);
@@ -23,4 +25,5 @@ bool IsWiiHost();
void InterruptRequest();
void CodeLoaded(const u8* ptr, int size);
void UpdateDebugger();
}
} // namespace Host
} // namespace DSP
+3
View File
@@ -11,6 +11,8 @@
#include "Core/DSP/DSPHWInterface.h"
#include "Core/DSP/DSPTables.h"
namespace DSP
{
u16 dsp_imem_read(u16 addr)
{
switch (addr >> 12)
@@ -82,3 +84,4 @@ void dsp_skip_inst()
{
g_dsp.pc += opTable[dsp_peek_code()]->size;
}
} // namespace DSP

Some files were not shown because too many files have changed in this diff Show More