MMU: Move invalidation logic into the TLBEntry struct

Puts the invalidation logic in one place and lets us tidy up
InvalidateTLBEntry a little.
This commit is contained in:
Lioncash 2021-08-31 10:04:42 -04:00
parent 3216040bfe
commit 1c776d8c1a
2 changed files with 10 additions and 10 deletions

View File

@ -1295,13 +1295,8 @@ void InvalidateTLBEntry(u32 address)
{ {
const u32 entry_index = (address >> HW_PAGE_INDEX_SHIFT) & HW_PAGE_INDEX_MASK; const u32 entry_index = (address >> HW_PAGE_INDEX_SHIFT) & HW_PAGE_INDEX_MASK;
TLBEntry& tlbe = ppcState.tlb[0][entry_index]; ppcState.tlb[0][entry_index].Invalidate();
tlbe.tag[0] = TLBEntry::INVALID_TAG; ppcState.tlb[1][entry_index].Invalidate();
tlbe.tag[1] = TLBEntry::INVALID_TAG;
TLBEntry& tlbe_i = ppcState.tlb[1][entry_index];
tlbe_i.tag[0] = TLBEntry::INVALID_TAG;
tlbe_i.tag[1] = TLBEntry::INVALID_TAG;
} }
// Page Address Translation // Page Address Translation

View File

@ -3,6 +3,7 @@
#pragma once #pragma once
#include <array>
#include <cstddef> #include <cstddef>
#include <iosfwd> #include <iosfwd>
#include <tuple> #include <tuple>
@ -49,12 +50,16 @@ constexpr size_t TLB_WAYS = 2;
struct TLBEntry struct TLBEntry
{ {
using WayArray = std::array<u32, TLB_WAYS>;
static constexpr u32 INVALID_TAG = 0xffffffff; static constexpr u32 INVALID_TAG = 0xffffffff;
u32 tag[TLB_WAYS] = {INVALID_TAG, INVALID_TAG}; WayArray tag{INVALID_TAG, INVALID_TAG};
u32 paddr[TLB_WAYS] = {}; WayArray paddr{};
u32 pte[TLB_WAYS] = {}; WayArray pte{};
u32 recent = 0; u32 recent = 0;
void Invalidate() { tag.fill(INVALID_TAG); }
}; };
struct PairedSingle struct PairedSingle