From bddb2504b58a96041bd96ba59569092f632bbc38 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Thu, 21 Aug 2014 11:01:01 -0500 Subject: [PATCH] Get the VTLB working on x86_64. VTLB does some nonsense with signed integers for the pointers. We've got to make sure to set the signed bit in the correct bit on 64bit pointers so it works. --- pcsx2/vtlb.cpp | 8 ++++---- pcsx2/vtlb.h | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pcsx2/vtlb.cpp b/pcsx2/vtlb.cpp index 05a9c7736f..a26ba37bac 100644 --- a/pcsx2/vtlb.cpp +++ b/pcsx2/vtlb.cpp @@ -355,7 +355,7 @@ void __fastcall GoemonPreloadTlb() u32 vaddr = tlb[i].low_add; u32 paddr = tlb[i].physical_add; - if ((u32)vtlbdata.vmap[vaddr>>VTLB_PAGE_BITS] == 0x80000000u) { + if ((uptr)vtlbdata.vmap[vaddr>>VTLB_PAGE_BITS] == POINTER_SIGN_BIT) { DevCon.WriteLn("Preload TLB[%d]: From V:0x%8.8x to P:0x%8.8x (%d pages)", i, vaddr, paddr, size >> VTLB_PAGE_BITS); vtlb_VMap( vaddr , paddr, size); vtlb_VMap(0x20000000|vaddr , paddr, size); @@ -636,13 +636,13 @@ void vtlb_VMap(u32 vaddr,u32 paddr,u32 size) while (size > 0) { - s32 pme; + sptr pme; if (paddr >= VTLB_PMAP_SZ) { pme = UnmappedPhyHandler0; - if (paddr & 0x80000000) + if (paddr & POINTER_SIGN_BIT) pme = UnmappedPhyHandler1; - pme |= 0x80000000; + pme |= POINTER_SIGN_BIT; pme |= paddr;// top bit is set anyway ... } else diff --git a/pcsx2/vtlb.h b/pcsx2/vtlb.h index 8ad218630a..1e10a88103 100644 --- a/pcsx2/vtlb.h +++ b/pcsx2/vtlb.h @@ -190,6 +190,8 @@ namespace vtlb_private static const uint VTLB_HANDLER_ITEMS = 128; + static const uptr POINTER_SIGN_BIT = 1ULL << (sizeof(uptr) * 8 - 1); + struct MapData { // first indexer -- 8/16/32/64/128 bit tables [values 0-4]