Merge pull request #4375 from leoetlino/ipc-hle-small-cleanup

IPC_HLE: Small cleanup
This commit is contained in:
Anthony
2016-11-25 17:50:14 -06:00
committed by GitHub
45 changed files with 616 additions and 750 deletions
+2
View File
@@ -137,6 +137,8 @@ set(SRCS ActionReplay.cpp
IPC_HLE/ICMPLin.cpp
IPC_HLE/NWC24Config.cpp
IPC_HLE/WII_IPC_HLE.cpp
IPC_HLE/WII_IPC_HLE_Device.cpp
IPC_HLE/WII_IPC_HLE_Device_stub.cpp
IPC_HLE/WII_IPC_HLE_Device_DI.cpp
IPC_HLE/WII_IPC_HLE_Device_es.cpp
IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp
+3
View File
@@ -171,6 +171,8 @@
<ClCompile Include="IPC_HLE\NWC24Config.cpp" />
<ClCompile Include="IPC_HLE\WiiMote_HID_Attr.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_stub.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_DI.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_es.cpp" />
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_FileIO.cpp" />
@@ -388,6 +390,7 @@
<ClInclude Include="IPC_HLE\WiiMote_HID_Attr.h" />
<ClInclude Include="IPC_HLE\WII_IPC_HLE.h" />
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device.h" />
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_stub.h" />
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_DI.h" />
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_es.h" />
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_FileIO.h" />
+9
View File
@@ -555,6 +555,12 @@
<ClCompile Include="IPC_HLE\WII_IPC_HLE.cpp">
<Filter>IPC HLE %28IOS/Starlet%29</Filter>
</ClCompile>
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device.cpp">
<Filter>IPC HLE %28IOS/Starlet%29</Filter>
</ClCompile>
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_stub.cpp">
<Filter>IPC HLE %28IOS/Starlet%29</Filter>
</ClCompile>
<ClCompile Include="IPC_HLE\WII_IPC_HLE_Device_DI.cpp">
<Filter>IPC HLE %28IOS/Starlet%29\DI</Filter>
</ClCompile>
@@ -1127,6 +1133,9 @@
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device.h">
<Filter>IPC HLE %28IOS/Starlet%29</Filter>
</ClInclude>
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_stub.h">
<Filter>IPC HLE %28IOS/Starlet%29</Filter>
</ClInclude>
<ClInclude Include="IPC_HLE\WII_IPC_HLE_Device_stm.h">
<Filter>IPC HLE %28IOS/Starlet%29</Filter>
</ClInclude>
+17 -32
View File
@@ -20,27 +20,23 @@ in case of success they are
They will also generate a true or false return for UpdateInterrupts() in WII_IPC.cpp.
*/
#include <list>
#include <deque>
#include <map>
#include <memory>
#include <mutex>
#include <string>
#include <utility>
#include <vector>
#include "Common/Assert.h"
#include "Common/ChunkFile.h"
#include "Common/CommonPaths.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/Thread.h"
#include "Common/Logging/Log.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/CoreTiming.h"
#include "Core/Debugger/Debugger_SymbolMap.h"
#include "Core/HW/CPU.h"
#include "Core/HW/Memmap.h"
#include "Core/HW/SystemTimers.h"
#include "Core/HW/WII_IPC.h"
#include "Core/IPC_HLE/WII_IPC_HLE.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_DI.h"
@@ -51,17 +47,21 @@ They will also generate a true or false return for UpdateInterrupts() in WII_IPC
#include "Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_stm.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_stub.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_real.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_kbd.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_ven.h"
namespace CoreTiming
{
struct EventType;
} // namespace CoreTiming
#if defined(__LIBUSB__)
#include "Core/IPC_HLE/WII_IPC_HLE_Device_hid.h"
#endif
#include "Core/PowerPC/PowerPC.h"
namespace WII_IPC_HLE_Interface
{
static std::map<u32, std::shared_ptr<IWII_IPC_HLE_Device>> s_device_map;
@@ -553,14 +553,7 @@ void ExecuteCommand(u32 address)
s_last_reply_time = CoreTiming::GetTicks() + result.reply_delay_ticks;
if (result.send_reply)
{
// The original hardware overwrites the command type with the async reply type.
Memory::Write_U32(IPC_REP_ASYNC, address);
// IOS also seems to write back the command that was responded to in the FD field.
Memory::Write_U32(Command, address + 8);
// Generate a reply to the IPC command
EnqueueReply(address, (int)result.reply_delay_ticks);
}
EnqueueReply(address, static_cast<int>(result.reply_delay_ticks));
}
// Happens AS SOON AS IPC gets a new pointer!
@@ -569,12 +562,13 @@ void EnqueueRequest(u32 address)
CoreTiming::ScheduleEvent(1000, s_event_enqueue, address | ENQUEUE_REQUEST_FLAG);
}
// Called when IOS module has some reply
// NOTE: Only call this if you have correctly handled
// CommandAddress+0 and CommandAddress+8.
// Please search for examples of this being called elsewhere.
// Called to send a reply to an IOS syscall
void EnqueueReply(u32 address, int cycles_in_future, CoreTiming::FromThread from)
{
// IOS writes back the command that was responded to in the FD field.
Memory::Write_U32(Memory::Read_U32(address), address + 8);
// IOS also overwrites the command type with the async reply type.
Memory::Write_U32(IPC_REP_ASYNC, address);
CoreTiming::ScheduleEvent(cycles_in_future, s_event_enqueue, address, from);
}
@@ -631,12 +625,3 @@ void UpdateDevices()
}
} // end of namespace WII_IPC_HLE_Interface
// TODO: create WII_IPC_HLE_Device.cpp ?
void IWII_IPC_HLE_Device::DoStateShared(PointerWrap& p)
{
p.Do(m_Name);
p.Do(m_DeviceID);
p.Do(m_Hardware);
p.Do(m_Active);
}
-1
View File
@@ -9,7 +9,6 @@
#include <vector>
#include "Common/CommonTypes.h"
#include "Core/CoreTiming.h"
#include "Core/HW/SystemTimers.h"
@@ -0,0 +1,181 @@
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Core/IPC_HLE/WII_IPC_HLE.h"
#include "Common/StringUtil.h"
#include "Core/HW/Memmap.h"
#include "Core/HW/SystemTimers.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device.h"
SIOCtlVBuffer::SIOCtlVBuffer(const u32 address) : m_Address(address)
{
// These are the Ioctlv parameters in the IOS communication. The BufferVector
// is a memory address offset at where the in and out buffer addresses are
// stored.
Parameter = Memory::Read_U32(m_Address + 0x0C); // command 3, arg0
NumberInBuffer = Memory::Read_U32(m_Address + 0x10); // 4, arg1
NumberPayloadBuffer = Memory::Read_U32(m_Address + 0x14); // 5, arg2
BufferVector = Memory::Read_U32(m_Address + 0x18); // 6, arg3
// The start of the out buffer
u32 BufferVectorOffset = BufferVector;
// Write the address and size for all in messages
for (u32 i = 0; i < NumberInBuffer; i++)
{
SBuffer Buffer;
Buffer.m_Address = Memory::Read_U32(BufferVectorOffset);
BufferVectorOffset += 4;
Buffer.m_Size = Memory::Read_U32(BufferVectorOffset);
BufferVectorOffset += 4;
InBuffer.push_back(Buffer);
DEBUG_LOG(WII_IPC_HLE, "SIOCtlVBuffer in%i: 0x%08x, 0x%x", i, Buffer.m_Address, Buffer.m_Size);
}
// Write the address and size for all out or in-out messages
for (u32 i = 0; i < NumberPayloadBuffer; i++)
{
SBuffer Buffer;
Buffer.m_Address = Memory::Read_U32(BufferVectorOffset);
BufferVectorOffset += 4;
Buffer.m_Size = Memory::Read_U32(BufferVectorOffset);
BufferVectorOffset += 4;
PayloadBuffer.push_back(Buffer);
DEBUG_LOG(WII_IPC_HLE, "SIOCtlVBuffer io%i: 0x%08x, 0x%x", i, Buffer.m_Address, Buffer.m_Size);
}
}
IWII_IPC_HLE_Device::IWII_IPC_HLE_Device(const u32 device_id, const std::string& device_name,
const bool hardware)
: m_Name(device_name), m_DeviceID(device_id), m_Hardware(hardware)
{
}
void IWII_IPC_HLE_Device::DoState(PointerWrap& p)
{
DoStateShared(p);
p.Do(m_Active);
}
void IWII_IPC_HLE_Device::DoStateShared(PointerWrap& p)
{
p.Do(m_Name);
p.Do(m_DeviceID);
p.Do(m_Hardware);
p.Do(m_Active);
}
IPCCommandResult IWII_IPC_HLE_Device::Open(u32 command_address, u32 mode)
{
WARN_LOG(WII_IPC_HLE, "%s does not support Open()", m_Name.c_str());
Memory::Write_U32(FS_ENOENT, command_address + 4);
m_Active = true;
return GetDefaultReply();
}
IPCCommandResult IWII_IPC_HLE_Device::Close(u32 command_address, bool force)
{
WARN_LOG(WII_IPC_HLE, "%s does not support Close()", m_Name.c_str());
if (!force)
Memory::Write_U32(FS_EINVAL, command_address + 4);
m_Active = false;
return GetDefaultReply();
}
IPCCommandResult IWII_IPC_HLE_Device::Seek(u32 command_address)
{
WARN_LOG(WII_IPC_HLE, "%s does not support Seek()", m_Name.c_str());
return GetDefaultReply();
}
IPCCommandResult IWII_IPC_HLE_Device::Read(u32 command_address)
{
WARN_LOG(WII_IPC_HLE, "%s does not support Read()", m_Name.c_str());
return GetDefaultReply();
}
IPCCommandResult IWII_IPC_HLE_Device::Write(u32 command_address)
{
WARN_LOG(WII_IPC_HLE, "%s does not support Write()", m_Name.c_str());
return GetDefaultReply();
}
IPCCommandResult IWII_IPC_HLE_Device::IOCtl(u32 command_address)
{
WARN_LOG(WII_IPC_HLE, "%s does not support IOCtl()", m_Name.c_str());
return GetDefaultReply();
}
IPCCommandResult IWII_IPC_HLE_Device::IOCtlV(u32 command_address)
{
WARN_LOG(WII_IPC_HLE, "%s does not support IOCtlV()", m_Name.c_str());
return GetDefaultReply();
}
// Returns an IPCCommandResult for a reply that takes 250 us (arbitrarily chosen value)
IPCCommandResult IWII_IPC_HLE_Device::GetDefaultReply()
{
return {true, SystemTimers::GetTicksPerSecond() / 4000};
}
// Returns an IPCCommandResult with no reply. Useful for async commands that will generate a reply
// later
IPCCommandResult IWII_IPC_HLE_Device::GetNoReply()
{
return {false, 0};
}
// Write out the IPC struct from command_address to num_commands numbers
// of 4 byte commands.
void IWII_IPC_HLE_Device::DumpCommands(u32 command_address, size_t num_commands,
LogTypes::LOG_TYPE log_type, LogTypes::LOG_LEVELS verbosity)
{
GENERIC_LOG(log_type, verbosity, "CommandDump of %s", GetDeviceName().c_str());
for (u32 i = 0; i < num_commands; i++)
{
GENERIC_LOG(log_type, verbosity, " Command%02i: 0x%08x", i,
Memory::Read_U32(command_address + i * 4));
}
}
void IWII_IPC_HLE_Device::DumpAsync(u32 buffer_vector, u32 number_in_buffer, u32 number_io_buffer,
LogTypes::LOG_TYPE log_type, LogTypes::LOG_LEVELS verbosity)
{
GENERIC_LOG(log_type, verbosity, "======= DumpAsync ======");
u32 BufferOffset = buffer_vector;
for (u32 i = 0; i < number_in_buffer; i++)
{
u32 InBuffer = Memory::Read_U32(BufferOffset);
BufferOffset += 4;
u32 InBufferSize = Memory::Read_U32(BufferOffset);
BufferOffset += 4;
GENERIC_LOG(log_type, LogTypes::LINFO, "%s - IOCtlV InBuffer[%i]:", GetDeviceName().c_str(), i);
std::string Temp;
for (u32 j = 0; j < InBufferSize; j++)
{
Temp += StringFromFormat("%02x ", Memory::Read_U8(InBuffer + j));
}
GENERIC_LOG(log_type, LogTypes::LDEBUG, " Buffer: %s", Temp.c_str());
}
for (u32 i = 0; i < number_io_buffer; i++)
{
u32 OutBuffer = Memory::Read_U32(BufferOffset);
BufferOffset += 4;
u32 OutBufferSize = Memory::Read_U32(BufferOffset);
BufferOffset += 4;
GENERIC_LOG(log_type, LogTypes::LINFO, "%s - IOCtlV OutBuffer[%i]:", GetDeviceName().c_str(),
i);
GENERIC_LOG(log_type, LogTypes::LINFO, " OutBuffer: 0x%08x (0x%x):", OutBuffer,
OutBufferSize);
if (verbosity >= LogTypes::LOG_LEVELS::LINFO)
DumpCommands(OutBuffer, OutBufferSize, log_type, verbosity);
}
}
+27 -185
View File
@@ -4,13 +4,14 @@
#pragma once
#include <queue>
#include <cstddef>
#include <string>
#include <vector>
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/StringUtil.h"
#include "Core/HW/Memmap.h"
#include "Core/IPC_HLE/WII_IPC_HLE.h"
#define FS_SUCCESS (u32)0 // Success
@@ -41,53 +42,13 @@
// A struct for IOS ioctlv calls
struct SIOCtlVBuffer
{
SIOCtlVBuffer(u32 _Address) : m_Address(_Address)
{
// These are the Ioctlv parameters in the IOS communication. The BufferVector
// is a memory address offset at where the in and out buffer addresses are
// stored.
Parameter = Memory::Read_U32(m_Address + 0x0C); // command 3, arg0
NumberInBuffer = Memory::Read_U32(m_Address + 0x10); // 4, arg1
NumberPayloadBuffer = Memory::Read_U32(m_Address + 0x14); // 5, arg2
BufferVector = Memory::Read_U32(m_Address + 0x18); // 6, arg3
// The start of the out buffer
u32 BufferVectorOffset = BufferVector;
// Write the address and size for all in messages
for (u32 i = 0; i < NumberInBuffer; i++)
{
SBuffer Buffer;
Buffer.m_Address = Memory::Read_U32(BufferVectorOffset);
BufferVectorOffset += 4;
Buffer.m_Size = Memory::Read_U32(BufferVectorOffset);
BufferVectorOffset += 4;
InBuffer.push_back(Buffer);
DEBUG_LOG(WII_IPC_HLE, "SIOCtlVBuffer in%i: 0x%08x, 0x%x", i, Buffer.m_Address,
Buffer.m_Size);
}
// Write the address and size for all out or in-out messages
for (u32 i = 0; i < NumberPayloadBuffer; i++)
{
SBuffer Buffer;
Buffer.m_Address = Memory::Read_U32(BufferVectorOffset);
BufferVectorOffset += 4;
Buffer.m_Size = Memory::Read_U32(BufferVectorOffset);
BufferVectorOffset += 4;
PayloadBuffer.push_back(Buffer);
DEBUG_LOG(WII_IPC_HLE, "SIOCtlVBuffer io%i: 0x%08x, 0x%x", i, Buffer.m_Address,
Buffer.m_Size);
}
}
explicit SIOCtlVBuffer(u32 address);
const u32 m_Address;
u32 Parameter;
u32 NumberInBuffer;
u32 NumberPayloadBuffer;
u32 BufferVector;
struct SBuffer
{
u32 m_Address, m_Size;
@@ -99,164 +60,45 @@ struct SIOCtlVBuffer
class IWII_IPC_HLE_Device
{
public:
IWII_IPC_HLE_Device(u32 _DeviceID, const std::string& _rName, bool _Hardware = true)
: m_Name(_rName), m_DeviceID(_DeviceID), m_Hardware(_Hardware), m_Active(false)
{
}
IWII_IPC_HLE_Device(u32 device_id, const std::string& device_name, bool hardware = true);
virtual ~IWII_IPC_HLE_Device() {}
virtual ~IWII_IPC_HLE_Device() = default;
// Release any resources which might interfere with savestating.
virtual void PrepareForState(PointerWrap::Mode mode) {}
virtual void DoState(PointerWrap& p)
{
DoStateShared(p);
p.Do(m_Active);
}
virtual void DoState(PointerWrap& p);
void DoStateShared(PointerWrap& p);
const std::string& GetDeviceName() const { return m_Name; }
u32 GetDeviceID() const { return m_DeviceID; }
virtual IPCCommandResult Open(u32 _CommandAddress, u32 _Mode)
{
(void)_Mode;
WARN_LOG(WII_IPC_HLE, "%s does not support Open()", m_Name.c_str());
Memory::Write_U32(FS_ENOENT, _CommandAddress + 4);
m_Active = true;
return GetDefaultReply();
}
virtual IPCCommandResult Close(u32 _CommandAddress, bool _bForce = false)
{
WARN_LOG(WII_IPC_HLE, "%s does not support Close()", m_Name.c_str());
if (!_bForce)
Memory::Write_U32(FS_EINVAL, _CommandAddress + 4);
m_Active = false;
return GetDefaultReply();
}
#define UNIMPLEMENTED_CMD(cmd) \
WARN_LOG(WII_IPC_HLE, "%s does not support " #cmd "()", m_Name.c_str()); \
return GetDefaultReply();
virtual IPCCommandResult Seek(u32) { UNIMPLEMENTED_CMD(Seek) }
virtual IPCCommandResult Read(u32) { UNIMPLEMENTED_CMD(Read) }
virtual IPCCommandResult Write(u32) { UNIMPLEMENTED_CMD(Write) }
virtual IPCCommandResult IOCtl(u32) { UNIMPLEMENTED_CMD(IOCtl) }
virtual IPCCommandResult IOCtlV(u32) { UNIMPLEMENTED_CMD(IOCtlV) }
#undef UNIMPLEMENTED_CMD
virtual IPCCommandResult Open(u32 command_address, u32 mode);
virtual IPCCommandResult Close(u32 command_address, bool force = false);
virtual IPCCommandResult Seek(u32 command_address);
virtual IPCCommandResult Read(u32 command_address);
virtual IPCCommandResult Write(u32 command_address);
virtual IPCCommandResult IOCtl(u32 command_address);
virtual IPCCommandResult IOCtlV(u32 command_address);
virtual u32 Update() { return 0; }
virtual bool IsHardware() { return m_Hardware; }
virtual bool IsOpened() { return m_Active; }
// Returns an IPCCommandResult for a reply that takes 250 us (arbitrarily chosen value)
static IPCCommandResult GetDefaultReply()
{
return {true, SystemTimers::GetTicksPerSecond() / 4000};
}
// Returns an IPCCommandResult with no reply. Useful for async commands that will generate a reply
// later
static IPCCommandResult GetNoReply() { return {false, 0}; }
virtual bool IsHardware() const { return m_Hardware; }
virtual bool IsOpened() const { return m_Active; }
static IPCCommandResult GetDefaultReply();
static IPCCommandResult GetNoReply();
std::string m_Name;
protected:
// STATE_TO_SAVE
u32 m_DeviceID;
bool m_Hardware;
bool m_Active;
bool m_Active = false;
// Write out the IPC struct from _CommandAddress to _NumberOfCommands numbers
// Write out the IPC struct from command_address to number_of_commands numbers
// of 4 byte commands.
void DumpCommands(u32 _CommandAddress, size_t _NumberOfCommands = 8,
LogTypes::LOG_TYPE LogType = LogTypes::WII_IPC_HLE,
LogTypes::LOG_LEVELS Verbosity = LogTypes::LDEBUG)
{
GENERIC_LOG(LogType, Verbosity, "CommandDump of %s", GetDeviceName().c_str());
for (u32 i = 0; i < _NumberOfCommands; i++)
{
GENERIC_LOG(LogType, Verbosity, " Command%02i: 0x%08x", i,
Memory::Read_U32(_CommandAddress + i * 4));
}
}
void DumpCommands(u32 command_address, size_t number_of_commands = 8,
LogTypes::LOG_TYPE log_type = LogTypes::WII_IPC_HLE,
LogTypes::LOG_LEVELS verbosity = LogTypes::LDEBUG);
void DumpAsync(u32 BufferVector, u32 NumberInBuffer, u32 NumberOutBuffer,
LogTypes::LOG_TYPE LogType = LogTypes::WII_IPC_HLE,
LogTypes::LOG_LEVELS Verbosity = LogTypes::LDEBUG)
{
GENERIC_LOG(LogType, Verbosity, "======= DumpAsync ======");
u32 BufferOffset = BufferVector;
for (u32 i = 0; i < NumberInBuffer; i++)
{
u32 InBuffer = Memory::Read_U32(BufferOffset);
BufferOffset += 4;
u32 InBufferSize = Memory::Read_U32(BufferOffset);
BufferOffset += 4;
GENERIC_LOG(LogType, LogTypes::LINFO, "%s - IOCtlV InBuffer[%i]:", GetDeviceName().c_str(),
i);
std::string Temp;
for (u32 j = 0; j < InBufferSize; j++)
{
Temp += StringFromFormat("%02x ", Memory::Read_U8(InBuffer + j));
}
GENERIC_LOG(LogType, LogTypes::LDEBUG, " Buffer: %s", Temp.c_str());
}
for (u32 i = 0; i < NumberOutBuffer; i++)
{
u32 OutBuffer = Memory::Read_U32(BufferOffset);
BufferOffset += 4;
u32 OutBufferSize = Memory::Read_U32(BufferOffset);
BufferOffset += 4;
GENERIC_LOG(LogType, LogTypes::LINFO, "%s - IOCtlV OutBuffer[%i]:", GetDeviceName().c_str(),
i);
GENERIC_LOG(LogType, LogTypes::LINFO, " OutBuffer: 0x%08x (0x%x):", OutBuffer,
OutBufferSize);
if (Verbosity >= LogTypes::LOG_LEVELS::LINFO)
DumpCommands(OutBuffer, OutBufferSize, LogType, Verbosity);
}
}
};
class CWII_IPC_HLE_Device_stub : public IWII_IPC_HLE_Device
{
public:
CWII_IPC_HLE_Device_stub(u32 DeviceID, const std::string& Name)
: IWII_IPC_HLE_Device(DeviceID, Name)
{
}
IPCCommandResult Open(u32 CommandAddress, u32 Mode) override
{
(void)Mode;
WARN_LOG(WII_IPC_HLE, "%s faking Open()", m_Name.c_str());
Memory::Write_U32(GetDeviceID(), CommandAddress + 4);
m_Active = true;
return GetDefaultReply();
}
IPCCommandResult Close(u32 CommandAddress, bool bForce = false) override
{
WARN_LOG(WII_IPC_HLE, "%s faking Close()", m_Name.c_str());
if (!bForce)
Memory::Write_U32(FS_SUCCESS, CommandAddress + 4);
m_Active = false;
return GetDefaultReply();
}
IPCCommandResult IOCtl(u32 CommandAddress) override
{
WARN_LOG(WII_IPC_HLE, "%s faking IOCtl()", m_Name.c_str());
Memory::Write_U32(FS_SUCCESS, CommandAddress + 4);
return GetDefaultReply();
}
IPCCommandResult IOCtlV(u32 CommandAddress) override
{
WARN_LOG(WII_IPC_HLE, "%s faking IOCtlV()", m_Name.c_str());
Memory::Write_U32(FS_SUCCESS, CommandAddress + 4);
return GetDefaultReply();
}
void DumpAsync(u32 buffer_vector, u32 number_in_buffer, u32 number_io_buffer,
LogTypes::LOG_TYPE log_type = LogTypes::WII_IPC_HLE,
LogTypes::LOG_LEVELS verbosity = LogTypes::LDEBUG);
};
@@ -4,15 +4,15 @@
#include <cinttypes>
#include <memory>
#include <vector>
#include "Common/Assert.h"
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/LogManager.h"
#include "Core/ConfigManager.h"
#include "Core/CoreTiming.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "Core/HW/DVDInterface.h"
#include "Core/HW/Memmap.h"
#include "Core/HW/SystemTimers.h"
#include "Core/IPC_HLE/WII_IPC_HLE.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_DI.h"
#include "DiscIO/Volume.h"
@@ -107,12 +107,6 @@ void CWII_IPC_HLE_Device_di::FinishIOCtl(DVDInterface::DIInterruptType interrupt
// The DI interrupt type is used as a return value
Memory::Write_U32(interrupt_type, command_address + 4);
// The original hardware overwrites the command type with the async reply type.
Memory::Write_U32(IPC_REP_ASYNC, command_address);
// IOS also seems to write back the command that was responded to in the FD field.
Memory::Write_U32(Memory::Read_U32(command_address), command_address + 8);
// Generate a reply to the IPC command
WII_IPC_HLE_Interface::EnqueueReply(command_address);
// DVDInterface is now ready to execute another command,
@@ -5,9 +5,14 @@
#pragma once
#include <deque>
#include <string>
#include "Common/CommonTypes.h"
#include "Core/IPC_HLE/WII_IPC_HLE.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device.h"
class PointerWrap;
namespace DVDInterface
{
enum DIInterruptType : int;
@@ -2,18 +2,18 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <algorithm>
#include <cstdio>
#include <map>
#include <memory>
#include <utility>
#include "Common/ChunkFile.h"
#include "Common/CommonPaths.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "Common/NandPaths.h"
#include "Common/StringUtil.h"
#include "Core/Core.h"
#include "Core/HW/Memmap.h"
#include "Core/IPC_HLE/WII_IPC_HLE.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_fs.h"
@@ -93,11 +93,9 @@ void HLE_IPC_CreateVirtualFATFilesystem()
}
}
CWII_IPC_HLE_Device_FileIO::CWII_IPC_HLE_Device_FileIO(u32 _DeviceID,
const std::string& _rDeviceName)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName, false) // not a real hardware
,
m_Mode(0), m_SeekPos(0), m_file()
CWII_IPC_HLE_Device_FileIO::CWII_IPC_HLE_Device_FileIO(u32 device_id,
const std::string& device_name)
: IWII_IPC_HLE_Device(device_id, device_name, false) // not a real hardware
{
Common::ReadReplacements(replacements);
}
@@ -5,9 +5,14 @@
#pragma once
#include <string>
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Core/IPC_HLE/WII_IPC_HLE.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device.h"
class PointerWrap;
namespace File
{
class IOFile;
@@ -75,8 +80,8 @@ private:
ISFS_IOCTL_SHUTDOWN = 13
};
u32 m_Mode;
u32 m_SeekPos;
u32 m_Mode = 0;
u32 m_SeekPos = 0;
std::string m_filepath;
std::shared_ptr<File::IOFile> m_file;
@@ -31,21 +31,27 @@
*/
// =============
// need to include this before mbedtls/aes.h,
// otherwise we may not get __STDC_FORMAT_MACROS
#include <cinttypes>
#include <mbedtls/aes.h>
#include <cstdio>
#include <cstring>
#include <memory>
#include <utility>
#include <vector>
#include <mbedtls/aes.h>
#include "Common/Assert.h"
#include "Common/ChunkFile.h"
#include "Common/CommonPaths.h"
#include "Common/CommonFuncs.h"
#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "Common/NandPaths.h"
#include "Common/StringUtil.h"
#include "Core/Boot/Boot_DOL.h"
#include "Core/ConfigManager.h"
#include "Core/HW/DVDInterface.h"
#include "Core/HW/Memmap.h"
#include "Core/HW/Wiimote.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_es.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.h"
#include "Core/IPC_HLE/WII_IPC_HLE_WiiMote.h"
@@ -9,9 +9,12 @@
#include <string>
#include <vector>
#include "Common/CommonTypes.h"
#include "Core/IPC_HLE/WII_IPC_HLE.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device.h"
class PointerWrap;
namespace DiscIO
{
class CNANDContentLoader;
@@ -4,14 +4,20 @@
#include <algorithm>
#include <cstring>
#include <deque>
#include <memory>
#include <vector>
#include "Common/Assert.h"
#include "Common/ChunkFile.h"
#include "Common/CommonPaths.h"
#include "Common/CommonTypes.h"
#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
#include "Common/MsgHandler.h"
#include "Common/NandPaths.h"
#include "Common/StringUtil.h"
#include "Core/HW/Memmap.h"
#include "Core/HW/SystemTimers.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_fs.h"
@@ -28,6 +34,13 @@ CWII_IPC_HLE_Device_fs::~CWII_IPC_HLE_Device_fs()
{
}
// ~1/1000th of a second is too short and causes hangs in Wii Party
// Play it safe at 1/500th
IPCCommandResult CWII_IPC_HLE_Device_fs::GetFSReply() const
{
return {true, SystemTimers::GetTicksPerSecond() / 500};
}
IPCCommandResult CWII_IPC_HLE_Device_fs::Open(u32 _CommandAddress, u32 _Mode)
{
// clear tmp folder
@@ -4,6 +4,10 @@
#pragma once
#include <string>
#include "Common/CommonTypes.h"
#include "Core/IPC_HLE/WII_IPC_HLE.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device.h"
class PointerWrap;
@@ -60,9 +64,7 @@ private:
IOCTL_SHUTDOWN = 0x0D
};
// ~1/1000th of a second is too short and causes hangs in Wii Party
// Play it safe at 1/500th
IPCCommandResult GetFSReply() const { return {true, SystemTimers::GetTicksPerSecond() / 500}; }
IPCCommandResult GetFSReply() const;
s32 ExecuteCommand(u32 Parameter, u32 _BufferIn, u32 _BufferInSize, u32 _BufferOut,
u32 _BufferOutSize);
};
@@ -2,14 +2,20 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <cerrno>
#include <cstdlib>
#include <cstring>
#include <memory>
#include <utility>
#include <vector>
#include <libusb.h>
#include "Common/Thread.h"
#include "Common/CommonFuncs.h"
#include "Common/Logging/Log.h"
#include "Core/Core.h"
#include "Core/CoreTiming.h"
#include "Core/Debugger/Debugger_SymbolMap.h"
#include "Core/HW/WII_IPC.h"
#include "Core/HW/Memmap.h"
#include "Core/IPC_HLE/WII_IPC_HLE.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_hid.h"
@@ -33,14 +39,8 @@ void CWII_IPC_HLE_Device_hid::checkUsbUpdates(CWII_IPC_HLE_Device_hid* hid)
hid->FillOutDevices(Memory::Read_U32(hid->deviceCommandAddress + 0x18),
Memory::Read_U32(hid->deviceCommandAddress + 0x1C));
// The original hardware overwrites the command type with the async reply type.
Memory::Write_U32(IPC_REP_ASYNC, hid->deviceCommandAddress);
// IOS also seems to write back the command that was responded to in the FD field.
Memory::Write_U32(IPC_CMD_IOCTL, hid->deviceCommandAddress + 8);
// Return value
Memory::Write_U32(0, hid->deviceCommandAddress + 4);
WII_IPC_HLE_Interface::EnqueueReply(hid->deviceCommandAddress, 0,
CoreTiming::FromThread::NON_CPU);
hid->deviceCommandAddress = 0;
@@ -62,17 +62,9 @@ void CWII_IPC_HLE_Device_hid::handleUsbUpdates(struct libusb_transfer* transfer)
ret = transfer->length;
}
// The original hardware overwrites the command type with the async reply type.
Memory::Write_U32(IPC_REP_ASYNC, replyAddress);
// IOS also seems to write back the command that was responded to in the FD field.
Memory::Write_U32(IPC_CMD_IOCTL, replyAddress + 8);
// Return value
Memory::Write_U32(ret, replyAddress + 4);
WII_IPC_HLE_Interface::EnqueueReply(replyAddress, 0, CoreTiming::FromThread::NON_CPU);
// DEBUG_LOG(WII_IPC_HID, "OMG OMG OMG I GOT A CALLBACK, IMMA BE FAMOUS %d %d %d",
// transfer->actual_length, transfer->length, transfer->status);
}
CWII_IPC_HLE_Device_hid::CWII_IPC_HLE_Device_hid(u32 _DeviceID, const std::string& _rDeviceName)
@@ -259,11 +251,6 @@ IPCCommandResult CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress)
{
Memory::Write_U32(0xFFFFFFFF, Memory::Read_U32(deviceCommandAddress + 0x18));
// The original hardware overwrites the command type with the async reply type.
Memory::Write_U32(IPC_REP_ASYNC, deviceCommandAddress);
// IOS also seems to write back the command that was responded to in the FD field.
Memory::Write_U32(IPC_CMD_IOCTL, deviceCommandAddress + 8);
// Return value
Memory::Write_U32(-1, deviceCommandAddress + 4);
WII_IPC_HLE_Interface::EnqueueReply(deviceCommandAddress);
@@ -7,8 +7,10 @@
#include <list>
#include <map>
#include <mutex>
#include <string>
#include <thread>
#include "Common/CommonTypes.h"
#include "Core/IPC_HLE/WII_IPC_HLE.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device.h"
@@ -19,11 +21,11 @@
#else
#define LIBUSB_CALL
#endif
struct libusb_device_handle;
struct libusb_device_descriptor;
struct libusb_config_descriptor;
struct libusb_interface_descriptor;
struct libusb_device_descriptor;
struct libusb_device_handle;
struct libusb_endpoint_descriptor;
struct libusb_interface_descriptor;
struct libusb_transfer;
#define HID_ID_MASK 0x0000FFFFFFFFFFFF
@@ -6,14 +6,19 @@
#include <cinttypes>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#ifndef _WIN32
#include <arpa/inet.h>
#include <netdb.h>
#include <poll.h>
#endif
#include "Common/Assert.h"
#include "Common/CommonFuncs.h"
#include "Common/CommonPaths.h"
#include "Common/FileUtil.h"
#include "Common/Logging/Log.h"
@@ -21,11 +26,9 @@
#include "Common/Network.h"
#include "Common/SettingsHandler.h"
#include "Common/StringUtil.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/IPC_HLE/ICMP.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_es.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_net.h"
#include "Core/IPC_HLE/WII_Socket.h"
#include "Core/ec_wii.h"
@@ -38,16 +41,8 @@
#define FREE(x) HeapFree(GetProcessHeap(), 0, (x))
#elif defined(__linux__) or defined(__APPLE__)
#include <arpa/inet.h>
#include <errno.h>
#include <net/if.h>
#include <netdb.h>
#include <netinet/in.h>
#include <poll.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/types.h>
typedef struct pollfd pollfd_t;
#else
@@ -4,13 +4,14 @@
#pragma once
#include <string>
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
#include "Common/Timer.h"
#include "Core/HW/EXI_DeviceIPL.h"
#include "Core/HW/Memmap.h"
#include "Core/IPC_HLE/NWC24Config.h"
#include "Core/IPC_HLE/WII_IPC_HLE.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device.h"
#include "Core/IPC_HLE/WiiNetConfig.h"
@@ -2,12 +2,17 @@
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <algorithm>
#include <cstring>
#include <memory>
#include <vector>
#include <mbedtls/md.h>
#include "Common/FileUtil.h"
#include "Common/NandPaths.h"
#include "Common/Logging/Log.h"
#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/HW/Memmap.h"
#include "Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h"
#include "Core/IPC_HLE/WII_Socket.h"

Some files were not shown because too many files have changed in this diff Show More