diff --git a/Core/Core.cpp b/Core/Core.cpp index e24d6ea401..46bf78a70e 100644 --- a/Core/Core.cpp +++ b/Core/Core.cpp @@ -78,6 +78,11 @@ static int steppingCounter = 0; static std::set lifecycleFuncs; static std::set 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; } diff --git a/Core/Core.h b/Core/Core.h index 976ca04372..3c7bf80bae 100644 --- a/Core/Core.h +++ b/Core/Core.h @@ -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, diff --git a/Core/Core.vcxproj b/Core/Core.vcxproj index b73d036daf..3b4dc630e8 100644 --- a/Core/Core.vcxproj +++ b/Core/Core.vcxproj @@ -594,7 +594,6 @@ - diff --git a/Core/Core.vcxproj.filters b/Core/Core.vcxproj.filters index e00f5b24ba..8dcc3c8b93 100644 --- a/Core/Core.vcxproj.filters +++ b/Core/Core.vcxproj.filters @@ -658,9 +658,6 @@ FileLoaders - - MIPS\IR - MIPS\IR diff --git a/Core/Debugger/WebSocket/GPUStatsSubscriber.cpp b/Core/Debugger/WebSocket/GPUStatsSubscriber.cpp index 1135ad98a2..fec2a565a4 100644 --- a/Core/Debugger/WebSocket/GPUStatsSubscriber.cpp +++ b/Core/Debugger/WebSocket/GPUStatsSubscriber.cpp @@ -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 guard(pendingLock_); sendFeed_ = enable; if (forced_ != enable) { - Core_ForceDebugStats(enable); + PSP_ForceDebugStats(enable); forced_ = enable; } } diff --git a/Core/HLE/sceFont.cpp b/Core/HLE/sceFont.cpp index 0715a40dc7..3d39d02bd0 100644 --- a/Core/HLE/sceFont.cpp +++ b/Core/HLE/sceFont.cpp @@ -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 { diff --git a/Core/HW/AsyncIOManager.h b/Core/HW/AsyncIOManager.h index 54d24eb047..e1f03527ab 100644 --- a/Core/HW/AsyncIOManager.h +++ b/Core/HW/AsyncIOManager.h @@ -21,6 +21,7 @@ #include #include +#include "Core/Core.h" #include "Core/ThreadEventQueue.h" class NoBase { diff --git a/Core/Loaders.cpp b/Core/Loaders.cpp index b7ec039512..f4b906d0e8 100644 --- a/Core/Loaders.cpp +++ b/Core/Loaders.cpp @@ -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" diff --git a/Core/MIPS/ARM/ArmAsm.cpp b/Core/MIPS/ARM/ArmAsm.cpp index 2b00b1573a..6773e01123 100644 --- a/Core/MIPS/ARM/ArmAsm.cpp +++ b/Core/MIPS/ARM/ArmAsm.cpp @@ -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" diff --git a/Core/MIPS/ARM64/Arm64Asm.cpp b/Core/MIPS/ARM64/Arm64Asm.cpp index 727f26a7cf..245d99c2e1 100644 --- a/Core/MIPS/ARM64/Arm64Asm.cpp +++ b/Core/MIPS/ARM64/Arm64Asm.cpp @@ -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" diff --git a/Core/MIPS/ARM64/Arm64IRAsm.cpp b/Core/MIPS/ARM64/Arm64IRAsm.cpp index 7783045b08..fd518d4a35 100644 --- a/Core/MIPS/ARM64/Arm64IRAsm.cpp +++ b/Core/MIPS/ARM64/Arm64IRAsm.cpp @@ -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 { diff --git a/Core/MIPS/IR/IRAsm.cpp b/Core/MIPS/IR/IRAsm.cpp deleted file mode 100644 index 38d40469d8..0000000000 --- a/Core/MIPS/IR/IRAsm.cpp +++ /dev/null @@ -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" - - diff --git a/Core/MIPS/MIPS.cpp b/Core/MIPS/MIPS.cpp index e0719971bd..55a78fc086 100644 --- a/Core/MIPS/MIPS.cpp +++ b/Core/MIPS/MIPS.cpp @@ -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" diff --git a/Core/MIPS/MIPSDebugInterface.cpp b/Core/MIPS/MIPSDebugInterface.cpp index 8c63c3929f..1b894ffdc5 100644 --- a/Core/MIPS/MIPSDebugInterface.cpp +++ b/Core/MIPS/MIPSDebugInterface.cpp @@ -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, diff --git a/Core/MIPS/RiscV/RiscVAsm.cpp b/Core/MIPS/RiscV/RiscVAsm.cpp index 63e68a345b..c88d961a97 100644 --- a/Core/MIPS/RiscV/RiscVAsm.cpp +++ b/Core/MIPS/RiscV/RiscVAsm.cpp @@ -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 { diff --git a/Core/MIPS/x86/X64IRAsm.cpp b/Core/MIPS/x86/X64IRAsm.cpp index 3745bde4f8..883149dcd5 100644 --- a/Core/MIPS/x86/X64IRAsm.cpp +++ b/Core/MIPS/x86/X64IRAsm.cpp @@ -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 { diff --git a/Core/System.cpp b/Core/System.cpp index d72423e601..ef483c98d3 100644 --- a/Core/System.cpp +++ b/Core/System.cpp @@ -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 { diff --git a/Core/System.h b/Core/System.h index 22eae2a3ef..4b584223cd 100644 --- a/Core/System.h +++ b/Core/System.h @@ -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; diff --git a/Core/Util/PortManager.cpp b/Core/Util/PortManager.cpp index dfa493b65e..623dd2f320 100644 --- a/Core/Util/PortManager.cpp +++ b/Core/Util/PortManager.cpp @@ -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" diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index 98e64c1eb8..aa2cc82f76 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -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" diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 7c2469829a..ef26f9298d 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -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)) { diff --git a/UWP/CoreUWP/CoreUWP.vcxproj b/UWP/CoreUWP/CoreUWP.vcxproj index b9fc66b1e6..c52f636643 100644 --- a/UWP/CoreUWP/CoreUWP.vcxproj +++ b/UWP/CoreUWP/CoreUWP.vcxproj @@ -554,7 +554,6 @@ - @@ -1023,4 +1022,4 @@ - \ No newline at end of file + diff --git a/UWP/CoreUWP/CoreUWP.vcxproj.filters b/UWP/CoreUWP/CoreUWP.vcxproj.filters index 0434c2142b..3c89d91677 100644 --- a/UWP/CoreUWP/CoreUWP.vcxproj.filters +++ b/UWP/CoreUWP/CoreUWP.vcxproj.filters @@ -645,9 +645,6 @@ Ext - - MIPS\IR - MIPS\IR @@ -1906,4 +1903,4 @@ Ext\gason - \ No newline at end of file + diff --git a/headless/Headless.cpp b/headless/Headless.cpp index 9154c21e96..87ea7411e5 100644 --- a/headless/Headless.cpp +++ b/headless/Headless.cpp @@ -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;