CPU: Add the Media Engine core, off by default

MeCore owns a second MIPSState in the ME's address space, held in reset
until released (SetReset). It runs on the interpreter, a slice behind the
main CPU: CoreTiming runs it for the cycles the main CPU has just used, in
Advance and ForceCheck. Its own PRId (COP0 22) and mfic/mtic flag; MMIO
counts as kernel mode on it, and a syscall stops it with an error rather
than reaching HLE. The interpreter's block stepping reads delay slots
through the stepping CPU's memory, and cache instructions log at verbose
level, as ME code flushes its caches in a loop.

Created at boot only for homebrew (PBP with MG category or no SFO, ELF;
the VSH counts, as vshmain.prx loads as an ELF), when "Enable ME
emulation for homebrew" is on: a global checkbox in developer settings,
off by default and not translated yet, or --me-core. Saved in its own
section after MMIO (SaveStart v5), with its own memory; loading a state
creates or removes the ME to match.

The boot page now starts with a reset stub that sends the ME on to
0xBFC00040, where homebrew puts its code (from the firmware's reset code,
read on a PSP-1000).

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-20 22:22:40 +02:00
1 parent 41851007a2
commit fef84cf0ca
26 files changed
+377 -10

No files matched your search

+8 -1
View File
@@ -61,6 +61,7 @@
#include "Core/HLE/sceUtility.h"
#include "Core/HW/Display.h"
#include "Core/HW/MMIO.h"
#include "Core/MIPS/MeCore.h"
#include "Core/Config.h"
#include "Core/Core.h"
#include "Core/Util/PathUtil.h"
@@ -383,6 +384,7 @@ static bool CPU_Init(FileLoader *fileLoader, IdentifiedFileType type, std::strin
std::string geDumpDiscID;
std::string gameTitle = "Unidentified PSP title";
bool homebrew = false;
switch (type) {
case IdentifiedFileType::PSP_ISO:
@@ -437,7 +439,7 @@ static bool CPU_Init(FileLoader *fileLoader, IdentifiedFileType type, std::strin
// would, and the program would then overwrite its own heap and stacks.
// Homebrew is identified by the MG ("memory stick game") category, or no PARAM.SFO at all.
// (g_paramSFO only gets a few keys copied over for a PBP, so the category is in the raw copy.)
const bool homebrew = !hasSFO || g_paramSFORaw.GetValueString("CATEGORY") == "MG";
homebrew = !hasSFO || g_paramSFORaw.GetValueString("CATEGORY") == "MG";
if (homebrew && Memory::g_PSPModel != PSP_MODEL_FAT && Memory::g_MemorySize == Memory::RAM_NORMAL_SIZE) {
INFO_LOG(Log::Loader, "Homebrew PBP: mapping the PSP-2000 extra RAM, outside the user partition");
Memory::g_MemorySize = Memory::RAM_DOUBLE_SIZE;
@@ -446,6 +448,7 @@ static bool CPU_Init(FileLoader *fileLoader, IdentifiedFileType type, std::strin
break;
}
case IdentifiedFileType::PSP_ELF:
homebrew = true;
if (Memory::g_PSPModel != PSP_MODEL_FAT) {
INFO_LOG(Log::Loader, "ELF, using full PSP-2000 memory access");
Memory::g_MemorySize = Memory::RAM_DOUBLE_SIZE;
@@ -554,6 +557,9 @@ static bool CPU_Init(FileLoader *fileLoader, IdentifiedFileType type, std::strin
CoreTiming::Init(&mipsr4k);
MMIO::Init();
if (MeCore::Wanted(homebrew)) {
MeCore::Init();
}
DisplayHWInit();
@@ -678,6 +684,7 @@ void CPU_Shutdown(bool success) {
Replacement_Shutdown();
CoreTiming::Shutdown();
MeCore::Shutdown();
MMIO::Shutdown();
__KernelShutdown();
HLEShutdown();