CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Core/Core.h
Views: 1401
// Copyright (c) 2012- PPSSPP Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official git repository and contact information can be found at15// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.1617#pragma once1819#include <string>20#include <string_view>2122#include "Core/System.h"23#include "Core/CoreParameter.h"2425class GraphicsContext;2627// called from emu thread28void UpdateRunLoop(GraphicsContext *ctx);2930// Returns false when an UI exit state is detected.31bool Core_Run(GraphicsContext *ctx);32void Core_Stop();3334// For platforms that don't call Core_Run35void Core_SetGraphicsContext(GraphicsContext *ctx);3637// called from gui38void Core_EnableStepping(bool step, const char *reason = nullptr, u32 relatedAddress = 0);3940bool Core_ShouldRunBehind();41bool Core_MustRunBehind();4243bool Core_NextFrame();44void Core_DoSingleStep();45void Core_UpdateSingleStep();46void Core_ProcessStepping();4748// Changes every time we enter stepping.49int Core_GetSteppingCounter();50struct SteppingReason {51const char *reason = nullptr;52u32 relatedAddress = 0;53};54SteppingReason Core_GetSteppingReason();5556enum class CoreLifecycle {57STARTING,58// Note: includes failure cases. Guaranteed call after STARTING.59START_COMPLETE,60STOPPING,61// Guaranteed call after STOPPING.62STOPPED,6364// Sometimes called for save states. Guaranteed sequence, and never during STARTING or STOPPING.65MEMORY_REINITING,66MEMORY_REINITED,67};6869// Callback is called on the Emu thread.70typedef void (* CoreLifecycleFunc)(CoreLifecycle stage);71void Core_ListenLifecycle(CoreLifecycleFunc func);72void Core_NotifyLifecycle(CoreLifecycle stage);7374// Callback is executed on requesting thread.75typedef void (* CoreStopRequestFunc)();76void Core_ListenStopRequest(CoreStopRequestFunc callback);7778bool Core_IsStepping();7980bool Core_IsActive();81bool Core_IsInactive();82// Warning: these currently work only on Windows.83void Core_WaitInactive();84void Core_WaitInactive(int milliseconds);8586bool UpdateScreenScale(int width, int height);8788// Don't run the core when minimized etc.89void Core_NotifyWindowHidden(bool hidden);90bool Core_IsWindowHidden();9192void Core_SetPowerSaving(bool mode);93bool Core_GetPowerSaving();9495enum class MemoryExceptionType {96NONE,97UNKNOWN,98READ_WORD,99WRITE_WORD,100READ_BLOCK,101WRITE_BLOCK,102ALIGNMENT,103};104enum class ExecExceptionType {105JUMP,106THREAD,107};108109// Separate one for without info, to avoid having to allocate a string110void Core_MemoryException(u32 address, u32 accessSize, u32 pc, MemoryExceptionType type);111112void Core_MemoryExceptionInfo(u32 address, u32 accessSize, u32 pc, MemoryExceptionType type, std::string_view additionalInfo, bool forceReport);113114void Core_ExecException(u32 address, u32 pc, ExecExceptionType type);115void Core_Break(u32 pc);116// Call when loading save states, etc.117void Core_ResetException();118119enum class MIPSExceptionType {120NONE,121MEMORY,122BREAK,123BAD_EXEC_ADDR,124};125126struct MIPSExceptionInfo {127MIPSExceptionType type;128std::string info;129std::string stackTrace; // if available.130131// Memory exception info132MemoryExceptionType memory_type;133uint32_t pc;134uint32_t address;135uint32_t accessSize;136uint32_t ra = 0;137138// Reuses pc and address from memory type, where address is the failed destination.139ExecExceptionType exec_type;140};141142const MIPSExceptionInfo &Core_GetExceptionInfo();143144const char *ExceptionTypeAsString(MIPSExceptionType type);145const char *MemoryExceptionTypeAsString(MemoryExceptionType type);146const char *ExecExceptionTypeAsString(ExecExceptionType type);147148149