ee: use enum for mmap_GetRamPageInfo returned value

This commit is contained in:
Gregory Hainaut 2015-11-12 10:33:26 +01:00
parent ef063b07b4
commit e4f407ae7c
3 changed files with 20 additions and 19 deletions

View File

@ -891,13 +891,6 @@ void eeMemoryReserve::Release()
// code below.
//
enum vtlb_ProtectionMode
{
ProtMode_None = 0, // page is 'unaccounted' -- neither protected nor unprotected
ProtMode_Write, // page is under write protection (exception handler)
ProtMode_Manual // page is under manual protection (self-checked at execution)
};
struct vtlb_PageProtectionInfo
{
// Ram De-mapping -- used to convert fully translated/mapped offsets (which reside with
@ -914,12 +907,10 @@ static __aligned16 vtlb_PageProtectionInfo m_PageProtectInfo[Ps2MemSize::MainRam
// returns:
// -1 - unchecked block (resides in ROM, thus is integrity is constant)
// 0 - page is using Write protection
// 1 - page is using manual protection (recompiler must include execution-time
// self-checking of block integrity)
// ProtMode_NotRequired - unchecked block (resides in ROM, thus is integrity is constant)
// Or the current mode
//
int mmap_GetRamPageInfo( u32 paddr )
vtlb_ProtectionMode mmap_GetRamPageInfo( u32 paddr )
{
pxAssert( eeMem );
@ -929,10 +920,11 @@ int mmap_GetRamPageInfo( u32 paddr )
uptr rampage = ptr - (uptr)eeMem->Main;
if (rampage >= Ps2MemSize::MainRam)
return -1; //not in ram, no tracking done ...
return ProtMode_NotRequired; //not in ram, no tracking done ...
rampage >>= 12;
return ( m_PageProtectInfo[rampage].Mode == ProtMode_Manual ) ? 1 : 0;
return m_PageProtectInfo[rampage].Mode;
}
// paddr - physically mapped PS2 address

View File

@ -116,7 +116,15 @@ extern void memBindConditionalHandlers();
extern void memMapVUmicro();
extern int mmap_GetRamPageInfo( u32 paddr );
enum vtlb_ProtectionMode
{
ProtMode_None = 0, // page is 'unaccounted' -- neither protected nor unprotected
ProtMode_Write, // page is under write protection (exception handler)
ProtMode_Manual, // page is under manual protection (self-checked at execution)
ProtMode_NotRequired // page doesn't require any protection
};
extern vtlb_ProtectionMode mmap_GetRamPageInfo( u32 paddr );
extern void mmap_MarkCountedRamPage( u32 paddr );
extern void mmap_ResetBlockTracking();

View File

@ -1646,21 +1646,22 @@ static void memory_protect_recompiled_code(u32 startpc, u32 size)
// note: blocks are guaranteed to reside within the confines of a single page.
const int PageType = mmap_GetRamPageInfo( inpage_ptr );
const vtlb_ProtectionMode PageType = mmap_GetRamPageInfo( inpage_ptr );
//const u32 pgsz = std::min(0x1000 - inpage_offs, inpage_sz);
const u32 pgsz = inpage_sz;
switch (PageType)
{
case -1:
case ProtMode_NotRequired:
break;
case 0:
case ProtMode_None:
case ProtMode_Write:
mmap_MarkCountedRamPage( inpage_ptr );
manual_page[inpage_ptr >> 12] = 0;
break;
default:
case ProtMode_Manual:
xMOV( ecx, inpage_ptr );
xMOV( edx, pgsz / 4 );
//xMOV( eax, startpc ); // uncomment this to access startpc (as eax) in dyna_block_discard