IPC_HLE/stm: Separate header and implementation
There was as far as I know no reason to put everything in the header. Separating the declaration from the implementation reduces build times in case the implementation is updated without changing any declaration.
This commit is contained in:
parent
8017e11784
commit
faf202f0f6
|
@ -143,6 +143,7 @@ set(SRCS ActionReplay.cpp
|
|||
IPC_HLE/WII_Socket.cpp
|
||||
IPC_HLE/WII_IPC_HLE_Device_net.cpp
|
||||
IPC_HLE/WII_IPC_HLE_Device_net_ssl.cpp
|
||||
IPC_HLE/WII_IPC_HLE_Device_stm.cpp
|
||||
IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp
|
||||
IPC_HLE/WII_IPC_HLE_Device_usb.cpp
|
||||
IPC_HLE/WII_IPC_HLE_Device_usb_kbd.cpp
|
||||
|
|
|
@ -183,6 +183,7 @@
|
|||
</ClCompile>
|
||||
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_net.cpp" />
|
||||
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_net_ssl.cpp" />
|
||||
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_stm.cpp" />
|
||||
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_sdio_slot0.cpp" />
|
||||
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_usb.cpp" />
|
||||
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_usb_kbd.cpp" />
|
||||
|
@ -386,8 +387,8 @@
|
|||
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_hid.h" />
|
||||
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_net.h" />
|
||||
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_net_ssl.h" />
|
||||
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_sdio_slot0.h" />
|
||||
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_stm.h" />
|
||||
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_sdio_slot0.h" />
|
||||
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_usb.h" />
|
||||
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_usb_kbd.h" />
|
||||
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_usb_ven.h" />
|
||||
|
@ -480,4 +481,4 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -585,6 +585,9 @@
|
|||
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_sdio_slot0.cpp">
|
||||
<Filter>IPC HLE %28IOS/Starlet%29\SDIO - SD Card</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_stm.cpp">
|
||||
<Filter>IPC HLE %28IOS/Starlet%29</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_hid.cpp">
|
||||
<Filter>IPC HLE %28IOS/Starlet%29\USB</Filter>
|
||||
</ClCompile>
|
||||
|
@ -1247,4 +1250,4 @@
|
|||
<ItemGroup>
|
||||
<Text Include="CMakeLists.txt" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -0,0 +1,134 @@
|
|||
// Copyright 2016 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "Core/IPC_HLE/WII_IPC_HLE_Device_stm.h"
|
||||
|
||||
IPCCommandResult CWII_IPC_HLE_Device_stm_immediate::Open(u32 _CommandAddress, u32 _Mode)
|
||||
{
|
||||
INFO_LOG(WII_IPC_STM, "STM immediate: Open");
|
||||
Memory::Write_U32(GetDeviceID(), _CommandAddress + 4);
|
||||
m_Active = true;
|
||||
return GetDefaultReply();
|
||||
}
|
||||
|
||||
IPCCommandResult CWII_IPC_HLE_Device_stm_immediate::Close(u32 _CommandAddress, bool _bForce)
|
||||
{
|
||||
INFO_LOG(WII_IPC_STM, "STM immediate: Close");
|
||||
if (!_bForce)
|
||||
Memory::Write_U32(0, _CommandAddress + 4);
|
||||
m_Active = false;
|
||||
return GetDefaultReply();
|
||||
}
|
||||
|
||||
IPCCommandResult CWII_IPC_HLE_Device_stm_immediate::IOCtl(u32 _CommandAddress)
|
||||
{
|
||||
u32 Parameter = Memory::Read_U32(_CommandAddress + 0x0C);
|
||||
u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10);
|
||||
u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14);
|
||||
u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18);
|
||||
u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C);
|
||||
|
||||
// Prepare the out buffer(s) with zeroes as a safety precaution
|
||||
// to avoid returning bad values
|
||||
Memory::Memset(BufferOut, 0, BufferOutSize);
|
||||
u32 ReturnValue = 0;
|
||||
|
||||
switch (Parameter)
|
||||
{
|
||||
case IOCTL_STM_RELEASE_EH:
|
||||
INFO_LOG(WII_IPC_STM, "%s - IOCtl:", GetDeviceName().c_str());
|
||||
INFO_LOG(WII_IPC_STM, " IOCTL_STM_RELEASE_EH");
|
||||
break;
|
||||
|
||||
case IOCTL_STM_HOTRESET:
|
||||
INFO_LOG(WII_IPC_STM, "%s - IOCtl:", GetDeviceName().c_str());
|
||||
INFO_LOG(WII_IPC_STM, " IOCTL_STM_HOTRESET");
|
||||
break;
|
||||
|
||||
case IOCTL_STM_VIDIMMING: // (Input: 20 bytes, Output: 20 bytes)
|
||||
INFO_LOG(WII_IPC_STM, "%s - IOCtl:", GetDeviceName().c_str());
|
||||
INFO_LOG(WII_IPC_STM, " IOCTL_STM_VIDIMMING");
|
||||
// DumpCommands(BufferIn, BufferInSize / 4, LogTypes::WII_IPC_STM);
|
||||
// Memory::Write_U32(1, BufferOut);
|
||||
// ReturnValue = 1;
|
||||
break;
|
||||
|
||||
case IOCTL_STM_LEDMODE: // (Input: 20 bytes, Output: 20 bytes)
|
||||
INFO_LOG(WII_IPC_STM, "%s - IOCtl:", GetDeviceName().c_str());
|
||||
INFO_LOG(WII_IPC_STM, " IOCTL_STM_LEDMODE");
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
_dbg_assert_msg_(WII_IPC_STM, 0, "CWII_IPC_HLE_Device_stm_immediate: 0x%x", Parameter);
|
||||
|
||||
INFO_LOG(WII_IPC_STM, "%s - IOCtl:", GetDeviceName().c_str());
|
||||
DEBUG_LOG(WII_IPC_STM, " Parameter: 0x%x", Parameter);
|
||||
DEBUG_LOG(WII_IPC_STM, " InBuffer: 0x%08x", BufferIn);
|
||||
DEBUG_LOG(WII_IPC_STM, " InBufferSize: 0x%08x", BufferInSize);
|
||||
DEBUG_LOG(WII_IPC_STM, " OutBuffer: 0x%08x", BufferOut);
|
||||
DEBUG_LOG(WII_IPC_STM, " OutBufferSize: 0x%08x", BufferOutSize);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Write return value to the IPC call
|
||||
Memory::Write_U32(ReturnValue, _CommandAddress + 0x4);
|
||||
return GetDefaultReply();
|
||||
}
|
||||
|
||||
IPCCommandResult CWII_IPC_HLE_Device_stm_eventhook::Open(u32 _CommandAddress, u32 _Mode)
|
||||
{
|
||||
Memory::Write_U32(GetDeviceID(), _CommandAddress + 4);
|
||||
m_Active = true;
|
||||
return GetDefaultReply();
|
||||
}
|
||||
|
||||
IPCCommandResult CWII_IPC_HLE_Device_stm_eventhook::Close(u32 _CommandAddress, bool _bForce)
|
||||
{
|
||||
m_EventHookAddress = 0;
|
||||
|
||||
INFO_LOG(WII_IPC_STM, "STM eventhook: Close");
|
||||
if (!_bForce)
|
||||
Memory::Write_U32(0, _CommandAddress + 4);
|
||||
m_Active = false;
|
||||
return GetDefaultReply();
|
||||
}
|
||||
|
||||
IPCCommandResult CWII_IPC_HLE_Device_stm_eventhook::IOCtl(u32 _CommandAddress)
|
||||
{
|
||||
u32 Parameter = Memory::Read_U32(_CommandAddress + 0x0C);
|
||||
if (Parameter != IOCTL_STM_EVENTHOOK)
|
||||
{
|
||||
ERROR_LOG(WII_IPC_STM, "Bad IOCtl in CWII_IPC_HLE_Device_stm_eventhook");
|
||||
Memory::Write_U32(FS_EINVAL, _CommandAddress + 4);
|
||||
return GetDefaultReply();
|
||||
}
|
||||
|
||||
// IOCTL_STM_EVENTHOOK waits until the reset button or power button
|
||||
// is pressed.
|
||||
m_EventHookAddress = _CommandAddress;
|
||||
return GetNoReply();
|
||||
}
|
||||
|
||||
void CWII_IPC_HLE_Device_stm_eventhook::ResetButton()
|
||||
{
|
||||
if (!m_Active || m_EventHookAddress == 0)
|
||||
{
|
||||
// If the device isn't open, ignore the button press.
|
||||
return;
|
||||
}
|
||||
|
||||
// The reset button returns STM_EVENT_RESET.
|
||||
u32 BufferOut = Memory::Read_U32(m_EventHookAddress + 0x18);
|
||||
Memory::Write_U32(STM_EVENT_RESET, BufferOut);
|
||||
|
||||
// Fill in command buffer.
|
||||
Memory::Write_U32(FS_SUCCESS, m_EventHookAddress + 4);
|
||||
Memory::Write_U32(IPC_REP_ASYNC, m_EventHookAddress);
|
||||
Memory::Write_U32(IPC_CMD_IOCTL, m_EventHookAddress + 8);
|
||||
|
||||
// Generate a reply to the IPC command.
|
||||
WII_IPC_HLE_Interface::EnqueueReply(m_EventHookAddress);
|
||||
}
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "Core/IPC_HLE/WII_IPC_HLE_Device.h"
|
||||
|
||||
enum
|
||||
|
@ -40,80 +39,10 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
virtual ~CWII_IPC_HLE_Device_stm_immediate() {}
|
||||
IPCCommandResult Open(u32 _CommandAddress, u32 _Mode) override
|
||||
{
|
||||
INFO_LOG(WII_IPC_STM, "STM immediate: Open");
|
||||
Memory::Write_U32(GetDeviceID(), _CommandAddress + 4);
|
||||
m_Active = true;
|
||||
return GetDefaultReply();
|
||||
}
|
||||
|
||||
IPCCommandResult Close(u32 _CommandAddress, bool _bForce) override
|
||||
{
|
||||
INFO_LOG(WII_IPC_STM, "STM immediate: Close");
|
||||
if (!_bForce)
|
||||
Memory::Write_U32(0, _CommandAddress + 4);
|
||||
m_Active = false;
|
||||
return GetDefaultReply();
|
||||
}
|
||||
|
||||
IPCCommandResult IOCtl(u32 _CommandAddress) override
|
||||
{
|
||||
u32 Parameter = Memory::Read_U32(_CommandAddress + 0x0C);
|
||||
u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10);
|
||||
u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14);
|
||||
u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18);
|
||||
u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C);
|
||||
|
||||
// Prepare the out buffer(s) with zeroes as a safety precaution
|
||||
// to avoid returning bad values
|
||||
Memory::Memset(BufferOut, 0, BufferOutSize);
|
||||
u32 ReturnValue = 0;
|
||||
|
||||
switch (Parameter)
|
||||
{
|
||||
case IOCTL_STM_RELEASE_EH:
|
||||
INFO_LOG(WII_IPC_STM, "%s - IOCtl:", GetDeviceName().c_str());
|
||||
INFO_LOG(WII_IPC_STM, " IOCTL_STM_RELEASE_EH");
|
||||
break;
|
||||
|
||||
case IOCTL_STM_HOTRESET:
|
||||
INFO_LOG(WII_IPC_STM, "%s - IOCtl:", GetDeviceName().c_str());
|
||||
INFO_LOG(WII_IPC_STM, " IOCTL_STM_HOTRESET");
|
||||
break;
|
||||
|
||||
case IOCTL_STM_VIDIMMING: // (Input: 20 bytes, Output: 20 bytes)
|
||||
INFO_LOG(WII_IPC_STM, "%s - IOCtl:", GetDeviceName().c_str());
|
||||
INFO_LOG(WII_IPC_STM, " IOCTL_STM_VIDIMMING");
|
||||
// DumpCommands(BufferIn, BufferInSize / 4, LogTypes::WII_IPC_STM);
|
||||
// Memory::Write_U32(1, BufferOut);
|
||||
// ReturnValue = 1;
|
||||
break;
|
||||
|
||||
case IOCTL_STM_LEDMODE: // (Input: 20 bytes, Output: 20 bytes)
|
||||
INFO_LOG(WII_IPC_STM, "%s - IOCtl:", GetDeviceName().c_str());
|
||||
INFO_LOG(WII_IPC_STM, " IOCTL_STM_LEDMODE");
|
||||
break;
|
||||
|
||||
default:
|
||||
{
|
||||
_dbg_assert_msg_(WII_IPC_STM, 0, "CWII_IPC_HLE_Device_stm_immediate: 0x%x", Parameter);
|
||||
|
||||
INFO_LOG(WII_IPC_STM, "%s - IOCtl:", GetDeviceName().c_str());
|
||||
DEBUG_LOG(WII_IPC_STM, " Parameter: 0x%x", Parameter);
|
||||
DEBUG_LOG(WII_IPC_STM, " InBuffer: 0x%08x", BufferIn);
|
||||
DEBUG_LOG(WII_IPC_STM, " InBufferSize: 0x%08x", BufferInSize);
|
||||
DEBUG_LOG(WII_IPC_STM, " OutBuffer: 0x%08x", BufferOut);
|
||||
DEBUG_LOG(WII_IPC_STM, " OutBufferSize: 0x%08x", BufferOutSize);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Write return value to the IPC call
|
||||
Memory::Write_U32(ReturnValue, _CommandAddress + 0x4);
|
||||
return GetDefaultReply();
|
||||
}
|
||||
~CWII_IPC_HLE_Device_stm_immediate() override = default;
|
||||
IPCCommandResult Open(u32 _CommandAddress, u32 _Mode) override;
|
||||
IPCCommandResult Close(u32 _CommandAddress, bool _bForce) override;
|
||||
IPCCommandResult IOCtl(u32 _CommandAddress) override;
|
||||
};
|
||||
|
||||
// The /dev/stm/eventhook
|
||||
|
@ -125,61 +54,12 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
virtual ~CWII_IPC_HLE_Device_stm_eventhook() {}
|
||||
IPCCommandResult Open(u32 _CommandAddress, u32 _Mode) override
|
||||
{
|
||||
Memory::Write_U32(GetDeviceID(), _CommandAddress + 4);
|
||||
m_Active = true;
|
||||
return GetDefaultReply();
|
||||
}
|
||||
~CWII_IPC_HLE_Device_stm_eventhook() override = default;
|
||||
IPCCommandResult Open(u32 _CommandAddress, u32 _Mode) override;
|
||||
IPCCommandResult Close(u32 _CommandAddress, bool _bForce) override;
|
||||
IPCCommandResult IOCtl(u32 _CommandAddress) override;
|
||||
|
||||
IPCCommandResult Close(u32 _CommandAddress, bool _bForce) override
|
||||
{
|
||||
m_EventHookAddress = 0;
|
||||
|
||||
INFO_LOG(WII_IPC_STM, "STM eventhook: Close");
|
||||
if (!_bForce)
|
||||
Memory::Write_U32(0, _CommandAddress + 4);
|
||||
m_Active = false;
|
||||
return GetDefaultReply();
|
||||
}
|
||||
|
||||
IPCCommandResult IOCtl(u32 _CommandAddress) override
|
||||
{
|
||||
u32 Parameter = Memory::Read_U32(_CommandAddress + 0x0C);
|
||||
if (Parameter != IOCTL_STM_EVENTHOOK)
|
||||
{
|
||||
ERROR_LOG(WII_IPC_STM, "Bad IOCtl in CWII_IPC_HLE_Device_stm_eventhook");
|
||||
Memory::Write_U32(FS_EINVAL, _CommandAddress + 4);
|
||||
return GetDefaultReply();
|
||||
}
|
||||
|
||||
// IOCTL_STM_EVENTHOOK waits until the reset button or power button
|
||||
// is pressed.
|
||||
m_EventHookAddress = _CommandAddress;
|
||||
return GetNoReply();
|
||||
}
|
||||
|
||||
void ResetButton()
|
||||
{
|
||||
if (!m_Active || m_EventHookAddress == 0)
|
||||
{
|
||||
// If the device isn't open, ignore the button press.
|
||||
return;
|
||||
}
|
||||
|
||||
// The reset button returns STM_EVENT_RESET.
|
||||
u32 BufferOut = Memory::Read_U32(m_EventHookAddress + 0x18);
|
||||
Memory::Write_U32(STM_EVENT_RESET, BufferOut);
|
||||
|
||||
// Fill in command buffer.
|
||||
Memory::Write_U32(FS_SUCCESS, m_EventHookAddress + 4);
|
||||
Memory::Write_U32(IPC_REP_ASYNC, m_EventHookAddress);
|
||||
Memory::Write_U32(IPC_CMD_IOCTL, m_EventHookAddress + 8);
|
||||
|
||||
// Generate a reply to the IPC command.
|
||||
WII_IPC_HLE_Interface::EnqueueReply(m_EventHookAddress);
|
||||
}
|
||||
void ResetButton();
|
||||
|
||||
// STATE_TO_SAVE
|
||||
u32 m_EventHookAddress;
|
||||
|
|
Loading…
Reference in New Issue