Put IOS devices in a namespace and drop WII_IPC_HLE prefix

This commit is contained in:
Léo Lam
2017-01-18 21:42:33 +01:00
parent 24199293d3
commit 49b9c723e2
51 changed files with 598 additions and 570 deletions
+2 -2
View File
@@ -1155,9 +1155,9 @@ void FinishExecutingCommand(ReplyType reply_type, DIInterruptType interrupt_type
case ReplyType::IOS_HLE:
{
std::shared_ptr<IOS::HLE::IWII_IPC_HLE_Device> di = IOS::HLE::GetDeviceByName("/dev/di");
auto di = IOS::HLE::GetDeviceByName("/dev/di");
if (di)
std::static_pointer_cast<IOS::HLE::CWII_IPC_HLE_Device_di>(di)->FinishIOCtl(interrupt_type);
std::static_pointer_cast<IOS::HLE::Device::DI>(di)->FinishIOCtl(interrupt_type);
break;
}
+4 -6
View File
@@ -212,10 +212,9 @@ static void IOSNotifyResetButtonCallback(u64 userdata, s64 cyclesLate)
{
if (SConfig::GetInstance().bWii)
{
std::shared_ptr<IOS::HLE::IWII_IPC_HLE_Device> stm =
IOS::HLE::GetDeviceByName("/dev/stm/eventhook");
auto stm = IOS::HLE::GetDeviceByName("/dev/stm/eventhook");
if (stm)
std::static_pointer_cast<IOS::HLE::CWII_IPC_HLE_Device_stm_eventhook>(stm)->ResetButton();
std::static_pointer_cast<IOS::HLE::Device::STMEventHook>(stm)->ResetButton();
}
}
@@ -223,10 +222,9 @@ static void IOSNotifyPowerButtonCallback(u64 userdata, s64 cyclesLate)
{
if (SConfig::GetInstance().bWii)
{
std::shared_ptr<IOS::HLE::IWII_IPC_HLE_Device> stm =
IOS::HLE::GetDeviceByName("/dev/stm/eventhook");
auto stm = IOS::HLE::GetDeviceByName("/dev/stm/eventhook");
if (stm)
std::static_pointer_cast<IOS::HLE::CWII_IPC_HLE_Device_stm_eventhook>(stm)->PowerButton();
std::static_pointer_cast<IOS::HLE::Device::STMEventHook>(stm)->PowerButton();
}
}
+2 -2
View File
@@ -34,13 +34,13 @@ IPC_HLE_PERIOD: For the Wii Remote this is the call schedule:
// If the AclFrameQue is empty this will call Wiimote_Update() and make it send
the current input status to the game. I'm not sure if this occurs approximately
once every frame or if the frequency is not exactly tied to rendered frames
CWII_IPC_HLE_Device_usb_oh1_57e_305::Update()
IOS::HLE::Device::BluetoothEmu::Update()
PluginWiimote::Wiimote_Update()
// This is also a device updated by IOS::HLE::Update() but it doesn't
seem to ultimately call PluginWiimote::Wiimote_Update(). However it can be called
by the /dev/usb/oh1 device if the AclFrameQue is empty.
CWII_IPC_HLE_WiiMote::Update()
IOS::HLE::WiimoteDevice::Update()
*/
#include "Core/HW/SystemTimers.h"
+12 -14
View File
@@ -21,22 +21,19 @@ namespace IOS
{
namespace HLE
{
CWII_IPC_HLE_Device_di::CWII_IPC_HLE_Device_di(u32 _DeviceID, const std::string& _rDeviceName)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
namespace Device
{
DI::DI(u32 device_id, const std::string& device_name) : Device(device_id, device_name)
{
}
CWII_IPC_HLE_Device_di::~CWII_IPC_HLE_Device_di()
{
}
void CWII_IPC_HLE_Device_di::DoState(PointerWrap& p)
void DI::DoState(PointerWrap& p)
{
DoStateShared(p);
p.Do(m_commands_to_execute);
}
IPCCommandResult CWII_IPC_HLE_Device_di::IOCtl(const IOSIOCtlRequest& request)
IPCCommandResult DI::IOCtl(const IOSIOCtlRequest& request)
{
// DI IOCtls are handled in a special way by Dolphin
// compared to other WII_IPC_HLE functions.
@@ -50,12 +47,12 @@ IPCCommandResult CWII_IPC_HLE_Device_di::IOCtl(const IOSIOCtlRequest& request)
if (ready_to_execute)
StartIOCtl(request);
// DVDInterface handles the timing and we handle the reply,
// so WII_IPC_HLE shouldn't handle anything.
// DVDInterface handles the timing and will call FinishIOCtl after the command
// has been executed to reply to the request, so we shouldn't reply here.
return GetNoReply();
}
void CWII_IPC_HLE_Device_di::StartIOCtl(const IOSIOCtlRequest& request)
void DI::StartIOCtl(const IOSIOCtlRequest& request)
{
const u32 command_0 = Memory::Read_U32(request.buffer_in);
const u32 command_1 = Memory::Read_U32(request.buffer_in + 4);
@@ -67,11 +64,11 @@ void CWII_IPC_HLE_Device_di::StartIOCtl(const IOSIOCtlRequest& request)
request.buffer_out_size, true);
}
void CWII_IPC_HLE_Device_di::FinishIOCtl(DVDInterface::DIInterruptType interrupt_type)
void DI::FinishIOCtl(DVDInterface::DIInterruptType interrupt_type)
{
if (m_commands_to_execute.empty())
{
PanicAlert("WII_IPC_HLE_Device_DI: There is no command to execute!");
PanicAlert("IOS::HLE::Device::DI: There is no command to execute!");
return;
}
@@ -89,7 +86,7 @@ void CWII_IPC_HLE_Device_di::FinishIOCtl(DVDInterface::DIInterruptType interrupt
}
}
IPCCommandResult CWII_IPC_HLE_Device_di::IOCtlV(const IOSIOCtlVRequest& request)
IPCCommandResult DI::IOCtlV(const IOSIOCtlVRequest& request)
{
for (const auto& vector : request.io_vectors)
Memory::Memset(vector.address, 0, vector.size);
@@ -121,5 +118,6 @@ IPCCommandResult CWII_IPC_HLE_Device_di::IOCtlV(const IOSIOCtlVRequest& request)
}
return GetDefaultReply(return_value);
}
} // namespace Device
} // namespace HLE
} // namespace IOS
+5 -4
View File
@@ -22,12 +22,12 @@ namespace IOS
{
namespace HLE
{
class CWII_IPC_HLE_Device_di : public IWII_IPC_HLE_Device
namespace Device
{
class DI : public Device
{
public:
CWII_IPC_HLE_Device_di(u32 _DeviceID, const std::string& _rDeviceName);
virtual ~CWII_IPC_HLE_Device_di();
DI(u32 device_id, const std::string& device_name);
void DoState(PointerWrap& p) override;
@@ -41,5 +41,6 @@ private:
std::deque<u32> m_commands_to_execute;
};
} // namespace Device
} // namespace HLE
} // namespace IOS
+11 -9
View File
@@ -121,19 +121,20 @@ void IOSIOCtlVRequest::DumpUnknown(const std::string& description, LogTypes::LOG
Dump("Unknown IOCtlV - " + description, type, level);
}
IWII_IPC_HLE_Device::IWII_IPC_HLE_Device(const u32 device_id, const std::string& device_name,
const DeviceType type)
namespace Device
{
Device::Device(const u32 device_id, const std::string& device_name, const DeviceType type)
: m_name(device_name), m_device_id(device_id), m_device_type(type)
{
}
void IWII_IPC_HLE_Device::DoState(PointerWrap& p)
void Device::DoState(PointerWrap& p)
{
DoStateShared(p);
p.Do(m_is_active);
}
void IWII_IPC_HLE_Device::DoStateShared(PointerWrap& p)
void Device::DoStateShared(PointerWrap& p)
{
p.Do(m_name);
p.Do(m_device_id);
@@ -141,18 +142,18 @@ void IWII_IPC_HLE_Device::DoStateShared(PointerWrap& p)
p.Do(m_is_active);
}
IOSReturnCode IWII_IPC_HLE_Device::Open(const IOSOpenRequest& request)
IOSReturnCode Device::Open(const IOSOpenRequest& request)
{
m_is_active = true;
return IPC_SUCCESS;
}
void IWII_IPC_HLE_Device::Close()
void Device::Close()
{
m_is_active = false;
}
IPCCommandResult IWII_IPC_HLE_Device::Unsupported(const IOSRequest& request)
IPCCommandResult Device::Unsupported(const IOSRequest& request)
{
static std::map<IPCCommandType, std::string> names = {{{IPC_CMD_READ, "Read"},
{IPC_CMD_WRITE, "Write"},
@@ -164,16 +165,17 @@ IPCCommandResult IWII_IPC_HLE_Device::Unsupported(const IOSRequest& request)
}
// Returns an IPCCommandResult for a reply that takes 250 us (arbitrarily chosen value)
IPCCommandResult IWII_IPC_HLE_Device::GetDefaultReply(const s32 return_value)
IPCCommandResult Device::GetDefaultReply(const s32 return_value)
{
return {return_value, true, SystemTimers::GetTicksPerSecond() / 4000};
}
// Returns an IPCCommandResult with no reply. Useful for async commands that will generate a reply
// later. This takes no return value because it won't be used.
IPCCommandResult IWII_IPC_HLE_Device::GetNoReply()
IPCCommandResult Device::GetNoReply()
{
return {IPC_SUCCESS, false, 0};
}
} // namespace Device
} // namespace HLE
} // namespace IOS
+8 -5
View File
@@ -128,7 +128,9 @@ struct IOSIOCtlVRequest final : IOSRequest
LogTypes::LOG_LEVELS level = LogTypes::LERROR) const;
};
class IWII_IPC_HLE_Device
namespace Device
{
class Device
{
public:
enum class DeviceType : u32
@@ -137,10 +139,9 @@ public:
FileIO, // FileIO devices which are created dynamically.
};
IWII_IPC_HLE_Device(u32 device_id, const std::string& device_name,
DeviceType type = DeviceType::Static);
Device(u32 device_id, const std::string& device_name, DeviceType type = DeviceType::Static);
virtual ~IWII_IPC_HLE_Device() = default;
virtual ~Device() = default;
// Release any resources which might interfere with savestating.
virtual void PrepareForState(PointerWrap::Mode mode) {}
virtual void DoState(PointerWrap& p);
@@ -148,7 +149,8 @@ public:
const std::string& GetDeviceName() const { return m_name; }
u32 GetDeviceID() const { return m_device_id; }
// Replies to Open and Close requests are sent by WII_IPC_HLE, not by the devices themselves.
// Replies to Open and Close requests are sent by the IPC request handler (HandleCommand),
// not by the devices themselves.
virtual IOSReturnCode Open(const IOSOpenRequest& request);
virtual void Close();
virtual IPCCommandResult Seek(const IOSSeekRequest& seek) { return Unsupported(seek); }
@@ -172,5 +174,6 @@ protected:
private:
IPCCommandResult Unsupported(const IOSRequest& request);
};
} // namespace Device
} // namespace HLE
} // namespace IOS
+8 -6
View File
@@ -9,34 +9,36 @@ namespace IOS
{
namespace HLE
{
CWII_IPC_HLE_Device_stub::CWII_IPC_HLE_Device_stub(u32 device_id, const std::string& device_name)
: IWII_IPC_HLE_Device(device_id, device_name)
namespace Device
{
Stub::Stub(u32 device_id, const std::string& device_name) : Device(device_id, device_name)
{
}
IOSReturnCode CWII_IPC_HLE_Device_stub::Open(const IOSOpenRequest& request)
IOSReturnCode Stub::Open(const IOSOpenRequest& request)
{
WARN_LOG(WII_IPC_HLE, "%s faking Open()", m_name.c_str());
m_is_active = true;
return IPC_SUCCESS;
}
void CWII_IPC_HLE_Device_stub::Close()
void Stub::Close()
{
WARN_LOG(WII_IPC_HLE, "%s faking Close()", m_name.c_str());
m_is_active = false;
}
IPCCommandResult CWII_IPC_HLE_Device_stub::IOCtl(const IOSIOCtlRequest& request)
IPCCommandResult Stub::IOCtl(const IOSIOCtlRequest& request)
{
WARN_LOG(WII_IPC_HLE, "%s faking IOCtl()", m_name.c_str());
return GetDefaultReply(IPC_SUCCESS);
}
IPCCommandResult CWII_IPC_HLE_Device_stub::IOCtlV(const IOSIOCtlVRequest& request)
IPCCommandResult Stub::IOCtlV(const IOSIOCtlVRequest& request)
{
WARN_LOG(WII_IPC_HLE, "%s faking IOCtlV()", m_name.c_str());
return GetDefaultReply(IPC_SUCCESS);
}
} // namespace Device
} // namespace HLE
} // namespace IOS
+5 -2
View File
@@ -14,15 +14,18 @@ namespace IOS
{
namespace HLE
{
class CWII_IPC_HLE_Device_stub : public IWII_IPC_HLE_Device
namespace Device
{
class Stub final : public Device
{
public:
CWII_IPC_HLE_Device_stub(u32 device_id, const std::string& device_name);
Stub(u32 device_id, const std::string& device_name);
IOSReturnCode Open(const IOSOpenRequest& request) override;
void Close() override;
IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override;
IPCCommandResult IOCtlV(const IOSIOCtlVRequest& request) override;
};
} // namespace Device
} // namespace HLE
} // namespace IOS
+20 -19
View File
@@ -71,10 +71,11 @@ namespace IOS
{
namespace HLE
{
std::string CWII_IPC_HLE_Device_es::m_ContentFile;
namespace Device
{
std::string ES::m_ContentFile;
CWII_IPC_HLE_Device_es::CWII_IPC_HLE_Device_es(u32 device_id, const std::string& device_name)
: IWII_IPC_HLE_Device(device_id, device_name)
ES::ES(u32 device_id, const std::string& device_name) : Device(device_id, device_name)
{
}
@@ -87,7 +88,7 @@ static u8 key_empty[0x10] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
// default key table
u8* CWII_IPC_HLE_Device_es::keyTable[11] = {
u8* ES::keyTable[11] = {
key_ecc, // ECC Private Key
key_empty, // Console ID
key_empty, // NAND AES Key
@@ -101,13 +102,12 @@ u8* CWII_IPC_HLE_Device_es::keyTable[11] = {
key_empty, // Unknown
};
void CWII_IPC_HLE_Device_es::LoadWAD(const std::string& _rContentFile)
void ES::LoadWAD(const std::string& _rContentFile)
{
m_ContentFile = _rContentFile;
}
void CWII_IPC_HLE_Device_es::DecryptContent(u32 key_index, u8* iv, u8* input, u32 size, u8* new_iv,
u8* output)
void ES::DecryptContent(u32 key_index, u8* iv, u8* input, u32 size, u8* new_iv, u8* output)
{
mbedtls_aes_context AES_ctx;
mbedtls_aes_setkey_dec(&AES_ctx, keyTable[key_index], 128);
@@ -115,7 +115,7 @@ void CWII_IPC_HLE_Device_es::DecryptContent(u32 key_index, u8* iv, u8* input, u3
mbedtls_aes_crypt_cbc(&AES_ctx, MBEDTLS_AES_DECRYPT, size, new_iv, input, output);
}
void CWII_IPC_HLE_Device_es::OpenInternal()
void ES::OpenInternal()
{
auto& contentLoader = DiscIO::CNANDContentManager::Access().GetNANDLoader(m_ContentFile);
@@ -144,9 +144,9 @@ void CWII_IPC_HLE_Device_es::OpenInternal()
INFO_LOG(WII_IPC_ES, "Set default title to %08x/%08x", (u32)(m_TitleID >> 32), (u32)m_TitleID);
}
void CWII_IPC_HLE_Device_es::DoState(PointerWrap& p)
void ES::DoState(PointerWrap& p)
{
IWII_IPC_HLE_Device::DoState(p);
Device::DoState(p);
p.Do(m_ContentFile);
OpenInternal();
p.Do(m_AccessIdentID);
@@ -195,16 +195,16 @@ void CWII_IPC_HLE_Device_es::DoState(PointerWrap& p)
}
}
IOSReturnCode CWII_IPC_HLE_Device_es::Open(const IOSOpenRequest& request)
IOSReturnCode ES::Open(const IOSOpenRequest& request)
{
OpenInternal();
if (m_is_active)
INFO_LOG(WII_IPC_ES, "Device was re-opened.");
return IWII_IPC_HLE_Device::Open(request);
return Device::Open(request);
}
void CWII_IPC_HLE_Device_es::Close()
void ES::Close()
{
m_ContentAccessMap.clear();
m_TitleIDs.clear();
@@ -217,7 +217,7 @@ void CWII_IPC_HLE_Device_es::Close()
DiscIO::CNANDContentManager::Access().ClearCache();
}
u32 CWII_IPC_HLE_Device_es::OpenTitleContent(u32 CFD, u64 TitleID, u16 Index)
u32 ES::OpenTitleContent(u32 CFD, u64 TitleID, u16 Index)
{
const DiscIO::CNANDContentLoader& Loader = AccessContentDevice(TitleID);
@@ -246,7 +246,7 @@ u32 CWII_IPC_HLE_Device_es::OpenTitleContent(u32 CFD, u64 TitleID, u16 Index)
return CFD;
}
IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request)
IPCCommandResult ES::IOCtlV(const IOSIOCtlVRequest& request)
{
DEBUG_LOG(WII_IPC_ES, "%s (0x%x)", GetDeviceName().c_str(), request.request);
// Clear the IO buffers. Note that this is unsafe for other ioctlvs.
@@ -1113,7 +1113,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request)
bool* wiiMoteConnected = new bool[MAX_BBMOTES];
if (!SConfig::GetInstance().m_bt_passthrough_enabled)
{
CWII_IPC_HLE_Device_usb_oh1_57e_305_emu* s_Usb = GetUsbPointer();
BluetoothEmu* s_Usb = GetUsbPointer();
for (unsigned int i = 0; i < MAX_BBMOTES; i++)
wiiMoteConnected[i] = s_Usb->m_WiiMotes[i].IsConnected();
}
@@ -1123,7 +1123,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request)
if (!SConfig::GetInstance().m_bt_passthrough_enabled)
{
CWII_IPC_HLE_Device_usb_oh1_57e_305_emu* s_Usb = GetUsbPointer();
BluetoothEmu* s_Usb = GetUsbPointer();
for (unsigned int i = 0; i < MAX_BBMOTES; i++)
{
if (wiiMoteConnected[i])
@@ -1237,7 +1237,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request)
return GetDefaultReply(IPC_SUCCESS);
}
const DiscIO::CNANDContentLoader& CWII_IPC_HLE_Device_es::AccessContentDevice(u64 title_id)
const DiscIO::CNANDContentLoader& ES::AccessContentDevice(u64 title_id)
{
// for WADs, the passed title id and the stored title id match; along with m_ContentFile being set
// to the
@@ -1251,7 +1251,7 @@ const DiscIO::CNANDContentLoader& CWII_IPC_HLE_Device_es::AccessContentDevice(u6
return DiscIO::CNANDContentManager::Access().GetNANDLoader(title_id, Common::FROM_SESSION_ROOT);
}
u32 CWII_IPC_HLE_Device_es::ES_DIVerify(const std::vector<u8>& tmd)
u32 ES::ES_DIVerify(const std::vector<u8>& tmd)
{
u64 title_id = 0xDEADBEEFDEADBEEFull;
u64 tmd_title_id = Common::swap64(&tmd[0x18C]);
@@ -1323,5 +1323,6 @@ u32 CWII_IPC_HLE_Device_es::ES_DIVerify(const std::vector<u8>& tmd)
DiscIO::CNANDContentManager::Access().ClearCache();
return 0;
}
} // namespace Device
} // namespace HLE
} // namespace IOS
+5 -2
View File
@@ -26,10 +26,12 @@ namespace IOS
{
namespace HLE
{
class CWII_IPC_HLE_Device_es : public IWII_IPC_HLE_Device
namespace Device
{
class ES : public Device
{
public:
CWII_IPC_HLE_Device_es(u32 _DeviceID, const std::string& _rDeviceName);
ES(u32 device_id, const std::string& device_name);
void LoadWAD(const std::string& _rContentFile);
@@ -166,5 +168,6 @@ private:
u8 padding[0x3c];
};
};
} // namespace Device
} // namespace HLE
} // namespace IOS
+12 -10
View File
@@ -31,19 +31,20 @@ static bool IsValidWiiPath(const std::string& path)
return path.compare(0, 1, "/") == 0;
}
CWII_IPC_HLE_Device_fs::CWII_IPC_HLE_Device_fs(u32 _DeviceID, const std::string& _rDeviceName)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
namespace Device
{
FS::FS(u32 device_id, const std::string& device_name) : Device(device_id, device_name)
{
}
// ~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 s32 return_value) const
IPCCommandResult FS::GetFSReply(const s32 return_value) const
{
return {return_value, true, SystemTimers::GetTicksPerSecond() / 500};
}
IOSReturnCode CWII_IPC_HLE_Device_fs::Open(const IOSOpenRequest& request)
IOSReturnCode FS::Open(const IOSOpenRequest& request)
{
// clear tmp folder
{
@@ -71,7 +72,7 @@ static u64 ComputeTotalFileSize(const File::FSTEntry& parentEntry)
return sizeOfFiles;
}
IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(const IOSIOCtlVRequest& request)
IPCCommandResult FS::IOCtlV(const IOSIOCtlVRequest& request)
{
s32 return_value = IPC_SUCCESS;
switch (request.request)
@@ -231,14 +232,14 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(const IOSIOCtlVRequest& request)
return GetFSReply(return_value);
}
IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtl(const IOSIOCtlRequest& request)
IPCCommandResult FS::IOCtl(const IOSIOCtlRequest& request)
{
Memory::Memset(request.buffer_out, 0, request.buffer_out_size);
const s32 return_value = ExecuteCommand(request);
return GetFSReply(return_value);
}
s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(const IOSIOCtlRequest& request)
s32 FS::ExecuteCommand(const IOSIOCtlRequest& request)
{
switch (request.request)
{
@@ -522,8 +523,8 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(const IOSIOCtlRequest& request)
bool Result = File::CreateEmptyFile(Filename);
if (!Result)
{
ERROR_LOG(WII_IPC_FILEIO, "CWII_IPC_HLE_Device_fs: couldn't create new file");
PanicAlert("CWII_IPC_HLE_Device_fs: couldn't create new file");
ERROR_LOG(WII_IPC_FILEIO, "FS: couldn't create new file");
PanicAlert("FS: couldn't create new file");
return FS_EINVAL;
}
@@ -544,7 +545,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(const IOSIOCtlRequest& request)
return FS_EINVAL;
}
void CWII_IPC_HLE_Device_fs::DoState(PointerWrap& p)
void FS::DoState(PointerWrap& p)
{
DoStateShared(p);
@@ -638,5 +639,6 @@ void CWII_IPC_HLE_Device_fs::DoState(PointerWrap& p)
p.Do(type);
}
}
} // namespace Device
} // namespace HLE
} // namespace IOS
+5 -2
View File
@@ -27,10 +27,12 @@ struct NANDStat
u32 Used_Inodes;
};
class CWII_IPC_HLE_Device_fs : public IWII_IPC_HLE_Device
namespace Device
{
class FS : public Device
{
public:
CWII_IPC_HLE_Device_fs(u32 _DeviceID, const std::string& _rDeviceName);
FS(u32 device_id, const std::string& device_name);
void DoState(PointerWrap& p) override;
@@ -56,5 +58,6 @@ private:
IPCCommandResult GetFSReply(s32 return_value) const;
s32 ExecuteCommand(const IOSIOCtlRequest& request);
};
} // namespace Device
} // namespace HLE
} // namespace IOS
+15 -13
View File
@@ -69,13 +69,14 @@ void HLE_IPC_CreateVirtualFATFilesystem()
}
}
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, DeviceType::FileIO)
namespace Device
{
FileIO::FileIO(u32 device_id, const std::string& device_name)
: Device(device_id, device_name, DeviceType::FileIO)
{
}
void CWII_IPC_HLE_Device_FileIO::Close()
void FileIO::Close()
{
INFO_LOG(WII_IPC_FILEIO, "FileIO: Close %s (DeviceID=%08x)", m_name.c_str(), m_device_id);
m_Mode = 0;
@@ -87,7 +88,7 @@ void CWII_IPC_HLE_Device_FileIO::Close()
m_is_active = false;
}
IOSReturnCode CWII_IPC_HLE_Device_FileIO::Open(const IOSOpenRequest& request)
IOSReturnCode FileIO::Open(const IOSOpenRequest& request)
{
m_Mode = request.flags;
@@ -112,7 +113,7 @@ IOSReturnCode CWII_IPC_HLE_Device_FileIO::Open(const IOSOpenRequest& request)
}
// This isn't theadsafe, but it's only called from the CPU thread.
void CWII_IPC_HLE_Device_FileIO::OpenFile()
void FileIO::OpenFile()
{
// On the wii, all file operations are strongly ordered.
// If a game opens the same file twice (or 8 times, looking at you PokePark Wii)
@@ -155,7 +156,7 @@ void CWII_IPC_HLE_Device_FileIO::OpenFile()
}
}
IPCCommandResult CWII_IPC_HLE_Device_FileIO::Seek(const IOSSeekRequest& request)
IPCCommandResult FileIO::Seek(const IOSSeekRequest& request)
{
u32 return_value = FS_EINVAL;
@@ -201,7 +202,7 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Seek(const IOSSeekRequest& request)
default:
{
PanicAlert("CWII_IPC_HLE_Device_FileIO Unsupported seek mode %i", request.mode);
PanicAlert("FileIO Unsupported seek mode %i", request.mode);
return_value = FS_EINVAL;
break;
}
@@ -214,7 +215,7 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Seek(const IOSSeekRequest& request)
return GetDefaultReply(return_value);
}
IPCCommandResult CWII_IPC_HLE_Device_FileIO::Read(const IOSReadWriteRequest& request)
IPCCommandResult FileIO::Read(const IOSReadWriteRequest& request)
{
s32 return_value = FS_EACCESS;
if (m_file->IsOpen())
@@ -253,7 +254,7 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Read(const IOSReadWriteRequest& req
return GetDefaultReply(return_value);
}
IPCCommandResult CWII_IPC_HLE_Device_FileIO::Write(const IOSReadWriteRequest& request)
IPCCommandResult FileIO::Write(const IOSReadWriteRequest& request)
{
s32 return_value = FS_EACCESS;
if (m_file->IsOpen())
@@ -288,7 +289,7 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Write(const IOSReadWriteRequest& re
return GetDefaultReply(return_value);
}
IPCCommandResult CWII_IPC_HLE_Device_FileIO::IOCtl(const IOSIOCtlRequest& request)
IPCCommandResult FileIO::IOCtl(const IOSIOCtlRequest& request)
{
DEBUG_LOG(WII_IPC_FILEIO, "FileIO: IOCtl (Device=%s)", m_name.c_str());
s32 return_value = IPC_SUCCESS;
@@ -318,14 +319,14 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::IOCtl(const IOSIOCtlRequest& reques
return GetDefaultReply(return_value);
}
void CWII_IPC_HLE_Device_FileIO::PrepareForState(PointerWrap::Mode mode)
void FileIO::PrepareForState(PointerWrap::Mode mode)
{
// Temporally close the file, to prevent any issues with the savestating of /tmp
// it can be opened again with another call to OpenFile()
m_file.reset();
}
void CWII_IPC_HLE_Device_FileIO::DoState(PointerWrap& p)
void FileIO::DoState(PointerWrap& p)
{
DoStateShared(p);
@@ -338,5 +339,6 @@ void CWII_IPC_HLE_Device_FileIO::DoState(PointerWrap& p)
// Open it again
OpenFile();
}
} // namespace Device
} // namespace HLE
} // namespace IOS
+5 -2
View File
@@ -25,10 +25,12 @@ namespace HLE
std::string HLE_IPC_BuildFilename(const std::string& wii_path);
void HLE_IPC_CreateVirtualFATFilesystem();
class CWII_IPC_HLE_Device_FileIO : public IWII_IPC_HLE_Device
namespace Device
{
class FileIO : public Device
{
public:
CWII_IPC_HLE_Device_FileIO(u32 _DeviceID, const std::string& _rDeviceName);
FileIO(u32 device_id, const std::string& device_name);
void Close() override;
IOSReturnCode Open(const IOSOpenRequest& request) override;
@@ -74,5 +76,6 @@ private:
std::string m_filepath;
std::shared_ptr<File::IOFile> m_file;
};
} // namespace Device
} // namespace HLE
} // namespace IOS
+45 -46
View File
@@ -64,14 +64,14 @@ namespace IOS
{
namespace HLE
{
static std::map<u32, std::shared_ptr<IWII_IPC_HLE_Device>> s_device_map;
static std::map<u32, std::shared_ptr<Device::Device>> s_device_map;
static std::mutex s_device_map_mutex;
// STATE_TO_SAVE
constexpr u8 IPC_MAX_FDS = 0x18;
constexpr u8 ES_MAX_COUNT = 3;
static std::shared_ptr<IWII_IPC_HLE_Device> s_fdmap[IPC_MAX_FDS];
static std::shared_ptr<CWII_IPC_HLE_Device_es> s_es_handles[ES_MAX_COUNT];
static std::shared_ptr<Device::Device> s_fdmap[IPC_MAX_FDS];
static std::shared_ptr<Device::ES> s_es_handles[ES_MAX_COUNT];
using IPCMsgQueue = std::deque<u32>;
static IPCMsgQueue s_request_queue; // ppc -> arm
@@ -104,8 +104,7 @@ static void EnqueueEvent(u64 userdata, s64 cycles_late = 0)
static void SDIO_EventNotify_CPUThread(u64 userdata, s64 cycles_late)
{
auto device =
static_cast<CWII_IPC_HLE_Device_sdio_slot0*>(GetDeviceByName("/dev/sdio/slot0").get());
auto device = static_cast<Device::SDIOSlot0*>(GetDeviceByName("/dev/sdio/slot0").get());
if (device)
device->EventNotify();
}
@@ -116,7 +115,7 @@ template <typename T>
std::shared_ptr<T> AddDevice(const char* device_name)
{
auto device = std::make_shared<T>(num_devices, device_name);
_assert_(device->GetDeviceType() == IWII_IPC_HLE_Device::DeviceType::Static);
_assert_(device->GetDeviceType() == Device::Device::DeviceType::Static);
s_device_map[num_devices] = device;
num_devices++;
return device;
@@ -126,43 +125,43 @@ void Reinit()
{
std::lock_guard<std::mutex> lock(s_device_map_mutex);
_assert_msg_(WII_IPC_HLE, s_device_map.empty(), "Reinit called while already initialized");
CWII_IPC_HLE_Device_es::m_ContentFile = "";
Device::ES::m_ContentFile = "";
num_devices = 0;
// Build hardware devices
if (!SConfig::GetInstance().m_bt_passthrough_enabled)
AddDevice<CWII_IPC_HLE_Device_usb_oh1_57e_305_emu>("/dev/usb/oh1/57e/305");
AddDevice<Device::BluetoothEmu>("/dev/usb/oh1/57e/305");
else
AddDevice<CWII_IPC_HLE_Device_usb_oh1_57e_305_real>("/dev/usb/oh1/57e/305");
AddDevice<Device::BluetoothReal>("/dev/usb/oh1/57e/305");
AddDevice<CWII_IPC_HLE_Device_stm_immediate>("/dev/stm/immediate");
AddDevice<CWII_IPC_HLE_Device_stm_eventhook>("/dev/stm/eventhook");
AddDevice<CWII_IPC_HLE_Device_fs>("/dev/fs");
AddDevice<Device::STMImmediate>("/dev/stm/immediate");
AddDevice<Device::STMEventHook>("/dev/stm/eventhook");
AddDevice<Device::FS>("/dev/fs");
// IOS allows two ES devices at a time
for (auto& es_device : s_es_handles)
es_device = AddDevice<CWII_IPC_HLE_Device_es>("/dev/es");
es_device = AddDevice<Device::ES>("/dev/es");
AddDevice<CWII_IPC_HLE_Device_di>("/dev/di");
AddDevice<CWII_IPC_HLE_Device_net_kd_request>("/dev/net/kd/request");
AddDevice<CWII_IPC_HLE_Device_net_kd_time>("/dev/net/kd/time");
AddDevice<CWII_IPC_HLE_Device_net_ncd_manage>("/dev/net/ncd/manage");
AddDevice<CWII_IPC_HLE_Device_net_wd_command>("/dev/net/wd/command");
AddDevice<CWII_IPC_HLE_Device_net_ip_top>("/dev/net/ip/top");
AddDevice<CWII_IPC_HLE_Device_net_ssl>("/dev/net/ssl");
AddDevice<CWII_IPC_HLE_Device_usb_kbd>("/dev/usb/kbd");
AddDevice<CWII_IPC_HLE_Device_usb_ven>("/dev/usb/ven");
AddDevice<CWII_IPC_HLE_Device_sdio_slot0>("/dev/sdio/slot0");
AddDevice<CWII_IPC_HLE_Device_stub>("/dev/sdio/slot1");
AddDevice<Device::DI>("/dev/di");
AddDevice<Device::NetKDRequest>("/dev/net/kd/request");
AddDevice<Device::NetKDTime>("/dev/net/kd/time");
AddDevice<Device::NetNCDManage>("/dev/net/ncd/manage");
AddDevice<Device::NetWDCommand>("/dev/net/wd/command");
AddDevice<Device::NetIPTop>("/dev/net/ip/top");
AddDevice<Device::NetSSL>("/dev/net/ssl");
AddDevice<Device::USB_KBD>("/dev/usb/kbd");
AddDevice<Device::USB_VEN>("/dev/usb/ven");
AddDevice<Device::SDIOSlot0>("/dev/sdio/slot0");
AddDevice<Device::Stub>("/dev/sdio/slot1");
#if defined(__LIBUSB__)
AddDevice<CWII_IPC_HLE_Device_hid>("/dev/usb/hid");
AddDevice<Device::USB_HIDv4>("/dev/usb/hid");
#else
AddDevice<CWII_IPC_HLE_Device_stub>("/dev/usb/hid");
AddDevice<Device::Stub>("/dev/usb/hid");
#endif
AddDevice<CWII_IPC_HLE_Device_stub>("/dev/usb/oh1");
AddDevice<CWII_IPC_HLE_Device_usb_wfssrv>("/dev/usb/wfssrv");
AddDevice<CWII_IPC_HLE_Device_wfsi>("/dev/wfsi");
AddDevice<Device::Stub>("/dev/usb/oh1");
AddDevice<Device::WFSSRV>("/dev/usb/wfssrv");
AddDevice<Device::WFSI>("/dev/wfsi");
}
void Init()
@@ -212,7 +211,7 @@ void SetDefaultContentFile(const std::string& file_name)
void ES_DIVerify(const std::vector<u8>& tmd)
{
CWII_IPC_HLE_Device_es::ES_DIVerify(tmd);
Device::ES::ES_DIVerify(tmd);
}
void SDIO_EventNotify()
@@ -236,7 +235,7 @@ static int GetFreeDeviceID()
return -1;
}
std::shared_ptr<IWII_IPC_HLE_Device> GetDeviceByName(const std::string& device_name)
std::shared_ptr<Device::Device> GetDeviceByName(const std::string& device_name)
{
std::lock_guard<std::mutex> lock(s_device_map_mutex);
for (const auto& entry : s_device_map)
@@ -250,7 +249,7 @@ std::shared_ptr<IWII_IPC_HLE_Device> GetDeviceByName(const std::string& device_n
return nullptr;
}
std::shared_ptr<IWII_IPC_HLE_Device> AccessDeviceByID(u32 id)
std::shared_ptr<Device::Device> AccessDeviceByID(u32 id)
{
std::lock_guard<std::mutex> lock(s_device_map_mutex);
if (s_device_map.find(id) != s_device_map.end())
@@ -267,7 +266,7 @@ void DoState(PointerWrap& p)
p.Do(s_reply_queue);
p.Do(s_last_reply_time);
// We need to make sure all file handles are closed so WII_IPC_Devices_fs::DoState can
// We need to make sure all file handles are closed so IOS::HLE::Device::FS::DoState can
// successfully save or re-create /tmp
for (auto& descriptor : s_fdmap)
{
@@ -286,19 +285,19 @@ void DoState(PointerWrap& p)
p.Do(exists);
if (exists)
{
auto device_type = IWII_IPC_HLE_Device::DeviceType::Static;
auto device_type = Device::Device::DeviceType::Static;
p.Do(device_type);
switch (device_type)
{
case IWII_IPC_HLE_Device::DeviceType::Static:
case Device::Device::DeviceType::Static:
{
u32 device_id = 0;
p.Do(device_id);
s_fdmap[i] = AccessDeviceByID(device_id);
break;
}
case IWII_IPC_HLE_Device::DeviceType::FileIO:
s_fdmap[i] = std::make_shared<CWII_IPC_HLE_Device_FileIO>(i, "");
case Device::Device::DeviceType::FileIO:
s_fdmap[i] = std::make_shared<Device::FileIO>(i, "");
s_fdmap[i]->DoState(p);
break;
}
@@ -309,7 +308,7 @@ void DoState(PointerWrap& p)
{
const u32 handle_id = es_device->GetDeviceID();
p.Do(handle_id);
es_device = std::static_pointer_cast<CWII_IPC_HLE_Device_es>(AccessDeviceByID(handle_id));
es_device = std::static_pointer_cast<Device::ES>(AccessDeviceByID(handle_id));
}
}
else
@@ -322,7 +321,7 @@ void DoState(PointerWrap& p)
{
auto device_type = descriptor->GetDeviceType();
p.Do(device_type);
if (device_type == IWII_IPC_HLE_Device::DeviceType::Static)
if (device_type == Device::Device::DeviceType::Static)
{
u32 hwId = descriptor->GetDeviceID();
p.Do(hwId);
@@ -342,7 +341,7 @@ void DoState(PointerWrap& p)
}
}
static std::shared_ptr<IWII_IPC_HLE_Device> GetUnusedESDevice()
static std::shared_ptr<Device::Device> GetUnusedESDevice()
{
const auto iterator = std::find_if(std::begin(s_es_handles), std::end(s_es_handles),
[](const auto& es_device) { return !es_device->IsOpened(); });
@@ -360,7 +359,7 @@ static s32 OpenDevice(const IOSOpenRequest& request)
return FS_EFDEXHAUSTED;
}
std::shared_ptr<IWII_IPC_HLE_Device> device;
std::shared_ptr<Device::Device> device;
if (request.path == "/dev/es")
{
device = GetUnusedESDevice();
@@ -373,7 +372,7 @@ static s32 OpenDevice(const IOSOpenRequest& request)
}
else if (request.path.find('/') == 0)
{
device = std::make_shared<CWII_IPC_HLE_Device_FileIO>(new_fd, request.path);
device = std::make_shared<Device::FileIO>(new_fd, request.path);
}
if (!device)
@@ -395,19 +394,19 @@ static IPCCommandResult HandleCommand(const IOSRequest& request)
{
IOSOpenRequest open_request{request.address};
const s32 new_fd = OpenDevice(open_request);
return IWII_IPC_HLE_Device::GetDefaultReply(new_fd);
return Device::Device::GetDefaultReply(new_fd);
}
const auto device = (request.fd < IPC_MAX_FDS) ? s_fdmap[request.fd] : nullptr;
if (!device)
return IWII_IPC_HLE_Device::GetDefaultReply(IPC_EINVAL);
return Device::Device::GetDefaultReply(IPC_EINVAL);
switch (request.command)
{
case IPC_CMD_CLOSE:
s_fdmap[request.fd].reset();
device->Close();
return IWII_IPC_HLE_Device::GetDefaultReply(IPC_SUCCESS);
return Device::Device::GetDefaultReply(IPC_SUCCESS);
case IPC_CMD_READ:
return device->Read(IOSReadWriteRequest{request.address});
case IPC_CMD_WRITE:
@@ -420,7 +419,7 @@ static IPCCommandResult HandleCommand(const IOSRequest& request)
return device->IOCtlV(IOSIOCtlVRequest{request.address});
default:
_assert_msg_(WII_IPC_HLE, false, "Unexpected command: %x", request.command);
return IWII_IPC_HLE_Device::GetDefaultReply(IPC_EINVAL);
return Device::Device::GetDefaultReply(IPC_EINVAL);
}
}
+7 -3
View File
@@ -18,7 +18,11 @@ namespace IOS
{
namespace HLE
{
class IWII_IPC_HLE_Device;
namespace Device
{
class Device;
}
struct IOSRequest;
struct IPCCommandResult
@@ -62,8 +66,8 @@ void ES_DIVerify(const std::vector<u8>& tmd);
void SDIO_EventNotify();
std::shared_ptr<IWII_IPC_HLE_Device> GetDeviceByName(const std::string& device_name);
std::shared_ptr<IWII_IPC_HLE_Device> AccessDeviceByID(u32 id);
std::shared_ptr<Device::Device> GetDeviceByName(const std::string& device_name);
std::shared_ptr<Device::Device> AccessDeviceByID(u32 id);
// Update
void Update();
+22 -32
View File
@@ -63,20 +63,21 @@ namespace IOS
{
namespace HLE
{
namespace Device
{
// **********************************************************************************
// Handle /dev/net/kd/request requests
CWII_IPC_HLE_Device_net_kd_request::CWII_IPC_HLE_Device_net_kd_request(
u32 _DeviceID, const std::string& _rDeviceName)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
NetKDRequest::NetKDRequest(u32 device_id, const std::string& device_name)
: Device(device_id, device_name)
{
}
CWII_IPC_HLE_Device_net_kd_request::~CWII_IPC_HLE_Device_net_kd_request()
NetKDRequest::~NetKDRequest()
{
WiiSockMan::GetInstance().Clean();
}
IPCCommandResult CWII_IPC_HLE_Device_net_kd_request::IOCtl(const IOSIOCtlRequest& request)
IPCCommandResult NetKDRequest::IOCtl(const IOSIOCtlRequest& request)
{
s32 return_value = 0;
switch (request.request)
@@ -197,7 +198,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_kd_request::IOCtl(const IOSIOCtlRequest
return GetDefaultReply(return_value);
}
u8 CWII_IPC_HLE_Device_net_kd_request::GetAreaCode(const std::string& area) const
u8 NetKDRequest::GetAreaCode(const std::string& area) const
{
static std::map<const std::string, u8> regions = {
{"JPN", 0}, {"USA", 1}, {"EUR", 2}, {"AUS", 2}, {"BRA", 1}, {"TWN", 3}, {"ROC", 3},
@@ -211,7 +212,7 @@ u8 CWII_IPC_HLE_Device_net_kd_request::GetAreaCode(const std::string& area) cons
return 7; // Unknown
}
u8 CWII_IPC_HLE_Device_net_kd_request::GetHardwareModel(const std::string& model) const
u8 NetKDRequest::GetHardwareModel(const std::string& model) const
{
static std::map<const std::string, u8> models = {
{"RVL", MODEL_RVL}, {"RVT", MODEL_RVT}, {"RVV", MODEL_RVV}, {"RVD", MODEL_RVD},
@@ -236,8 +237,8 @@ static inline u64 u64_insert_byte(u64 value, u8 shift, u8 byte)
return (value & ~mask) | inst;
}
s32 CWII_IPC_HLE_Device_net_kd_request::NWC24MakeUserID(u64* nwc24_id, u32 hollywood_id, u16 id_ctr,
u8 hardware_model, u8 area_code)
s32 NetKDRequest::NWC24MakeUserID(u64* nwc24_id, u32 hollywood_id, u16 id_ctr, u8 hardware_model,
u8 area_code)
{
const u8 table2[8] = {0x1, 0x5, 0x0, 0x4, 0x2, 0x3, 0x6, 0x7};
const u8 table1[16] = {0x4, 0xB, 0x7, 0x9, 0xF, 0x1, 0xD, 0x3,
@@ -320,17 +321,12 @@ static void GetMacAddress(u8* mac)
// **********************************************************************************
// Handle /dev/net/ncd/manage requests
CWII_IPC_HLE_Device_net_ncd_manage::CWII_IPC_HLE_Device_net_ncd_manage(
u32 _DeviceID, const std::string& _rDeviceName)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
NetNCDManage::NetNCDManage(u32 device_id, const std::string& device_name)
: Device(device_id, device_name)
{
}
CWII_IPC_HLE_Device_net_ncd_manage::~CWII_IPC_HLE_Device_net_ncd_manage()
{
}
IPCCommandResult CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(const IOSIOCtlVRequest& request)
IPCCommandResult NetNCDManage::IOCtlV(const IOSIOCtlVRequest& request)
{
s32 return_value = IPC_SUCCESS;
u32 common_result = 0;
@@ -398,20 +394,15 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(const IOSIOCtlVReque
// **********************************************************************************
// Handle /dev/net/wd/command requests
CWII_IPC_HLE_Device_net_wd_command::CWII_IPC_HLE_Device_net_wd_command(
u32 DeviceID, const std::string& DeviceName)
: IWII_IPC_HLE_Device(DeviceID, DeviceName)
{
}
CWII_IPC_HLE_Device_net_wd_command::~CWII_IPC_HLE_Device_net_wd_command()
NetWDCommand::NetWDCommand(u32 device_id, const std::string& device_name)
: Device(device_id, device_name)
{
}
// This is just for debugging / playing around.
// There really is no reason to implement wd unless we can bend it such that
// we can talk to the DS.
IPCCommandResult CWII_IPC_HLE_Device_net_wd_command::IOCtlV(const IOSIOCtlVRequest& request)
IPCCommandResult NetWDCommand::IOCtlV(const IOSIOCtlVRequest& request)
{
s32 return_value = IPC_SUCCESS;
@@ -483,9 +474,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_wd_command::IOCtlV(const IOSIOCtlVReque
// **********************************************************************************
// Handle /dev/net/ip/top requests
CWII_IPC_HLE_Device_net_ip_top::CWII_IPC_HLE_Device_net_ip_top(u32 _DeviceID,
const std::string& _rDeviceName)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
NetIPTop::NetIPTop(u32 device_id, const std::string& device_name) : Device(device_id, device_name)
{
#ifdef _WIN32
int ret = WSAStartup(MAKEWORD(2, 2), &InitData);
@@ -493,7 +482,7 @@ CWII_IPC_HLE_Device_net_ip_top::CWII_IPC_HLE_Device_net_ip_top(u32 _DeviceID,
#endif
}
CWII_IPC_HLE_Device_net_ip_top::~CWII_IPC_HLE_Device_net_ip_top()
NetIPTop::~NetIPTop()
{
#ifdef _WIN32
WSACleanup();
@@ -550,7 +539,7 @@ static unsigned int opt_level_mapping[][2] = {{SOL_SOCKET, 0xFFFF}};
static unsigned int opt_name_mapping[][2] = {
{SO_REUSEADDR, 0x4}, {SO_SNDBUF, 0x1001}, {SO_RCVBUF, 0x1002}, {SO_ERROR, 0x1009}};
IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& request)
IPCCommandResult NetIPTop::IOCtl(const IOSIOCtlRequest& request)
{
if (Core::g_want_determinism)
{
@@ -1063,7 +1052,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re
return GetDefaultReply(return_value);
}
IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtlV(const IOSIOCtlVRequest& request)
IPCCommandResult NetIPTop::IOCtlV(const IOSIOCtlVRequest& request)
{
s32 return_value = 0;
@@ -1373,9 +1362,10 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtlV(const IOSIOCtlVRequest&
return GetDefaultReply(return_value);
}
void CWII_IPC_HLE_Device_net_ip_top::Update()
void NetIPTop::Update()
{
WiiSockMan::GetInstance().Update();
}
} // namespace Device
} // namespace HLE
} // namespace IOS
+57 -57
View File
@@ -23,16 +23,58 @@ namespace IOS
{
namespace HLE
{
enum NET_IOCTL
{
IOCTL_SO_ACCEPT = 1,
IOCTL_SO_BIND,
IOCTL_SO_CLOSE,
IOCTL_SO_CONNECT,
IOCTL_SO_FCNTL,
IOCTL_SO_GETPEERNAME,
IOCTL_SO_GETSOCKNAME,
IOCTL_SO_GETSOCKOPT,
IOCTL_SO_SETSOCKOPT,
IOCTL_SO_LISTEN,
IOCTL_SO_POLL,
IOCTLV_SO_RECVFROM,
IOCTLV_SO_SENDTO,
IOCTL_SO_SHUTDOWN,
IOCTL_SO_SOCKET,
IOCTL_SO_GETHOSTID,
IOCTL_SO_GETHOSTBYNAME,
IOCTL_SO_GETHOSTBYADDR,
IOCTLV_SO_GETNAMEINFO,
IOCTL_SO_UNK14,
IOCTL_SO_INETATON,
IOCTL_SO_INETPTON,
IOCTL_SO_INETNTOP,
IOCTLV_SO_GETADDRINFO,
IOCTL_SO_SOCKATMARK,
IOCTLV_SO_UNK1A,
IOCTLV_SO_UNK1B,
IOCTLV_SO_GETINTERFACEOPT,
IOCTLV_SO_SETINTERFACEOPT,
IOCTL_SO_SETINTERFACE,
IOCTL_SO_STARTUP,
IOCTL_SO_ICMPSOCKET = 0x30,
IOCTLV_SO_ICMPPING,
IOCTL_SO_ICMPCANCEL,
IOCTL_SO_ICMPCLOSE
};
// TODO: split this up.
namespace Device
{
//////////////////////////////////////////////////////////////////////////
// KD is the IOS module responsible for implementing WiiConnect24 functionality.
// It can perform HTTPS downloads, send and receive mail via SMTP, and execute a
// JavaScript-like language while the Wii is in standby mode.
class CWII_IPC_HLE_Device_net_kd_request : public IWII_IPC_HLE_Device
class NetKDRequest : public Device
{
public:
CWII_IPC_HLE_Device_net_kd_request(u32 _DeviceID, const std::string& _rDeviceName);
NetKDRequest(u32 device_id, const std::string& device_name);
virtual ~CWII_IPC_HLE_Device_net_kd_request();
virtual ~NetKDRequest();
IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override;
@@ -81,15 +123,15 @@ private:
};
//////////////////////////////////////////////////////////////////////////
class CWII_IPC_HLE_Device_net_kd_time : public IWII_IPC_HLE_Device
class NetKDTime : public Device
{
public:
CWII_IPC_HLE_Device_net_kd_time(u32 _DeviceID, const std::string& _rDeviceName)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName), rtc(), utcdiff()
NetKDTime(u32 device_id, const std::string& device_name)
: Device(device_id, device_name), rtc(), utcdiff()
{
}
virtual ~CWII_IPC_HLE_Device_net_kd_time() {}
virtual ~NetKDTime() {}
IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override
{
s32 result = 0;
@@ -159,52 +201,13 @@ private:
}
};
enum NET_IOCTL
{
IOCTL_SO_ACCEPT = 1,
IOCTL_SO_BIND,
IOCTL_SO_CLOSE,
IOCTL_SO_CONNECT,
IOCTL_SO_FCNTL,
IOCTL_SO_GETPEERNAME,
IOCTL_SO_GETSOCKNAME,
IOCTL_SO_GETSOCKOPT,
IOCTL_SO_SETSOCKOPT,
IOCTL_SO_LISTEN,
IOCTL_SO_POLL,
IOCTLV_SO_RECVFROM,
IOCTLV_SO_SENDTO,
IOCTL_SO_SHUTDOWN,
IOCTL_SO_SOCKET,
IOCTL_SO_GETHOSTID,
IOCTL_SO_GETHOSTBYNAME,
IOCTL_SO_GETHOSTBYADDR,
IOCTLV_SO_GETNAMEINFO,
IOCTL_SO_UNK14,
IOCTL_SO_INETATON,
IOCTL_SO_INETPTON,
IOCTL_SO_INETNTOP,
IOCTLV_SO_GETADDRINFO,
IOCTL_SO_SOCKATMARK,
IOCTLV_SO_UNK1A,
IOCTLV_SO_UNK1B,
IOCTLV_SO_GETINTERFACEOPT,
IOCTLV_SO_SETINTERFACEOPT,
IOCTL_SO_SETINTERFACE,
IOCTL_SO_STARTUP,
IOCTL_SO_ICMPSOCKET = 0x30,
IOCTLV_SO_ICMPPING,
IOCTL_SO_ICMPCANCEL,
IOCTL_SO_ICMPCLOSE
};
//////////////////////////////////////////////////////////////////////////
class CWII_IPC_HLE_Device_net_ip_top : public IWII_IPC_HLE_Device
class NetIPTop : public Device
{
public:
CWII_IPC_HLE_Device_net_ip_top(u32 _DeviceID, const std::string& _rDeviceName);
NetIPTop(u32 device_id, const std::string& device_name);
virtual ~CWII_IPC_HLE_Device_net_ip_top();
virtual ~NetIPTop();
IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override;
IPCCommandResult IOCtlV(const IOSIOCtlVRequest& request) override;
@@ -219,12 +222,10 @@ private:
// **********************************************************************************
// Interface for reading and changing network configuration (probably some other stuff as well)
class CWII_IPC_HLE_Device_net_ncd_manage : public IWII_IPC_HLE_Device
class NetNCDManage : public Device
{
public:
CWII_IPC_HLE_Device_net_ncd_manage(u32 _DeviceID, const std::string& _rDeviceName);
virtual ~CWII_IPC_HLE_Device_net_ncd_manage();
NetNCDManage(u32 device_id, const std::string& device_name);
IPCCommandResult IOCtlV(const IOSIOCtlVRequest& request) override;
@@ -245,12 +246,10 @@ private:
};
//////////////////////////////////////////////////////////////////////////
class CWII_IPC_HLE_Device_net_wd_command : public IWII_IPC_HLE_Device
class NetWDCommand : public Device
{
public:
CWII_IPC_HLE_Device_net_wd_command(u32 DeviceID, const std::string& DeviceName);
virtual ~CWII_IPC_HLE_Device_net_wd_command();
NetWDCommand(u32 device_id, const std::string& device_name);
IPCCommandResult IOCtlV(const IOSIOCtlVRequest& request) override;
@@ -335,5 +334,6 @@ private:
};
#pragma pack(pop)
};
} // namespace Device
} // namespace HLE
} // namespace IOS
+9 -8
View File
@@ -20,7 +20,9 @@ namespace IOS
{
namespace HLE
{
WII_SSL CWII_IPC_HLE_Device_net_ssl::_SSL[NET_SSL_MAXINSTANCES];
namespace Device
{
WII_SSL NetSSL::_SSL[NET_SSL_MAXINSTANCES];
static constexpr mbedtls_x509_crt_profile mbedtls_x509_crt_profile_wii = {
/* Hashes from SHA-1 and above */
@@ -32,9 +34,7 @@ static constexpr mbedtls_x509_crt_profile mbedtls_x509_crt_profile_wii = {
0, /* No RSA min key size */
};
CWII_IPC_HLE_Device_net_ssl::CWII_IPC_HLE_Device_net_ssl(u32 _DeviceID,
const std::string& _rDeviceName)
: IWII_IPC_HLE_Device(_DeviceID, _rDeviceName)
NetSSL::NetSSL(u32 device_id, const std::string& device_name) : Device(device_id, device_name)
{
for (WII_SSL& ssl : _SSL)
{
@@ -42,7 +42,7 @@ CWII_IPC_HLE_Device_net_ssl::CWII_IPC_HLE_Device_net_ssl(u32 _DeviceID,
}
}
CWII_IPC_HLE_Device_net_ssl::~CWII_IPC_HLE_Device_net_ssl()
NetSSL::~NetSSL()
{
// Cleanup sessions
for (WII_SSL& ssl : _SSL)
@@ -67,7 +67,7 @@ CWII_IPC_HLE_Device_net_ssl::~CWII_IPC_HLE_Device_net_ssl()
}
}
int CWII_IPC_HLE_Device_net_ssl::GetSSLFreeID() const
int NetSSL::GetSSLFreeID() const
{
for (int i = 0; i < NET_SSL_MAXINSTANCES; i++)
{
@@ -79,13 +79,13 @@ int CWII_IPC_HLE_Device_net_ssl::GetSSLFreeID() const
return 0;
}
IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtl(const IOSIOCtlRequest& request)
IPCCommandResult NetSSL::IOCtl(const IOSIOCtlRequest& request)
{
request.Log(GetDeviceName(), LogTypes::WII_IPC_SSL, LogTypes::LINFO);
return GetDefaultReply(IPC_SUCCESS);
}
IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(const IOSIOCtlVRequest& request)
IPCCommandResult NetSSL::IOCtlV(const IOSIOCtlVRequest& request)
{
u32 BufferIn = 0, BufferIn2 = 0, BufferIn3 = 0;
u32 BufferInSize = 0, BufferInSize2 = 0, BufferInSize3 = 0;
@@ -498,5 +498,6 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(const IOSIOCtlVRequest& req
// SSL return codes are written to BufferIn
return GetDefaultReply(IPC_SUCCESS);
}
} // namespace Device
} // namespace HLE
} // namespace IOS

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