Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #69 from delroth/mmio-interface
Redesign of the MMIO access interface
  • Loading branch information
delroth committed Feb 16, 2014
2 parents 1e94853 + 96a66ad commit 2a7a943
Show file tree
Hide file tree
Showing 49 changed files with 2,010 additions and 2,722 deletions.
1 change: 0 additions & 1 deletion Source/Core/Common/Log.h
Expand Up @@ -47,7 +47,6 @@ enum LOG_TYPE
STREAMINGINTERFACE,
VIDEO,
VIDEOINTERFACE,
WII_IOB,
WII_IPC,
WII_IPC_DVD,
WII_IPC_ES,
Expand Down
1 change: 0 additions & 1 deletion Source/Core/Common/LogManager.cpp
Expand Up @@ -60,7 +60,6 @@ LogManager::LogManager()
m_Log[LogTypes::CONSOLE] = new LogContainer("CONSOLE", "Dolphin Console");
m_Log[LogTypes::OSREPORT] = new LogContainer("OSREPORT", "OSReport");
m_Log[LogTypes::WIIMOTE] = new LogContainer("Wiimote", "Wiimote");
m_Log[LogTypes::WII_IOB] = new LogContainer("WII_IOB", "WII IO Bridge");
m_Log[LogTypes::WII_IPC] = new LogContainer("WII_IPC", "WII IPC");
m_Log[LogTypes::WII_IPC_HID] = new LogContainer("WII_IPC_HID", "WII IPC HID");
m_Log[LogTypes::WII_IPC_HLE] = new LogContainer("WII_IPC_HLE", "WII IPC HLE");
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/CMakeLists.txt
Expand Up @@ -107,6 +107,7 @@ set(SRCS ActionReplay.cpp
HW/Memmap.cpp
HW/MemmapFunctions.cpp
HW/MemoryInterface.cpp
HW/MMIO.cpp
HW/ProcessorInterface.cpp
HW/SI.cpp
HW/SI_DeviceAMBaseboard.cpp
Expand All @@ -119,7 +120,6 @@ set(SRCS ActionReplay.cpp
HW/StreamADPCM.cpp
HW/SystemTimers.cpp
HW/VideoInterface.cpp
HW/WII_IOB.cpp
HW/WII_IPC.cpp
HW/Wiimote.cpp
HW/WiimoteEmu/WiimoteEmu.cpp
Expand Down
5 changes: 3 additions & 2 deletions Source/Core/Core/Core.vcxproj
Expand Up @@ -145,6 +145,7 @@
<ClCompile Include="HW\Memmap.cpp" />
<ClCompile Include="HW\MemmapFunctions.cpp" />
<ClCompile Include="HW\MemoryInterface.cpp" />
<ClCompile Include="HW\MMIO.cpp" />
<ClCompile Include="HW\ProcessorInterface.cpp" />
<ClCompile Include="HW\SI.cpp" />
<ClCompile Include="HW\SI_Device.cpp" />
Expand All @@ -170,7 +171,6 @@
<ClCompile Include="HW\WiimoteEmu\WiimoteEmu.cpp" />
<ClCompile Include="HW\WiimoteReal\IOWin.cpp" />
<ClCompile Include="HW\WiimoteReal\WiimoteReal.cpp" />
<ClCompile Include="HW\WII_IOB.cpp" />
<ClCompile Include="HW\WII_IPC.cpp" />
<ClCompile Include="IPC_HLE\ICMPWin.cpp" />
<ClCompile Include="IPC_HLE\WiiMote_HID_Attr.cpp" />
Expand Down Expand Up @@ -342,6 +342,8 @@
<ClInclude Include="HW\HW.h" />
<ClInclude Include="HW\Memmap.h" />
<ClInclude Include="HW\MemoryInterface.h" />
<ClInclude Include="HW\MMIO.h" />
<ClInclude Include="HW\MMIOHandlers.h" />
<ClInclude Include="HW\ProcessorInterface.h" />
<ClInclude Include="HW\SI.h" />
<ClInclude Include="HW\SI_Device.h" />
Expand All @@ -368,7 +370,6 @@
<ClInclude Include="HW\WiimoteEmu\WiimoteHid.h" />
<ClInclude Include="HW\WiimoteReal\WiimoteReal.h" />
<ClInclude Include="HW\WiimoteReal\WiimoteRealBase.h" />
<ClInclude Include="HW\WII_IOB.h" />
<ClInclude Include="HW\WII_IPC.h" />
<ClInclude Include="IPC_HLE\fakepoll.h" />
<ClInclude Include="IPC_HLE\hci.h" />
Expand Down
17 changes: 10 additions & 7 deletions Source/Core/Core/Core.vcxproj.filters
Expand Up @@ -492,9 +492,6 @@
<ClCompile Include="HW\WiimoteReal\WiimoteReal.cpp">
<Filter>HW %28Flipper/Hollywood%29\Wiimote\Real</Filter>
</ClCompile>
<ClCompile Include="HW\WII_IOB.cpp">
<Filter>HW %28Flipper/Hollywood%29\Wii IO Bridge</Filter>
</ClCompile>
<ClCompile Include="HW\WII_IPC.cpp">
<Filter>HW %28Flipper/Hollywood%29\Wii IPC</Filter>
</ClCompile>
Expand All @@ -510,6 +507,9 @@
<ClCompile Include="HW\MemmapFunctions.cpp">
<Filter>HW %28Flipper/Hollywood%29</Filter>
</ClCompile>
<ClCompile Include="HW\MMIO.cpp">
<Filter>HW %28Flipper/Hollywood%29</Filter>
</ClCompile>
<ClCompile Include="HW\SystemTimers.cpp">
<Filter>HW %28Flipper/Hollywood%29</Filter>
</ClCompile>
Expand Down Expand Up @@ -1022,9 +1022,6 @@
<ClInclude Include="HW\WiimoteReal\WiimoteRealBase.h">
<Filter>HW %28Flipper/Hollywood%29\Wiimote\Real</Filter>
</ClInclude>
<ClInclude Include="HW\WII_IOB.h">
<Filter>HW %28Flipper/Hollywood%29\Wii IO Bridge</Filter>
</ClInclude>
<ClInclude Include="HW\WII_IPC.h">
<Filter>HW %28Flipper/Hollywood%29\Wii IPC</Filter>
</ClInclude>
Expand All @@ -1037,6 +1034,12 @@
<ClInclude Include="HW\Memmap.h">
<Filter>HW %28Flipper/Hollywood%29</Filter>
</ClInclude>
<ClInclude Include="HW\MMIO.h">
<Filter>HW %28Flipper/Hollywood%29</Filter>
</ClInclude>
<ClInclude Include="HW\MMIOHandlers.h">
<Filter>HW %28Flipper/Hollywood%29</Filter>
</ClInclude>
<ClInclude Include="HW\SystemTimers.h">
<Filter>HW %28Flipper/Hollywood%29</Filter>
</ClInclude>
Expand Down Expand Up @@ -1219,4 +1222,4 @@
<ItemGroup>
<Text Include="CMakeLists.txt" />
</ItemGroup>
</Project>
</Project>
92 changes: 30 additions & 62 deletions Source/Core/Core/HW/AudioInterface.cpp
Expand Up @@ -62,6 +62,7 @@ This file mainly deals with the [Drive I/F], however [AIDFR] controls
#include "../PowerPC/PowerPC.h"
#include "../CoreTiming.h"
#include "SystemTimers.h"
#include "MMIO.h"

namespace AudioInterface
{
Expand Down Expand Up @@ -170,43 +171,12 @@ void Shutdown()
{
}

void Read32(u32& _rReturnValue, const u32 _Address)
void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
{
switch (_Address & 0xFFFF)
{
case AI_CONTROL_REGISTER:
_rReturnValue = m_Control.hex;
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);
mmio->Register(base | AI_CONTROL_REGISTER,
MMIO::DirectRead<u32>(&m_Control.hex),
MMIO::ComplexWrite<u32>([](u32, u32 val) {
AICR tmpAICtrl(val);

m_Control.AIINTMSK = tmpAICtrl.AIINTMSK;
m_Control.AIINTVLD = tmpAICtrl.AIINTVLD;
Expand Down Expand Up @@ -260,32 +230,30 @@ void Write32(const u32 _Value, const u32 _Address)
}

UpdateInterrupts();
}
break;

case AI_VOLUME_REGISTER:
m_Volume.hex = _Value;
DEBUG_LOG(AUDIO_INTERFACE, "Set volume: left(%02x) right(%02x)", m_Volume.left, m_Volume.right);
break;

case AI_SAMPLE_COUNTER:
// Why was this commented out? Does something do this?
_dbg_assert_msg_(AUDIO_INTERFACE, 0, "AIS - sample counter is read only");
m_SampleCounter = _Value;
break;

case AI_INTERRUPT_TIMING:
m_InterruptTiming = _Value;
CoreTiming::RemoveEvent(et_AI);
CoreTiming::ScheduleEvent(((int)GetAIPeriod() / 2), et_AI);
DEBUG_LOG(AUDIO_INTERFACE, "Set interrupt: %08x samples", m_InterruptTiming);
break;

default:
ERROR_LOG(AUDIO_INTERFACE, "Unknown write %08x @ %08x", _Value, _Address);
_dbg_assert_msg_(AUDIO_INTERFACE,0,"AIS - Write %08x to %08x", _Value, _Address);
break;
}
})
);

mmio->Register(base | AI_VOLUME_REGISTER,
MMIO::DirectRead<u32>(&m_Volume.hex),
MMIO::DirectWrite<u32>(&m_Volume.hex)
);

mmio->Register(base | AI_SAMPLE_COUNTER,
MMIO::ComplexRead<u32>([](u32) {
Update(0, 0);
return m_SampleCounter;
}),
MMIO::DirectWrite<u32>(&m_SampleCounter)
);

mmio->Register(base | AI_INTERRUPT_TIMING,
MMIO::DirectRead<u32>(&m_InterruptTiming),
MMIO::ComplexWrite<u32>([](u32, u32 val) {
m_InterruptTiming = val;
CoreTiming::RemoveEvent(et_AI);
CoreTiming::ScheduleEvent(((int)GetAIPeriod() / 2), et_AI);
})
);
}

static void UpdateInterrupts()
Expand Down
6 changes: 3 additions & 3 deletions Source/Core/Core/HW/AudioInterface.h
Expand Up @@ -9,6 +9,7 @@
#include "CommonTypes.h"

class PointerWrap;
namespace MMIO { class Mapping; }

namespace AudioInterface
{
Expand All @@ -17,15 +18,14 @@ void Init();
void Shutdown();
void DoState(PointerWrap &p);

void RegisterMMIO(MMIO::Mapping* mmio, u32 base);

void Update(u64 userdata, int cyclesLate);

// Called by DSP emulator
void Callback_GetSampleRate(unsigned int &_AISampleRate, unsigned int &_DACSampleRate);
unsigned int Callback_GetStreaming(short* _pDestBuffer, unsigned int _numSamples, unsigned int _sampleRate = 48000);

void Read32(u32& _uReturnValue, const u32 _iAddress);
void Write32(const u32 _iValue, const u32 _iAddress);

// Get the audio rates (48000 or 32000 only)
unsigned int GetAIDSampleRate();

Expand Down

0 comments on commit 2a7a943

Please sign in to comment.