summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2020-06-27 18:20:06 -0400
committerGravatar Fernando Sahmkow2020-06-27 18:20:06 -0400
commit2f8947583f2f0af4058600243d6c1d244e3c4890 (patch)
treea0e7a10c6131efb23d6fdb3ee7fc0de4bd4163af /src/core
parentNvFlinger: Clang Format. (diff)
downloadyuzu-2f8947583f2f0af4058600243d6c1d244e3c4890.tar.gz
yuzu-2f8947583f2f0af4058600243d6c1d244e3c4890.tar.xz
yuzu-2f8947583f2f0af4058600243d6c1d244e3c4890.zip
Core/Common: Address Feedback.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/arm/arm_interface.h2
-rw-r--r--src/core/arm/cpu_interrupt_handler.h2
-rw-r--r--src/core/arm/dynarmic/arm_dynarmic_32.cpp5
-rw-r--r--src/core/arm/dynarmic/arm_dynarmic_32.h2
-rw-r--r--src/core/arm/dynarmic/arm_dynarmic_64.cpp5
-rw-r--r--src/core/arm/dynarmic/arm_dynarmic_64.h2
-rw-r--r--src/core/arm/unicorn/arm_unicorn.cpp2
-rw-r--r--src/core/arm/unicorn/arm_unicorn.h2
-rw-r--r--src/core/core.cpp2
-rw-r--r--src/core/core.h4
-rw-r--r--src/core/core_timing.cpp28
-rw-r--r--src/core/hle/kernel/kernel.cpp14
-rw-r--r--src/core/hle/kernel/physical_core.cpp4
-rw-r--r--src/core/hle/kernel/physical_core.h7
-rw-r--r--src/core/hle/kernel/scheduler.cpp4
-rw-r--r--src/core/hle/kernel/scheduler.h4
16 files changed, 44 insertions, 45 deletions
diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h
index 0c1d6ac39..1f24051e4 100644
--- a/src/core/arm/arm_interface.h
+++ b/src/core/arm/arm_interface.h
@@ -148,7 +148,7 @@ public:
148 */ 148 */
149 virtual void SetTPIDR_EL0(u64 value) = 0; 149 virtual void SetTPIDR_EL0(u64 value) = 0;
150 150
151 virtual void ChangeProcessorId(std::size_t new_core_id) = 0; 151 virtual void ChangeProcessorID(std::size_t new_core_id) = 0;
152 152
153 virtual void SaveContext(ThreadContext32& ctx) = 0; 153 virtual void SaveContext(ThreadContext32& ctx) = 0;
154 virtual void SaveContext(ThreadContext64& ctx) = 0; 154 virtual void SaveContext(ThreadContext64& ctx) = 0;
diff --git a/src/core/arm/cpu_interrupt_handler.h b/src/core/arm/cpu_interrupt_handler.h
index 91c31a271..3d062d326 100644
--- a/src/core/arm/cpu_interrupt_handler.h
+++ b/src/core/arm/cpu_interrupt_handler.h
@@ -23,7 +23,7 @@ public:
23 CPUInterruptHandler(CPUInterruptHandler&&) = default; 23 CPUInterruptHandler(CPUInterruptHandler&&) = default;
24 CPUInterruptHandler& operator=(CPUInterruptHandler&&) = default; 24 CPUInterruptHandler& operator=(CPUInterruptHandler&&) = default;
25 25
26 constexpr bool IsInterrupted() const { 26 bool IsInterrupted() const {
27 return is_interrupted; 27 return is_interrupted;
28 } 28 }
29 29
diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp
index cfda12098..0d4ab95b7 100644
--- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp
+++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp
@@ -107,7 +107,7 @@ public:
107 u64 GetTicksRemaining() override { 107 u64 GetTicksRemaining() override {
108 if (parent.uses_wall_clock) { 108 if (parent.uses_wall_clock) {
109 if (!parent.interrupt_handlers[parent.core_index].IsInterrupted()) { 109 if (!parent.interrupt_handlers[parent.core_index].IsInterrupted()) {
110 return 1000U; 110 return minimum_run_cycles;
111 } 111 }
112 return 0U; 112 return 0U;
113 } 113 }
@@ -116,6 +116,7 @@ public:
116 116
117 ARM_Dynarmic_32& parent; 117 ARM_Dynarmic_32& parent;
118 std::size_t num_interpreted_instructions{}; 118 std::size_t num_interpreted_instructions{};
119 static constexpr u64 minimum_run_cycles = 1000U;
119}; 120};
120 121
121std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable& page_table, 122std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable& page_table,
@@ -214,7 +215,7 @@ void ARM_Dynarmic_32::SetTPIDR_EL0(u64 value) {
214 cp15->uprw = static_cast<u32>(value); 215 cp15->uprw = static_cast<u32>(value);
215} 216}
216 217
217void ARM_Dynarmic_32::ChangeProcessorId(std::size_t new_core_id) { 218void ARM_Dynarmic_32::ChangeProcessorID(std::size_t new_core_id) {
218 jit->ChangeProcessorID(new_core_id); 219 jit->ChangeProcessorID(new_core_id);
219} 220}
220 221
diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.h b/src/core/arm/dynarmic/arm_dynarmic_32.h
index d9c0bfede..2bab31b92 100644
--- a/src/core/arm/dynarmic/arm_dynarmic_32.h
+++ b/src/core/arm/dynarmic/arm_dynarmic_32.h
@@ -47,7 +47,7 @@ public:
47 void SetTlsAddress(VAddr address) override; 47 void SetTlsAddress(VAddr address) override;
48 void SetTPIDR_EL0(u64 value) override; 48 void SetTPIDR_EL0(u64 value) override;
49 u64 GetTPIDR_EL0() const override; 49 u64 GetTPIDR_EL0() const override;
50 void ChangeProcessorId(std::size_t new_core_id) override; 50 void ChangeProcessorID(std::size_t new_core_id) override;
51 51
52 void SaveContext(ThreadContext32& ctx) override; 52 void SaveContext(ThreadContext32& ctx) override;
53 void SaveContext(ThreadContext64& ctx) override {} 53 void SaveContext(ThreadContext64& ctx) override {}
diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp
index 35a99e28a..790981034 100644
--- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp
+++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp
@@ -144,7 +144,7 @@ public:
144 u64 GetTicksRemaining() override { 144 u64 GetTicksRemaining() override {
145 if (parent.uses_wall_clock) { 145 if (parent.uses_wall_clock) {
146 if (!parent.interrupt_handlers[parent.core_index].IsInterrupted()) { 146 if (!parent.interrupt_handlers[parent.core_index].IsInterrupted()) {
147 return 1000U; 147 return minimum_run_cycles;
148 } 148 }
149 return 0U; 149 return 0U;
150 } 150 }
@@ -159,6 +159,7 @@ public:
159 std::size_t num_interpreted_instructions = 0; 159 std::size_t num_interpreted_instructions = 0;
160 u64 tpidrro_el0 = 0; 160 u64 tpidrro_el0 = 0;
161 u64 tpidr_el0 = 0; 161 u64 tpidr_el0 = 0;
162 static constexpr u64 minimum_run_cycles = 1000U;
162}; 163};
163 164
164std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable& page_table, 165std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable& page_table,
@@ -271,7 +272,7 @@ void ARM_Dynarmic_64::SetTPIDR_EL0(u64 value) {
271 cb->tpidr_el0 = value; 272 cb->tpidr_el0 = value;
272} 273}
273 274
274void ARM_Dynarmic_64::ChangeProcessorId(std::size_t new_core_id) { 275void ARM_Dynarmic_64::ChangeProcessorID(std::size_t new_core_id) {
275 jit->ChangeProcessorID(new_core_id); 276 jit->ChangeProcessorID(new_core_id);
276} 277}
277 278
diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.h b/src/core/arm/dynarmic/arm_dynarmic_64.h
index c74fcbcea..403c55961 100644
--- a/src/core/arm/dynarmic/arm_dynarmic_64.h
+++ b/src/core/arm/dynarmic/arm_dynarmic_64.h
@@ -45,7 +45,7 @@ public:
45 void SetTlsAddress(VAddr address) override; 45 void SetTlsAddress(VAddr address) override;
46 void SetTPIDR_EL0(u64 value) override; 46 void SetTPIDR_EL0(u64 value) override;
47 u64 GetTPIDR_EL0() const override; 47 u64 GetTPIDR_EL0() const override;
48 void ChangeProcessorId(std::size_t new_core_id) override; 48 void ChangeProcessorID(std::size_t new_core_id) override;
49 49
50 void SaveContext(ThreadContext32& ctx) override {} 50 void SaveContext(ThreadContext32& ctx) override {}
51 void SaveContext(ThreadContext64& ctx) override; 51 void SaveContext(ThreadContext64& ctx) override;
diff --git a/src/core/arm/unicorn/arm_unicorn.cpp b/src/core/arm/unicorn/arm_unicorn.cpp
index 35e8f42e8..1df3f3ed1 100644
--- a/src/core/arm/unicorn/arm_unicorn.cpp
+++ b/src/core/arm/unicorn/arm_unicorn.cpp
@@ -159,7 +159,7 @@ void ARM_Unicorn::SetTPIDR_EL0(u64 value) {
159 CHECKED(uc_reg_write(uc, UC_ARM64_REG_TPIDR_EL0, &value)); 159 CHECKED(uc_reg_write(uc, UC_ARM64_REG_TPIDR_EL0, &value));
160} 160}
161 161
162void ARM_Unicorn::ChangeProcessorId(std::size_t new_core_id) { 162void ARM_Unicorn::ChangeProcessorID(std::size_t new_core_id) {
163 core_index = new_core_id; 163 core_index = new_core_id;
164} 164}
165 165
diff --git a/src/core/arm/unicorn/arm_unicorn.h b/src/core/arm/unicorn/arm_unicorn.h
index 8ace8b86f..810aff311 100644
--- a/src/core/arm/unicorn/arm_unicorn.h
+++ b/src/core/arm/unicorn/arm_unicorn.h
@@ -36,7 +36,7 @@ public:
36 void SetTlsAddress(VAddr address) override; 36 void SetTlsAddress(VAddr address) override;
37 void SetTPIDR_EL0(u64 value) override; 37 void SetTPIDR_EL0(u64 value) override;
38 u64 GetTPIDR_EL0() const override; 38 u64 GetTPIDR_EL0() const override;
39 void ChangeProcessorId(std::size_t new_core_id) override; 39 void ChangeProcessorID(std::size_t new_core_id) override;
40 void PrepareReschedule() override; 40 void PrepareReschedule() override;
41 void ClearExclusiveState() override; 41 void ClearExclusiveState() override;
42 void ExecuteInstructions(std::size_t num_instructions); 42 void ExecuteInstructions(std::size_t num_instructions);
diff --git a/src/core/core.cpp b/src/core/core.cpp
index 8256ec0fc..1a243c515 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -443,7 +443,7 @@ bool System::IsPoweredOn() const {
443} 443}
444 444
445void System::PrepareReschedule() { 445void System::PrepareReschedule() {
446 // impl->CurrentPhysicalCore().Stop(); 446 // Deprecated, does nothing, kept for backward compatibility.
447} 447}
448 448
449void System::PrepareReschedule(const u32 core_index) { 449void System::PrepareReschedule(const u32 core_index) {
diff --git a/src/core/core.h b/src/core/core.h
index 133ecb8e1..5c6cfbffe 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -138,13 +138,13 @@ public:
138 138
139 /** 139 /**
140 * Run the OS and Application 140 * Run the OS and Application
141 * This function will start emulation and run the competent devices 141 * This function will start emulation and run the relevant devices
142 */ 142 */
143 ResultStatus Run(); 143 ResultStatus Run();
144 144
145 /** 145 /**
146 * Pause the OS and Application 146 * Pause the OS and Application
147 * This function will pause emulation and stop the competent devices 147 * This function will pause emulation and stop the relevant devices
148 */ 148 */
149 ResultStatus Pause(); 149 ResultStatus Pause();
150 150
diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp
index 1aa89a1cc..5c83c41a4 100644
--- a/src/core/core_timing.cpp
+++ b/src/core/core_timing.cpp
@@ -45,9 +45,9 @@ CoreTiming::CoreTiming() {
45CoreTiming::~CoreTiming() = default; 45CoreTiming::~CoreTiming() = default;
46 46
47void CoreTiming::ThreadEntry(CoreTiming& instance) { 47void CoreTiming::ThreadEntry(CoreTiming& instance) {
48 std::string name = "yuzu:HostTiming"; 48 constexpr char name[] = "yuzu:HostTiming";
49 MicroProfileOnThreadCreate(name.c_str()); 49 MicroProfileOnThreadCreate(name);
50 Common::SetCurrentThreadName(name.c_str()); 50 Common::SetCurrentThreadName(name);
51 Common::SetCurrentThreadPriority(Common::ThreadPriority::VeryHigh); 51 Common::SetCurrentThreadPriority(Common::ThreadPriority::VeryHigh);
52 instance.on_thread_init(); 52 instance.on_thread_init();
53 instance.ThreadLoop(); 53 instance.ThreadLoop();
@@ -108,18 +108,19 @@ bool CoreTiming::HasPendingEvents() const {
108 108
109void CoreTiming::ScheduleEvent(s64 ns_into_future, const std::shared_ptr<EventType>& event_type, 109void CoreTiming::ScheduleEvent(s64 ns_into_future, const std::shared_ptr<EventType>& event_type,
110 u64 userdata) { 110 u64 userdata) {
111 basic_lock.lock(); 111 {
112 const u64 timeout = static_cast<u64>(GetGlobalTimeNs().count() + ns_into_future); 112 std::scoped_lock scope{basic_lock};
113 const u64 timeout = static_cast<u64>(GetGlobalTimeNs().count() + ns_into_future);
113 114
114 event_queue.emplace_back(Event{timeout, event_fifo_id++, userdata, event_type}); 115 event_queue.emplace_back(Event{timeout, event_fifo_id++, userdata, event_type});
115 116
116 std::push_heap(event_queue.begin(), event_queue.end(), std::greater<>()); 117 std::push_heap(event_queue.begin(), event_queue.end(), std::greater<>());
117 basic_lock.unlock(); 118 }
118 event.Set(); 119 event.Set();
119} 120}
120 121
121void CoreTiming::UnscheduleEvent(const std::shared_ptr<EventType>& event_type, u64 userdata) { 122void CoreTiming::UnscheduleEvent(const std::shared_ptr<EventType>& event_type, u64 userdata) {
122 basic_lock.lock(); 123 std::scoped_lock scope{basic_lock};
123 const auto itr = std::remove_if(event_queue.begin(), event_queue.end(), [&](const Event& e) { 124 const auto itr = std::remove_if(event_queue.begin(), event_queue.end(), [&](const Event& e) {
124 return e.type.lock().get() == event_type.get() && e.userdata == userdata; 125 return e.type.lock().get() == event_type.get() && e.userdata == userdata;
125 }); 126 });
@@ -129,7 +130,6 @@ void CoreTiming::UnscheduleEvent(const std::shared_ptr<EventType>& event_type, u
129 event_queue.erase(itr, event_queue.end()); 130 event_queue.erase(itr, event_queue.end());
130 std::make_heap(event_queue.begin(), event_queue.end(), std::greater<>()); 131 std::make_heap(event_queue.begin(), event_queue.end(), std::greater<>());
131 } 132 }
132 basic_lock.unlock();
133} 133}
134 134
135void CoreTiming::AddTicks(u64 ticks) { 135void CoreTiming::AddTicks(u64 ticks) {
@@ -187,8 +187,8 @@ void CoreTiming::RemoveEvent(const std::shared_ptr<EventType>& event_type) {
187} 187}
188 188
189std::optional<s64> CoreTiming::Advance() { 189std::optional<s64> CoreTiming::Advance() {
190 advance_lock.lock(); 190 std::scoped_lock advance_scope{advance_lock};
191 basic_lock.lock(); 191 std::scoped_lock basic_scope{basic_lock};
192 global_timer = GetGlobalTimeNs().count(); 192 global_timer = GetGlobalTimeNs().count();
193 193
194 while (!event_queue.empty() && event_queue.front().time <= global_timer) { 194 while (!event_queue.empty() && event_queue.front().time <= global_timer) {
@@ -207,12 +207,8 @@ std::optional<s64> CoreTiming::Advance() {
207 207
208 if (!event_queue.empty()) { 208 if (!event_queue.empty()) {
209 const s64 next_time = event_queue.front().time - global_timer; 209 const s64 next_time = event_queue.front().time - global_timer;
210 basic_lock.unlock();
211 advance_lock.unlock();
212 return next_time; 210 return next_time;
213 } else { 211 } else {
214 basic_lock.unlock();
215 advance_lock.unlock();
216 return std::nullopt; 212 return std::nullopt;
217 } 213 }
218} 214}
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index dbb75416d..1f2af7a1b 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -472,16 +472,12 @@ const Core::ExclusiveMonitor& KernelCore::GetExclusiveMonitor() const {
472} 472}
473 473
474void KernelCore::InvalidateAllInstructionCaches() { 474void KernelCore::InvalidateAllInstructionCaches() {
475 if (!IsMulticore()) { 475 auto& threads = GlobalScheduler().GetThreadList();
476 auto& threads = GlobalScheduler().GetThreadList(); 476 for (auto& thread : threads) {
477 for (auto& thread : threads) { 477 if (!thread->IsHLEThread()) {
478 if (!thread->IsHLEThread()) { 478 auto& arm_interface = thread->ArmInterface();
479 auto& arm_interface = thread->ArmInterface(); 479 arm_interface.ClearInstructionCache();
480 arm_interface.ClearInstructionCache();
481 }
482 } 480 }
483 } else {
484 UNIMPLEMENTED_MSG("Cache Invalidation unimplemented for multicore");
485 } 481 }
486} 482}
487 483
diff --git a/src/core/hle/kernel/physical_core.cpp b/src/core/hle/kernel/physical_core.cpp
index c82c60a16..c6bbdb080 100644
--- a/src/core/hle/kernel/physical_core.cpp
+++ b/src/core/hle/kernel/physical_core.cpp
@@ -37,6 +37,10 @@ void PhysicalCore::Shutdown() {
37 scheduler.Shutdown(); 37 scheduler.Shutdown();
38} 38}
39 39
40bool PhysicalCore::IsInterrupted() const {
41 return interrupt_handler.IsInterrupted();
42}
43
40void PhysicalCore::Interrupt() { 44void PhysicalCore::Interrupt() {
41 guard->lock(); 45 guard->lock();
42 interrupt_handler.SetInterrupt(true); 46 interrupt_handler.SetInterrupt(true);
diff --git a/src/core/hle/kernel/physical_core.h b/src/core/hle/kernel/physical_core.h
index 85f6dec05..d7a7a951c 100644
--- a/src/core/hle/kernel/physical_core.h
+++ b/src/core/hle/kernel/physical_core.h
@@ -7,8 +7,6 @@
7#include <cstddef> 7#include <cstddef>
8#include <memory> 8#include <memory>
9 9
10#include "core/arm/cpu_interrupt_handler.h"
11
12namespace Common { 10namespace Common {
13class SpinLock; 11class SpinLock;
14} 12}
@@ -19,6 +17,7 @@ class Scheduler;
19 17
20namespace Core { 18namespace Core {
21class ARM_Interface; 19class ARM_Interface;
20class CPUInterruptHandler;
22class ExclusiveMonitor; 21class ExclusiveMonitor;
23class System; 22class System;
24} // namespace Core 23} // namespace Core
@@ -45,9 +44,7 @@ public:
45 void ClearInterrupt(); 44 void ClearInterrupt();
46 45
47 /// Check if this core is interrupted 46 /// Check if this core is interrupted
48 bool IsInterrupted() const { 47 bool IsInterrupted() const;
49 return interrupt_handler.IsInterrupted();
50 }
51 48
52 // Shutdown this physical core. 49 // Shutdown this physical core.
53 void Shutdown(); 50 void Shutdown();
diff --git a/src/core/hle/kernel/scheduler.cpp b/src/core/hle/kernel/scheduler.cpp
index 61b8a396a..2b12c0dbf 100644
--- a/src/core/hle/kernel/scheduler.cpp
+++ b/src/core/hle/kernel/scheduler.cpp
@@ -658,7 +658,7 @@ void Scheduler::Reload() {
658 cpu_core.LoadContext(thread->GetContext64()); 658 cpu_core.LoadContext(thread->GetContext64());
659 cpu_core.SetTlsAddress(thread->GetTLSAddress()); 659 cpu_core.SetTlsAddress(thread->GetTLSAddress());
660 cpu_core.SetTPIDR_EL0(thread->GetTPIDR_EL0()); 660 cpu_core.SetTPIDR_EL0(thread->GetTPIDR_EL0());
661 cpu_core.ChangeProcessorId(this->core_id); 661 cpu_core.ChangeProcessorID(this->core_id);
662 cpu_core.ClearExclusiveState(); 662 cpu_core.ClearExclusiveState();
663 } 663 }
664 } 664 }
@@ -691,7 +691,7 @@ void Scheduler::SwitchContextStep2() {
691 cpu_core.LoadContext(new_thread->GetContext64()); 691 cpu_core.LoadContext(new_thread->GetContext64());
692 cpu_core.SetTlsAddress(new_thread->GetTLSAddress()); 692 cpu_core.SetTlsAddress(new_thread->GetTLSAddress());
693 cpu_core.SetTPIDR_EL0(new_thread->GetTPIDR_EL0()); 693 cpu_core.SetTPIDR_EL0(new_thread->GetTPIDR_EL0());
694 cpu_core.ChangeProcessorId(this->core_id); 694 cpu_core.ChangeProcessorID(this->core_id);
695 cpu_core.ClearExclusiveState(); 695 cpu_core.ClearExclusiveState();
696 } 696 }
697 } 697 }
diff --git a/src/core/hle/kernel/scheduler.h b/src/core/hle/kernel/scheduler.h
index 348107160..b3b4b5169 100644
--- a/src/core/hle/kernel/scheduler.h
+++ b/src/core/hle/kernel/scheduler.h
@@ -240,6 +240,10 @@ public:
240 return switch_fiber; 240 return switch_fiber;
241 } 241 }
242 242
243 const std::shared_ptr<Common::Fiber>& ControlContext() const {
244 return switch_fiber;
245 }
246
243private: 247private:
244 friend class GlobalScheduler; 248 friend class GlobalScheduler;
245 249