Core: Have entryHI use functions to set/get parts

This commit is contained in:
zilmar 2023-11-16 09:19:24 +10:30
parent a0130ff896
commit dcb6969067
3 changed files with 47 additions and 7 deletions

View File

@ -218,6 +218,38 @@ const char * CRegName::FPR_Ctrl[32] = {
"FCSR", "FCSR",
}; };
uint32_t COP0EntryHi::ASID() const
{
return (uint32_t)(Value & 0xFF);
}
uint32_t COP0EntryHi::VPN2() const
{
return (uint32_t)((Value >> 13) & 0x7FFFFFFFll);
}
uint32_t COP0EntryHi::FILL() const
{
return (uint32_t)((Value >> 44) & 0x3FFFF);
}
uint32_t COP0EntryHi::R() const
{
return (uint32_t)((Value >> 62) & 0x3);
}
void COP0EntryHi::SetVPN2(uint32_t VPN2)
{
Value &= ~(0x7FFFFFFFll << 13);
Value |= ((uint64_t)(VPN2 & 0x7FFFFFFF)) << 13;
}
void COP0EntryHi::SetR(uint32_t R)
{
Value &= ~(0x3ll << 62ll);
Value |= ((uint64_t)(R & 0x3)) << 62;
}
CP0registers::CP0registers(uint64_t * _CP0) : CP0registers::CP0registers(uint64_t * _CP0) :
INDEX_REGISTER(_CP0[0]), INDEX_REGISTER(_CP0[0]),
RANDOM_REGISTER(_CP0[1]), RANDOM_REGISTER(_CP0[1]),
@ -764,8 +796,8 @@ void CRegisters::TriggerAddressException(uint64_t Address, uint32_t ExceptionCod
} }
BAD_VADDR_REGISTER = Address; BAD_VADDR_REGISTER = Address;
ENTRYHI_REGISTER.VPN2 = ((Address >> 13) & 0x7FFFFFF); ENTRYHI_REGISTER.SetVPN2((Address >> 13) & 0x7FFFFFF);
ENTRYHI_REGISTER.R = Address >> 62; ENTRYHI_REGISTER.SetR(Address >> 62);
CONTEXT_REGISTER.BadVPN2 = Address >> 13; CONTEXT_REGISTER.BadVPN2 = Address >> 13;
XCONTEXT_REGISTER.BadVPN2 = Address >> 13; XCONTEXT_REGISTER.BadVPN2 = Address >> 13;
XCONTEXT_REGISTER.R = Address >> 62; XCONTEXT_REGISTER.R = Address >> 62;

View File

@ -51,6 +51,14 @@ union COP0EntryHi
{ {
uint64_t Value; uint64_t Value;
uint32_t ASID() const;
uint32_t VPN2() const;
uint32_t FILL() const;
uint32_t R() const;
void SetVPN2(uint32_t VPN2);
void SetR(uint32_t R);
struct struct
{ {
uint64_t ASID : 8; uint64_t ASID : 8;
@ -58,7 +66,7 @@ union COP0EntryHi
uint64_t VPN2 : 31; uint64_t VPN2 : 31;
uint64_t FILL : 18; uint64_t FILL : 18;
uint64_t R : 2; uint64_t R : 2;
}; } Raw;
}; };
enum PRIVILEGE_MODE : unsigned enum PRIVILEGE_MODE : unsigned

View File

@ -99,8 +99,8 @@ void CTLB::Probe()
uint64_t EntryHiMasked = m_Reg.ENTRYHI_REGISTER.Value & Mask; uint64_t EntryHiMasked = m_Reg.ENTRYHI_REGISTER.Value & Mask;
if (TlbValueMasked != EntryHiMasked || if (TlbValueMasked != EntryHiMasked ||
TlbEntryHiValue.R != m_Reg.ENTRYHI_REGISTER.R || TlbEntryHiValue.R() != m_Reg.ENTRYHI_REGISTER.R() ||
(m_tlb[i].EntryLo0.GLOBAL == 0 || m_tlb[i].EntryLo1.GLOBAL == 0) && TlbEntryHiValue.ASID != m_Reg.ENTRYHI_REGISTER.ASID) (m_tlb[i].EntryLo0.GLOBAL == 0 || m_tlb[i].EntryLo1.GLOBAL == 0) && TlbEntryHiValue.ASID() != m_Reg.ENTRYHI_REGISTER.ASID())
{ {
continue; continue;
} }
@ -226,7 +226,7 @@ void CTLB::SetupTLB_Entry(uint32_t Index, bool Random)
TLB_Unmaped(m_FastTlb[FastIndx].VSTART, m_FastTlb[FastIndx].Length); TLB_Unmaped(m_FastTlb[FastIndx].VSTART, m_FastTlb[FastIndx].Length);
} }
m_FastTlb[FastIndx].Length = (uint32_t)((m_tlb[Index].PageMask.Mask << 12) + 0xFFF); m_FastTlb[FastIndx].Length = (uint32_t)((m_tlb[Index].PageMask.Mask << 12) + 0xFFF);
m_FastTlb[FastIndx].VSTART = m_tlb[Index].EntryHi.R << 62 | m_tlb[Index].EntryHi.VPN2 << 13; m_FastTlb[FastIndx].VSTART = ((uint64_t)m_tlb[Index].EntryHi.R() << 62) | ((uint64_t)m_tlb[Index].EntryHi.VPN2() << 13);
m_FastTlb[FastIndx].VEND = m_FastTlb[FastIndx].VSTART + m_FastTlb[FastIndx].Length; m_FastTlb[FastIndx].VEND = m_FastTlb[FastIndx].VSTART + m_FastTlb[FastIndx].Length;
m_FastTlb[FastIndx].PHYSSTART = (uint32_t)(m_tlb[Index].EntryLo0.PFN << 12); m_FastTlb[FastIndx].PHYSSTART = (uint32_t)(m_tlb[Index].EntryLo0.PFN << 12);
m_FastTlb[FastIndx].PHYSEND = m_FastTlb[FastIndx].PHYSSTART + m_FastTlb[FastIndx].Length; m_FastTlb[FastIndx].PHYSEND = m_FastTlb[FastIndx].PHYSSTART + m_FastTlb[FastIndx].Length;
@ -243,7 +243,7 @@ void CTLB::SetupTLB_Entry(uint32_t Index, bool Random)
TLB_Unmaped(m_FastTlb[FastIndx].VSTART, m_FastTlb[FastIndx].Length); TLB_Unmaped(m_FastTlb[FastIndx].VSTART, m_FastTlb[FastIndx].Length);
} }
m_FastTlb[FastIndx].Length = (uint32_t)((m_tlb[Index].PageMask.Mask << 12) + 0xFFF); m_FastTlb[FastIndx].Length = (uint32_t)((m_tlb[Index].PageMask.Mask << 12) + 0xFFF);
m_FastTlb[FastIndx].VSTART = (m_tlb[Index].EntryHi.R << 62 | (m_tlb[Index].EntryHi.VPN2 << 13)) + (m_FastTlb[FastIndx].Length + 1); m_FastTlb[FastIndx].VSTART = ((uint64_t)m_tlb[Index].EntryHi.R() << 62 | ((uint64_t)m_tlb[Index].EntryHi.VPN2() << 13)) + (m_FastTlb[FastIndx].Length + 1);
m_FastTlb[FastIndx].VEND = m_FastTlb[FastIndx].VSTART + m_FastTlb[FastIndx].Length; m_FastTlb[FastIndx].VEND = m_FastTlb[FastIndx].VSTART + m_FastTlb[FastIndx].Length;
m_FastTlb[FastIndx].PHYSSTART = (uint32_t)m_tlb[Index].EntryLo1.PFN << 12; m_FastTlb[FastIndx].PHYSSTART = (uint32_t)m_tlb[Index].EntryLo1.PFN << 12;
m_FastTlb[FastIndx].PHYSEND = m_FastTlb[FastIndx].PHYSSTART + m_FastTlb[FastIndx].Length; m_FastTlb[FastIndx].PHYSEND = m_FastTlb[FastIndx].PHYSSTART + m_FastTlb[FastIndx].Length;