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;
TLBEntry& tlbe = ppcState.tlb[0][entry_index];
tlbe.tag[0] = TLBEntry::INVALID_TAG;
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;
ppcState.tlb[0][entry_index].Invalidate();
ppcState.tlb[1][entry_index].Invalidate();
}
// Page Address Translation

View File

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