MMU: Convert PTE unions over to Common::BitField

This commit is contained in:
Lioncash 2021-08-31 09:33:23 -04:00
parent c2c30b4d50
commit 65e131ef5f

View File

@ -1171,29 +1171,31 @@ TranslateResult JitCache_TranslateAddress(u32 address)
// Hey! these duplicate a structure in Gekko.h // Hey! these duplicate a structure in Gekko.h
union UPTE1 union UPTE1
{ {
struct BitField<0, 6, u32> API;
{ BitField<6, 1, u32> H;
u32 API : 6; BitField<7, 24, u32> VSID;
u32 H : 1; BitField<31, 1, u32> V;
u32 VSID : 24;
u32 V : 1; u32 Hex = 0;
};
u32 Hex; UPTE1() = default;
explicit UPTE1(u32 hex_) : Hex{hex_} {}
}; };
union UPTE2 union UPTE2
{ {
struct BitField<0, 2, u32> PP;
{ BitField<2, 1, u32> reserved_1;
u32 PP : 2; BitField<3, 4, u32> WIMG;
u32 : 1; BitField<7, 1, u32> C;
u32 WIMG : 4; BitField<8, 1, u32> R;
u32 C : 1; BitField<9, 3, u32> reserved_2;
u32 R : 1; BitField<12, 20, u32> RPN;
u32 : 3;
u32 RPN : 20; u32 Hex = 0;
};
u32 Hex; UPTE2() = default;
explicit UPTE2(u32 hex_) : Hex{hex_} {}
}; };
static void GenerateDSIException(u32 effective_address, bool write) static void GenerateDSIException(u32 effective_address, bool write)
@ -1258,8 +1260,7 @@ static TLBLookupResult LookupTLBPageAddress(const XCheckTLBFlag flag, const u32
if (tlbe.tag[0] == tag) if (tlbe.tag[0] == tag)
{ {
UPTE2 PTE2; UPTE2 PTE2(tlbe.pte[0]);
PTE2.Hex = tlbe.pte[0];
// Check if C bit requires updating // Check if C bit requires updating
if (flag == XCheckTLBFlag::Write) if (flag == XCheckTLBFlag::Write)
@ -1282,8 +1283,7 @@ static TLBLookupResult LookupTLBPageAddress(const XCheckTLBFlag flag, const u32
} }
if (tlbe.tag[1] == tag) if (tlbe.tag[1] == tag)
{ {
UPTE2 PTE2; UPTE2 PTE2(tlbe.pte[1]);
PTE2.Hex = tlbe.pte[1];
// Check if C bit requires updating // Check if C bit requires updating
if (flag == XCheckTLBFlag::Write) if (flag == XCheckTLBFlag::Write)
@ -1388,8 +1388,7 @@ static TranslateAddressResult TranslatePageAddress(const u32 address, const XChe
if (pte1 == pteg) if (pte1 == pteg)
{ {
UPTE2 PTE2; UPTE2 PTE2(Memory::Read_U32(pteg_addr + 4));
PTE2.Hex = Memory::Read_U32(pteg_addr + 4);
// set the access bits // set the access bits
switch (flag) switch (flag)