MMIO: Port the AI MMIOs to the new interface.

This commit is contained in:
Pierre Bourdon 2014-01-25 21:13:50 +01:00
parent 191b447092
commit a7c1e0d0d7
3 changed files with 44 additions and 58 deletions

View File

@ -62,6 +62,7 @@ This file mainly deals with the [Drive I/F], however [AIDFR] controls
#include "../PowerPC/PowerPC.h" #include "../PowerPC/PowerPC.h"
#include "../CoreTiming.h" #include "../CoreTiming.h"
#include "SystemTimers.h" #include "SystemTimers.h"
#include "MMIO.h"
namespace AudioInterface namespace AudioInterface
{ {
@ -170,43 +171,12 @@ void Shutdown()
{ {
} }
void Read32(u32& _rReturnValue, const u32 _Address) void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
{ {
switch (_Address & 0xFFFF) mmio->Register(base | AI_CONTROL_REGISTER,
{ MMIO::DirectRead<u32>(&m_Control.hex),
case AI_CONTROL_REGISTER: MMIO::ComplexWrite<u32>([](u32, u32 val) {
_rReturnValue = m_Control.hex; AICR tmpAICtrl(val);
break;
case AI_VOLUME_REGISTER:
_rReturnValue = m_Volume.hex;
break;
case AI_SAMPLE_COUNTER:
Update(0, 0);
_rReturnValue = m_SampleCounter;
break;
case AI_INTERRUPT_TIMING:
_rReturnValue = m_InterruptTiming;
break;
default:
ERROR_LOG(AUDIO_INTERFACE, "Unknown read 0x%08x", _Address);
_dbg_assert_msg_(AUDIO_INTERFACE, 0, "AudioInterface - Read from 0x%08x", _Address);
_rReturnValue = 0;
return;
}
DEBUG_LOG(AUDIO_INTERFACE, "r32 %08x %08x", _Address, _rReturnValue);
}
void Write32(const u32 _Value, const u32 _Address)
{
switch (_Address & 0xFFFF)
{
case AI_CONTROL_REGISTER:
{
AICR tmpAICtrl(_Value);
m_Control.AIINTMSK = tmpAICtrl.AIINTMSK; m_Control.AIINTMSK = tmpAICtrl.AIINTMSK;
m_Control.AIINTVLD = tmpAICtrl.AIINTVLD; m_Control.AIINTVLD = tmpAICtrl.AIINTVLD;
@ -260,32 +230,42 @@ void Write32(const u32 _Value, const u32 _Address)
} }
UpdateInterrupts(); UpdateInterrupts();
} })
break; );
case AI_VOLUME_REGISTER: mmio->Register(base | AI_VOLUME_REGISTER,
m_Volume.hex = _Value; MMIO::DirectRead<u32>(&m_Volume.hex),
DEBUG_LOG(AUDIO_INTERFACE, "Set volume: left(%02x) right(%02x)", m_Volume.left, m_Volume.right); MMIO::DirectWrite<u32>(&m_Volume.hex)
break; );
case AI_SAMPLE_COUNTER: mmio->Register(base | AI_SAMPLE_COUNTER,
// Why was this commented out? Does something do this? MMIO::ComplexRead<u32>([](u32) {
_dbg_assert_msg_(AUDIO_INTERFACE, 0, "AIS - sample counter is read only"); Update(0, 0);
m_SampleCounter = _Value; return m_SampleCounter;
break; }),
MMIO::DirectWrite<u32>(&m_SampleCounter)
);
case AI_INTERRUPT_TIMING: mmio->Register(base | AI_INTERRUPT_TIMING,
m_InterruptTiming = _Value; MMIO::DirectRead<u32>(&m_InterruptTiming),
CoreTiming::RemoveEvent(et_AI); MMIO::ComplexWrite<u32>([](u32, u32 val) {
CoreTiming::ScheduleEvent(((int)GetAIPeriod() / 2), et_AI); m_InterruptTiming = val;
DEBUG_LOG(AUDIO_INTERFACE, "Set interrupt: %08x samples", m_InterruptTiming); CoreTiming::RemoveEvent(et_AI);
break; CoreTiming::ScheduleEvent(((int)GetAIPeriod() / 2), et_AI);
})
);
}
default: void Read32(u32& _rReturnValue, const u32 _Address)
ERROR_LOG(AUDIO_INTERFACE, "Unknown write %08x @ %08x", _Value, _Address); {
_dbg_assert_msg_(AUDIO_INTERFACE,0,"AIS - Write %08x to %08x", _Value, _Address); // HACK: Remove this function when the new MMIO interface is used.
break; Memory::mmio_mapping->Read(_Address, _rReturnValue);
} }
void Write32(const u32 _Value, const u32 _Address)
{
// HACK: Remove this function when the new MMIO interface is used.
Memory::mmio_mapping->Write(_Address, _Value);
} }
static void UpdateInterrupts() static void UpdateInterrupts()

View File

@ -9,6 +9,7 @@
#include "CommonTypes.h" #include "CommonTypes.h"
class PointerWrap; class PointerWrap;
namespace MMIO { class Mapping; }
namespace AudioInterface namespace AudioInterface
{ {
@ -17,6 +18,8 @@ void Init();
void Shutdown(); void Shutdown();
void DoState(PointerWrap &p); void DoState(PointerWrap &p);
void RegisterMMIO(MMIO::Mapping* mmio, u32 base);
void Update(u64 userdata, int cyclesLate); void Update(u64 userdata, int cyclesLate);
// Called by DSP emulator // Called by DSP emulator

View File

@ -316,6 +316,7 @@ void InitMMIO(MMIO::Mapping* mmio)
DSP::RegisterMMIO(mmio, 0xCC005000); DSP::RegisterMMIO(mmio, 0xCC005000);
DVDInterface::RegisterMMIO(mmio, 0xCC006000); DVDInterface::RegisterMMIO(mmio, 0xCC006000);
SerialInterface::RegisterMMIO(mmio, 0xCC006400); SerialInterface::RegisterMMIO(mmio, 0xCC006400);
AudioInterface::RegisterMMIO(mmio, 0xCC006C00);
} }
void InitMMIOWii(MMIO::Mapping* mmio) void InitMMIOWii(MMIO::Mapping* mmio)
@ -328,6 +329,8 @@ void InitMMIOWii(MMIO::Mapping* mmio)
DVDInterface::RegisterMMIO(mmio, 0xCD006000); DVDInterface::RegisterMMIO(mmio, 0xCD006000);
SerialInterface::RegisterMMIO(mmio, 0xCC006400); SerialInterface::RegisterMMIO(mmio, 0xCC006400);
SerialInterface::RegisterMMIO(mmio, 0xCD006400); SerialInterface::RegisterMMIO(mmio, 0xCD006400);
AudioInterface::RegisterMMIO(mmio, 0xCC006C00);
AudioInterface::RegisterMMIO(mmio, 0xCD006C00);
} }
writeFn32 GetHWWriteFun32(const u32 _Address) writeFn32 GetHWWriteFun32(const u32 _Address)