summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2018-06-19 13:06:37 -0400
committerLioncash <mathew1800@gmail.com>2018-06-19 13:26:08 -0400
commit562d2a700bd4b930f7f64702e4b2c8d56e9fe9bf (patch)
tree55b821ee217fd52607b044330f020d1b17bd56d8 /Source/Core
parent18c3e0302f6bca8546516173f4cb3ab0aa896a90 (diff)
PowerPC: Add functions to read/write the full timebase value
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.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/HW/SystemTimers.cpp2
-rw-r--r--Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp10
-rw-r--r--Source/Core/Core/PowerPC/PowerPC.cpp12
-rw-r--r--Source/Core/Core/PowerPC/PowerPC.h3
-rw-r--r--Source/Core/DolphinQt2/Debugger/RegisterWidget.cpp7
-rw-r--r--Source/Core/DolphinWX/Debugger/RegisterView.cpp4
6 files changed, 20 insertions, 18 deletions
diff --git a/Source/Core/Core/HW/SystemTimers.cpp b/Source/Core/Core/HW/SystemTimers.cpp
index 6ae82fc3bc..85883acbdc 100644
--- a/Source/Core/Core/HW/SystemTimers.cpp
+++ b/Source/Core/Core/HW/SystemTimers.cpp
@@ -156,7 +156,7 @@ u32 GetFakeDecrementer()
void TimeBaseSet()
{
CoreTiming::SetFakeTBStartTicks(CoreTiming::GetTicks());
- CoreTiming::SetFakeTBStartValue(*((u64*)&TL));
+ CoreTiming::SetFakeTBStartValue(PowerPC::ReadFullTimeBaseValue());
}
u64 GetFakeTimeBase()
diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp
index 57942be5e8..7580be9b83 100644
--- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp
+++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp
@@ -4,8 +4,6 @@
#include "Core/PowerPC/Interpreter/Interpreter.h"
-#include <cstring>
-
#include "Common/Assert.h"
#include "Common/CommonTypes.h"
#include "Common/FPURoundMode.h"
@@ -253,12 +251,8 @@ void Interpreter::mfspr(UGeckoInstruction inst)
case SPR_TL:
case SPR_TU:
- {
- // works since we are little endian and TL comes first :)
- const u64 time_base = SystemTimers::GetFakeTimeBase();
- std::memcpy(&TL, &time_base, sizeof(u64));
- }
- break;
+ PowerPC::WriteFullTimeBaseValue(SystemTimers::GetFakeTimeBase());
+ break;
case SPR_WPAR:
{
diff --git a/Source/Core/Core/PowerPC/PowerPC.cpp b/Source/Core/Core/PowerPC/PowerPC.cpp
index 0d44dc2cce..8abac6ae87 100644
--- a/Source/Core/Core/PowerPC/PowerPC.cpp
+++ b/Source/Core/Core/PowerPC/PowerPC.cpp
@@ -349,6 +349,18 @@ void RunLoop()
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)
{
switch (MMCR0.PMC1SELECT)
diff --git a/Source/Core/Core/PowerPC/PowerPC.h b/Source/Core/Core/PowerPC/PowerPC.h
index c6871dccd3..28dd4dc26b 100644
--- a/Source/Core/Core/PowerPC/PowerPC.h
+++ b/Source/Core/Core/PowerPC/PowerPC.h
@@ -178,6 +178,9 @@ void RunLoop();
u32 CompactCR();
void ExpandCR(u32 cr);
+u64 ReadFullTimeBaseValue();
+void WriteFullTimeBaseValue(u64 value);
+
void UpdatePerformanceMonitor(u32 cycles, u32 num_load_stores, u32 num_fp_inst);
// Easy register access macros.
diff --git a/Source/Core/DolphinQt2/Debugger/RegisterWidget.cpp b/Source/Core/DolphinQt2/Debugger/RegisterWidget.cpp
index 2a2fff7aa2..794bc88856 100644
--- a/Source/Core/DolphinQt2/Debugger/RegisterWidget.cpp
+++ b/Source/Core/DolphinQt2/Debugger/RegisterWidget.cpp
@@ -261,12 +261,7 @@ void RegisterWidget::PopulateTable()
// Special registers
// TB
- AddRegister(16, 5, RegisterType::tb, "TB",
- [] {
- return static_cast<u64>(PowerPC::ppcState.spr[SPR_TU]) << 32 |
- PowerPC::ppcState.spr[SPR_TL];
- },
- nullptr);
+ AddRegister(16, 5, RegisterType::tb, "TB", PowerPC::ReadFullTimeBaseValue, nullptr);
// PC
AddRegister(17, 5, RegisterType::pc, "PC", [] { return PowerPC::ppcState.pc; },
diff --git a/Source/Core/DolphinWX/Debugger/RegisterView.cpp b/Source/Core/DolphinWX/Debugger/RegisterView.cpp
index 0e392d829d..1d43773ded 100644
--- a/Source/Core/DolphinWX/Debugger/RegisterView.cpp
+++ b/Source/Core/DolphinWX/Debugger/RegisterView.cpp
@@ -334,9 +334,7 @@ wxString CRegTable::GetValue(int row, int col)
PowerPC::ppcState.spr[SPR_IBAT4L + (row - 16) * 2]);
if (row == 16)
- return wxString::Format("%016" PRIx64, static_cast<u64>(PowerPC::ppcState.spr[SPR_TU])
- << 32 |
- PowerPC::ppcState.spr[SPR_TL]);
+ return wxString::Format("%016" PRIx64, PowerPC::ReadFullTimeBaseValue());
break;
}