Move more core-related stuff into Core.cpp/h

This commit is contained in:
Henrik Rydgård
2024-12-08 11:54:58 +01:00
parent df91f699fc
commit 83af54950f
24 changed files with 62 additions and 96 deletions
+11
View File
@@ -78,6 +78,11 @@ static int steppingCounter = 0;
static std::set<CoreLifecycleFunc> lifecycleFuncs;
static std::set<CoreStopRequestFunc> stopFuncs;
// This can be read and written from ANYWHERE.
volatile CoreState coreState = CORE_STEPPING_CPU;
// If true, core state has been changed, but JIT has probably not noticed yet.
volatile bool coreStatePending = false;
static bool powerSaving = false;
static MIPSExceptionInfo g_exceptionInfo;
@@ -124,6 +129,12 @@ bool Core_MustRunBehind() {
return __NetAdhocConnected();
}
void Core_UpdateState(CoreState newState) {
if ((coreState == CORE_RUNNING_CPU || coreState == CORE_NEXTFRAME) && newState != CORE_RUNNING_CPU)
coreStatePending = true;
coreState = newState;
}
bool Core_IsStepping() {
return coreState == CORE_STEPPING_CPU || coreState == CORE_POWERDOWN;
}
+29
View File
@@ -81,6 +81,28 @@ enum class CoreLifecycle {
MEMORY_REINITED,
};
// RUNNING must be at 0, NEXTFRAME must be at 1.
enum CoreState {
// Emulation is running normally.
CORE_RUNNING_CPU = 0,
// Emulation was running normally, just reached the end of a frame.
CORE_NEXTFRAME = 1,
// Emulation is paused, CPU thread is sleeping.
CORE_STEPPING_CPU, // Can be used for recoverable runtime errors (ignored memory exceptions)
// Core is being powered up.
CORE_POWERUP,
// Core is being powered down.
CORE_POWERDOWN,
// An error happened at boot.
CORE_BOOT_ERROR,
// Unrecoverable runtime error. Recoverable errors should use CORE_STEPPING.
CORE_RUNTIME_ERROR,
// Stepping the GPU. When done, will switch over to STEPPING_CPU.
CORE_STEPPING_GE,
// Running the GPU. When done, will switch over to RUNNING_CPU.
CORE_RUNNING_GE,
};
// Callback is called on the Emu thread.
typedef void (* CoreLifecycleFunc)(CoreLifecycle stage);
void Core_ListenLifecycle(CoreLifecycleFunc func);
@@ -104,6 +126,13 @@ bool Core_GetPowerSaving();
void Core_RunLoopUntil(u64 globalticks);
const char *CoreStateToString(CoreState state);
extern volatile CoreState coreState;
extern volatile bool coreStatePending;
void Core_UpdateState(CoreState newState);
enum class MemoryExceptionType {
NONE,
UNKNOWN,
-1
View File
@@ -594,7 +594,6 @@
<ClCompile Include="MIPS\ARM64\Arm64IRRegCache.cpp" />
<ClCompile Include="MIPS\fake\FakeJit.cpp" />
<ClCompile Include="MIPS\IR\IRAnalysis.cpp" />
<ClCompile Include="MIPS\IR\IRAsm.cpp" />
<ClCompile Include="MIPS\IR\IRCompALU.cpp" />
<ClCompile Include="MIPS\IR\IRCompBranch.cpp" />
<ClCompile Include="MIPS\IR\IRCompFPU.cpp" />
-3
View File
@@ -658,9 +658,6 @@
<ClCompile Include="FileLoaders\RamCachingFileLoader.cpp">
<Filter>FileLoaders</Filter>
</ClCompile>
<ClCompile Include="MIPS\IR\IRAsm.cpp">
<Filter>MIPS\IR</Filter>
</ClCompile>
<ClCompile Include="MIPS\IR\IRCompALU.cpp">
<Filter>MIPS\IR</Filter>
</ClCompile>
@@ -101,7 +101,7 @@ WebSocketGPUStatsState::WebSocketGPUStatsState() {
WebSocketGPUStatsState::~WebSocketGPUStatsState() {
if (forced_)
Core_ForceDebugStats(false);
PSP_ForceDebugStats(false);
__DisplayForgetFlip(&WebSocketGPUStatsState::FlipForwarder, this);
}
@@ -178,7 +178,7 @@ void WebSocketGPUStatsState::Feed(DebuggerRequest &req) {
std::lock_guard<std::mutex> guard(pendingLock_);
sendFeed_ = enable;
if (forced_ != enable) {
Core_ForceDebugStats(enable);
PSP_ForceDebugStats(enable);
forced_ = enable;
}
}
+1 -1
View File
@@ -20,7 +20,7 @@
#include "Core/FileSystems/MetaFileSystem.h"
#include "Core/MemMapHelpers.h"
#include "Core/Reporting.h"
#include "Core/System.h"
#include "Core/Core.h"
#include "Core/Font/PGF.h"
enum {
+1
View File
@@ -21,6 +21,7 @@
#include <set>
#include <mutex>
#include "Core/Core.h"
#include "Core/ThreadEventQueue.h"
class NoBase {
+1 -1
View File
@@ -31,7 +31,7 @@
#include "Core/PSPLoaders.h"
#include "Core/MemMap.h"
#include "Core/Loaders.h"
#include "Core/System.h"
#include "Core/Core.h"
#include "Core/ELF/PBPReader.h"
#include "Core/ELF/ParamSFO.h"
+1 -1
View File
@@ -20,7 +20,7 @@
#include "Core/MemMap.h"
#include "Core/MIPS/MIPS.h"
#include "Core/System.h"
#include "Core/Core.h"
#include "Core/CoreTiming.h"
#include "Common/MemoryUtil.h"
#include "Common/CPUDetect.h"
+1 -1
View File
@@ -25,7 +25,7 @@
#include "Common/Arm64Emitter.h"
#include "Core/MemMap.h"
#include "Core/MIPS/MIPS.h"
#include "Core/System.h"
#include "Core/Core.h"
#include "Core/CoreTiming.h"
#include "Core/MIPS/ARM64/Arm64Jit.h"
#include "Core/MIPS/JitCommon/JitCommon.h"
+1 -1
View File
@@ -26,7 +26,7 @@
#include "Core/MIPS/ARM64/Arm64IRRegCache.h"
#include "Core/MIPS/JitCommon/JitCommon.h"
#include "Core/MIPS/JitCommon/JitState.h"
#include "Core/System.h"
#include "Core/Core.h"
namespace MIPSComp {
-27
View File
@@ -1,27 +0,0 @@
// Copyright (c) 2015- 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 "Common/Log.h"
#include "Common/MemoryUtil.h"
#include "Core/MemMap.h"
#include "Core/MIPS/MIPS.h"
#include "Core/System.h"
#include "Core/CoreTiming.h"
#include "Core/MIPS/IR/IRJit.h"
#include "Core/MIPS/JitCommon/JitCommon.h"
+1 -1
View File
@@ -33,7 +33,7 @@
#include "Core/MIPS/MIPSVFPUUtils.h"
#include "Core/MIPS/IR/IRJit.h"
#include "Core/Reporting.h"
#include "Core/System.h"
#include "Core/Core.h"
#include "Core/MIPS/JitCommon/JitCommon.h"
#include "Core/CoreTiming.h"
+1 -1
View File
@@ -33,7 +33,7 @@
#include "Core/MemMap.h"
#include "Core/MIPS/MIPSTables.h"
#include "Core/MIPS/MIPS.h"
#include "Core/System.h"
#include "Core/Core.h"
enum ReferenceIndexType {
REF_INDEX_PC = 32,
+1 -1
View File
@@ -22,7 +22,7 @@
#include "Core/MIPS/RiscV/RiscVRegCache.h"
#include "Core/MIPS/JitCommon/JitCommon.h"
#include "Core/MIPS/JitCommon/JitState.h"
#include "Core/System.h"
#include "Core/Core.h"
namespace MIPSComp {
+1 -1
View File
@@ -25,7 +25,7 @@
#include "Core/MIPS/x86/X64IRRegCache.h"
#include "Core/MIPS/JitCommon/JitCommon.h"
#include "Core/MIPS/JitCommon/JitState.h"
#include "Core/System.h"
#include "Core/Core.h"
namespace MIPSComp {
+2 -13
View File
@@ -93,11 +93,6 @@ static std::mutex loadingLock;
bool coreCollectDebugStats = false;
static int coreCollectDebugStatsCounter = 0;
// This can be read and written from ANYWHERE.
volatile CoreState coreState = CORE_STEPPING_CPU;
// If true, core state has been changed, but JIT has probably not noticed yet.
volatile bool coreStatePending = false;
static volatile CPUThreadState cpuThreadState = CPU_THREAD_NOT_RUNNING;
static GPUBackend gpuBackend;
@@ -373,13 +368,7 @@ void UpdateLoadedFile(FileLoader *fileLoader) {
g_loadedFile = fileLoader;
}
void Core_UpdateState(CoreState newState) {
if ((coreState == CORE_RUNNING_CPU || coreState == CORE_NEXTFRAME) && newState != CORE_RUNNING_CPU)
coreStatePending = true;
coreState = newState;
}
void Core_UpdateDebugStats(bool collectStats) {
void PSP_UpdateDebugStats(bool collectStats) {
bool newState = collectStats || coreCollectDebugStatsCounter > 0;
if (coreCollectDebugStats != newState) {
coreCollectDebugStats = newState;
@@ -392,7 +381,7 @@ void Core_UpdateDebugStats(bool collectStats) {
}
}
void Core_ForceDebugStats(bool enable) {
void PSP_ForceDebugStats(bool enable) {
if (enable) {
coreCollectDebugStatsCounter++;
} else {
+2 -30
View File
@@ -92,9 +92,9 @@ struct PSP_LoadingLock {
};
// Call before PSP_BeginHostFrame() in order to not miss any GPU stats.
void Core_UpdateDebugStats(bool collectStats);
void PSP_UpdateDebugStats(bool collectStats);
// Increments or decrements an internal counter. Intended to be used by debuggers.
void Core_ForceDebugStats(bool enable);
void PSP_ForceDebugStats(bool enable);
void UpdateLoadedFile(FileLoader *fileLoader);
@@ -104,36 +104,8 @@ Path GetSysDirectory(PSPDirectories directoryType);
bool CreateSysDirectories();
// RUNNING must be at 0, NEXTFRAME must be at 1.
enum CoreState {
// Emulation is running normally.
CORE_RUNNING_CPU = 0,
// Emulation was running normally, just reached the end of a frame.
CORE_NEXTFRAME = 1,
// Emulation is paused, CPU thread is sleeping.
CORE_STEPPING_CPU, // Can be used for recoverable runtime errors (ignored memory exceptions)
// Core is being powered up.
CORE_POWERUP,
// Core is being powered down.
CORE_POWERDOWN,
// An error happened at boot.
CORE_BOOT_ERROR,
// Unrecoverable runtime error. Recoverable errors should use CORE_STEPPING.
CORE_RUNTIME_ERROR,
// Stepping the GPU. When done, will switch over to STEPPING_CPU.
CORE_STEPPING_GE,
// Running the GPU. When done, will switch over to RUNNING_CPU.
CORE_RUNNING_GE,
};
const char *CoreStateToString(CoreState state);
extern bool coreCollectDebugStats;
extern volatile CoreState coreState;
extern volatile bool coreStatePending;
void Core_UpdateState(CoreState newState);
inline CoreParameter &PSP_CoreParameter() {
extern CoreParameter g_CoreParameter;
return g_CoreParameter;
+1 -1
View File
@@ -38,7 +38,7 @@
#include "Common/System/OSD.h"
#include "Common/Log.h"
#include "Core/Config.h"
#include "Core/System.h"
#include "Core/Core.h"
#include "Core/ELF/ParamSFO.h"
#include "Core/Util/PortManager.h"
+1 -2
View File
@@ -28,9 +28,8 @@
#include "Core/Config.h"
#include "Core/Debugger/Breakpoints.h"
#include "Core/MemMapHelpers.h"
#include "Core/Config.h"
#include "Core/Reporting.h"
#include "Core/System.h"
#include "Core/Core.h"
#include "Core/ELF/ParamSFO.h"
#include "GPU/GPUState.h"
+1 -1
View File
@@ -1523,7 +1523,7 @@ ScreenRenderFlags EmuScreen::render(ScreenRenderMode mode) {
}
}
Core_UpdateDebugStats((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::DEBUG_STATS || g_Config.bLogFrameDrops);
PSP_UpdateDebugStats((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::DEBUG_STATS || g_Config.bLogFrameDrops);
if (doFrameAdvance_.exchange(false)) {
if (!Achievements::WarnUserIfHardcoreModeActive(false)) {
+1 -2
View File
@@ -554,7 +554,6 @@
<ClCompile Include="..\..\Core\MIPS\ARM\ArmJit.cpp" />
<ClCompile Include="..\..\Core\MIPS\ARM\ArmRegCache.cpp" />
<ClCompile Include="..\..\Core\MIPS\ARM\ArmRegCacheFPU.cpp" />
<ClCompile Include="..\..\Core\MIPS\IR\IRAsm.cpp" />
<ClCompile Include="..\..\Core\MIPS\IR\IRCompALU.cpp" />
<ClCompile Include="..\..\Core\MIPS\IR\IRCompBranch.cpp" />
<ClCompile Include="..\..\Core\MIPS\IR\IRCompFPU.cpp" />
@@ -1023,4 +1022,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
+1 -4
View File
@@ -645,9 +645,6 @@
<ClCompile Include="..\..\ext\xxhash.c">
<Filter>Ext</Filter>
</ClCompile>
<ClCompile Include="..\..\Core\MIPS\IR\IRAsm.cpp">
<Filter>MIPS\IR</Filter>
</ClCompile>
<ClCompile Include="..\..\Core\MIPS\IR\IRCompALU.cpp">
<Filter>MIPS\IR</Filter>
</ClCompile>
@@ -1906,4 +1903,4 @@
<Filter>Ext\gason</Filter>
</None>
</ItemGroup>
</Project>
</Project>
+1 -1
View File
@@ -232,7 +232,7 @@ bool RunAutoTest(HeadlessHost *headlessHost, CoreParameter &coreParameter, const
System_Notify(SystemNotification::BOOT_DONE);
Core_UpdateDebugStats((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::DEBUG_STATS || g_Config.bLogFrameDrops);
PSP_UpdateDebugStats((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::DEBUG_STATS || g_Config.bLogFrameDrops);
PSP_BeginHostFrame();
Draw::DrawContext *draw = coreParameter.graphicsContext ? coreParameter.graphicsContext->GetDrawContext() : nullptr;