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/HLE/ReplaceTables.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// Regular replacement funcs are just C functions. These take care of their18// own parameter parsing using the old school PARAM macros.19// The return value is the number of cycles to eat.2021// JIT replacefuncs can be for inline or "outline" replacement.22// With inline replacement, we recognize the call to the functions23// at jal time already. With outline replacement, we just replace the24// implementation.2526// In both cases the jit needs to know how much to subtract downcount.27//28// If the replacement func returned a positive number, this will be treated29// as the number of cycles to subtract.30// If the replacement func returns -1, it will be assumed that the subtraction31// was done by the replacement func.3233#pragma once3435#include <map>3637#include "Common/CommonTypes.h"38#include "Core/MIPS/JitCommon/JitCommon.h"3940typedef int (* ReplaceFunc)();4142enum {43REPFLAG_ALLOWINLINE = 0x01,44// Used to keep things around but disable them.45REPFLAG_DISABLED = 0x02,46// Note that this will re-execute in a function that loops at start.47REPFLAG_HOOKENTER = 0x04,48// Only hooks jr ra, so only use on funcs that have that.49REPFLAG_HOOKEXIT = 0x08,50// Function may take a lot of time and execute in slices (executed multiple times.)51REPFLAG_SLICED = 0x10,52};5354// Kind of similar to HLE functions but with different data.55struct ReplacementTableEntry {56const char *name;57ReplaceFunc replaceFunc;58MIPSComp::MIPSReplaceFunc jitReplaceFunc;59int flags;60s32 hookOffset;61};6263void Replacement_Init();64void Replacement_Shutdown();6566int GetNumReplacementFuncs();67std::vector<int> GetReplacementFuncIndexes(u64 hash, int funcSize);68const ReplacementTableEntry *GetReplacementFunc(size_t index);6970void WriteReplaceInstructions(u32 address, u64 hash, int size);71void RestoreReplacedInstruction(u32 address);72void RestoreReplacedInstructions(u32 startAddr, u32 endAddr);73bool GetReplacedOpAt(u32 address, u32 *op);74bool CanReplaceJalTo(u32 dest, const ReplacementTableEntry **entry, u32 *funcSize);7576// For savestates. If you call SaveAndClearReplacements(), you must call RestoreSavedReplacements().77std::map<u32, u32> SaveAndClearReplacements();78void RestoreSavedReplacements(const std::map<u32, u32> &saved);798081