Skip to content

Commit

Permalink
PowerPC: Add functions to read/write the full timebase value
Browse files Browse the repository at this point in the history
Allows us to get rid of a silly pointer cast and deduplicate some code
from the front-end when it comes to reading the value.
  • Loading branch information
lioncash committed Jun 19, 2018
1 parent 18c3e03 commit 562d2a7
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Source/Core/Core/HW/SystemTimers.cpp
Expand Up @@ -156,7 +156,7 @@ u32 GetFakeDecrementer()
void TimeBaseSet() void TimeBaseSet()
{ {
CoreTiming::SetFakeTBStartTicks(CoreTiming::GetTicks()); CoreTiming::SetFakeTBStartTicks(CoreTiming::GetTicks());
CoreTiming::SetFakeTBStartValue(*((u64*)&TL)); CoreTiming::SetFakeTBStartValue(PowerPC::ReadFullTimeBaseValue());
} }


u64 GetFakeTimeBase() u64 GetFakeTimeBase()
Expand Down
Expand Up @@ -4,8 +4,6 @@


#include "Core/PowerPC/Interpreter/Interpreter.h" #include "Core/PowerPC/Interpreter/Interpreter.h"


#include <cstring>

#include "Common/Assert.h" #include "Common/Assert.h"
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/FPURoundMode.h" #include "Common/FPURoundMode.h"
Expand Down Expand Up @@ -253,12 +251,8 @@ void Interpreter::mfspr(UGeckoInstruction inst)


case SPR_TL: case SPR_TL:
case SPR_TU: case SPR_TU:
{ PowerPC::WriteFullTimeBaseValue(SystemTimers::GetFakeTimeBase());
// works since we are little endian and TL comes first :) break;
const u64 time_base = SystemTimers::GetFakeTimeBase();
std::memcpy(&TL, &time_base, sizeof(u64));
}
break;


case SPR_WPAR: case SPR_WPAR:
{ {
Expand Down
12 changes: 12 additions & 0 deletions Source/Core/Core/PowerPC/PowerPC.cpp
Expand Up @@ -349,6 +349,18 @@ void RunLoop()
Host_UpdateDisasmDialog(); Host_UpdateDisasmDialog();
} }


u64 ReadFullTimeBaseValue()
{
u64 value;
std::memcpy(&value, &TL, sizeof(value));
return value;
}

void WriteFullTimeBaseValue(u64 value)
{
std::memcpy(&TL, &value, sizeof(value));
}

void UpdatePerformanceMonitor(u32 cycles, u32 num_load_stores, u32 num_fp_inst) void UpdatePerformanceMonitor(u32 cycles, u32 num_load_stores, u32 num_fp_inst)
{ {
switch (MMCR0.PMC1SELECT) switch (MMCR0.PMC1SELECT)
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/Core/PowerPC/PowerPC.h
Expand Up @@ -178,6 +178,9 @@ void RunLoop();
u32 CompactCR(); u32 CompactCR();
void ExpandCR(u32 cr); void ExpandCR(u32 cr);


u64 ReadFullTimeBaseValue();
void WriteFullTimeBaseValue(u64 value);

void UpdatePerformanceMonitor(u32 cycles, u32 num_load_stores, u32 num_fp_inst); void UpdatePerformanceMonitor(u32 cycles, u32 num_load_stores, u32 num_fp_inst);


// Easy register access macros. // Easy register access macros.
Expand Down
7 changes: 1 addition & 6 deletions Source/Core/DolphinQt2/Debugger/RegisterWidget.cpp
Expand Up @@ -261,12 +261,7 @@ void RegisterWidget::PopulateTable()


// Special registers // Special registers
// TB // TB
AddRegister(16, 5, RegisterType::tb, "TB", AddRegister(16, 5, RegisterType::tb, "TB", PowerPC::ReadFullTimeBaseValue, nullptr);
[] {
return static_cast<u64>(PowerPC::ppcState.spr[SPR_TU]) << 32 |
PowerPC::ppcState.spr[SPR_TL];
},
nullptr);


// PC // PC
AddRegister(17, 5, RegisterType::pc, "PC", [] { return PowerPC::ppcState.pc; }, AddRegister(17, 5, RegisterType::pc, "PC", [] { return PowerPC::ppcState.pc; },
Expand Down
4 changes: 1 addition & 3 deletions Source/Core/DolphinWX/Debugger/RegisterView.cpp
Expand Up @@ -334,9 +334,7 @@ wxString CRegTable::GetValue(int row, int col)
PowerPC::ppcState.spr[SPR_IBAT4L + (row - 16) * 2]); PowerPC::ppcState.spr[SPR_IBAT4L + (row - 16) * 2]);


if (row == 16) if (row == 16)
return wxString::Format("%016" PRIx64, static_cast<u64>(PowerPC::ppcState.spr[SPR_TU]) return wxString::Format("%016" PRIx64, PowerPC::ReadFullTimeBaseValue());
<< 32 |
PowerPC::ppcState.spr[SPR_TL]);


break; break;
} }
Expand Down

0 comments on commit 562d2a7

Please sign in to comment.