-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Media Engine LLE: add homebrew-focused ME support #21554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
frangarcj
wants to merge
10
commits into
hrydgard:master
Choose a base branch
from
frangarcj:pr/media-engine-lle-homebrew-main
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
70bd8aa
Media Engine LLE: add homebrew-focused Media Engine support
frangarcj 1b13497
Media Engine: add ME CPU windows to ImGui debugger
frangarcj 881aca0
Media Engine: add initial x64 native ME backend
frangarcj 2dc86c4
Media Engine: restore ME witness word after load
frangarcj 491a737
Media Engine: fix x64 ME dispatcher J_CC compile error
frangarcj 57e0504
Media Engine: expose ME core backend selector in Developer Tools UI
frangarcj 64bb9bf
Media Engine: move ME interrupt syscalls to end of table
frangarcj ddd5503
Media Engine: document IsMeSensitiveHwPage hardware register ranges
frangarcj 0c06d0b
ME HLE: use Register_*() pattern with separate files for ME modules
frangarcj 90955c7
Media Engine: consolidate IsMeSensitiveHwPage to MemMapFunctions.cpp
frangarcj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -151,3 +151,4 @@ RAPrefs_PPSSPP.cfg | |
| cmake-build-*/ | ||
|
|
||
| /.vscode/ | ||
| smw.sfc | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -131,6 +131,16 @@ static void sceKernelCpuResumeIntrWithSync(u32 enable) | |
|
|
||
| bool IntrHandler::run(PendingInterrupt& pend) | ||
| { | ||
| if (pend.subintr == PSP_INTR_SUB_NONE) { | ||
| if (baseHandlerAddress_ == 0 || !baseEnabled_) { | ||
| WARN_LOG(Log::sceIntc, "Ignoring base interrupt %d without enabled handler.", pend.intr); | ||
| return false; | ||
| } | ||
|
|
||
| copyArgsToCPU(pend); | ||
| return true; | ||
| } | ||
|
|
||
| SubIntrHandler *handler = get(pend.subintr); | ||
| if (!handler) { | ||
| WARN_LOG(Log::sceIntc, "Ignoring interrupt, already been released."); | ||
|
|
@@ -144,6 +154,14 @@ bool IntrHandler::run(PendingInterrupt& pend) | |
|
|
||
| void IntrHandler::copyArgsToCPU(PendingInterrupt& pend) | ||
| { | ||
| if (pend.subintr == PSP_INTR_SUB_NONE) { | ||
| DEBUG_LOG(Log::CPU, "Entering base interrupt handler %08x", baseHandlerAddress_); | ||
| currentMIPS->pc = baseHandlerAddress_; | ||
| currentMIPS->r[MIPS_REG_A0] = pend.intr; | ||
| currentMIPS->r[MIPS_REG_A1] = baseHandlerArg_; | ||
| return; | ||
| } | ||
|
|
||
| SubIntrHandler* handler = get(pend.subintr); | ||
| DEBUG_LOG(Log::CPU, "Entering interrupt handler %08x", handler->handlerAddress); | ||
| currentMIPS->pc = handler->handlerAddress; | ||
|
|
@@ -189,11 +207,35 @@ SubIntrHandler* IntrHandler::get(int subIntrNum) | |
| } | ||
| void IntrHandler::clear() | ||
| { | ||
| baseEnabled_ = false; | ||
| baseHandlerAddress_ = 0; | ||
| baseHandlerArg_ = 0; | ||
| subIntrHandlers.clear(); | ||
| } | ||
|
|
||
| void IntrHandler::setBase(u32 handlerAddress, u32 handlerArg) { | ||
| baseHandlerAddress_ = handlerAddress; | ||
| baseHandlerArg_ = handlerArg; | ||
| } | ||
|
|
||
| void IntrHandler::clearBase() { | ||
| baseEnabled_ = false; | ||
| baseHandlerAddress_ = 0; | ||
| baseHandlerArg_ = 0; | ||
| } | ||
|
|
||
| void IntrHandler::enableBase() { | ||
| baseEnabled_ = true; | ||
| } | ||
|
|
||
| void IntrHandler::disableBase() { | ||
| baseEnabled_ = false; | ||
| } | ||
|
|
||
| void IntrHandler::queueUp(int subintr) { | ||
| if (subintr == PSP_INTR_SUB_NONE) { | ||
| // Always queue here. Derived handlers may override run(), and the base | ||
| // handler check belongs in IntrHandler::run(). | ||
| pendingInterrupts.push_back(PendingInterrupt(intrNumber, subintr)); | ||
| } else { | ||
| // Just call execute on all the subintr handlers for this interrupt. | ||
|
|
@@ -590,6 +632,50 @@ static int QueryIntrHandlerInfo() | |
| return 0; | ||
| } | ||
|
|
||
| static u32 sceKernelRegisterIntrHandler(u32 intrNumber, u32 unknown, u32 handler, u32 handlerArg, u32 subCount) { | ||
| (void)unknown; | ||
| (void)subCount; | ||
| if (intrNumber >= PSP_NUMBER_INTERRUPTS) { | ||
| return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_INTRCODE, "invalid interrupt"); | ||
| } | ||
| IntrHandler *intr = intrHandlers[intrNumber]; | ||
| if (handler == 0) { | ||
| return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_ADDR, "NULL handler"); | ||
| } | ||
| if (intr == nullptr) { | ||
| return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_INTRCODE, "missing interrupt"); | ||
| } | ||
| if (intrNumber == PSP_MECODEC_INTR) { | ||
| DEBUG_LOG(Log::sceIntc, "Registering base handler for MECODEC intr at %08x", handler); | ||
| } | ||
| intr->setBase(handler, handlerArg); | ||
| return hleLogDebug(Log::sceIntc, 0); | ||
| } | ||
|
|
||
| static u32 sceKernelReleaseIntrHandler(u32 intrNumber) { | ||
| if (intrNumber >= PSP_NUMBER_INTERRUPTS) { | ||
| return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_INTRCODE, "invalid interrupt"); | ||
| } | ||
| IntrHandler *intr = intrHandlers[intrNumber]; | ||
| if (intr == nullptr) { | ||
| return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_INTRCODE, "missing interrupt"); | ||
| } | ||
| intr->clearBase(); | ||
| return hleLogDebug(Log::sceIntc, 0); | ||
| } | ||
|
|
||
| static u32 sceKernelEnableIntr(u32 intrNumber) { | ||
| if (intrNumber >= PSP_NUMBER_INTERRUPTS) { | ||
| return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_INTRCODE, "invalid interrupt"); | ||
| } | ||
| IntrHandler *intr = intrHandlers[intrNumber]; | ||
| if (intr == nullptr) { | ||
| return hleLogError(Log::sceIntc, SCE_KERNEL_ERROR_ILLEGAL_INTRCODE, "missing interrupt"); | ||
| } | ||
| intr->enableBase(); | ||
| return hleLogDebug(Log::sceIntc, 0); | ||
| } | ||
|
|
||
| static u32 sceKernelMemset(u32 addr, u32 fillc, u32 n) { | ||
| u8 c = fillc & 0xff; | ||
| bool skip = false; | ||
|
|
@@ -1053,6 +1139,10 @@ const HLEFunction InterruptManagerForKernel[] = | |
| {0XFA835CDE, &WrapI_I<sceKernelGetTlsAddr>, "sceKernelGetTlsAddr", 'i', "i" ,HLE_KERNEL_SYSCALL }, | ||
| {0X05572A5F, &WrapV_V<sceKernelExitGame>, "sceKernelExitGame", 'v', "" ,HLE_KERNEL_SYSCALL }, | ||
| {0X4AC57943, &WrapI_I<sceKernelRegisterExitCallback>, "sceKernelRegisterExitCallback", 'i', "i" ,HLE_KERNEL_SYSCALL }, | ||
| // Media Engine base interrupt handlers (added at end to preserve syscall numbering). | ||
| {0XF987B1F0, &WrapU_U<sceKernelReleaseIntrHandler>, "sceKernelReleaseIntrHandler", 'x', "x" ,HLE_KERNEL_SYSCALL }, | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add new functions at the end of the list. |
||
| {0X58DD8978, &WrapU_UUUUU<sceKernelRegisterIntrHandler>, "sceKernelRegisterIntrHandler", 'x', "xxxxx",HLE_KERNEL_SYSCALL }, | ||
| {0X4D6E7305, &WrapU_U<sceKernelEnableIntr>, "sceKernelEnableIntr", 'x', "x" ,HLE_KERNEL_SYSCALL }, | ||
| }; | ||
|
|
||
| void Register_InterruptManagerForKernel() | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // Copyright (c) 2012- PPSSPP Project. | ||
|
|
||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, version 2.0 or later versions. | ||
|
|
||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License 2.0 for more details. | ||
|
|
||
| // A copy of the GPL 2.0 should have been included with the program. | ||
| // If not, see http://www.gnu.org/licenses/ | ||
|
|
||
| // Official git repository and contact information can be found at | ||
| // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. | ||
|
|
||
| #include "Core/HLE/HLE.h" | ||
| #include "Core/HLE/FunctionWrappers.h" | ||
|
|
||
| static u32 sceMeBootStartStub(u32 arg) { return 0; } | ||
|
|
||
| const HLEFunction sceMeCore_driver[] = { | ||
| {0X47DB48C2, &WrapU_U<sceMeBootStartStub>, "sceMeBootStart", 'x', "x" }, | ||
| {0XC287AD90, &WrapU_U<sceMeBootStartStub>, "sceMeBootStart371", 'x', "x" }, | ||
| {0XD857CF93, &WrapU_U<sceMeBootStartStub>, "sceMeBootStart380", 'x', "x" }, | ||
| {0X8988AD49, &WrapU_U<sceMeBootStartStub>, "sceMeBootStart395", 'x', "x" }, | ||
| {0X051C1601, &WrapU_U<sceMeBootStartStub>, "sceMeBootStart500", 'x', "x" }, | ||
| {0X3A2E60BB, &WrapU_U<sceMeBootStartStub>, "sceMeBootStart620", 'x', "x" }, | ||
| {0X99E4DBFA, &WrapU_U<sceMeBootStartStub>, "sceMeBootStart635", 'x', "x" }, | ||
| {0X5DFF5C50, &WrapU_U<sceMeBootStartStub>, "sceMeBootStart660", 'x', "x" }, | ||
| }; | ||
|
|
||
| void Register_sceMeCore_driver() { | ||
| RegisterHLEModule("sceMeCore_driver", ARRAY_SIZE(sceMeCore_driver), sceMeCore_driver); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| // Copyright (c) 2012- PPSSPP Project. | ||
|
|
||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, version 2.0 or later versions. | ||
|
|
||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License 2.0 for more details. | ||
|
|
||
| // A copy of the GPL 2.0 should have been included with the program. | ||
| // If not, see http://www.gnu.org/licenses/ | ||
|
|
||
| // Official git repository and contact information can be found at | ||
| // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. | ||
|
|
||
| #pragma once | ||
|
|
||
| void Register_sceMeCore_driver(); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use this moduleList thing. Instead, make new Register_...() functions, and importantly, call them at the end of RegisterAllModules.
Otherwise syscall module numbering gets messed up which breaks save state compatibility.