ME: Syscalls to the firmware's cache functions do nothing

Kernel code the ME runs calls a few firmware functions directly: POPS's
ME loop calls sceKernelDcacheWritebackInvalidateAll for every sample. On
a PSP the loader links kernel imports as direct jumps, so the ME runs
the function's code; here they're HLE syscall stubs. The cache functions
only work on the calling CPU's caches, and the ME's aren't emulated,
so they return 0 and do nothing, as does an unresolved import (as on
the main CPU). Others are still an error, now naming the function.

The IR ends the block after one, as for a syscall on the main CPU: a jr
with it in its delay slot leaves the exit to it, and the ME ran on into
the next stub.

A syscall instruction of the ME's own should take its exception vector
(ExcCode 8); none has come up yet.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-10-21 12:50:46 +02:00
1 parent 6936d22b38
commit bafdb45128
4 files changed
+53 -5

No files matched your search

+16 -2
View File
@@ -24,6 +24,7 @@
#include "Core/HLE/HLETables.h"
#include "Core/MIPS/MIPS.h"
#include "Core/MIPS/MeCore.h"
#include "Core/MIPS/MIPSCodeUtils.h"
#include "Core/MIPS/MIPSAnalyst.h"
#include "Core/MIPS/MIPSTables.h"
@@ -464,8 +465,21 @@ void IRFrontend::Comp_JumpReg(MIPSOpcode op) {
void IRFrontend::Comp_Syscall(MIPSOpcode op) {
if (IsMediaEngine()) {
// There's no HLE on the ME, the interpreter traps it.
Comp_Generic(op);
// There's no HLE on the ME. A call to a stub that does nothing there returns 0, ending the
// block as a syscall does on the main CPU (a jr with it in its delay slot leaves the exit to
// it); the interpreter traps the rest.
if (!MeCore::SyscallDoesNothing(op, GetCompilerPC())) {
Comp_Generic(op);
return;
}
ir.Write(IROp::Downcount, 0, 0, 0, js.downcountAmount);
js.downcountAmount = 0;
if (!js.inDelaySlot)
ir.Write(IROp::SetPCConst, 0, 0, 0, GetCompilerPC() + 4);
ir.WriteSetConstant(MIPS_REG_V0, 0);
FlushAll();
ir.Write(IROp::ExitToPC);
js.compiling = false;
return;
}
// Like the interpreter, the syscall sees every earlier instruction charged (including a branch it's