2012-12-19 09:30:18 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* *
|
2015-11-10 05:21:49 +00:00
|
|
|
* Project64 - A Nintendo 64 emulator. *
|
2012-12-19 09:30:18 +00:00
|
|
|
* http://www.pj64-emu.com/ *
|
|
|
|
* Copyright (C) 2012 Project64. All rights reserved. *
|
|
|
|
* *
|
|
|
|
* License: *
|
|
|
|
* GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html *
|
|
|
|
* *
|
|
|
|
****************************************************************************/
|
|
|
|
#pragma once
|
2015-12-06 09:59:58 +00:00
|
|
|
#include <Project64-core/Settings/RecompilerSettings.h>
|
|
|
|
#include <Project64-core/N64System/Recompiler/FunctionMapClass.h>
|
|
|
|
#include <Project64-core/N64System/ProfilingClass.h>
|
|
|
|
#include "RecompilerMemory.h"
|
2012-12-19 09:30:18 +00:00
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
class CRecompiler :
|
2015-11-09 20:19:27 +00:00
|
|
|
protected CDebugSettings,
|
|
|
|
public CRecompilerSettings,
|
|
|
|
public CFunctionMap,
|
|
|
|
private CRecompMemory,
|
|
|
|
private CSystemRegisters
|
2008-09-18 03:15:49 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2015-11-09 20:19:27 +00:00
|
|
|
enum REMOVE_REASON
|
|
|
|
{
|
|
|
|
Remove_InitialCode,
|
|
|
|
Remove_Cache,
|
|
|
|
Remove_ProtectedMem,
|
|
|
|
Remove_ValidateFunc,
|
|
|
|
Remove_TLB,
|
|
|
|
Remove_DMA,
|
|
|
|
Remove_StoreInstruc,
|
|
|
|
};
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-12-13 07:52:22 +00:00
|
|
|
typedef void(*DelayFunc)();
|
2010-06-07 02:23:58 +00:00
|
|
|
|
2010-05-25 09:15:19 +00:00
|
|
|
public:
|
2015-11-09 20:19:27 +00:00
|
|
|
CRecompiler(CRegisters & Registers, CProfiling & Profile, bool & EndEmulation);
|
|
|
|
~CRecompiler();
|
2010-05-25 09:15:19 +00:00
|
|
|
|
2015-11-09 20:19:27 +00:00
|
|
|
void Run();
|
|
|
|
void Reset();
|
|
|
|
void ResetRecompCode(bool bAllocate);
|
2010-05-25 09:15:19 +00:00
|
|
|
|
2015-11-09 20:19:27 +00:00
|
|
|
//Self modifying code methods
|
2015-12-13 07:52:22 +00:00
|
|
|
void ClearRecompCode_Virt(uint32_t VirtualAddress, int32_t length, REMOVE_REASON Reason);
|
|
|
|
void ClearRecompCode_Phys(uint32_t PhysicalAddress, int32_t length, REMOVE_REASON Reason);
|
2010-07-23 10:45:35 +00:00
|
|
|
|
2015-11-09 20:19:27 +00:00
|
|
|
void ResetMemoryStackPos();
|
|
|
|
|
|
|
|
uint32_t& MemoryStackPos() { return m_MemoryStack; }
|
2010-05-25 09:15:19 +00:00
|
|
|
|
2008-09-18 03:15:49 +00:00
|
|
|
private:
|
2015-11-09 20:19:27 +00:00
|
|
|
CRecompiler(); // Disable default constructor
|
|
|
|
CRecompiler(const CRecompiler&); // Disable copy constructor
|
|
|
|
CRecompiler& operator=(const CRecompiler&); // Disable assignment
|
|
|
|
|
|
|
|
CCompiledFunc * CompilerCode();
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-11-09 20:19:27 +00:00
|
|
|
// Main loops for the different look up methods
|
|
|
|
void RecompilerMain_VirtualTable();
|
|
|
|
void RecompilerMain_VirtualTable_validate();
|
|
|
|
void RecompilerMain_ChangeMemory();
|
|
|
|
void RecompilerMain_Lookup();
|
|
|
|
void RecompilerMain_Lookup_TLB();
|
|
|
|
void RecompilerMain_Lookup_validate();
|
|
|
|
void RecompilerMain_Lookup_validate_TLB();
|
2008-09-18 03:15:49 +00:00
|
|
|
|
2015-11-09 20:19:27 +00:00
|
|
|
CCompiledFuncList m_Functions;
|
|
|
|
CRegisters & m_Registers;
|
|
|
|
CProfiling & m_Profile;
|
|
|
|
bool & m_EndEmulation;
|
|
|
|
uint32_t m_MemoryStack;
|
2013-01-03 08:51:00 +00:00
|
|
|
|
2015-11-09 20:19:27 +00:00
|
|
|
//Quick access to registers
|
2015-11-08 20:45:41 +00:00
|
|
|
uint32_t & PROGRAM_COUNTER;
|
2008-09-18 03:15:49 +00:00
|
|
|
};
|