diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp index 19c1898393..b46e9c3a0f 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp @@ -57,44 +57,7 @@ #include "WII_IPC_HLE_Device_net.h" -#define IOCTL_NWC24_STARTUP 0x06 -enum { - IOCTL_SO_ACCEPT = 1, - IOCTL_SO_BIND, - IOCTL_SO_CLOSE, - IOCTL_SO_CONNECT, - IOCTL_SO_FCNTL, - IOCTL_SO_GETPEERNAME, // todo - IOCTL_SO_GETSOCKNAME, // todo - IOCTL_SO_GETSOCKOPT, // todo 8 - IOCTL_SO_SETSOCKOPT, - IOCTL_SO_LISTEN, - IOCTL_SO_POLL, // todo b - IOCTLV_SO_RECVFROM, - IOCTLV_SO_SENDTO, - IOCTL_SO_SHUTDOWN, // todo e - IOCTL_SO_SOCKET, - IOCTL_SO_GETHOSTID, - IOCTL_SO_GETHOSTBYNAME, - IOCTL_SO_GETHOSTBYADDR,// todo - IOCTLV_SO_GETNAMEINFO, // todo 13 - IOCTL_SO_UNK14, // todo - IOCTL_SO_INETATON, // todo - IOCTL_SO_INETPTON, // todo - IOCTL_SO_INETNTOP, // todo - IOCTLV_SO_GETADDRINFO, // todo - IOCTL_SO_SOCKATMARK, // todo - IOCTLV_SO_UNK1A, // todo - IOCTLV_SO_UNK1B, // todo - IOCTLV_SO_GETINTERFACEOPT, // todo - IOCTLV_SO_SETINTERFACEOPT, // todo - IOCTL_SO_SETINTERFACE, // todo - IOCTL_SO_STARTUP, // 0x1f - IOCTL_SO_ICMPSOCKET = 0x30, // todo - IOCTLV_SO_ICMPPING, // todo - IOCTL_SO_ICMPCANCEL, // todo - IOCTL_SO_ICMPCLOSE // todo -}; +extern std::queue > g_ReplyQueueLater; // ********************************************************************************** @@ -124,64 +87,80 @@ bool CWII_IPC_HLE_Device_net_kd_request::Close(u32 _CommandAddress) return true; } + bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress) { u32 Parameter = Memory::Read_U32(_CommandAddress + 0xC); u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10); u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14); u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18); - u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C); + u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C); - u32 ReturnValue = ExecuteCommand(Parameter, BufferIn, BufferInSize, BufferOut, BufferOutSize); + u32 ReturnValue = 0; + switch(Parameter) + { + case IOCTL_NWC24_SUSPEND_SCHEDULAR: // NWC24iResumeForCloseLib from NWC24SuspendScheduler (Input: none, Output: 32 bytes) + ERROR_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_SUSPEND_SCHEDULAR - NI"); + ReturnValue = 0; + break; - INFO_LOG(WII_IPC_NET, "NET_KD_REQ: IOCtl (Device=%s) (Parameter: 0x%02x)", GetDeviceName().c_str(), Parameter); + case IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR: // NWC24iResumeForCloseLib + ERROR_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR - NI"); + ReturnValue = 0; + break; + case IOCTL_NWC24_UNK_3: // NWC24iResumeForCloseLib + ERROR_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_UNK_3 - NI"); + ReturnValue = 0; + break; + + case IOCTL_NWC24_STARTUP_SOCKET: + ERROR_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_STARTUP_SOCKET - NI"); + ReturnValue = 0; + break; + + case IOCTL_NWC24_LOCK_SOCKET: // WiiMenu + ERROR_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_LOCK_SOCKET - NI"); + ReturnValue = 0; + break; + + case IOCTL_NWC24_UNLOCK_SOCKET: + ERROR_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_UNLOCK_SOCKET - NI"); + ReturnValue = 0; + break; + + case IOCTL_NWC24_REQUEST_GENERATED_USER_ID: // (Input: none, Output: 32 bytes) + PanicAlert("IOCTL_NWC24_REQUEST_GENERATED_USER_ID"); + ReturnValue = 0; + break; + + case IOCTL_NWC24_GET_SCHEDULAR_STAT: + ERROR_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_GET_SCHEDULAR_STAT - NI"); + ReturnValue = 0; + break; + + case IOCTL_NWC24_SAVE_MAIL_NOW: + ERROR_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_SAVE_MAIL_NOW - NI"); + ReturnValue = 0; + break; + + case IOCTL_NWC24_REQUEST_SHUTDOWN: + ERROR_LOG(WII_IPC_NET, "NET_KD_REQ: IOCTL_NWC24_REQUEST_SHUTDOWN - NI"); // if ya set the IOS version to a very high value this happens ... + ReturnValue = 0; + break; + + default: + _dbg_assert_msg_(WII_IPC_NET, 0, "/dev/net/kd/request::IOCtl request 0x%x (BufferIn: (%08x, %i), BufferOut: (%08x, %i)", + Parameter, BufferIn, BufferInSize, BufferOut, BufferOutSize); + break; + } + + // g_ReplyQueueLater.push(std::pair(_CommandAddress, GetDeviceName())); Memory::Write_U32(ReturnValue, _CommandAddress + 4); - + return true; } -s32 CWII_IPC_HLE_Device_net_kd_request::ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _BufferInSize, u32 _BufferOut, u32 _BufferOutSize) -{ - // Clean the location of the output buffer to zeroes as a safety precaution */ - Memory::Memset(_BufferOut, 0, _BufferOutSize); - - switch(_Parameter) - { - case 1: // SuspendScheduler (Input: none, Output: 32 bytes) - //Memory::Write_U32(0, _BufferOut); - return -1; - break; - case 2: // ExecTrySuspendScheduler (Input: 32 bytes, Output: 32 bytes). - DumpCommands(_BufferIn, _BufferInSize / 4, LogTypes::WII_IPC_NET); - Memory::Write_U32(1, _BufferOut); - return 0; - break; - case 3: // ? (Input: none, Output: 32 bytes) - //Memory::Write_U32(0, _BufferOut); - return -1; - break; - case IOCTL_NWC24_STARTUP: - return 0; - - case 8: // WiiMenu - case 9: - return 0; - - case 0xf: // NWC24iRequestGenerateUserId (Input: none, Output: 32 bytes) - //Memory::Write_U32(0, _BufferOut); - return -1; - break; - default: - _dbg_assert_msg_(WII_IPC_NET, 0, "/dev/net/kd/request::IOCtl request 0x%x (BufferIn: (%08x, %i), BufferOut: (%08x, %i)", - _Parameter, _BufferIn, _BufferInSize, _BufferOut, _BufferOutSize); - break; - } - - // We return a success for any potential unknown requests - return 0; -} - // ********************************************************************************** // Handle /dev/net/ncd/manage requests @@ -195,12 +174,14 @@ CWII_IPC_HLE_Device_net_ncd_manage::~CWII_IPC_HLE_Device_net_ncd_manage() bool CWII_IPC_HLE_Device_net_ncd_manage::Open(u32 _CommandAddress, u32 _Mode) { + INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE: Open"); Memory::Write_U32(GetDeviceID(), _CommandAddress+4); return true; } bool CWII_IPC_HLE_Device_net_ncd_manage::Close(u32 _CommandAddress) { + INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE: Close"); Memory::Write_U32(0, _CommandAddress + 4); return true; } @@ -222,12 +203,13 @@ bool CWII_IPC_HLE_Device_net_ncd_manage::IOCtlV(u32 _CommandAddress) case 0x08: break; - default: - INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE IOCtlV: %i", CommandBuffer.Parameter); + default: _dbg_assert_msg_(WII_IPC_NET, 0, "NET_NCD_MANAGE IOCtlV: %i", CommandBuffer.Parameter); break; } + INFO_LOG(WII_IPC_NET, "NET_NCD_MANAGE IOCtlV: %i", CommandBuffer.Parameter); + Memory::Write_U32(ReturnValue, _CommandAddress+4); return true; @@ -245,12 +227,14 @@ CWII_IPC_HLE_Device_net_ip_top::~CWII_IPC_HLE_Device_net_ip_top() bool CWII_IPC_HLE_Device_net_ip_top::Open(u32 _CommandAddress, u32 _Mode) { + INFO_LOG(WII_IPC_NET, "NET_IP_TOP: Open"); Memory::Write_U32(GetDeviceID(), _CommandAddress+4); return true; } bool CWII_IPC_HLE_Device_net_ip_top::Close(u32 _CommandAddress) { + INFO_LOG(WII_IPC_NET, "NET_IP_TOP: Close"); Memory::Write_U32(0, _CommandAddress + 4); return true; } @@ -271,10 +255,12 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtl(u32 _CommandAddress) return true; } -s32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command, u32 _BufferIn, u32 _BufferInSize, u32 _BufferOut, u32 _BufferOutSize) +s32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command, u32 _BufferIn, u32 BufferInSize, u32 BufferOut, u32 BufferOutSize) { // Clean the location of the output buffer to zeroes as a safety precaution */ - Memory::Memset(_BufferOut, 0, _BufferOutSize); + Memory::Memset(BufferOut, 0, BufferOutSize); + + INFO_LOG(WII_IPC_NET, "NET_IP_TOP IOCtlV: %i", _Command); switch(_Command) { @@ -282,7 +268,7 @@ s32 CWII_IPC_HLE_Device_net_ip_top::ExecuteCommand(u32 _Command, u32 _BufferIn, default: _dbg_assert_msg_(WII_IPC_NET, 0, "/dev/net/ip/top::IOCtl request 0x%x (BufferIn: (%08x, %i), BufferOut: (%08x, %i)", - _Command, _BufferIn, _BufferInSize, _BufferOut, _BufferOutSize); + _Command, _BufferIn, BufferInSize, BufferOut, BufferOutSize); break; } @@ -296,6 +282,8 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 _CommandAddress) SIOCtlVBuffer CommandBuffer(_CommandAddress); + INFO_LOG(WII_IPC_NET, "NET_IP_TOP IOCtlV: %i", CommandBuffer.Parameter); + switch(CommandBuffer.Parameter) { default: diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.h index 501b08d451..0524524de8 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.h @@ -34,7 +34,31 @@ public: private: - s32 ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _BufferInSize, u32 _BufferOut, u32 _BufferOutSize); + enum + { + IOCTL_NWC24_SUSPEND_SCHEDULAR = 0x01, + IOCTL_NWC24_EXEC_TRY_SUSPEND_SCHEDULAR = 0x02, + IOCTL_NWC24_UNK_3 = 0x03, + IOCTL_NWC24_UNK_4 = 0x04, + IOCTL_NWC24_UNK_5 = 0x05, + IOCTL_NWC24_STARTUP_SOCKET = 0x06, + IOCTL_NWC24_CLEANUP_SOCKET = 0x07, + IOCTL_NWC24_LOCK_SOCKET = 0x08, + IOCTL_NWC24_UNLOCK_SOCKET = 0x09, + IOCTL_NWC24_UNK_A = 0x0A, + IOCTL_NWC24_UNK_B = 0x0B, + IOCTL_NWC24_UNK_C = 0x0C, + IOCTL_NWC24_SAVE_MAIL_NOW = 0x0D, + IOCTL_NWC24_DOWNLOAD_NOW_EX = 0x0E, + IOCTL_NWC24_REQUEST_GENERATED_USER_ID = 0x0F, + IOCTL_NWC24_REQUEST_REGISTER_USER_ID = 0x10, + IOCTL_NWC24_GET_SCHEDULAR_STAT = 0x1E, + IOCTL_NWC24_UNK_1F = 0x1F, + IOCTL_NWC24_UNK_20 = 0x20, + IOCTL_NWC24_UNK_21 = 0x21, + IOCTL_NWC24_SET_SCRIPT_MODE = 0x22, + IOCTL_NWC24_REQUEST_SHUTDOWN = 0x28, + }; }; // ************************************************************************************** @@ -52,41 +76,73 @@ public: virtual bool Open(u32 _CommandAddress, u32 _Mode) { - INFO_LOG(WII_IPC_NET, "%s - IOCtl: Open", GetDeviceName().c_str()); + INFO_LOG(WII_IPC_NET, "NET_KD_TIME: Open"); Memory::Write_U32(GetDeviceID(), _CommandAddress+4); return true; } - virtual bool Close(u32 _CommandAddress, u32 _Mode) + virtual bool Close(u32 _CommandAddress) { - INFO_LOG(WII_IPC_NET, "%s - IOCtl: Close", GetDeviceName().c_str()); + INFO_LOG(WII_IPC_NET, "NET_KD_TIME: Close"); Memory::Write_U32(0, _CommandAddress + 4); return true; } virtual bool IOCtl(u32 _CommandAddress) { - #if LOGLEVEL >= 4 - u32 Parameter = Memory::Read_U32(_CommandAddress +0x0C); - u32 Buffer1 = Memory::Read_U32(_CommandAddress +0x10); - u32 BufferSize1 = Memory::Read_U32(_CommandAddress +0x14); - u32 Buffer2 = Memory::Read_U32(_CommandAddress +0x18); - u32 BufferSize2 = Memory::Read_U32(_CommandAddress +0x1C); - #endif + u32 Parameter = Memory::Read_U32(_CommandAddress +0x0C); + u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10); + u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14); + u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18); + u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C); + + switch (Parameter) + { + case IOCTL_NW24_SET_RTC_COUNTER: // NWC24iSetRtcCounter (but prolly just the first 4 bytes are intresting...) + _dbg_assert_msg_(WII_IPC_NET, BufferInSize==0x20, "NET_KD_TIME: Set RTC Counter BufferIn to small"); + _dbg_assert_msg_(WII_IPC_NET, BufferOutSize==0x20, "NET_KD_TIME: Set RTC Counter BufferOut to small"); + + for (int i=0; i<0x20; i++) + { + m_RtcCounter[i] = Memory::Read_U8(BufferIn+i); + } + + // send back for sync?? at least there is a out buffer... + for (int i=0; i<0x20; i++) + { + Memory::Write_U8(m_RtcCounter[i], BufferOut+i); + } + + INFO_LOG(WII_IPC_NET, "NET_KD_TIME: Set RTC Counter"); + + Memory::Write_U32(0, _CommandAddress + 0x4); + return true; + + default: + ERROR_LOG(WII_IPC_NET, "%s - IOCtl:\n" + " Parameter: 0x%x (0x17 NWC24iSetRtcCounter) \n" + " BufferIn: 0x%08x\n" + " BufferInSize: 0x%08x\n" + " BufferOut: 0x%08x\n" + " BufferOutSize: 0x%08x\n", + GetDeviceName().c_str(), Parameter, BufferIn, BufferInSize, BufferOut, BufferOutSize); + break; + } // write return value Memory::Write_U32(0, _CommandAddress + 0x4); - - DEBUG_LOG(WII_IPC_NET, "%s - IOCtl:\n" - " Parameter: 0x%x (0x17 could be some kind of Sync RTC) \n" - " Buffer1: 0x%08x\n" - " BufferSize1: 0x%08x\n" - " Buffer2: 0x%08x\n" - " BufferSize2: 0x%08x\n", - GetDeviceName().c_str(), Parameter, Buffer1, BufferSize1, Buffer2, BufferSize2); - return true; } + +private: + + enum + { + IOCTL_NW24_SET_RTC_COUNTER = 0x17, + IOCTL_NW24_GET_TIME_DIFF = 0x18, + }; + + u8 m_RtcCounter[0x20]; }; // ************************************************************************************** @@ -104,6 +160,45 @@ public: virtual bool IOCtlV(u32 _CommandAddress); private: + + enum { + IOCTL_SO_ACCEPT = 1, + IOCTL_SO_BIND, + IOCTL_SO_CLOSE, + IOCTL_SO_CONNECT, + IOCTL_SO_FCNTL, + IOCTL_SO_GETPEERNAME, // todo + IOCTL_SO_GETSOCKNAME, // todo + IOCTL_SO_GETSOCKOPT, // todo 8 + IOCTL_SO_SETSOCKOPT, + IOCTL_SO_LISTEN, + IOCTL_SO_POLL, // todo b + IOCTLV_SO_RECVFROM, + IOCTLV_SO_SENDTO, + IOCTL_SO_SHUTDOWN, // todo e + IOCTL_SO_SOCKET, + IOCTL_SO_GETHOSTID, + IOCTL_SO_GETHOSTBYNAME, + IOCTL_SO_GETHOSTBYADDR,// todo + IOCTLV_SO_GETNAMEINFO, // todo 13 + IOCTL_SO_UNK14, // todo + IOCTL_SO_INETATON, // todo + IOCTL_SO_INETPTON, // todo + IOCTL_SO_INETNTOP, // todo + IOCTLV_SO_GETADDRINFO, // todo + IOCTL_SO_SOCKATMARK, // todo + IOCTLV_SO_UNK1A, // todo + IOCTLV_SO_UNK1B, // todo + IOCTLV_SO_GETINTERFACEOPT, // todo + IOCTLV_SO_SETINTERFACEOPT, // todo + IOCTL_SO_SETINTERFACE, // todo + IOCTL_SO_STARTUP, // 0x1f + IOCTL_SO_ICMPSOCKET = 0x30, // todo + IOCTLV_SO_ICMPPING, // todo + IOCTL_SO_ICMPCANCEL, // todo + IOCTL_SO_ICMPCLOSE // todo + }; + s32 ExecuteCommand(u32 _Parameter, u32 _BufferIn, u32 _BufferInSize, u32 _BufferOut, u32 _BufferOutSize); };