Merge pull request #3411 from lioncash/dsp

DSPCore: Minor changes
This commit is contained in:
Pierre Bourdon 2015-12-29 19:46:16 +01:00
commit 76250a9bf4
9 changed files with 48 additions and 52 deletions

View File

@ -5,6 +5,7 @@
#include <algorithm>
#include <array>
#include <memory>
#include "Common/CommonFuncs.h"
#include "Common/CommonTypes.h"
@ -22,11 +23,11 @@
#include "Core/DSP/DSPIntUtil.h"
SDSP g_dsp;
DSPBreakpoints dsp_breakpoints;
DSPBreakpoints g_dsp_breakpoints;
static DSPCoreState core_state = DSPCORE_STOP;
u16 cyclesLeft = 0;
bool init_hax = false;
DSPEmitter *dspjit = nullptr;
u16 g_cycles_left = 0;
bool g_init_hax = false;
std::unique_ptr<DSPEmitter> g_dsp_jit;
std::unique_ptr<DSPCaptureLogger> g_dsp_cap;
static Common::Event step_event;
@ -100,9 +101,8 @@ static void DSPCore_FreeMemoryPages()
bool DSPCore_Init(const DSPInitOptions& opts)
{
g_dsp.step_counter = 0;
cyclesLeft = 0;
init_hax = false;
dspjit = nullptr;
g_cycles_left = 0;
g_init_hax = false;
g_dsp.irom = (u16*)AllocateMemoryPages(DSP_IROM_BYTE_SIZE);
g_dsp.iram = (u16*)AllocateMemoryPages(DSP_IRAM_BYTE_SIZE);
@ -147,7 +147,7 @@ bool DSPCore_Init(const DSPInitOptions& opts)
// Initialize JIT, if necessary
if (opts.core_type == DSPInitOptions::CORE_JIT)
dspjit = new DSPEmitter();
g_dsp_jit = std::make_unique<DSPEmitter>();
g_dsp_cap.reset(opts.capture_logger);
@ -162,11 +162,7 @@ void DSPCore_Shutdown()
core_state = DSPCORE_STOP;
if (dspjit)
{
delete dspjit;
dspjit = nullptr;
}
g_dsp_jit.reset();
DSPCore_FreeMemoryPages();
@ -245,7 +241,7 @@ void DSPCore_CheckExceptions()
// Handle state changes and stepping.
int DSPCore_RunCycles(int cycles)
{
if (dspjit)
if (g_dsp_jit)
{
if (g_dsp.external_interrupt_waiting)
{
@ -254,14 +250,14 @@ int DSPCore_RunCycles(int cycles)
DSPCore_SetExternalInterrupt(false);
}
cyclesLeft = cycles;
DSPCompiledCode pExecAddr = (DSPCompiledCode)dspjit->enterDispatcher;
g_cycles_left = cycles;
DSPCompiledCode pExecAddr = (DSPCompiledCode)g_dsp_jit->enterDispatcher;
pExecAddr();
if (g_dsp.reset_dspjit_codespace)
dspjit->ClearIRAMandDSPJITCodespaceReset();
g_dsp_jit->ClearIRAMandDSPJITCodespaceReset();
return cyclesLeft;
return g_cycles_left;
}
while (cycles > 0)
@ -317,7 +313,7 @@ void DSPCore_Step()
void CompileCurrent()
{
dspjit->Compile(g_dsp.pc);
g_dsp_jit->Compile(g_dsp.pc);
bool retry = true;
@ -326,11 +322,11 @@ void CompileCurrent()
retry = false;
for (u16 i = 0x0000; i < 0xffff; ++i)
{
if (!dspjit->unresolvedJumps[i].empty())
if (!g_dsp_jit->unresolvedJumps[i].empty())
{
u16 addrToCompile = dspjit->unresolvedJumps[i].front();
dspjit->Compile(addrToCompile);
if (!dspjit->unresolvedJumps[i].empty())
u16 addrToCompile = g_dsp_jit->unresolvedJumps[i].front();
g_dsp_jit->Compile(addrToCompile);
if (!g_dsp_jit->unresolvedJumps[i].empty())
retry = true;
}
}

View File

@ -296,10 +296,10 @@ struct SDSP
};
extern SDSP g_dsp;
extern DSPBreakpoints dsp_breakpoints;
extern DSPEmitter *dspjit;
extern u16 cyclesLeft;
extern bool init_hax;
extern DSPBreakpoints g_dsp_breakpoints;
extern u16 g_cycles_left;
extern bool g_init_hax;
extern std::unique_ptr<DSPEmitter> g_dsp_jit;
extern std::unique_ptr<DSPCaptureLogger> g_dsp_cap;
struct DSPInitOptions

View File

@ -410,7 +410,7 @@ void DSPEmitter::CompileDispatcher()
returnDispatcher = GetCodePtr();
// Decrement cyclesLeft
SUB(16, M(&cyclesLeft), R(EAX));
SUB(16, M(&g_cycles_left), R(EAX));
J_CC(CC_A, dispatcherLoop);

View File

@ -57,7 +57,7 @@ void gdsp_mbox_write_l(Mailbox mbx, u16 val)
u16 gdsp_mbox_read_h(Mailbox mbx)
{
if (init_hax && mbx == MAILBOX_DSP)
if (g_init_hax && mbx == MAILBOX_DSP)
{
return 0x8054;
}
@ -70,9 +70,9 @@ u16 gdsp_mbox_read_l(Mailbox mbx)
const u32 value = g_dsp.mbox[mbx].load(std::memory_order_acquire);
g_dsp.mbox[mbx].store(value & ~0x80000000, std::memory_order_release);
if (init_hax && mbx == MAILBOX_DSP)
if (g_init_hax && mbx == MAILBOX_DSP)
{
init_hax = false;
g_init_hax = false;
DSPCore_Reset();
return 0x4348;
}

View File

@ -30,7 +30,7 @@ void WriteCR(u16 val)
// HAX!
// OSInitAudioSystem ucode should send this mail - not DSP core itself
INFO_LOG(DSPLLE,"DSP_CONTROL INIT");
init_hax = true;
g_init_hax = true;
val |= 0x800;
}
@ -109,7 +109,7 @@ int RunCyclesDebug(int cycles)
{
if (g_dsp.cr & CR_HALT)
return 0;
if (dsp_breakpoints.IsAddressBreakPoint(g_dsp.pc))
if (g_dsp_breakpoints.IsAddressBreakPoint(g_dsp.pc))
{
DSPCore_SetState(DSPCORE_STEPPING);
return cycles;
@ -128,7 +128,7 @@ int RunCyclesDebug(int cycles)
{
if (g_dsp.cr & CR_HALT)
return 0;
if (dsp_breakpoints.IsAddressBreakPoint(g_dsp.pc))
if (g_dsp_breakpoints.IsAddressBreakPoint(g_dsp.pc))
{
DSPCore_SetState(DSPCORE_STEPPING);
return cycles;
@ -145,7 +145,7 @@ int RunCyclesDebug(int cycles)
// Now, lets run some more without idle skipping.
for (int i = 0; i < 200; i++)
{
if (dsp_breakpoints.IsAddressBreakPoint(g_dsp.pc))
if (g_dsp_breakpoints.IsAddressBreakPoint(g_dsp.pc))
{
DSPCore_SetState(DSPCORE_STEPPING);
return cycles;

View File

@ -99,12 +99,12 @@ static void WriteBlockLink(DSPEmitter& emitter, u16 dest)
{
emitter.gpr.FlushRegs();
// Check if we have enough cycles to execute the next block
emitter.MOV(16, R(ECX), M(&cyclesLeft));
emitter.MOV(16, R(ECX), M(&g_cycles_left));
emitter.CMP(16, R(ECX), Imm16(emitter.blockSize[emitter.startAddr] + emitter.blockSize[dest]));
FixupBranch notEnoughCycles = emitter.J_CC(CC_BE);
emitter.SUB(16, R(ECX), Imm16(emitter.blockSize[emitter.startAddr]));
emitter.MOV(16, M(&cyclesLeft), R(ECX));
emitter.MOV(16, M(&g_cycles_left), R(ECX));
emitter.JMP(emitter.blockLinks[dest], true);
emitter.SetJumpTarget(notEnoughCycles);
}

View File

@ -75,9 +75,9 @@ bool DSPDebugInterface::IsBreakpoint(unsigned int address)
{
int real_addr = DSPSymbols::Line2Addr(address);
if (real_addr >= 0)
return dsp_breakpoints.IsAddressBreakPoint(real_addr);
else
return false;
return g_dsp_breakpoints.IsAddressBreakPoint(real_addr);
return false;
}
void DSPDebugInterface::SetBreakpoint(unsigned int address)
@ -86,7 +86,7 @@ void DSPDebugInterface::SetBreakpoint(unsigned int address)
if (real_addr >= 0)
{
if (dsp_breakpoints.Add(real_addr))
if (g_dsp_breakpoints.Add(real_addr))
{
}
@ -99,7 +99,7 @@ void DSPDebugInterface::ClearBreakpoint(unsigned int address)
if (real_addr >= 0)
{
if (dsp_breakpoints.Remove(real_addr))
if (g_dsp_breakpoints.Remove(real_addr))
{
}
@ -108,7 +108,7 @@ void DSPDebugInterface::ClearBreakpoint(unsigned int address)
void DSPDebugInterface::ClearAllBreakpoints()
{
dsp_breakpoints.Clear();
g_dsp_breakpoints.Clear();
}
void DSPDebugInterface::ToggleBreakpoint(unsigned int address)
@ -116,10 +116,10 @@ void DSPDebugInterface::ToggleBreakpoint(unsigned int address)
int real_addr = DSPSymbols::Line2Addr(address);
if (real_addr >= 0)
{
if (dsp_breakpoints.IsAddressBreakPoint(real_addr))
dsp_breakpoints.Remove(real_addr);
if (g_dsp_breakpoints.IsAddressBreakPoint(real_addr))
g_dsp_breakpoints.Remove(real_addr);
else
dsp_breakpoints.Add(real_addr);
g_dsp_breakpoints.Add(real_addr);
}
}

View File

@ -96,8 +96,8 @@ void CodeLoaded(const u8 *ptr, int size)
UpdateDebugger();
if (dspjit)
dspjit->ClearIRAM();
if (g_dsp_jit)
g_dsp_jit->ClearIRAM();
DSPAnalyzer::Analyze();
}

View File

@ -83,8 +83,8 @@ void DSPLLE::DoState(PointerWrap &p)
if (p.GetMode() == PointerWrap::MODE_READ)
DSPHost::CodeLoaded((const u8*)g_dsp.iram, DSP_IRAM_BYTE_SIZE);
p.DoArray(g_dsp.dram, DSP_DRAM_SIZE);
p.Do(cyclesLeft);
p.Do(init_hax);
p.Do(g_cycles_left);
p.Do(g_init_hax);
p.Do(m_cycle_count);
}
@ -99,7 +99,7 @@ void DSPLLE::DSPThread(DSPLLE* dsp_lle)
if (cycles > 0)
{
std::lock_guard<std::mutex> dsp_thread_lock(dsp_lle->m_csDSPThreadActive);
if (dspjit)
if (g_dsp_jit)
{
DSPCore_RunCycles(cycles);
}
@ -176,7 +176,7 @@ bool DSPLLE::Initialize(bool bWii, bool bDSPThread)
// needs to be after DSPCore_Init for the dspjit ptr
if (NetPlay::IsNetPlayRunning() || Movie::IsMovieActive() ||
Core::g_want_determinism || !dspjit)
Core::g_want_determinism || !g_dsp_jit)
{
bDSPThread = false;
}