2012-12-19 09:30:18 +00:00
|
|
|
/****************************************************************************
|
|
|
|
* *
|
|
|
|
* Project 64 - A Nintendo 64 emulator. *
|
|
|
|
* 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
|
|
|
|
|
2010-05-31 00:21:08 +00:00
|
|
|
class CMipsMemoryVM :
|
|
|
|
public CMipsMemory,
|
|
|
|
public CTransVaddr,
|
2010-06-07 02:23:58 +00:00
|
|
|
private CRecompilerOps,
|
2010-06-14 21:14:58 +00:00
|
|
|
private R4300iOp,
|
2010-06-22 20:36:28 +00:00
|
|
|
private CPifRam,
|
|
|
|
private CFlashram,
|
|
|
|
private CSram,
|
|
|
|
private CDMA
|
2010-05-31 00:21:08 +00:00
|
|
|
{
|
|
|
|
public:
|
2010-06-14 21:14:58 +00:00
|
|
|
CMipsMemoryVM ( CMipsMemory_CallBack * CallBack, bool SavesReadOnly );
|
2010-05-31 00:21:08 +00:00
|
|
|
~CMipsMemoryVM ( void );
|
|
|
|
|
2012-12-18 10:43:29 +00:00
|
|
|
static void ReserveMemory ( void );
|
|
|
|
static void FreeReservedMemory ( void );
|
|
|
|
|
2010-05-31 00:21:08 +00:00
|
|
|
BOOL Initialize ( void );
|
2010-06-14 21:14:58 +00:00
|
|
|
void Reset ( bool EraseMemory );
|
2010-05-31 00:21:08 +00:00
|
|
|
|
|
|
|
BYTE * Rdram ( void );
|
|
|
|
DWORD RdramSize ( void );
|
|
|
|
BYTE * Dmem ( void );
|
|
|
|
BYTE * Imem ( void );
|
|
|
|
BYTE * PifRam ( void );
|
|
|
|
|
|
|
|
BOOL LB_VAddr ( DWORD VAddr, BYTE & Value );
|
|
|
|
BOOL LH_VAddr ( DWORD VAddr, WORD & Value );
|
|
|
|
BOOL LW_VAddr ( DWORD VAddr, DWORD & Value );
|
|
|
|
BOOL LD_VAddr ( DWORD VAddr, QWORD & Value );
|
|
|
|
|
2015-01-22 05:50:20 +00:00
|
|
|
BOOL LB_PAddr ( DWORD PAddr, BYTE & Value );
|
|
|
|
BOOL LH_PAddr ( DWORD PAddr, WORD & Value );
|
|
|
|
BOOL LW_PAddr ( DWORD PAddr, DWORD & Value );
|
|
|
|
BOOL LD_PAddr ( DWORD PAddr, QWORD & Value );
|
|
|
|
|
2010-05-31 00:21:08 +00:00
|
|
|
BOOL SB_VAddr ( DWORD VAddr, BYTE Value );
|
|
|
|
BOOL SH_VAddr ( DWORD VAddr, WORD Value );
|
|
|
|
BOOL SW_VAddr ( DWORD VAddr, DWORD Value );
|
|
|
|
BOOL SD_VAddr ( DWORD VAddr, QWORD Value );
|
|
|
|
|
2015-01-22 05:50:20 +00:00
|
|
|
BOOL SB_PAddr ( DWORD PAddr, BYTE Value );
|
|
|
|
BOOL SH_PAddr ( DWORD PAddr, WORD Value );
|
|
|
|
BOOL SW_PAddr ( DWORD PAddr, DWORD Value );
|
|
|
|
BOOL SD_PAddr ( DWORD PAddr, QWORD Value );
|
|
|
|
|
2010-05-31 00:21:08 +00:00
|
|
|
int MemoryFilter ( DWORD dwExptCode, void * lpExceptionPointer );
|
2015-02-06 23:19:49 +00:00
|
|
|
void UpdateFieldSerration (unsigned int interlaced);
|
2010-05-31 00:21:08 +00:00
|
|
|
|
|
|
|
//Protect the Memory from being written to
|
|
|
|
void ProtectMemory ( DWORD StartVaddr, DWORD EndVaddr );
|
|
|
|
void UnProtectMemory ( DWORD StartVaddr, DWORD EndVaddr );
|
|
|
|
|
|
|
|
//Compilation Functions
|
|
|
|
void ResetMemoryStack ( void );
|
2010-06-14 21:14:58 +00:00
|
|
|
void ResetTLB ( void );
|
2010-05-31 00:21:08 +00:00
|
|
|
|
|
|
|
void Compile_LB ( void );
|
|
|
|
void Compile_LBU ( void );
|
|
|
|
void Compile_LH ( void );
|
|
|
|
void Compile_LHU ( void );
|
|
|
|
void Compile_LW ( void );
|
2013-02-19 18:31:10 +00:00
|
|
|
void Compile_LL ( void );
|
2010-05-31 00:21:08 +00:00
|
|
|
void Compile_LWC1 ( void );
|
|
|
|
void Compile_LWU ( void );
|
|
|
|
void Compile_LWL ( void );
|
|
|
|
void Compile_LWR ( void );
|
|
|
|
void Compile_LD ( void );
|
|
|
|
void Compile_LDC1 ( void );
|
|
|
|
void Compile_LDL ( void );
|
|
|
|
void Compile_LDR ( void );
|
|
|
|
void Compile_SB ( void );
|
|
|
|
void Compile_SH ( void );
|
|
|
|
void Compile_SW ( void );
|
|
|
|
void Compile_SWL ( void );
|
|
|
|
void Compile_SWR ( void );
|
|
|
|
void Compile_SD ( void );
|
|
|
|
void Compile_SDL ( void );
|
|
|
|
void Compile_SDR ( void );
|
2013-02-19 18:31:10 +00:00
|
|
|
void Compile_SC ( void );
|
2010-05-31 00:21:08 +00:00
|
|
|
void Compile_SWC1 ( void );
|
|
|
|
void Compile_SDC1 ( void );
|
|
|
|
|
|
|
|
void ResetMemoryStack ( CRegInfo & RegInfo );
|
|
|
|
void Compile_LB ( CX86Ops::x86Reg Reg, DWORD Addr, BOOL SignExtend );
|
|
|
|
void Compile_LH ( CX86Ops::x86Reg Reg, DWORD Addr, BOOL SignExtend );
|
2010-06-04 06:25:07 +00:00
|
|
|
void Compile_LW ( CX86Ops::x86Reg Reg, DWORD Addr );
|
2010-05-31 00:21:08 +00:00
|
|
|
void Compile_SB_Const ( BYTE Value, DWORD Addr );
|
|
|
|
void Compile_SB_Register ( CX86Ops::x86Reg Reg, DWORD Addr );
|
|
|
|
void Compile_SH_Const ( WORD Value, DWORD Addr );
|
|
|
|
void Compile_SH_Register ( CX86Ops::x86Reg Reg, DWORD Addr );
|
|
|
|
void Compile_SW_Const ( DWORD Value, DWORD Addr );
|
|
|
|
|
|
|
|
void Compile_SW_Register ( CX86Ops::x86Reg Reg, DWORD Addr );
|
|
|
|
|
|
|
|
//Functions for TLB notification
|
|
|
|
void TLB_Mapped ( DWORD VAddr, DWORD Len, DWORD PAddr, bool bReadOnly );
|
|
|
|
void TLB_Unmaped ( DWORD Vaddr, DWORD Len );
|
|
|
|
|
|
|
|
// CTransVaddr interface
|
|
|
|
bool TranslateVaddr ( DWORD VAddr, DWORD &PAddr) const;
|
2010-06-12 02:02:06 +00:00
|
|
|
bool ValidVaddr ( DWORD VAddr ) const;
|
2012-09-24 22:07:51 +00:00
|
|
|
bool VAddrToRealAddr ( DWORD VAddr, void * &RealAddress ) const;
|
2010-05-31 00:21:08 +00:00
|
|
|
|
|
|
|
// Labels
|
|
|
|
LPCTSTR LabelName ( DWORD Address ) const;
|
|
|
|
|
|
|
|
private:
|
2012-12-18 10:43:29 +00:00
|
|
|
CMipsMemoryVM(void); // Disable default constructor
|
|
|
|
CMipsMemoryVM(const CMipsMemoryVM&); // Disable copy constructor
|
|
|
|
CMipsMemoryVM& operator=(const CMipsMemoryVM&); // Disable assignment
|
|
|
|
|
2013-02-19 18:31:10 +00:00
|
|
|
void Compile_LW ( bool ResultSigned, bool bRecordLLbit );
|
|
|
|
void Compile_SW ( bool bCheckLLbit );
|
2013-01-11 21:57:51 +00:00
|
|
|
|
2010-06-12 02:02:06 +00:00
|
|
|
static void RdramChanged ( CMipsMemoryVM * _this );
|
|
|
|
static void ChangeSpStatus ( void );
|
|
|
|
static void ChangeMiIntrMask ( void );
|
|
|
|
|
2010-05-31 00:21:08 +00:00
|
|
|
int LB_NonMemory ( DWORD PAddr, DWORD * Value, BOOL SignExtend );
|
|
|
|
int LH_NonMemory ( DWORD PAddr, DWORD * Value, int SignExtend );
|
|
|
|
int LW_NonMemory ( DWORD PAddr, DWORD * Value );
|
|
|
|
|
|
|
|
int SB_NonMemory ( DWORD PAddr, BYTE Value );
|
|
|
|
int SH_NonMemory ( DWORD PAddr, WORD Value );
|
|
|
|
int SW_NonMemory ( DWORD PAddr, DWORD Value );
|
|
|
|
|
2010-06-16 07:31:47 +00:00
|
|
|
void Compile_StoreInstructClean (x86Reg AddressReg, int Length );
|
|
|
|
|
2012-12-18 10:43:29 +00:00
|
|
|
CMipsMemory_CallBack * const m_CBClass;
|
|
|
|
|
|
|
|
//Memory Locations
|
|
|
|
static BYTE * m_Reserve1, * m_Reserve2;
|
|
|
|
BYTE * m_RDRAM, * m_DMEM, * m_IMEM;
|
|
|
|
DWORD m_AllocatedRdramSize;
|
|
|
|
|
|
|
|
//Rom Information
|
|
|
|
bool m_RomMapped;
|
|
|
|
BYTE * m_Rom;
|
|
|
|
DWORD m_RomSize;
|
|
|
|
bool m_RomWrittenTo;
|
|
|
|
DWORD m_RomWroteValue;
|
|
|
|
|
|
|
|
//Current Half line
|
|
|
|
void UpdateHalfLine ( void );
|
|
|
|
DWORD m_HalfLine;
|
2012-12-30 20:56:49 +00:00
|
|
|
DWORD m_HalfLineCheck;
|
2015-02-06 23:19:49 +00:00
|
|
|
DWORD m_FieldSerration;
|
2012-12-18 10:43:29 +00:00
|
|
|
DWORD m_TempValue;
|
|
|
|
|
2015-03-29 17:19:28 +00:00
|
|
|
//Initializing and resetting information about the memory system
|
2012-12-18 10:43:29 +00:00
|
|
|
void FreeMemory ( void );
|
|
|
|
|
2010-05-31 00:21:08 +00:00
|
|
|
mutable char m_strLabelName[100];
|
|
|
|
|
|
|
|
//BIG look up table to quickly translate the tlb to real mem address
|
|
|
|
DWORD * m_TLB_ReadMap;
|
|
|
|
DWORD * m_TLB_WriteMap;
|
|
|
|
};
|