newHostVM: Fix for savestates!

git-svn-id: http://pcsx2.googlecode.com/svn/branches/newHostVM@4004 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2010-11-07 00:04:53 +00:00
parent d6de2e3942
commit f1024dad91
3 changed files with 27 additions and 5 deletions

View File

@ -264,7 +264,20 @@ void* SpatialArrayReserve::Reserve( uint size, uptr base, uptr upper_bounds )
// Resets/clears the spatial array, reducing the memory commit pool overhead to zero (0).
void SpatialArrayReserve::Reset()
{
__parent::Reset();
if (m_commited)
{
u8* curptr = GetPtr();
const uint blockBytes = m_blocksize * __pagesize;
for (uint i=0; i<m_numblocks; ++i, curptr+=blockBytes)
{
uint thisbit = 1 << (i & 7);
if (!(m_blockbits[i/8] & thisbit)) continue;
HostSys::MemProtect(curptr, blockBytes, PageAccess_None());
HostSys::MmapResetPtr(curptr, blockBytes);
}
}
memzero_sse_a(m_blockbits.GetPtr(), _calcBlockBitArrayLength());
}
@ -357,7 +370,10 @@ void SpatialArrayReserve::OnCommittedBlock( void* block )
uptr relative = (uptr)block - (uptr)m_baseptr;
relative /= m_blocksize * __pagesize;
m_blockbits[relative/32] |= 1 << (relative & 31);
//DbgCon.WriteLn("Check me out @ 0x%08x", block);
pxAssert( (m_blockbits[relative/8] & (1 << (relative & 7))) == 0 );
m_blockbits[relative/8] |= 1 << (relative & 7);
}

View File

@ -100,7 +100,7 @@ void HostSys::Munmap(uptr base, size_t size)
void HostSys::MemProtect( void* baseaddr, size_t size, const PageProtectionMode& mode )
{
pxAssertDev( ((size & (__pagesize-1)) == 0), wxsFormat(
pxAssertDev( ((size & (__pagesize-1)) == 0), pxsFmt(
L"Memory block size must be a multiple of the target platform's page size.\n"
L"\tPage Size: 0x%04x (%d), Block Size: 0x%04x (%d)",
__pagesize, __pagesize, size, size )
@ -109,9 +109,13 @@ void HostSys::MemProtect( void* baseaddr, size_t size, const PageProtectionMode&
DWORD OldProtect; // enjoy my uselessness, yo!
if (!VirtualProtect( baseaddr, size, ConvertToWinApi(mode), &OldProtect ))
{
throw Exception::WinApiError().SetDiagMsg(
Exception::WinApiError apiError;
apiError.SetDiagMsg(
pxsFmt(L"VirtualProtect failed @ 0x%08X -> 0x%08X (mode=%s)",
baseaddr, (uptr)baseaddr + size, mode.ToString().c_str()
));
pxFailDev( apiError.FormatDiagnosticMessage() );
}
}

View File

@ -125,7 +125,7 @@ static void recEventTest()
// stackframe setup code in this function)
static void __fastcall StackFrameCheckFailed( int espORebp, int regval )
{
pxFailDev( wxsFormat( L"(R3000A Recompiler Stackframe) Sanity check failed on %s\n\tCurrent=%d; Saved=%d",
pxFailDev( pxsFmt( L"(R3000A Recompiler Stackframe) Sanity check failed on %s\n\tCurrent=%d; Saved=%d",
(espORebp==0) ? L"ESP" : L"EBP", regval, (espORebp==0) ? s_store_esp : s_store_ebp )
);
@ -827,6 +827,7 @@ void recResetIOP()
for (int i = 0; i < 0x10000; i++)
recLUT_SetPage(psxRecLUT, 0, 0, 0, i, 0);
// IOP knows 64k pages, hence for the 0x10000's
// The bottom 2 bits of PC are always zero, so we <<14 to "compress"
@ -834,6 +835,7 @@ void recResetIOP()
// We're only mapping 20 pages here in 4 places.
// 0x80 comes from : (Ps2MemSize::IopRam / 0x10000) * 4
for (int i=0; i<0x80; i++)
{
recLUT_SetPage(psxRecLUT, psxhwLUT, recRAM, 0x0000, i, i & 0x1f);