diff --git a/Source/Core/Common/Logging/Log.h b/Source/Core/Common/Logging/Log.h index 165699ff1b..b225fe8dbd 100644 --- a/Source/Core/Common/Logging/Log.h +++ b/Source/Core/Common/Logging/Log.h @@ -27,6 +27,17 @@ enum LOG_TYPE GDB_STUB, GPFIFO, HOST_GPU, + IOS, + IOS_DI, + IOS_ES, + IOS_FILEIO, + IOS_HID, + IOS_NET, + IOS_SD, + IOS_SSL, + IOS_STM, + IOS_WC24, + IOS_WIIMOTE, MASTER_LOG, MEMMAP, MEMCARD_MANAGER, @@ -42,17 +53,6 @@ enum LOG_TYPE VIDEO, VIDEOINTERFACE, WII_IPC, - WII_IPC_DVD, - WII_IPC_ES, - WII_IPC_FILEIO, - WII_IPC_HID, - WII_IPC_HLE, - WII_IPC_NET, - WII_IPC_SD, - WII_IPC_SSL, - WII_IPC_STM, - WII_IPC_WC24, - WII_IPC_WIIMOTE, WIIMOTE, NUMBER_OF_LOGS // Must be last diff --git a/Source/Core/Common/Logging/LogManager.cpp b/Source/Core/Common/Logging/LogManager.cpp index 5d15998398..1d3281ff63 100644 --- a/Source/Core/Common/Logging/LogManager.cpp +++ b/Source/Core/Common/Logging/LogManager.cpp @@ -61,6 +61,17 @@ LogManager::LogManager() m_Log[LogTypes::GDB_STUB] = new LogContainer("GDB_STUB", "GDB Stub"); m_Log[LogTypes::GPFIFO] = new LogContainer("GP", "GPFifo"); m_Log[LogTypes::HOST_GPU] = new LogContainer("Host GPU", "Host GPU"); + m_Log[LogTypes::IOS] = new LogContainer("IOS", "IOS"); + m_Log[LogTypes::IOS_DI] = new LogContainer("IOS_DI", "IOS - Drive Interface"); + m_Log[LogTypes::IOS_ES] = new LogContainer("IOS_ES", "IOS - ETicket Services"); + m_Log[LogTypes::IOS_FILEIO] = new LogContainer("IOS_FILEIO", "IOS - FileIO"); + m_Log[LogTypes::IOS_HID] = new LogContainer("IOS_HID", "IOS - USB_HID"); + m_Log[LogTypes::IOS_SD] = new LogContainer("IOS_SD", "IOS - SDIO"); + m_Log[LogTypes::IOS_SSL] = new LogContainer("IOS_SSL", "IOS - SSL"); + m_Log[LogTypes::IOS_STM] = new LogContainer("IOS_STM", "IOS - State Transition Manager"); + m_Log[LogTypes::IOS_NET] = new LogContainer("IOS_NET", "IOS - Network"); + m_Log[LogTypes::IOS_WC24] = new LogContainer("IOS_WC24", "IOS - WiiConnect24"); + m_Log[LogTypes::IOS_WIIMOTE] = new LogContainer("IOS_WIIMOTE", "IOS - Wii Remote"); m_Log[LogTypes::MASTER_LOG] = new LogContainer("*", "Master Log"); m_Log[LogTypes::MEMCARD_MANAGER] = new LogContainer("MemCard Manager", "MemCard Manager"); m_Log[LogTypes::MEMMAP] = new LogContainer("MI", "MI & memmap"); @@ -77,17 +88,6 @@ LogManager::LogManager() m_Log[LogTypes::VIDEOINTERFACE] = new LogContainer("VI", "Video Interface (VI)"); m_Log[LogTypes::WIIMOTE] = new LogContainer("Wiimote", "Wiimote"); m_Log[LogTypes::WII_IPC] = new LogContainer("WII_IPC", "WII IPC"); - m_Log[LogTypes::WII_IPC_DVD] = new LogContainer("WII_IPC_DVD", "WII IPC DVD"); - m_Log[LogTypes::WII_IPC_ES] = new LogContainer("WII_IPC_ES", "WII IPC ES"); - m_Log[LogTypes::WII_IPC_FILEIO] = new LogContainer("WII_IPC_FILEIO", "WII IPC FILEIO"); - 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"); - m_Log[LogTypes::WII_IPC_SD] = new LogContainer("WII_IPC_SD", "WII IPC SD"); - m_Log[LogTypes::WII_IPC_SSL] = new LogContainer("WII_IPC_SSL", "WII IPC SSL"); - m_Log[LogTypes::WII_IPC_STM] = new LogContainer("WII_IPC_STM", "WII IPC STM"); - m_Log[LogTypes::WII_IPC_NET] = new LogContainer("WII_IPC_NET", "WII IPC NET"); - m_Log[LogTypes::WII_IPC_WC24] = new LogContainer("WII_IPC_WC24", "WII IPC WC24"); - m_Log[LogTypes::WII_IPC_WIIMOTE] = new LogContainer("WII_IPC_WIIMOTE", "WII IPC WIIMOTE"); RegisterListener(LogListener::FILE_LISTENER, new FileLogListener(File::GetUserPath(F_MAINLOG_IDX))); diff --git a/Source/Core/Core/Boot/Boot.cpp b/Source/Core/Core/Boot/Boot.cpp index 7bf221273a..eb520092ec 100644 --- a/Source/Core/Core/Boot/Boot.cpp +++ b/Source/Core/Core/Boot/Boot.cpp @@ -26,7 +26,7 @@ #include "Core/HW/ProcessorInterface.h" #include "Core/HW/VideoInterface.h" #include "Core/Host.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" +#include "Core/IOS/IPC.h" #include "Core/PatchEngine.h" #include "Core/PowerPC/PPCAnalyst.h" #include "Core/PowerPC/PPCSymbolDB.h" diff --git a/Source/Core/Core/Boot/Boot_WiiWAD.cpp b/Source/Core/Core/Boot/Boot_WiiWAD.cpp index 366f89e439..4869353bf4 100644 --- a/Source/Core/Core/Boot/Boot_WiiWAD.cpp +++ b/Source/Core/Core/Boot/Boot_WiiWAD.cpp @@ -14,8 +14,8 @@ #include "Core/HLE/HLE.h" #include "Core/HW/Memmap.h" #include "Core/HW/VideoInterface.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.h" +#include "Core/IOS/FS/FileIO.h" +#include "Core/IOS/IPC.h" #include "Core/PatchEngine.h" #include "Core/PowerPC/PowerPC.h" diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt index 7b576f9577..c38ed5859e 100644 --- a/Source/Core/Core/CMakeLists.txt +++ b/Source/Core/Core/CMakeLists.txt @@ -135,31 +135,31 @@ set(SRCS ActionReplay.cpp HW/WiimoteEmu/Speaker.cpp HW/WiimoteReal/WiimoteReal.cpp HW/WiiSaveCrypted.cpp - IPC_HLE/ESFormats.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 - IPC_HLE/WII_IPC_HLE_Device_fs.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_bt_base.cpp - IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.cpp - IPC_HLE/WII_IPC_HLE_Device_usb_bt_stub.cpp - IPC_HLE/WII_IPC_HLE_Device_usb_kbd.cpp - IPC_HLE/WII_IPC_HLE_Device_usb_ven.cpp - IPC_HLE/WII_IPC_HLE_Device_usb_wfssrv.cpp - IPC_HLE/WII_IPC_HLE_Device_wfsi.cpp - IPC_HLE/WII_IPC_HLE_WiiMote.cpp - IPC_HLE/WiiMote_HID_Attr.cpp - IPC_HLE/WiiNetConfig.cpp + IOS/Device.cpp + IOS/DeviceStub.cpp + IOS/IPC.cpp + IOS/DI/DI.cpp + IOS/ES/ES.cpp + IOS/ES/Formats.cpp + IOS/FS/FileIO.cpp + IOS/FS/FS.cpp + IOS/Network/Config.cpp + IOS/Network/ICMPLin.cpp + IOS/Network/NWC24Config.cpp + IOS/Network/Socket.cpp + IOS/Network/Net.cpp + IOS/Network/SSL.cpp + IOS/SDIO/SDIOSlot0.cpp + IOS/STM/STM.cpp + IOS/USB/USB_KBD.cpp + IOS/USB/USB_VEN.cpp + IOS/USB/Bluetooth/BTBase.cpp + IOS/USB/Bluetooth/BTEmu.cpp + IOS/USB/Bluetooth/BTStub.cpp + IOS/USB/Bluetooth/WiimoteDevice.cpp + IOS/USB/Bluetooth/WiimoteHIDAttr.cpp + IOS/WFS/WFSSRV.cpp + IOS/WFS/WFSI.cpp PowerPC/BreakPoints.cpp PowerPC/MMU.cpp PowerPC/PowerPC.cpp @@ -260,8 +260,8 @@ set(LIBS if(LIBUSB_FOUND) # Using shared LibUSB set(LIBS ${LIBS} ${LIBUSB_LIBRARIES}) - set(SRCS ${SRCS} IPC_HLE/WII_IPC_HLE_Device_hid.cpp - IPC_HLE/WII_IPC_HLE_Device_usb_bt_real.cpp) + set(SRCS ${SRCS} IOS/USB/USB_HIDv4.cpp + IOS/USB/Bluetooth/BTReal.cpp) endif(LIBUSB_FOUND) if(NOT APPLE) diff --git a/Source/Core/Core/ConfigManager.cpp b/Source/Core/Core/ConfigManager.cpp index cf89127184..7d8f7d7993 100644 --- a/Source/Core/Core/ConfigManager.cpp +++ b/Source/Core/Core/ConfigManager.cpp @@ -22,7 +22,7 @@ #include "Core/Core.h" // for bWii #include "Core/FifoPlayer/FifoDataFile.h" #include "Core/HW/SI.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.h" +#include "Core/IOS/USB/Bluetooth/BTBase.h" #include "Core/PowerPC/PowerPC.h" #include "DiscIO/Enums.h" diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index fbe872c534..03dcc175b0 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -54,9 +54,9 @@ #include "Core/HW/SystemTimers.h" #include "Core/HW/VideoInterface.h" #include "Core/HW/Wiimote.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.h" -#include "Core/IPC_HLE/WII_IPC_HLE_WiiMote.h" -#include "Core/IPC_HLE/WII_Socket.h" +#include "Core/IOS/Network/Socket.h" +#include "Core/IOS/USB/Bluetooth/BTEmu.h" +#include "Core/IOS/USB/Bluetooth/WiimoteDevice.h" #include "Core/Movie.h" #include "Core/NetPlayClient.h" #include "Core/NetPlayProto.h" diff --git a/Source/Core/Core/Core.vcxproj b/Source/Core/Core/Core.vcxproj index b9f950a2eb..0219697453 100644 --- a/Source/Core/Core/Core.vcxproj +++ b/Source/Core/Core/Core.vcxproj @@ -167,41 +167,41 @@ - - - - - - - - - - - - + + + + + + + + + + + + + + + + + 4200;%(DisableSpecificWarnings) - - - - - - - + + + + + + 4200;%(DisableSpecificWarnings) - - - - - - - - + + + + @@ -395,35 +395,36 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Source/Core/Core/Core.vcxproj.filters b/Source/Core/Core/Core.vcxproj.filters index 555cf460a6..8afa31ba27 100644 --- a/Source/Core/Core/Core.vcxproj.filters +++ b/Source/Core/Core/Core.vcxproj.filters @@ -25,9 +25,6 @@ {d060b137-c211-44eb-9cad-fc12dedbea73} - - {becbad5b-2531-410c-b032-2da2f078b178} - {ebd24590-dfdc-433e-a411-21723e4b7cb5} @@ -112,39 +109,42 @@ {2b41ab45-ba8c-45dc-92cc-9107c1fa3e36} - - {9370a21f-a7bf-4973-8258-290253617653} - - - {3f85582a-e612-4582-b0fa-ecc27ba3658c} - - - {1f5662c1-885f-4ed4-9f10-cc8e98eaa35d} - - - {1fb00563-01ba-42c4-82de-2c66371e614a} - - - {4620ba8f-5638-4d56-941e-69fc4a4dfc07} - - - {83c278e5-6b06-4cd0-96fb-2e3c88eb32d7} - - - {4a090016-76d5-43dd-95a4-abedfc11ef31} - - - {f11746cf-277a-4d58-bcf1-578a45348b07} - - - {8352be4d-d37d-4f55-adec-b940a9712802} - {827afa93-1a80-4835-93ae-b5516d95867f} {81956f71-d9fe-454f-96a6-855195d611c4} + + {e14b3339-dc23-46d6-845d-7206dc4f88c3} + + + {c1e2e0dc-30ac-44cd-9909-e5b594647a04} + + + {5846b261-397e-4e2a-89e3-88d22ab927c5} + + + {ab9cdd90-54d7-4f42-9248-d7903ce52cc8} + + + {3db8c364-1d72-4660-9179-86d1c46904b9} + + + {75be4669-90fe-4280-b0ea-df350f481357} + + + {7fae98ef-4b62-4701-8f08-c496bd1ce2a7} + + + {b132ac6a-a02e-429e-858b-bfbc3fdc1851} + + + {2bfd4ecc-7225-48f0-91b9-efb42aaf71bf} + + + {1fa9df3e-6741-4045-b2f6-457b4a0540a9} + @@ -568,84 +568,6 @@ DSPCore - - IPC HLE %28IOS/Starlet%29\ES - - - IPC HLE %28IOS/Starlet%29 - - - IPC HLE %28IOS/Starlet%29 - - - IPC HLE %28IOS/Starlet%29 - - - IPC HLE %28IOS/Starlet%29\DI - - - IPC HLE %28IOS/Starlet%29\ES - - - IPC HLE %28IOS/Starlet%29\FS - - - IPC HLE %28IOS/Starlet%29\FS - - - IPC HLE %28IOS/Starlet%29\Keyboard - - - IPC HLE %28IOS/Starlet%29\Net - - - IPC HLE %28IOS/Starlet%29\Net - - - IPC HLE %28IOS/Starlet%29\Net - - - IPC HLE %28IOS/Starlet%29\Net - - - IPC HLE %28IOS/Starlet%29\Net - - - IPC HLE %28IOS/Starlet%29\Net - - - IPC HLE %28IOS/Starlet%29\SDIO - SD Card - - - IPC HLE %28IOS/Starlet%29 - - - IPC HLE %28IOS/Starlet%29\USB - - - IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote - - - IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote - - - IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote - - - IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote - - - IPC HLE %28IOS/Starlet%29\WFS - - - IPC HLE %28IOS/Starlet%29\WFS - - - IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote - - - IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote - HW %28Flipper/Hollywood%29\Wiimote @@ -779,17 +701,89 @@ PowerPC\Jit64Common - - IPC HLE %28IOS/Starlet%29\USB + + + + + IOS\USB\Bluetooth - - PowerPC\SignatureDB + + IOS\USB\Bluetooth - - PowerPC\SignatureDB + + IOS\USB\Bluetooth - - PowerPC\SignatureDB + + IOS\USB\Bluetooth + + + IOS\Network + + + IOS + + + IOS + + + IOS\DI + + + IOS\FS + + + IOS\ES + + + IOS\ES + + + IOS\FS + + + IOS\Network + + + IOS + + + IOS\Network + + + IOS\Network + + + IOS\SDIO + + + IOS\Network + + + IOS\Network + + + IOS\STM + + + IOS\USB + + + IOS\USB + + + IOS\USB + + + IOS\WFS + + + IOS\WFS + + + IOS\USB\Bluetooth + + + IOS\USB\Bluetooth @@ -1174,90 +1168,6 @@ DSPCore - - IPC HLE %28IOS/Starlet%29\ES - - - IPC HLE %28IOS/Starlet%29 - - - IPC HLE %28IOS/Starlet%29 - - - IPC HLE %28IOS/Starlet%29 - - - IPC HLE %28IOS/Starlet%29 - - - IPC HLE %28IOS/Starlet%29\DI - - - IPC HLE %28IOS/Starlet%29\ES - - - IPC HLE %28IOS/Starlet%29\FS - - - IPC HLE %28IOS/Starlet%29\FS - - - IPC HLE %28IOS/Starlet%29\Keyboard - - - IPC HLE %28IOS/Starlet%29\Net - - - IPC HLE %28IOS/Starlet%29\Net - - - IPC HLE %28IOS/Starlet%29\Net - - - IPC HLE %28IOS/Starlet%29\Net - - - IPC HLE %28IOS/Starlet%29\Net - - - IPC HLE %28IOS/Starlet%29\Net - - - IPC HLE %28IOS/Starlet%29\SDIO - SD Card - - - IPC HLE %28IOS/Starlet%29\USB - - - IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote - - - IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote - - - IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote - - - IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote - - - IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote - - - IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote - - - IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote - - - IPC HLE %28IOS/Starlet%29\USB/BT/Wiimote - - - IPC HLE %28IOS/Starlet%29\WFS - - - IPC HLE %28IOS/Starlet%29\WFS - HW %28Flipper/Hollywood%29\Wiimote @@ -1356,20 +1266,101 @@ PowerPC\Jit64Common - - IPC HLE %28IOS/Starlet%29\USB + + + + + IOS\USB\Bluetooth - - PowerPC\SignatureDB + + IOS\USB\Bluetooth - - PowerPC\SignatureDB + + IOS\USB\Bluetooth - - PowerPC\SignatureDB + + IOS\USB\Bluetooth + + + IOS\Network + + + IOS + + + IOS\DI + + + IOS\ES + + + IOS\FS + + + IOS\ES + + + IOS\FS + + + IOS\USB\Bluetooth + + + IOS\Network + + + IOS\Network + + + IOS\USB\Bluetooth + + + IOS\Network + + + IOS\Network + + + IOS\SDIO + + + IOS\Network + + + IOS\Network + + + IOS\STM + + + IOS\USB + + + IOS\USB + + + IOS\USB + + + IOS\WFS + + + IOS\WFS + + + IOS\USB\Bluetooth + + + IOS\USB\Bluetooth + + + IOS + + + IOS - + \ No newline at end of file diff --git a/Source/Core/Core/HLE/HLE.cpp b/Source/Core/Core/HLE/HLE.cpp index e30d073192..fbb6bef40b 100644 --- a/Source/Core/Core/HLE/HLE.cpp +++ b/Source/Core/Core/HLE/HLE.cpp @@ -14,7 +14,7 @@ #include "Core/HLE/HLE_Misc.h" #include "Core/HLE/HLE_OS.h" #include "Core/HW/Memmap.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_es.h" +#include "Core/IOS/ES/ES.h" #include "Core/PowerPC/PPCSymbolDB.h" #include "Core/PowerPC/PowerPC.h" diff --git a/Source/Core/Core/HW/DVDInterface.cpp b/Source/Core/Core/HW/DVDInterface.cpp index c56c9e7a0d..c7fe1e4a6d 100644 --- a/Source/Core/Core/HW/DVDInterface.cpp +++ b/Source/Core/Core/HW/DVDInterface.cpp @@ -24,8 +24,8 @@ #include "Core/HW/ProcessorInterface.h" #include "Core/HW/StreamADPCM.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 "Core/IOS/DI/DI.h" +#include "Core/IOS/IPC.h" #include "Core/Movie.h" #include "DiscIO/Enums.h" @@ -729,7 +729,7 @@ bool ExecuteReadCommand(u64 DVD_offset, u32 output_address, u32 DVD_length, u32 void ExecuteCommand(u32 command_0, u32 command_1, u32 command_2, u32 output_address, u32 output_length, bool reply_to_ios) { - ReplyType reply_type = reply_to_ios ? ReplyType::IOS_HLE : ReplyType::Interrupt; + ReplyType reply_type = reply_to_ios ? ReplyType::IOS : ReplyType::Interrupt; DIInterruptType interrupt_type = INT_TCINT; s64 ticks_until_completion = SystemTimers::GetTicksPerSecond() / 15000; bool command_handled_by_thread = false; @@ -1153,11 +1153,11 @@ void FinishExecutingCommand(ReplyType reply_type, DIInterruptType interrupt_type break; } - case ReplyType::IOS_HLE: + case ReplyType::IOS: { - std::shared_ptr di = IOS::HLE::GetDeviceByName("/dev/di"); + auto di = IOS::HLE::GetDeviceByName("/dev/di"); if (di) - std::static_pointer_cast(di)->FinishIOCtl(interrupt_type); + std::static_pointer_cast(di)->FinishIOCtl(interrupt_type); break; } diff --git a/Source/Core/Core/HW/DVDInterface.h b/Source/Core/Core/HW/DVDInterface.h index 279dc15d92..110a24c2ae 100644 --- a/Source/Core/Core/HW/DVDInterface.h +++ b/Source/Core/Core/HW/DVDInterface.h @@ -96,7 +96,7 @@ enum DIInterruptType : int enum class ReplyType : u32 { Interrupt, - IOS_HLE, + IOS, DTK }; diff --git a/Source/Core/Core/HW/HW.cpp b/Source/Core/Core/HW/HW.cpp index bfc4856320..8518bb192b 100644 --- a/Source/Core/Core/HW/HW.cpp +++ b/Source/Core/Core/HW/HW.cpp @@ -21,7 +21,7 @@ #include "Core/HW/SystemTimers.h" #include "Core/HW/VideoInterface.h" #include "Core/HW/WII_IPC.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" +#include "Core/IOS/IPC.h" #include "Core/State.h" #include "Core/WiiRoot.h" #include "DiscIO/NANDContentLoader.h" diff --git a/Source/Core/Core/HW/ProcessorInterface.cpp b/Source/Core/Core/HW/ProcessorInterface.cpp index c5bf1ba412..47535938fc 100644 --- a/Source/Core/Core/HW/ProcessorInterface.cpp +++ b/Source/Core/Core/HW/ProcessorInterface.cpp @@ -11,8 +11,8 @@ #include "Core/HW/MMIO.h" #include "Core/HW/ProcessorInterface.h" #include "Core/HW/SystemTimers.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_stm.h" +#include "Core/IOS/IPC.h" +#include "Core/IOS/STM/STM.h" #include "Core/PowerPC/PowerPC.h" namespace ProcessorInterface @@ -212,10 +212,9 @@ static void IOSNotifyResetButtonCallback(u64 userdata, s64 cyclesLate) { if (SConfig::GetInstance().bWii) { - std::shared_ptr stm = - IOS::HLE::GetDeviceByName("/dev/stm/eventhook"); + auto stm = IOS::HLE::GetDeviceByName("/dev/stm/eventhook"); if (stm) - std::static_pointer_cast(stm)->ResetButton(); + std::static_pointer_cast(stm)->ResetButton(); } } @@ -223,10 +222,9 @@ static void IOSNotifyPowerButtonCallback(u64 userdata, s64 cyclesLate) { if (SConfig::GetInstance().bWii) { - std::shared_ptr stm = - IOS::HLE::GetDeviceByName("/dev/stm/eventhook"); + auto stm = IOS::HLE::GetDeviceByName("/dev/stm/eventhook"); if (stm) - std::static_pointer_cast(stm)->PowerButton(); + std::static_pointer_cast(stm)->PowerButton(); } } diff --git a/Source/Core/Core/HW/SystemTimers.cpp b/Source/Core/Core/HW/SystemTimers.cpp index 45ffa2f9f7..fcd269e199 100644 --- a/Source/Core/Core/HW/SystemTimers.cpp +++ b/Source/Core/Core/HW/SystemTimers.cpp @@ -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" @@ -57,7 +57,7 @@ IPC_HLE_PERIOD: For the Wii Remote this is the call schedule: #include "Core/HW/DSP.h" #include "Core/HW/EXI_DeviceIPL.h" #include "Core/HW/VideoInterface.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" +#include "Core/IOS/IPC.h" #include "Core/PatchEngine.h" #include "Core/PowerPC/PowerPC.h" #include "VideoCommon/Fifo.h" diff --git a/Source/Core/Core/HW/WII_IPC.cpp b/Source/Core/Core/HW/WII_IPC.cpp index c98775a0b5..19974b0533 100644 --- a/Source/Core/Core/HW/WII_IPC.cpp +++ b/Source/Core/Core/HW/WII_IPC.cpp @@ -9,7 +9,7 @@ #include "Core/CoreTiming.h" #include "Core/HW/MMIO.h" #include "Core/HW/ProcessorInterface.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" +#include "Core/IOS/IPC.h" // This is the intercommunication between ARM and PPC. Currently only PPC actually uses it, because // of the IOS HLE diff --git a/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp b/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp index 2100d23779..c5bec3fba8 100644 --- a/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp +++ b/Source/Core/Core/HW/WiimoteEmu/Speaker.cpp @@ -110,7 +110,7 @@ void Wiimote::SpeakerData(wm_speaker_data* sd) } else { - ERROR_LOG(WII_IPC_WIIMOTE, "Unknown speaker format %x", m_reg_speaker.format); + ERROR_LOG(IOS_WIIMOTE, "Unknown speaker format %x", m_reg_speaker.format); return; } diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_DI.cpp b/Source/Core/Core/IOS/DI/DI.cpp similarity index 69% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_DI.cpp rename to Source/Core/Core/IOS/DI/DI.cpp index 3940f1d800..6092007d19 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_DI.cpp +++ b/Source/Core/Core/IOS/DI/DI.cpp @@ -13,33 +13,30 @@ #include "Common/MsgHandler.h" #include "Core/HW/DVDInterface.h" #include "Core/HW/Memmap.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_DI.h" +#include "Core/IOS/DI/DI.h" +#include "Core/IOS/IPC.h" #include "DiscIO/Volume.h" 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. + // compared to other IOS functions. // This is a wrapper around DVDInterface's ExecuteCommand, // which will execute commands more or less asynchronously. // Only one command can be executed at a time, so commands @@ -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); @@ -98,15 +95,14 @@ IPCCommandResult CWII_IPC_HLE_Device_di::IOCtlV(const IOSIOCtlVRequest& request) { case DVDInterface::DVDLowOpenPartition: { - _dbg_assert_msg_(WII_IPC_DVD, request.in_vectors[1].address == 0, - "DVDLowOpenPartition with ticket"); - _dbg_assert_msg_(WII_IPC_DVD, request.in_vectors[2].address == 0, + _dbg_assert_msg_(IOS_DI, request.in_vectors[1].address == 0, "DVDLowOpenPartition with ticket"); + _dbg_assert_msg_(IOS_DI, request.in_vectors[2].address == 0, "DVDLowOpenPartition with cert chain"); u64 const partition_offset = ((u64)Memory::Read_U32(request.in_vectors[0].address + 4) << 2); DVDInterface::ChangePartition(partition_offset); - INFO_LOG(WII_IPC_DVD, "DVDLowOpenPartition: partition_offset 0x%016" PRIx64, partition_offset); + INFO_LOG(IOS_DI, "DVDLowOpenPartition: partition_offset 0x%016" PRIx64, partition_offset); // Read TMD to the buffer std::vector tmd_buffer = DVDInterface::GetVolume().GetTMD(); @@ -117,9 +113,10 @@ IPCCommandResult CWII_IPC_HLE_Device_di::IOCtlV(const IOSIOCtlVRequest& request) break; } default: - request.DumpUnknown(GetDeviceName(), LogTypes::WII_IPC_DVD); + request.DumpUnknown(GetDeviceName(), LogTypes::IOS_DI); } return GetDefaultReply(return_value); } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_DI.h b/Source/Core/Core/IOS/DI/DI.h similarity index 73% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_DI.h rename to Source/Core/Core/IOS/DI/DI.h index abc537f37c..489ebfcbee 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_DI.h +++ b/Source/Core/Core/IOS/DI/DI.h @@ -8,8 +8,8 @@ #include #include "Common/CommonTypes.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device.h" +#include "Core/IOS/Device.h" +#include "Core/IOS/IPC.h" class PointerWrap; @@ -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 m_commands_to_execute; }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device.cpp b/Source/Core/Core/IOS/Device.cpp similarity index 87% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device.cpp rename to Source/Core/Core/IOS/Device.cpp index c852bc3263..e52e1278bc 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device.cpp +++ b/Source/Core/Core/IOS/Device.cpp @@ -9,8 +9,8 @@ #include "Common/StringUtil.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.h" +#include "Core/IOS/Device.h" +#include "Core/IOS/IPC.h" namespace IOS { @@ -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,39 +142,40 @@ 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 names = {{{IPC_CMD_READ, "Read"}, {IPC_CMD_WRITE, "Write"}, {IPC_CMD_SEEK, "Seek"}, {IPC_CMD_IOCTL, "IOCtl"}, {IPC_CMD_IOCTLV, "IOCtlV"}}}; - WARN_LOG(WII_IPC_HLE, "%s does not support %s()", m_name.c_str(), names[request.command].c_str()); + WARN_LOG(IOS, "%s does not support %s()", m_name.c_str(), names[request.command].c_str()); return GetDefaultReply(IPC_EINVAL); } // 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 diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device.h b/Source/Core/Core/IOS/Device.h similarity index 91% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device.h rename to Source/Core/Core/IOS/Device.h index fe7983b536..df139a30af 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device.h +++ b/Source/Core/Core/IOS/Device.h @@ -11,7 +11,7 @@ #include "Common/ChunkFile.h" #include "Common/CommonTypes.h" #include "Common/Logging/Log.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" +#include "Core/IOS/IPC.h" namespace IOS { @@ -96,11 +96,11 @@ struct IOSIOCtlRequest final : IOSRequest u32 buffer_out = 0; u32 buffer_out_size = 0; explicit IOSIOCtlRequest(u32 address); - void Log(const std::string& description, LogTypes::LOG_TYPE type = LogTypes::WII_IPC_HLE, + void Log(const std::string& description, LogTypes::LOG_TYPE type = LogTypes::IOS, LogTypes::LOG_LEVELS level = LogTypes::LINFO) const; - void Dump(const std::string& description, LogTypes::LOG_TYPE type = LogTypes::WII_IPC_HLE, + void Dump(const std::string& description, LogTypes::LOG_TYPE type = LogTypes::IOS, LogTypes::LOG_LEVELS level = LogTypes::LINFO) const; - void DumpUnknown(const std::string& description, LogTypes::LOG_TYPE type = LogTypes::WII_IPC_HLE, + void DumpUnknown(const std::string& description, LogTypes::LOG_TYPE type = LogTypes::IOS, LogTypes::LOG_LEVELS level = LogTypes::LERROR) const; }; @@ -122,13 +122,15 @@ struct IOSIOCtlVRequest final : IOSRequest std::vector io_vectors; explicit IOSIOCtlVRequest(u32 address); bool HasInputVectorWithAddress(u32 vector_address) const; - void Dump(const std::string& description, LogTypes::LOG_TYPE type = LogTypes::WII_IPC_HLE, + void Dump(const std::string& description, LogTypes::LOG_TYPE type = LogTypes::IOS, LogTypes::LOG_LEVELS level = LogTypes::LINFO) const; - void DumpUnknown(const std::string& description, LogTypes::LOG_TYPE type = LogTypes::WII_IPC_HLE, + void DumpUnknown(const std::string& description, LogTypes::LOG_TYPE type = LogTypes::IOS, 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 diff --git a/Source/Core/Core/IOS/DeviceStub.cpp b/Source/Core/Core/IOS/DeviceStub.cpp new file mode 100644 index 0000000000..3fdc25409d --- /dev/null +++ b/Source/Core/Core/IOS/DeviceStub.cpp @@ -0,0 +1,44 @@ +// Copyright 2016 Dolphin Emulator Project +// Licensed under GPLv2+ +// Refer to the license.txt file included. + +#include "Core/IOS/DeviceStub.h" +#include "Common/Logging/Log.h" + +namespace IOS +{ +namespace HLE +{ +namespace Device +{ +Stub::Stub(u32 device_id, const std::string& device_name) : Device(device_id, device_name) +{ +} + +IOSReturnCode Stub::Open(const IOSOpenRequest& request) +{ + WARN_LOG(IOS, "%s faking Open()", m_name.c_str()); + m_is_active = true; + return IPC_SUCCESS; +} + +void Stub::Close() +{ + WARN_LOG(IOS, "%s faking Close()", m_name.c_str()); + m_is_active = false; +} + +IPCCommandResult Stub::IOCtl(const IOSIOCtlRequest& request) +{ + WARN_LOG(IOS, "%s faking IOCtl()", m_name.c_str()); + return GetDefaultReply(IPC_SUCCESS); +} + +IPCCommandResult Stub::IOCtlV(const IOSIOCtlVRequest& request) +{ + WARN_LOG(IOS, "%s faking IOCtlV()", m_name.c_str()); + return GetDefaultReply(IPC_SUCCESS); +} +} // namespace Device +} // namespace HLE +} // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stub.h b/Source/Core/Core/IOS/DeviceStub.h similarity index 69% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stub.h rename to Source/Core/Core/IOS/DeviceStub.h index a4c641ad77..672432c43c 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stub.h +++ b/Source/Core/Core/IOS/DeviceStub.h @@ -7,22 +7,25 @@ #include #include "Common/CommonTypes.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device.h" +#include "Core/IOS/Device.h" +#include "Core/IOS/IPC.h" 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 diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.cpp b/Source/Core/Core/IOS/ES/ES.cpp similarity index 79% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.cpp rename to Source/Core/Core/IOS/ES/ES.cpp index 1c04f7357d..ff8ff7e655 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.cpp +++ b/Source/Core/Core/IOS/ES/ES.cpp @@ -53,10 +53,10 @@ #include "Core/HW/DVDInterface.h" #include "Core/HW/Memmap.h" #include "Core/HW/Wiimote.h" -#include "Core/IPC_HLE/ESFormats.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" +#include "Core/IOS/ES/ES.h" +#include "Core/IOS/ES/Formats.h" +#include "Core/IOS/USB/Bluetooth/BTEmu.h" +#include "Core/IOS/USB/Bluetooth/WiimoteDevice.h" #include "Core/Movie.h" #include "Core/PowerPC/PowerPC.h" #include "Core/ec_wii.h" @@ -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); @@ -141,12 +141,12 @@ void CWII_IPC_HLE_Device_es::OpenInternal() m_TitleID = ((u64)0x00010000 << 32) | 0xF00DBEEF; } - INFO_LOG(WII_IPC_ES, "Set default title to %08x/%08x", (u32)(m_TitleID >> 32), (u32)m_TitleID); + INFO_LOG(IOS_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,35 +195,35 @@ 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); + INFO_LOG(IOS_ES, "Device was re-opened."); + return Device::Open(request); } -void CWII_IPC_HLE_Device_es::Close() +void ES::Close() { m_ContentAccessMap.clear(); m_TitleIDs.clear(); m_TitleID = -1; m_AccessIdentID = 0x6000000; - INFO_LOG(WII_IPC_ES, "ES: Close"); + INFO_LOG(IOS_ES, "ES: Close"); m_is_active = false; // clear the NAND content cache to make sure nothing remains open. 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); if (!Loader.IsValid()) { - WARN_LOG(WII_IPC_ES, "ES: loader not valid for %" PRIx64, TitleID); + WARN_LOG(IOS_ES, "ES: loader not valid for %" PRIx64, TitleID); return 0xffffffff; } @@ -246,9 +246,9 @@ 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); + DEBUG_LOG(IOS_ES, "%s (0x%x)", GetDeviceName().c_str(), request.request); // Clear the IO buffers. Note that this is unsafe for other ioctlvs. for (const auto& io_vector : request.io_vectors) { @@ -259,10 +259,10 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) { case IOCTL_ES_ADDTICKET: { - _dbg_assert_msg_(WII_IPC_ES, request.in_vectors.size() == 3, + _dbg_assert_msg_(IOS_ES, request.in_vectors.size() == 3, "IOCTL_ES_ADDTICKET wrong number of inputs"); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_ADDTICKET"); + INFO_LOG(IOS_ES, "IOCTL_ES_ADDTICKET"); std::vector ticket(request.in_vectors[0].size); Memory::CopyFromEmu(ticket.data(), request.in_vectors[0].address, request.in_vectors[0].size); DiscIO::AddTicket(ticket); @@ -271,17 +271,17 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) case IOCTL_ES_ADDTITLESTART: { - _dbg_assert_msg_(WII_IPC_ES, request.in_vectors.size() == 4, + _dbg_assert_msg_(IOS_ES, request.in_vectors.size() == 4, "IOCTL_ES_ADDTITLESTART wrong number of inputs"); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_ADDTITLESTART"); + INFO_LOG(IOS_ES, "IOCTL_ES_ADDTITLESTART"); std::vector tmd(request.in_vectors[0].size); Memory::CopyFromEmu(tmd.data(), request.in_vectors[0].address, request.in_vectors[0].size); m_addtitle_tmd.SetBytes(tmd); if (!m_addtitle_tmd.IsValid()) { - ERROR_LOG(WII_IPC_ES, "Invalid TMD while adding title (size = %zd)", tmd.size()); + ERROR_LOG(IOS_ES, "Invalid TMD while adding title (size = %zd)", tmd.size()); return GetDefaultReply(ES_INVALID_TMD); } @@ -297,7 +297,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) case IOCTL_ES_ADDCONTENTSTART: { - _dbg_assert_msg_(WII_IPC_ES, request.in_vectors.size() == 2, + _dbg_assert_msg_(IOS_ES, request.in_vectors.size() == 2, "IOCTL_ES_ADDCONTENTSTART wrong number of inputs"); u64 title_id = Memory::Read_U64(request.in_vectors[0].address); @@ -305,22 +305,22 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) if (m_addtitle_content_id != 0xFFFFFFFF) { - ERROR_LOG(WII_IPC_ES, "Trying to add content when we haven't finished adding " - "another content. Unsupported."); + ERROR_LOG(IOS_ES, "Trying to add content when we haven't finished adding " + "another content. Unsupported."); return GetDefaultReply(ES_WRITE_FAILURE); } m_addtitle_content_id = content_id; m_addtitle_content_buffer.clear(); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_ADDCONTENTSTART: title id %016" PRIx64 ", " - "content id %08x", + INFO_LOG(IOS_ES, "IOCTL_ES_ADDCONTENTSTART: title id %016" PRIx64 ", " + "content id %08x", title_id, m_addtitle_content_id); if (title_id != m_addtitle_tmd.GetTitleId()) { - ERROR_LOG(WII_IPC_ES, "IOCTL_ES_ADDCONTENTSTART: title id %016" PRIx64 " != " - "TMD title id %016lx, ignoring", + ERROR_LOG(IOS_ES, "IOCTL_ES_ADDCONTENTSTART: title id %016" PRIx64 " != " + "TMD title id %016lx, ignoring", title_id, m_addtitle_tmd.GetTitleId()); } @@ -334,12 +334,12 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) case IOCTL_ES_ADDCONTENTDATA: { - _dbg_assert_msg_(WII_IPC_ES, request.in_vectors.size() == 2, + _dbg_assert_msg_(IOS_ES, request.in_vectors.size() == 2, "IOCTL_ES_ADDCONTENTDATA wrong number of inputs"); u32 content_fd = Memory::Read_U32(request.in_vectors[0].address); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_ADDCONTENTDATA: content fd %08x, " - "size %d", + INFO_LOG(IOS_ES, "IOCTL_ES_ADDCONTENTDATA: content fd %08x, " + "size %d", content_fd, request.in_vectors[1].size); u8* data_start = Memory::GetPointer(request.in_vectors[1].address); @@ -350,11 +350,11 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) case IOCTL_ES_ADDCONTENTFINISH: { - _dbg_assert_msg_(WII_IPC_ES, request.in_vectors.size() == 1, + _dbg_assert_msg_(IOS_ES, request.in_vectors.size() == 1, "IOCTL_ES_ADDCONTENTFINISH wrong number of inputs"); u32 content_fd = Memory::Read_U32(request.in_vectors[0].address); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_ADDCONTENTFINISH: content fd %08x", content_fd); + INFO_LOG(IOS_ES, "IOCTL_ES_ADDCONTENTFINISH: content fd %08x", content_fd); // Try to find the title key from a pre-installed ticket. std::vector ticket = DiscIO::FindSignedTicket(m_addtitle_tmd.GetTitleId()); @@ -394,25 +394,24 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) case IOCTL_ES_ADDTITLEFINISH: { - INFO_LOG(WII_IPC_ES, "IOCTL_ES_ADDTITLEFINISH"); + INFO_LOG(IOS_ES, "IOCTL_ES_ADDTITLEFINISH"); break; } case IOCTL_ES_GETDEVICEID: { - _dbg_assert_msg_(WII_IPC_ES, request.io_vectors.size() == 1, - "IOCTL_ES_GETDEVICEID no io vectors"); + _dbg_assert_msg_(IOS_ES, request.io_vectors.size() == 1, "IOCTL_ES_GETDEVICEID no io vectors"); EcWii& ec = EcWii::GetInstance(); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETDEVICEID %08X", ec.getNgId()); + INFO_LOG(IOS_ES, "IOCTL_ES_GETDEVICEID %08X", ec.getNgId()); Memory::Write_U32(ec.getNgId(), request.io_vectors[0].address); return GetDefaultReply(IPC_SUCCESS); } case IOCTL_ES_GETTITLECONTENTSCNT: { - _dbg_assert_(WII_IPC_ES, request.in_vectors.size() == 1); - _dbg_assert_(WII_IPC_ES, request.io_vectors.size() == 1); + _dbg_assert_(IOS_ES, request.in_vectors.size() == 1); + _dbg_assert_(IOS_ES, request.io_vectors.size() == 1); u64 TitleID = Memory::Read_U64(request.in_vectors[0].address); @@ -433,7 +432,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) return_value = static_cast(rNANDContent.GetContentSize()); } - INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETTITLECONTENTSCNT: TitleID: %08x/%08x content count %i", + INFO_LOG(IOS_ES, "IOCTL_ES_GETTITLECONTENTSCNT: TitleID: %08x/%08x content count %i", (u32)(TitleID >> 32), (u32)TitleID, rNANDContent.IsValid() ? NumberOfPrivateContent : (u32)rNANDContent.GetContentSize()); @@ -443,9 +442,9 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) case IOCTL_ES_GETTITLECONTENTS: { - _dbg_assert_msg_(WII_IPC_ES, request.in_vectors.size() == 2, + _dbg_assert_msg_(IOS_ES, request.in_vectors.size() == 2, "IOCTL_ES_GETTITLECONTENTS bad in buffer"); - _dbg_assert_msg_(WII_IPC_ES, request.io_vectors.size() == 1, + _dbg_assert_msg_(IOS_ES, request.io_vectors.size() == 1, "IOCTL_ES_GETTITLECONTENTS bad out buffer"); u64 TitleID = Memory::Read_U64(request.in_vectors[0].address); @@ -458,14 +457,14 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) { Memory::Write_U32(rNANDContent.GetContentByIndex(i)->m_ContentID, request.io_vectors[0].address + i * 4); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETTITLECONTENTS: Index %d: %08x", i, + INFO_LOG(IOS_ES, "IOCTL_ES_GETTITLECONTENTS: Index %d: %08x", i, rNANDContent.GetContentByIndex(i)->m_ContentID); } } else { return_value = static_cast(rNANDContent.GetContentSize()); - ERROR_LOG(WII_IPC_ES, "IOCTL_ES_GETTITLECONTENTS: Unable to open content %zu", + ERROR_LOG(IOS_ES, "IOCTL_ES_GETTITLECONTENTS: Unable to open content %zu", rNANDContent.GetContentSize()); } @@ -475,15 +474,15 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) case IOCTL_ES_OPENTITLECONTENT: { - _dbg_assert_(WII_IPC_ES, request.in_vectors.size() == 3); - _dbg_assert_(WII_IPC_ES, request.io_vectors.size() == 0); + _dbg_assert_(IOS_ES, request.in_vectors.size() == 3); + _dbg_assert_(IOS_ES, request.io_vectors.size() == 0); u64 TitleID = Memory::Read_U64(request.in_vectors[0].address); u32 Index = Memory::Read_U32(request.in_vectors[2].address); s32 CFD = OpenTitleContent(m_AccessIdentID++, TitleID, Index); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_OPENTITLECONTENT: TitleID: %08x/%08x Index %i -> got CFD %x", + INFO_LOG(IOS_ES, "IOCTL_ES_OPENTITLECONTENT: TitleID: %08x/%08x Index %i -> got CFD %x", (u32)(TitleID >> 32), (u32)TitleID, Index, CFD); return GetDefaultReply(CFD); @@ -492,12 +491,12 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) case IOCTL_ES_OPENCONTENT: { - _dbg_assert_(WII_IPC_ES, request.in_vectors.size() == 1); - _dbg_assert_(WII_IPC_ES, request.io_vectors.size() == 0); + _dbg_assert_(IOS_ES, request.in_vectors.size() == 1); + _dbg_assert_(IOS_ES, request.io_vectors.size() == 0); u32 Index = Memory::Read_U32(request.in_vectors[0].address); s32 CFD = OpenTitleContent(m_AccessIdentID++, m_TitleID, Index); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_OPENCONTENT: Index %i -> got CFD %x", Index, CFD); + INFO_LOG(IOS_ES, "IOCTL_ES_OPENCONTENT: Index %i -> got CFD %x", Index, CFD); return GetDefaultReply(CFD); } @@ -505,8 +504,8 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) case IOCTL_ES_READCONTENT: { - _dbg_assert_(WII_IPC_ES, request.in_vectors.size() == 1); - _dbg_assert_(WII_IPC_ES, request.io_vectors.size() == 1); + _dbg_assert_(IOS_ES, request.in_vectors.size() == 1); + _dbg_assert_(IOS_ES, request.io_vectors.size() == 1); u32 CFD = Memory::Read_U32(request.in_vectors[0].address); u32 Size = request.io_vectors[0].size; @@ -536,8 +535,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) { const DiscIO::SNANDContent* pContent = ContentLoader.GetContentByIndex(rContent.m_Index); if (!pContent->m_Data->GetRange(rContent.m_Position, Size, pDest)) - ERROR_LOG(WII_IPC_ES, "ES: failed to read %u bytes from %u!", Size, - rContent.m_Position); + ERROR_LOG(IOS_ES, "ES: failed to read %u bytes from %u!", Size, rContent.m_Position); } rContent.m_Position += Size; @@ -548,7 +546,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) } } - DEBUG_LOG(WII_IPC_ES, + DEBUG_LOG(IOS_ES, "IOCTL_ES_READCONTENT: CFD %x, Address 0x%x, Size %i -> stream pos %i (Index %i)", CFD, Addr, Size, rContent.m_Position, rContent.m_Index); @@ -558,12 +556,12 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) case IOCTL_ES_CLOSECONTENT: { - _dbg_assert_(WII_IPC_ES, request.in_vectors.size() == 1); - _dbg_assert_(WII_IPC_ES, request.io_vectors.size() == 0); + _dbg_assert_(IOS_ES, request.in_vectors.size() == 1); + _dbg_assert_(IOS_ES, request.io_vectors.size() == 0); u32 CFD = Memory::Read_U32(request.in_vectors[0].address); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_CLOSECONTENT: CFD %x", CFD); + INFO_LOG(IOS_ES, "IOCTL_ES_CLOSECONTENT: CFD %x", CFD); auto itr = m_ContentAccessMap.find(CFD); if (itr == m_ContentAccessMap.end()) @@ -587,8 +585,8 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) case IOCTL_ES_SEEKCONTENT: { - _dbg_assert_(WII_IPC_ES, request.in_vectors.size() == 3); - _dbg_assert_(WII_IPC_ES, request.io_vectors.size() == 0); + _dbg_assert_(IOS_ES, request.in_vectors.size() == 3); + _dbg_assert_(IOS_ES, request.io_vectors.size() == 0); u32 CFD = Memory::Read_U32(request.in_vectors[0].address); u32 Addr = Memory::Read_U32(request.in_vectors[1].address); @@ -616,8 +614,8 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) break; } - DEBUG_LOG(WII_IPC_ES, "IOCTL_ES_SEEKCONTENT: CFD %x, Address 0x%x, Mode %i -> Pos %i", CFD, - Addr, Mode, rContent.m_Position); + DEBUG_LOG(IOS_ES, "IOCTL_ES_SEEKCONTENT: CFD %x, Address 0x%x, Mode %i -> Pos %i", CFD, Addr, + Mode, rContent.m_Position); return GetDefaultReply(rContent.m_Position); } @@ -625,52 +623,51 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) case IOCTL_ES_GETTITLEDIR: { - _dbg_assert_(WII_IPC_ES, request.in_vectors.size() == 1); - _dbg_assert_(WII_IPC_ES, request.io_vectors.size() == 1); + _dbg_assert_(IOS_ES, request.in_vectors.size() == 1); + _dbg_assert_(IOS_ES, request.io_vectors.size() == 1); u64 TitleID = Memory::Read_U64(request.in_vectors[0].address); char* Path = (char*)Memory::GetPointer(request.io_vectors[0].address); sprintf(Path, "/title/%08x/%08x/data", (u32)(TitleID >> 32), (u32)TitleID); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETTITLEDIR: %s", Path); + INFO_LOG(IOS_ES, "IOCTL_ES_GETTITLEDIR: %s", Path); } break; case IOCTL_ES_GETTITLEID: { - _dbg_assert_(WII_IPC_ES, request.in_vectors.size() == 0); - _dbg_assert_msg_(WII_IPC_ES, request.io_vectors.size() == 1, - "IOCTL_ES_GETTITLEID no out buffer"); + _dbg_assert_(IOS_ES, request.in_vectors.size() == 0); + _dbg_assert_msg_(IOS_ES, request.io_vectors.size() == 1, "IOCTL_ES_GETTITLEID no out buffer"); Memory::Write_U64(m_TitleID, request.io_vectors[0].address); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETTITLEID: %08x/%08x", (u32)(m_TitleID >> 32), (u32)m_TitleID); + INFO_LOG(IOS_ES, "IOCTL_ES_GETTITLEID: %08x/%08x", (u32)(m_TitleID >> 32), (u32)m_TitleID); } break; case IOCTL_ES_SETUID: { - _dbg_assert_msg_(WII_IPC_ES, request.in_vectors.size() == 1, "IOCTL_ES_SETUID no in buffer"); - _dbg_assert_msg_(WII_IPC_ES, request.io_vectors.size() == 0, + _dbg_assert_msg_(IOS_ES, request.in_vectors.size() == 1, "IOCTL_ES_SETUID no in buffer"); + _dbg_assert_msg_(IOS_ES, request.io_vectors.size() == 0, "IOCTL_ES_SETUID has a payload, it shouldn't"); // TODO: fs permissions based on this u64 TitleID = Memory::Read_U64(request.in_vectors[0].address); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_SETUID titleID: %08x/%08x", (u32)(TitleID >> 32), (u32)TitleID); + INFO_LOG(IOS_ES, "IOCTL_ES_SETUID titleID: %08x/%08x", (u32)(TitleID >> 32), (u32)TitleID); } break; case IOCTL_ES_GETTITLECNT: { - _dbg_assert_msg_(WII_IPC_ES, request.in_vectors.size() == 0, + _dbg_assert_msg_(IOS_ES, request.in_vectors.size() == 0, "IOCTL_ES_GETTITLECNT has an in buffer"); - _dbg_assert_msg_(WII_IPC_ES, request.io_vectors.size() == 1, + _dbg_assert_msg_(IOS_ES, request.io_vectors.size() == 1, "IOCTL_ES_GETTITLECNT has no out buffer"); - _dbg_assert_msg_(WII_IPC_ES, request.io_vectors[0].size == 4, + _dbg_assert_msg_(IOS_ES, request.io_vectors[0].size == 4, "IOCTL_ES_GETTITLECNT payload[0].size != 4"); Memory::Write_U32((u32)m_TitleIDs.size(), request.io_vectors[0].address); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETTITLECNT: Number of Titles %zu", m_TitleIDs.size()); + INFO_LOG(IOS_ES, "IOCTL_ES_GETTITLECNT: Number of Titles %zu", m_TitleIDs.size()); return GetDefaultReply(IPC_SUCCESS); } @@ -678,9 +675,8 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) case IOCTL_ES_GETTITLES: { - _dbg_assert_msg_(WII_IPC_ES, request.in_vectors.size() == 1, - "IOCTL_ES_GETTITLES has an in buffer"); - _dbg_assert_msg_(WII_IPC_ES, request.io_vectors.size() == 1, + _dbg_assert_msg_(IOS_ES, request.in_vectors.size() == 1, "IOCTL_ES_GETTITLES has an in buffer"); + _dbg_assert_msg_(IOS_ES, request.io_vectors.size() == 1, "IOCTL_ES_GETTITLES has no out buffer"); u32 MaxCount = Memory::Read_U32(request.in_vectors[0].address); @@ -688,24 +684,22 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) for (int i = 0; i < (int)m_TitleIDs.size(); i++) { Memory::Write_U64(m_TitleIDs[i], request.io_vectors[0].address + i * 8); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETTITLES: %08x/%08x", (u32)(m_TitleIDs[i] >> 32), + INFO_LOG(IOS_ES, "IOCTL_ES_GETTITLES: %08x/%08x", (u32)(m_TitleIDs[i] >> 32), (u32)m_TitleIDs[i]); Count++; if (Count >= MaxCount) break; } - INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETTITLES: Number of titles returned %i", Count); + INFO_LOG(IOS_ES, "IOCTL_ES_GETTITLES: Number of titles returned %i", Count); return GetDefaultReply(IPC_SUCCESS); } break; case IOCTL_ES_GETVIEWCNT: { - _dbg_assert_msg_(WII_IPC_ES, request.in_vectors.size() == 1, - "IOCTL_ES_GETVIEWCNT no in buffer"); - _dbg_assert_msg_(WII_IPC_ES, request.io_vectors.size() == 1, - "IOCTL_ES_GETVIEWCNT no out buffer"); + _dbg_assert_msg_(IOS_ES, request.in_vectors.size() == 1, "IOCTL_ES_GETVIEWCNT no in buffer"); + _dbg_assert_msg_(IOS_ES, request.io_vectors.size() == 1, "IOCTL_ES_GETVIEWCNT no out buffer"); u64 TitleID = Memory::Read_U64(request.in_vectors[0].address); @@ -720,11 +714,11 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) if (File::Exists(TicketFilename)) { u32 FileSize = (u32)File::GetSize(TicketFilename); - _dbg_assert_msg_(WII_IPC_ES, (FileSize % DiscIO::CNANDContentLoader::TICKET_SIZE) == 0, + _dbg_assert_msg_(IOS_ES, (FileSize % DiscIO::CNANDContentLoader::TICKET_SIZE) == 0, "IOCTL_ES_GETVIEWCNT ticket file size seems to be wrong"); ViewCount = FileSize / DiscIO::CNANDContentLoader::TICKET_SIZE; - _dbg_assert_msg_(WII_IPC_ES, (ViewCount > 0) && (ViewCount <= 4), + _dbg_assert_msg_(IOS_ES, (ViewCount > 0) && (ViewCount <= 4), "IOCTL_ES_GETVIEWCNT ticket count seems to be wrong"); } else if (TitleID >> 32 == 0x00000001) @@ -744,7 +738,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) } } - INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETVIEWCNT for titleID: %08x/%08x (View Count = %i)", + INFO_LOG(IOS_ES, "IOCTL_ES_GETVIEWCNT for titleID: %08x/%08x (View Count = %i)", (u32)(TitleID >> 32), (u32)TitleID, ViewCount); Memory::Write_U32(ViewCount, request.io_vectors[0].address); @@ -754,8 +748,8 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) case IOCTL_ES_GETVIEWS: { - _dbg_assert_msg_(WII_IPC_ES, request.in_vectors.size() == 2, "IOCTL_ES_GETVIEWS no in buffer"); - _dbg_assert_msg_(WII_IPC_ES, request.io_vectors.size() == 1, "IOCTL_ES_GETVIEWS no out buffer"); + _dbg_assert_msg_(IOS_ES, request.in_vectors.size() == 2, "IOCTL_ES_GETVIEWS no in buffer"); + _dbg_assert_msg_(IOS_ES, request.io_vectors.size() == 1, "IOCTL_ES_GETVIEWS no out buffer"); u64 TitleID = Memory::Read_U64(request.in_vectors[0].address); u32 maxViews = Memory::Read_U32(request.in_vectors[1].address); @@ -817,7 +811,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) } } - INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETVIEWS for titleID: %08x/%08x (MaxViews = %i)", + INFO_LOG(IOS_ES, "IOCTL_ES_GETVIEWS for titleID: %08x/%08x (MaxViews = %i)", (u32)(TitleID >> 32), (u32)TitleID, maxViews); return GetDefaultReply(retVal); @@ -826,9 +820,8 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) case IOCTL_ES_GETTMDVIEWCNT: { - _dbg_assert_msg_(WII_IPC_ES, request.in_vectors.size() == 1, - "IOCTL_ES_GETTMDVIEWCNT no in buffer"); - _dbg_assert_msg_(WII_IPC_ES, request.io_vectors.size() == 1, + _dbg_assert_msg_(IOS_ES, request.in_vectors.size() == 1, "IOCTL_ES_GETTMDVIEWCNT no in buffer"); + _dbg_assert_msg_(IOS_ES, request.io_vectors.size() == 1, "IOCTL_ES_GETTMDVIEWCNT no out buffer"); u64 TitleID = Memory::Read_U64(request.in_vectors[0].address); @@ -846,7 +839,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) } Memory::Write_U32(TMDViewCnt, request.io_vectors[0].address); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETTMDVIEWCNT: title: %08x/%08x (view size %i)", + INFO_LOG(IOS_ES, "IOCTL_ES_GETTMDVIEWCNT: title: %08x/%08x (view size %i)", (u32)(TitleID >> 32), (u32)TitleID, TMDViewCnt); return GetDefaultReply(IPC_SUCCESS); } @@ -854,9 +847,8 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) case IOCTL_ES_GETTMDVIEWS: { - _dbg_assert_msg_(WII_IPC_ES, request.in_vectors.size() == 2, - "IOCTL_ES_GETTMDVIEWCNT no in buffer"); - _dbg_assert_msg_(WII_IPC_ES, request.io_vectors.size() == 1, + _dbg_assert_msg_(IOS_ES, request.in_vectors.size() == 2, "IOCTL_ES_GETTMDVIEWCNT no in buffer"); + _dbg_assert_msg_(IOS_ES, request.io_vectors.size() == 1, "IOCTL_ES_GETTMDVIEWCNT no out buffer"); u64 TitleID = Memory::Read_U64(request.in_vectors[0].address); @@ -864,7 +856,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) const DiscIO::CNANDContentLoader& Loader = AccessContentDevice(TitleID); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETTMDVIEWCNT: title: %08x/%08x buffer size: %i", + INFO_LOG(IOS_ES, "IOCTL_ES_GETTMDVIEWCNT: title: %08x/%08x buffer size: %i", (u32)(TitleID >> 32), (u32)TitleID, MaxCount); if (Loader.IsValid()) @@ -892,11 +884,10 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) Address += 8; } - _dbg_assert_(WII_IPC_ES, - (Address - request.io_vectors[0].address) == request.io_vectors[0].size); + _dbg_assert_(IOS_ES, (Address - request.io_vectors[0].address) == request.io_vectors[0].size); } - INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETTMDVIEWS: title: %08x/%08x (buffer size: %i)", + INFO_LOG(IOS_ES, "IOCTL_ES_GETTMDVIEWS: title: %08x/%08x (buffer size: %i)", (u32)(TitleID >> 32), (u32)TitleID, MaxCount); return GetDefaultReply(IPC_SUCCESS); } @@ -904,14 +895,13 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) case IOCTL_ES_GETCONSUMPTION: // This is at least what crediar's ES module does Memory::Write_U32(0, request.io_vectors[1].address); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETCONSUMPTION"); + INFO_LOG(IOS_ES, "IOCTL_ES_GETCONSUMPTION"); return GetDefaultReply(IPC_SUCCESS); case IOCTL_ES_DELETETICKET: { u64 TitleID = Memory::Read_U64(request.in_vectors[0].address); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_DELETETICKET: title: %08x/%08x", (u32)(TitleID >> 32), - (u32)TitleID); + INFO_LOG(IOS_ES, "IOCTL_ES_DELETETICKET: title: %08x/%08x", (u32)(TitleID >> 32), (u32)TitleID); // Presumably return -1017 when delete fails if (!File::Delete(Common::GetTicketFileName(TitleID, Common::FROM_SESSION_ROOT))) return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT); @@ -921,7 +911,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) case IOCTL_ES_DELETETITLECONTENT: { u64 TitleID = Memory::Read_U64(request.in_vectors[0].address); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_DELETETITLECONTENT: title: %08x/%08x", (u32)(TitleID >> 32), + INFO_LOG(IOS_ES, "IOCTL_ES_DELETETITLECONTENT: title: %08x/%08x", (u32)(TitleID >> 32), (u32)TitleID); // Presumably return -1017 when title not installed TODO verify if (!DiscIO::CNANDContentManager::Access().RemoveTitle(TitleID, Common::FROM_SESSION_ROOT)) @@ -931,15 +921,15 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) case IOCTL_ES_GETSTOREDTMDSIZE: { - _dbg_assert_msg_(WII_IPC_ES, request.in_vectors.size() == 1, + _dbg_assert_msg_(IOS_ES, request.in_vectors.size() == 1, "IOCTL_ES_GETSTOREDTMDSIZE no in buffer"); - // _dbg_assert_msg_(WII_IPC_ES, request.io_vectors.size() == 1, "IOCTL_ES_ES_GETSTOREDTMDSIZE + // _dbg_assert_msg_(IOS_ES, request.io_vectors.size() == 1, "IOCTL_ES_ES_GETSTOREDTMDSIZE // no out buffer"); u64 TitleID = Memory::Read_U64(request.in_vectors[0].address); const DiscIO::CNANDContentLoader& Loader = AccessContentDevice(TitleID); - _dbg_assert_(WII_IPC_ES, Loader.IsValid()); + _dbg_assert_(IOS_ES, Loader.IsValid()); u32 TMDCnt = 0; if (Loader.IsValid()) { @@ -949,19 +939,18 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) if (request.io_vectors.size()) Memory::Write_U32(TMDCnt, request.io_vectors[0].address); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETSTOREDTMDSIZE: title: %08x/%08x (view size %i)", + INFO_LOG(IOS_ES, "IOCTL_ES_GETSTOREDTMDSIZE: title: %08x/%08x (view size %i)", (u32)(TitleID >> 32), (u32)TitleID, TMDCnt); return GetDefaultReply(IPC_SUCCESS); } break; case IOCTL_ES_GETSTOREDTMD: { - _dbg_assert_msg_(WII_IPC_ES, request.in_vectors.size() > 0, - "IOCTL_ES_GETSTOREDTMD no in buffer"); + _dbg_assert_msg_(IOS_ES, request.in_vectors.size() > 0, "IOCTL_ES_GETSTOREDTMD no in buffer"); // requires 1 inbuffer and no outbuffer, presumably outbuffer required when second inbuffer is // used for maxcount (allocated mem?) // called with 1 inbuffer after deleting a titleid - //_dbg_assert_msg_(WII_IPC_ES, request.io_vectors.size() == 1, "IOCTL_ES_GETSTOREDTMD no out + //_dbg_assert_msg_(IOS_ES, request.io_vectors.size() == 1, "IOCTL_ES_GETSTOREDTMD no out // buffer"); u64 TitleID = Memory::Read_U64(request.in_vectors[0].address); @@ -973,7 +962,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) } const DiscIO::CNANDContentLoader& Loader = AccessContentDevice(TitleID); - INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETSTOREDTMD: title: %08x/%08x buffer size: %i", + INFO_LOG(IOS_ES, "IOCTL_ES_GETSTOREDTMD: title: %08x/%08x buffer size: %i", (u32)(TitleID >> 32), (u32)TitleID, MaxCount); if (Loader.IsValid() && request.io_vectors.size()) @@ -992,11 +981,10 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) Address += DiscIO::CNANDContentLoader::CONTENT_HEADER_SIZE; } - _dbg_assert_(WII_IPC_ES, - (Address - request.io_vectors[0].address) == request.io_vectors[0].size); + _dbg_assert_(IOS_ES, (Address - request.io_vectors[0].address) == request.io_vectors[0].size); } - INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETSTOREDTMD: title: %08x/%08x (buffer size: %i)", + INFO_LOG(IOS_ES, "IOCTL_ES_GETSTOREDTMD: title: %08x/%08x (buffer size: %i)", (u32)(TitleID >> 32), (u32)TitleID, MaxCount); return GetDefaultReply(IPC_SUCCESS); } @@ -1016,7 +1004,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) memcpy(newIV, IV, 16); mbedtls_aes_crypt_cbc(&AES_ctx, MBEDTLS_AES_ENCRYPT, size, newIV, source, destination); - _dbg_assert_msg_(WII_IPC_ES, keyIndex == 6, + _dbg_assert_msg_(IOS_ES, keyIndex == 6, "IOCTL_ES_ENCRYPT: Key type is not SD, data will be crap"); } break; @@ -1032,14 +1020,14 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) DecryptContent(keyIndex, IV, source, size, newIV, destination); - _dbg_assert_msg_(WII_IPC_ES, keyIndex == 6, + _dbg_assert_msg_(IOS_ES, keyIndex == 6, "IOCTL_ES_DECRYPT: Key type is not SD, data will be crap"); } break; case IOCTL_ES_LAUNCH: { - _dbg_assert_(WII_IPC_ES, request.in_vectors.size() == 2); + _dbg_assert_(IOS_ES, request.in_vectors.size() == 2); bool bSuccess = false; bool bReset = false; u16 IOSv = 0xffff; @@ -1113,7 +1101,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 +1111,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]) @@ -1153,8 +1141,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) // Note: If we just reset the PPC, don't write anything to the command buffer. This // could clobber the DOL we just loaded. - ERROR_LOG(WII_IPC_ES, - "IOCTL_ES_LAUNCH %016" PRIx64 " %08x %016" PRIx64 " %08x %016" PRIx64 " %04x", + ERROR_LOG(IOS_ES, "IOCTL_ES_LAUNCH %016" PRIx64 " %08x %016" PRIx64 " %08x %016" PRIx64 " %04x", TitleID, view, ticketid, devicetype, titleid, access); // IOCTL_ES_LAUNCH 0001000248414341 00000001 0001c0fef3df2cfa 00000000 // 0001000248414341 ffff @@ -1181,13 +1168,13 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) // IOS70 has this to let system menu 4.2 check if the console is region changed. it returns // -1017 // if the IOS didn't find the Korean keys and 0 if it does. 0 leads to a error 003 - INFO_LOG(WII_IPC_ES, "IOCTL_ES_CHECKKOREAREGION: Title checked for Korean keys."); + INFO_LOG(IOS_ES, "IOCTL_ES_CHECKKOREAREGION: Title checked for Korean keys."); return GetDefaultReply(ES_PARAMETER_SIZE_OR_ALIGNMENT); case IOCTL_ES_GETDEVICECERT: // (Input: none, Output: 384 bytes) { - INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETDEVICECERT"); - _dbg_assert_(WII_IPC_ES, request.io_vectors.size() == 1); + INFO_LOG(IOS_ES, "IOCTL_ES_GETDEVICECERT"); + _dbg_assert_(IOS_ES, request.io_vectors.size() == 1); u8* destination = Memory::GetPointer(request.io_vectors[0].address); EcWii& ec = EcWii::GetInstance(); @@ -1197,7 +1184,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) case IOCTL_ES_SIGN: { - INFO_LOG(WII_IPC_ES, "IOCTL_ES_SIGN"); + INFO_LOG(IOS_ES, "IOCTL_ES_SIGN"); u8* ap_cert_out = Memory::GetPointer(request.io_vectors[1].address); u8* data = Memory::GetPointer(request.in_vectors[0].address); u32 data_size = request.in_vectors[0].size; @@ -1211,7 +1198,7 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) case IOCTL_ES_GETBOOT2VERSION: { - INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETBOOT2VERSION"); + INFO_LOG(IOS_ES, "IOCTL_ES_GETBOOT2VERSION"); Memory::Write_U32( 4, request.io_vectors[0].address); // as of 26/02/2012, this was latest bootmii version @@ -1222,22 +1209,22 @@ IPCCommandResult CWII_IPC_HLE_Device_es::IOCtlV(const IOSIOCtlVRequest& request) // unsupported functions // =============================================================================================== case IOCTL_ES_DIGETTICKETVIEW: // (Input: none, Output: 216 bytes) bug crediar :D - WARN_LOG(WII_IPC_ES, "IOCTL_ES_DIGETTICKETVIEW: this looks really wrong..."); + WARN_LOG(IOS_ES, "IOCTL_ES_DIGETTICKETVIEW: this looks really wrong..."); break; case IOCTL_ES_GETOWNEDTITLECNT: - INFO_LOG(WII_IPC_ES, "IOCTL_ES_GETOWNEDTITLECNT"); + INFO_LOG(IOS_ES, "IOCTL_ES_GETOWNEDTITLECNT"); Memory::Write_U32(0, request.io_vectors[0].address); break; default: - request.DumpUnknown(GetDeviceName(), LogTypes::WII_IPC_HLE); + request.DumpUnknown(GetDeviceName(), LogTypes::IOS); } 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 +1238,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& tmd) +u32 ES::ES_DIVerify(const std::vector& tmd) { u64 title_id = 0xDEADBEEFDEADBEEFull; u64 tmd_title_id = Common::swap64(&tmd[0x18C]); @@ -1315,7 +1302,7 @@ u32 CWII_IPC_HLE_Device_es::ES_DIVerify(const std::vector& tmd) { File::IOFile tmd_file(tmd_path, "wb"); if (!tmd_file.WriteBytes(tmd.data(), tmd.size())) - ERROR_LOG(WII_IPC_ES, "DIVerify failed to write disc TMD to NAND."); + ERROR_LOG(IOS_ES, "DIVerify failed to write disc TMD to NAND."); } DiscIO::cUIDsys::AccessInstance().AddTitle(tmd_title_id); // DI_VERIFY writes to title.tmd, which is read and cached inside the NAND Content Manager. @@ -1323,5 +1310,6 @@ u32 CWII_IPC_HLE_Device_es::ES_DIVerify(const std::vector& tmd) DiscIO::CNANDContentManager::Access().ClearCache(); return 0; } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.h b/Source/Core/Core/IOS/ES/ES.h similarity index 94% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.h rename to Source/Core/Core/IOS/ES/ES.h index 61fedff948..1f2ccfe111 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_es.h +++ b/Source/Core/Core/IOS/ES/ES.h @@ -10,9 +10,9 @@ #include #include "Common/CommonTypes.h" -#include "Core/IPC_HLE/ESFormats.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device.h" +#include "Core/IOS/Device.h" +#include "Core/IOS/ES/Formats.h" +#include "Core/IOS/IPC.h" class PointerWrap; @@ -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 diff --git a/Source/Core/Core/IPC_HLE/ESFormats.cpp b/Source/Core/Core/IOS/ES/Formats.cpp similarity index 98% rename from Source/Core/Core/IPC_HLE/ESFormats.cpp rename to Source/Core/Core/IOS/ES/Formats.cpp index a2e24d755a..8e0879ef87 100644 --- a/Source/Core/Core/IPC_HLE/ESFormats.cpp +++ b/Source/Core/Core/IOS/ES/Formats.cpp @@ -2,7 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include "Core/IPC_HLE/ESFormats.h" +#include "Core/IOS/ES/Formats.h" #include #include diff --git a/Source/Core/Core/IPC_HLE/ESFormats.h b/Source/Core/Core/IOS/ES/Formats.h similarity index 100% rename from Source/Core/Core/IPC_HLE/ESFormats.h rename to Source/Core/Core/IOS/ES/Formats.h diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_fs.cpp b/Source/Core/Core/IOS/FS/FS.cpp similarity index 74% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_fs.cpp rename to Source/Core/Core/IOS/FS/FS.cpp index 79e9fdd4e1..1c8d4a3343 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_fs.cpp +++ b/Source/Core/Core/IOS/FS/FS.cpp @@ -19,8 +19,8 @@ #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" +#include "Core/IOS/FS/FS.h" +#include "Core/IOS/FS/FileIO.h" namespace IOS { @@ -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) @@ -83,7 +84,7 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(const IOSIOCtlVRequest& request) if (!IsValidWiiPath(relative_path)) { - WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", relative_path.c_str()); + WARN_LOG(IOS_FILEIO, "Not a valid path: %s", relative_path.c_str()); return_value = FS_EINVAL; break; } @@ -91,11 +92,11 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(const IOSIOCtlVRequest& request) // the Wii uses this function to define the type (dir or file) std::string DirName(HLE_IPC_BuildFilename(relative_path)); - INFO_LOG(WII_IPC_FILEIO, "FS: IOCTL_READ_DIR %s", DirName.c_str()); + INFO_LOG(IOS_FILEIO, "FS: IOCTL_READ_DIR %s", DirName.c_str()); if (!File::Exists(DirName)) { - WARN_LOG(WII_IPC_FILEIO, "FS: Search not found: %s", DirName.c_str()); + WARN_LOG(IOS_FILEIO, "FS: Search not found: %s", DirName.c_str()); return_value = FS_ENOENT; break; } @@ -104,7 +105,7 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(const IOSIOCtlVRequest& request) // It's not a directory, so error. // Games don't usually seem to care WHICH error they get, as long as it's < // Well the system menu CARES! - WARN_LOG(WII_IPC_FILEIO, "\tNot a directory - return FS_EINVAL"); + WARN_LOG(IOS_FILEIO, "\tNot a directory - return FS_EINVAL"); return_value = FS_EINVAL; break; } @@ -115,7 +116,7 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(const IOSIOCtlVRequest& request) if ((request.in_vectors.size() == 1) && (request.io_vectors.size() == 1)) { size_t numFile = entry.children.size(); - INFO_LOG(WII_IPC_FILEIO, "\t%zu files found", numFile); + INFO_LOG(IOS_FILEIO, "\t%zu files found", numFile); Memory::Write_U32((u32)numFile, request.io_vectors[0].address); } @@ -149,7 +150,7 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(const IOSIOCtlVRequest& request) *pFilename++ = 0x00; // termination numFiles++; - INFO_LOG(WII_IPC_FILEIO, "\tFound: %s", FileName.c_str()); + INFO_LOG(IOS_FILEIO, "\tFound: %s", FileName.c_str()); } Memory::Write_U32((u32)numFiles, request.io_vectors[1].address); @@ -161,9 +162,9 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(const IOSIOCtlVRequest& request) case IOCTLV_GETUSAGE: { - _dbg_assert_(WII_IPC_FILEIO, request.io_vectors.size() == 2); - _dbg_assert_(WII_IPC_FILEIO, request.io_vectors[0].size == 4); - _dbg_assert_(WII_IPC_FILEIO, request.io_vectors[1].size == 4); + _dbg_assert_(IOS_FILEIO, request.io_vectors.size() == 2); + _dbg_assert_(IOS_FILEIO, request.io_vectors[0].size == 4); + _dbg_assert_(IOS_FILEIO, request.io_vectors[1].size == 4); // this command sucks because it asks of the number of used // fsBlocks and inodes @@ -173,7 +174,7 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(const IOSIOCtlVRequest& request) if (!IsValidWiiPath(relativepath)) { - WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", relativepath.c_str()); + WARN_LOG(IOS_FILEIO, "Not a valid path: %s", relativepath.c_str()); return_value = FS_EINVAL; break; } @@ -182,7 +183,7 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(const IOSIOCtlVRequest& request) u32 fsBlocks = 0; u32 iNodes = 0; - INFO_LOG(WII_IPC_FILEIO, "IOCTL_GETUSAGE %s", path.c_str()); + INFO_LOG(IOS_FILEIO, "IOCTL_GETUSAGE %s", path.c_str()); if (File::IsDirectory(path)) { // LPFaint99: After I found that setting the number of inodes to the number of children + 1 @@ -208,14 +209,14 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(const IOSIOCtlVRequest& request) } return_value = IPC_SUCCESS; - INFO_LOG(WII_IPC_FILEIO, "FS: fsBlock: %i, iNodes: %i", fsBlocks, iNodes); + INFO_LOG(IOS_FILEIO, "FS: fsBlock: %i, iNodes: %i", fsBlocks, iNodes); } else { fsBlocks = 0; iNodes = 0; return_value = IPC_SUCCESS; - WARN_LOG(WII_IPC_FILEIO, "FS: fsBlock failed, cannot find directory: %s", path.c_str()); + WARN_LOG(IOS_FILEIO, "FS: fsBlock failed, cannot find directory: %s", path.c_str()); } Memory::Write_U32(fsBlocks, request.io_vectors[0].address); @@ -224,21 +225,21 @@ IPCCommandResult CWII_IPC_HLE_Device_fs::IOCtlV(const IOSIOCtlVRequest& request) break; default: - request.DumpUnknown(GetDeviceName(), LogTypes::WII_IPC_FILEIO); + request.DumpUnknown(GetDeviceName(), LogTypes::IOS_FILEIO); break; } 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) { @@ -247,7 +248,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(const IOSIOCtlRequest& request) if (request.buffer_out_size < 0x1c) return -1017; - WARN_LOG(WII_IPC_FILEIO, "FS: GET STATS - returning static values for now"); + WARN_LOG(IOS_FILEIO, "FS: GET STATS - returning static values for now"); NANDStat fs; @@ -268,7 +269,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(const IOSIOCtlRequest& request) case IOCTL_CREATE_DIR: { - _dbg_assert_(WII_IPC_FILEIO, request.buffer_out_size == 0); + _dbg_assert_(IOS_FILEIO, request.buffer_out_size == 0); u32 Addr = request.buffer_in; u32 OwnerID = Memory::Read_U32(Addr); @@ -278,7 +279,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(const IOSIOCtlRequest& request) const std::string wii_path = Memory::GetString(Addr, 64); if (!IsValidWiiPath(wii_path)) { - WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", wii_path.c_str()); + WARN_LOG(IOS_FILEIO, "Not a valid path: %s", wii_path.c_str()); return FS_EINVAL; } std::string DirName(HLE_IPC_BuildFilename(wii_path)); @@ -286,12 +287,12 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(const IOSIOCtlRequest& request) Addr += 9; // owner attribs, permission u8 Attribs = Memory::Read_U8(Addr); - INFO_LOG(WII_IPC_FILEIO, "FS: CREATE_DIR %s, OwnerID %#x, GroupID %#x, Attributes %#x", + INFO_LOG(IOS_FILEIO, "FS: CREATE_DIR %s, OwnerID %#x, GroupID %#x, Attributes %#x", DirName.c_str(), OwnerID, GroupID, Attribs); DirName += DIR_SEP; File::CreateFullPath(DirName); - _dbg_assert_msg_(WII_IPC_FILEIO, File::IsDirectory(DirName), "FS: CREATE_DIR %s failed", + _dbg_assert_msg_(IOS_FILEIO, File::IsDirectory(DirName), "FS: CREATE_DIR %s failed", DirName.c_str()); return IPC_SUCCESS; @@ -309,7 +310,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(const IOSIOCtlRequest& request) const std::string wii_path = Memory::GetString(Addr, 64); if (!IsValidWiiPath(wii_path)) { - WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", wii_path.c_str()); + WARN_LOG(IOS_FILEIO, "Not a valid path: %s", wii_path.c_str()); return FS_EINVAL; } std::string Filename = HLE_IPC_BuildFilename(wii_path); @@ -323,13 +324,13 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(const IOSIOCtlRequest& request) u8 Attributes = Memory::Read_U8(Addr); Addr += 1; - INFO_LOG(WII_IPC_FILEIO, "FS: SetAttrib %s", Filename.c_str()); - DEBUG_LOG(WII_IPC_FILEIO, " OwnerID: 0x%08x", OwnerID); - DEBUG_LOG(WII_IPC_FILEIO, " GroupID: 0x%04x", GroupID); - DEBUG_LOG(WII_IPC_FILEIO, " OwnerPerm: 0x%02x", OwnerPerm); - DEBUG_LOG(WII_IPC_FILEIO, " GroupPerm: 0x%02x", GroupPerm); - DEBUG_LOG(WII_IPC_FILEIO, " OtherPerm: 0x%02x", OtherPerm); - DEBUG_LOG(WII_IPC_FILEIO, " Attributes: 0x%02x", Attributes); + INFO_LOG(IOS_FILEIO, "FS: SetAttrib %s", Filename.c_str()); + DEBUG_LOG(IOS_FILEIO, " OwnerID: 0x%08x", OwnerID); + DEBUG_LOG(IOS_FILEIO, " GroupID: 0x%04x", GroupID); + DEBUG_LOG(IOS_FILEIO, " OwnerPerm: 0x%02x", OwnerPerm); + DEBUG_LOG(IOS_FILEIO, " GroupPerm: 0x%02x", GroupPerm); + DEBUG_LOG(IOS_FILEIO, " OtherPerm: 0x%02x", OtherPerm); + DEBUG_LOG(IOS_FILEIO, " Attributes: 0x%02x", Attributes); return IPC_SUCCESS; } @@ -337,7 +338,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(const IOSIOCtlRequest& request) case IOCTL_GET_ATTR: { - _dbg_assert_msg_(WII_IPC_FILEIO, request.buffer_out_size == 76, + _dbg_assert_msg_(IOS_FILEIO, request.buffer_out_size == 76, " GET_ATTR needs an 76 bytes large output buffer but it is %i bytes large", request.buffer_out_size); @@ -347,7 +348,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(const IOSIOCtlRequest& request) const std::string wii_path = Memory::GetString(request.buffer_in, 64); if (!IsValidWiiPath(wii_path)) { - WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", wii_path.c_str()); + WARN_LOG(IOS_FILEIO, "Not a valid path: %s", wii_path.c_str()); return FS_EINVAL; } std::string Filename = HLE_IPC_BuildFilename(wii_path); @@ -357,19 +358,18 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(const IOSIOCtlRequest& request) u8 Attributes = 0x00; // no attributes if (File::IsDirectory(Filename)) { - INFO_LOG(WII_IPC_FILEIO, "FS: GET_ATTR Directory %s - all permission flags are set", + INFO_LOG(IOS_FILEIO, "FS: GET_ATTR Directory %s - all permission flags are set", Filename.c_str()); } else { if (File::Exists(Filename)) { - INFO_LOG(WII_IPC_FILEIO, "FS: GET_ATTR %s - all permission flags are set", - Filename.c_str()); + INFO_LOG(IOS_FILEIO, "FS: GET_ATTR %s - all permission flags are set", Filename.c_str()); } else { - INFO_LOG(WII_IPC_FILEIO, "FS: GET_ATTR unknown %s", Filename.c_str()); + INFO_LOG(IOS_FILEIO, "FS: GET_ATTR unknown %s", Filename.c_str()); return FS_ENOENT; } } @@ -400,28 +400,28 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(const IOSIOCtlRequest& request) case IOCTL_DELETE_FILE: { - _dbg_assert_(WII_IPC_FILEIO, request.buffer_out_size == 0); + _dbg_assert_(IOS_FILEIO, request.buffer_out_size == 0); int Offset = 0; const std::string wii_path = Memory::GetString(request.buffer_in + Offset, 64); if (!IsValidWiiPath(wii_path)) { - WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", wii_path.c_str()); + WARN_LOG(IOS_FILEIO, "Not a valid path: %s", wii_path.c_str()); return FS_EINVAL; } std::string Filename = HLE_IPC_BuildFilename(wii_path); Offset += 64; if (File::Delete(Filename)) { - INFO_LOG(WII_IPC_FILEIO, "FS: DeleteFile %s", Filename.c_str()); + INFO_LOG(IOS_FILEIO, "FS: DeleteFile %s", Filename.c_str()); } else if (File::DeleteDir(Filename)) { - INFO_LOG(WII_IPC_FILEIO, "FS: DeleteDir %s", Filename.c_str()); + INFO_LOG(IOS_FILEIO, "FS: DeleteDir %s", Filename.c_str()); } else { - WARN_LOG(WII_IPC_FILEIO, "FS: DeleteFile %s - failed!!!", Filename.c_str()); + WARN_LOG(IOS_FILEIO, "FS: DeleteFile %s - failed!!!", Filename.c_str()); } return IPC_SUCCESS; @@ -430,13 +430,13 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(const IOSIOCtlRequest& request) case IOCTL_RENAME_FILE: { - _dbg_assert_(WII_IPC_FILEIO, request.buffer_out_size == 0); + _dbg_assert_(IOS_FILEIO, request.buffer_out_size == 0); int Offset = 0; const std::string wii_path = Memory::GetString(request.buffer_in + Offset, 64); if (!IsValidWiiPath(wii_path)) { - WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", wii_path.c_str()); + WARN_LOG(IOS_FILEIO, "Not a valid path: %s", wii_path.c_str()); return FS_EINVAL; } std::string Filename = HLE_IPC_BuildFilename(wii_path); @@ -445,7 +445,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(const IOSIOCtlRequest& request) const std::string wii_path_rename = Memory::GetString(request.buffer_in + Offset, 64); if (!IsValidWiiPath(wii_path_rename)) { - WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", wii_path_rename.c_str()); + WARN_LOG(IOS_FILEIO, "Not a valid path: %s", wii_path_rename.c_str()); return FS_EINVAL; } std::string FilenameRename = HLE_IPC_BuildFilename(wii_path_rename); @@ -463,11 +463,11 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(const IOSIOCtlRequest& request) // finally try to rename the file if (File::Rename(Filename, FilenameRename)) { - INFO_LOG(WII_IPC_FILEIO, "FS: Rename %s to %s", Filename.c_str(), FilenameRename.c_str()); + INFO_LOG(IOS_FILEIO, "FS: Rename %s to %s", Filename.c_str(), FilenameRename.c_str()); } else { - ERROR_LOG(WII_IPC_FILEIO, "FS: Rename %s to %s - failed", Filename.c_str(), + ERROR_LOG(IOS_FILEIO, "FS: Rename %s to %s - failed", Filename.c_str(), FilenameRename.c_str()); return FS_ENOENT; } @@ -478,7 +478,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(const IOSIOCtlRequest& request) case IOCTL_CREATE_FILE: { - _dbg_assert_(WII_IPC_FILEIO, request.buffer_out_size == 0); + _dbg_assert_(IOS_FILEIO, request.buffer_out_size == 0); u32 Addr = request.buffer_in; u32 OwnerID = Memory::Read_U32(Addr); @@ -488,7 +488,7 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(const IOSIOCtlRequest& request) const std::string wii_path = Memory::GetString(Addr, 64); if (!IsValidWiiPath(wii_path)) { - WARN_LOG(WII_IPC_FILEIO, "Not a valid path: %s", wii_path.c_str()); + WARN_LOG(IOS_FILEIO, "Not a valid path: %s", wii_path.c_str()); return FS_EINVAL; } std::string Filename(HLE_IPC_BuildFilename(wii_path)); @@ -502,18 +502,18 @@ s32 CWII_IPC_HLE_Device_fs::ExecuteCommand(const IOSIOCtlRequest& request) u8 Attributes = Memory::Read_U8(Addr); Addr++; - INFO_LOG(WII_IPC_FILEIO, "FS: CreateFile %s", Filename.c_str()); - DEBUG_LOG(WII_IPC_FILEIO, " OwnerID: 0x%08x", OwnerID); - DEBUG_LOG(WII_IPC_FILEIO, " GroupID: 0x%04x", GroupID); - DEBUG_LOG(WII_IPC_FILEIO, " OwnerPerm: 0x%02x", OwnerPerm); - DEBUG_LOG(WII_IPC_FILEIO, " GroupPerm: 0x%02x", GroupPerm); - DEBUG_LOG(WII_IPC_FILEIO, " OtherPerm: 0x%02x", OtherPerm); - DEBUG_LOG(WII_IPC_FILEIO, " Attributes: 0x%02x", Attributes); + INFO_LOG(IOS_FILEIO, "FS: CreateFile %s", Filename.c_str()); + DEBUG_LOG(IOS_FILEIO, " OwnerID: 0x%08x", OwnerID); + DEBUG_LOG(IOS_FILEIO, " GroupID: 0x%04x", GroupID); + DEBUG_LOG(IOS_FILEIO, " OwnerPerm: 0x%02x", OwnerPerm); + DEBUG_LOG(IOS_FILEIO, " GroupPerm: 0x%02x", GroupPerm); + DEBUG_LOG(IOS_FILEIO, " OtherPerm: 0x%02x", OtherPerm); + DEBUG_LOG(IOS_FILEIO, " Attributes: 0x%02x", Attributes); // check if the file already exist if (File::Exists(Filename)) { - INFO_LOG(WII_IPC_FILEIO, "\tresult = FS_EEXIST"); + INFO_LOG(IOS_FILEIO, "\tresult = FS_EEXIST"); return FS_EEXIST; } @@ -522,29 +522,29 @@ 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(IOS_FILEIO, "FS: couldn't create new file"); + PanicAlert("FS: couldn't create new file"); return FS_EINVAL; } - INFO_LOG(WII_IPC_FILEIO, "\tresult = IPC_SUCCESS"); + INFO_LOG(IOS_FILEIO, "\tresult = IPC_SUCCESS"); return IPC_SUCCESS; } break; case IOCTL_SHUTDOWN: { - INFO_LOG(WII_IPC_FILEIO, "Wii called Shutdown()"); + INFO_LOG(IOS_FILEIO, "Wii called Shutdown()"); // TODO: stop emulation } break; default: - request.DumpUnknown(GetDeviceName(), LogTypes::WII_IPC_FILEIO); + request.DumpUnknown(GetDeviceName(), LogTypes::IOS_FILEIO); } return FS_EINVAL; } -void CWII_IPC_HLE_Device_fs::DoState(PointerWrap& p) +void FS::DoState(PointerWrap& p) { DoStateShared(p); @@ -638,5 +638,6 @@ void CWII_IPC_HLE_Device_fs::DoState(PointerWrap& p) p.Do(type); } } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_fs.h b/Source/Core/Core/IOS/FS/FS.h similarity index 83% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_fs.h rename to Source/Core/Core/IOS/FS/FS.h index 0b25f85f7a..fb7bd8f0be 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_fs.h +++ b/Source/Core/Core/IOS/FS/FS.h @@ -7,8 +7,8 @@ #include #include "Common/CommonTypes.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device.h" +#include "Core/IOS/Device.h" +#include "Core/IOS/IPC.h" class PointerWrap; @@ -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 diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp b/Source/Core/Core/IOS/FS/FileIO.cpp similarity index 76% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp rename to Source/Core/Core/IOS/FS/FileIO.cpp index 6d428c594d..941dcce8b4 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp +++ b/Source/Core/Core/IOS/FS/FileIO.cpp @@ -14,8 +14,8 @@ #include "Common/FileUtil.h" #include "Common/NandPaths.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/IOS/FS/FileIO.h" +#include "Core/IOS/IPC.h" namespace IOS { @@ -69,15 +69,16 @@ 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); + INFO_LOG(IOS_FILEIO, "FileIO: Close %s (DeviceID=%08x)", m_name.c_str(), m_device_id); m_Mode = 0; // Let go of our pointer to the file, it will automatically close if we are the last handle @@ -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; @@ -99,12 +100,12 @@ IOSReturnCode CWII_IPC_HLE_Device_FileIO::Open(const IOSOpenRequest& request) // It should be created by ISFS_CreateFile, not here if (!File::Exists(m_filepath) || File::IsDirectory(m_filepath)) { - WARN_LOG(WII_IPC_FILEIO, "FileIO: Open (%s) failed - File doesn't exist %s", Modes[m_Mode], + WARN_LOG(IOS_FILEIO, "FileIO: Open (%s) failed - File doesn't exist %s", Modes[m_Mode], m_filepath.c_str()); return FS_ENOENT; } - INFO_LOG(WII_IPC_FILEIO, "FileIO: Open %s (%s == %08X)", m_name.c_str(), Modes[m_Mode], m_Mode); + INFO_LOG(IOS_FILEIO, "FileIO: Open %s (%s == %08X)", m_name.c_str(), Modes[m_Mode], m_Mode); OpenFile(); m_is_active = true; @@ -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,15 +156,15 @@ 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; if (m_file->IsOpen()) { const u32 file_size = static_cast(m_file->GetSize()); - DEBUG_LOG(WII_IPC_FILEIO, "FileIO: Seek Pos: 0x%08x, Mode: %i (%s, Length=0x%08x)", - request.offset, request.mode, m_name.c_str(), file_size); + DEBUG_LOG(IOS_FILEIO, "FileIO: Seek Pos: 0x%08x, Mode: %i (%s, Length=0x%08x)", request.offset, + request.mode, m_name.c_str(), file_size); switch (request.mode) { @@ -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,20 +215,19 @@ 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()) { if (m_Mode == IOS_OPEN_WRITE) { - WARN_LOG(WII_IPC_FILEIO, - "FileIO: Attempted to read 0x%x bytes to 0x%08x on a write-only file %s", + WARN_LOG(IOS_FILEIO, "FileIO: Attempted to read 0x%x bytes to 0x%08x on a write-only file %s", request.size, request.buffer, m_name.c_str()); } else { - DEBUG_LOG(WII_IPC_FILEIO, "FileIO: Read 0x%x bytes to 0x%08x from %s", request.size, + DEBUG_LOG(IOS_FILEIO, "FileIO: Read 0x%x bytes to 0x%08x from %s", request.size, request.buffer, m_name.c_str()); m_file->Seek(m_SeekPos, SEEK_SET); // File might be opened twice, need to seek before we read return_value = static_cast( @@ -244,8 +244,8 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Read(const IOSReadWriteRequest& req } else { - ERROR_LOG(WII_IPC_FILEIO, "FileIO: Failed to read from %s (Addr=0x%08x Size=0x%x) - file could " - "not be opened or does not exist", + ERROR_LOG(IOS_FILEIO, "FileIO: Failed to read from %s (Addr=0x%08x Size=0x%x) - file could " + "not be opened or does not exist", m_name.c_str(), request.buffer, request.size); return_value = FS_ENOENT; } @@ -253,20 +253,20 @@ 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()) { if (m_Mode == IOS_OPEN_READ) { - WARN_LOG(WII_IPC_FILEIO, + WARN_LOG(IOS_FILEIO, "FileIO: Attempted to write 0x%x bytes from 0x%08x to a read-only file %s", request.size, request.buffer, m_name.c_str()); } else { - DEBUG_LOG(WII_IPC_FILEIO, "FileIO: Write 0x%04x bytes from 0x%08x to %s", request.size, + DEBUG_LOG(IOS_FILEIO, "FileIO: Write 0x%04x bytes from 0x%08x to %s", request.size, request.buffer, m_name.c_str()); m_file->Seek(m_SeekPos, SEEK_SET); // File might be opened twice, need to seek before we write @@ -279,8 +279,8 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::Write(const IOSReadWriteRequest& re } else { - ERROR_LOG(WII_IPC_FILEIO, "FileIO: Failed to read from %s (Addr=0x%08x Size=0x%x) - file could " - "not be opened or does not exist", + ERROR_LOG(IOS_FILEIO, "FileIO: Failed to read from %s (Addr=0x%08x Size=0x%x) - file could " + "not be opened or does not exist", m_name.c_str(), request.buffer, request.size); return_value = FS_ENOENT; } @@ -288,9 +288,9 @@ 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()); + DEBUG_LOG(IOS_FILEIO, "FileIO: IOCtl (Device=%s)", m_name.c_str()); s32 return_value = IPC_SUCCESS; switch (request.request) @@ -299,7 +299,7 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::IOCtl(const IOSIOCtlRequest& reques { if (m_file->IsOpen()) { - DEBUG_LOG(WII_IPC_FILEIO, "File: %s, Length: %" PRIu64 ", Pos: %i", m_name.c_str(), + DEBUG_LOG(IOS_FILEIO, "File: %s, Length: %" PRIu64 ", Pos: %i", m_name.c_str(), m_file->GetSize(), m_SeekPos); Memory::Write_U32(static_cast(m_file->GetSize()), request.buffer_out); Memory::Write_U32(m_SeekPos, request.buffer_out + 4); @@ -312,20 +312,20 @@ IPCCommandResult CWII_IPC_HLE_Device_FileIO::IOCtl(const IOSIOCtlRequest& reques break; default: - request.Log(GetDeviceName(), LogTypes::WII_IPC_FILEIO, LogTypes::LERROR); + request.Log(GetDeviceName(), LogTypes::IOS_FILEIO, LogTypes::LERROR); } 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 +338,6 @@ void CWII_IPC_HLE_Device_FileIO::DoState(PointerWrap& p) // Open it again OpenFile(); } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.h b/Source/Core/Core/IOS/FS/FileIO.h similarity index 87% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.h rename to Source/Core/Core/IOS/FS/FileIO.h index b5039c031a..f0bb1927b3 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.h +++ b/Source/Core/Core/IOS/FS/FileIO.h @@ -8,8 +8,8 @@ #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" +#include "Core/IOS/Device.h" +#include "Core/IOS/IPC.h" class PointerWrap; @@ -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 m_file; }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp b/Source/Core/Core/IOS/IPC.cpp similarity index 68% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp rename to Source/Core/Core/IOS/IPC.cpp index b0ab9610ec..5cfa99b896 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp +++ b/Source/Core/Core/IOS/IPC.cpp @@ -33,23 +33,23 @@ #include "Core/CoreTiming.h" #include "Core/HW/Memmap.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" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_FileIO.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_es.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_fs.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_net.h" -#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" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_wfssrv.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_wfsi.h" +#include "Core/IOS/DI/DI.h" +#include "Core/IOS/Device.h" +#include "Core/IOS/DeviceStub.h" +#include "Core/IOS/ES/ES.h" +#include "Core/IOS/FS/FS.h" +#include "Core/IOS/FS/FileIO.h" +#include "Core/IOS/IPC.h" +#include "Core/IOS/Network/Net.h" +#include "Core/IOS/Network/SSL.h" +#include "Core/IOS/SDIO/SDIOSlot0.h" +#include "Core/IOS/STM/STM.h" +#include "Core/IOS/USB/Bluetooth/BTEmu.h" +#include "Core/IOS/USB/Bluetooth/BTReal.h" +#include "Core/IOS/USB/USB_KBD.h" +#include "Core/IOS/USB/USB_VEN.h" +#include "Core/IOS/WFS/WFSI.h" +#include "Core/IOS/WFS/WFSSRV.h" namespace CoreTiming { @@ -57,21 +57,21 @@ struct EventType; } // namespace CoreTiming #if defined(__LIBUSB__) -#include "Core/IPC_HLE/WII_IPC_HLE_Device_hid.h" +#include "Core/IOS/USB/USB_HIDv4.h" #endif namespace IOS { namespace HLE { -static std::map> s_device_map; +static std::map> 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 s_fdmap[IPC_MAX_FDS]; -static std::shared_ptr s_es_handles[ES_MAX_COUNT]; +static std::shared_ptr s_fdmap[IPC_MAX_FDS]; +static std::shared_ptr s_es_handles[ES_MAX_COUNT]; using IPCMsgQueue = std::deque; 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(GetDeviceByName("/dev/sdio/slot0").get()); + auto device = static_cast(GetDeviceByName("/dev/sdio/slot0").get()); if (device) device->EventNotify(); } @@ -116,7 +115,7 @@ template std::shared_ptr AddDevice(const char* device_name) { auto device = std::make_shared(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; @@ -125,44 +124,44 @@ std::shared_ptr AddDevice(const char* device_name) void Reinit() { std::lock_guard 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 = ""; + _assert_msg_(IOS, s_device_map.empty(), "Reinit called while already initialized"); + Device::ES::m_ContentFile = ""; num_devices = 0; // Build hardware devices if (!SConfig::GetInstance().m_bt_passthrough_enabled) - AddDevice("/dev/usb/oh1/57e/305"); + AddDevice("/dev/usb/oh1/57e/305"); else - AddDevice("/dev/usb/oh1/57e/305"); + AddDevice("/dev/usb/oh1/57e/305"); - AddDevice("/dev/stm/immediate"); - AddDevice("/dev/stm/eventhook"); - AddDevice("/dev/fs"); + AddDevice("/dev/stm/immediate"); + AddDevice("/dev/stm/eventhook"); + AddDevice("/dev/fs"); // IOS allows two ES devices at a time for (auto& es_device : s_es_handles) - es_device = AddDevice("/dev/es"); + es_device = AddDevice("/dev/es"); - AddDevice("/dev/di"); - AddDevice("/dev/net/kd/request"); - AddDevice("/dev/net/kd/time"); - AddDevice("/dev/net/ncd/manage"); - AddDevice("/dev/net/wd/command"); - AddDevice("/dev/net/ip/top"); - AddDevice("/dev/net/ssl"); - AddDevice("/dev/usb/kbd"); - AddDevice("/dev/usb/ven"); - AddDevice("/dev/sdio/slot0"); - AddDevice("/dev/sdio/slot1"); + AddDevice("/dev/di"); + AddDevice("/dev/net/kd/request"); + AddDevice("/dev/net/kd/time"); + AddDevice("/dev/net/ncd/manage"); + AddDevice("/dev/net/wd/command"); + AddDevice("/dev/net/ip/top"); + AddDevice("/dev/net/ssl"); + AddDevice("/dev/usb/kbd"); + AddDevice("/dev/usb/ven"); + AddDevice("/dev/sdio/slot0"); + AddDevice("/dev/sdio/slot1"); #if defined(__LIBUSB__) - AddDevice("/dev/usb/hid"); + AddDevice("/dev/usb/hid"); #else - AddDevice("/dev/usb/hid"); + AddDevice("/dev/usb/hid"); #endif - AddDevice("/dev/usb/oh1"); - AddDevice("/dev/usb/wfssrv"); - AddDevice("/dev/wfsi"); + AddDevice("/dev/usb/oh1"); + AddDevice("/dev/usb/wfssrv"); + AddDevice("/dev/wfsi"); } void Init() @@ -212,7 +211,7 @@ void SetDefaultContentFile(const std::string& file_name) void ES_DIVerify(const std::vector& 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 GetDeviceByName(const std::string& device_name) +std::shared_ptr GetDeviceByName(const std::string& device_name) { std::lock_guard lock(s_device_map_mutex); for (const auto& entry : s_device_map) @@ -250,7 +249,7 @@ std::shared_ptr GetDeviceByName(const std::string& device_n return nullptr; } -std::shared_ptr AccessDeviceByID(u32 id) +std::shared_ptr AccessDeviceByID(u32 id) { std::lock_guard 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(i, ""); + case Device::Device::DeviceType::FileIO: + s_fdmap[i] = std::make_shared(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(AccessDeviceByID(handle_id)); + es_device = std::static_pointer_cast(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 GetUnusedESDevice() +static std::shared_ptr 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(); }); @@ -353,14 +352,14 @@ static std::shared_ptr GetUnusedESDevice() static s32 OpenDevice(const IOSOpenRequest& request) { const s32 new_fd = GetFreeDeviceID(); - INFO_LOG(WII_IPC_HLE, "Opening %s (mode %d, fd %d)", request.path.c_str(), request.flags, new_fd); + INFO_LOG(IOS, "Opening %s (mode %d, fd %d)", request.path.c_str(), request.flags, new_fd); if (new_fd < 0 || new_fd >= IPC_MAX_FDS) { - ERROR_LOG(WII_IPC_HLE, "Couldn't get a free fd, too many open files"); + ERROR_LOG(IOS, "Couldn't get a free fd, too many open files"); return FS_EFDEXHAUSTED; } - std::shared_ptr device; + std::shared_ptr device; if (request.path == "/dev/es") { device = GetUnusedESDevice(); @@ -373,12 +372,12 @@ static s32 OpenDevice(const IOSOpenRequest& request) } else if (request.path.find('/') == 0) { - device = std::make_shared(new_fd, request.path); + device = std::make_shared(new_fd, request.path); } if (!device) { - ERROR_LOG(WII_IPC_HLE, "Unknown device: %s", request.path.c_str()); + ERROR_LOG(IOS, "Unknown device: %s", request.path.c_str()); return IPC_ENOENT; } @@ -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: @@ -419,8 +418,8 @@ static IPCCommandResult HandleCommand(const IOSRequest& request) case IPC_CMD_IOCTLV: 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); + _assert_msg_(IOS, false, "Unexpected command: %x", request.command); + return Device::Device::GetDefaultReply(IPC_EINVAL); } } @@ -473,7 +472,7 @@ void Update() if (s_request_queue.size()) { GenerateAck(s_request_queue.front()); - DEBUG_LOG(WII_IPC_HLE, "||-- Acknowledge IPC Request @ 0x%08x", s_request_queue.front()); + DEBUG_LOG(IOS, "||-- Acknowledge IPC Request @ 0x%08x", s_request_queue.front()); u32 command = s_request_queue.front(); s_request_queue.pop_front(); ExecuteCommand(command); @@ -483,7 +482,7 @@ void Update() if (s_reply_queue.size()) { GenerateReply(s_reply_queue.front()); - DEBUG_LOG(WII_IPC_HLE, "<<-- Reply to IPC Request @ 0x%08x", s_reply_queue.front()); + DEBUG_LOG(IOS, "<<-- Reply to IPC Request @ 0x%08x", s_reply_queue.front()); s_reply_queue.pop_front(); return; } @@ -491,7 +490,7 @@ void Update() if (s_ack_queue.size()) { GenerateAck(s_ack_queue.front()); - WARN_LOG(WII_IPC_HLE, "<<-- Double-ack to IPC Request @ 0x%08x", s_ack_queue.front()); + WARN_LOG(IOS, "<<-- Double-ack to IPC Request @ 0x%08x", s_ack_queue.front()); s_ack_queue.pop_front(); return; } diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE.h b/Source/Core/Core/IOS/IPC.h similarity index 89% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE.h rename to Source/Core/Core/IOS/IPC.h index c18ab49189..366feda655 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE.h +++ b/Source/Core/Core/IOS/IPC.h @@ -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& tmd); void SDIO_EventNotify(); -std::shared_ptr GetDeviceByName(const std::string& device_name); -std::shared_ptr AccessDeviceByID(u32 id); +std::shared_ptr GetDeviceByName(const std::string& device_name); +std::shared_ptr AccessDeviceByID(u32 id); // Update void Update(); diff --git a/Source/Core/Core/IPC_HLE/WiiNetConfig.cpp b/Source/Core/Core/IOS/Network/Config.cpp similarity index 93% rename from Source/Core/Core/IPC_HLE/WiiNetConfig.cpp rename to Source/Core/Core/IOS/Network/Config.cpp index 0d79ed2e63..162d44e92b 100644 --- a/Source/Core/Core/IPC_HLE/WiiNetConfig.cpp +++ b/Source/Core/Core/IOS/Network/Config.cpp @@ -2,7 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include "Core/IPC_HLE/WiiNetConfig.h" +#include "Core/IOS/Network/Config.h" #include @@ -44,7 +44,7 @@ void WiiNetConfig::WriteConfig() const if (!File::CreateFullPath(File::GetUserPath(D_SESSION_WIIROOT_IDX) + "/" WII_SYSCONF_DIR "/net/02/")) { - ERROR_LOG(WII_IPC_NET, "Failed to create directory for network config file"); + ERROR_LOG(IOS_NET, "Failed to create directory for network config file"); } } diff --git a/Source/Core/Core/IPC_HLE/WiiNetConfig.h b/Source/Core/Core/IOS/Network/Config.h similarity index 100% rename from Source/Core/Core/IPC_HLE/WiiNetConfig.h rename to Source/Core/Core/IOS/Network/Config.h diff --git a/Source/Core/Core/IPC_HLE/ICMP.h b/Source/Core/Core/IOS/Network/ICMP.h similarity index 100% rename from Source/Core/Core/IPC_HLE/ICMP.h rename to Source/Core/Core/IOS/Network/ICMP.h diff --git a/Source/Core/Core/IPC_HLE/ICMPLin.cpp b/Source/Core/Core/IOS/Network/ICMPLin.cpp similarity index 93% rename from Source/Core/Core/IPC_HLE/ICMPLin.cpp rename to Source/Core/Core/IOS/Network/ICMPLin.cpp index d847d8d0a2..258371c294 100644 --- a/Source/Core/Core/IPC_HLE/ICMPLin.cpp +++ b/Source/Core/Core/IOS/Network/ICMPLin.cpp @@ -2,7 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include "ICMP.h" +#include "Core/IOS/Network/ICMP.h" // Currently stubbed. AFAIK (delroth) there is no way to send ICMP echo // requests without being root on current Linux versions. diff --git a/Source/Core/Core/IPC_HLE/ICMPWin.cpp b/Source/Core/Core/IOS/Network/ICMPWin.cpp similarity index 98% rename from Source/Core/Core/IPC_HLE/ICMPWin.cpp rename to Source/Core/Core/IOS/Network/ICMPWin.cpp index ced1b4d320..d95bf64de3 100644 --- a/Source/Core/Core/IPC_HLE/ICMPWin.cpp +++ b/Source/Core/Core/IOS/Network/ICMPWin.cpp @@ -2,7 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include "Core/IPC_HLE/ICMP.h" +#include "Core/IOS/Network/ICMP.h" enum { diff --git a/Source/Core/Core/IPC_HLE/NWC24Config.cpp b/Source/Core/Core/IOS/Network/NWC24Config.cpp similarity index 89% rename from Source/Core/Core/IPC_HLE/NWC24Config.cpp rename to Source/Core/Core/IOS/Network/NWC24Config.cpp index 7aa5c3fb18..6cfb374898 100644 --- a/Source/Core/Core/IPC_HLE/NWC24Config.cpp +++ b/Source/Core/Core/IOS/Network/NWC24Config.cpp @@ -2,7 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include "Core/IPC_HLE/NWC24Config.h" +#include "Core/IOS/Network/NWC24Config.h" #include @@ -36,7 +36,7 @@ void NWC24Config::ReadConfig() { const s32 config_error = CheckNwc24Config(); if (config_error) - ERROR_LOG(WII_IPC_WC24, "There is an error in the config for for WC24: %d", config_error); + ERROR_LOG(IOS_WC24, "There is an error in the config for for WC24: %d", config_error); } } else @@ -51,7 +51,7 @@ void NWC24Config::WriteConfig() const { if (!File::CreateFullPath(File::GetUserPath(D_SESSION_WIIROOT_IDX) + "/" WII_WC24CONF_DIR)) { - ERROR_LOG(WII_IPC_WC24, "Failed to create directory for WC24"); + ERROR_LOG(IOS_WC24, "Failed to create directory for WC24"); } } @@ -105,21 +105,21 @@ s32 NWC24Config::CheckNwc24Config() const // 'WcCf' magic if (Magic() != 0x57634366) { - ERROR_LOG(WII_IPC_WC24, "Magic mismatch"); + ERROR_LOG(IOS_WC24, "Magic mismatch"); return -14; } const u32 checksum = CalculateNwc24ConfigChecksum(); - DEBUG_LOG(WII_IPC_WC24, "Checksum: %X", checksum); + DEBUG_LOG(IOS_WC24, "Checksum: %X", checksum); if (Checksum() != checksum) { - ERROR_LOG(WII_IPC_WC24, "Checksum mismatch expected %X and got %X", checksum, Checksum()); + ERROR_LOG(IOS_WC24, "Checksum mismatch expected %X and got %X", checksum, Checksum()); return -14; } if (IdGen() > 0x1F) { - ERROR_LOG(WII_IPC_WC24, "Id gen error"); + ERROR_LOG(IOS_WC24, "Id gen error"); return -14; } diff --git a/Source/Core/Core/IPC_HLE/NWC24Config.h b/Source/Core/Core/IOS/Network/NWC24Config.h similarity index 100% rename from Source/Core/Core/IPC_HLE/NWC24Config.h rename to Source/Core/Core/IOS/Network/NWC24Config.h diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_net.cpp b/Source/Core/Core/IOS/Network/Net.cpp similarity index 83% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_net.cpp rename to Source/Core/Core/IOS/Network/Net.cpp index 7c0c954b5f..a48ee40735 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_net.cpp +++ b/Source/Core/Core/IOS/Network/Net.cpp @@ -28,9 +28,9 @@ #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_net.h" -#include "Core/IPC_HLE/WII_Socket.h" +#include "Core/IOS/Network/ICMP.h" +#include "Core/IOS/Network/Net.h" +#include "Core/IOS/Network/Socket.h" #include "Core/ec_wii.h" #ifdef _WIN32 @@ -63,36 +63,37 @@ 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) { case IOCTL_NWC24_SUSPEND_SCHEDULAR: // NWC24iResumeForCloseLib from NWC24SuspendScheduler (Input: none, Output: 32 bytes) - INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_SUSPEND_SCHEDULAR - NI"); + INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_SUSPEND_SCHEDULAR - NI"); Memory::Write_U32(0, request.buffer_out); // no error break; case IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR: // NWC24iResumeForCloseLib - INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR - NI"); + INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR - NI"); break; case IOCTL_NWC24_EXEC_RESUME_SCHEDULAR: // NWC24iResumeForCloseLib - INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_EXEC_RESUME_SCHEDULAR - NI"); + INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_EXEC_RESUME_SCHEDULAR - NI"); Memory::Write_U32(0, request.buffer_out); // no error break; @@ -100,29 +101,29 @@ IPCCommandResult CWII_IPC_HLE_Device_net_kd_request::IOCtl(const IOSIOCtlRequest Memory::Write_U32(0, request.buffer_out); Memory::Write_U32(0, request.buffer_out + 4); return_value = 0; - INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_STARTUP_SOCKET - NI"); + INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_STARTUP_SOCKET - NI"); break; case IOCTL_NWC24_CLEANUP_SOCKET: - INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_CLEANUP_SOCKET - NI"); + INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_CLEANUP_SOCKET - NI"); break; case IOCTL_NWC24_LOCK_SOCKET: // WiiMenu - INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_LOCK_SOCKET - NI"); + INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_LOCK_SOCKET - NI"); break; case IOCTL_NWC24_UNLOCK_SOCKET: - INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_UNLOCK_SOCKET - NI"); + INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_UNLOCK_SOCKET - NI"); break; case IOCTL_NWC24_REQUEST_REGISTER_USER_ID: - INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_REGISTER_USER_ID"); + INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_REGISTER_USER_ID"); Memory::Write_U32(0, request.buffer_out); Memory::Write_U32(0, request.buffer_out + 4); break; case IOCTL_NWC24_REQUEST_GENERATED_USER_ID: // (Input: none, Output: 32 bytes) - INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_GENERATED_USER_ID"); + INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_GENERATED_USER_ID"); if (config.CreationStage() == NWC24::NWC24Config::NWC24_IDCS_INITIAL) { std::string settings_Filename( @@ -178,26 +179,26 @@ IPCCommandResult CWII_IPC_HLE_Device_net_kd_request::IOCtl(const IOSIOCtlRequest break; case IOCTL_NWC24_GET_SCHEDULAR_STAT: - INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_GET_SCHEDULAR_STAT - NI"); + INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_GET_SCHEDULAR_STAT - NI"); break; case IOCTL_NWC24_SAVE_MAIL_NOW: - INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_SAVE_MAIL_NOW - NI"); + INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_SAVE_MAIL_NOW - NI"); break; case IOCTL_NWC24_REQUEST_SHUTDOWN: // if ya set the IOS version to a very high value this happens ... - INFO_LOG(WII_IPC_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_SHUTDOWN - NI"); + INFO_LOG(IOS_WC24, "NET_KD_REQ: IOCTL_NWC24_REQUEST_SHUTDOWN - NI"); break; default: - request.Log(GetDeviceName(), LogTypes::WII_IPC_WC24); + request.Log(GetDeviceName(), LogTypes::IOS_WC24); } 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 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 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, @@ -310,27 +311,22 @@ static void GetMacAddress(u8* mac) SaveMacAddress(mac); if (!wireless_mac.empty()) { - ERROR_LOG(WII_IPC_NET, "The MAC provided (%s) is invalid. We have " - "generated another one for you.", + ERROR_LOG(IOS_NET, "The MAC provided (%s) is invalid. We have " + "generated another one for you.", Common::MacAddressToString(mac).c_str()); } } - INFO_LOG(WII_IPC_NET, "Using MAC address: %s", Common::MacAddressToString(mac).c_str()); + INFO_LOG(IOS_NET, "Using MAC address: %s", Common::MacAddressToString(mac).c_str()); } // ********************************************************************************** // 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; @@ -346,37 +342,37 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(const IOSIOCtlVReque break; case IOCTLV_NCD_GETCONFIG: - INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETCONFIG"); + INFO_LOG(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETCONFIG"); config.WriteToMem(request.io_vectors.at(0).address); common_vector = 1; break; case IOCTLV_NCD_SETCONFIG: - INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE: IOCTLV_NCD_SETCONFIG"); + INFO_LOG(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_SETCONFIG"); config.ReadFromMem(request.in_vectors.at(0).address); break; case IOCTLV_NCD_READCONFIG: - INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE: IOCTLV_NCD_READCONFIG"); + INFO_LOG(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_READCONFIG"); config.ReadConfig(); config.WriteToMem(request.io_vectors.at(0).address); common_vector = 1; break; case IOCTLV_NCD_WRITECONFIG: - INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE: IOCTLV_NCD_WRITECONFIG"); + INFO_LOG(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_WRITECONFIG"); config.ReadFromMem(request.in_vectors.at(0).address); config.WriteConfig(); break; case IOCTLV_NCD_GETLINKSTATUS: - INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETLINKSTATUS"); + INFO_LOG(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETLINKSTATUS"); // Always connected Memory::Write_U32(Net::ConnectionSettings::LINK_WIRED, request.io_vectors.at(0).address + 4); break; case IOCTLV_NCD_GETWIRELESSMACADDRESS: - INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETWIRELESSMACADDRESS"); + INFO_LOG(IOS_NET, "NET_NCD_MANAGE: IOCTLV_NCD_GETWIRELESSMACADDRESS"); u8 address[Common::MAC_ADDRESS_SIZE]; GetMacAddress(address); @@ -384,7 +380,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(const IOSIOCtlVReque break; default: - INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE IOCtlV: %#x", request.request); + INFO_LOG(IOS_NET, "NET_NCD_MANAGE IOCtlV: %#x", request.request); break; } @@ -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; @@ -475,7 +466,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_wd_command::IOCtlV(const IOSIOCtlVReque case IOCTLV_WD_RECV_FRAME: case IOCTLV_WD_RECV_NOTIFICATION: default: - request.Dump(GetDeviceName(), LogTypes::WII_IPC_NET, LogTypes::LINFO); + request.Dump(GetDeviceName(), LogTypes::IOS_NET, LogTypes::LINFO); } return GetDefaultReply(return_value); @@ -483,17 +474,15 @@ 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); - INFO_LOG(WII_IPC_NET, "WSAStartup: %d", ret); + INFO_LOG(IOS_NET, "WSAStartup: %d", ret); #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) { @@ -562,7 +551,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re { case IOCTL_SO_STARTUP: { - request.Log(GetDeviceName(), LogTypes::WII_IPC_WC24); + request.Log(GetDeviceName(), LogTypes::IOS_WC24); break; } case IOCTL_SO_SOCKET: @@ -573,8 +562,8 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re WiiSockMan& sm = WiiSockMan::GetInstance(); return_value = sm.NewSocket(af, type, prot); - INFO_LOG(WII_IPC_NET, "IOCTL_SO_SOCKET " - "Socket: %08x (%d,%d,%d), BufferIn: (%08x, %i), BufferOut: (%08x, %i)", + INFO_LOG(IOS_NET, "IOCTL_SO_SOCKET " + "Socket: %08x (%d,%d,%d), BufferIn: (%08x, %i), BufferOut: (%08x, %i)", return_value, af, type, prot, request.buffer_in, request.buffer_in_size, request.buffer_out, request.buffer_out_size); break; @@ -585,7 +574,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re WiiSockMan& sm = WiiSockMan::GetInstance(); return_value = sm.NewSocket(pf, SOCK_RAW, IPPROTO_ICMP); - INFO_LOG(WII_IPC_NET, "IOCTL_SO_ICMPSOCKET(%x) %d", pf, return_value); + INFO_LOG(IOS_NET, "IOCTL_SO_ICMPSOCKET(%x) %d", pf, return_value); break; } case IOCTL_SO_CLOSE: @@ -594,7 +583,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re u32 fd = Memory::Read_U32(request.buffer_in); WiiSockMan& sm = WiiSockMan::GetInstance(); return_value = sm.DeleteSocket(fd); - INFO_LOG(WII_IPC_NET, "%s(%x) %x", + INFO_LOG(IOS_NET, "%s(%x) %x", request.request == IOCTL_SO_ICMPCLOSE ? "IOCTL_SO_ICMPCLOSE" : "IOCTL_SO_CLOSE", fd, return_value); break; @@ -614,7 +603,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re ///////////////////////////////////////////////////////////// case IOCTL_SO_SHUTDOWN: { - request.Log(GetDeviceName(), LogTypes::WII_IPC_WC24); + request.Log(GetDeviceName(), LogTypes::IOS_WC24); u32 fd = Memory::Read_U32(request.buffer_in); u32 how = Memory::Read_U32(request.buffer_in + 4); @@ -628,7 +617,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re u32 BACKLOG = Memory::Read_U32(request.buffer_in + 0x04); u32 ret = listen(fd, BACKLOG); return_value = WiiSockMan::GetNetErrorCode(ret, "SO_LISTEN", false); - request.Log(GetDeviceName(), LogTypes::WII_IPC_WC24); + request.Log(GetDeviceName(), LogTypes::IOS_WC24); break; } case IOCTL_SO_GETSOCKOPT: @@ -637,7 +626,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re u32 level = Memory::Read_U32(request.buffer_out + 4); u32 optname = Memory::Read_U32(request.buffer_out + 8); - request.Log(GetDeviceName(), LogTypes::WII_IPC_WC24); + request.Log(GetDeviceName(), LogTypes::IOS_WC24); // Do the level/optname translation int nat_level = -1, nat_optname = -1; @@ -679,10 +668,10 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re optlen = std::min(optlen, (u32)sizeof(optval)); Memory::CopyFromEmu(optval, request.buffer_in + 0x10, optlen); - INFO_LOG(WII_IPC_NET, "IOCTL_SO_SETSOCKOPT(%08x, %08x, %08x, %08x) " - "BufferIn: (%08x, %i), BufferOut: (%08x, %i)" - "%02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx " - "%02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx", + INFO_LOG(IOS_NET, "IOCTL_SO_SETSOCKOPT(%08x, %08x, %08x, %08x) " + "BufferIn: (%08x, %i), BufferOut: (%08x, %i)" + "%02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx " + "%02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx %02hhx", fd, level, optname, optlen, request.buffer_in, request.buffer_in_size, request.buffer_out, request.buffer_out_size, optval[0], optval[1], optval[2], optval[3], optval[4], optval[5], optval[6], optval[7], optval[8], optval[9], @@ -710,7 +699,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re if (nat_level == -1 || nat_optname == -1) { - INFO_LOG(WII_IPC_NET, "SO_SETSOCKOPT: unknown level %d or optname %d", level, optname); + INFO_LOG(IOS_NET, "SO_SETSOCKOPT: unknown level %d or optname %d", level, optname); // Default to the given level/optname. They match on Windows... nat_level = level; @@ -725,7 +714,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re { u32 fd = Memory::Read_U32(request.buffer_in); - request.Log(GetDeviceName(), LogTypes::WII_IPC_WC24); + request.Log(GetDeviceName(), LogTypes::IOS_WC24); sockaddr sa; socklen_t sa_len; @@ -733,7 +722,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re int ret = getsockname(fd, &sa, &sa_len); if (request.buffer_out_size < 2 + sizeof(sa.sa_data)) - WARN_LOG(WII_IPC_NET, "IOCTL_SO_GETSOCKNAME output buffer is too small. Truncating"); + WARN_LOG(IOS_NET, "IOCTL_SO_GETSOCKNAME output buffer is too small. Truncating"); if (request.buffer_out_size > 0) Memory::Write_U8(request.buffer_out_size, request.buffer_out); @@ -756,7 +745,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re int ret = getpeername(fd, &sa, &sa_len); if (request.buffer_out_size < 2 + sizeof(sa.sa_data)) - WARN_LOG(WII_IPC_NET, "IOCTL_SO_GETPEERNAME output buffer is too small. Truncating"); + WARN_LOG(IOS_NET, "IOCTL_SO_GETPEERNAME output buffer is too small. Truncating"); if (request.buffer_out_size > 0) Memory::Write_U8(request.buffer_out_size, request.buffer_out); @@ -766,7 +755,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re Memory::CopyToEmu(request.buffer_out + 2, &sa.sa_data, std::min(sizeof(sa.sa_data), request.buffer_out_size - 2)); - INFO_LOG(WII_IPC_NET, "IOCTL_SO_GETPEERNAME(%x)", fd); + INFO_LOG(IOS_NET, "IOCTL_SO_GETPEERNAME(%x)", fd); return_value = ret; break; @@ -774,7 +763,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re case IOCTL_SO_GETHOSTID: { - request.Log(GetDeviceName(), LogTypes::WII_IPC_WC24); + request.Log(GetDeviceName(), LogTypes::IOS_WC24); #ifdef _WIN32 DWORD forwardTableSize, ipTableSize, result; @@ -842,8 +831,8 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re if (remoteHost == nullptr || remoteHost->h_addr_list == nullptr || remoteHost->h_addr_list[0] == nullptr) { - INFO_LOG(WII_IPC_NET, "IOCTL_SO_INETATON = -1 " - "%s, BufferIn: (%08x, %i), BufferOut: (%08x, %i), IP Found: None", + INFO_LOG(IOS_NET, "IOCTL_SO_INETATON = -1 " + "%s, BufferIn: (%08x, %i), BufferOut: (%08x, %i), IP Found: None", hostname.c_str(), request.buffer_in, request.buffer_in_size, request.buffer_out, request.buffer_out_size); return_value = 0; @@ -851,8 +840,8 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re else { Memory::Write_U32(Common::swap32(*(u32*)remoteHost->h_addr_list[0]), request.buffer_out); - INFO_LOG(WII_IPC_NET, "IOCTL_SO_INETATON = 0 " - "%s, BufferIn: (%08x, %i), BufferOut: (%08x, %i), IP Found: %08X", + INFO_LOG(IOS_NET, "IOCTL_SO_INETATON = 0 " + "%s, BufferIn: (%08x, %i), BufferOut: (%08x, %i), IP Found: %08X", hostname.c_str(), request.buffer_in, request.buffer_in_size, request.buffer_out, request.buffer_out_size, Common::swap32(*(u32*)remoteHost->h_addr_list[0])); return_value = 1; @@ -863,8 +852,8 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re case IOCTL_SO_INETPTON: { std::string address = Memory::GetString(request.buffer_in); - INFO_LOG(WII_IPC_NET, "IOCTL_SO_INETPTON " - "(Translating: %s)", + INFO_LOG(IOS_NET, "IOCTL_SO_INETPTON " + "(Translating: %s)", address.c_str()); return_value = inet_pton(address.c_str(), Memory::GetPointer(request.buffer_out + 4)); break; @@ -879,7 +868,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re sprintf(ip_s, "%i.%i.%i.%i", Memory::Read_U8(request.buffer_in + 8), Memory::Read_U8(request.buffer_in + 8 + 1), Memory::Read_U8(request.buffer_in + 8 + 2), Memory::Read_U8(request.buffer_in + 8 + 3)); - INFO_LOG(WII_IPC_NET, "IOCTL_SO_INETNTOP %s", ip_s); + INFO_LOG(IOS_NET, "IOCTL_SO_INETNTOP %s", ip_s); Memory::CopyToEmu(request.buffer_out, (u8*)ip_s, strlen(ip_s)); break; } @@ -901,7 +890,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re int nfds = request.buffer_out_size / 0xc; if (nfds == 0) - ERROR_LOG(WII_IPC_NET, "Hidden POLL"); + ERROR_LOG(IOS_NET, "Hidden POLL"); std::vector ufds(nfds); @@ -920,16 +909,16 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re ufds[i].events |= map.native; unhandled_events &= ~map.wii; } - DEBUG_LOG(WII_IPC_NET, "IOCTL_SO_POLL(%d) " - "Sock: %08x, Unknown: %08x, Events: %08x, " - "NativeEvents: %08x", + DEBUG_LOG(IOS_NET, "IOCTL_SO_POLL(%d) " + "Sock: %08x, Unknown: %08x, Events: %08x, " + "NativeEvents: %08x", i, ufds[i].fd, unknown, events, ufds[i].events); // Do not pass return-only events to the native poll ufds[i].events &= ~(POLLERR | POLLHUP | POLLNVAL | UNSUPPORTED_WSAPOLL); if (unhandled_events) - ERROR_LOG(WII_IPC_NET, "SO_POLL: unhandled Wii event types: %04x", unhandled_events); + ERROR_LOG(IOS_NET, "SO_POLL: unhandled Wii event types: %04x", unhandled_events); } int ret = poll(ufds.data(), nfds, timeout); @@ -950,7 +939,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re // Memory::Write_U32(events, request.buffer_out + 0xc*i + 4); //events Memory::Write_U32(revents, request.buffer_out + 0xc * i + 8); // revents - DEBUG_LOG(WII_IPC_NET, "IOCTL_SO_POLL socket %d wevents %08X events %08X revents %08X", i, + DEBUG_LOG(IOS_NET, "IOCTL_SO_POLL socket %d wevents %08X events %08X revents %08X", i, revents, ufds[i].events, ufds[i].revents); } @@ -962,7 +951,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re { if (request.buffer_out_size != 0x460) { - ERROR_LOG(WII_IPC_NET, "Bad buffer size for IOCTL_SO_GETHOSTBYNAME"); + ERROR_LOG(IOS_NET, "Bad buffer size for IOCTL_SO_GETHOSTBYNAME"); return_value = -1; break; } @@ -970,8 +959,8 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re std::string hostname = Memory::GetString(request.buffer_in); hostent* remoteHost = gethostbyname(hostname.c_str()); - INFO_LOG(WII_IPC_NET, "IOCTL_SO_GETHOSTBYNAME " - "Address: %s, BufferIn: (%08x, %i), BufferOut: (%08x, %i)", + INFO_LOG(IOS_NET, "IOCTL_SO_GETHOSTBYNAME " + "Address: %s, BufferIn: (%08x, %i), BufferOut: (%08x, %i)", hostname.c_str(), request.buffer_in, request.buffer_in_size, request.buffer_out, request.buffer_out_size); @@ -979,7 +968,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re { for (int i = 0; remoteHost->h_aliases[i]; ++i) { - DEBUG_LOG(WII_IPC_NET, "alias%i:%s", i, remoteHost->h_aliases[i]); + DEBUG_LOG(IOS_NET, "alias%i:%s", i, remoteHost->h_aliases[i]); } for (int i = 0; remoteHost->h_addr_list[i]; ++i) @@ -987,7 +976,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re u32 ip = Common::swap32(*(u32*)(remoteHost->h_addr_list[i])); std::string ip_s = StringFromFormat("%i.%i.%i.%i", ip >> 24, (ip >> 16) & 0xff, (ip >> 8) & 0xff, ip & 0xff); - DEBUG_LOG(WII_IPC_NET, "addr%i:%s", i, ip_s.c_str()); + DEBUG_LOG(IOS_NET, "addr%i:%s", i, ip_s.c_str()); } // Host name; located immediately after struct @@ -997,7 +986,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re u32 name_length = (u32)strlen(remoteHost->h_name) + 1; if (name_length > (GETHOSTBYNAME_IP_LIST_OFFSET - GETHOSTBYNAME_STRUCT_SIZE)) { - ERROR_LOG(WII_IPC_NET, "Hostname too long in IOCTL_SO_GETHOSTBYNAME"); + ERROR_LOG(IOS_NET, "Hostname too long in IOCTL_SO_GETHOSTBYNAME"); return_value = -1; break; } @@ -1037,7 +1026,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re request.buffer_out + 4); // Returned struct must be ipv4. - _assert_msg_(WII_IPC_NET, + _assert_msg_(IOS_NET, remoteHost->h_addrtype == AF_INET && remoteHost->h_length == sizeof(u32), "returned host info is not IPv4"); Memory::Write_U16(AF_INET, request.buffer_out + 8); @@ -1054,16 +1043,16 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtl(const IOSIOCtlRequest& re } case IOCTL_SO_ICMPCANCEL: - ERROR_LOG(WII_IPC_NET, "IOCTL_SO_ICMPCANCEL"); + ERROR_LOG(IOS_NET, "IOCTL_SO_ICMPCANCEL"); default: - request.DumpUnknown(GetDeviceName(), LogTypes::WII_IPC_NET); + request.DumpUnknown(GetDeviceName(), LogTypes::IOS_NET); } 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; @@ -1081,8 +1070,8 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtlV(const IOSIOCtlVRequest& param5 = Memory::Read_U32(request.io_vectors[0].address + 4); } - INFO_LOG(WII_IPC_NET, "IOCTLV_SO_GETINTERFACEOPT(%08X, %08X, %X, %X, %X) " - "BufferIn: (%08x, %i), BufferIn2: (%08x, %i) ", + INFO_LOG(IOS_NET, "IOCTLV_SO_GETINTERFACEOPT(%08X, %08X, %X, %X, %X) " + "BufferIn: (%08x, %i), BufferIn2: (%08x, %i) ", param, param2, param3, param4, param5, request.in_vectors[0].address, request.in_vectors[0].size, request.in_vectors.size() > 1 ? request.in_vectors[1].address : 0, @@ -1133,8 +1122,8 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtlV(const IOSIOCtlVRequest& if (AdapterList->IfIndex == dwBestIfIndex && AdapterList->FirstDnsServerAddress && AdapterList->OperStatus == IfOperStatusUp) { - INFO_LOG(WII_IPC_NET, "Name of valid interface: %S", AdapterList->FriendlyName); - INFO_LOG(WII_IPC_NET, "DNS: %u.%u.%u.%u", + INFO_LOG(IOS_NET, "Name of valid interface: %S", AdapterList->FriendlyName); + INFO_LOG(IOS_NET, "DNS: %u.%u.%u.%u", (unsigned char) AdapterList->FirstDnsServerAddress->Address.lpSockaddr->sa_data[2], (unsigned char) @@ -1190,7 +1179,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtlV(const IOSIOCtlVRequest& break; default: - ERROR_LOG(WII_IPC_NET, "Unknown param2: %08X", param2); + ERROR_LOG(IOS_NET, "Unknown param2: %08X", param2); break; } break; @@ -1299,7 +1288,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtlV(const IOSIOCtlVRequest& ret = -305; } - request.Dump(GetDeviceName(), LogTypes::WII_IPC_NET, LogTypes::LINFO); + request.Dump(GetDeviceName(), LogTypes::IOS_NET, LogTypes::LINFO); return_value = ret; break; } @@ -1319,7 +1308,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtlV(const IOSIOCtlVRequest& if (num_ip != 1) { - INFO_LOG(WII_IPC_NET, "IOCTLV_SO_ICMPPING %i IPs", num_ip); + INFO_LOG(IOS_NET, "IOCTLV_SO_ICMPPING %i IPs", num_ip); } ip_info.length = Memory::Read_U8(request.in_vectors[0].address + 16); @@ -1329,12 +1318,12 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtlV(const IOSIOCtlVRequest& if (ip_info.length != 8 || ip_info.addr_family != AF_INET) { - INFO_LOG(WII_IPC_NET, "IOCTLV_SO_ICMPPING strange IPInfo:\n" - "length %x addr_family %x", + INFO_LOG(IOS_NET, "IOCTLV_SO_ICMPPING strange IPInfo:\n" + "length %x addr_family %x", ip_info.length, ip_info.addr_family); } - INFO_LOG(WII_IPC_NET, "IOCTLV_SO_ICMPPING %x", ip_info.ip); + INFO_LOG(IOS_NET, "IOCTLV_SO_ICMPPING %x", ip_info.ip); sockaddr_in addr; addr.sin_family = AF_INET; @@ -1367,15 +1356,16 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ip_top::IOCtlV(const IOSIOCtlVRequest& break; } default: - request.DumpUnknown(GetDeviceName(), LogTypes::WII_IPC_NET); + request.DumpUnknown(GetDeviceName(), LogTypes::IOS_NET); } 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 diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_net.h b/Source/Core/Core/IOS/Network/Net.h similarity index 85% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_net.h rename to Source/Core/Core/IOS/Network/Net.h index 9472aa048b..29e9080f8e 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_net.h +++ b/Source/Core/Core/IOS/Network/Net.h @@ -10,10 +10,10 @@ #include "Common/Logging/Log.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" +#include "Core/IOS/Device.h" +#include "Core/IOS/IPC.h" +#include "Core/IOS/Network/Config.h" +#include "Core/IOS/Network/NWC24Config.h" #ifdef _WIN32 #include @@ -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; @@ -122,7 +164,7 @@ public: break; default: - ERROR_LOG(WII_IPC_NET, "%s - unknown IOCtl: %x", GetDeviceName().c_str(), request.request); + ERROR_LOG(IOS_NET, "%s - unknown IOCtl: %x", GetDeviceName().c_str(), request.request); break; } @@ -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 diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.cpp b/Source/Core/Core/IOS/Network/SSL.cpp similarity index 74% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.cpp rename to Source/Core/Core/IOS/Network/SSL.cpp index ba6642aa04..6c044cfcfe 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.cpp +++ b/Source/Core/Core/IOS/Network/SSL.cpp @@ -13,14 +13,16 @@ #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" +#include "Core/IOS/Network/SSL.h" +#include "Core/IOS/Network/Socket.h" 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); + request.Log(GetDeviceName(), LogTypes::IOS_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; @@ -185,10 +185,10 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(const IOSIOCtlVRequest& req Memory::Write_U32(SSL_ERR_FAILED, BufferIn); } - INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_NEW (%d, %s) " - "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " - "BufferIn3: (%08x, %i), BufferOut: (%08x, %i), " - "BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)", + INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_NEW (%d, %s) " + "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " + "BufferIn3: (%08x, %i), BufferOut: (%08x, %i), " + "BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)", verifyOption, hostname.c_str(), BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3); @@ -222,20 +222,20 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(const IOSIOCtlVRequest& req { Memory::Write_U32(SSL_ERR_ID, BufferIn); } - INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SHUTDOWN " - "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " - "BufferIn3: (%08x, %i), BufferOut: (%08x, %i), " - "BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)", + INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SHUTDOWN " + "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " + "BufferIn3: (%08x, %i), BufferOut: (%08x, %i), " + "BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)", BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3); break; } case IOCTLV_NET_SSL_SETROOTCA: { - INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETROOTCA " - "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " - "BufferIn3: (%08x, %i), BufferOut: (%08x, %i), " - "BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)", + INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETROOTCA " + "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " + "BufferIn3: (%08x, %i), BufferOut: (%08x, %i), " + "BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)", BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3); @@ -262,7 +262,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(const IOSIOCtlVRequest& req Memory::Write_U32(SSL_OK, BufferIn); } - INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETROOTCA = %d", ret); + INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETROOTCA = %d", ret); } else { @@ -272,10 +272,10 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(const IOSIOCtlVRequest& req } case IOCTLV_NET_SSL_SETBUILTINCLIENTCERT: { - INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT " - "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " - "BufferIn3: (%08x, %i), BufferOut: (%08x, %i), " - "BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)", + INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT " + "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " + "BufferIn3: (%08x, %i), BufferOut: (%08x, %i), " + "BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)", BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3); @@ -300,21 +300,21 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(const IOSIOCtlVRequest& req Memory::Write_U32(SSL_OK, BufferIn); } - INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT = (%d, %d)", ret, pk_ret); + INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT = (%d, %d)", ret, pk_ret); } else { Memory::Write_U32(SSL_ERR_ID, BufferIn); - INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT invalid sslID = %d", sslID); + INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT invalid sslID = %d", sslID); } break; } case IOCTLV_NET_SSL_REMOVECLIENTCERT: { - INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_REMOVECLIENTCERT " - "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " - "BufferIn3: (%08x, %i), BufferOut: (%08x, %i), " - "BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)", + INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_REMOVECLIENTCERT " + "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " + "BufferIn3: (%08x, %i), BufferOut: (%08x, %i), " + "BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)", BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3); @@ -331,7 +331,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(const IOSIOCtlVRequest& req else { Memory::Write_U32(SSL_ERR_ID, BufferIn); - INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT invalid sslID = %d", sslID); + INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINCLIENTCERT invalid sslID = %d", sslID); } break; } @@ -354,16 +354,16 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(const IOSIOCtlVRequest& req mbedtls_ssl_conf_ca_chain(&ssl->config, &ssl->cacert, nullptr); Memory::Write_U32(SSL_OK, BufferIn); } - INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINROOTCA = %d", ret); + INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINROOTCA = %d", ret); } else { Memory::Write_U32(SSL_ERR_ID, BufferIn); } - INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETBUILTINROOTCA " - "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " - "BufferIn3: (%08x, %i), BufferOut: (%08x, %i), " - "BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)", + INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETBUILTINROOTCA " + "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " + "BufferIn3: (%08x, %i), BufferOut: (%08x, %i), " + "BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)", BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3); break; @@ -376,7 +376,7 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(const IOSIOCtlVRequest& req WII_SSL* ssl = &_SSL[sslID]; mbedtls_ssl_setup(&ssl->ctx, &ssl->config); ssl->sockfd = Memory::Read_U32(BufferOut2); - INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_CONNECT socket = %d", ssl->sockfd); + INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_CONNECT socket = %d", ssl->sockfd); mbedtls_ssl_set_bio(&ssl->ctx, &ssl->sockfd, mbedtls_net_send, mbedtls_net_recv, nullptr); Memory::Write_U32(SSL_OK, BufferIn); } @@ -384,10 +384,10 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(const IOSIOCtlVRequest& req { Memory::Write_U32(SSL_ERR_ID, BufferIn); } - INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_CONNECT " - "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " - "BufferIn3: (%08x, %i), BufferOut: (%08x, %i), " - "BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)", + INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_CONNECT " + "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " + "BufferIn3: (%08x, %i), BufferOut: (%08x, %i), " + "BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)", BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3); break; @@ -420,13 +420,13 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(const IOSIOCtlVRequest& req { Memory::Write_U32(SSL_ERR_ID, BufferIn); } - INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_WRITE " - "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " - "BufferIn3: (%08x, %i), BufferOut: (%08x, %i), " - "BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)", + INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_WRITE " + "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " + "BufferIn3: (%08x, %i), BufferOut: (%08x, %i), " + "BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)", BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3); - INFO_LOG(WII_IPC_SSL, "%s", Memory::GetString(BufferOut2).c_str()); + INFO_LOG(IOS_SSL, "%s", Memory::GetString(BufferOut2).c_str()); break; } case IOCTLV_NET_SSL_READ: @@ -444,10 +444,10 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(const IOSIOCtlVRequest& req Memory::Write_U32(SSL_ERR_ID, BufferIn); } - INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_READ(%d)" - "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " - "BufferIn3: (%08x, %i), BufferOut: (%08x, %i), " - "BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)", + INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_READ(%d)" + "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " + "BufferIn3: (%08x, %i), BufferOut: (%08x, %i), " + "BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)", ret, BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3); break; @@ -463,20 +463,20 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(const IOSIOCtlVRequest& req { Memory::Write_U32(SSL_ERR_ID, BufferIn); } - INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETROOTCADEFAULT " - "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " - "BufferIn3: (%08x, %i), BufferOut: (%08x, %i), " - "BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)", + INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETROOTCADEFAULT " + "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " + "BufferIn3: (%08x, %i), BufferOut: (%08x, %i), " + "BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)", BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3); break; } case IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT: { - INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT " - "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " - "BufferIn3: (%08x, %i), BufferOut: (%08x, %i), " - "BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)", + INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_SETCLIENTCERTDEFAULT " + "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " + "BufferIn3: (%08x, %i), BufferOut: (%08x, %i), " + "BufferOut2: (%08x, %i), BufferOut3: (%08x, %i)", BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferIn3, BufferInSize3, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2, BufferOut3, BufferOutSize3); @@ -492,11 +492,12 @@ IPCCommandResult CWII_IPC_HLE_Device_net_ssl::IOCtlV(const IOSIOCtlVRequest& req break; } default: - request.DumpUnknown(GetDeviceName(), LogTypes::WII_IPC_SSL); + request.DumpUnknown(GetDeviceName(), LogTypes::IOS_SSL); } // SSL return codes are written to BufferIn return GetDefaultReply(IPC_SUCCESS); } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h b/Source/Core/Core/IOS/Network/SSL.h similarity index 87% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h rename to Source/Core/Core/IOS/Network/SSL.h index 136569cb0b..1114f65f6f 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h +++ b/Source/Core/Core/IOS/Network/SSL.h @@ -19,8 +19,8 @@ // clang-format on #include "Common/CommonTypes.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device.h" +#include "Core/IOS/IPC.h" +#include "Core/IOS/Device.h" namespace IOS { @@ -28,8 +28,9 @@ namespace HLE { #define NET_SSL_MAXINSTANCES 4 +// TODO: remove this macro. #define SSLID_VALID(x) \ - (x >= 0 && x < NET_SSL_MAXINSTANCES && CWII_IPC_HLE_Device_net_ssl::_SSL[x].active) + (x >= 0 && x < NET_SSL_MAXINSTANCES && ::IOS::HLE::Device::NetSSL::_SSL[x].active) enum ssl_err_t { @@ -84,12 +85,14 @@ struct WII_SSL bool active; }; -class CWII_IPC_HLE_Device_net_ssl : public IWII_IPC_HLE_Device +namespace Device +{ +class NetSSL : public Device { public: - CWII_IPC_HLE_Device_net_ssl(u32 _DeviceID, const std::string& _rDeviceName); + NetSSL(u32 device_id, const std::string& device_name); - virtual ~CWII_IPC_HLE_Device_net_ssl(); + virtual ~NetSSL(); IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override; IPCCommandResult IOCtlV(const IOSIOCtlVRequest& request) override; @@ -98,5 +101,6 @@ public: static WII_SSL _SSL[NET_SSL_MAXINSTANCES]; }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_Socket.cpp b/Source/Core/Core/IOS/Network/Socket.cpp similarity index 91% rename from Source/Core/Core/IPC_HLE/WII_Socket.cpp rename to Source/Core/Core/IOS/Network/Socket.cpp index 53812b4d8f..3b6598d577 100644 --- a/Source/Core/Core/IPC_HLE/WII_Socket.cpp +++ b/Source/Core/Core/IOS/Network/Socket.cpp @@ -12,9 +12,9 @@ #include "Common/FileUtil.h" #include "Core/ConfigManager.h" #include "Core/Core.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device.h" -#include "Core/IPC_HLE/WII_Socket.h" // No Wii socket support while using NetPlay or TAS +#include "Core/IOS/Device.h" +#include "Core/IOS/IPC.h" +#include "Core/IOS/Network/Socket.h" // No Wii socket support while using NetPlay or TAS #ifdef _WIN32 #define ERRORCODE(name) WSA##name @@ -50,7 +50,7 @@ static s32 TranslateErrorCode(s32 native_error, bool isRW) switch (native_error) { case ERRORCODE(EMSGSIZE): - ERROR_LOG(WII_IPC_NET, "Find out why this happened, looks like PEEK failure?"); + ERROR_LOG(IOS_NET, "Find out why this happened, looks like PEEK failure?"); return -1; // Should be -SO_EMSGSIZE case EITHER(WSAENOTSOCK, EBADF): return -SO_EBADF; @@ -103,7 +103,7 @@ s32 WiiSockMan::GetNetErrorCode(s32 ret, const char* caller, bool isRW) return ret; } - ERROR_LOG(WII_IPC_NET, "%s failed with error %d: %s, ret= %d", caller, errorCode, + ERROR_LOG(IOS_NET, "%s failed with error %d: %s, ret= %d", caller, errorCode, DecodeError(errorCode), ret); s32 ReturnValue = TranslateErrorCode(errorCode, isRW); @@ -176,10 +176,10 @@ s32 WiiSocket::FCntl(u32 cmd, u32 arg) } else { - ERROR_LOG(WII_IPC_NET, "SO_FCNTL unknown command"); + ERROR_LOG(IOS_NET, "SO_FCNTL unknown command"); } - INFO_LOG(WII_IPC_NET, "IOCTL_SO_FCNTL(%08x, %08X, %08X)", fd, cmd, arg); + INFO_LOG(IOS_NET, "IOCTL_SO_FCNTL(%08x, %08X, %08X)", fd, cmd, arg); return ret; } @@ -213,8 +213,8 @@ void WiiSocket::Update(bool read, bool write, bool except) int ret = bind(fd, (sockaddr*)&local_name, sizeof(local_name)); ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_BIND", false); - INFO_LOG(WII_IPC_NET, "IOCTL_SO_BIND (%08X %s:%d) = %d ", fd, - inet_ntoa(local_name.sin_addr), Common::swap16(local_name.sin_port), ret); + INFO_LOG(IOS_NET, "IOCTL_SO_BIND (%08X %s:%d) = %d ", fd, inet_ntoa(local_name.sin_addr), + Common::swap16(local_name.sin_port), ret); break; } case IOCTL_SO_CONNECT: @@ -226,7 +226,7 @@ void WiiSocket::Update(bool read, bool write, bool except) int ret = connect(fd, (sockaddr*)&local_name, sizeof(local_name)); ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_CONNECT", false); - INFO_LOG(WII_IPC_NET, "IOCTL_SO_CONNECT (%08x, %s:%d)", fd, inet_ntoa(local_name.sin_addr), + INFO_LOG(IOS_NET, "IOCTL_SO_CONNECT (%08x, %s:%d)", fd, inet_ntoa(local_name.sin_addr), Common::swap16(local_name.sin_port)); break; } @@ -252,7 +252,7 @@ void WiiSocket::Update(bool read, bool write, bool except) WiiSockMan::GetInstance().AddSocket(ReturnValue); - ioctl.Log("IOCTL_SO_ACCEPT", LogTypes::WII_IPC_NET); + ioctl.Log("IOCTL_SO_ACCEPT", LogTypes::IOS_NET); break; } default: @@ -309,13 +309,13 @@ void WiiSocket::Update(bool read, bool write, bool except) { case IOCTLV_NET_SSL_DOHANDSHAKE: { - mbedtls_ssl_context* ctx = &CWII_IPC_HLE_Device_net_ssl::_SSL[sslID].ctx; + mbedtls_ssl_context* ctx = &Device::NetSSL::_SSL[sslID].ctx; int ret = mbedtls_ssl_handshake(ctx); if (ret) { char error_buffer[256] = ""; mbedtls_strerror(ret, error_buffer, sizeof(error_buffer)); - ERROR_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_DOHANDSHAKE: %s", error_buffer); + ERROR_LOG(IOS_SSL, "IOCTLV_NET_SSL_DOHANDSHAKE: %s", error_buffer); } switch (ret) { @@ -337,7 +337,7 @@ void WiiSocket::Update(bool read, bool write, bool except) char error_buffer[256] = ""; int res = mbedtls_ssl_get_verify_result(ctx); mbedtls_x509_crt_verify_info(error_buffer, sizeof(error_buffer), "", res); - ERROR_LOG(WII_IPC_SSL, "MBEDTLS_ERR_X509_CERT_VERIFY_FAILED (verify_result = %d): %s", + ERROR_LOG(IOS_SSL, "MBEDTLS_ERR_X509_CERT_VERIFY_FAILED (verify_result = %d): %s", res, error_buffer); if (res & MBEDTLS_X509_BADCERT_CN_MISMATCH) @@ -375,16 +375,16 @@ void WiiSocket::Update(bool read, bool write, bool except) } } - INFO_LOG(WII_IPC_SSL, "IOCTLV_NET_SSL_DOHANDSHAKE = (%d) " - "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " - "BufferOut: (%08x, %i), BufferOut2: (%08x, %i)", + INFO_LOG(IOS_SSL, "IOCTLV_NET_SSL_DOHANDSHAKE = (%d) " + "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " + "BufferOut: (%08x, %i), BufferOut2: (%08x, %i)", ret, BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2); break; } case IOCTLV_NET_SSL_WRITE: { - int ret = mbedtls_ssl_write(&CWII_IPC_HLE_Device_net_ssl::_SSL[sslID].ctx, + int ret = mbedtls_ssl_write(&Device::NetSSL::_SSL[sslID].ctx, Memory::GetPointer(BufferOut2), BufferOutSize2); if (SConfig::GetInstance().m_SSLDumpWrite && ret > 0) @@ -422,7 +422,7 @@ void WiiSocket::Update(bool read, bool write, bool except) } case IOCTLV_NET_SSL_READ: { - int ret = mbedtls_ssl_read(&CWII_IPC_HLE_Device_net_ssl::_SSL[sslID].ctx, + int ret = mbedtls_ssl_read(&Device::NetSSL::_SSL[sslID].ctx, Memory::GetPointer(BufferIn2), BufferInSize2); if (SConfig::GetInstance().m_SSLDumpRead && ret > 0) @@ -497,7 +497,7 @@ void WiiSocket::Update(bool read, bool write, bool except) ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_SENDTO", true); DEBUG_LOG( - WII_IPC_NET, + IOS_NET, "%s = %d Socket: %08x, BufferIn: (%08x, %i), BufferIn2: (%08x, %i), %u.%u.%u.%u", has_destaddr ? "IOCTLV_SO_SENDTO " : "IOCTLV_SO_SEND ", ReturnValue, fd, BufferIn, BufferInSize, BufferIn2, BufferInSize2, local_name.sin_addr.s_addr & 0xFF, @@ -542,9 +542,9 @@ void WiiSocket::Update(bool read, bool write, bool except) ReturnValue = WiiSockMan::GetNetErrorCode(ret, BufferOutSize2 ? "SO_RECVFROM" : "SO_RECV", true); - INFO_LOG(WII_IPC_NET, "%s(%d, %p) Socket: %08X, Flags: %08X, " - "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " - "BufferOut: (%08x, %i), BufferOut2: (%08x, %i)", + INFO_LOG(IOS_NET, "%s(%d, %p) Socket: %08X, Flags: %08X, " + "BufferIn: (%08x, %i), BufferIn2: (%08x, %i), " + "BufferOut: (%08x, %i), BufferOut2: (%08x, %i)", BufferOutSize2 ? "IOCTLV_SO_RECVFROM " : "IOCTLV_SO_RECV ", ReturnValue, data, fd, flags, BufferIn, BufferInSize, BufferIn2, BufferInSize2, BufferOut, BufferOutSize, BufferOut2, BufferOutSize2); @@ -567,7 +567,7 @@ void WiiSocket::Update(bool read, bool write, bool except) ReturnValue != -SO_EALREADY) || (it->is_ssl && ReturnValue != SSL_ERR_WAGAIN && ReturnValue != SSL_ERR_RAGAIN)) { - DEBUG_LOG(WII_IPC_NET, + DEBUG_LOG(IOS_NET, "IOCTL(V) Sock: %08x ioctl/v: %d returned: %d nonBlock: %d forceNonBlock: %d", fd, it->is_ssl ? (int)it->ssl_type : (int)it->net_type, ReturnValue, nonBlock, forceNonBlock); diff --git a/Source/Core/Core/IPC_HLE/WII_Socket.h b/Source/Core/Core/IOS/Network/Socket.h similarity index 94% rename from Source/Core/Core/IPC_HLE/WII_Socket.h rename to Source/Core/Core/IOS/Network/Socket.h index 6736fe4899..b0db89bc3c 100644 --- a/Source/Core/Core/IPC_HLE/WII_Socket.h +++ b/Source/Core/Core/IOS/Network/Socket.h @@ -52,9 +52,9 @@ typedef struct pollfd pollfd_t; #include "Common/Logging/Log.h" #include "Common/NonCopyable.h" #include "Core/HW/Memmap.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_net.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h" +#include "Core/IOS/IPC.h" +#include "Core/IOS/Network/Net.h" +#include "Core/IOS/Network/SSL.h" namespace IOS { @@ -232,8 +232,8 @@ public: auto socket_entry = WiiSockets.find(sock); if (socket_entry == WiiSockets.end()) { - ERROR_LOG(WII_IPC_NET, "DoSock: Error, fd not found (%08x, %08X, %08X)", sock, - request.address, type); + ERROR_LOG(IOS_NET, "DoSock: Error, fd not found (%08x, %08X, %08X)", sock, request.address, + type); EnqueueReply(request, -SO_EBADF); } else diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp b/Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp similarity index 74% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp rename to Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp index a33afc4703..4d324795bc 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp +++ b/Source/Core/Core/IOS/SDIO/SDIOSlot0.cpp @@ -14,20 +14,20 @@ #include "Common/SDCardUtil.h" #include "Core/ConfigManager.h" #include "Core/HW/Memmap.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.h" +#include "Core/IOS/IPC.h" +#include "Core/IOS/SDIO/SDIOSlot0.h" namespace IOS { namespace HLE { -CWII_IPC_HLE_Device_sdio_slot0::CWII_IPC_HLE_Device_sdio_slot0(const u32 device_id, - const std::string& device_name) - : IWII_IPC_HLE_Device(device_id, device_name) +namespace Device +{ +SDIOSlot0::SDIOSlot0(u32 device_id, const std::string& device_name) : Device(device_id, device_name) { } -void CWII_IPC_HLE_Device_sdio_slot0::DoState(PointerWrap& p) +void SDIOSlot0::DoState(PointerWrap& p) { DoStateShared(p); if (p.GetMode() == PointerWrap::MODE_READ) @@ -40,7 +40,7 @@ void CWII_IPC_HLE_Device_sdio_slot0::DoState(PointerWrap& p) p.Do(m_registers); } -void CWII_IPC_HLE_Device_sdio_slot0::EventNotify() +void SDIOSlot0::EventNotify() { if (!m_event) return; @@ -54,27 +54,27 @@ void CWII_IPC_HLE_Device_sdio_slot0::EventNotify() } } -void CWII_IPC_HLE_Device_sdio_slot0::OpenInternal() +void SDIOSlot0::OpenInternal() { const std::string filename = File::GetUserPath(F_WIISDCARD_IDX); m_Card.Open(filename, "r+b"); if (!m_Card) { - WARN_LOG(WII_IPC_SD, "Failed to open SD Card image, trying to create a new 128MB image..."); + WARN_LOG(IOS_SD, "Failed to open SD Card image, trying to create a new 128MB image..."); if (SDCardCreate(128, filename)) { - INFO_LOG(WII_IPC_SD, "Successfully created %s", filename.c_str()); + INFO_LOG(IOS_SD, "Successfully created %s", filename.c_str()); m_Card.Open(filename, "r+b"); } if (!m_Card) { - ERROR_LOG(WII_IPC_SD, "Could not open SD Card image or create a new one, are you running " - "from a read-only directory?"); + ERROR_LOG(IOS_SD, "Could not open SD Card image or create a new one, are you running " + "from a read-only directory?"); } } } -IOSReturnCode CWII_IPC_HLE_Device_sdio_slot0::Open(const IOSOpenRequest& request) +IOSReturnCode SDIOSlot0::Open(const IOSOpenRequest& request) { OpenInternal(); m_registers.fill(0); @@ -83,7 +83,7 @@ IOSReturnCode CWII_IPC_HLE_Device_sdio_slot0::Open(const IOSOpenRequest& request return IPC_SUCCESS; } -void CWII_IPC_HLE_Device_sdio_slot0::Close() +void SDIOSlot0::Close() { m_Card.Close(); m_BlockLength = 0; @@ -93,7 +93,7 @@ void CWII_IPC_HLE_Device_sdio_slot0::Close() } // The front SD slot -IPCCommandResult CWII_IPC_HLE_Device_sdio_slot0::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult SDIOSlot0::IOCtl(const IOSIOCtlRequest& request) { Memory::Memset(request.buffer_out, 0, request.buffer_out_size); s32 return_value = IPC_SUCCESS; @@ -104,11 +104,11 @@ IPCCommandResult CWII_IPC_HLE_Device_sdio_slot0::IOCtl(const IOSIOCtlRequest& re u32 reg = Memory::Read_U32(request.buffer_in); u32 val = Memory::Read_U32(request.buffer_in + 16); - INFO_LOG(WII_IPC_SD, "IOCTL_WRITEHCR 0x%08x - 0x%08x", reg, val); + INFO_LOG(IOS_SD, "IOCTL_WRITEHCR 0x%08x - 0x%08x", reg, val); if (reg >= m_registers.size()) { - WARN_LOG(WII_IPC_SD, "IOCTL_WRITEHCR out of range"); + WARN_LOG(IOS_SD, "IOCTL_WRITEHCR out of range"); break; } @@ -136,12 +136,12 @@ IPCCommandResult CWII_IPC_HLE_Device_sdio_slot0::IOCtl(const IOSIOCtlRequest& re if (reg >= m_registers.size()) { - WARN_LOG(WII_IPC_SD, "IOCTL_READHCR out of range"); + WARN_LOG(IOS_SD, "IOCTL_READHCR out of range"); break; } u32 val = m_registers[reg]; - INFO_LOG(WII_IPC_SD, "IOCTL_READHCR 0x%08x - 0x%08x", reg, val); + INFO_LOG(IOS_SD, "IOCTL_READHCR 0x%08x - 0x%08x", reg, val); // Just reading the register Memory::Write_U32(val, request.buffer_out); @@ -149,7 +149,7 @@ IPCCommandResult CWII_IPC_HLE_Device_sdio_slot0::IOCtl(const IOSIOCtlRequest& re break; case IOCTL_RESETCARD: - INFO_LOG(WII_IPC_SD, "IOCTL_RESETCARD"); + INFO_LOG(IOS_SD, "IOCTL_RESETCARD"); if (m_Card) m_Status |= CARD_INITIALIZED; // Returns 16bit RCA and 16bit 0s (meaning success) @@ -158,17 +158,17 @@ IPCCommandResult CWII_IPC_HLE_Device_sdio_slot0::IOCtl(const IOSIOCtlRequest& re case IOCTL_SETCLK: { - INFO_LOG(WII_IPC_SD, "IOCTL_SETCLK"); + INFO_LOG(IOS_SD, "IOCTL_SETCLK"); // libogc only sets it to 1 and makes sure the return isn't negative... // one half of the sdclk divisor: a power of two or zero. u32 clock = Memory::Read_U32(request.buffer_in); if (clock != 1) - INFO_LOG(WII_IPC_SD, "Setting to %i, interesting", clock); + INFO_LOG(IOS_SD, "Setting to %i, interesting", clock); } break; case IOCTL_SENDCMD: - INFO_LOG(WII_IPC_SD, "IOCTL_SENDCMD %x IPC:%08x", Memory::Read_U32(request.buffer_in), + INFO_LOG(IOS_SD, "IOCTL_SENDCMD %x IPC:%08x", Memory::Read_U32(request.buffer_in), request.address); return_value = ExecuteCommand(request, request.buffer_in, request.buffer_in_size, 0, 0, request.buffer_out, request.buffer_out_size); @@ -179,19 +179,19 @@ IPCCommandResult CWII_IPC_HLE_Device_sdio_slot0::IOCtl(const IOSIOCtlRequest& re m_Status |= CARD_INSERTED; else m_Status = CARD_NOT_EXIST; - INFO_LOG(WII_IPC_SD, "IOCTL_GETSTATUS. Replying that SD card is %s%s", + INFO_LOG(IOS_SD, "IOCTL_GETSTATUS. Replying that SD card is %s%s", (m_Status & CARD_INSERTED) ? "inserted" : "not present", (m_Status & CARD_INITIALIZED) ? " and initialized" : ""); Memory::Write_U32(m_Status, request.buffer_out); break; case IOCTL_GETOCR: - INFO_LOG(WII_IPC_SD, "IOCTL_GETOCR"); + INFO_LOG(IOS_SD, "IOCTL_GETOCR"); Memory::Write_U32(0x80ff8000, request.buffer_out); break; default: - ERROR_LOG(WII_IPC_SD, "Unknown SD IOCtl command (0x%08x)", request.request); + ERROR_LOG(IOS_SD, "Unknown SD IOCtl command (0x%08x)", request.request); break; } @@ -204,13 +204,13 @@ IPCCommandResult CWII_IPC_HLE_Device_sdio_slot0::IOCtl(const IOSIOCtlRequest& re return GetDefaultReply(return_value); } -IPCCommandResult CWII_IPC_HLE_Device_sdio_slot0::IOCtlV(const IOSIOCtlVRequest& request) +IPCCommandResult SDIOSlot0::IOCtlV(const IOSIOCtlVRequest& request) { s32 return_value = IPC_SUCCESS; switch (request.request) { case IOCTLV_SENDCMD: - DEBUG_LOG(WII_IPC_SD, "IOCTLV_SENDCMD 0x%08x", Memory::Read_U32(request.in_vectors[0].address)); + DEBUG_LOG(IOS_SD, "IOCTLV_SENDCMD 0x%08x", Memory::Read_U32(request.in_vectors[0].address)); Memory::Memset(request.io_vectors[0].address, 0, request.io_vectors[0].size); return_value = ExecuteCommand(request, request.in_vectors[0].address, request.in_vectors[0].size, @@ -219,16 +219,14 @@ IPCCommandResult CWII_IPC_HLE_Device_sdio_slot0::IOCtlV(const IOSIOCtlVRequest& break; default: - ERROR_LOG(WII_IPC_SD, "Unknown SD IOCtlV command 0x%08x", request.request); + ERROR_LOG(IOS_SD, "Unknown SD IOCtlV command 0x%08x", request.request); } return GetDefaultReply(return_value); } -u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(const IOSRequest& request, u32 _BufferIn, - u32 _BufferInSize, u32 _rwBuffer, - u32 _rwBufferSize, u32 _BufferOut, - u32 _BufferOutSize) +u32 SDIOSlot0::ExecuteCommand(const IOSRequest& request, u32 _BufferIn, u32 _BufferInSize, + u32 _rwBuffer, u32 _rwBufferSize, u32 _BufferOut, u32 _BufferOutSize) { // The game will send us a SendCMD with this information. To be able to read and write // to a file we need to prepare a 0x10 byte output buffer as response. @@ -284,7 +282,7 @@ u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(const IOSRequest& request, u3 break; case SEND_CSD: - INFO_LOG(WII_IPC_SD, "SEND_CSD"); + INFO_LOG(IOS_SD, "SEND_CSD"); // shuffle2_, OCR: 0x80ff8000 CID: 0x38a00000 0x480032d5 0x3c608030 0x8803d420 // CSD: 0xff928040 0xc93efbcf 0x325f5a83 0x00002600 @@ -297,7 +295,7 @@ u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(const IOSRequest& request, u3 case ALL_SEND_CID: case SEND_CID: - INFO_LOG(WII_IPC_SD, "(ALL_)SEND_CID"); + INFO_LOG(IOS_SD, "(ALL_)SEND_CID"); Memory::Write_U32(0x80114d1c, _BufferOut); Memory::Write_U32(0x80080000, _BufferOut + 4); Memory::Write_U32(0x8007b520, _BufferOut + 8); @@ -330,7 +328,7 @@ u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(const IOSRequest& request, u3 { // Data address (req.arg) is in byte units in a Standard Capacity SD Memory Card // and in block (512 Byte) units in a High Capacity SD Memory Card. - INFO_LOG(WII_IPC_SD, "%sRead %i Block(s) from 0x%08x bsize %i into 0x%08x!", + INFO_LOG(IOS_SD, "%sRead %i Block(s) from 0x%08x bsize %i into 0x%08x!", req.isDMA ? "DMA " : "", req.blocks, req.arg, req.bsize, req.addr); if (m_Card) @@ -338,15 +336,15 @@ u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(const IOSRequest& request, u3 u32 size = req.bsize * req.blocks; if (!m_Card.Seek(req.arg, SEEK_SET)) - ERROR_LOG(WII_IPC_SD, "Seek failed WTF"); + ERROR_LOG(IOS_SD, "Seek failed WTF"); if (m_Card.ReadBytes(Memory::GetPointer(req.addr), size)) { - DEBUG_LOG(WII_IPC_SD, "Outbuffer size %i got %i", _rwBufferSize, size); + DEBUG_LOG(IOS_SD, "Outbuffer size %i got %i", _rwBufferSize, size); } else { - ERROR_LOG(WII_IPC_SD, "Read Failed - error: %i, eof: %i", ferror(m_Card.GetHandle()), + ERROR_LOG(IOS_SD, "Read Failed - error: %i, eof: %i", ferror(m_Card.GetHandle()), feof(m_Card.GetHandle())); ret = RET_FAIL; } @@ -359,7 +357,7 @@ u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(const IOSRequest& request, u3 { // Data address (req.arg) is in byte units in a Standard Capacity SD Memory Card // and in block (512 Byte) units in a High Capacity SD Memory Card. - INFO_LOG(WII_IPC_SD, "%sWrite %i Block(s) from 0x%08x bsize %i to offset 0x%08x!", + INFO_LOG(IOS_SD, "%sWrite %i Block(s) from 0x%08x bsize %i to offset 0x%08x!", req.isDMA ? "DMA " : "", req.blocks, req.addr, req.bsize, req.arg); if (m_Card && SConfig::GetInstance().bEnableMemcardSdWriting) @@ -367,11 +365,11 @@ u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(const IOSRequest& request, u3 u32 size = req.bsize * req.blocks; if (!m_Card.Seek(req.arg, SEEK_SET)) - ERROR_LOG(WII_IPC_SD, "fseeko failed WTF"); + ERROR_LOG(IOS_SD, "fseeko failed WTF"); if (!m_Card.WriteBytes(Memory::GetPointer(req.addr), size)) { - ERROR_LOG(WII_IPC_SD, "Write Failed - error: %i, eof: %i", ferror(m_Card.GetHandle()), + ERROR_LOG(IOS_SD, "Write Failed - error: %i, eof: %i", ferror(m_Card.GetHandle()), feof(m_Card.GetHandle())); ret = RET_FAIL; } @@ -381,7 +379,7 @@ u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(const IOSRequest& request, u3 break; case EVENT_REGISTER: // async - INFO_LOG(WII_IPC_SD, "Register event %x", req.arg); + INFO_LOG(IOS_SD, "Register event %x", req.arg); m_event = std::make_unique(static_cast(req.arg), request); ret = RET_EVENT_REGISTER; break; @@ -389,7 +387,7 @@ u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(const IOSRequest& request, u3 // Used to cancel an event that was already registered. case EVENT_UNREGISTER: { - INFO_LOG(WII_IPC_SD, "Unregister event %x", req.arg); + INFO_LOG(IOS_SD, "Unregister event %x", req.arg); if (!m_event) return IPC_EINVAL; // release returns 0 @@ -401,11 +399,12 @@ u32 CWII_IPC_HLE_Device_sdio_slot0::ExecuteCommand(const IOSRequest& request, u3 } default: - ERROR_LOG(WII_IPC_SD, "Unknown SD command 0x%08x", req.command); + ERROR_LOG(IOS_SD, "Unknown SD command 0x%08x", req.command); break; } return ret; } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.h b/Source/Core/Core/IOS/SDIO/SDIOSlot0.h similarity index 91% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.h rename to Source/Core/Core/IOS/SDIO/SDIOSlot0.h index 2c349546fe..69106da61a 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.h +++ b/Source/Core/Core/IOS/SDIO/SDIOSlot0.h @@ -11,8 +11,8 @@ #include "Common/CommonTypes.h" #include "Common/FileUtil.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device.h" +#include "Core/IOS/Device.h" +#include "Core/IOS/IPC.h" class PointerWrap; @@ -20,10 +20,12 @@ namespace IOS { namespace HLE { -class CWII_IPC_HLE_Device_sdio_slot0 : public IWII_IPC_HLE_Device +namespace Device +{ +class SDIOSlot0 : public Device { public: - CWII_IPC_HLE_Device_sdio_slot0(u32 device_id, const std::string& device_name); + SDIOSlot0(u32 device_id, const std::string& device_name); void DoState(PointerWrap& p) override; @@ -129,5 +131,6 @@ private: u32 BufferInSize2, u32 _BufferOut, u32 BufferOutSize); void OpenInternal(); }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stm.cpp b/Source/Core/Core/IOS/STM/STM.cpp similarity index 64% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stm.cpp rename to Source/Core/Core/IOS/STM/STM.cpp index 5a6af84273..abd2387366 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stm.cpp +++ b/Source/Core/Core/IOS/STM/STM.cpp @@ -2,7 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include "Core/IPC_HLE/WII_IPC_HLE_Device_stm.h" +#include "Core/IOS/STM/STM.h" #include #include @@ -21,16 +21,18 @@ namespace IOS { namespace HLE { +namespace Device +{ static std::unique_ptr s_event_hook_request; -IPCCommandResult CWII_IPC_HLE_Device_stm_immediate::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult STMImmediate::IOCtl(const IOSIOCtlRequest& request) { s32 return_value = IPC_SUCCESS; switch (request.request) { case IOCTL_STM_IDLE: case IOCTL_STM_SHUTDOWN: - NOTICE_LOG(WII_IPC_STM, "IOCTL_STM_IDLE or IOCTL_STM_SHUTDOWN received, shutting down"); + NOTICE_LOG(IOS_STM, "IOCTL_STM_IDLE or IOCTL_STM_SHUTDOWN received, shutting down"); Core::QueueHostJob(&Core::Stop, false); break; @@ -46,42 +48,39 @@ IPCCommandResult CWII_IPC_HLE_Device_stm_immediate::IOCtl(const IOSIOCtlRequest& break; case IOCTL_STM_HOTRESET: - INFO_LOG(WII_IPC_STM, "%s - IOCtl:", GetDeviceName().c_str()); - INFO_LOG(WII_IPC_STM, " IOCTL_STM_HOTRESET"); + INFO_LOG(IOS_STM, "%s - IOCtl:", GetDeviceName().c_str()); + INFO_LOG(IOS_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"); + INFO_LOG(IOS_STM, "%s - IOCtl:", GetDeviceName().c_str()); + INFO_LOG(IOS_STM, " IOCTL_STM_VIDIMMING"); // Memory::Write_U32(1, buffer_out); // return_value = 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"); + INFO_LOG(IOS_STM, "%s - IOCtl:", GetDeviceName().c_str()); + INFO_LOG(IOS_STM, " IOCTL_STM_LEDMODE"); break; default: - request.DumpUnknown(GetDeviceName(), LogTypes::WII_IPC_STM); + request.DumpUnknown(GetDeviceName(), LogTypes::IOS_STM); } return GetDefaultReply(return_value); } -void CWII_IPC_HLE_Device_stm_eventhook::Close() +void STMEventHook::Close() { s_event_hook_request.reset(); m_is_active = false; } -IPCCommandResult CWII_IPC_HLE_Device_stm_eventhook::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult STMEventHook::IOCtl(const IOSIOCtlRequest& request) { if (request.request != IOCTL_STM_EVENTHOOK) - { - ERROR_LOG(WII_IPC_STM, "Bad IOCtl in CWII_IPC_HLE_Device_stm_eventhook"); return GetDefaultReply(IPC_EINVAL); - } if (s_event_hook_request) return GetDefaultReply(IPC_EEXIST); @@ -91,12 +90,12 @@ IPCCommandResult CWII_IPC_HLE_Device_stm_eventhook::IOCtl(const IOSIOCtlRequest& return GetNoReply(); } -bool CWII_IPC_HLE_Device_stm_eventhook::HasHookInstalled() const +bool STMEventHook::HasHookInstalled() const { return s_event_hook_request != nullptr; } -void CWII_IPC_HLE_Device_stm_eventhook::TriggerEvent(const u32 event) const +void STMEventHook::TriggerEvent(const u32 event) const { // If the device isn't open, ignore the button press. if (!m_is_active || !s_event_hook_request) @@ -107,15 +106,16 @@ void CWII_IPC_HLE_Device_stm_eventhook::TriggerEvent(const u32 event) const s_event_hook_request.reset(); } -void CWII_IPC_HLE_Device_stm_eventhook::ResetButton() const +void STMEventHook::ResetButton() const { // The reset button triggers STM_EVENT_RESET. TriggerEvent(STM_EVENT_RESET); } -void CWII_IPC_HLE_Device_stm_eventhook::PowerButton() const +void STMEventHook::PowerButton() const { TriggerEvent(STM_EVENT_POWER); } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stm.h b/Source/Core/Core/IOS/STM/STM.h similarity index 68% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stm.h rename to Source/Core/Core/IOS/STM/STM.h index 4ba8e29672..40c804ce02 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stm.h +++ b/Source/Core/Core/IOS/STM/STM.h @@ -7,8 +7,8 @@ #include #include "Common/CommonTypes.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device.h" +#include "Core/IOS/Device.h" +#include "Core/IOS/IPC.h" namespace IOS { @@ -38,27 +38,21 @@ enum STM_EVENT_POWER = 0x00000800 }; +namespace Device +{ // The /dev/stm/immediate -class CWII_IPC_HLE_Device_stm_immediate final : public IWII_IPC_HLE_Device +class STMImmediate final : public Device { public: - CWII_IPC_HLE_Device_stm_immediate(u32 device_id, const std::string& device_name) - : IWII_IPC_HLE_Device(device_id, device_name) - { - } - + STMImmediate(u32 device_id, const std::string& device_name) : Device(device_id, device_name) {} IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override; }; // The /dev/stm/eventhook -class CWII_IPC_HLE_Device_stm_eventhook final : public IWII_IPC_HLE_Device +class STMEventHook final : public Device { public: - CWII_IPC_HLE_Device_stm_eventhook(u32 device_id, const std::string& device_name) - : IWII_IPC_HLE_Device(device_id, device_name) - { - } - + STMEventHook(u32 device_id, const std::string& device_name) : Device(device_id, device_name) {} void Close() override; IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override; @@ -69,5 +63,6 @@ public: private: void TriggerEvent(u32 event) const; }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.cpp b/Source/Core/Core/IOS/USB/Bluetooth/BTBase.cpp similarity index 72% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.cpp rename to Source/Core/Core/IOS/USB/Bluetooth/BTBase.cpp index a9148d8752..ede3685820 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.cpp +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTBase.cpp @@ -14,7 +14,7 @@ #include "Common/Logging/Log.h" #include "Common/SysConf.h" #include "Core/HW/Memmap.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.h" +#include "Core/IOS/USB/Bluetooth/BTBase.h" namespace IOS { @@ -31,11 +31,11 @@ void BackUpBTInfoSection(SysConf* sysconf) std::vector section(BT_INFO_SECTION_LENGTH); if (!sysconf->GetArrayData("BT.DINF", section.data(), static_cast(section.size()))) { - ERROR_LOG(WII_IPC_WIIMOTE, "Failed to read source BT.DINF section"); + ERROR_LOG(IOS_WIIMOTE, "Failed to read source BT.DINF section"); return; } if (!backup.WriteBytes(section.data(), section.size())) - ERROR_LOG(WII_IPC_WIIMOTE, "Failed to back up BT.DINF section"); + ERROR_LOG(IOS_WIIMOTE, "Failed to back up BT.DINF section"); } void RestoreBTInfoSection(SysConf* sysconf) @@ -47,15 +47,16 @@ void RestoreBTInfoSection(SysConf* sysconf) std::vector section(BT_INFO_SECTION_LENGTH); if (!backup.ReadBytes(section.data(), section.size())) { - ERROR_LOG(WII_IPC_WIIMOTE, "Failed to read backed up BT.DINF section"); + ERROR_LOG(IOS_WIIMOTE, "Failed to read backed up BT.DINF section"); return; } sysconf->SetArrayData("BT.DINF", section.data(), static_cast(section.size())); File::Delete(filename); } -CWII_IPC_HLE_Device_usb_oh1_57e_305_base::CtrlMessage::CtrlMessage(const IOSIOCtlVRequest& ioctlv) - : ios_request(ioctlv) +namespace Device +{ +BluetoothBase::CtrlMessage::CtrlMessage(const IOSIOCtlVRequest& ioctlv) : ios_request(ioctlv) { request_type = Memory::Read_U8(ioctlv.in_vectors[0].address); request = Memory::Read_U8(ioctlv.in_vectors[1].address); @@ -65,20 +66,19 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305_base::CtrlMessage::CtrlMessage(const IOSIOCt payload_addr = ioctlv.io_vectors[0].address; } -CWII_IPC_HLE_Device_usb_oh1_57e_305_base::CtrlBuffer::CtrlBuffer(const IOSIOCtlVRequest& ioctlv) - : ios_request(ioctlv) +BluetoothBase::CtrlBuffer::CtrlBuffer(const IOSIOCtlVRequest& ioctlv) : ios_request(ioctlv) { m_endpoint = Memory::Read_U8(ioctlv.in_vectors[0].address); m_length = Memory::Read_U16(ioctlv.in_vectors[1].address); m_payload_addr = ioctlv.io_vectors[0].address; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_base::CtrlBuffer::FillBuffer(const u8* src, - const size_t size) const +void BluetoothBase::CtrlBuffer::FillBuffer(const u8* src, const size_t size) const { - _assert_msg_(WII_IPC_WIIMOTE, size <= m_length, "FillBuffer: size %li > payload length %i", size, + _assert_msg_(IOS_WIIMOTE, size <= m_length, "FillBuffer: size %li > payload length %i", size, m_length); Memory::CopyToEmu(m_payload_addr, src, size); } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.h b/Source/Core/Core/IOS/USB/Bluetooth/BTBase.h similarity index 82% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.h rename to Source/Core/Core/IOS/USB/Bluetooth/BTBase.h index c6889dcf5b..2677ff45a8 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.h +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTBase.h @@ -8,8 +8,8 @@ #include #include "Common/CommonTypes.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device.h" +#include "Core/IOS/Device.h" +#include "Core/IOS/IPC.h" class PointerWrap; class SysConf; @@ -21,14 +21,12 @@ namespace HLE void BackUpBTInfoSection(SysConf* sysconf); void RestoreBTInfoSection(SysConf* sysconf); -class CWII_IPC_HLE_Device_usb_oh1_57e_305_base : public IWII_IPC_HLE_Device +namespace Device +{ +class BluetoothBase : public Device { public: - CWII_IPC_HLE_Device_usb_oh1_57e_305_base(u32 device_id, const std::string& device_name) - : IWII_IPC_HLE_Device(device_id, device_name) - { - } - + BluetoothBase(u32 device_id, const std::string& device_name) : Device(device_id, device_name) {} virtual void UpdateSyncButtonState(bool is_held) {} virtual void TriggerSyncButtonPressedEvent() {} virtual void TriggerSyncButtonHeldEvent() {} @@ -75,5 +73,6 @@ protected: u32 m_payload_addr = 0; }; }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.cpp b/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp similarity index 62% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.cpp rename to Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp index 568a51e079..cb1b2945a4 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.cpp +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.cpp @@ -22,10 +22,9 @@ #include "Core/HW/SystemTimers.h" #include "Core/HW/Wiimote.h" #include "Core/Host.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_usb_bt_emu.h" -#include "Core/IPC_HLE/WII_IPC_HLE_WiiMote.h" +#include "Core/IOS/Device.h" +#include "Core/IOS/IPC.h" +#include "Core/IOS/USB/Bluetooth/BTEmu.h" #include "InputCommon/ControllerInterface/ControllerInterface.h" namespace IOS @@ -38,10 +37,10 @@ SQueuedEvent::SQueuedEvent(u32 size, u16 handle) : m_size(size), m_connectionHan PanicAlert("SQueuedEvent: The size is too large."); } -// The device class -CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CWII_IPC_HLE_Device_usb_oh1_57e_305_emu( - u32 _DeviceID, const std::string& _rDeviceName) - : CWII_IPC_HLE_Device_usb_oh1_57e_305_base(_DeviceID, _rDeviceName) +namespace Device +{ +BluetoothEmu::BluetoothEmu(u32 device_id, const std::string& device_name) + : BluetoothBase(device_id, device_name) { SysConf sysconf{Core::g_want_determinism ? Common::FromWhichRoot::FROM_SESSION_ROOT : Common::FromWhichRoot::FROM_CONFIGURED_ROOT}; @@ -78,9 +77,9 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CWII_IPC_HLE_Device_usb_oh1_57e_305_emu memcpy(BT_DINF.registered[i].name, wmName, 20); memcpy(BT_DINF.active[i].name, wmName, 20); - DEBUG_LOG(WII_IPC_WIIMOTE, "Wii Remote %d BT ID %x,%x,%x,%x,%x,%x", i, tmpBD.b[0], tmpBD.b[1], + DEBUG_LOG(IOS_WIIMOTE, "Wii Remote %d BT ID %x,%x,%x,%x,%x,%x", i, tmpBD.b[0], tmpBD.b[1], tmpBD.b[2], tmpBD.b[3], tmpBD.b[4], tmpBD.b[5]); - m_WiiMotes.push_back(CWII_IPC_HLE_WiiMote(this, i, tmpBD, false)); + m_WiiMotes.emplace_back(this, i, tmpBD, false); i++; } @@ -102,7 +101,7 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CWII_IPC_HLE_Device_usb_oh1_57e_305_emu Host_SetWiiMoteConnectionState(0); } -CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::~CWII_IPC_HLE_Device_usb_oh1_57e_305_emu() +BluetoothEmu::~BluetoothEmu() { m_WiiMotes.clear(); SetUsbPointer(nullptr); @@ -120,7 +119,7 @@ static void DoStateForMessage(PointerWrap& p, std::unique_ptr& message) } } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::DoState(PointerWrap& p) +void BluetoothEmu::DoState(PointerWrap& p) { bool passthrough_bluetooth = false; p.Do(passthrough_bluetooth); @@ -146,12 +145,12 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::DoState(PointerWrap& p) m_WiiMotes[i].DoState(p); } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::RemoteDisconnect(u16 _connectionHandle) +bool BluetoothEmu::RemoteDisconnect(u16 _connectionHandle) { return SendEventDisconnect(_connectionHandle, 0x13); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::Close() +void BluetoothEmu::Close() { // Clean up state m_ScanEnable = 0; @@ -163,7 +162,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::Close() m_is_active = false; } -IPCCommandResult CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::IOCtlV(const IOSIOCtlVRequest& request) +IPCCommandResult BluetoothEmu::IOCtlV(const IOSIOCtlVRequest& request) { bool send_reply = true; switch (request.request) @@ -189,8 +188,8 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::IOCtlV(const IOSIOCtlV const auto* acl_header = reinterpret_cast(Memory::GetPointer(ctrl.m_payload_addr)); - _dbg_assert_(WII_IPC_WIIMOTE, HCI_BC_FLAG(acl_header->con_handle) == HCI_POINT2POINT); - _dbg_assert_(WII_IPC_WIIMOTE, HCI_PB_FLAG(acl_header->con_handle) == HCI_PACKET_START); + _dbg_assert_(IOS_WIIMOTE, HCI_BC_FLAG(acl_header->con_handle) == HCI_POINT2POINT); + _dbg_assert_(IOS_WIIMOTE, HCI_PB_FLAG(acl_header->con_handle) == HCI_PACKET_START); SendToDevice(HCI_CON_HANDLE(acl_header->con_handle), Memory::GetPointer(ctrl.m_payload_addr + sizeof(hci_acldata_hdr_t)), @@ -200,12 +199,12 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::IOCtlV(const IOSIOCtlV case ACL_DATA_IN: // We are given an ACL buffer to fill { m_ACLEndpoint = std::make_unique(request); - DEBUG_LOG(WII_IPC_WIIMOTE, "ACL_DATA_IN: 0x%08x ", request.address); + DEBUG_LOG(IOS_WIIMOTE, "ACL_DATA_IN: 0x%08x ", request.address); send_reply = false; break; } default: - _dbg_assert_msg_(WII_IPC_WIIMOTE, 0, "Unknown USBV0_IOCTL_BLKMSG: %x", ctrl.m_endpoint); + _dbg_assert_msg_(IOS_WIIMOTE, 0, "Unknown USBV0_IOCTL_BLKMSG: %x", ctrl.m_endpoint); } break; } @@ -216,51 +215,49 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::IOCtlV(const IOSIOCtlV if (ctrl.m_endpoint == HCI_EVENT) // We are given a HCI buffer to fill { m_HCIEndpoint = std::make_unique(request); - DEBUG_LOG(WII_IPC_WIIMOTE, "HCI_EVENT: 0x%08x ", request.address); + DEBUG_LOG(IOS_WIIMOTE, "HCI_EVENT: 0x%08x ", request.address); send_reply = false; } else { - _dbg_assert_msg_(WII_IPC_WIIMOTE, 0, "Unknown USBV0_IOCTL_INTRMSG: %x", ctrl.m_endpoint); + _dbg_assert_msg_(IOS_WIIMOTE, 0, "Unknown USBV0_IOCTL_INTRMSG: %x", ctrl.m_endpoint); } break; } default: - request.DumpUnknown(GetDeviceName(), LogTypes::WII_IPC_WIIMOTE); + request.DumpUnknown(GetDeviceName(), LogTypes::IOS_WIIMOTE); } return send_reply ? GetDefaultReply(IPC_SUCCESS) : GetNoReply(); } // Here we handle the USBV0_IOCTL_BLKMSG Ioctlv -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendToDevice(u16 _ConnectionHandle, u8* _pData, - u32 _Size) +void BluetoothEmu::SendToDevice(u16 _ConnectionHandle, u8* _pData, u32 _Size) { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_ConnectionHandle); + WiimoteDevice* pWiiMote = AccessWiiMote(_ConnectionHandle); if (pWiiMote == nullptr) return; - DEBUG_LOG(WII_IPC_WIIMOTE, "Send ACL Packet to ConnectionHandle 0x%04x", _ConnectionHandle); + DEBUG_LOG(IOS_WIIMOTE, "Send ACL Packet to ConnectionHandle 0x%04x", _ConnectionHandle); IncDataPacket(_ConnectionHandle); pWiiMote->ExecuteL2capCmd(_pData, _Size); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::IncDataPacket(u16 _ConnectionHandle) +void BluetoothEmu::IncDataPacket(u16 _ConnectionHandle) { m_PacketCount[_ConnectionHandle & 0xff]++; } // Here we send ACL packets to CPU. They will consist of header + data. // The header is for example 07 00 41 00 which means size 0x0007 and channel 0x0041. -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendACLPacket(u16 connection_handle, const u8* data, - u32 size) +void BluetoothEmu::SendACLPacket(u16 connection_handle, const u8* data, u32 size) { - DEBUG_LOG(WII_IPC_WIIMOTE, "ACL packet from %x ready to send to stack...", connection_handle); + DEBUG_LOG(IOS_WIIMOTE, "ACL packet from %x ready to send to stack...", connection_handle); if (m_ACLEndpoint && !m_HCIEndpoint && m_EventQueue.empty()) { - DEBUG_LOG(WII_IPC_WIIMOTE, "ACL endpoint valid, sending packet to %08x", + DEBUG_LOG(IOS_WIIMOTE, "ACL endpoint valid, sending packet to %08x", m_ACLEndpoint->ios_request.address); hci_acldata_hdr_t* header = @@ -276,7 +273,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendACLPacket(u16 connection_handl } else { - DEBUG_LOG(WII_IPC_WIIMOTE, "ACL endpoint not currently valid, queuing..."); + DEBUG_LOG(IOS_WIIMOTE, "ACL endpoint not currently valid, queuing..."); m_acl_pool.Store(data, size, connection_handle); } } @@ -284,18 +281,17 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendACLPacket(u16 connection_handl // These messages are sent from the Wii Remote to the game, for example RequestConnection() // or ConnectionComplete(). // -// Our WII_IPC_HLE is so efficient that we could fill the buffer immediately +// Our IOS is so efficient that we could fill the buffer immediately // rather than enqueue it to some other memory and this will do good for StateSave -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::AddEventToQueue(const SQueuedEvent& _event) +void BluetoothEmu::AddEventToQueue(const SQueuedEvent& _event) { - DEBUG_LOG(WII_IPC_WIIMOTE, "HCI event %x completed...", - ((hci_event_hdr_t*)_event.m_buffer)->event); + DEBUG_LOG(IOS_WIIMOTE, "HCI event %x completed...", ((hci_event_hdr_t*)_event.m_buffer)->event); if (m_HCIEndpoint) { if (m_EventQueue.empty()) // fast path :) { - DEBUG_LOG(WII_IPC_WIIMOTE, "HCI endpoint valid, sending packet to %08x", + DEBUG_LOG(IOS_WIIMOTE, "HCI endpoint valid, sending packet to %08x", m_HCIEndpoint->ios_request.address); m_HCIEndpoint->FillBuffer(_event.m_buffer, _event.m_size); @@ -305,12 +301,12 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::AddEventToQueue(const SQueuedEvent } else // push new one, pop oldest { - DEBUG_LOG(WII_IPC_WIIMOTE, "HCI endpoint not currently valid, queueing (%zu)...", + DEBUG_LOG(IOS_WIIMOTE, "HCI endpoint not currently valid, queueing (%zu)...", m_EventQueue.size()); m_EventQueue.push_back(_event); const SQueuedEvent& event = m_EventQueue.front(); - DEBUG_LOG(WII_IPC_WIIMOTE, "HCI event %x " - "being written from queue (%zu) to %08x...", + DEBUG_LOG(IOS_WIIMOTE, "HCI event %x " + "being written from queue (%zu) to %08x...", ((hci_event_hdr_t*)event.m_buffer)->event, m_EventQueue.size() - 1, m_HCIEndpoint->ios_request.address); m_HCIEndpoint->FillBuffer(event.m_buffer, event.m_size); @@ -323,20 +319,20 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::AddEventToQueue(const SQueuedEvent } else { - DEBUG_LOG(WII_IPC_WIIMOTE, "HCI endpoint not currently valid, queuing (%zu)...", + DEBUG_LOG(IOS_WIIMOTE, "HCI endpoint not currently valid, queuing (%zu)...", m_EventQueue.size()); m_EventQueue.push_back(_event); } } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::Update() +void BluetoothEmu::Update() { // check HCI queue if (!m_EventQueue.empty() && m_HCIEndpoint) { // an endpoint has become available, and we have a stored response. const SQueuedEvent& event = m_EventQueue.front(); - DEBUG_LOG(WII_IPC_WIIMOTE, "HCI event %x being written from queue (%zu) to %08x...", + DEBUG_LOG(IOS_WIIMOTE, "HCI event %x being written from queue (%zu) to %08x...", ((hci_event_hdr_t*)event.m_buffer)->event, m_EventQueue.size() - 1, m_HCIEndpoint->ios_request.address); m_HCIEndpoint->FillBuffer(event.m_buffer, event.m_size); @@ -397,17 +393,16 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::Update() SendEventNumberOfCompletedPackets(); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::ACLPool::Store(const u8* data, const u16 size, - const u16 conn_handle) +void BluetoothEmu::ACLPool::Store(const u8* data, const u16 size, const u16 conn_handle) { if (m_queue.size() >= 100) { // Many simultaneous exchanges of ACL packets tend to cause the queue to fill up. - ERROR_LOG(WII_IPC_WIIMOTE, "ACL queue size reached 100 - current packet will be dropped!"); + ERROR_LOG(IOS_WIIMOTE, "ACL queue size reached 100 - current packet will be dropped!"); return; } - _dbg_assert_msg_(WII_IPC_WIIMOTE, size < ACL_PKT_SIZE, "ACL packet too large for pool"); + _dbg_assert_msg_(IOS_WIIMOTE, size < ACL_PKT_SIZE, "ACL packet too large for pool"); m_queue.push_back(Packet()); auto& packet = m_queue.back(); @@ -417,7 +412,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::ACLPool::Store(const u8* data, con packet.conn_handle = conn_handle; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::ACLPool::WriteToEndpoint(CtrlBuffer& endpoint) +void BluetoothEmu::ACLPool::WriteToEndpoint(CtrlBuffer& endpoint) { auto& packet = m_queue.front(); @@ -425,8 +420,8 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::ACLPool::WriteToEndpoint(CtrlBuffe const u16 size = packet.size; const u16 conn_handle = packet.conn_handle; - DEBUG_LOG(WII_IPC_WIIMOTE, "ACL packet being written from " - "queue to %08x", + DEBUG_LOG(IOS_WIIMOTE, "ACL packet being written from " + "queue to %08x", endpoint.ios_request.address); hci_acldata_hdr_t* pHeader = (hci_acldata_hdr_t*)Memory::GetPointer(endpoint.m_payload_addr); @@ -441,7 +436,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::ACLPool::WriteToEndpoint(CtrlBuffe EnqueueReply(endpoint.ios_request, sizeof(hci_acldata_hdr_t) + size); } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventInquiryComplete() +bool BluetoothEmu::SendEventInquiryComplete() { SQueuedEvent Event(sizeof(SHCIEventInquiryComplete), 0); @@ -452,19 +447,19 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventInquiryComplete() AddEventToQueue(Event); - DEBUG_LOG(WII_IPC_WIIMOTE, "Event: Inquiry complete"); + DEBUG_LOG(IOS_WIIMOTE, "Event: Inquiry complete"); return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventInquiryResponse() +bool BluetoothEmu::SendEventInquiryResponse() { if (m_WiiMotes.empty()) return false; - _dbg_assert_(WII_IPC_WIIMOTE, sizeof(SHCIEventInquiryResult) - 2 + - (m_WiiMotes.size() * sizeof(hci_inquiry_response)) < - 256); + _dbg_assert_(IOS_WIIMOTE, sizeof(SHCIEventInquiryResult) - 2 + + (m_WiiMotes.size() * sizeof(hci_inquiry_response)) < + 256); SQueuedEvent Event(static_cast(sizeof(SHCIEventInquiryResult) + m_WiiMotes.size() * sizeof(hci_inquiry_response)), @@ -496,8 +491,8 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventInquiryResponse() pResponse->page_scan_mode = 0; pResponse->clock_offset = 0x3818; - DEBUG_LOG(WII_IPC_WIIMOTE, "Event: Send Fake Inquiry of one controller"); - DEBUG_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", pResponse->bdaddr.b[0], + DEBUG_LOG(IOS_WIIMOTE, "Event: Send Fake Inquiry of one controller"); + DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", pResponse->bdaddr.b[0], pResponse->bdaddr.b[1], pResponse->bdaddr.b[2], pResponse->bdaddr.b[3], pResponse->bdaddr.b[4], pResponse->bdaddr.b[5]); } @@ -507,9 +502,9 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventInquiryResponse() return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventConnectionComplete(const bdaddr_t& _bd) +bool BluetoothEmu::SendEventConnectionComplete(const bdaddr_t& _bd) { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_bd); + WiimoteDevice* pWiiMote = AccessWiiMote(_bd); if (pWiiMote == nullptr) return false; @@ -527,7 +522,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventConnectionComplete(const AddEventToQueue(Event); - CWII_IPC_HLE_WiiMote* pWiimote = AccessWiiMote(pConnectionComplete->Connection_Handle); + WiimoteDevice* pWiimote = AccessWiiMote(pConnectionComplete->Connection_Handle); if (pWiimote) pWiimote->EventConnectionAccepted(); @@ -537,21 +532,20 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventConnectionComplete(const {"HCI_LINK_eSCO 0x02 - eSCO"}, }; - DEBUG_LOG(WII_IPC_WIIMOTE, "Event: SendEventConnectionComplete"); - DEBUG_LOG(WII_IPC_WIIMOTE, " Connection_Handle: 0x%04x", pConnectionComplete->Connection_Handle); - DEBUG_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", - pConnectionComplete->bdaddr.b[0], pConnectionComplete->bdaddr.b[1], - pConnectionComplete->bdaddr.b[2], pConnectionComplete->bdaddr.b[3], - pConnectionComplete->bdaddr.b[4], pConnectionComplete->bdaddr.b[5]); - DEBUG_LOG(WII_IPC_WIIMOTE, " LinkType: %s", s_szLinkType[pConnectionComplete->LinkType]); - DEBUG_LOG(WII_IPC_WIIMOTE, " EncryptionEnabled: %i", pConnectionComplete->EncryptionEnabled); + DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventConnectionComplete"); + DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", pConnectionComplete->Connection_Handle); + DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", pConnectionComplete->bdaddr.b[0], + pConnectionComplete->bdaddr.b[1], pConnectionComplete->bdaddr.b[2], + pConnectionComplete->bdaddr.b[3], pConnectionComplete->bdaddr.b[4], + pConnectionComplete->bdaddr.b[5]); + DEBUG_LOG(IOS_WIIMOTE, " LinkType: %s", s_szLinkType[pConnectionComplete->LinkType]); + DEBUG_LOG(IOS_WIIMOTE, " EncryptionEnabled: %i", pConnectionComplete->EncryptionEnabled); return true; } // This is called from Update() after ScanEnable has been enabled. -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventRequestConnection( - CWII_IPC_HLE_WiiMote& _rWiiMote) +bool BluetoothEmu::SendEventRequestConnection(WiimoteDevice& _rWiiMote) { SQueuedEvent Event(sizeof(SHCIEventRequestConnection), 0); @@ -573,22 +567,22 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventRequestConnection( {"HCI_LINK_eSCO 0x02 - eSCO"}, }; - DEBUG_LOG(WII_IPC_WIIMOTE, "Event: SendEventRequestConnection"); - DEBUG_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", + DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventRequestConnection"); + DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", pEventRequestConnection->bdaddr.b[0], pEventRequestConnection->bdaddr.b[1], pEventRequestConnection->bdaddr.b[2], pEventRequestConnection->bdaddr.b[3], pEventRequestConnection->bdaddr.b[4], pEventRequestConnection->bdaddr.b[5]); - DEBUG_LOG(WII_IPC_WIIMOTE, " COD[0]: 0x%02x", pEventRequestConnection->uclass[0]); - DEBUG_LOG(WII_IPC_WIIMOTE, " COD[1]: 0x%02x", pEventRequestConnection->uclass[1]); - DEBUG_LOG(WII_IPC_WIIMOTE, " COD[2]: 0x%02x", pEventRequestConnection->uclass[2]); - DEBUG_LOG(WII_IPC_WIIMOTE, " LinkType: %s", LinkType[pEventRequestConnection->LinkType]); + DEBUG_LOG(IOS_WIIMOTE, " COD[0]: 0x%02x", pEventRequestConnection->uclass[0]); + DEBUG_LOG(IOS_WIIMOTE, " COD[1]: 0x%02x", pEventRequestConnection->uclass[1]); + DEBUG_LOG(IOS_WIIMOTE, " COD[2]: 0x%02x", pEventRequestConnection->uclass[2]); + DEBUG_LOG(IOS_WIIMOTE, " LinkType: %s", LinkType[pEventRequestConnection->LinkType]); return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventDisconnect(u16 _connectionHandle, u8 _Reason) +bool BluetoothEmu::SendEventDisconnect(u16 _connectionHandle, u8 _Reason) { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_connectionHandle); + WiimoteDevice* pWiiMote = AccessWiiMote(_connectionHandle); if (pWiiMote == nullptr) return false; @@ -603,17 +597,16 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventDisconnect(u16 _connectio AddEventToQueue(Event); - DEBUG_LOG(WII_IPC_WIIMOTE, "Event: SendEventDisconnect"); - DEBUG_LOG(WII_IPC_WIIMOTE, " Connection_Handle: 0x%04x", pDisconnect->Connection_Handle); - DEBUG_LOG(WII_IPC_WIIMOTE, " Reason: 0x%02x", pDisconnect->Reason); + DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventDisconnect"); + DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", pDisconnect->Connection_Handle); + DEBUG_LOG(IOS_WIIMOTE, " Reason: 0x%02x", pDisconnect->Reason); return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventAuthenticationCompleted( - u16 _connectionHandle) +bool BluetoothEmu::SendEventAuthenticationCompleted(u16 _connectionHandle) { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_connectionHandle); + WiimoteDevice* pWiiMote = AccessWiiMote(_connectionHandle); if (pWiiMote == nullptr) return false; @@ -626,8 +619,8 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventAuthenticationCompleted( pEventAuthenticationCompleted->EventStatus = 0; pEventAuthenticationCompleted->Connection_Handle = _connectionHandle; - DEBUG_LOG(WII_IPC_WIIMOTE, "Event: SendEventAuthenticationCompleted"); - DEBUG_LOG(WII_IPC_WIIMOTE, " Connection_Handle: 0x%04x", + DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventAuthenticationCompleted"); + DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", pEventAuthenticationCompleted->Connection_Handle); AddEventToQueue(Event); @@ -635,9 +628,9 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventAuthenticationCompleted( return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventRemoteNameReq(const bdaddr_t& _bd) +bool BluetoothEmu::SendEventRemoteNameReq(const bdaddr_t& _bd) { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_bd); + WiimoteDevice* pWiiMote = AccessWiiMote(_bd); if (pWiiMote == nullptr) return false; @@ -651,20 +644,20 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventRemoteNameReq(const bdadd pRemoteNameReq->bdaddr = _bd; strcpy((char*)pRemoteNameReq->RemoteName, pWiiMote->GetName()); - DEBUG_LOG(WII_IPC_WIIMOTE, "Event: SendEventRemoteNameReq"); - DEBUG_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", pRemoteNameReq->bdaddr.b[0], + DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventRemoteNameReq"); + DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", pRemoteNameReq->bdaddr.b[0], pRemoteNameReq->bdaddr.b[1], pRemoteNameReq->bdaddr.b[2], pRemoteNameReq->bdaddr.b[3], pRemoteNameReq->bdaddr.b[4], pRemoteNameReq->bdaddr.b[5]); - DEBUG_LOG(WII_IPC_WIIMOTE, " RemoteName: %s", pRemoteNameReq->RemoteName); + DEBUG_LOG(IOS_WIIMOTE, " RemoteName: %s", pRemoteNameReq->RemoteName); AddEventToQueue(Event); return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventReadRemoteFeatures(u16 _connectionHandle) +bool BluetoothEmu::SendEventReadRemoteFeatures(u16 _connectionHandle) { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_connectionHandle); + WiimoteDevice* pWiiMote = AccessWiiMote(_connectionHandle); if (pWiiMote == nullptr) return false; @@ -685,9 +678,9 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventReadRemoteFeatures(u16 _c pReadRemoteFeatures->features[6] = pWiiMote->GetFeatures()[6]; pReadRemoteFeatures->features[7] = pWiiMote->GetFeatures()[7]; - DEBUG_LOG(WII_IPC_WIIMOTE, "Event: SendEventReadRemoteFeatures"); - DEBUG_LOG(WII_IPC_WIIMOTE, " Connection_Handle: 0x%04x", pReadRemoteFeatures->ConnectionHandle); - DEBUG_LOG(WII_IPC_WIIMOTE, " features: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", + DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventReadRemoteFeatures"); + DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", pReadRemoteFeatures->ConnectionHandle); + DEBUG_LOG(IOS_WIIMOTE, " features: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", pReadRemoteFeatures->features[0], pReadRemoteFeatures->features[1], pReadRemoteFeatures->features[2], pReadRemoteFeatures->features[3], pReadRemoteFeatures->features[4], pReadRemoteFeatures->features[5], @@ -698,9 +691,9 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventReadRemoteFeatures(u16 _c return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventReadRemoteVerInfo(u16 _connectionHandle) +bool BluetoothEmu::SendEventReadRemoteVerInfo(u16 _connectionHandle) { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_connectionHandle); + WiimoteDevice* pWiiMote = AccessWiiMote(_connectionHandle); if (pWiiMote == nullptr) return false; @@ -715,21 +708,20 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventReadRemoteVerInfo(u16 _co pReadRemoteVerInfo->manufacturer = pWiiMote->GetManufactorID(); pReadRemoteVerInfo->lmp_subversion = pWiiMote->GetLMPSubVersion(); - DEBUG_LOG(WII_IPC_WIIMOTE, "Event: SendEventReadRemoteVerInfo"); - DEBUG_LOG(WII_IPC_WIIMOTE, " Connection_Handle: 0x%04x", pReadRemoteVerInfo->ConnectionHandle); - DEBUG_LOG(WII_IPC_WIIMOTE, " lmp_version: 0x%02x", pReadRemoteVerInfo->lmp_version); - DEBUG_LOG(WII_IPC_WIIMOTE, " manufacturer: 0x%04x", pReadRemoteVerInfo->manufacturer); - DEBUG_LOG(WII_IPC_WIIMOTE, " lmp_subversion: 0x%04x", pReadRemoteVerInfo->lmp_subversion); + DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventReadRemoteVerInfo"); + DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", pReadRemoteVerInfo->ConnectionHandle); + DEBUG_LOG(IOS_WIIMOTE, " lmp_version: 0x%02x", pReadRemoteVerInfo->lmp_version); + DEBUG_LOG(IOS_WIIMOTE, " manufacturer: 0x%04x", pReadRemoteVerInfo->manufacturer); + DEBUG_LOG(IOS_WIIMOTE, " lmp_subversion: 0x%04x", pReadRemoteVerInfo->lmp_subversion); AddEventToQueue(Event); return true; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventCommandComplete(u16 opcode, const void* data, - u32 data_size) +void BluetoothEmu::SendEventCommandComplete(u16 opcode, const void* data, u32 data_size) { - _dbg_assert_(WII_IPC_WIIMOTE, (sizeof(SHCIEventCommand) - 2 + data_size) < 256); + _dbg_assert_(IOS_WIIMOTE, (sizeof(SHCIEventCommand) - 2 + data_size) < 256); SQueuedEvent event(sizeof(SHCIEventCommand) + data_size, 0); @@ -746,12 +738,12 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventCommandComplete(u16 opcod memcpy(payload, data, data_size); } - DEBUG_LOG(WII_IPC_WIIMOTE, "Event: Command Complete (Opcode: 0x%04x)", hci_event->Opcode); + DEBUG_LOG(IOS_WIIMOTE, "Event: Command Complete (Opcode: 0x%04x)", hci_event->Opcode); AddEventToQueue(event); } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventCommandStatus(u16 _Opcode) +bool BluetoothEmu::SendEventCommandStatus(u16 _Opcode) { SQueuedEvent Event(sizeof(SHCIEventStatus), 0); @@ -762,16 +754,16 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventCommandStatus(u16 _Opcode pHCIEvent->PacketIndicator = 0x01; pHCIEvent->Opcode = _Opcode; - INFO_LOG(WII_IPC_WIIMOTE, "Event: Command Status (Opcode: 0x%04x)", pHCIEvent->Opcode); + INFO_LOG(IOS_WIIMOTE, "Event: Command Status (Opcode: 0x%04x)", pHCIEvent->Opcode); AddEventToQueue(Event); return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventRoleChange(bdaddr_t _bd, bool _master) +bool BluetoothEmu::SendEventRoleChange(bdaddr_t _bd, bool _master) { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_bd); + WiimoteDevice* pWiiMote = AccessWiiMote(_bd); if (pWiiMote == nullptr) return false; @@ -787,22 +779,22 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventRoleChange(bdaddr_t _bd, AddEventToQueue(Event); - DEBUG_LOG(WII_IPC_WIIMOTE, "Event: SendEventRoleChange"); - DEBUG_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", pRoleChange->bdaddr.b[0], + DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventRoleChange"); + DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", pRoleChange->bdaddr.b[0], pRoleChange->bdaddr.b[1], pRoleChange->bdaddr.b[2], pRoleChange->bdaddr.b[3], pRoleChange->bdaddr.b[4], pRoleChange->bdaddr.b[5]); - DEBUG_LOG(WII_IPC_WIIMOTE, " NewRole: %i", pRoleChange->NewRole); + DEBUG_LOG(IOS_WIIMOTE, " NewRole: %i", pRoleChange->NewRole); return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventNumberOfCompletedPackets() +bool BluetoothEmu::SendEventNumberOfCompletedPackets() { SQueuedEvent Event((u32)(sizeof(hci_event_hdr_t) + sizeof(hci_num_compl_pkts_ep) + (sizeof(hci_num_compl_pkts_info) * m_WiiMotes.size())), 0); - DEBUG_LOG(WII_IPC_WIIMOTE, "Event: SendEventNumberOfCompletedPackets"); + DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventNumberOfCompletedPackets"); hci_event_hdr_t* event_hdr = (hci_event_hdr_t*)Event.m_buffer; hci_num_compl_pkts_ep* event = (hci_num_compl_pkts_ep*)((u8*)event_hdr + sizeof(hci_event_hdr_t)); @@ -822,8 +814,8 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventNumberOfCompletedPackets( info->compl_pkts = m_PacketCount[i]; info->con_handle = m_WiiMotes[i].GetConnectionHandle(); - DEBUG_LOG(WII_IPC_WIIMOTE, " Connection_Handle: 0x%04x", info->con_handle); - DEBUG_LOG(WII_IPC_WIIMOTE, " Number_Of_Completed_Packets: %i", info->compl_pkts); + DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", info->con_handle); + DEBUG_LOG(IOS_WIIMOTE, " Number_Of_Completed_Packets: %i", info->compl_pkts); acc += info->compl_pkts; m_PacketCount[i] = 0; @@ -836,16 +828,15 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventNumberOfCompletedPackets( } else { - DEBUG_LOG(WII_IPC_WIIMOTE, "SendEventNumberOfCompletedPackets: no packets; no event"); + DEBUG_LOG(IOS_WIIMOTE, "SendEventNumberOfCompletedPackets: no packets; no event"); } return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventModeChange(u16 _connectionHandle, u8 _mode, - u16 _value) +bool BluetoothEmu::SendEventModeChange(u16 _connectionHandle, u8 _mode, u16 _value) { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_connectionHandle); + WiimoteDevice* pWiiMote = AccessWiiMote(_connectionHandle); if (pWiiMote == nullptr) return false; @@ -859,22 +850,22 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventModeChange(u16 _connectio pModeChange->CurrentMode = _mode; pModeChange->Value = _value; - DEBUG_LOG(WII_IPC_WIIMOTE, "Event: SendEventModeChange"); - DEBUG_LOG(WII_IPC_WIIMOTE, " Connection_Handle: 0x%04x", pModeChange->Connection_Handle); - DEBUG_LOG(WII_IPC_WIIMOTE, " Current Mode: 0x%02x", pModeChange->CurrentMode = _mode); + DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventModeChange"); + DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", pModeChange->Connection_Handle); + DEBUG_LOG(IOS_WIIMOTE, " Current Mode: 0x%02x", pModeChange->CurrentMode = _mode); AddEventToQueue(Event); return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventLinkKeyNotification(const u8 num_to_send) +bool BluetoothEmu::SendEventLinkKeyNotification(const u8 num_to_send) { u8 payload_length = sizeof(hci_return_link_keys_ep) + sizeof(hci_link_key_rep_cp) * num_to_send; SQueuedEvent Event(2 + payload_length, 0); SHCIEventLinkKeyNotification* pEventLinkKey = (SHCIEventLinkKeyNotification*)Event.m_buffer; - DEBUG_LOG(WII_IPC_WIIMOTE, "Event: SendEventLinkKeyNotification"); + DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventLinkKeyNotification"); // event header pEventLinkKey->EventType = HCI_EVENT_RETURN_LINK_KEYS; @@ -891,7 +882,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventLinkKeyNotification(const link_key_info->bdaddr = m_WiiMotes[i].GetBD(); memcpy(link_key_info->key, m_WiiMotes[i].GetLinkKey(), HCI_KEY_SIZE); - DEBUG_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", link_key_info->bdaddr.b[0], + DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", link_key_info->bdaddr.b[0], link_key_info->bdaddr.b[1], link_key_info->bdaddr.b[2], link_key_info->bdaddr.b[3], link_key_info->bdaddr.b[4], link_key_info->bdaddr.b[5]); } @@ -901,7 +892,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventLinkKeyNotification(const return true; }; -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventRequestLinkKey(const bdaddr_t& _bd) +bool BluetoothEmu::SendEventRequestLinkKey(const bdaddr_t& _bd) { SQueuedEvent Event(sizeof(SHCIEventRequestLinkKey), 0); @@ -911,21 +902,20 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventRequestLinkKey(const bdad pEventRequestLinkKey->PayloadLength = sizeof(SHCIEventRequestLinkKey) - 2; pEventRequestLinkKey->bdaddr = _bd; - DEBUG_LOG(WII_IPC_WIIMOTE, "Event: SendEventRequestLinkKey"); - DEBUG_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", - pEventRequestLinkKey->bdaddr.b[0], pEventRequestLinkKey->bdaddr.b[1], - pEventRequestLinkKey->bdaddr.b[2], pEventRequestLinkKey->bdaddr.b[3], - pEventRequestLinkKey->bdaddr.b[4], pEventRequestLinkKey->bdaddr.b[5]); + DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventRequestLinkKey"); + DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", pEventRequestLinkKey->bdaddr.b[0], + pEventRequestLinkKey->bdaddr.b[1], pEventRequestLinkKey->bdaddr.b[2], + pEventRequestLinkKey->bdaddr.b[3], pEventRequestLinkKey->bdaddr.b[4], + pEventRequestLinkKey->bdaddr.b[5]); AddEventToQueue(Event); return true; }; -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventReadClockOffsetComplete( - u16 _connectionHandle) +bool BluetoothEmu::SendEventReadClockOffsetComplete(u16 _connectionHandle) { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_connectionHandle); + WiimoteDevice* pWiiMote = AccessWiiMote(_connectionHandle); if (pWiiMote == nullptr) return false; @@ -939,20 +929,18 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventReadClockOffsetComplete( pReadClockOffsetComplete->ConnectionHandle = _connectionHandle; pReadClockOffsetComplete->ClockOffset = 0x3818; - DEBUG_LOG(WII_IPC_WIIMOTE, "Event: SendEventReadClockOffsetComplete"); - DEBUG_LOG(WII_IPC_WIIMOTE, " Connection_Handle: 0x%04x", - pReadClockOffsetComplete->ConnectionHandle); - DEBUG_LOG(WII_IPC_WIIMOTE, " ClockOffset: 0x%04x", pReadClockOffsetComplete->ClockOffset); + DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventReadClockOffsetComplete"); + DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", pReadClockOffsetComplete->ConnectionHandle); + DEBUG_LOG(IOS_WIIMOTE, " ClockOffset: 0x%04x", pReadClockOffsetComplete->ClockOffset); AddEventToQueue(Event); return true; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventConPacketTypeChange(u16 _connectionHandle, - u16 _packetType) +bool BluetoothEmu::SendEventConPacketTypeChange(u16 _connectionHandle, u16 _packetType) { - CWII_IPC_HLE_WiiMote* pWiiMote = AccessWiiMote(_connectionHandle); + WiimoteDevice* pWiiMote = AccessWiiMote(_connectionHandle); if (pWiiMote == nullptr) return false; @@ -966,9 +954,9 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventConPacketTypeChange(u16 _ pChangeConPacketType->ConnectionHandle = _connectionHandle; pChangeConPacketType->PacketType = _packetType; - DEBUG_LOG(WII_IPC_WIIMOTE, "Event: SendEventConPacketTypeChange"); - DEBUG_LOG(WII_IPC_WIIMOTE, " Connection_Handle: 0x%04x", pChangeConPacketType->ConnectionHandle); - DEBUG_LOG(WII_IPC_WIIMOTE, " PacketType: 0x%04x", pChangeConPacketType->PacketType); + DEBUG_LOG(IOS_WIIMOTE, "Event: SendEventConPacketTypeChange"); + DEBUG_LOG(IOS_WIIMOTE, " Connection_Handle: 0x%04x", pChangeConPacketType->ConnectionHandle); + DEBUG_LOG(IOS_WIIMOTE, " PacketType: 0x%04x", pChangeConPacketType->PacketType); AddEventToQueue(Event); @@ -977,8 +965,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::SendEventConPacketTypeChange(u16 _ // Command dispatcher // This is called from the USBV0_IOCTL_CTRLMSG Ioctlv -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::ExecuteHCICommandMessage( - const CtrlMessage& ctrl_message) +void BluetoothEmu::ExecuteHCICommandMessage(const CtrlMessage& ctrl_message) { u8* pInput = Memory::GetPointer(ctrl_message.payload_addr + 3); SCommandMessage* pMsg = (SCommandMessage*)Memory::GetPointer(ctrl_message.payload_addr); @@ -986,8 +973,8 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::ExecuteHCICommandMessage( u16 ocf = HCI_OCF(pMsg->Opcode); u16 ogf = HCI_OGF(pMsg->Opcode); - DEBUG_LOG(WII_IPC_WIIMOTE, "**************************************************"); - DEBUG_LOG(WII_IPC_WIIMOTE, "Execute HCI Command: 0x%04x (ocf: 0x%02x, ogf: 0x%02x)", pMsg->Opcode, + DEBUG_LOG(IOS_WIIMOTE, "**************************************************"); + DEBUG_LOG(IOS_WIIMOTE, "Execute HCI Command: 0x%04x (ocf: 0x%02x, ogf: 0x%02x)", pMsg->Opcode, ocf, ogf); switch (pMsg->Opcode) @@ -1142,17 +1129,16 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::ExecuteHCICommandMessage( if (ogf == HCI_OGF_VENDOR) { - ERROR_LOG(WII_IPC_WIIMOTE, "Command: vendor specific: 0x%04X (ocf: 0x%x)", pMsg->Opcode, ocf); + ERROR_LOG(IOS_WIIMOTE, "Command: vendor specific: 0x%04X (ocf: 0x%x)", pMsg->Opcode, ocf); for (int i = 0; i < pMsg->len; i++) { - ERROR_LOG(WII_IPC_WIIMOTE, " 0x02%x", pInput[i]); + ERROR_LOG(IOS_WIIMOTE, " 0x02%x", pInput[i]); } } else { - _dbg_assert_msg_(WII_IPC_WIIMOTE, 0, - "Unknown USB_IOCTL_CTRLMSG: 0x%04X (ocf: 0x%x ogf 0x%x)", pMsg->Opcode, ocf, - ogf); + _dbg_assert_msg_(IOS_WIIMOTE, 0, "Unknown USB_IOCTL_CTRLMSG: 0x%04X (ocf: 0x%x ogf 0x%x)", + pMsg->Opcode, ocf, ogf); } break; } @@ -1166,62 +1152,62 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::ExecuteHCICommandMessage( // --- command helper // // -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandInquiry(const u8* input) +void BluetoothEmu::CommandInquiry(const u8* input) { // Inquiry should not be called normally const hci_inquiry_cp* inquiry = reinterpret_cast(input); - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_INQUIRY:"); - DEBUG_LOG(WII_IPC_WIIMOTE, "write:"); - DEBUG_LOG(WII_IPC_WIIMOTE, " LAP[0]: 0x%02x", inquiry->lap[0]); - DEBUG_LOG(WII_IPC_WIIMOTE, " LAP[1]: 0x%02x", inquiry->lap[1]); - DEBUG_LOG(WII_IPC_WIIMOTE, " LAP[2]: 0x%02x", inquiry->lap[2]); - DEBUG_LOG(WII_IPC_WIIMOTE, " inquiry_length: %i (N x 1.28) sec", inquiry->inquiry_length); - DEBUG_LOG(WII_IPC_WIIMOTE, " num_responses: %i (N x 1.28) sec", inquiry->num_responses); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_INQUIRY:"); + DEBUG_LOG(IOS_WIIMOTE, "write:"); + DEBUG_LOG(IOS_WIIMOTE, " LAP[0]: 0x%02x", inquiry->lap[0]); + DEBUG_LOG(IOS_WIIMOTE, " LAP[1]: 0x%02x", inquiry->lap[1]); + DEBUG_LOG(IOS_WIIMOTE, " LAP[2]: 0x%02x", inquiry->lap[2]); + DEBUG_LOG(IOS_WIIMOTE, " inquiry_length: %i (N x 1.28) sec", inquiry->inquiry_length); + DEBUG_LOG(IOS_WIIMOTE, " num_responses: %i (N x 1.28) sec", inquiry->num_responses); SendEventCommandStatus(HCI_CMD_INQUIRY); SendEventInquiryResponse(); SendEventInquiryComplete(); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandInquiryCancel(const u8* input) +void BluetoothEmu::CommandInquiryCancel(const u8* input) { hci_inquiry_cancel_rp reply; reply.status = 0x00; - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_INQUIRY_CANCEL"); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_INQUIRY_CANCEL"); SendEventCommandComplete(HCI_CMD_INQUIRY_CANCEL, &reply, sizeof(hci_inquiry_cancel_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandCreateCon(const u8* input) +void BluetoothEmu::CommandCreateCon(const u8* input) { const hci_create_con_cp* create_connection = reinterpret_cast(input); - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_CREATE_CON"); - DEBUG_LOG(WII_IPC_WIIMOTE, "Input:"); - DEBUG_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", create_connection->bdaddr.b[0], + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_CREATE_CON"); + DEBUG_LOG(IOS_WIIMOTE, "Input:"); + DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", create_connection->bdaddr.b[0], create_connection->bdaddr.b[1], create_connection->bdaddr.b[2], create_connection->bdaddr.b[3], create_connection->bdaddr.b[4], create_connection->bdaddr.b[5]); - DEBUG_LOG(WII_IPC_WIIMOTE, " pkt_type: %i", create_connection->pkt_type); - DEBUG_LOG(WII_IPC_WIIMOTE, " page_scan_rep_mode: %i", create_connection->page_scan_rep_mode); - DEBUG_LOG(WII_IPC_WIIMOTE, " page_scan_mode: %i", create_connection->page_scan_mode); - DEBUG_LOG(WII_IPC_WIIMOTE, " clock_offset: %i", create_connection->clock_offset); - DEBUG_LOG(WII_IPC_WIIMOTE, " accept_role_switch: %i", create_connection->accept_role_switch); + DEBUG_LOG(IOS_WIIMOTE, " pkt_type: %i", create_connection->pkt_type); + DEBUG_LOG(IOS_WIIMOTE, " page_scan_rep_mode: %i", create_connection->page_scan_rep_mode); + DEBUG_LOG(IOS_WIIMOTE, " page_scan_mode: %i", create_connection->page_scan_mode); + DEBUG_LOG(IOS_WIIMOTE, " clock_offset: %i", create_connection->clock_offset); + DEBUG_LOG(IOS_WIIMOTE, " accept_role_switch: %i", create_connection->accept_role_switch); SendEventCommandStatus(HCI_CMD_CREATE_CON); SendEventConnectionComplete(create_connection->bdaddr); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandDisconnect(const u8* input) +void BluetoothEmu::CommandDisconnect(const u8* input) { const hci_discon_cp* disconnect = reinterpret_cast(input); - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_DISCONNECT"); - DEBUG_LOG(WII_IPC_WIIMOTE, " ConnectionHandle: 0x%04x", disconnect->con_handle); - DEBUG_LOG(WII_IPC_WIIMOTE, " Reason: 0x%02x", disconnect->reason); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_DISCONNECT"); + DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%04x", disconnect->con_handle); + DEBUG_LOG(IOS_WIIMOTE, " Reason: 0x%02x", disconnect->reason); Host_SetWiiMoteConnectionState(0); DisplayDisconnectMessage((disconnect->con_handle & 0xFF) + 1, disconnect->reason); @@ -1229,12 +1215,12 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandDisconnect(const u8* input) SendEventCommandStatus(HCI_CMD_DISCONNECT); SendEventDisconnect(disconnect->con_handle, disconnect->reason); - CWII_IPC_HLE_WiiMote* wiimote = AccessWiiMote(disconnect->con_handle); + WiimoteDevice* wiimote = AccessWiiMote(disconnect->con_handle); if (wiimote) wiimote->EventDisconnect(); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandAcceptCon(const u8* input) +void BluetoothEmu::CommandAcceptCon(const u8* input) { const hci_accept_con_cp* accept_connection = reinterpret_cast(input); @@ -1242,12 +1228,12 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandAcceptCon(const u8* input) {"Master (0x00)"}, {"Slave (0x01)"}, }; - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_ACCEPT_CON"); - DEBUG_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", accept_connection->bdaddr.b[0], + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_ACCEPT_CON"); + DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", accept_connection->bdaddr.b[0], accept_connection->bdaddr.b[1], accept_connection->bdaddr.b[2], accept_connection->bdaddr.b[3], accept_connection->bdaddr.b[4], accept_connection->bdaddr.b[5]); - DEBUG_LOG(WII_IPC_WIIMOTE, " role: %s", roles[accept_connection->role]); + DEBUG_LOG(IOS_WIIMOTE, " role: %s", roles[accept_connection->role]); SendEventCommandStatus(HCI_CMD_ACCEPT_CON); @@ -1260,12 +1246,12 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandAcceptCon(const u8* input) SendEventConnectionComplete(accept_connection->bdaddr); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandLinkKeyRep(const u8* input) +void BluetoothEmu::CommandLinkKeyRep(const u8* input) { const hci_link_key_rep_cp* key_rep = reinterpret_cast(input); - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_LINK_KEY_REP"); - DEBUG_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", key_rep->bdaddr.b[0], + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_LINK_KEY_REP"); + DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", key_rep->bdaddr.b[0], key_rep->bdaddr.b[1], key_rep->bdaddr.b[2], key_rep->bdaddr.b[3], key_rep->bdaddr.b[4], key_rep->bdaddr.b[5]); @@ -1276,12 +1262,12 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandLinkKeyRep(const u8* input) SendEventCommandComplete(HCI_CMD_LINK_KEY_REP, &reply, sizeof(hci_link_key_rep_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandLinkKeyNegRep(const u8* input) +void BluetoothEmu::CommandLinkKeyNegRep(const u8* input) { const hci_link_key_neg_rep_cp* key_neg = reinterpret_cast(input); - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_LINK_KEY_NEG_REP"); - DEBUG_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", key_neg->bdaddr.b[0], + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_LINK_KEY_NEG_REP"); + DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", key_neg->bdaddr.b[0], key_neg->bdaddr.b[1], key_neg->bdaddr.b[2], key_neg->bdaddr.b[3], key_neg->bdaddr.b[4], key_neg->bdaddr.b[5]); @@ -1292,7 +1278,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandLinkKeyNegRep(const u8* inp SendEventCommandComplete(HCI_CMD_LINK_KEY_NEG_REP, &reply, sizeof(hci_link_key_neg_rep_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandChangeConPacketType(const u8* input) +void BluetoothEmu::CommandChangeConPacketType(const u8* input) { const hci_change_con_pkt_type_cp* change_packet_type = reinterpret_cast(input); @@ -1300,117 +1286,117 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandChangeConPacketType(const u // ntd stack sets packet type 0xcc18, which is HCI_PKT_DH5 | HCI_PKT_DM5 | HCI_PKT_DH1 | // HCI_PKT_DM1 // dunno what to do...run awayyyyyy! - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_CHANGE_CON_PACKET_TYPE"); - DEBUG_LOG(WII_IPC_WIIMOTE, " ConnectionHandle: 0x%04x", change_packet_type->con_handle); - DEBUG_LOG(WII_IPC_WIIMOTE, " PacketType: 0x%04x", change_packet_type->pkt_type); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_CHANGE_CON_PACKET_TYPE"); + DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%04x", change_packet_type->con_handle); + DEBUG_LOG(IOS_WIIMOTE, " PacketType: 0x%04x", change_packet_type->pkt_type); SendEventCommandStatus(HCI_CMD_CHANGE_CON_PACKET_TYPE); SendEventConPacketTypeChange(change_packet_type->con_handle, change_packet_type->pkt_type); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandAuthenticationRequested(const u8* input) +void BluetoothEmu::CommandAuthenticationRequested(const u8* input) { const hci_auth_req_cp* auth_req = reinterpret_cast(input); - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_AUTH_REQ"); - DEBUG_LOG(WII_IPC_WIIMOTE, " ConnectionHandle: 0x%04x", auth_req->con_handle); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_AUTH_REQ"); + DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%04x", auth_req->con_handle); SendEventCommandStatus(HCI_CMD_AUTH_REQ); SendEventAuthenticationCompleted(auth_req->con_handle); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandRemoteNameReq(const u8* input) +void BluetoothEmu::CommandRemoteNameReq(const u8* input) { const hci_remote_name_req_cp* remote_name_req = reinterpret_cast(input); - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_REMOTE_NAME_REQ"); - DEBUG_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", remote_name_req->bdaddr.b[0], + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_REMOTE_NAME_REQ"); + DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", remote_name_req->bdaddr.b[0], remote_name_req->bdaddr.b[1], remote_name_req->bdaddr.b[2], remote_name_req->bdaddr.b[3], remote_name_req->bdaddr.b[4], remote_name_req->bdaddr.b[5]); - DEBUG_LOG(WII_IPC_WIIMOTE, " page_scan_rep_mode: %i", remote_name_req->page_scan_rep_mode); - DEBUG_LOG(WII_IPC_WIIMOTE, " page_scan_mode: %i", remote_name_req->page_scan_mode); - DEBUG_LOG(WII_IPC_WIIMOTE, " clock_offset: %i", remote_name_req->clock_offset); + DEBUG_LOG(IOS_WIIMOTE, " page_scan_rep_mode: %i", remote_name_req->page_scan_rep_mode); + DEBUG_LOG(IOS_WIIMOTE, " page_scan_mode: %i", remote_name_req->page_scan_mode); + DEBUG_LOG(IOS_WIIMOTE, " clock_offset: %i", remote_name_req->clock_offset); SendEventCommandStatus(HCI_CMD_REMOTE_NAME_REQ); SendEventRemoteNameReq(remote_name_req->bdaddr); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadRemoteFeatures(const u8* input) +void BluetoothEmu::CommandReadRemoteFeatures(const u8* input) { const hci_read_remote_features_cp* read_remote_features = reinterpret_cast(input); - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_READ_REMOTE_FEATURES"); - DEBUG_LOG(WII_IPC_WIIMOTE, " ConnectionHandle: 0x%04x", read_remote_features->con_handle); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_REMOTE_FEATURES"); + DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%04x", read_remote_features->con_handle); SendEventCommandStatus(HCI_CMD_READ_REMOTE_FEATURES); SendEventReadRemoteFeatures(read_remote_features->con_handle); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadRemoteVerInfo(const u8* input) +void BluetoothEmu::CommandReadRemoteVerInfo(const u8* input) { const hci_read_remote_ver_info_cp* read_remote_ver_info = reinterpret_cast(input); - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_READ_REMOTE_VER_INFO"); - DEBUG_LOG(WII_IPC_WIIMOTE, " ConnectionHandle: 0x%02x", read_remote_ver_info->con_handle); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_REMOTE_VER_INFO"); + DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%02x", read_remote_ver_info->con_handle); SendEventCommandStatus(HCI_CMD_READ_REMOTE_VER_INFO); SendEventReadRemoteVerInfo(read_remote_ver_info->con_handle); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadClockOffset(const u8* input) +void BluetoothEmu::CommandReadClockOffset(const u8* input) { const hci_read_clock_offset_cp* read_clock_offset = reinterpret_cast(input); - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_READ_CLOCK_OFFSET"); - DEBUG_LOG(WII_IPC_WIIMOTE, " ConnectionHandle: 0x%02x", read_clock_offset->con_handle); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_CLOCK_OFFSET"); + DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%02x", read_clock_offset->con_handle); SendEventCommandStatus(HCI_CMD_READ_CLOCK_OFFSET); SendEventReadClockOffsetComplete(read_clock_offset->con_handle); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandSniffMode(const u8* input) +void BluetoothEmu::CommandSniffMode(const u8* input) { const hci_sniff_mode_cp* sniff_mode = reinterpret_cast(input); - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_SNIFF_MODE"); - DEBUG_LOG(WII_IPC_WIIMOTE, " ConnectionHandle: 0x%04x", sniff_mode->con_handle); - DEBUG_LOG(WII_IPC_WIIMOTE, " max_interval: %f msec", sniff_mode->max_interval * .625); - DEBUG_LOG(WII_IPC_WIIMOTE, " min_interval: %f msec", sniff_mode->min_interval * .625); - DEBUG_LOG(WII_IPC_WIIMOTE, " attempt: %f msec", sniff_mode->attempt * 1.25); - DEBUG_LOG(WII_IPC_WIIMOTE, " timeout: %f msec", sniff_mode->timeout * 1.25); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_SNIFF_MODE"); + DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%04x", sniff_mode->con_handle); + DEBUG_LOG(IOS_WIIMOTE, " max_interval: %f msec", sniff_mode->max_interval * .625); + DEBUG_LOG(IOS_WIIMOTE, " min_interval: %f msec", sniff_mode->min_interval * .625); + DEBUG_LOG(IOS_WIIMOTE, " attempt: %f msec", sniff_mode->attempt * 1.25); + DEBUG_LOG(IOS_WIIMOTE, " timeout: %f msec", sniff_mode->timeout * 1.25); SendEventCommandStatus(HCI_CMD_SNIFF_MODE); SendEventModeChange(sniff_mode->con_handle, 0x02, sniff_mode->max_interval); // 0x02 - sniff mode } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteLinkPolicy(const u8* input) +void BluetoothEmu::CommandWriteLinkPolicy(const u8* input) { const hci_write_link_policy_settings_cp* link_policy = reinterpret_cast(input); - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_WRITE_LINK_POLICY_SETTINGS"); - DEBUG_LOG(WII_IPC_WIIMOTE, " ConnectionHandle: 0x%04x", link_policy->con_handle); - DEBUG_LOG(WII_IPC_WIIMOTE, " Policy: 0x%04x", link_policy->settings); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_LINK_POLICY_SETTINGS"); + DEBUG_LOG(IOS_WIIMOTE, " ConnectionHandle: 0x%04x", link_policy->con_handle); + DEBUG_LOG(IOS_WIIMOTE, " Policy: 0x%04x", link_policy->settings); SendEventCommandStatus(HCI_CMD_WRITE_LINK_POLICY_SETTINGS); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReset(const u8* input) +void BluetoothEmu::CommandReset(const u8* input) { hci_status_rp reply; reply.status = 0x00; - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_RESET"); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_RESET"); SendEventCommandComplete(HCI_CMD_RESET, &reply, sizeof(hci_status_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandSetEventFilter(const u8* input) +void BluetoothEmu::CommandSetEventFilter(const u8* input) { const hci_set_event_filter_cp* set_event_filter = reinterpret_cast(input); @@ -1418,15 +1404,14 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandSetEventFilter(const u8* in hci_set_event_filter_rp reply; reply.status = 0x00; - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_SET_EVENT_FILTER:"); - DEBUG_LOG(WII_IPC_WIIMOTE, " filter_type: %i", set_event_filter->filter_type); - DEBUG_LOG(WII_IPC_WIIMOTE, " filter_condition_type: %i", - set_event_filter->filter_condition_type); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_SET_EVENT_FILTER:"); + DEBUG_LOG(IOS_WIIMOTE, " filter_type: %i", set_event_filter->filter_type); + DEBUG_LOG(IOS_WIIMOTE, " filter_condition_type: %i", set_event_filter->filter_condition_type); SendEventCommandComplete(HCI_CMD_SET_EVENT_FILTER, &reply, sizeof(hci_set_event_filter_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWritePinType(const u8* input) +void BluetoothEmu::CommandWritePinType(const u8* input) { const hci_write_pin_type_cp* write_pin_type = reinterpret_cast(input); @@ -1434,13 +1419,13 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWritePinType(const u8* inpu hci_write_pin_type_rp reply; reply.status = 0x00; - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_WRITE_PIN_TYPE:"); - DEBUG_LOG(WII_IPC_WIIMOTE, " pin_type: %x", write_pin_type->pin_type); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_PIN_TYPE:"); + DEBUG_LOG(IOS_WIIMOTE, " pin_type: %x", write_pin_type->pin_type); SendEventCommandComplete(HCI_CMD_WRITE_PIN_TYPE, &reply, sizeof(hci_write_pin_type_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadStoredLinkKey(const u8* input) +void BluetoothEmu::CommandReadStoredLinkKey(const u8* input) { const hci_read_stored_link_key_cp* read_stored_link_key = reinterpret_cast(input); @@ -1456,38 +1441,38 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadStoredLinkKey(const u8* } else { - ERROR_LOG(WII_IPC_WIIMOTE, "CommandReadStoredLinkKey isn't looking for all devices"); + ERROR_LOG(IOS_WIIMOTE, "CommandReadStoredLinkKey isn't looking for all devices"); } - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_READ_STORED_LINK_KEY:"); - DEBUG_LOG(WII_IPC_WIIMOTE, "input:"); - DEBUG_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", - read_stored_link_key->bdaddr.b[0], read_stored_link_key->bdaddr.b[1], - read_stored_link_key->bdaddr.b[2], read_stored_link_key->bdaddr.b[3], - read_stored_link_key->bdaddr.b[4], read_stored_link_key->bdaddr.b[5]); - DEBUG_LOG(WII_IPC_WIIMOTE, " read_all: %i", read_stored_link_key->read_all); - DEBUG_LOG(WII_IPC_WIIMOTE, "return:"); - DEBUG_LOG(WII_IPC_WIIMOTE, " max_num_keys: %i", reply.max_num_keys); - DEBUG_LOG(WII_IPC_WIIMOTE, " num_keys_read: %i", reply.num_keys_read); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_STORED_LINK_KEY:"); + DEBUG_LOG(IOS_WIIMOTE, "input:"); + DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", read_stored_link_key->bdaddr.b[0], + read_stored_link_key->bdaddr.b[1], read_stored_link_key->bdaddr.b[2], + read_stored_link_key->bdaddr.b[3], read_stored_link_key->bdaddr.b[4], + read_stored_link_key->bdaddr.b[5]); + DEBUG_LOG(IOS_WIIMOTE, " read_all: %i", read_stored_link_key->read_all); + DEBUG_LOG(IOS_WIIMOTE, "return:"); + DEBUG_LOG(IOS_WIIMOTE, " max_num_keys: %i", reply.max_num_keys); + DEBUG_LOG(IOS_WIIMOTE, " num_keys_read: %i", reply.num_keys_read); SendEventLinkKeyNotification((u8)reply.num_keys_read); SendEventCommandComplete(HCI_CMD_READ_STORED_LINK_KEY, &reply, sizeof(hci_read_stored_link_key_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandDeleteStoredLinkKey(const u8* input) +void BluetoothEmu::CommandDeleteStoredLinkKey(const u8* input) { const hci_delete_stored_link_key_cp* delete_stored_link_key = reinterpret_cast(input); - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_OCF_DELETE_STORED_LINK_KEY"); - DEBUG_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", - delete_stored_link_key->bdaddr.b[0], delete_stored_link_key->bdaddr.b[1], - delete_stored_link_key->bdaddr.b[2], delete_stored_link_key->bdaddr.b[3], - delete_stored_link_key->bdaddr.b[4], delete_stored_link_key->bdaddr.b[5]); - DEBUG_LOG(WII_IPC_WIIMOTE, " delete_all: 0x%01x", delete_stored_link_key->delete_all); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_OCF_DELETE_STORED_LINK_KEY"); + DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", delete_stored_link_key->bdaddr.b[0], + delete_stored_link_key->bdaddr.b[1], delete_stored_link_key->bdaddr.b[2], + delete_stored_link_key->bdaddr.b[3], delete_stored_link_key->bdaddr.b[4], + delete_stored_link_key->bdaddr.b[5]); + DEBUG_LOG(IOS_WIIMOTE, " delete_all: 0x%01x", delete_stored_link_key->delete_all); - CWII_IPC_HLE_WiiMote* wiiMote = AccessWiiMote(delete_stored_link_key->bdaddr); + WiimoteDevice* wiiMote = AccessWiiMote(delete_stored_link_key->bdaddr); if (wiiMote == nullptr) return; @@ -1498,11 +1483,11 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandDeleteStoredLinkKey(const u SendEventCommandComplete(HCI_CMD_DELETE_STORED_LINK_KEY, &reply, sizeof(hci_delete_stored_link_key_rp)); - ERROR_LOG(WII_IPC_WIIMOTE, "HCI: CommandDeleteStoredLinkKey... Probably the security for linking " - "has failed. Could be a problem with loading the SCONF"); + ERROR_LOG(IOS_WIIMOTE, "HCI: CommandDeleteStoredLinkKey... Probably the security for linking " + "has failed. Could be a problem with loading the SCONF"); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteLocalName(const u8* input) +void BluetoothEmu::CommandWriteLocalName(const u8* input) { const hci_write_local_name_cp* write_local_name = reinterpret_cast(input); @@ -1510,15 +1495,15 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteLocalName(const u8* in hci_write_local_name_rp reply; reply.status = 0x00; - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_WRITE_LOCAL_NAME:"); - DEBUG_LOG(WII_IPC_WIIMOTE, " local_name: %s", write_local_name->name); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_LOCAL_NAME:"); + DEBUG_LOG(IOS_WIIMOTE, " local_name: %s", write_local_name->name); SendEventCommandComplete(HCI_CMD_WRITE_LOCAL_NAME, &reply, sizeof(hci_write_local_name_rp)); } // Here we normally receive the timeout interval. // But not from homebrew games that use lwbt. Why not? -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWritePageTimeOut(const u8* input) +void BluetoothEmu::CommandWritePageTimeOut(const u8* input) { const hci_write_page_timeout_cp* write_page_timeout = reinterpret_cast(input); @@ -1526,14 +1511,14 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWritePageTimeOut(const u8* hci_host_buffer_size_rp reply; reply.status = 0x00; - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_WRITE_PAGE_TIMEOUT:"); - DEBUG_LOG(WII_IPC_WIIMOTE, " timeout: %i", write_page_timeout->timeout); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_PAGE_TIMEOUT:"); + DEBUG_LOG(IOS_WIIMOTE, " timeout: %i", write_page_timeout->timeout); SendEventCommandComplete(HCI_CMD_WRITE_PAGE_TIMEOUT, &reply, sizeof(hci_host_buffer_size_rp)); } /* This will enable ScanEnable so that Update() can start the Wii Remote. */ -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteScanEnable(const u8* input) +void BluetoothEmu::CommandWriteScanEnable(const u8* input) { const hci_write_scan_enable_cp* write_scan_enable = reinterpret_cast(input); @@ -1549,14 +1534,14 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteScanEnable(const u8* i {"HCI_INQUIRY_AND_PAGE_SCAN_ENABLE"}, }; - DEBUG_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_WRITE_SCAN_ENABLE: (0x%02x)", + DEBUG_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_SCAN_ENABLE: (0x%02x)", write_scan_enable->scan_enable); - DEBUG_LOG(WII_IPC_WIIMOTE, " scan_enable: %s", scanning[write_scan_enable->scan_enable]); + DEBUG_LOG(IOS_WIIMOTE, " scan_enable: %s", scanning[write_scan_enable->scan_enable]); SendEventCommandComplete(HCI_CMD_WRITE_SCAN_ENABLE, &reply, sizeof(hci_write_scan_enable_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteUnitClass(const u8* input) +void BluetoothEmu::CommandWriteUnitClass(const u8* input) { const hci_write_unit_class_cp* write_unit_class = reinterpret_cast(input); @@ -1564,15 +1549,15 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteUnitClass(const u8* in hci_write_unit_class_rp reply; reply.status = 0x00; - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_WRITE_UNIT_CLASS:"); - DEBUG_LOG(WII_IPC_WIIMOTE, " COD[0]: 0x%02x", write_unit_class->uclass[0]); - DEBUG_LOG(WII_IPC_WIIMOTE, " COD[1]: 0x%02x", write_unit_class->uclass[1]); - DEBUG_LOG(WII_IPC_WIIMOTE, " COD[2]: 0x%02x", write_unit_class->uclass[2]); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_UNIT_CLASS:"); + DEBUG_LOG(IOS_WIIMOTE, " COD[0]: 0x%02x", write_unit_class->uclass[0]); + DEBUG_LOG(IOS_WIIMOTE, " COD[1]: 0x%02x", write_unit_class->uclass[1]); + DEBUG_LOG(IOS_WIIMOTE, " COD[2]: 0x%02x", write_unit_class->uclass[2]); SendEventCommandComplete(HCI_CMD_WRITE_UNIT_CLASS, &reply, sizeof(hci_write_unit_class_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandHostBufferSize(const u8* input) +void BluetoothEmu::CommandHostBufferSize(const u8* input) { const hci_host_buffer_size_cp* host_buffer_size = reinterpret_cast(input); @@ -1580,24 +1565,24 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandHostBufferSize(const u8* in hci_host_buffer_size_rp reply; reply.status = 0x00; - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_HOST_BUFFER_SIZE:"); - DEBUG_LOG(WII_IPC_WIIMOTE, " max_acl_size: %i", host_buffer_size->max_acl_size); - DEBUG_LOG(WII_IPC_WIIMOTE, " max_sco_size: %i", host_buffer_size->max_sco_size); - DEBUG_LOG(WII_IPC_WIIMOTE, " num_acl_pkts: %i", host_buffer_size->num_acl_pkts); - DEBUG_LOG(WII_IPC_WIIMOTE, " num_sco_pkts: %i", host_buffer_size->num_sco_pkts); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_HOST_BUFFER_SIZE:"); + DEBUG_LOG(IOS_WIIMOTE, " max_acl_size: %i", host_buffer_size->max_acl_size); + DEBUG_LOG(IOS_WIIMOTE, " max_sco_size: %i", host_buffer_size->max_sco_size); + DEBUG_LOG(IOS_WIIMOTE, " num_acl_pkts: %i", host_buffer_size->num_acl_pkts); + DEBUG_LOG(IOS_WIIMOTE, " num_sco_pkts: %i", host_buffer_size->num_sco_pkts); SendEventCommandComplete(HCI_CMD_HOST_BUFFER_SIZE, &reply, sizeof(hci_host_buffer_size_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteLinkSupervisionTimeout(const u8* input) +void BluetoothEmu::CommandWriteLinkSupervisionTimeout(const u8* input) { const hci_write_link_supervision_timeout_cp* supervision = reinterpret_cast(input); // timeout of 0 means timing out is disabled - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_WRITE_LINK_SUPERVISION_TIMEOUT"); - DEBUG_LOG(WII_IPC_WIIMOTE, " con_handle: 0x%04x", supervision->con_handle); - DEBUG_LOG(WII_IPC_WIIMOTE, " timeout: 0x%02x", supervision->timeout); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_LINK_SUPERVISION_TIMEOUT"); + DEBUG_LOG(IOS_WIIMOTE, " con_handle: 0x%04x", supervision->con_handle); + DEBUG_LOG(IOS_WIIMOTE, " timeout: 0x%02x", supervision->timeout); hci_write_link_supervision_timeout_rp reply; reply.status = 0x00; @@ -1607,7 +1592,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteLinkSupervisionTimeout sizeof(hci_write_link_supervision_timeout_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteInquiryScanType(const u8* input) +void BluetoothEmu::CommandWriteInquiryScanType(const u8* input) { const hci_write_inquiry_scan_type_cp* set_event_filter = reinterpret_cast(input); @@ -1615,14 +1600,14 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteInquiryScanType(const hci_write_inquiry_scan_type_rp reply; reply.status = 0x00; - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_WRITE_INQUIRY_SCAN_TYPE:"); - DEBUG_LOG(WII_IPC_WIIMOTE, " type: %i", set_event_filter->type); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_INQUIRY_SCAN_TYPE:"); + DEBUG_LOG(IOS_WIIMOTE, " type: %i", set_event_filter->type); SendEventCommandComplete(HCI_CMD_WRITE_INQUIRY_SCAN_TYPE, &reply, sizeof(hci_write_inquiry_scan_type_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteInquiryMode(const u8* input) +void BluetoothEmu::CommandWriteInquiryMode(const u8* input) { const hci_write_inquiry_mode_cp* inquiry_mode = reinterpret_cast(input); @@ -1634,13 +1619,13 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWriteInquiryMode(const u8* {"Standard Inquiry Result event format (default)"}, {"Inquiry Result format with RSSI"}, {"Inquiry Result with RSSI format or Extended Inquiry Result format"}}; - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_WRITE_INQUIRY_MODE:"); - DEBUG_LOG(WII_IPC_WIIMOTE, " mode: %s", inquiry_mode_tag[inquiry_mode->mode]); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_INQUIRY_MODE:"); + DEBUG_LOG(IOS_WIIMOTE, " mode: %s", inquiry_mode_tag[inquiry_mode->mode]); SendEventCommandComplete(HCI_CMD_WRITE_INQUIRY_MODE, &reply, sizeof(hci_write_inquiry_mode_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWritePageScanType(const u8* input) +void BluetoothEmu::CommandWritePageScanType(const u8* input) { const hci_write_page_scan_type_cp* write_page_scan_type = reinterpret_cast(input); @@ -1651,14 +1636,14 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandWritePageScanType(const u8* static char page_scan_type[][128] = {{"Mandatory: Standard Scan (default)"}, {"Optional: Interlaced Scan"}}; - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_WRITE_PAGE_SCAN_TYPE:"); - DEBUG_LOG(WII_IPC_WIIMOTE, " type: %s", page_scan_type[write_page_scan_type->type]); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_WRITE_PAGE_SCAN_TYPE:"); + DEBUG_LOG(IOS_WIIMOTE, " type: %s", page_scan_type[write_page_scan_type->type]); SendEventCommandComplete(HCI_CMD_WRITE_PAGE_SCAN_TYPE, &reply, sizeof(hci_write_page_scan_type_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadLocalVer(const u8* input) +void BluetoothEmu::CommandReadLocalVer(const u8* input) { hci_read_local_ver_rp reply; reply.status = 0x00; @@ -1668,18 +1653,18 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadLocalVer(const u8* inpu reply.manufacturer = 0x000F; // manufacturer: reserved for tests reply.lmp_subversion = 0x430e; // LMP subversion - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_READ_LOCAL_VER:"); - DEBUG_LOG(WII_IPC_WIIMOTE, "return:"); - DEBUG_LOG(WII_IPC_WIIMOTE, " status: %i", reply.status); - DEBUG_LOG(WII_IPC_WIIMOTE, " hci_revision: %i", reply.hci_revision); - DEBUG_LOG(WII_IPC_WIIMOTE, " lmp_version: %i", reply.lmp_version); - DEBUG_LOG(WII_IPC_WIIMOTE, " manufacturer: %i", reply.manufacturer); - DEBUG_LOG(WII_IPC_WIIMOTE, " lmp_subversion: %i", reply.lmp_subversion); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_LOCAL_VER:"); + DEBUG_LOG(IOS_WIIMOTE, "return:"); + DEBUG_LOG(IOS_WIIMOTE, " status: %i", reply.status); + DEBUG_LOG(IOS_WIIMOTE, " hci_revision: %i", reply.hci_revision); + DEBUG_LOG(IOS_WIIMOTE, " lmp_version: %i", reply.lmp_version); + DEBUG_LOG(IOS_WIIMOTE, " manufacturer: %i", reply.manufacturer); + DEBUG_LOG(IOS_WIIMOTE, " lmp_subversion: %i", reply.lmp_subversion); SendEventCommandComplete(HCI_CMD_READ_LOCAL_VER, &reply, sizeof(hci_read_local_ver_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadLocalFeatures(const u8* input) +void BluetoothEmu::CommandReadLocalFeatures(const u8* input) { hci_read_local_features_rp reply; reply.status = 0x00; @@ -1692,16 +1677,16 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadLocalFeatures(const u8* reply.features[6] = 0x00; reply.features[7] = 0x80; - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_READ_LOCAL_FEATURES:"); - DEBUG_LOG(WII_IPC_WIIMOTE, "return:"); - DEBUG_LOG(WII_IPC_WIIMOTE, " features: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", - reply.features[0], reply.features[1], reply.features[2], reply.features[3], - reply.features[4], reply.features[5], reply.features[6], reply.features[7]); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_LOCAL_FEATURES:"); + DEBUG_LOG(IOS_WIIMOTE, "return:"); + DEBUG_LOG(IOS_WIIMOTE, " features: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", reply.features[0], + reply.features[1], reply.features[2], reply.features[3], reply.features[4], + reply.features[5], reply.features[6], reply.features[7]); SendEventCommandComplete(HCI_CMD_READ_LOCAL_FEATURES, &reply, sizeof(hci_read_local_features_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadBufferSize(const u8* input) +void BluetoothEmu::CommandReadBufferSize(const u8* input) { hci_read_buffer_size_rp reply; reply.status = 0x00; @@ -1713,32 +1698,32 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadBufferSize(const u8* in reply.max_sco_size = SCO_PKT_SIZE; reply.num_sco_pkts = SCO_PKT_NUM; - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_READ_BUFFER_SIZE:"); - DEBUG_LOG(WII_IPC_WIIMOTE, "return:"); - DEBUG_LOG(WII_IPC_WIIMOTE, " max_acl_size: %i", reply.max_acl_size); - DEBUG_LOG(WII_IPC_WIIMOTE, " num_acl_pkts: %i", reply.num_acl_pkts); - DEBUG_LOG(WII_IPC_WIIMOTE, " max_sco_size: %i", reply.max_sco_size); - DEBUG_LOG(WII_IPC_WIIMOTE, " num_sco_pkts: %i", reply.num_sco_pkts); + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_BUFFER_SIZE:"); + DEBUG_LOG(IOS_WIIMOTE, "return:"); + DEBUG_LOG(IOS_WIIMOTE, " max_acl_size: %i", reply.max_acl_size); + DEBUG_LOG(IOS_WIIMOTE, " num_acl_pkts: %i", reply.num_acl_pkts); + DEBUG_LOG(IOS_WIIMOTE, " max_sco_size: %i", reply.max_sco_size); + DEBUG_LOG(IOS_WIIMOTE, " num_sco_pkts: %i", reply.num_sco_pkts); SendEventCommandComplete(HCI_CMD_READ_BUFFER_SIZE, &reply, sizeof(hci_read_buffer_size_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandReadBDAdrr(const u8* input) +void BluetoothEmu::CommandReadBDAdrr(const u8* input) { hci_read_bdaddr_rp reply; reply.status = 0x00; reply.bdaddr = m_ControllerBD; - INFO_LOG(WII_IPC_WIIMOTE, "Command: HCI_CMD_READ_BDADDR:"); - DEBUG_LOG(WII_IPC_WIIMOTE, "return:"); - DEBUG_LOG(WII_IPC_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", reply.bdaddr.b[0], + INFO_LOG(IOS_WIIMOTE, "Command: HCI_CMD_READ_BDADDR:"); + DEBUG_LOG(IOS_WIIMOTE, "return:"); + DEBUG_LOG(IOS_WIIMOTE, " bd: %02x:%02x:%02x:%02x:%02x:%02x", reply.bdaddr.b[0], reply.bdaddr.b[1], reply.bdaddr.b[2], reply.bdaddr.b[3], reply.bdaddr.b[4], reply.bdaddr.b[5]); SendEventCommandComplete(HCI_CMD_READ_BDADDR, &reply, sizeof(hci_read_bdaddr_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandVendorSpecific_FC4F(const u8* input, u32 size) +void BluetoothEmu::CommandVendorSpecific_FC4F(const u8* input, u32 size) { // callstack... // BTM_VendorSpecificCommad() @@ -1750,22 +1735,22 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandVendorSpecific_FC4F(const u hci_status_rp reply; reply.status = 0x00; - INFO_LOG(WII_IPC_WIIMOTE, "Command: CommandVendorSpecific_FC4F: (callstack WUDiRemovePatch)"); - DEBUG_LOG(WII_IPC_WIIMOTE, "Input (size 0x%x):", size); + INFO_LOG(IOS_WIIMOTE, "Command: CommandVendorSpecific_FC4F: (callstack WUDiRemovePatch)"); + DEBUG_LOG(IOS_WIIMOTE, "Input (size 0x%x):", size); - Dolphin_Debugger::PrintDataBuffer(LogTypes::WII_IPC_WIIMOTE, input, size, "Data: "); + Dolphin_Debugger::PrintDataBuffer(LogTypes::IOS_WIIMOTE, input, size, "Data: "); SendEventCommandComplete(0xFC4F, &reply, sizeof(hci_status_rp)); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandVendorSpecific_FC4C(const u8* input, u32 size) +void BluetoothEmu::CommandVendorSpecific_FC4C(const u8* input, u32 size) { hci_status_rp reply; reply.status = 0x00; - DEBUG_LOG(WII_IPC_WIIMOTE, "Command: CommandVendorSpecific_FC4C:"); - DEBUG_LOG(WII_IPC_WIIMOTE, "Input (size 0x%x):", size); - Dolphin_Debugger::PrintDataBuffer(LogTypes::WII_IPC_WIIMOTE, input, size, "Data: "); + DEBUG_LOG(IOS_WIIMOTE, "Command: CommandVendorSpecific_FC4C:"); + DEBUG_LOG(IOS_WIIMOTE, "Input (size 0x%x):", size); + Dolphin_Debugger::PrintDataBuffer(LogTypes::IOS_WIIMOTE, input, size, "Data: "); SendEventCommandComplete(0xFC4C, &reply, sizeof(hci_status_rp)); } @@ -1775,7 +1760,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::CommandVendorSpecific_FC4C(const u // --- helper // // -CWII_IPC_HLE_WiiMote* CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::AccessWiiMote(const bdaddr_t& _rAddr) +WiimoteDevice* BluetoothEmu::AccessWiiMote(const bdaddr_t& _rAddr) { for (auto& wiimote : m_WiiMotes) { @@ -1785,12 +1770,12 @@ CWII_IPC_HLE_WiiMote* CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::AccessWiiMote(con return &wiimote; } - ERROR_LOG(WII_IPC_WIIMOTE, "Can't find WiiMote by bd: %02x:%02x:%02x:%02x:%02x:%02x", _rAddr.b[0], + ERROR_LOG(IOS_WIIMOTE, "Can't find WiiMote by bd: %02x:%02x:%02x:%02x:%02x:%02x", _rAddr.b[0], _rAddr.b[1], _rAddr.b[2], _rAddr.b[3], _rAddr.b[4], _rAddr.b[5]); return nullptr; } -CWII_IPC_HLE_WiiMote* CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::AccessWiiMote(u16 _ConnectionHandle) +WiimoteDevice* BluetoothEmu::AccessWiiMote(u16 _ConnectionHandle) { for (auto& wiimote : m_WiiMotes) { @@ -1798,13 +1783,12 @@ CWII_IPC_HLE_WiiMote* CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::AccessWiiMote(u16 return &wiimote; } - ERROR_LOG(WII_IPC_WIIMOTE, "Can't find Wiimote by connection handle %02x", _ConnectionHandle); + ERROR_LOG(IOS_WIIMOTE, "Can't find Wiimote by connection handle %02x", _ConnectionHandle); PanicAlertT("Can't find Wii Remote by connection handle %02x", _ConnectionHandle); return nullptr; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::DisplayDisconnectMessage(const int wiimoteNumber, - const int reason) +void BluetoothEmu::DisplayDisconnectMessage(const int wiimoteNumber, const int reason) { // TODO: If someone wants to be fancy we could also figure out what the values for pDiscon->reason // mean @@ -1812,5 +1796,6 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::DisplayDisconnectMessage(const int Core::DisplayMessage( StringFromFormat("Wii Remote %i disconnected by emulated software", wiimoteNumber), 3000); } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.h b/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.h similarity index 88% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.h rename to Source/Core/Core/IOS/USB/Bluetooth/BTEmu.h index bbd06fdadb..960dac4d49 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.h +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTEmu.h @@ -13,11 +13,11 @@ #include "Common/CommonTypes.h" #include "Core/HW/Wiimote.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_usb_bt_base.h" -#include "Core/IPC_HLE/WII_IPC_HLE_WiiMote.h" -#include "Core/IPC_HLE/hci.h" +#include "Core/IOS/Device.h" +#include "Core/IOS/IPC.h" +#include "Core/IOS/USB/Bluetooth/BTBase.h" +#include "Core/IOS/USB/Bluetooth/WiimoteDevice.h" +#include "Core/IOS/USB/Bluetooth/hci.h" class PointerWrap; @@ -25,8 +25,6 @@ namespace IOS { namespace HLE { -class CWII_IPC_HLE_WiiMote; - struct SQueuedEvent { u8 m_buffer[1024] = {0}; @@ -37,17 +35,18 @@ struct SQueuedEvent SQueuedEvent() = default; }; +namespace Device +{ // Important to remember that this class is for /dev/usb/oh1/57e/305 ONLY // /dev/usb/oh1 -> internal usb bus // 57e/305 -> VendorID/ProductID of device on usb bus // This device is ONLY the internal Bluetooth module (based on BCM2045 chip) -class CWII_IPC_HLE_Device_usb_oh1_57e_305_emu final - : public CWII_IPC_HLE_Device_usb_oh1_57e_305_base +class BluetoothEmu final : public BluetoothBase { public: - CWII_IPC_HLE_Device_usb_oh1_57e_305_emu(u32 _DeviceID, const std::string& _rDeviceName); + BluetoothEmu(u32 device_id, const std::string& device_name); - virtual ~CWII_IPC_HLE_Device_usb_oh1_57e_305_emu(); + virtual ~BluetoothEmu(); void Close() override; IPCCommandResult IOCtlV(const IOSIOCtlVRequest& request) override; @@ -59,9 +58,9 @@ public: bool RemoteDisconnect(u16 _connectionHandle); - std::vector m_WiiMotes; - CWII_IPC_HLE_WiiMote* AccessWiiMote(const bdaddr_t& _rAddr); - CWII_IPC_HLE_WiiMote* AccessWiiMote(u16 _ConnectionHandle); + std::vector m_WiiMotes; + WiimoteDevice* AccessWiiMote(const bdaddr_t& _rAddr); + WiimoteDevice* AccessWiiMote(u16 _ConnectionHandle); void DoState(PointerWrap& p) override; @@ -112,7 +111,7 @@ private: bool SendEventInquiryResponse(); bool SendEventInquiryComplete(); bool SendEventRemoteNameReq(const bdaddr_t& _bd); - bool SendEventRequestConnection(CWII_IPC_HLE_WiiMote& _rWiiMote); + bool SendEventRequestConnection(WiimoteDevice& _rWiiMote); bool SendEventConnectionComplete(const bdaddr_t& _bd); bool SendEventReadClockOffsetComplete(u16 _connectionHandle); bool SendEventConPacketTypeChange(u16 _connectionHandle, u16 _packetType); @@ -194,5 +193,6 @@ private: }; #pragma pack(pop) }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_real.cpp b/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp similarity index 86% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_real.cpp rename to Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp index 7f93b65cbe..4acdbe8870 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_real.cpp +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTReal.cpp @@ -27,9 +27,9 @@ #include "Core/ConfigManager.h" #include "Core/Core.h" #include "Core/HW/Memmap.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_real.h" -#include "Core/IPC_HLE/hci.h" +#include "Core/IOS/Device.h" +#include "Core/IOS/USB/Bluetooth/BTReal.h" +#include "Core/IOS/USB/Bluetooth/hci.h" namespace IOS { @@ -66,17 +66,18 @@ static bool IsBluetoothDevice(const libusb_interface_descriptor& descriptor) descriptor.bInterfaceProtocol == PROTOCOL_BLUETOOTH; } -CWII_IPC_HLE_Device_usb_oh1_57e_305_real::CWII_IPC_HLE_Device_usb_oh1_57e_305_real( - u32 device_id, const std::string& device_name) - : CWII_IPC_HLE_Device_usb_oh1_57e_305_base(device_id, device_name) +namespace Device +{ +BluetoothReal::BluetoothReal(u32 device_id, const std::string& device_name) + : BluetoothBase(device_id, device_name) { const int ret = libusb_init(&m_libusb_context); - _assert_msg_(WII_IPC_WIIMOTE, ret == 0, "Failed to init libusb."); + _assert_msg_(IOS_WIIMOTE, ret == 0, "Failed to init libusb."); LoadLinkKeys(); } -CWII_IPC_HLE_Device_usb_oh1_57e_305_real::~CWII_IPC_HLE_Device_usb_oh1_57e_305_real() +BluetoothReal::~BluetoothReal() { if (m_handle != nullptr) { @@ -94,11 +95,11 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305_real::~CWII_IPC_HLE_Device_usb_oh1_57e_305_r SaveLinkKeys(); } -IOSReturnCode CWII_IPC_HLE_Device_usb_oh1_57e_305_real::Open(const IOSOpenRequest& request) +IOSReturnCode BluetoothReal::Open(const IOSOpenRequest& request) { libusb_device** list; const ssize_t cnt = libusb_get_device_list(m_libusb_context, &list); - _dbg_assert_msg_(WII_IPC_HLE, cnt > 0, "Couldn't get device list"); + _dbg_assert_msg_(IOS, cnt > 0, "Couldn't get device list"); for (ssize_t i = 0; i < cnt; ++i) { libusb_device* device = list[i]; @@ -108,7 +109,7 @@ IOSReturnCode CWII_IPC_HLE_Device_usb_oh1_57e_305_real::Open(const IOSOpenReques const int ret = libusb_get_active_config_descriptor(device, &config_descriptor); if (ret != 0) { - ERROR_LOG(WII_IPC_WIIMOTE, "Failed to get config descriptor for device %04x:%04x: %s", + ERROR_LOG(IOS_WIIMOTE, "Failed to get config descriptor for device %04x:%04x: %s", device_descriptor.idVendor, device_descriptor.idProduct, libusb_error_name(ret)); continue; } @@ -124,7 +125,7 @@ IOSReturnCode CWII_IPC_HLE_Device_usb_oh1_57e_305_real::Open(const IOSOpenReques sizeof(product)); libusb_get_string_descriptor_ascii(m_handle, device_descriptor.iSerialNumber, serial_number, sizeof(serial_number)); - NOTICE_LOG(WII_IPC_WIIMOTE, "Using device %04x:%04x (rev %x) for Bluetooth: %s %s %s", + NOTICE_LOG(IOS_WIIMOTE, "Using device %04x:%04x (rev %x) for Bluetooth: %s %s %s", device_descriptor.idVendor, device_descriptor.idProduct, device_descriptor.bcdDevice, manufacturer, product, serial_number); m_is_wii_bt_module = @@ -150,7 +151,7 @@ IOSReturnCode CWII_IPC_HLE_Device_usb_oh1_57e_305_real::Open(const IOSOpenReques return IPC_SUCCESS; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::Close() +void BluetoothReal::Close() { if (m_handle) { @@ -163,7 +164,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::Close() m_is_active = false; } -IPCCommandResult CWII_IPC_HLE_Device_usb_oh1_57e_305_real::IOCtlV(const IOSIOCtlVRequest& request) +IPCCommandResult BluetoothReal::IOCtlV(const IOSIOCtlVRequest& request) { if (!m_is_wii_bt_module && s_need_reset_keys.TestAndClear()) { @@ -266,7 +267,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_oh1_57e_305_real::IOCtlV(const IOSIOCtl return GetNoReply(); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::DoState(PointerWrap& p) +void BluetoothReal::DoState(PointerWrap& p) { bool passthrough_bluetooth = true; p.Do(passthrough_bluetooth); @@ -280,7 +281,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::DoState(PointerWrap& p) } } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::UpdateSyncButtonState(const bool is_held) +void BluetoothReal::UpdateSyncButtonState(const bool is_held) { if (m_sync_button_state == SyncButtonState::Unpressed && is_held) { @@ -298,17 +299,17 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::UpdateSyncButtonState(const bool m_sync_button_state = SyncButtonState::Unpressed; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::TriggerSyncButtonPressedEvent() +void BluetoothReal::TriggerSyncButtonPressedEvent() { m_sync_button_state = SyncButtonState::Pressed; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::TriggerSyncButtonHeldEvent() +void BluetoothReal::TriggerSyncButtonHeldEvent() { m_sync_button_state = SyncButtonState::LongPressed; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::WaitForHCICommandComplete(const u16 opcode) +void BluetoothReal::WaitForHCICommandComplete(const u16 opcode) { int actual_length; std::vector buffer(1024); @@ -323,17 +324,17 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::WaitForHCICommandComplete(const u } } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::SendHCIResetCommand() +void BluetoothReal::SendHCIResetCommand() { const u8 type = LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE; u8 packet[3] = {}; const u16 payload[] = {HCI_CMD_RESET}; memcpy(packet, payload, sizeof(payload)); libusb_control_transfer(m_handle, type, 0, 0, 0, packet, sizeof(packet), TIMEOUT); - INFO_LOG(WII_IPC_WIIMOTE, "Sent a reset command to adapter"); + INFO_LOG(IOS_WIIMOTE, "Sent a reset command to adapter"); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::SendHCIDeleteLinkKeyCommand() +void BluetoothReal::SendHCIDeleteLinkKeyCommand() { const u8 type = LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE; std::vector packet(sizeof(hci_cmd_hdr_t) + sizeof(hci_delete_stored_link_key_cp)); @@ -350,7 +351,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::SendHCIDeleteLinkKeyCommand() TIMEOUT); } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_real::SendHCIStoreLinkKeyCommand() +bool BluetoothReal::SendHCIStoreLinkKeyCommand() { if (s_link_keys.empty()) return false; @@ -389,7 +390,7 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_real::SendHCIStoreLinkKeyCommand() return true; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::FakeVendorCommandReply(CtrlBuffer& ctrl) +void BluetoothReal::FakeVendorCommandReply(CtrlBuffer& ctrl) { u8* packet = Memory::GetPointer(ctrl.m_payload_addr); auto* hci_event = reinterpret_cast(packet); @@ -406,7 +407,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::FakeVendorCommandReply(CtrlBuffer // - it will cause a u8 underflow and royally screw things up. // Therefore, the reply to this command has to be faked to avoid random, weird issues // (including Wiimote disconnects and "event mismatch" warning messages). -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::FakeReadBufferSizeReply(CtrlBuffer& ctrl) +void BluetoothReal::FakeReadBufferSizeReply(CtrlBuffer& ctrl) { u8* packet = Memory::GetPointer(ctrl.m_payload_addr); auto* hci_event = reinterpret_cast(packet); @@ -427,8 +428,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::FakeReadBufferSizeReply(CtrlBuffe static_cast(sizeof(SHCIEventCommand) + sizeof(hci_read_buffer_size_rp))); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::FakeSyncButtonEvent(CtrlBuffer& ctrl, - const u8* payload, const u8 size) +void BluetoothReal::FakeSyncButtonEvent(CtrlBuffer& ctrl, const u8* payload, const u8 size) { u8* packet = Memory::GetPointer(ctrl.m_payload_addr); auto* hci_event = reinterpret_cast(packet); @@ -442,24 +442,24 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::FakeSyncButtonEvent(CtrlBuffer& c // > HCI Event: Vendor (0xff) plen 1 // 08 // This causes the emulated software to perform a BT inquiry and connect to found Wiimotes. -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::FakeSyncButtonPressedEvent(CtrlBuffer& ctrl) +void BluetoothReal::FakeSyncButtonPressedEvent(CtrlBuffer& ctrl) { - NOTICE_LOG(WII_IPC_WIIMOTE, "Faking 'sync button pressed' (0x08) event packet"); + NOTICE_LOG(IOS_WIIMOTE, "Faking 'sync button pressed' (0x08) event packet"); const u8 payload[1] = {0x08}; FakeSyncButtonEvent(ctrl, payload, sizeof(payload)); m_sync_button_state = SyncButtonState::Ignored; } // When the red sync button is held for 10 seconds, a HCI event with payload 09 is sent. -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::FakeSyncButtonHeldEvent(CtrlBuffer& ctrl) +void BluetoothReal::FakeSyncButtonHeldEvent(CtrlBuffer& ctrl) { - NOTICE_LOG(WII_IPC_WIIMOTE, "Faking 'sync button held' (0x09) event packet"); + NOTICE_LOG(IOS_WIIMOTE, "Faking 'sync button held' (0x09) event packet"); const u8 payload[1] = {0x09}; FakeSyncButtonEvent(ctrl, payload, sizeof(payload)); m_sync_button_state = SyncButtonState::Ignored; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::LoadLinkKeys() +void BluetoothReal::LoadLinkKeys() { const std::string& entries = SConfig::GetInstance().m_bt_passthrough_link_keys; if (entries.empty()) @@ -490,7 +490,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::LoadLinkKeys() } } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::SaveLinkKeys() +void BluetoothReal::SaveLinkKeys() { std::ostringstream oss; for (const auto& entry : s_link_keys) @@ -511,7 +511,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::SaveLinkKeys() SConfig::GetInstance().m_bt_passthrough_link_keys = config_string; } -bool CWII_IPC_HLE_Device_usb_oh1_57e_305_real::OpenDevice(libusb_device* device) +bool BluetoothReal::OpenDevice(libusb_device* device) { m_device = libusb_ref_device(device); const int ret = libusb_open(m_device, &m_handle); @@ -536,15 +536,15 @@ bool CWII_IPC_HLE_Device_usb_oh1_57e_305_real::OpenDevice(libusb_device* device) return true; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::StartTransferThread() +void BluetoothReal::StartTransferThread() { if (m_thread_running.IsSet()) return; m_thread_running.Set(); - m_thread = std::thread(&CWII_IPC_HLE_Device_usb_oh1_57e_305_real::TransferThread, this); + m_thread = std::thread(&BluetoothReal::TransferThread, this); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::StopTransferThread() +void BluetoothReal::StopTransferThread() { if (m_thread_running.TestAndClear()) { @@ -553,7 +553,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::StopTransferThread() } } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::TransferThread() +void BluetoothReal::TransferThread() { Common::SetCurrentThreadName("BT USB Thread"); while (m_thread_running.IsSet()) @@ -563,12 +563,12 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::TransferThread() } // The callbacks are called from libusb code on a separate thread. -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::CommandCallback(libusb_transfer* tr) +void BluetoothReal::CommandCallback(libusb_transfer* tr) { const std::unique_ptr cmd(static_cast(tr->user_data)); if (tr->status != LIBUSB_TRANSFER_COMPLETED && tr->status != LIBUSB_TRANSFER_NO_DEVICE) { - ERROR_LOG(WII_IPC_WIIMOTE, "libusb command transfer failed, status: 0x%02x", tr->status); + ERROR_LOG(IOS_WIIMOTE, "libusb command transfer failed, status: 0x%02x", tr->status); if (!s_showed_failed_transfer.IsSet()) { Core::DisplayMessage("Failed to send a command to the Bluetooth adapter.", 10000); @@ -584,13 +584,13 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::CommandCallback(libusb_transfer* EnqueueReply(cmd->ios_request, tr->actual_length, 0, CoreTiming::FromThread::NON_CPU); } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::TransferCallback(libusb_transfer* tr) +void BluetoothReal::TransferCallback(libusb_transfer* tr) { const std::unique_ptr ctrl(static_cast(tr->user_data)); if (tr->status != LIBUSB_TRANSFER_COMPLETED && tr->status != LIBUSB_TRANSFER_TIMED_OUT && tr->status != LIBUSB_TRANSFER_NO_DEVICE) { - ERROR_LOG(WII_IPC_WIIMOTE, "libusb transfer failed, status: 0x%02x", tr->status); + ERROR_LOG(IOS_WIIMOTE, "libusb transfer failed, status: 0x%02x", tr->status); if (!s_showed_failed_transfer.IsSet()) { Core::DisplayMessage("Failed to transfer to or from to the Bluetooth adapter.", 10000); @@ -627,5 +627,6 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305_real::TransferCallback(libusb_transfer* EnqueueReply(ctrl->ios_request, tr->actual_length, 0, CoreTiming::FromThread::NON_CPU); } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_real.h b/Source/Core/Core/IOS/USB/Bluetooth/BTReal.h similarity index 85% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_real.h rename to Source/Core/Core/IOS/USB/Bluetooth/BTReal.h index a87b9cc4b6..692e3fb3b8 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_real.h +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTReal.h @@ -13,8 +13,8 @@ #include "Common/CommonTypes.h" #include "Common/Flag.h" #include "Common/Timer.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.h" +#include "Core/IOS/IPC.h" +#include "Core/IOS/USB/Bluetooth/BTBase.h" class PointerWrap; struct libusb_context; @@ -39,12 +39,13 @@ enum class SyncButtonState using btaddr_t = std::array; using linkkey_t = std::array; -class CWII_IPC_HLE_Device_usb_oh1_57e_305_real final - : public CWII_IPC_HLE_Device_usb_oh1_57e_305_base +namespace Device +{ +class BluetoothReal final : public BluetoothBase { public: - CWII_IPC_HLE_Device_usb_oh1_57e_305_real(u32 device_id, const std::string& device_name); - ~CWII_IPC_HLE_Device_usb_oh1_57e_305_real() override; + BluetoothReal(u32 device_id, const std::string& device_name); + ~BluetoothReal() override; IOSReturnCode Open(const IOSOpenRequest& request) override; void Close() override; @@ -100,17 +101,21 @@ private: static void CommandCallback(libusb_transfer* transfer); static void TransferCallback(libusb_transfer* transfer); }; +} // namespace Device } // namespace HLE } // namespace IOS #else -#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_stub.h" +#include "Core/IOS/USB/Bluetooth/BTStub.h" namespace IOS { namespace HLE { -using CWII_IPC_HLE_Device_usb_oh1_57e_305_real = CWII_IPC_HLE_Device_usb_oh1_57e_305_stub; +namespace Device +{ +using BluetoothReal = BluetoothStub; +} // namespace Device } // namespace HLE } // namespace IOS #endif diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_stub.cpp b/Source/Core/Core/IOS/USB/Bluetooth/BTStub.cpp similarity index 74% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_stub.cpp rename to Source/Core/Core/IOS/USB/Bluetooth/BTStub.cpp index 074404e40e..1a76484427 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_stub.cpp +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTStub.cpp @@ -2,7 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_stub.h" +#include "Core/IOS/USB/Bluetooth/BTStub.h" #include "Common/ChunkFile.h" #include "Common/MsgHandler.h" @@ -16,17 +16,20 @@ namespace IOS { namespace HLE { -IOSReturnCode CWII_IPC_HLE_Device_usb_oh1_57e_305_stub::Open(const IOSOpenRequest& request) +namespace Device +{ +IOSReturnCode BluetoothStub::Open(const IOSOpenRequest& request) { PanicAlertT("Bluetooth passthrough mode is enabled, but Dolphin was built without libusb." " Passthrough mode cannot be used."); return IPC_ENOENT; } -void CWII_IPC_HLE_Device_usb_oh1_57e_305_stub::DoState(PointerWrap& p) +void BluetoothStub::DoState(PointerWrap& p) { Core::DisplayMessage("The current IPC_HLE_Device_usb is a stub. Aborting load.", 4000); p.SetMode(PointerWrap::MODE_VERIFY); } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_stub.h b/Source/Core/Core/IOS/USB/Bluetooth/BTStub.h similarity index 51% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_stub.h rename to Source/Core/Core/IOS/USB/Bluetooth/BTStub.h index e811b8eb0e..0d78d991d0 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_stub.h +++ b/Source/Core/Core/IOS/USB/Bluetooth/BTStub.h @@ -7,8 +7,8 @@ #include #include "Common/CommonTypes.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.h" +#include "Core/IOS/IPC.h" +#include "Core/IOS/USB/Bluetooth/BTBase.h" class PointerWrap; @@ -16,16 +16,18 @@ namespace IOS { namespace HLE { -class CWII_IPC_HLE_Device_usb_oh1_57e_305_stub final - : public CWII_IPC_HLE_Device_usb_oh1_57e_305_base +namespace Device +{ +class BluetoothStub final : public BluetoothBase { public: - CWII_IPC_HLE_Device_usb_oh1_57e_305_stub(const u32 device_id, const std::string& device_name) - : CWII_IPC_HLE_Device_usb_oh1_57e_305_base(device_id, device_name) + BluetoothStub(const u32 device_id, const std::string& device_name) + : BluetoothBase(device_id, device_name) { } IOSReturnCode Open(const IOSOpenRequest& request) override; void DoState(PointerWrap& p) override; }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_WiiMote.cpp b/Source/Core/Core/IOS/USB/Bluetooth/WiimoteDevice.cpp similarity index 69% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_WiiMote.cpp rename to Source/Core/Core/IOS/USB/Bluetooth/WiimoteDevice.cpp index 0b13fac48c..dddd3feb64 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_WiiMote.cpp +++ b/Source/Core/Core/IOS/USB/Bluetooth/WiimoteDevice.cpp @@ -16,34 +16,33 @@ #include "Core/Core.h" #include "Core/HW/Wiimote.h" #include "Core/Host.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.h" -#include "Core/IPC_HLE/WII_IPC_HLE_WiiMote.h" -#include "Core/IPC_HLE/WiiMote_HID_Attr.h" -#include "Core/IPC_HLE/l2cap.h" +#include "Core/IOS/USB/Bluetooth/BTEmu.h" +#include "Core/IOS/USB/Bluetooth/WiimoteDevice.h" +#include "Core/IOS/USB/Bluetooth/WiimoteHIDAttr.h" +#include "Core/IOS/USB/Bluetooth/l2cap.h" namespace IOS { namespace HLE { -static CWII_IPC_HLE_Device_usb_oh1_57e_305_emu* s_Usb = nullptr; +static Device::BluetoothEmu* s_Usb = nullptr; -CWII_IPC_HLE_Device_usb_oh1_57e_305_emu* GetUsbPointer() +Device::BluetoothEmu* GetUsbPointer() { return s_Usb; } -void SetUsbPointer(CWII_IPC_HLE_Device_usb_oh1_57e_305_emu* ptr) +void SetUsbPointer(Device::BluetoothEmu* ptr) { s_Usb = ptr; } -CWII_IPC_HLE_WiiMote::CWII_IPC_HLE_WiiMote(CWII_IPC_HLE_Device_usb_oh1_57e_305_emu* host, - int number, bdaddr_t bd, bool ready) +WiimoteDevice::WiimoteDevice(Device::BluetoothEmu* host, int number, bdaddr_t bd, bool ready) : m_BD(bd), m_Name(number == WIIMOTE_BALANCE_BOARD ? "Nintendo RVL-WBC-01" : "Nintendo RVL-CNT-01"), m_pHost(host) { - INFO_LOG(WII_IPC_WIIMOTE, "Wiimote: #%i Constructed", number); + INFO_LOG(IOS_WIIMOTE, "Wiimote: #%i Constructed", number); m_ConnectionState = (ready) ? CONN_READY : CONN_INACTIVE; m_ConnectionHandle = 0x100 + number; @@ -76,7 +75,7 @@ CWII_IPC_HLE_WiiMote::CWII_IPC_HLE_WiiMote(CWII_IPC_HLE_Device_usb_oh1_57e_305_e lmp_subversion = 0x229; } -void CWII_IPC_HLE_WiiMote::DoState(PointerWrap& p) +void WiimoteDevice::DoState(PointerWrap& p) { bool passthrough_bluetooth = false; p.Do(passthrough_bluetooth); @@ -88,7 +87,7 @@ void CWII_IPC_HLE_WiiMote::DoState(PointerWrap& p) return; } - // this function is usually not called... see CWII_IPC_HLE_Device_usb_oh1_57e_305::DoState + // this function is usually not called... see Device::BluetoothEmu::DoState p.Do(m_ConnectionState); @@ -124,7 +123,7 @@ void CWII_IPC_HLE_WiiMote::DoState(PointerWrap& p) // // -bool CWII_IPC_HLE_WiiMote::LinkChannel() +bool WiimoteDevice::LinkChannel() { if (m_ConnectionState != CONN_LINKING) return false; @@ -173,7 +172,7 @@ bool CWII_IPC_HLE_WiiMote::LinkChannel() return true; } - DEBUG_LOG(WII_IPC_WIIMOTE, "ConnectionState CONN_LINKING -> CONN_COMPLETE"); + DEBUG_LOG(IOS_WIIMOTE, "ConnectionState CONN_LINKING -> CONN_COMPLETE"); m_ConnectionState = CONN_COMPLETE; return false; @@ -189,7 +188,7 @@ bool CWII_IPC_HLE_WiiMote::LinkChannel() // // // -void CWII_IPC_HLE_WiiMote::Activate(bool ready) +void WiimoteDevice::Activate(bool ready) { if (ready && (m_ConnectionState == CONN_INACTIVE)) { @@ -202,13 +201,13 @@ void CWII_IPC_HLE_WiiMote::Activate(bool ready) } } -void CWII_IPC_HLE_WiiMote::EventConnectionAccepted() +void WiimoteDevice::EventConnectionAccepted() { - DEBUG_LOG(WII_IPC_WIIMOTE, "ConnectionState %x -> CONN_LINKING", m_ConnectionState); + DEBUG_LOG(IOS_WIIMOTE, "ConnectionState %x -> CONN_LINKING", m_ConnectionState); m_ConnectionState = CONN_LINKING; } -void CWII_IPC_HLE_WiiMote::EventDisconnect() +void WiimoteDevice::EventDisconnect() { // Send disconnect message to plugin Wiimote::ControlChannel(m_ConnectionHandle & 0xFF, 99, nullptr, 0); @@ -218,7 +217,7 @@ void CWII_IPC_HLE_WiiMote::EventDisconnect() ResetChannels(); } -bool CWII_IPC_HLE_WiiMote::EventPagingChanged(u8 _pageMode) +bool WiimoteDevice::EventPagingChanged(u8 _pageMode) { if ((m_ConnectionState == CONN_READY) && (_pageMode & HCI_PAGE_SCAN_ENABLE)) return true; @@ -226,7 +225,7 @@ bool CWII_IPC_HLE_WiiMote::EventPagingChanged(u8 _pageMode) return false; } -void CWII_IPC_HLE_WiiMote::ResetChannels() +void WiimoteDevice::ResetChannels() { // reset connection process m_HIDControlChannel_Connected = false; @@ -251,18 +250,18 @@ void CWII_IPC_HLE_WiiMote::ResetChannels() // // This function receives L2CAP commands from the CPU -void CWII_IPC_HLE_WiiMote::ExecuteL2capCmd(u8* _pData, u32 _Size) +void WiimoteDevice::ExecuteL2capCmd(u8* _pData, u32 _Size) { // parse the command l2cap_hdr_t* pHeader = (l2cap_hdr_t*)_pData; u8* pData = _pData + sizeof(l2cap_hdr_t); u32 DataSize = _Size - sizeof(l2cap_hdr_t); - DEBUG_LOG(WII_IPC_WIIMOTE, " CID 0x%04x, Len 0x%x, DataSize 0x%x", pHeader->dcid, - pHeader->length, DataSize); + DEBUG_LOG(IOS_WIIMOTE, " CID 0x%04x, Len 0x%x, DataSize 0x%x", pHeader->dcid, pHeader->length, + DataSize); if (pHeader->length != DataSize) { - INFO_LOG(WII_IPC_WIIMOTE, "Faulty packet. It is dropped."); + INFO_LOG(IOS_WIIMOTE, "Faulty packet. It is dropped."); return; } @@ -274,7 +273,7 @@ void CWII_IPC_HLE_WiiMote::ExecuteL2capCmd(u8* _pData, u32 _Size) default: { - _dbg_assert_msg_(WII_IPC_WIIMOTE, DoesChannelExist(pHeader->dcid), + _dbg_assert_msg_(IOS_WIIMOTE, DoesChannelExist(pHeader->dcid), "L2CAP: SendACLPacket to unknown channel %i", pHeader->dcid); CChannelMap::iterator itr = m_Channel.find(pHeader->dcid); @@ -309,8 +308,7 @@ void CWII_IPC_HLE_WiiMote::ExecuteL2capCmd(u8* _pData, u32 _Size) break; default: - ERROR_LOG(WII_IPC_WIIMOTE, "Channel 0x04%x has unknown PSM %x", pHeader->dcid, - rChannel.PSM); + ERROR_LOG(IOS_WIIMOTE, "Channel 0x04%x has unknown PSM %x", pHeader->dcid, rChannel.PSM); break; } } @@ -319,7 +317,7 @@ void CWII_IPC_HLE_WiiMote::ExecuteL2capCmd(u8* _pData, u32 _Size) } } -void CWII_IPC_HLE_WiiMote::SignalChannel(u8* _pData, u32 _Size) +void WiimoteDevice::SignalChannel(u8* _pData, u32 _Size) { while (_Size >= sizeof(l2cap_cmd_hdr_t)) { @@ -330,8 +328,8 @@ void CWII_IPC_HLE_WiiMote::SignalChannel(u8* _pData, u32 _Size) switch (cmd_hdr->code) { case L2CAP_COMMAND_REJ: - ERROR_LOG(WII_IPC_WIIMOTE, "SignalChannel - L2CAP_COMMAND_REJ (something went wrong)." - "Try to replace your SYSCONF file with a new copy."); + ERROR_LOG(IOS_WIIMOTE, "SignalChannel - L2CAP_COMMAND_REJ (something went wrong)." + "Try to replace your SYSCONF file with a new copy."); break; case L2CAP_CONNECT_REQ: @@ -355,7 +353,7 @@ void CWII_IPC_HLE_WiiMote::SignalChannel(u8* _pData, u32 _Size) break; default: - ERROR_LOG(WII_IPC_WIIMOTE, " Unknown Command-Code (0x%02x)", cmd_hdr->code); + ERROR_LOG(IOS_WIIMOTE, " Unknown Command-Code (0x%02x)", cmd_hdr->code); return; } @@ -374,7 +372,7 @@ void CWII_IPC_HLE_WiiMote::SignalChannel(u8* _pData, u32 _Size) // // -void CWII_IPC_HLE_WiiMote::ReceiveConnectionReq(u8 _Ident, u8* _pData, u32 _Size) +void WiimoteDevice::ReceiveConnectionReq(u8 _Ident, u8* _pData, u32 _Size) { l2cap_con_req_cp* pCommandConnectionReq = (l2cap_con_req_cp*)_pData; @@ -384,11 +382,11 @@ void CWII_IPC_HLE_WiiMote::ReceiveConnectionReq(u8 _Ident, u8* _pData, u32 _Size rChannel.SCID = pCommandConnectionReq->scid; rChannel.DCID = pCommandConnectionReq->scid; - DEBUG_LOG(WII_IPC_WIIMOTE, "[L2CAP] ReceiveConnectionRequest"); - DEBUG_LOG(WII_IPC_WIIMOTE, " Ident: 0x%02x", _Ident); - DEBUG_LOG(WII_IPC_WIIMOTE, " PSM: 0x%04x", rChannel.PSM); - DEBUG_LOG(WII_IPC_WIIMOTE, " SCID: 0x%04x", rChannel.SCID); - DEBUG_LOG(WII_IPC_WIIMOTE, " DCID: 0x%04x", rChannel.DCID); + DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveConnectionRequest"); + DEBUG_LOG(IOS_WIIMOTE, " Ident: 0x%02x", _Ident); + DEBUG_LOG(IOS_WIIMOTE, " PSM: 0x%04x", rChannel.PSM); + DEBUG_LOG(IOS_WIIMOTE, " SCID: 0x%04x", rChannel.SCID); + DEBUG_LOG(IOS_WIIMOTE, " DCID: 0x%04x", rChannel.DCID); // response l2cap_con_rsp_cp Rsp; @@ -397,7 +395,7 @@ void CWII_IPC_HLE_WiiMote::ReceiveConnectionReq(u8 _Ident, u8* _pData, u32 _Size Rsp.result = L2CAP_SUCCESS; Rsp.status = L2CAP_NO_INFO; - DEBUG_LOG(WII_IPC_WIIMOTE, "[L2CAP] SendConnectionResponse"); + DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendConnectionResponse"); SendCommandToACL(_Ident, L2CAP_CONNECT_RSP, sizeof(l2cap_con_rsp_cp), (u8*)&Rsp); // update state machine @@ -409,21 +407,21 @@ void CWII_IPC_HLE_WiiMote::ReceiveConnectionReq(u8 _Ident, u8* _pData, u32 _Size */ } -void CWII_IPC_HLE_WiiMote::ReceiveConnectionResponse(u8 _Ident, u8* _pData, u32 _Size) +void WiimoteDevice::ReceiveConnectionResponse(u8 _Ident, u8* _pData, u32 _Size) { l2cap_con_rsp_cp* rsp = (l2cap_con_rsp_cp*)_pData; - _dbg_assert_(WII_IPC_WIIMOTE, _Size == sizeof(l2cap_con_rsp_cp)); + _dbg_assert_(IOS_WIIMOTE, _Size == sizeof(l2cap_con_rsp_cp)); - DEBUG_LOG(WII_IPC_WIIMOTE, "[L2CAP] ReceiveConnectionResponse"); - DEBUG_LOG(WII_IPC_WIIMOTE, " DCID: 0x%04x", rsp->dcid); - DEBUG_LOG(WII_IPC_WIIMOTE, " SCID: 0x%04x", rsp->scid); - DEBUG_LOG(WII_IPC_WIIMOTE, " Result: 0x%04x", rsp->result); - DEBUG_LOG(WII_IPC_WIIMOTE, " Status: 0x%04x", rsp->status); + DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveConnectionResponse"); + DEBUG_LOG(IOS_WIIMOTE, " DCID: 0x%04x", rsp->dcid); + DEBUG_LOG(IOS_WIIMOTE, " SCID: 0x%04x", rsp->scid); + DEBUG_LOG(IOS_WIIMOTE, " Result: 0x%04x", rsp->result); + DEBUG_LOG(IOS_WIIMOTE, " Status: 0x%04x", rsp->status); - _dbg_assert_(WII_IPC_WIIMOTE, rsp->result == L2CAP_SUCCESS); - _dbg_assert_(WII_IPC_WIIMOTE, rsp->status == L2CAP_NO_INFO); - _dbg_assert_(WII_IPC_WIIMOTE, DoesChannelExist(rsp->scid)); + _dbg_assert_(IOS_WIIMOTE, rsp->result == L2CAP_SUCCESS); + _dbg_assert_(IOS_WIIMOTE, rsp->status == L2CAP_NO_INFO); + _dbg_assert_(IOS_WIIMOTE, DoesChannelExist(rsp->scid)); SChannel& rChannel = m_Channel[rsp->scid]; rChannel.DCID = rsp->dcid; @@ -435,21 +433,21 @@ void CWII_IPC_HLE_WiiMote::ReceiveConnectionResponse(u8 _Ident, u8* _pData, u32 m_HIDInterruptChannel_Connected = true; } -void CWII_IPC_HLE_WiiMote::ReceiveConfigurationReq(u8 _Ident, u8* _pData, u32 _Size) +void WiimoteDevice::ReceiveConfigurationReq(u8 _Ident, u8* _pData, u32 _Size) { u32 Offset = 0; l2cap_cfg_req_cp* pCommandConfigReq = (l2cap_cfg_req_cp*)_pData; - _dbg_assert_(WII_IPC_WIIMOTE, pCommandConfigReq->flags == - 0x00); // 1 means that the options are send in multi-packets - _dbg_assert_(WII_IPC_WIIMOTE, DoesChannelExist(pCommandConfigReq->dcid)); + _dbg_assert_(IOS_WIIMOTE, pCommandConfigReq->flags == + 0x00); // 1 means that the options are send in multi-packets + _dbg_assert_(IOS_WIIMOTE, DoesChannelExist(pCommandConfigReq->dcid)); SChannel& rChannel = m_Channel[pCommandConfigReq->dcid]; - DEBUG_LOG(WII_IPC_WIIMOTE, "[L2CAP] ReceiveConfigurationRequest"); - DEBUG_LOG(WII_IPC_WIIMOTE, " Ident: 0x%02x", _Ident); - DEBUG_LOG(WII_IPC_WIIMOTE, " DCID: 0x%04x", pCommandConfigReq->dcid); - DEBUG_LOG(WII_IPC_WIIMOTE, " Flags: 0x%04x", pCommandConfigReq->flags); + DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveConfigurationRequest"); + DEBUG_LOG(IOS_WIIMOTE, " Ident: 0x%02x", _Ident); + DEBUG_LOG(IOS_WIIMOTE, " DCID: 0x%04x", pCommandConfigReq->dcid); + DEBUG_LOG(IOS_WIIMOTE, " Flags: 0x%04x", pCommandConfigReq->flags); Offset += sizeof(l2cap_cfg_req_cp); @@ -473,24 +471,24 @@ void CWII_IPC_HLE_WiiMote::ReceiveConfigurationReq(u8 _Ident, u8* _pData, u32 _S { case L2CAP_OPT_MTU: { - _dbg_assert_(WII_IPC_WIIMOTE, pOptions->length == L2CAP_OPT_MTU_SIZE); + _dbg_assert_(IOS_WIIMOTE, pOptions->length == L2CAP_OPT_MTU_SIZE); l2cap_cfg_opt_val_t* pMTU = (l2cap_cfg_opt_val_t*)&_pData[Offset]; rChannel.MTU = pMTU->mtu; - DEBUG_LOG(WII_IPC_WIIMOTE, " MTU: 0x%04x", pMTU->mtu); + DEBUG_LOG(IOS_WIIMOTE, " MTU: 0x%04x", pMTU->mtu); } break; case L2CAP_OPT_FLUSH_TIMO: { - _dbg_assert_(WII_IPC_WIIMOTE, pOptions->length == L2CAP_OPT_FLUSH_TIMO_SIZE); + _dbg_assert_(IOS_WIIMOTE, pOptions->length == L2CAP_OPT_FLUSH_TIMO_SIZE); l2cap_cfg_opt_val_t* pFlushTimeOut = (l2cap_cfg_opt_val_t*)&_pData[Offset]; rChannel.FlushTimeOut = pFlushTimeOut->flush_timo; - DEBUG_LOG(WII_IPC_WIIMOTE, " FlushTimeOut: 0x%04x", pFlushTimeOut->flush_timo); + DEBUG_LOG(IOS_WIIMOTE, " FlushTimeOut: 0x%04x", pFlushTimeOut->flush_timo); } break; default: - _dbg_assert_msg_(WII_IPC_WIIMOTE, 0, "Unknown Option: 0x%02x", pOptions->type); + _dbg_assert_msg_(IOS_WIIMOTE, 0, "Unknown Option: 0x%02x", pOptions->type); break; } @@ -501,7 +499,7 @@ void CWII_IPC_HLE_WiiMote::ReceiveConfigurationReq(u8 _Ident, u8* _pData, u32 _S RespLen += OptionSize; } - DEBUG_LOG(WII_IPC_WIIMOTE, "[L2CAP] SendConfigurationResponse"); + DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendConfigurationResponse"); SendCommandToACL(_Ident, L2CAP_CONFIG_RSP, RespLen, TempBuffer); // update state machine @@ -511,16 +509,16 @@ void CWII_IPC_HLE_WiiMote::ReceiveConfigurationReq(u8 _Ident, u8* _pData, u32 _S m_HIDInterruptChannel_Connected = true; } -void CWII_IPC_HLE_WiiMote::ReceiveConfigurationResponse(u8 _Ident, u8* _pData, u32 _Size) +void WiimoteDevice::ReceiveConfigurationResponse(u8 _Ident, u8* _pData, u32 _Size) { l2cap_cfg_rsp_cp* rsp = (l2cap_cfg_rsp_cp*)_pData; - DEBUG_LOG(WII_IPC_WIIMOTE, "[L2CAP] ReceiveConfigurationResponse"); - DEBUG_LOG(WII_IPC_WIIMOTE, " SCID: 0x%04x", rsp->scid); - DEBUG_LOG(WII_IPC_WIIMOTE, " Flags: 0x%04x", rsp->flags); - DEBUG_LOG(WII_IPC_WIIMOTE, " Result: 0x%04x", rsp->result); + DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveConfigurationResponse"); + DEBUG_LOG(IOS_WIIMOTE, " SCID: 0x%04x", rsp->scid); + DEBUG_LOG(IOS_WIIMOTE, " Flags: 0x%04x", rsp->flags); + DEBUG_LOG(IOS_WIIMOTE, " Result: 0x%04x", rsp->result); - _dbg_assert_(WII_IPC_WIIMOTE, rsp->result == L2CAP_SUCCESS); + _dbg_assert_(IOS_WIIMOTE, rsp->result == L2CAP_SUCCESS); // update state machine SChannel& rChannel = m_Channel[rsp->scid]; @@ -531,21 +529,21 @@ void CWII_IPC_HLE_WiiMote::ReceiveConfigurationResponse(u8 _Ident, u8* _pData, u m_HIDInterruptChannel_Config = true; } -void CWII_IPC_HLE_WiiMote::ReceiveDisconnectionReq(u8 _Ident, u8* _pData, u32 _Size) +void WiimoteDevice::ReceiveDisconnectionReq(u8 _Ident, u8* _pData, u32 _Size) { l2cap_discon_req_cp* pCommandDisconnectionReq = (l2cap_discon_req_cp*)_pData; - DEBUG_LOG(WII_IPC_WIIMOTE, "[L2CAP] ReceiveDisconnectionReq"); - DEBUG_LOG(WII_IPC_WIIMOTE, " Ident: 0x%02x", _Ident); - DEBUG_LOG(WII_IPC_WIIMOTE, " DCID: 0x%04x", pCommandDisconnectionReq->dcid); - DEBUG_LOG(WII_IPC_WIIMOTE, " SCID: 0x%04x", pCommandDisconnectionReq->scid); + DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] ReceiveDisconnectionReq"); + DEBUG_LOG(IOS_WIIMOTE, " Ident: 0x%02x", _Ident); + DEBUG_LOG(IOS_WIIMOTE, " DCID: 0x%04x", pCommandDisconnectionReq->dcid); + DEBUG_LOG(IOS_WIIMOTE, " SCID: 0x%04x", pCommandDisconnectionReq->scid); // response l2cap_discon_req_cp Rsp; Rsp.dcid = pCommandDisconnectionReq->dcid; Rsp.scid = pCommandDisconnectionReq->scid; - DEBUG_LOG(WII_IPC_WIIMOTE, "[L2CAP] SendDisconnectionResponse"); + DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendDisconnectionResponse"); SendCommandToACL(_Ident, L2CAP_DISCONNECT_RSP, sizeof(l2cap_discon_req_cp), (u8*)&Rsp); } @@ -561,7 +559,7 @@ void CWII_IPC_HLE_WiiMote::ReceiveDisconnectionReq(u8 _Ident, u8* _pData, u32 _S // // We assume Wiimote is always connected -void CWII_IPC_HLE_WiiMote::SendConnectionRequest(u16 scid, u16 psm) +void WiimoteDevice::SendConnectionRequest(u16 scid, u16 psm) { // create the channel SChannel& rChannel = m_Channel[scid]; @@ -572,15 +570,15 @@ void CWII_IPC_HLE_WiiMote::SendConnectionRequest(u16 scid, u16 psm) cr.psm = psm; cr.scid = scid; - DEBUG_LOG(WII_IPC_WIIMOTE, "[L2CAP] SendConnectionRequest"); - DEBUG_LOG(WII_IPC_WIIMOTE, " Psm: 0x%04x", cr.psm); - DEBUG_LOG(WII_IPC_WIIMOTE, " Scid: 0x%04x", cr.scid); + DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendConnectionRequest"); + DEBUG_LOG(IOS_WIIMOTE, " Psm: 0x%04x", cr.psm); + DEBUG_LOG(IOS_WIIMOTE, " Scid: 0x%04x", cr.scid); SendCommandToACL(L2CAP_CONNECT_REQ, L2CAP_CONNECT_REQ, sizeof(l2cap_con_req_cp), (u8*)&cr); } // We don't initially disconnect Wiimote though ... -void CWII_IPC_HLE_WiiMote::SendDisconnectRequest(u16 scid) +void WiimoteDevice::SendDisconnectRequest(u16 scid) { // create the channel SChannel& rChannel = m_Channel[scid]; @@ -589,17 +587,17 @@ void CWII_IPC_HLE_WiiMote::SendDisconnectRequest(u16 scid) cr.dcid = rChannel.DCID; cr.scid = rChannel.SCID; - DEBUG_LOG(WII_IPC_WIIMOTE, "[L2CAP] SendDisconnectionRequest"); - DEBUG_LOG(WII_IPC_WIIMOTE, " Dcid: 0x%04x", cr.dcid); - DEBUG_LOG(WII_IPC_WIIMOTE, " Scid: 0x%04x", cr.scid); + DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendDisconnectionRequest"); + DEBUG_LOG(IOS_WIIMOTE, " Dcid: 0x%04x", cr.dcid); + DEBUG_LOG(IOS_WIIMOTE, " Scid: 0x%04x", cr.scid); SendCommandToACL(L2CAP_DISCONNECT_REQ, L2CAP_DISCONNECT_REQ, sizeof(l2cap_discon_req_cp), (u8*)&cr); } -void CWII_IPC_HLE_WiiMote::SendConfigurationRequest(u16 scid, u16 MTU, u16 FlushTimeOut) +void WiimoteDevice::SendConfigurationRequest(u16 scid, u16 MTU, u16 FlushTimeOut) { - _dbg_assert_(WII_IPC_WIIMOTE, DoesChannelExist(scid)); + _dbg_assert_(IOS_WIIMOTE, DoesChannelExist(scid)); SChannel& rChannel = m_Channel[scid]; u8 Buffer[1024]; @@ -610,9 +608,9 @@ void CWII_IPC_HLE_WiiMote::SendConfigurationRequest(u16 scid, u16 MTU, u16 Flush cr->flags = 0; Offset += sizeof(l2cap_cfg_req_cp); - DEBUG_LOG(WII_IPC_WIIMOTE, "[L2CAP] SendConfigurationRequest"); - DEBUG_LOG(WII_IPC_WIIMOTE, " Dcid: 0x%04x", cr->dcid); - DEBUG_LOG(WII_IPC_WIIMOTE, " Flags: 0x%04x", cr->flags); + DEBUG_LOG(IOS_WIIMOTE, "[L2CAP] SendConfigurationRequest"); + DEBUG_LOG(IOS_WIIMOTE, " Dcid: 0x%04x", cr->dcid); + DEBUG_LOG(IOS_WIIMOTE, " Flags: 0x%04x", cr->flags); l2cap_cfg_opt_t* pOptions; @@ -630,7 +628,7 @@ void CWII_IPC_HLE_WiiMote::SendConfigurationRequest(u16 scid, u16 MTU, u16 Flush pOptions->length = L2CAP_OPT_MTU_SIZE; *(u16*)&Buffer[Offset] = MTU; Offset += L2CAP_OPT_MTU_SIZE; - DEBUG_LOG(WII_IPC_WIIMOTE, " MTU: 0x%04x", MTU); + DEBUG_LOG(IOS_WIIMOTE, " MTU: 0x%04x", MTU); } if (FlushTimeOut || rChannel.FlushTimeOut) @@ -643,7 +641,7 @@ void CWII_IPC_HLE_WiiMote::SendConfigurationRequest(u16 scid, u16 MTU, u16 Flush pOptions->length = L2CAP_OPT_FLUSH_TIMO_SIZE; *(u16*)&Buffer[Offset] = FlushTimeOut; Offset += L2CAP_OPT_FLUSH_TIMO_SIZE; - DEBUG_LOG(WII_IPC_WIIMOTE, " FlushTimeOut: 0x%04x", FlushTimeOut); + DEBUG_LOG(IOS_WIIMOTE, " FlushTimeOut: 0x%04x", FlushTimeOut); } SendCommandToACL(L2CAP_CONFIG_REQ, L2CAP_CONFIG_REQ, Offset, Buffer); @@ -666,19 +664,19 @@ void CWII_IPC_HLE_WiiMote::SendConfigurationRequest(u16 scid, u16 MTU, u16 Flush #define SDP_SEQ8 0x35 #define SDP_SEQ16 0x36 -void CWII_IPC_HLE_WiiMote::SDPSendServiceSearchResponse(u16 cid, u16 TransactionID, - u8* pServiceSearchPattern, - u16 MaximumServiceRecordCount) +void WiimoteDevice::SDPSendServiceSearchResponse(u16 cid, u16 TransactionID, + u8* pServiceSearchPattern, + u16 MaximumServiceRecordCount) { // verify block... we handle search pattern for HID service only { CBigEndianBuffer buffer(pServiceSearchPattern); - _dbg_assert_(WII_IPC_WIIMOTE, buffer.Read8(0) == SDP_SEQ8); // data sequence - _dbg_assert_(WII_IPC_WIIMOTE, buffer.Read8(1) == 0x03); // sequence size + _dbg_assert_(IOS_WIIMOTE, buffer.Read8(0) == SDP_SEQ8); // data sequence + _dbg_assert_(IOS_WIIMOTE, buffer.Read8(1) == 0x03); // sequence size // HIDClassID - _dbg_assert_(WII_IPC_WIIMOTE, buffer.Read8(2) == 0x19); - _dbg_assert_(WII_IPC_WIIMOTE, buffer.Read16(3) == 0x1124); + _dbg_assert_(IOS_WIIMOTE, buffer.Read8(2) == 0x19); + _dbg_assert_(IOS_WIIMOTE, buffer.Read16(3) == 0x1124); } u8 DataFrame[1000]; @@ -723,7 +721,7 @@ static u32 ParseCont(u8* pCont) { return 0x00; } - ERROR_LOG(WII_IPC_WIIMOTE, "ParseCont: wrong cont: %i", typeID); + ERROR_LOG(IOS_WIIMOTE, "ParseCont: wrong cont: %i", typeID); PanicAlert("ParseCont: wrong cont: %i", typeID); return 0; } @@ -742,7 +740,7 @@ static int ParseAttribList(u8* pAttribIDList, u16& _startID, u16& _endID) if (MAX_LOGLEVEL >= LogTypes::LOG_LEVELS::LDEBUG) { - _dbg_assert_(WII_IPC_WIIMOTE, sequence == SDP_SEQ8); + _dbg_assert_(IOS_WIIMOTE, sequence == SDP_SEQ8); (void)seqSize; } @@ -758,26 +756,25 @@ static int ParseAttribList(u8* pAttribIDList, u16& _startID, u16& _endID) _startID = attribList.Read16(attribOffset); attribOffset += 2; _endID = _startID; - WARN_LOG(WII_IPC_WIIMOTE, "Read just a single attrib - not tested"); + WARN_LOG(IOS_WIIMOTE, "Read just a single attrib - not tested"); PanicAlert("Read just a single attrib - not tested"); } return attribOffset; } -void CWII_IPC_HLE_WiiMote::SDPSendServiceAttributeResponse(u16 cid, u16 TransactionID, - u32 ServiceHandle, u16 startAttrID, - u16 endAttrID, - u16 MaximumAttributeByteCount, - u8* pContinuationState) +void WiimoteDevice::SDPSendServiceAttributeResponse(u16 cid, u16 TransactionID, u32 ServiceHandle, + u16 startAttrID, u16 endAttrID, + u16 MaximumAttributeByteCount, + u8* pContinuationState) { if (ServiceHandle != 0x10000) { - ERROR_LOG(WII_IPC_WIIMOTE, "Unknown service handle %x", ServiceHandle); + ERROR_LOG(IOS_WIIMOTE, "Unknown service handle %x", ServiceHandle); PanicAlert("Unknown service handle %x", ServiceHandle); } - // _dbg_assert_(WII_IPC_WIIMOTE, ServiceHandle == 0x10000); + // _dbg_assert_(IOS_WIIMOTE, ServiceHandle == 0x10000); u32 contState = ParseCont(pContinuationState); @@ -808,7 +805,7 @@ void CWII_IPC_HLE_WiiMote::SDPSendServiceAttributeResponse(u16 cid, u16 Transact // "test response: "); } -void CWII_IPC_HLE_WiiMote::HandleSDP(u16 cid, u8* _pData, u32 _Size) +void WiimoteDevice::HandleSDP(u16 cid, u8* _pData, u32 _Size) { // Debugger::PrintDataBuffer(LogTypes::WIIMOTE, _pData, _Size, "HandleSDP: "); @@ -819,9 +816,9 @@ void CWII_IPC_HLE_WiiMote::HandleSDP(u16 cid, u8* _pData, u32 _Size) // SDP_ServiceSearchRequest case 0x02: { - WARN_LOG(WII_IPC_WIIMOTE, "!!! SDP_ServiceSearchRequest !!!"); + WARN_LOG(IOS_WIIMOTE, "!!! SDP_ServiceSearchRequest !!!"); - _dbg_assert_(WII_IPC_WIIMOTE, _Size == 13); + _dbg_assert_(IOS_WIIMOTE, _Size == 13); u16 TransactionID = buffer.Read16(1); u8* pServiceSearchPattern = buffer.GetPointer(5); @@ -835,7 +832,7 @@ void CWII_IPC_HLE_WiiMote::HandleSDP(u16 cid, u8* _pData, u32 _Size) // SDP_ServiceAttributeRequest case 0x04: { - WARN_LOG(WII_IPC_WIIMOTE, "!!! SDP_ServiceAttributeRequest !!!"); + WARN_LOG(IOS_WIIMOTE, "!!! SDP_ServiceAttributeRequest !!!"); u16 startAttrID, endAttrID; u32 offset = 1; @@ -857,7 +854,7 @@ void CWII_IPC_HLE_WiiMote::HandleSDP(u16 cid, u8* _pData, u32 _Size) break; default: - ERROR_LOG(WII_IPC_WIIMOTE, "WIIMOTE: Unknown SDP command %x", _pData[0]); + ERROR_LOG(IOS_WIIMOTE, "WIIMOTE: Unknown SDP command %x", _pData[0]); PanicAlert("WIIMOTE: Unknown SDP command %x", _pData[0]); break; } @@ -874,8 +871,7 @@ void CWII_IPC_HLE_WiiMote::HandleSDP(u16 cid, u8* _pData, u32 _Size) // // -void CWII_IPC_HLE_WiiMote::SendCommandToACL(u8 _Ident, u8 _Code, u8 _CommandLength, - u8* _pCommandData) +void WiimoteDevice::SendCommandToACL(u8 _Ident, u8 _Code, u8 _CommandLength, u8* _pCommandData) { u8 DataFrame[1024]; u32 Offset = 0; @@ -893,9 +889,9 @@ void CWII_IPC_HLE_WiiMote::SendCommandToACL(u8 _Ident, u8 _Code, u8 _CommandLeng memcpy(&DataFrame[Offset], _pCommandData, _CommandLength); - DEBUG_LOG(WII_IPC_WIIMOTE, "Send ACL Command to CPU"); - DEBUG_LOG(WII_IPC_WIIMOTE, " Ident: 0x%02x", _Ident); - DEBUG_LOG(WII_IPC_WIIMOTE, " Code: 0x%02x", _Code); + DEBUG_LOG(IOS_WIIMOTE, "Send ACL Command to CPU"); + DEBUG_LOG(IOS_WIIMOTE, " Ident: 0x%02x", _Ident); + DEBUG_LOG(IOS_WIIMOTE, " Code: 0x%02x", _Code); // send .... m_pHost->SendACLPacket(GetConnectionHandle(), DataFrame, pHeader->length + sizeof(l2cap_hdr_t)); @@ -904,7 +900,7 @@ void CWII_IPC_HLE_WiiMote::SendCommandToACL(u8 _Ident, u8 _Code, u8 _CommandLeng // "m_pHost->SendACLPacket: "); } -void CWII_IPC_HLE_WiiMote::ReceiveL2capData(u16 scid, const void* _pData, u32 _Size) +void WiimoteDevice::ReceiveL2capData(u16 scid, const void* _pData, u32 _Size) { // Allocate DataFrame u8 DataFrame[1024]; @@ -913,7 +909,7 @@ void CWII_IPC_HLE_WiiMote::ReceiveL2capData(u16 scid, const void* _pData, u32 _S Offset += sizeof(l2cap_hdr_t); // Check if we are already reporting on this channel - _dbg_assert_(WII_IPC_WIIMOTE, DoesChannelExist(scid)); + _dbg_assert_(IOS_WIIMOTE, DoesChannelExist(scid)); SChannel& rChannel = m_Channel[scid]; // Add an additional 4 byte header to the Wiimote report diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_WiiMote.h b/Source/Core/Core/IOS/USB/Bluetooth/WiimoteDevice.h similarity index 90% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_WiiMote.h rename to Source/Core/Core/IOS/USB/Bluetooth/WiimoteDevice.h index 66e5d46428..c7e1066d5f 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_WiiMote.h +++ b/Source/Core/Core/IOS/USB/Bluetooth/WiimoteDevice.h @@ -10,7 +10,7 @@ #include "Common/CommonFuncs.h" #include "Common/CommonTypes.h" -#include "Core/IPC_HLE/hci.h" +#include "Core/IOS/USB/Bluetooth/hci.h" class PointerWrap; @@ -18,10 +18,13 @@ namespace IOS { namespace HLE { -class CWII_IPC_HLE_Device_usb_oh1_57e_305_emu; +namespace Device +{ +class BluetoothEmu; +} -CWII_IPC_HLE_Device_usb_oh1_57e_305_emu* GetUsbPointer(); -void SetUsbPointer(CWII_IPC_HLE_Device_usb_oh1_57e_305_emu* ptr); +Device::BluetoothEmu* GetUsbPointer(); +void SetUsbPointer(Device::BluetoothEmu* ptr); class CBigEndianBuffer { @@ -38,13 +41,11 @@ private: u8* m_pBuffer; }; -class CWII_IPC_HLE_WiiMote +class WiimoteDevice { public: - CWII_IPC_HLE_WiiMote(CWII_IPC_HLE_Device_usb_oh1_57e_305_emu* _pHost, int _Number, bdaddr_t _BD, - bool ready = false); + WiimoteDevice(Device::BluetoothEmu* _pHost, int _Number, bdaddr_t _BD, bool ready = false); - virtual ~CWII_IPC_HLE_WiiMote() {} void DoState(PointerWrap& p); // ugly Host handling.... @@ -99,7 +100,7 @@ private: u16 lmp_subversion; u8 m_LinkKey[HCI_KEY_SIZE]; std::string m_Name; - CWII_IPC_HLE_Device_usb_oh1_57e_305_emu* m_pHost; + Device::BluetoothEmu* m_pHost; struct SChannel { diff --git a/Source/Core/Core/IPC_HLE/WiiMote_HID_Attr.cpp b/Source/Core/Core/IOS/USB/Bluetooth/WiimoteHIDAttr.cpp similarity index 97% rename from Source/Core/Core/IPC_HLE/WiiMote_HID_Attr.cpp rename to Source/Core/Core/IOS/USB/Bluetooth/WiimoteHIDAttr.cpp index f210cda351..7d25836560 100644 --- a/Source/Core/Core/IPC_HLE/WiiMote_HID_Attr.cpp +++ b/Source/Core/Core/IOS/USB/Bluetooth/WiimoteHIDAttr.cpp @@ -2,7 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include "Core/IPC_HLE/WiiMote_HID_Attr.h" +#include "Core/IOS/USB/Bluetooth/WiimoteHIDAttr.h" #include "Common/Assert.h" #include "Common/CommonTypes.h" @@ -93,7 +93,7 @@ const u8* GetAttribPacket(u32 serviceHandle, u32 cont, u32& _size) if (serviceHandle == 0x10001) { - _dbg_assert_(WII_IPC_WIIMOTE, cont == 0x00); + _dbg_assert_(IOS_WIIMOTE, cont == 0x00); _size = sizeof(packet4_0x10001); return packet4_0x10001; } diff --git a/Source/Core/Core/IPC_HLE/WiiMote_HID_Attr.h b/Source/Core/Core/IOS/USB/Bluetooth/WiimoteHIDAttr.h similarity index 100% rename from Source/Core/Core/IPC_HLE/WiiMote_HID_Attr.h rename to Source/Core/Core/IOS/USB/Bluetooth/WiimoteHIDAttr.h diff --git a/Source/Core/Core/IPC_HLE/hci.h b/Source/Core/Core/IOS/USB/Bluetooth/hci.h similarity index 100% rename from Source/Core/Core/IPC_HLE/hci.h rename to Source/Core/Core/IOS/USB/Bluetooth/hci.h diff --git a/Source/Core/Core/IPC_HLE/l2cap.h b/Source/Core/Core/IOS/USB/Bluetooth/l2cap.h similarity index 100% rename from Source/Core/Core/IPC_HLE/l2cap.h rename to Source/Core/Core/IOS/USB/Bluetooth/l2cap.h diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_hid.cpp b/Source/Core/Core/IOS/USB/USB_HIDv4.cpp similarity index 79% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_hid.cpp rename to Source/Core/Core/IOS/USB/USB_HIDv4.cpp index aa1f6206c3..f3492a4f77 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_hid.cpp +++ b/Source/Core/Core/IOS/USB/USB_HIDv4.cpp @@ -17,18 +17,20 @@ #include "Core/CoreTiming.h" #include "Core/Debugger/Debugger_SymbolMap.h" #include "Core/HW/Memmap.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_hid.h" +#include "Core/IOS/IPC.h" +#include "Core/IOS/USB/USB_HIDv4.h" namespace IOS { namespace HLE { -#define MAX_DEVICE_DEVNUM 256 +namespace Device +{ +constexpr int MAX_DEVICE_DEVNUM = 256; static u64 hidDeviceAliases[MAX_DEVICE_DEVNUM]; // Regular thread -void CWII_IPC_HLE_Device_hid::checkUsbUpdates(CWII_IPC_HLE_Device_hid* hid) +void USB_HIDv4::checkUsbUpdates(USB_HIDv4* hid) { timeval tv; tv.tv_sec = 0; @@ -54,7 +56,7 @@ void CWII_IPC_HLE_Device_hid::checkUsbUpdates(CWII_IPC_HLE_Device_hid* hid) return; } -void CWII_IPC_HLE_Device_hid::handleUsbUpdates(struct libusb_transfer* transfer) +void USB_HIDv4::handleUsbUpdates(struct libusb_transfer* transfer) { s32 ret = IPC_EINVAL; u32 replyAddress = (u32)(size_t)transfer->user_data; @@ -67,15 +69,14 @@ void CWII_IPC_HLE_Device_hid::handleUsbUpdates(struct libusb_transfer* transfer) EnqueueReply(request, ret, 0, CoreTiming::FromThread::NON_CPU); } -CWII_IPC_HLE_Device_hid::CWII_IPC_HLE_Device_hid(u32 _DeviceID, const std::string& _rDeviceName) - : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) +USB_HIDv4::USB_HIDv4(u32 device_id, const std::string& device_name) : Device(device_id, device_name) { deviceCommandAddress = 0; memset(hidDeviceAliases, 0, sizeof(hidDeviceAliases)); int ret = libusb_init(nullptr); if (ret) { - ERROR_LOG(WII_IPC_HID, "libusb_init failed with error: %d", ret); + ERROR_LOG(IOS_HID, "libusb_init failed with error: %d", ret); } else { @@ -84,7 +85,7 @@ CWII_IPC_HLE_Device_hid::CWII_IPC_HLE_Device_hid(u32 _DeviceID, const std::strin } } -CWII_IPC_HLE_Device_hid::~CWII_IPC_HLE_Device_hid() +USB_HIDv4::~USB_HIDv4() { bool deinit_libusb = false; if (usb_thread_running) @@ -104,7 +105,7 @@ CWII_IPC_HLE_Device_hid::~CWII_IPC_HLE_Device_hid() libusb_exit(nullptr); } -IPCCommandResult CWII_IPC_HLE_Device_hid::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult USB_HIDv4::IOCtl(const IOSIOCtlRequest& request) { if (Core::g_want_determinism) { @@ -157,7 +158,7 @@ IPCCommandResult CWII_IPC_HLE_Device_hid::IOCtl(const IOSIOCtlRequest& request) if (dev_handle == nullptr) { - INFO_LOG(WII_IPC_HID, "Could not find handle: %X", dev_num); + INFO_LOG(IOS_HID, "Could not find handle: %X", dev_num); break; } struct libusb_transfer* transfer = libusb_alloc_transfer(0); @@ -170,7 +171,7 @@ IPCCommandResult CWII_IPC_HLE_Device_hid::IOCtl(const IOSIOCtlRequest& request) (void*)(size_t)request.address, /* no timeout */ 0); libusb_submit_transfer(transfer); - // DEBUG_LOG(WII_IPC_HID, "HID::IOCtl(Control)(%02X, %02X) (BufferIn: (%08x, %i), + // DEBUG_LOG(IOS_HID, "HID::IOCtl(Control)(%02X, %02X) (BufferIn: (%08x, %i), // request.buffer_out: // (%08x, %i)", // bmRequestType, bRequest, BufferIn, request.buffer_in_size, request.buffer_out, @@ -194,7 +195,7 @@ IPCCommandResult CWII_IPC_HLE_Device_hid::IOCtl(const IOSIOCtlRequest& request) if (dev_handle == nullptr) { - INFO_LOG(WII_IPC_HID, "Could not find handle: %X", dev_num); + INFO_LOG(IOS_HID, "Could not find handle: %X", dev_num); break; } @@ -217,53 +218,53 @@ IPCCommandResult CWII_IPC_HLE_Device_hid::IOCtl(const IOSIOCtlRequest& request) EnqueueReply(pending_request, -1); deviceCommandAddress = 0; } - INFO_LOG(WII_IPC_HID, "HID::IOCtl(Shutdown) (BufferIn: (%08x, %i), BufferOut: (%08x, %i)", + INFO_LOG(IOS_HID, "HID::IOCtl(Shutdown) (BufferIn: (%08x, %i), BufferOut: (%08x, %i)", request.buffer_in, request.buffer_in_size, request.buffer_out, request.buffer_out_size); break; } default: - request.Log(GetDeviceName(), LogTypes::WII_IPC_HID); + request.Log(GetDeviceName(), LogTypes::IOS_HID); } return GetDefaultReply(return_value); } -bool CWII_IPC_HLE_Device_hid::ClaimDevice(libusb_device_handle* dev) +bool USB_HIDv4::ClaimDevice(libusb_device_handle* dev) { int ret = 0; if ((ret = libusb_kernel_driver_active(dev, 0)) == 1) { if ((ret = libusb_detach_kernel_driver(dev, 0)) && ret != LIBUSB_ERROR_NOT_SUPPORTED) { - ERROR_LOG(WII_IPC_HID, "libusb_detach_kernel_driver failed with error: %d", ret); + ERROR_LOG(IOS_HID, "libusb_detach_kernel_driver failed with error: %d", ret); return false; } } else if (ret != 0 && ret != LIBUSB_ERROR_NOT_SUPPORTED) { - ERROR_LOG(WII_IPC_HID, "libusb_kernel_driver_active error ret = %d", ret); + ERROR_LOG(IOS_HID, "libusb_kernel_driver_active error ret = %d", ret); return false; } if ((ret = libusb_claim_interface(dev, 0))) { - ERROR_LOG(WII_IPC_HID, "libusb_claim_interface failed with error: %d", ret); + ERROR_LOG(IOS_HID, "libusb_claim_interface failed with error: %d", ret); return false; } return true; } -IPCCommandResult CWII_IPC_HLE_Device_hid::IOCtlV(const IOSIOCtlVRequest& request) +IPCCommandResult USB_HIDv4::IOCtlV(const IOSIOCtlVRequest& request) { - Dolphin_Debugger::PrintCallstack(LogTypes::WII_IPC_HID, LogTypes::LWARNING); - request.DumpUnknown(GetDeviceName(), LogTypes::WII_IPC_HID); + Dolphin_Debugger::PrintCallstack(LogTypes::IOS_HID, LogTypes::LWARNING); + request.DumpUnknown(GetDeviceName(), LogTypes::IOS_HID); return GetDefaultReply(IPC_SUCCESS); } -void CWII_IPC_HLE_Device_hid::ConvertDeviceToWii(WiiHIDDeviceDescriptor* dest, - const struct libusb_device_descriptor* src) +void USB_HIDv4::ConvertDeviceToWii(WiiHIDDeviceDescriptor* dest, + const struct libusb_device_descriptor* src) { dest->bLength = src->bLength; dest->bDescriptorType = src->bDescriptorType; @@ -281,27 +282,27 @@ void CWII_IPC_HLE_Device_hid::ConvertDeviceToWii(WiiHIDDeviceDescriptor* dest, dest->bNumConfigurations = src->bNumConfigurations; } -void CWII_IPC_HLE_Device_hid::ConvertConfigToWii(WiiHIDConfigDescriptor* dest, - const struct libusb_config_descriptor* src) +void USB_HIDv4::ConvertConfigToWii(WiiHIDConfigDescriptor* dest, + const struct libusb_config_descriptor* src) { memcpy(dest, src, sizeof(WiiHIDConfigDescriptor)); dest->wTotalLength = Common::swap16(dest->wTotalLength); } -void CWII_IPC_HLE_Device_hid::ConvertInterfaceToWii(WiiHIDInterfaceDescriptor* dest, - const struct libusb_interface_descriptor* src) +void USB_HIDv4::ConvertInterfaceToWii(WiiHIDInterfaceDescriptor* dest, + const struct libusb_interface_descriptor* src) { memcpy(dest, src, sizeof(WiiHIDInterfaceDescriptor)); } -void CWII_IPC_HLE_Device_hid::ConvertEndpointToWii(WiiHIDEndpointDescriptor* dest, - const struct libusb_endpoint_descriptor* src) +void USB_HIDv4::ConvertEndpointToWii(WiiHIDEndpointDescriptor* dest, + const struct libusb_endpoint_descriptor* src) { memcpy(dest, src, sizeof(WiiHIDEndpointDescriptor)); dest->wMaxPacketSize = Common::swap16(dest->wMaxPacketSize); } -void CWII_IPC_HLE_Device_hid::FillOutDevices(const IOSIOCtlRequest& request) +void USB_HIDv4::FillOutDevices(const IOSIOCtlRequest& request) { static u16 check = 1; int OffsetBuffer = request.buffer_out; @@ -312,7 +313,7 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(const IOSIOCtlRequest& request) libusb_device** list; // libusb_device *found = nullptr; ssize_t cnt = libusb_get_device_list(nullptr, &list); - INFO_LOG(WII_IPC_HID, "Found %ld viable USB devices.", cnt); + INFO_LOG(IOS_HID, "Found %ld viable USB devices.", cnt); for (d = 0; d < cnt; d++) { libusb_device* device = list[d]; @@ -321,7 +322,7 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(const IOSIOCtlRequest& request) if (dRet) { // could not aquire the descriptor, no point in trying to use it. - WARN_LOG(WII_IPC_HID, "libusb_get_device_descriptor failed with error: %d", dRet); + WARN_LOG(IOS_HID, "libusb_get_device_descriptor failed with error: %d", dRet); continue; } OffsetStart = OffsetBuffer; @@ -383,7 +384,7 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(const IOSIOCtlRequest& request) else { if (cRet) - WARN_LOG(WII_IPC_HID, "libusb_get_config_descriptor failed with: %d", cRet); + WARN_LOG(IOS_HID, "libusb_get_config_descriptor failed with: %d", cRet); deviceValid = false; OffsetBuffer = OffsetStart; } @@ -404,13 +405,12 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(const IOSIOCtlRequest& request) if (devNum < 0) { // too many devices to handle. - ERROR_LOG(WII_IPC_HID, - "Exhausted device list, there are way too many usb devices plugged in."); + ERROR_LOG(IOS_HID, "Exhausted device list, there are way too many usb devices plugged in."); OffsetBuffer = OffsetStart; continue; } - INFO_LOG(WII_IPC_HID, "Found device with Vendor: %X Product: %X Devnum: %d", desc.idVendor, + INFO_LOG(IOS_HID, "Found device with Vendor: %X Product: %X Devnum: %d", desc.idVendor, desc.idProduct, devNum); Memory::Write_U32(devNum, OffsetStart + 4); // write device num @@ -423,7 +423,7 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(const IOSIOCtlRequest& request) u16 check_cur = (u16)(hidDeviceAliases[i] >> 48); if (hidDeviceAliases[i] != 0 && check_cur != check) { - INFO_LOG(WII_IPC_HID, "Removing: device %d %hX %hX", i, check, check_cur); + INFO_LOG(IOS_HID, "Removing: device %d %hX %hX", i, check, check_cur); std::lock_guard lk(m_open_devices_mutex); if (m_open_devices.find(i) != m_open_devices.end()) { @@ -441,7 +441,7 @@ void CWII_IPC_HLE_Device_hid::FillOutDevices(const IOSIOCtlRequest& request) Memory::Write_U32(0xFFFFFFFF, OffsetBuffer); // no more devices } -libusb_device_handle* CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum) +libusb_device_handle* USB_HIDv4::GetDeviceByDevNum(u32 devNum) { libusb_device** list; libusb_device_handle* handle = nullptr; @@ -493,14 +493,14 @@ libusb_device_handle* CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum) { if (dRet) { - ERROR_LOG(WII_IPC_HID, "Dolphin does not have access to this device: Bus %03d Device " - "%03d: ID ????:???? (couldn't get id).", + ERROR_LOG(IOS_HID, "Dolphin does not have access to this device: Bus %03d Device " + "%03d: ID ????:???? (couldn't get id).", bus, port); } else { ERROR_LOG( - WII_IPC_HID, + IOS_HID, "Dolphin does not have access to this device: Bus %03d Device %03d: ID %04X:%04X.", bus, port, desc.idVendor, desc.idProduct); } @@ -512,21 +512,21 @@ libusb_device_handle* CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum) { // Max of one warning. has_warned_about_drivers = true; - WARN_LOG(WII_IPC_HID, "Please install the libusb drivers for the device %04X:%04X", + WARN_LOG(IOS_HID, "Please install the libusb drivers for the device %04X:%04X", desc.idVendor, desc.idProduct); } } #endif else { - ERROR_LOG(WII_IPC_HID, "libusb_open failed to open device with error = %d", ret); + ERROR_LOG(IOS_HID, "libusb_open failed to open device with error = %d", ret); } continue; } if (!ClaimDevice(handle)) { - ERROR_LOG(WII_IPC_HID, "Could not claim the device for handle: %X", devNum); + ERROR_LOG(IOS_HID, "Could not claim the device for handle: %X", devNum); libusb_close(handle); continue; } @@ -545,8 +545,7 @@ libusb_device_handle* CWII_IPC_HLE_Device_hid::GetDeviceByDevNum(u32 devNum) return handle; } -int CWII_IPC_HLE_Device_hid::GetAvailableDevNum(u16 idVendor, u16 idProduct, u8 bus, u8 port, - u16 check) +int USB_HIDv4::GetAvailableDevNum(u16 idVendor, u16 idProduct, u8 bus, u8 port, u16 check) { int pos = -1; u64 unique_id = ((u64)idVendor << 32) | ((u64)idProduct << 16) | ((u64)bus << 8) | (u64)port; @@ -573,5 +572,6 @@ int CWII_IPC_HLE_Device_hid::GetAvailableDevNum(u16 idVendor, u16 idProduct, u8 return -1; } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_hid.h b/Source/Core/Core/IOS/USB/USB_HIDv4.h similarity index 91% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_hid.h rename to Source/Core/Core/IOS/USB/USB_HIDv4.h index 3b74d7b55f..588fa7987a 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_hid.h +++ b/Source/Core/Core/IOS/USB/USB_HIDv4.h @@ -11,8 +11,8 @@ #include #include "Common/CommonTypes.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device.h" +#include "Core/IOS/Device.h" +#include "Core/IOS/IPC.h" // Forward declare things which we need from libusb header. // This prevents users of this file from indirectly pulling in libusb. @@ -35,12 +35,14 @@ namespace HLE #define HID_ID_MASK 0x0000FFFFFFFFFFFF #define MAX_HID_INTERFACES 1 -class CWII_IPC_HLE_Device_hid : public IWII_IPC_HLE_Device +namespace Device +{ +class USB_HIDv4 : public Device { public: - CWII_IPC_HLE_Device_hid(u32 _DeviceID, const std::string& _rDeviceName); + USB_HIDv4(u32 _DeviceID, const std::string& _rDeviceName); - virtual ~CWII_IPC_HLE_Device_hid(); + virtual ~USB_HIDv4(); IPCCommandResult IOCtlV(const IOSIOCtlVRequest& request) override; IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override; @@ -129,7 +131,7 @@ private: const libusb_interface_descriptor* src); void ConvertEndpointToWii(WiiHIDEndpointDescriptor* dest, const libusb_endpoint_descriptor* src); - static void checkUsbUpdates(CWII_IPC_HLE_Device_hid* hid); + static void checkUsbUpdates(USB_HIDv4* hid); static void LIBUSB_CALL handleUsbUpdates(libusb_transfer* transfer); libusb_device_handle* GetDeviceByDevNum(u32 devNum); @@ -140,5 +142,6 @@ private: std::thread usb_thread; bool usb_thread_running; }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_kbd.cpp b/Source/Core/Core/IOS/USB/USB_KBD.cpp similarity index 89% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_kbd.cpp rename to Source/Core/Core/IOS/USB/USB_KBD.cpp index 69d377fb65..5f35a3bc39 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_kbd.cpp +++ b/Source/Core/Core/IOS/USB/USB_KBD.cpp @@ -11,7 +11,7 @@ #include "Core/ConfigManager.h" #include "Core/Core.h" // Local core functions #include "Core/HW/Memmap.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_kbd.h" +#include "Core/IOS/USB/USB_KBD.h" #ifdef _WIN32 #include @@ -21,7 +21,9 @@ namespace IOS { namespace HLE { -CWII_IPC_HLE_Device_usb_kbd::SMessageData::SMessageData(u32 type, u8 modifiers, u8* pressed_keys) +namespace Device +{ +USB_KBD::SMessageData::SMessageData(u32 type, u8 modifiers, u8* pressed_keys) { MsgType = Common::swap32(type); Unk1 = 0; // swapped @@ -36,15 +38,13 @@ CWII_IPC_HLE_Device_usb_kbd::SMessageData::SMessageData(u32 type, u8 modifiers, // TODO: support in netplay/movies. -CWII_IPC_HLE_Device_usb_kbd::CWII_IPC_HLE_Device_usb_kbd(u32 _DeviceID, - const std::string& _rDeviceName) - : IWII_IPC_HLE_Device(_DeviceID, _rDeviceName) +USB_KBD::USB_KBD(u32 device_id, const std::string& device_name) : Device(device_id, device_name) { } -IOSReturnCode CWII_IPC_HLE_Device_usb_kbd::Open(const IOSOpenRequest& request) +IOSReturnCode USB_KBD::Open(const IOSOpenRequest& request) { - INFO_LOG(WII_IPC_HLE, "CWII_IPC_HLE_Device_usb_kbd: Open"); + INFO_LOG(IOS, "USB_KBD: Open"); IniFile ini; ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)); ini.GetOrCreateSection("USB Keyboard")->Get("Layout", &m_KeyboardLayout, KBD_LAYOUT_QWERTY); @@ -62,7 +62,7 @@ IOSReturnCode CWII_IPC_HLE_Device_usb_kbd::Open(const IOSOpenRequest& request) return IPC_SUCCESS; } -IPCCommandResult CWII_IPC_HLE_Device_usb_kbd::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult USB_KBD::IOCtl(const IOSIOCtlRequest& request) { if (SConfig::GetInstance().m_WiiKeyboard && !Core::g_want_determinism && !m_MessageQueue.empty()) { @@ -72,7 +72,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_kbd::IOCtl(const IOSIOCtlRequest& reque return GetDefaultReply(IPC_SUCCESS); } -bool CWII_IPC_HLE_Device_usb_kbd::IsKeyPressed(int _Key) +bool USB_KBD::IsKeyPressed(int _Key) { #ifdef _WIN32 if (GetAsyncKeyState(_Key) & 0x8000) @@ -85,7 +85,7 @@ bool CWII_IPC_HLE_Device_usb_kbd::IsKeyPressed(int _Key) #endif } -void CWII_IPC_HLE_Device_usb_kbd::Update() +void USB_KBD::Update() { if (!SConfig::GetInstance().m_WiiKeyboard || Core::g_want_determinism || !m_is_active) return; @@ -165,7 +165,7 @@ void CWII_IPC_HLE_Device_usb_kbd::Update() // Crazy ugly #ifdef _WIN32 -u8 CWII_IPC_HLE_Device_usb_kbd::m_KeyCodesQWERTY[256] = { +u8 USB_KBD::m_KeyCodesQWERTY[256] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2A, // Backspace @@ -239,7 +239,7 @@ u8 CWII_IPC_HLE_Device_usb_kbd::m_KeyCodesQWERTY[256] = { }; -u8 CWII_IPC_HLE_Device_usb_kbd::m_KeyCodesAZERTY[256] = { +u8 USB_KBD::m_KeyCodesAZERTY[256] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2A, // Backspace @@ -313,9 +313,10 @@ u8 CWII_IPC_HLE_Device_usb_kbd::m_KeyCodesAZERTY[256] = { }; #else -u8 CWII_IPC_HLE_Device_usb_kbd::m_KeyCodesQWERTY[256] = {0}; +u8 USB_KBD::m_KeyCodesQWERTY[256] = {0}; -u8 CWII_IPC_HLE_Device_usb_kbd::m_KeyCodesAZERTY[256] = {0}; +u8 USB_KBD::m_KeyCodesAZERTY[256] = {0}; #endif +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_kbd.h b/Source/Core/Core/IOS/USB/USB_KBD.h similarity index 82% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_kbd.h rename to Source/Core/Core/IOS/USB/USB_KBD.h index 76ad64a260..eb4849446d 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_kbd.h +++ b/Source/Core/Core/IOS/USB/USB_KBD.h @@ -8,17 +8,19 @@ #include #include "Common/CommonTypes.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device.h" +#include "Core/IOS/Device.h" +#include "Core/IOS/IPC.h" namespace IOS { namespace HLE { -class CWII_IPC_HLE_Device_usb_kbd : public IWII_IPC_HLE_Device +namespace Device +{ +class USB_KBD : public Device { public: - CWII_IPC_HLE_Device_usb_kbd(u32 _DeviceID, const std::string& _rDeviceName); + USB_KBD(u32 device_id, const std::string& device_name); IOSReturnCode Open(const IOSOpenRequest& request) override; IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override; @@ -61,5 +63,6 @@ private: static u8 m_KeyCodesQWERTY[256]; static u8 m_KeyCodesAZERTY[256]; }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_ven.cpp b/Source/Core/Core/IOS/USB/USB_VEN.cpp similarity index 78% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_ven.cpp rename to Source/Core/Core/IOS/USB/USB_VEN.cpp index ec41fa8c35..61eb50ed71 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_ven.cpp +++ b/Source/Core/Core/IOS/USB/USB_VEN.cpp @@ -2,7 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_ven.h" +#include "Core/IOS/USB/USB_VEN.h" #include "Common/Logging/Log.h" #include "Core/HW/Memmap.h" @@ -10,19 +10,19 @@ namespace IOS { namespace HLE { -CWII_IPC_HLE_Device_usb_ven::CWII_IPC_HLE_Device_usb_ven(const u32 device_id, - const std::string& device_name) - : IWII_IPC_HLE_Device(device_id, device_name) +namespace Device +{ +USB_VEN::USB_VEN(u32 device_id, const std::string& device_name) : Device(device_id, device_name) { } -IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtlV(const IOSIOCtlVRequest& request) +IPCCommandResult USB_VEN::IOCtlV(const IOSIOCtlVRequest& request) { request.Dump(GetDeviceName()); return GetNoReply(); } -IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult USB_VEN::IOCtl(const IOSIOCtlRequest& request) { request.Log(GetDeviceName(), LogTypes::OSHLE); @@ -78,5 +78,6 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_ven::IOCtl(const IOSIOCtlRequest& reque } return reply; } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_ven.h b/Source/Core/Core/IOS/USB/USB_VEN.h similarity index 78% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_ven.h rename to Source/Core/Core/IOS/USB/USB_VEN.h index e74554e328..6e3e7019df 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_ven.h +++ b/Source/Core/Core/IOS/USB/USB_VEN.h @@ -7,17 +7,19 @@ #include #include "Common/CommonTypes.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device.h" +#include "Core/IOS/Device.h" +#include "Core/IOS/IPC.h" namespace IOS { namespace HLE { -class CWII_IPC_HLE_Device_usb_ven final : public IWII_IPC_HLE_Device +namespace Device +{ +class USB_VEN final : public Device { public: - CWII_IPC_HLE_Device_usb_ven(u32 device_id, const std::string& device_name); + USB_VEN(u32 device_id, const std::string& device_name); IPCCommandResult IOCtlV(const IOSIOCtlVRequest& request) override; IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override; @@ -39,5 +41,6 @@ private: USBV5_IOCTL_BULKMSG = 21 }; }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_wfsi.cpp b/Source/Core/Core/IOS/WFS/WFSI.cpp similarity index 80% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_wfsi.cpp rename to Source/Core/Core/IOS/WFS/WFSI.cpp index 22b563cf38..641e43d5f3 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_wfsi.cpp +++ b/Source/Core/Core/IOS/WFS/WFSI.cpp @@ -2,7 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include "Core/IPC_HLE/WII_IPC_HLE_Device_wfsi.h" +#include "Core/IOS/WFS/WFSI.h" #include #include @@ -14,8 +14,8 @@ #include "Common/FileUtil.h" #include "Common/Logging/Log.h" #include "Core/HW/Memmap.h" -#include "Core/IPC_HLE/ESFormats.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_wfssrv.h" +#include "Core/IOS/ES/Formats.h" +#include "Core/IOS/WFS/WFSSRV.h" #include "DiscIO/NANDContentLoader.h" namespace IOS @@ -37,7 +37,7 @@ void ARCUnpacker::Extract(const WriteCallback& callback) u32 fourcc = Common::swap32(m_whole_file.data()); if (fourcc != 0x55AA382D) { - ERROR_LOG(WII_IPC_HLE, "ARCUnpacker: invalid fourcc (%08x)", fourcc); + ERROR_LOG(IOS, "ARCUnpacker: invalid fourcc (%08x)", fourcc); return; } @@ -78,12 +78,13 @@ void ARCUnpacker::Extract(const WriteCallback& callback) } } -CWII_IPC_HLE_Device_wfsi::CWII_IPC_HLE_Device_wfsi(u32 device_id, const std::string& device_name) - : IWII_IPC_HLE_Device(device_id, device_name) +namespace Device +{ +WFSI::WFSI(u32 device_id, const std::string& device_name) : Device(device_id, device_name) { } -IPCCommandResult CWII_IPC_HLE_Device_wfsi::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult WFSI::IOCtl(const IOSIOCtlRequest& request) { u32 return_error_code = IPC_SUCCESS; @@ -94,12 +95,12 @@ IPCCommandResult CWII_IPC_HLE_Device_wfsi::IOCtl(const IOSIOCtlRequest& request) u32 tmd_addr = Memory::Read_U32(request.buffer_in); u32 tmd_size = Memory::Read_U32(request.buffer_in + 4); - INFO_LOG(WII_IPC_HLE, "IOCTL_WFSI_PREPARE_DEVICE"); + INFO_LOG(IOS, "IOCTL_WFSI_PREPARE_DEVICE"); constexpr u32 MAX_TMD_SIZE = 0x4000; if (tmd_size > MAX_TMD_SIZE) { - ERROR_LOG(WII_IPC_HLE, "IOCTL_WFSI_INIT: TMD size too large (%d)", tmd_size); + ERROR_LOG(IOS, "IOCTL_WFSI_INIT: TMD size too large (%d)", tmd_size); return_error_code = IPC_EINVAL; break; } @@ -136,7 +137,7 @@ IPCCommandResult CWII_IPC_HLE_Device_wfsi::IOCtl(const IOSIOCtlRequest& request) TMDReader::Content content_info; if (!m_tmd.FindContentById(content_id, &content_info)) { - WARN_LOG(WII_IPC_HLE, "%s: Content id %08x not found", ioctl_name, content_id); + WARN_LOG(IOS, "%s: Content id %08x not found", ioctl_name, content_id); return_error_code = -10003; break; } @@ -144,7 +145,7 @@ IPCCommandResult CWII_IPC_HLE_Device_wfsi::IOCtl(const IOSIOCtlRequest& request) memset(m_aes_iv, 0, sizeof(m_aes_iv)); m_aes_iv[0] = content_info.index >> 8; m_aes_iv[1] = content_info.index & 0xFF; - INFO_LOG(WII_IPC_HLE, "%s: Content id %08x found at index %d", ioctl_name, content_id, + INFO_LOG(IOS, "%s: Content id %08x found at index %d", ioctl_name, content_id, content_info.index); m_arc_unpacker.Reset(); @@ -161,8 +162,8 @@ IPCCommandResult CWII_IPC_HLE_Device_wfsi::IOCtl(const IOSIOCtlRequest& request) u32 content_id = Memory::Read_U32(request.buffer_in + 0xC); u32 input_ptr = Memory::Read_U32(request.buffer_in + 0x10); u32 input_size = Memory::Read_U32(request.buffer_in + 0x14); - INFO_LOG(WII_IPC_HLE, "%s: %08x bytes of data at %08x from content id %d", ioctl_name, - content_id, input_ptr, input_size); + INFO_LOG(IOS, "%s: %08x bytes of data at %08x from content id %d", ioctl_name, content_id, + input_ptr, input_size); std::vector decrypted(input_size); mbedtls_aes_crypt_cbc(&m_aes_ctx, MBEDTLS_AES_DECRYPT, input_size, m_aes_iv, @@ -178,17 +179,17 @@ IPCCommandResult CWII_IPC_HLE_Device_wfsi::IOCtl(const IOSIOCtlRequest& request) const char* ioctl_name = request.request == IOCTL_WFSI_FINALIZE_PROFILE ? "IOCTL_WFSI_FINALIZE_PROFILE" : "IOCTL_WFSI_FINALIZE_CONTENT"; - INFO_LOG(WII_IPC_HLE, "%s", ioctl_name); + INFO_LOG(IOS, "%s", ioctl_name); auto callback = [this](const std::string& filename, const std::vector& bytes) { - INFO_LOG(WII_IPC_HLE, "Extract: %s (%zd bytes)", filename.c_str(), bytes.size()); + INFO_LOG(IOS, "Extract: %s (%zd bytes)", filename.c_str(), bytes.size()); std::string path = WFS::NativePath(m_base_extract_path + "/" + filename); File::CreateFullPath(path); File::IOFile f(path, "wb"); if (!f) { - ERROR_LOG(WII_IPC_HLE, "Could not extract %s to %s", filename.c_str(), path.c_str()); + ERROR_LOG(IOS, "Could not extract %s to %s", filename.c_str(), path.c_str()); return; } f.WriteBytes(bytes.data(), bytes.size()); @@ -205,25 +206,25 @@ IPCCommandResult CWII_IPC_HLE_Device_wfsi::IOCtl(const IOSIOCtlRequest& request) // Bytes 0-4: ?? // Bytes 4-8: game id // Bytes 1c-1e: title id? - WARN_LOG(WII_IPC_HLE, "IOCTL_WFSI_DELETE_TITLE: unimplemented"); + WARN_LOG(IOS, "IOCTL_WFSI_DELETE_TITLE: unimplemented"); break; case IOCTL_WFSI_IMPORT_TITLE: - WARN_LOG(WII_IPC_HLE, "IOCTL_WFSI_IMPORT_TITLE: unimplemented"); + WARN_LOG(IOS, "IOCTL_WFSI_IMPORT_TITLE: unimplemented"); break; case IOCTL_WFSI_INIT: // Nothing to do. - INFO_LOG(WII_IPC_HLE, "IOCTL_WFSI_INIT"); + INFO_LOG(IOS, "IOCTL_WFSI_INIT"); break; case IOCTL_WFSI_SET_DEVICE_NAME: - INFO_LOG(WII_IPC_HLE, "IOCTL_WFSI_SET_DEVICE_NAME"); + INFO_LOG(IOS, "IOCTL_WFSI_SET_DEVICE_NAME"); m_device_name = Memory::GetString(request.buffer_in); break; case IOCTL_WFSI_APPLY_TITLE_PROFILE: - INFO_LOG(WII_IPC_HLE, "IOCTL_WFSI_APPLY_TITLE_PROFILE"); + INFO_LOG(IOS, "IOCTL_WFSI_APPLY_TITLE_PROFILE"); m_base_extract_path = StringFromFormat( "/vol/%s/_install/%c%c%c%c/content", m_device_name.c_str(), @@ -237,12 +238,13 @@ IPCCommandResult CWII_IPC_HLE_Device_wfsi::IOCtl(const IOSIOCtlRequest& request) // TODO(wfs): Should be returning an error. However until we have // everything properly stubbed it's easier to simulate the methods // succeeding. - request.DumpUnknown(GetDeviceName(), LogTypes::WII_IPC_HLE, LogTypes::LWARNING); + request.DumpUnknown(GetDeviceName(), LogTypes::IOS, LogTypes::LWARNING); Memory::Memset(request.buffer_out, 0, request.buffer_out_size); break; } return GetDefaultReply(return_error_code); } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_wfsi.h b/Source/Core/Core/IOS/WFS/WFSI.h similarity index 84% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_wfsi.h rename to Source/Core/Core/IOS/WFS/WFSI.h index baf44d809f..f7ddccd587 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_wfsi.h +++ b/Source/Core/Core/IOS/WFS/WFSI.h @@ -10,9 +10,9 @@ #include #include "Common/CommonTypes.h" -#include "Core/IPC_HLE/ESFormats.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device.h" +#include "Core/IOS/Device.h" +#include "Core/IOS/ES/Formats.h" +#include "Core/IOS/IPC.h" namespace IOS { @@ -33,10 +33,12 @@ private: std::vector m_whole_file; }; -class CWII_IPC_HLE_Device_wfsi : public IWII_IPC_HLE_Device +namespace Device +{ +class WFSI : public Device { public: - CWII_IPC_HLE_Device_wfsi(u32 device_id, const std::string& device_name); + WFSI(u32 device_id, const std::string& device_name); IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override; @@ -73,5 +75,6 @@ private: IOCTL_WFSI_APPLY_TITLE_PROFILE = 0x89, }; }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_wfssrv.cpp b/Source/Core/Core/IOS/WFS/WFSSRV.cpp similarity index 73% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_wfssrv.cpp rename to Source/Core/Core/IOS/WFS/WFSSRV.cpp index ab19a718d1..ea0fab0d7f 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_wfssrv.cpp +++ b/Source/Core/Core/IOS/WFS/WFSSRV.cpp @@ -2,7 +2,7 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. -#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_wfssrv.h" +#include "Core/IOS/WFS/WFSSRV.h" #include #include @@ -26,14 +26,14 @@ std::string NativePath(const std::string& wfs_path) } } // namespace WFS -CWII_IPC_HLE_Device_usb_wfssrv::CWII_IPC_HLE_Device_usb_wfssrv(u32 device_id, - const std::string& device_name) - : IWII_IPC_HLE_Device(device_id, device_name) +namespace Device +{ +WFSSRV::WFSSRV(u32 device_id, const std::string& device_name) : Device(device_id, device_name) { m_device_name = "msc01"; } -IPCCommandResult CWII_IPC_HLE_Device_usb_wfssrv::IOCtl(const IOSIOCtlRequest& request) +IPCCommandResult WFSSRV::IOCtl(const IOSIOCtlRequest& request) { int return_error_code = IPC_SUCCESS; @@ -41,18 +41,18 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_wfssrv::IOCtl(const IOSIOCtlRequest& re { case IOCTL_WFS_INIT: // TODO(wfs): Implement. - INFO_LOG(WII_IPC_HLE, "IOCTL_WFS_INIT"); + INFO_LOG(IOS, "IOCTL_WFS_INIT"); break; case IOCTL_WFS_DEVICE_INFO: - INFO_LOG(WII_IPC_HLE, "IOCTL_WFS_DEVICE_INFO"); + INFO_LOG(IOS, "IOCTL_WFS_DEVICE_INFO"); Memory::Write_U64(16ull << 30, request.buffer_out); // 16GB storage. Memory::Write_U8(4, request.buffer_out + 8); break; case IOCTL_WFS_GET_DEVICE_NAME: { - INFO_LOG(WII_IPC_HLE, "IOCTL_WFS_GET_DEVICE_NAME"); + INFO_LOG(IOS, "IOCTL_WFS_GET_DEVICE_NAME"); Memory::Write_U8(static_cast(m_device_name.size()), request.buffer_out); Memory::CopyToEmu(request.buffer_out + 1, m_device_name.data(), m_device_name.size()); break; @@ -60,14 +60,14 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_wfssrv::IOCtl(const IOSIOCtlRequest& re case IOCTL_WFS_ATTACH_DETACH_2: // TODO(wfs): Implement. - INFO_LOG(WII_IPC_HLE, "IOCTL_WFS_ATTACH_DETACH_2(%u)", request.request); + INFO_LOG(IOS, "IOCTL_WFS_ATTACH_DETACH_2(%u)", request.request); Memory::Write_U32(1, request.buffer_out); Memory::Write_U32(0, request.buffer_out + 4); // device id? Memory::Write_U32(0, request.buffer_out + 8); break; case IOCTL_WFS_ATTACH_DETACH: - INFO_LOG(WII_IPC_HLE, "IOCTL_WFS_ATTACH_DETACH(%u)", request.request); + INFO_LOG(IOS, "IOCTL_WFS_ATTACH_DETACH(%u)", request.request); Memory::Write_U32(1, request.buffer_out); Memory::Write_U32(0, request.buffer_out + 4); Memory::Write_U32(0, request.buffer_out + 8); @@ -76,18 +76,18 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_wfssrv::IOCtl(const IOSIOCtlRequest& re // TODO(wfs): Globbing is not really implemented, we just fake the one case // (listing /vol/*) which is required to get the installer to work. case IOCTL_WFS_GLOB_START: - INFO_LOG(WII_IPC_HLE, "IOCTL_WFS_GLOB_START(%u)", request.request); + INFO_LOG(IOS, "IOCTL_WFS_GLOB_START(%u)", request.request); Memory::Memset(request.buffer_out, 0, request.buffer_out_size); Memory::CopyToEmu(request.buffer_out + 0x14, m_device_name.data(), m_device_name.size()); break; case IOCTL_WFS_GLOB_NEXT: - INFO_LOG(WII_IPC_HLE, "IOCTL_WFS_GLOB_NEXT(%u)", request.request); + INFO_LOG(IOS, "IOCTL_WFS_GLOB_NEXT(%u)", request.request); return_error_code = WFS_EEMPTY; break; case IOCTL_WFS_GLOB_END: - INFO_LOG(WII_IPC_HLE, "IOCTL_WFS_GLOB_END(%u)", request.request); + INFO_LOG(IOS, "IOCTL_WFS_GLOB_END(%u)", request.request); Memory::Memset(request.buffer_out, 0, request.buffer_out_size); break; @@ -106,13 +106,13 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_wfssrv::IOCtl(const IOSIOCtlRequest& re if (!fd_obj->Open()) { - ERROR_LOG(WII_IPC_HLE, "IOCTL_WFS_OPEN(%s, %d): error opening file", path.c_str(), mode); + ERROR_LOG(IOS, "IOCTL_WFS_OPEN(%s, %d): error opening file", path.c_str(), mode); ReleaseFileDescriptor(fd); return_error_code = -1; // TODO(wfs): proper error code. break; } - INFO_LOG(WII_IPC_HLE, "IOCTL_WFS_OPEN(%s, %d) -> %d", path.c_str(), mode, fd); + INFO_LOG(IOS, "IOCTL_WFS_OPEN(%s, %d) -> %d", path.c_str(), mode, fd); Memory::Write_U16(fd, request.buffer_out + 0x14); break; } @@ -120,7 +120,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_wfssrv::IOCtl(const IOSIOCtlRequest& re case IOCTL_WFS_CLOSE: { u16 fd = Memory::Read_U16(request.buffer_in + 0x4); - INFO_LOG(WII_IPC_HLE, "IOCTL_WFS_CLOSE(%d)", fd); + INFO_LOG(IOS, "IOCTL_WFS_CLOSE(%d)", fd); ReleaseFileDescriptor(fd); break; } @@ -134,7 +134,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_wfssrv::IOCtl(const IOSIOCtlRequest& re FileDescriptor* fd_obj = FindFileDescriptor(fd); if (fd_obj == nullptr) { - ERROR_LOG(WII_IPC_HLE, "IOCTL_WFS_READ: invalid file descriptor %d", fd); + ERROR_LOG(IOS, "IOCTL_WFS_READ: invalid file descriptor %d", fd); return_error_code = -1; // TODO(wfs): proper error code. break; } @@ -147,7 +147,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_wfssrv::IOCtl(const IOSIOCtlRequest& re } fd_obj->position += read_bytes; - INFO_LOG(WII_IPC_HLE, "IOCTL_WFS_READ: read %zd bytes from FD %d (%s)", read_bytes, fd, + INFO_LOG(IOS, "IOCTL_WFS_READ: read %zd bytes from FD %d (%s)", read_bytes, fd, fd_obj->path.c_str()); return_error_code = static_cast(read_bytes); break; @@ -156,7 +156,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_wfssrv::IOCtl(const IOSIOCtlRequest& re default: // TODO(wfs): Should be returning -3. However until we have everything // properly stubbed it's easier to simulate the methods succeeding. - request.DumpUnknown(GetDeviceName(), LogTypes::WII_IPC_HLE, LogTypes::LWARNING); + request.DumpUnknown(GetDeviceName(), LogTypes::IOS, LogTypes::LWARNING); Memory::Memset(request.buffer_out, 0, request.buffer_out_size); break; } @@ -164,8 +164,7 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_wfssrv::IOCtl(const IOSIOCtlRequest& re return GetDefaultReply(return_error_code); } -CWII_IPC_HLE_Device_usb_wfssrv::FileDescriptor* -CWII_IPC_HLE_Device_usb_wfssrv::FindFileDescriptor(u16 fd) +WFSSRV::FileDescriptor* WFSSRV::FindFileDescriptor(u16 fd) { if (fd >= m_fds.size() || !m_fds[fd].in_use) { @@ -174,7 +173,7 @@ CWII_IPC_HLE_Device_usb_wfssrv::FindFileDescriptor(u16 fd) return &m_fds[fd]; } -u16 CWII_IPC_HLE_Device_usb_wfssrv::GetNewFileDescriptor() +u16 WFSSRV::GetNewFileDescriptor() { for (u32 i = 0; i < m_fds.size(); ++i) { @@ -187,7 +186,7 @@ u16 CWII_IPC_HLE_Device_usb_wfssrv::GetNewFileDescriptor() return static_cast(m_fds.size() - 1); } -void CWII_IPC_HLE_Device_usb_wfssrv::ReleaseFileDescriptor(u16 fd) +void WFSSRV::ReleaseFileDescriptor(u16 fd) { FileDescriptor* fd_obj = FindFileDescriptor(fd); if (!fd_obj) @@ -203,7 +202,7 @@ void CWII_IPC_HLE_Device_usb_wfssrv::ReleaseFileDescriptor(u16 fd) } } -bool CWII_IPC_HLE_Device_usb_wfssrv::FileDescriptor::Open() +bool WFSSRV::FileDescriptor::Open() { const char* mode_string; @@ -221,11 +220,12 @@ bool CWII_IPC_HLE_Device_usb_wfssrv::FileDescriptor::Open() } else { - ERROR_LOG(WII_IPC_HLE, "WFSOpen: invalid mode %d", mode); + ERROR_LOG(IOS, "WFSOpen: invalid mode %d", mode); return false; } return file.Open(WFS::NativePath(path), mode_string); } +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_wfssrv.h b/Source/Core/Core/IOS/WFS/WFSSRV.h similarity index 87% rename from Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_wfssrv.h rename to Source/Core/Core/IOS/WFS/WFSSRV.h index a26a8bf74a..f0f6084972 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_wfssrv.h +++ b/Source/Core/Core/IOS/WFS/WFSSRV.h @@ -9,8 +9,8 @@ #include "Common/CommonTypes.h" #include "Common/FileUtil.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device.h" +#include "Core/IOS/Device.h" +#include "Core/IOS/IPC.h" #include "DiscIO/Volume.h" namespace IOS @@ -22,10 +22,12 @@ namespace WFS std::string NativePath(const std::string& wfs_path); } -class CWII_IPC_HLE_Device_usb_wfssrv : public IWII_IPC_HLE_Device +namespace Device +{ +class WFSSRV : public Device { public: - CWII_IPC_HLE_Device_usb_wfssrv(u32 device_id, const std::string& device_name); + WFSSRV(u32 device_id, const std::string& device_name); IPCCommandResult IOCtl(const IOSIOCtlRequest& request) override; @@ -77,5 +79,6 @@ private: u16 GetNewFileDescriptor(); void ReleaseFileDescriptor(u16 fd); }; +} // namespace Device } // namespace HLE } // namespace IOS diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stub.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stub.cpp deleted file mode 100644 index 63cdec4c9d..0000000000 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stub.cpp +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2016 Dolphin Emulator Project -// Licensed under GPLv2+ -// Refer to the license.txt file included. - -#include "Core/IPC_HLE/WII_IPC_HLE_Device_stub.h" -#include "Common/Logging/Log.h" - -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) -{ -} - -IOSReturnCode CWII_IPC_HLE_Device_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() -{ - 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) -{ - 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) -{ - WARN_LOG(WII_IPC_HLE, "%s faking IOCtlV()", m_name.c_str()); - return GetDefaultReply(IPC_SUCCESS); -} -} // namespace HLE -} // namespace IOS diff --git a/Source/Core/Core/Movie.cpp b/Source/Core/Core/Movie.cpp index b1338db740..13882da1df 100644 --- a/Source/Core/Core/Movie.cpp +++ b/Source/Core/Core/Movie.cpp @@ -32,8 +32,8 @@ #include "Core/HW/Wiimote.h" #include "Core/HW/WiimoteEmu/WiimoteEmu.h" #include "Core/HW/WiimoteEmu/WiimoteHid.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.h" -#include "Core/IPC_HLE/WII_IPC_HLE_WiiMote.h" +#include "Core/IOS/USB/Bluetooth/BTEmu.h" +#include "Core/IOS/USB/Bluetooth/WiimoteDevice.h" #include "Core/Movie.h" #include "Core/NetPlayProto.h" #include "Core/PowerPC/PowerPC.h" @@ -580,7 +580,7 @@ bool BeginRecordingInput(int controllers) s_bRecordingFromSaveState = true; // This is only done here if starting from save state because otherwise we won't have the - // titleid. Otherwise it's set in WII_IPC_HLE_Device_es.cpp. + // titleid. Otherwise it's set in IOS::HLE::Device::ES. // TODO: find a way to GetTitleDataPath() from Movie::Init() if (SConfig::GetInstance().bWii) { diff --git a/Source/Core/Core/NetPlayClient.cpp b/Source/Core/Core/NetPlayClient.cpp index a9697ac058..0f3902910a 100644 --- a/Source/Core/Core/NetPlayClient.cpp +++ b/Source/Core/Core/NetPlayClient.cpp @@ -22,7 +22,7 @@ #include "Core/HW/Sram.h" #include "Core/HW/WiimoteEmu/WiimoteEmu.h" #include "Core/HW/WiimoteReal/WiimoteReal.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.h" +#include "Core/IOS/USB/Bluetooth/BTEmu.h" #include "Core/Movie.h" #include "InputCommon/GCAdapter.h" #include "VideoCommon/OnScreenDisplay.h" diff --git a/Source/Core/Core/WiiRoot.cpp b/Source/Core/Core/WiiRoot.cpp index d0be403339..dad2252cf1 100644 --- a/Source/Core/Core/WiiRoot.cpp +++ b/Source/Core/Core/WiiRoot.cpp @@ -23,11 +23,11 @@ void InitializeWiiRoot(bool use_temporary) s_temp_wii_root = File::CreateTempDir(); if (s_temp_wii_root.empty()) { - ERROR_LOG(WII_IPC_FILEIO, "Could not create temporary directory"); + ERROR_LOG(IOS_FILEIO, "Could not create temporary directory"); return; } File::CopyDir(File::GetSysDirectory() + WII_USER_DIR, s_temp_wii_root); - WARN_LOG(WII_IPC_FILEIO, "Using temporary directory %s for minimal Wii FS", + WARN_LOG(IOS_FILEIO, "Using temporary directory %s for minimal Wii FS", s_temp_wii_root.c_str()); static bool s_registered; if (!s_registered) diff --git a/Source/Core/Core/ec_wii.cpp b/Source/Core/Core/ec_wii.cpp index c814863cc4..b756f666a2 100644 --- a/Source/Core/Core/ec_wii.cpp +++ b/Source/Core/Core/ec_wii.cpp @@ -129,24 +129,23 @@ EcWii::EcWii() { init = false; - INFO_LOG(WII_IPC_ES, "Successfully loaded keys.bin created by: %s", BootMiiKeysBin.creator); + INFO_LOG(IOS_ES, "Successfully loaded keys.bin created by: %s", BootMiiKeysBin.creator); } else { - ERROR_LOG(WII_IPC_ES, - "Failed to read keys.bin, check it is the correct size of %08zX bytes.", + ERROR_LOG(IOS_ES, "Failed to read keys.bin, check it is the correct size of %08zX bytes.", sizeof(BootMiiKeysBin)); } } else { - ERROR_LOG(WII_IPC_ES, "Failed to open keys.bin, maybe a permissions error or it is in use?"); + ERROR_LOG(IOS_ES, "Failed to open keys.bin, maybe a permissions error or it is in use?"); } } else { ERROR_LOG( - WII_IPC_ES, + IOS_ES, "%s could not be found. Using default values. We recommend you grab keys.bin from BootMii.", keys_path.c_str()); } diff --git a/Source/Core/DolphinWX/Config/WiiConfigPane.cpp b/Source/Core/DolphinWX/Config/WiiConfigPane.cpp index 168e29a1c7..93beb2b73e 100644 --- a/Source/Core/DolphinWX/Config/WiiConfigPane.cpp +++ b/Source/Core/DolphinWX/Config/WiiConfigPane.cpp @@ -13,7 +13,7 @@ #include "Core/ConfigManager.h" #include "Core/Core.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" +#include "Core/IOS/IPC.h" #include "DolphinWX/DolphinSlider.h" #include "DolphinWX/WxEventUtils.h" #include "DolphinWX/WxUtils.h" diff --git a/Source/Core/DolphinWX/ControllerConfigDiag.cpp b/Source/Core/DolphinWX/ControllerConfigDiag.cpp index 2c0a8646bd..a63a9cdff7 100644 --- a/Source/Core/DolphinWX/ControllerConfigDiag.cpp +++ b/Source/Core/DolphinWX/ControllerConfigDiag.cpp @@ -27,8 +27,8 @@ #include "Core/HW/Wiimote.h" #include "Core/HW/WiimoteReal/WiimoteReal.h" #include "Core/HotkeyManager.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_real.h" +#include "Core/IOS/IPC.h" +#include "Core/IOS/USB/Bluetooth/BTReal.h" #include "Core/NetPlayProto.h" #include "DolphinWX/Config/GCAdapterConfigDiag.h" #include "DolphinWX/ControllerConfigDiag.h" @@ -529,7 +529,7 @@ void ControllerConfigDiag::OnPassthroughScanButton(wxCommandEvent& event) } auto device = IOS::HLE::GetDeviceByName("/dev/usb/oh1/57e/305"); if (device != nullptr) - std::static_pointer_cast(device) + std::static_pointer_cast(device) ->TriggerSyncButtonPressedEvent(); } @@ -543,8 +543,7 @@ void ControllerConfigDiag::OnPassthroughResetButton(wxCommandEvent& event) } auto device = IOS::HLE::GetDeviceByName("/dev/usb/oh1/57e/305"); if (device != nullptr) - std::static_pointer_cast(device) - ->TriggerSyncButtonHeldEvent(); + std::static_pointer_cast(device)->TriggerSyncButtonHeldEvent(); } void ControllerConfigDiag::OnBalanceBoardChanged(wxCommandEvent& event) diff --git a/Source/Core/DolphinWX/Frame.cpp b/Source/Core/DolphinWX/Frame.cpp index cd334b54d2..9bb98c5f62 100644 --- a/Source/Core/DolphinWX/Frame.cpp +++ b/Source/Core/DolphinWX/Frame.cpp @@ -46,8 +46,8 @@ #include "Core/HW/GCPad.h" #include "Core/HW/Wiimote.h" #include "Core/HotkeyManager.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.h" +#include "Core/IOS/IPC.h" +#include "Core/IOS/USB/Bluetooth/BTBase.h" #include "Core/Movie.h" #include "Core/State.h" @@ -1279,8 +1279,8 @@ void CFrame::ParseHotkeys() { auto device = IOS::HLE::GetDeviceByName("/dev/usb/oh1/57e/305"); if (device != nullptr) - std::static_pointer_cast(device) - ->UpdateSyncButtonState(IsHotkey(HK_TRIGGER_SYNC_BUTTON, true)); + std::static_pointer_cast(device)->UpdateSyncButtonState( + IsHotkey(HK_TRIGGER_SYNC_BUTTON, true)); } if (UseDebugger) diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index 243f217690..50dec10be5 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -42,10 +42,10 @@ #include "Core/HW/Wiimote.h" #include "Core/Host.h" #include "Core/HotkeyManager.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_stm.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.h" -#include "Core/IPC_HLE/WII_IPC_HLE_WiiMote.h" +#include "Core/IOS/IPC.h" +#include "Core/IOS/STM/STM.h" +#include "Core/IOS/USB/Bluetooth/BTEmu.h" +#include "Core/IOS/USB/Bluetooth/WiimoteDevice.h" #include "Core/Movie.h" #include "Core/PowerPC/PPCSymbolDB.h" #include "Core/PowerPC/PowerPC.h" @@ -861,12 +861,8 @@ void CFrame::DoStop() bool CFrame::TriggerSTMPowerEvent() { const auto stm = IOS::HLE::GetDeviceByName("/dev/stm/eventhook"); - if (!stm || - !std::static_pointer_cast(stm) - ->HasHookInstalled()) - { + if (!stm || !std::static_pointer_cast(stm)->HasHookInstalled()) return false; - } Core::DisplayMessage("Shutting down", 30000); // Unpause because gracefully shutting down needs the game to actually request a shutdown diff --git a/Source/Core/DolphinWX/MainNoGUI.cpp b/Source/Core/DolphinWX/MainNoGUI.cpp index e60b246605..f4e64f120e 100644 --- a/Source/Core/DolphinWX/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/MainNoGUI.cpp @@ -23,10 +23,10 @@ #include "Core/Core.h" #include "Core/HW/Wiimote.h" #include "Core/Host.h" -#include "Core/IPC_HLE/WII_IPC_HLE.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_stm.h" -#include "Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.h" -#include "Core/IPC_HLE/WII_IPC_HLE_WiiMote.h" +#include "Core/IOS/IPC.h" +#include "Core/IOS/STM/STM.h" +#include "Core/IOS/USB/Bluetooth/BTEmu.h" +#include "Core/IOS/USB/Bluetooth/WiimoteDevice.h" #include "Core/State.h" #include "UICommon/UICommon.h" @@ -239,8 +239,7 @@ class PlatformX11 : public Platform { const auto stm = IOS::HLE::GetDeviceByName("/dev/stm/eventhook"); if (!s_tried_graceful_shutdown.IsSet() && stm && - std::static_pointer_cast(stm) - ->HasHookInstalled()) + std::static_pointer_cast(stm)->HasHookInstalled()) { ProcessorInterface::PowerButton_Tap(); s_tried_graceful_shutdown.Set();