IOS LLE: optional IPC request/reply metadata trace (StarletOS phase 11 L2)

With DOLPHIN_IPC_TRACE=1 and the original IOS on the emulated Starlet, log
each request Broadway posts (X1: command, descriptor, argument words, an
OPEN's path) and each reply Starlet posts (Y1: original command, result).
Buffer contents are never read; nothing changes without the variable.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Yaya48andClaude Opus 5.5 committed 2026-10-06 18:40:56 +02:00
1 parent 78738093ec
commit cd8c8cedca
4 files changed
+107 -1

No files matched your search

+58
View File
@@ -3,6 +3,9 @@
#include "Core/HW/WII_IPC.h"
#include <cstdlib>
#include <string>
#include "Common/ChunkFile.h"
#include "Common/CommonTypes.h"
#include "Common/Logging/Log.h"
@@ -10,6 +13,7 @@
#include "Core/CoreTiming.h"
#include "Core/HW/DVD/DVDInterface.h"
#include "Core/HW/MMIO.h"
#include "Core/HW/Memmap.h"
#include "Core/HW/ProcessorInterface.h"
#include "Core/IOS/IOS.h"
#include "Core/IOS/Starlet/Starlet.h"
@@ -142,6 +146,55 @@ void WiiIPC::Shutdown()
{
}
namespace
{
// StarletOS phase 11 (proposal L2): with DOLPHIN_IPC_TRACE=1 while the original IOS runs on the
// emulated Starlet, each IPC request Broadway posts (X1) and each reply Starlet posts (Y1) is
// logged with its metadata only: the command, the descriptor and the five argument words (an
// OPEN's path), then the reply's result. Buffer contents are never read.
bool IPCTraceEnabled()
{
static const bool enabled = [] {
const char* value = std::getenv("DOLPHIN_IPC_TRACE");
return value != nullptr && value[0] == '1';
}();
return enabled;
}
void TraceIPCRequest(Core::System& system, u32 address)
{
auto& memory = system.GetMemory();
if (memory.GetPointerForRange(address, 0x20) == nullptr)
{
NOTICE_LOG_FMT(WII_IPC, "IPCTRACE RQ {:08x} unreadable", address);
return;
}
const u32 command = memory.Read_U32(address);
const u32 fd = memory.Read_U32(address + 8);
u32 arg[5];
for (u32 i = 0; i < 5; ++i)
arg[i] = memory.Read_U32(address + 0xc + 4 * i);
std::string path;
if (command == 1 && memory.GetPointerForRange(arg[0], 64) != nullptr)
path = " P " + memory.GetString(arg[0], 64);
NOTICE_LOG_FMT(WII_IPC, "IPCTRACE RQ {:08x} C {} FD {} A {:08x} {:08x} {:08x} {:08x} {:08x}{}",
address, command, static_cast<s32>(fd), arg[0], arg[1], arg[2], arg[3], arg[4],
path);
}
void TraceIPCReply(Core::System& system, u32 address)
{
auto& memory = system.GetMemory();
if (memory.GetPointerForRange(address, 0x10) == nullptr)
{
NOTICE_LOG_FMT(WII_IPC, "IPCTRACE RP {:08x} unreadable", address);
return;
}
NOTICE_LOG_FMT(WII_IPC, "IPCTRACE RP {:08x} C {} RC {}", address, memory.Read_U32(address + 8),
static_cast<s32>(memory.Read_U32(address + 4)));
}
} // namespace
void WiiIPC::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
{
// Both IPC message registers are general-purpose read/write registers on
@@ -168,6 +221,8 @@ void WiiIPC::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
wii_ipc.m_ppc_irq_flags |= INT_CAUSE_IPC_BROADWAY;
if (wii_ipc.m_ctrl.X1)
{
if (system.GetStarlet() && IPCTraceEnabled() && (val >> 0 & 1))
TraceIPCRequest(system, wii_ipc.m_ppc_msg);
if (system.GetStarlet())
wii_ipc.m_arm_irq_flags |= INT_CAUSE_IPC_STARLET;
else if (system.GetIOS())
@@ -386,6 +441,9 @@ void WiiIPC::WriteStarletRegister(u32 offset, u32 value)
break;
case IPC_ARMCTRL:
m_ctrl.arm(value);
// StarletOS phase 11: Y1 (bit 0) posts the reply whose pointer is in ARMMSG.
if (IPCTraceEnabled() && (value & 1))
TraceIPCReply(m_system, m_arm_msg);
break;
case PPC_IRQFLAG:
m_ppc_irq_flags &= ~value;