Merge pull request #438 from refractionpcsx2/ee_tlbr

EE: Implement TLBR operation
This commit is contained in:
PSISP 2021-03-01 14:07:53 -05:00 committed by GitHub
commit a3a420eee6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 37 additions and 0 deletions

View file

@ -223,6 +223,19 @@ bool Cop0::int_pending()
return false;
}
void Cop0::read_tlb(int index)
{
TLB_Entry* entry = &tlb[index];
//PageMask
gpr[5] = entry->page_mask << 13;
//EntryHi (VPN | ASID) & ~PageMask
gpr[10] = ((entry->vpn2 << 13) | entry->asid) & ~gpr[5];
//EntryLo0
gpr[2] = (entry->is_scratchpad << 31) | (entry->pfn[1] << 6) | (entry->cache_mode[1] << 3) | (entry->dirty[1] << 2) | (entry->valid[1] << 1) | entry->global;
//EntryLo1
gpr[3] = (entry->pfn[0] << 6) | (entry->cache_mode[0] << 3) | (entry->dirty[0] << 2) | (entry->valid[0] << 1) | entry->global;
}
void Cop0::set_tlb(int index)
{
TLB_Entry* new_entry = &tlb[index];

View file

@ -123,6 +123,7 @@ class Cop0
void count_up(int cycles);
void read_tlb(int index);
void set_tlb(int index);
void clear_tlb_modified(size_t page);
void set_tlb_modified(size_t page);

View file

@ -3405,6 +3405,11 @@ void EE_JitTranslator::translate_op_cop0_type2(uint32_t opcode, uint32_t PC, EE_
switch (op)
{
case 0x01:
// TLBR
Errors::print_warning("[EE_JIT] Unrecognized cop0 type2 op TLBR\n", op);
instrs.push_back(instr);
break;
case 0x02:
// TLBWI
Errors::print_warning("[EE_JIT] Unrecognized cop0 type2 op TLBWI\n", op);

View file

@ -1064,6 +1064,12 @@ void EmotionEngine::set_int1_signal(bool value)
printf("[EE] Set INT1\n");
}
void EmotionEngine::tlbr()
{
int index = cp0->gpr[0];
cp0->read_tlb(index);
}
void EmotionEngine::tlbwi()
{
int index = cp0->gpr[0];

View file

@ -195,6 +195,7 @@ class EmotionEngine
void set_int0_signal(bool value);
void set_int1_signal(bool value);
void tlbr();
void tlbwi();
void tlbp();
void eret();

View file

@ -911,6 +911,8 @@ string disasm_cop(uint32_t instruction, uint32_t instr_addr)
uint8_t op2 = instruction & 0x3F;
switch (op2)
{
case 0x1:
return "tlbr";
case 0x2:
return "tlbwi";
case 0x8:

View file

@ -985,6 +985,10 @@ void EmotionInterpreter::cache(EmotionEngine &cpu, uint32_t instruction)
}
}
void EmotionInterpreter::tlbr(EmotionEngine& cpu, uint32_t instruction)
{
cpu.tlbr();
}
void EmotionInterpreter::tlbwi(EmotionEngine& cpu, uint32_t instruction)
{
@ -1050,6 +1054,10 @@ void EmotionInterpreter::cop(EE_InstrInfo& info, uint32_t instruction)
uint8_t op2 = instruction & 0x3F;
switch (op2)
{
case 0x1:
info.interpreter_fn = &tlbr;
info.pipeline = EE_InstrInfo::Pipeline::COP0;
break;
case 0x2:
info.interpreter_fn = &tlbwi;
info.pipeline = EE_InstrInfo::Pipeline::COP0;

View file

@ -320,6 +320,7 @@ namespace EmotionInterpreter
void cache(EmotionEngine& cpu, uint32_t instruction);
void tlbr(EmotionEngine& cpu, uint32_t instruction);
void tlbwi(EmotionEngine& cpu, uint32_t instruction);
void eret(EmotionEngine& cpu, uint32_t instruction);
void ei(EmotionEngine& cpu, uint32_t instruction);