Merge pull request #4686 from lioncash/ppc-init

PowerPC: Minor initialization cleanup
This commit is contained in:
Matthew Parlane 2017-01-19 15:59:59 +13:00 committed by GitHub
commit 01f2216e20
2 changed files with 24 additions and 32 deletions

View File

@ -88,6 +88,7 @@ void DoState(PointerWrap& p)
static void ResetRegisters() static void ResetRegisters()
{ {
memset(ppcState.ps, 0, sizeof(ppcState.ps)); memset(ppcState.ps, 0, sizeof(ppcState.ps));
memset(ppcState.sr, 0, sizeof(ppcState.sr));
memset(ppcState.gpr, 0, sizeof(ppcState.gpr)); memset(ppcState.gpr, 0, sizeof(ppcState.gpr));
memset(ppcState.spr, 0, sizeof(ppcState.spr)); memset(ppcState.spr, 0, sizeof(ppcState.spr));
/* /*
@ -126,34 +127,8 @@ static void ResetRegisters()
SystemTimers::DecrementerSet(); SystemTimers::DecrementerSet();
} }
void Init(int cpu_core) static void InitializeCPUCore(int cpu_core)
{ {
// NOTE: This function runs on EmuThread, not the CPU Thread.
// Changing the rounding mode has a limited effect.
FPURoundMode::SetPrecisionMode(FPURoundMode::PREC_53);
s_invalidate_cache_thread_safe =
CoreTiming::RegisterEvent("invalidateEmulatedCache", InvalidateCacheThreadSafe);
memset(ppcState.sr, 0, sizeof(ppcState.sr));
ppcState.pagetable_base = 0;
ppcState.pagetable_hashmask = 0;
for (int tlb = 0; tlb < 2; tlb++)
{
for (int set = 0; set < 64; set++)
{
ppcState.tlb[tlb][set].recent = 0;
for (int way = 0; way < 2; way++)
{
ppcState.tlb[tlb][set].paddr[way] = 0;
ppcState.tlb[tlb][set].pte[way] = 0;
ppcState.tlb[tlb][set].tag[way] = TLB_TAG_INVALID;
}
}
}
ResetRegisters();
PPCTables::InitTables(cpu_core); PPCTables::InitTables(cpu_core);
// We initialize the interpreter because // We initialize the interpreter because
@ -184,7 +159,24 @@ void Init(int cpu_core)
{ {
s_mode = MODE_INTERPRETER; s_mode = MODE_INTERPRETER;
} }
}
void Init(int cpu_core)
{
// NOTE: This function runs on EmuThread, not the CPU Thread.
// Changing the rounding mode has a limited effect.
FPURoundMode::SetPrecisionMode(FPURoundMode::PREC_53);
s_invalidate_cache_thread_safe =
CoreTiming::RegisterEvent("invalidateEmulatedCache", InvalidateCacheThreadSafe);
ppcState.pagetable_base = 0;
ppcState.pagetable_hashmask = 0;
ppcState.tlb = {};
ResetRegisters();
InitializeCPUCore(cpu_core);
ppcState.iCache.Init(); ppcState.iCache.Init();
if (SConfig::GetInstance().bEnableDebugging) if (SConfig::GetInstance().bEnableDebugging)

View File

@ -49,10 +49,10 @@ enum CoreMode
struct tlb_entry struct tlb_entry
{ {
u32 tag[TLB_WAYS]; u32 tag[TLB_WAYS] = {TLB_TAG_INVALID, TLB_TAG_INVALID};
u32 paddr[TLB_WAYS]; u32 paddr[TLB_WAYS] = {};
u32 pte[TLB_WAYS]; u32 pte[TLB_WAYS] = {};
u8 recent; u8 recent = 0;
}; };
// This contains the entire state of the emulated PowerPC "Gekko" CPU. // This contains the entire state of the emulated PowerPC "Gekko" CPU.
@ -116,7 +116,7 @@ struct PowerPCState
// also for power management, but we don't care about that. // also for power management, but we don't care about that.
u32 spr[1024]; u32 spr[1024];
tlb_entry tlb[NUM_TLBS][TLB_SIZE / TLB_WAYS]; std::array<std::array<tlb_entry, TLB_SIZE / TLB_WAYS>, NUM_TLBS> tlb;
u32 pagetable_base; u32 pagetable_base;
u32 pagetable_hashmask; u32 pagetable_hashmask;