2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2009 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2014-02-10 11:54:46 -07:00
|
|
|
// Refer to the license.txt file included.
|
2009-07-05 20:10:26 -06:00
|
|
|
|
|
|
|
#include <gccore.h>
|
|
|
|
#include <ogcsys.h>
|
|
|
|
#include <ogc/dsp.h>
|
|
|
|
#include <ogc/irq.h>
|
|
|
|
#include <ogc/machine/asm.h>
|
|
|
|
#include <ogc/machine/processor.h>
|
|
|
|
|
|
|
|
#include "dsp_interface.h"
|
|
|
|
#include "real_dsp.h"
|
|
|
|
|
|
|
|
static vu16* const _dspReg = (u16*)0xCC005000;
|
|
|
|
|
|
|
|
// Handler for DSP interrupt.
|
|
|
|
static void dsp_irq_handler(u32 nIrq, void *pCtx)
|
|
|
|
{
|
|
|
|
// Acknowledge interrupt?
|
|
|
|
_dspReg[5] = (_dspReg[5] & ~(DSPCR_AIINT|DSPCR_ARINT)) | DSPCR_DSPINT;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RealDSP::Init()
|
|
|
|
{
|
|
|
|
_dspReg[5] = (_dspReg[5] & ~(DSPCR_AIINT|DSPCR_ARINT|DSPCR_DSPINT)) | DSPCR_DSPRESET;
|
|
|
|
_dspReg[5] = (_dspReg[5] & ~(DSPCR_HALT|DSPCR_AIINT|DSPCR_ARINT|DSPCR_DSPINT));
|
|
|
|
|
|
|
|
u32 level;
|
|
|
|
_CPU_ISR_Disable(level);
|
2014-03-09 14:14:26 -06:00
|
|
|
IRQ_Request(IRQ_DSP_DSP, dsp_irq_handler, nullptr);
|
2009-07-05 20:10:26 -06:00
|
|
|
_CPU_ISR_Restore(level);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RealDSP::Reset()
|
|
|
|
{
|
|
|
|
// Reset the DSP.
|
|
|
|
_dspReg[5] = (_dspReg[5] & ~(DSPCR_AIINT|DSPCR_ARINT|DSPCR_DSPINT)) | DSPCR_DSPRESET;
|
|
|
|
_dspReg[5] = (_dspReg[5] & ~(DSPCR_HALT|DSPCR_AIINT|DSPCR_ARINT|DSPCR_DSPINT));
|
|
|
|
_dspReg[5] |= DSPCR_RES;
|
|
|
|
while (_dspReg[5] & DSPCR_RES)
|
|
|
|
;
|
|
|
|
_dspReg[9] = 0x63;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 RealDSP::CheckMailTo()
|
|
|
|
{
|
|
|
|
return DSP_CheckMailTo();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RealDSP::SendMailTo(u32 mail)
|
|
|
|
{
|
|
|
|
DSP_SendMailTo(mail);
|
|
|
|
}
|