/* Copyright (C) 2009 StrmnNrmn This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "Base/Types.h" #include "Core/CPU.h" #include "Core/TLB.h" #include "Debug/DebugLog.h" #include "Debug/DBGConsole.h" #include "Ultra/ultra_R4300.h" // ALIGNED_GLOBAL(TLBEntry, g_TLBs[32], CACHE_ALIGN); alignas(CACHE_ALIGN) std::array g_TLBs; void TLBEntry::UpdateValue(u32 _pagemask, u32 _hi, u32 _pfno, u32 _pfne) { // From the R4300i Instruction manual: // The G bit of the TLB is written with the logical AND of the G bits of the EntryLo0 and EntryLo1 regs // The TLB entry is loaded with the contents of the EntryHi and EntryLo regs. // TLB[INDEX] <- PageMask || (EntryHi AND NOT PageMask) || EntryLo1 || EntryLo0 DPF( DEBUG_TLB, "PAGEMASK: 0x%08x ENTRYHI: 0x%08x. ENTRYLO1: 0x%08x. ENTRYLO0: 0x%08x", _pagemask, _hi, _pfno, _pfne); pagemask = _pagemask; hi = _hi; pfne = _pfne; pfno = _pfno; g = pfne & pfno & TLBLO_G; // Build the masks: mask = pagemask | (~TLBHI_VPN2MASK); mask2 = mask>>1; vpnmask = ~mask; vpn2mask = vpnmask>>1; addrcheck= hi & vpnmask; pfnehi = ((pfne<