dolphin/Source/DSPSpy/real_dsp.cpp
Pierre Bourdon e149ad4f0a
treewide: convert GPLv2+ license info to SPDX tags
SPDX standardizes how source code conveys its copyright and licensing
information. See https://spdx.github.io/spdx-spec/1-rationale/ . SPDX
tags are adopted in many large projects, including things like the Linux
kernel.
2021-07-05 04:35:56 +02:00

54 lines
1.3 KiB
C++

// Copyright 2009 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include <gccore.h>
#include <ogc/dsp.h>
#include <ogc/irq.h>
#include <ogc/machine/asm.h>
#include <ogc/machine/processor.h>
#include <ogcsys.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);
IRQ_Request(IRQ_DSP_DSP, dsp_irq_handler, nullptr);
_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);
}