diff --git a/Source/Core/Core/Src/Debugger/Debugger_SymbolMap.cpp b/Source/Core/Core/Src/Debugger/Debugger_SymbolMap.cpp index f274471f89..f03256d4bc 100644 --- a/Source/Core/Core/Src/Debugger/Debugger_SymbolMap.cpp +++ b/Source/Core/Core/Src/Debugger/Debugger_SymbolMap.cpp @@ -129,7 +129,7 @@ void PrintCallstack(LogTypes::LOG_TYPE _Log) const char *str = g_symbolDB.GetDescription(func); if (!str || strlen(str) == 0 || !strcmp(str, "Invalid")) str = "(unknown)"; - __Log(_Log, " * %s [ addr = %08x ]\n", str, func); + __Logv(_Log, 3, " * %s [ addr = %08x ]\n", str, func); addr = Memory::ReadUnchecked_U32(addr); } } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h index 59cd542c97..4a4eae4688 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device.h @@ -49,37 +49,56 @@ public: protected: + // =================================================== + /* A struct for IOS ioctlv calls */ + // ---------------- struct SIOCtlVBuffer { SIOCtlVBuffer(u32 _Address) : m_Address(_Address) { - Parameter = Memory::Read_U32(m_Address + 0x0C); - NumberInBuffer = Memory::Read_U32(m_Address + 0x10); - NumberPayloadBuffer = Memory::Read_U32(m_Address + 0x14); - BufferVector = Memory::Read_U32(m_Address + 0x18); - BufferSize = Memory::Read_U32(m_Address + 0x1C); + /* These are the Ioctlv parameters in the IOS communication. The BufferVector + is a memory address offset at where the in and out buffer addresses are + stored. */ + Parameter = Memory::Read_U32(m_Address + 0x0C); // command 3 + NumberInBuffer = Memory::Read_U32(m_Address + 0x10); // 4 + NumberPayloadBuffer = Memory::Read_U32(m_Address + 0x14); // 5 + BufferVector = Memory::Read_U32(m_Address + 0x18); // 6 + BufferSize = Memory::Read_U32(m_Address + 0x1C); // 7 + // The start of the out buffer u32 BufferVectorOffset = BufferVector; - for (u32 i=0; i InBuffer; std::vector PayloadBuffer; }; + // =================================================== + /* Write out the IPC struct from _CommandAddress to _NumberOfCommands numbers + of 4 byte commands. */ + // ---------------- void DumpCommands(u32 _CommandAddress, size_t _NumberOfCommands = 8) { - LOG(WII_IPC_HLE, " CommandDump of %s", GetDeviceName().c_str()); - for (u32 i=0; i<_NumberOfCommands; i++) - { - LOG(WII_IPC_HLE, " Command%02i: 0x%08x", i, Memory::Read_U32(_CommandAddress + i*4)); - } - } +// Because I have to use __Logv here I add this #if +#if defined(_DEBUG) || defined(DEBUGFAST) + // Select log type + int log; + if(GetDeviceName().find("dev/es") != std::string::npos) + log = LogTypes::WII_IPC_ES; + else + log = LogTypes::WII_IPC_HLE; + __Logv(log, 0, "CommandDump of %s", GetDeviceName().c_str()); + for (u32 i=0; i<_NumberOfCommands; i++) + { + __Logv(log, 0, " Command%02i: 0x%08x", i, Memory::Read_U32(_CommandAddress + i*4)); + } +#endif + } + void DumpAsync( u32 BufferVector, u32 _CommandAddress, u32 NumberInBuffer, u32 NumberOutBuffer ) { LOG(WII_IPC_HLE, "======= DumpAsync ======"); diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.h index 82f575d660..dfe085f31e 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_es.h @@ -42,6 +42,7 @@ public: IOCTL_ES_GETTITLES = 0x0F, IOCTL_ES_GETVIEWCNT = 0x12, IOCTL_ES_GETVIEWS = 0x13, + IOCTL_ES_GETTMDVIEWCNT = 0x14, IOCTL_ES_DIVERIFY = 0x1C, IOCTL_ES_GETTITLEDIR = 0x1D, IOCTL_ES_GETTITLEID = 0x20, @@ -78,8 +79,8 @@ public: SIOCtlVBuffer Buffer(_CommandAddress); switch(Buffer.Parameter) { - case IOCTL_ES_GETTITLEDIR: - { + case IOCTL_ES_GETTITLEDIR: // ES_GetDataDir in DevKitPro + { u32 TitleID = VolumeHandler::Read32(0); if (TitleID == 0) TitleID = 0xF00DBEEF; @@ -89,8 +90,7 @@ public: char* Path = (char*)Memory::GetPointer(Buffer.PayloadBuffer[0].m_Address); sprintf(Path, "/00010000/%02x%02x%02x%02x/data", (u8)pTitleID[3], (u8)pTitleID[2], (u8)pTitleID[1], (u8)pTitleID[0]); - LOG(WII_IPC_HLE, "CWII_IPC_HLE_Device_es command:" - " IOCTL_ES_GETTITLEDIR: %s", Path); + LOG(WII_IPC_ES, "ES: IOCTL_ES_GETTITLEDIR: %s ", Path); } break; @@ -104,11 +104,35 @@ public: Memory::Write_U32(TitleID, OutBuffer); - LOG(WII_IPC_HLE, "CWII_IPC_HLE_Device_es command:" - " IOCTL_ES_GETTITLEID: 0x%x", TitleID); + LOG(WII_IPC_ES, "ES: IOCTL_ES_GETTITLEID: 0x%x", TitleID); } break; - + + // This and 0x14 are called by Mario Kart + case IOCTL_ES_GETVIEWCNT: // (0x12) ES_GetNumTicketViews in DevKitPro + { + if(Buffer.NumberPayloadBuffer) + u32 OutBuffer = Memory::Read_U32(Buffer.PayloadBuffer[0].m_Address); + if(Buffer.NumberInBuffer) + u32 InBuffer = Memory::Read_U32(Buffer.InBuffer[0].m_Address); + + // Should we write something here? + //Memory::Write_U32(0, Buffer.PayloadBuffer[0].m_Address); + } + break; + + case IOCTL_ES_GETTMDVIEWCNT: // (0x14) ES_GetTMDViewSize in DevKitPro + { + if(Buffer.NumberPayloadBuffer) + u32 OutBuffer = Memory::Read_U32(Buffer.PayloadBuffer[0].m_Address); + if(Buffer.NumberInBuffer) + u32 InBuffer = Memory::Read_U32(Buffer.InBuffer[0].m_Address); + + // Should we write something here? + //Memory::Write_U32(0, Buffer.PayloadBuffer[0].m_Address); + } + break; + case 0x16: // Consumption case 0x1B: // ES_DiGetTicketView @@ -121,7 +145,7 @@ public: Memory::Write_U32(0, OutBuffer); - LOG(WII_IPC_HLE, "CWII_IPC_HLE_Device_es command:" + LOG(WII_IPC_ES, "CWII_IPC_HLE_Device_es command:" " IOCTL_ES_GETTITLECOUNT: 0x%x", OutBuffer); } break; @@ -137,6 +161,30 @@ public: break; } + /* Extended logs + //if(Buffer.Parameter == IOCTL_ES_GETTITLEDIR || Buffer.Parameter == IOCTL_ES_GETTITLEID || + // Buffer.Parameter == IOCTL_ES_GETVIEWCNT || Buffer.Parameter == IOCTL_ES_GETTMDVIEWCNT) + { + u32 OutBuffer = Memory::Read_U32(Buffer.PayloadBuffer[0].m_Address); + if(Buffer.NumberInBuffer > 0) + { + u32 InBuffer = Memory::Read_U32(Buffer.InBuffer[0].m_Address); + LOG(WII_IPC_ES, "ES Parameter: 0x%x (In: %i, Out:%i) (In 0x%08x = 0x%08x %i) (Out 0x%08x = 0x%08x %i)", + Buffer.Parameter, + Buffer.NumberInBuffer, Buffer.NumberPayloadBuffer, + Buffer.InBuffer[0].m_Address, InBuffer, Buffer.InBuffer[0].m_Size, + Buffer.PayloadBuffer[0].m_Address, OutBuffer, Buffer.PayloadBuffer[0].m_Size); + } + else + { + LOG(WII_IPC_ES, "ES Parameter: 0x%x (In: %i, Out:%i) (Out 0x%08x = 0x%08x %i)", + Buffer.Parameter, + Buffer.NumberInBuffer, Buffer.NumberPayloadBuffer, + Buffer.PayloadBuffer[0].m_Address, OutBuffer, Buffer.PayloadBuffer[0].m_Size); + } + //DumpCommands(_CommandAddress, 8); + } */ + // write return value Memory::Write_U32(0, _CommandAddress + 0x4); 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 969fd2bd93..0d27af3721 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 @@ -15,8 +15,13 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ + #include "WII_IPC_HLE_Device_net.h" + +// ********************************************************************************** +// 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) { @@ -29,14 +34,13 @@ CWII_IPC_HLE_Device_net_kd_request::~CWII_IPC_HLE_Device_net_kd_request() bool CWII_IPC_HLE_Device_net_kd_request::Open(u32 _CommandAddress, u32 _Mode) { - Memory::Write_U32(GetDeviceID(), _CommandAddress+4); + //LOG(WII_IPC_NET, "NET_KD_REQ: Open (Command: 0x%02x)", Memory::Read_U32(_CommandAddress)); + Memory::Write_U32(GetDeviceID(), _CommandAddress + 4); return true; } bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress) { - LOG(WII_IPC_NET, "NET_KD_REQ: IOCtl (Device=%s)", GetDeviceName().c_str()); - u32 Parameter = Memory::Read_U32(_CommandAddress + 0xC); u32 BufferIn = Memory::Read_U32(_CommandAddress + 0x10); u32 BufferInSize = Memory::Read_U32(_CommandAddress + 0x14); @@ -44,24 +48,69 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress) u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C); u32 ReturnValue = ExecuteCommand(Parameter, BufferIn, BufferInSize, BufferOut, BufferOutSize); - Memory::Write_U32(ReturnValue, _CommandAddress+4); + + LOG(WII_IPC_NET, "NET_KD_REQ: IOCtl (Device=%s) (Parameter: 0x%02x)", GetDeviceName().c_str(), Parameter); + + 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) { + // Requests are made in this order by these games + // Mario Kart: 2, 1, f, 3 + // SSBB: 2, 3 + + /* Extended logs + //if(_Parameter == 2 || _Parameter == 3) + if(true) + { + u32 OutBuffer = Memory::Read_U32(_BufferOut); + if(_BufferInSize > 0) + { + u32 InBuffer = Memory::Read_U32(_BufferIn); + LOG(WII_IPC_ES, "NET_KD_REQ: IOCtl Parameter: 0x%x (In 0x%08x = 0x%08x %i) (Out 0x%08x = 0x%08x %i)", + _Parameter, + _BufferIn, InBuffer, _BufferInSize, + _BufferOut, OutBuffer, _BufferOutSize); + } + else + { + LOG(WII_IPC_ES, "NET_KD_REQ: IOCtl Parameter: 0x%x (Out 0x%08x = 0x%08x %i)", + _Parameter, + _BufferOut, OutBuffer, _BufferOutSize); + } + }*/ + switch(_Parameter) { + case 1: // SuspendScheduler (Input: none, Output: 32 bytes) + Memory::Write_U32(0, _BufferOut); + break; + case 2: /* ExecTrySuspendScheduler (Input: 32 bytes, Output: 32 bytes). Sounds like it will check + if it should suspend the updates scheduler or not. */ + Memory::Write_U32(1, _BufferOut); + break; + case 3: // ? + Memory::Write_U32(0, _BufferOut); + break; + case 0xf: // NWC24iRequestGenerateUserId (Input: none, Output: 32 bytes) + Memory::Write_U32(0, _BufferOut); + break; default: - LOG(WII_IPC_NET, "CWII_IPC_HLE_Device_net_kd_request::IOCtl: ni 0x%x (iBufferSize: %i, oBufferSize: %i)", _Parameter, _BufferInSize, _BufferOutSize); - _dbg_assert_msg_(WII_IPC_NET, 0, "CWII_IPC_HLE_Device_net_kd_request::IOCtl: ni 0x%x (iBufferSize: %i, oBufferSize: %i)", _Parameter, _BufferInSize, _BufferOutSize); + _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; } + + // Should we always return 0? return 0; } + // ********************************************************************************** +// 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) diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp index 988951e04f..28c5025a66 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_sdio_slot0.cpp @@ -50,12 +50,12 @@ CWII_IPC_HLE_Device_sdio_slot0::Open(u32 _CommandAddress, u32 _Mode) // __________________________________________________________________________________________________ -// +// The front SD slot bool CWII_IPC_HLE_Device_sdio_slot0::IOCtl(u32 _CommandAddress) { - LOG(WII_IPC_HLE, "*************************************"); - LOG(WII_IPC_HLE, "CWII_IPC_HLE_Device_sdio_slot0::IOCtl"); - LOG(WII_IPC_HLE, "*************************************"); + LOG(WII_IPC_FILEIO, "*************************************"); + LOG(WII_IPC_FILEIO, "CWII_IPC_HLE_Device_sdio_slot0::IOCtl"); + LOG(WII_IPC_FILEIO, "*************************************"); // DumpCommands(_CommandAddress); @@ -67,7 +67,7 @@ bool CWII_IPC_HLE_Device_sdio_slot0::IOCtl(u32 _CommandAddress) u32 BufferOut = Memory::Read_U32(_CommandAddress + 0x18); u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C); - LOG(WII_IPC_HLE, "%s - BufferIn(0x%08x, 0x%x) BufferOut(0x%08x, 0x%x)", GetDeviceName().c_str(), BufferIn, BufferInSize, BufferOut, BufferOutSize); + LOG(WII_IPC_FILEIO, "%s - BufferIn(0x%08x, 0x%x) BufferOut(0x%08x, 0x%x)", GetDeviceName().c_str(), BufferIn, BufferInSize, BufferOut, BufferOutSize); u32 ReturnValue = 0; switch (Cmd) { @@ -86,8 +86,13 @@ bool CWII_IPC_HLE_Device_sdio_slot0::IOCtl(u32 _CommandAddress) case 7: //sendcmd ReturnValue = ExecuteCommand(BufferIn, BufferInSize, BufferOut, BufferOutSize); break; + + case 11: // sd_get_status + LOGV(WII_IPC_FILEIO, 0, "SD command: sd_get_status. Answer: SD card is inserted (write 1 to %08x).", BufferOut); + Memory::Write_U32(1, BufferOut); // SD card is inserted? + break; default: - PanicAlert("Unknown SD command"); + PanicAlert("Unknown SD command (0x%08x)", Cmd); break; }