diff options
| -rw-r--r-- | src/common/fiber.cpp | 10 | ||||
| -rw-r--r-- | src/common/spin_lock.cpp | 6 | ||||
| -rw-r--r-- | src/common/spin_lock.h | 5 | ||||
| -rw-r--r-- | src/common/x64/native_clock.cpp | 4 | ||||
| -rw-r--r-- | src/core/arm/arm_interface.h | 2 | ||||
| -rw-r--r-- | src/core/arm/cpu_interrupt_handler.h | 2 | ||||
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_32.cpp | 5 | ||||
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_32.h | 2 | ||||
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_64.cpp | 5 | ||||
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_64.h | 2 | ||||
| -rw-r--r-- | src/core/arm/unicorn/arm_unicorn.cpp | 2 | ||||
| -rw-r--r-- | src/core/arm/unicorn/arm_unicorn.h | 2 | ||||
| -rw-r--r-- | src/core/core.cpp | 2 | ||||
| -rw-r--r-- | src/core/core.h | 4 | ||||
| -rw-r--r-- | src/core/core_timing.cpp | 28 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 14 | ||||
| -rw-r--r-- | src/core/hle/kernel/physical_core.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/physical_core.h | 7 | ||||
| -rw-r--r-- | src/core/hle/kernel/scheduler.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/scheduler.h | 4 | ||||
| -rw-r--r-- | src/tests/common/fibers.cpp | 2 |
21 files changed, 58 insertions, 58 deletions
diff --git a/src/common/fiber.cpp b/src/common/fiber.cpp index f97ad433b..1c1d09ccb 100644 --- a/src/common/fiber.cpp +++ b/src/common/fiber.cpp | |||
| @@ -54,9 +54,7 @@ Fiber::Fiber(std::function<void(void*)>&& entry_point_func, void* start_paramete | |||
| 54 | impl->handle = CreateFiber(default_stack_size, &FiberStartFunc, this); | 54 | impl->handle = CreateFiber(default_stack_size, &FiberStartFunc, this); |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | Fiber::Fiber() { | 57 | Fiber::Fiber() : impl{std::make_unique<FiberImpl>()} {} |
| 58 | impl = std::make_unique<FiberImpl>(); | ||
| 59 | } | ||
| 60 | 58 | ||
| 61 | Fiber::~Fiber() { | 59 | Fiber::~Fiber() { |
| 62 | if (released) { | 60 | if (released) { |
| @@ -116,8 +114,8 @@ std::shared_ptr<Fiber> Fiber::ThreadToFiber() { | |||
| 116 | 114 | ||
| 117 | struct Fiber::FiberImpl { | 115 | struct Fiber::FiberImpl { |
| 118 | alignas(64) std::array<u8, default_stack_size> stack; | 116 | alignas(64) std::array<u8, default_stack_size> stack; |
| 119 | u8* stack_limit; | ||
| 120 | alignas(64) std::array<u8, default_stack_size> rewind_stack; | 117 | alignas(64) std::array<u8, default_stack_size> rewind_stack; |
| 118 | u8* stack_limit; | ||
| 121 | u8* rewind_stack_limit; | 119 | u8* rewind_stack_limit; |
| 122 | boost::context::detail::fcontext_t context; | 120 | boost::context::detail::fcontext_t context; |
| 123 | boost::context::detail::fcontext_t rewind_context; | 121 | boost::context::detail::fcontext_t rewind_context; |
| @@ -168,9 +166,7 @@ void Fiber::SetRewindPoint(std::function<void(void*)>&& rewind_func, void* start | |||
| 168 | rewind_parameter = start_parameter; | 166 | rewind_parameter = start_parameter; |
| 169 | } | 167 | } |
| 170 | 168 | ||
| 171 | Fiber::Fiber() { | 169 | Fiber::Fiber() : impl{std::make_unique<FiberImpl>()} {} |
| 172 | impl = std::make_unique<FiberImpl>(); | ||
| 173 | } | ||
| 174 | 170 | ||
| 175 | Fiber::~Fiber() { | 171 | Fiber::~Fiber() { |
| 176 | if (released) { | 172 | if (released) { |
diff --git a/src/common/spin_lock.cpp b/src/common/spin_lock.cpp index c7b46aac6..c1524220f 100644 --- a/src/common/spin_lock.cpp +++ b/src/common/spin_lock.cpp | |||
| @@ -20,7 +20,7 @@ | |||
| 20 | 20 | ||
| 21 | namespace { | 21 | namespace { |
| 22 | 22 | ||
| 23 | void thread_pause() { | 23 | void ThreadPause() { |
| 24 | #if __x86_64__ | 24 | #if __x86_64__ |
| 25 | _mm_pause(); | 25 | _mm_pause(); |
| 26 | #elif __aarch64__ && _MSC_VER | 26 | #elif __aarch64__ && _MSC_VER |
| @@ -30,13 +30,13 @@ void thread_pause() { | |||
| 30 | #endif | 30 | #endif |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | } // namespace | 33 | } // Anonymous namespace |
| 34 | 34 | ||
| 35 | namespace Common { | 35 | namespace Common { |
| 36 | 36 | ||
| 37 | void SpinLock::lock() { | 37 | void SpinLock::lock() { |
| 38 | while (lck.test_and_set(std::memory_order_acquire)) { | 38 | while (lck.test_and_set(std::memory_order_acquire)) { |
| 39 | thread_pause(); | 39 | ThreadPause(); |
| 40 | } | 40 | } |
| 41 | } | 41 | } |
| 42 | 42 | ||
diff --git a/src/common/spin_lock.h b/src/common/spin_lock.h index 70282a961..1df5528c4 100644 --- a/src/common/spin_lock.h +++ b/src/common/spin_lock.h | |||
| @@ -8,6 +8,11 @@ | |||
| 8 | 8 | ||
| 9 | namespace Common { | 9 | namespace Common { |
| 10 | 10 | ||
| 11 | /** | ||
| 12 | * SpinLock class | ||
| 13 | * a lock similar to mutex that forces a thread to spin wait instead calling the | ||
| 14 | * supervisor. Should be used on short sequences of code. | ||
| 15 | */ | ||
| 11 | class SpinLock { | 16 | class SpinLock { |
| 12 | public: | 17 | public: |
| 13 | void lock(); | 18 | void lock(); |
diff --git a/src/common/x64/native_clock.cpp b/src/common/x64/native_clock.cpp index f1bc60fd2..424b39b1f 100644 --- a/src/common/x64/native_clock.cpp +++ b/src/common/x64/native_clock.cpp | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <chrono> | 5 | #include <chrono> |
| 6 | #include <mutex> | ||
| 6 | #include <thread> | 7 | #include <thread> |
| 7 | 8 | ||
| 8 | #ifdef _MSC_VER | 9 | #ifdef _MSC_VER |
| @@ -52,7 +53,7 @@ NativeClock::NativeClock(u64 emulated_cpu_frequency, u64 emulated_clock_frequenc | |||
| 52 | } | 53 | } |
| 53 | 54 | ||
| 54 | u64 NativeClock::GetRTSC() { | 55 | u64 NativeClock::GetRTSC() { |
| 55 | rtsc_serialize.lock(); | 56 | std::scoped_lock scope{rtsc_serialize}; |
| 56 | _mm_mfence(); | 57 | _mm_mfence(); |
| 57 | const u64 current_measure = __rdtsc(); | 58 | const u64 current_measure = __rdtsc(); |
| 58 | u64 diff = current_measure - last_measure; | 59 | u64 diff = current_measure - last_measure; |
| @@ -61,7 +62,6 @@ u64 NativeClock::GetRTSC() { | |||
| 61 | last_measure = current_measure; | 62 | last_measure = current_measure; |
| 62 | } | 63 | } |
| 63 | accumulated_ticks += diff; | 64 | accumulated_ticks += diff; |
| 64 | rtsc_serialize.unlock(); | ||
| 65 | /// The clock cannot be more precise than the guest timer, remove the lower bits | 65 | /// The clock cannot be more precise than the guest timer, remove the lower bits |
| 66 | return accumulated_ticks & inaccuracy_mask; | 66 | return accumulated_ticks & inaccuracy_mask; |
| 67 | } | 67 | } |
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 | ||
| 121 | std::shared_ptr<Dynarmic::A32::Jit> ARM_Dynarmic_32::MakeJit(Common::PageTable& page_table, | 122 | std::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 | ||
| 217 | void ARM_Dynarmic_32::ChangeProcessorId(std::size_t new_core_id) { | 218 | void 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 | ||
| 164 | std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic_64::MakeJit(Common::PageTable& page_table, | 165 | std::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 | ||
| 274 | void ARM_Dynarmic_64::ChangeProcessorId(std::size_t new_core_id) { | 275 | void 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 | ||
| 162 | void ARM_Unicorn::ChangeProcessorId(std::size_t new_core_id) { | 162 | void 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 | ||
| 445 | void System::PrepareReschedule() { | 445 | void System::PrepareReschedule() { |
| 446 | // impl->CurrentPhysicalCore().Stop(); | 446 | // Deprecated, does nothing, kept for backward compatibility. |
| 447 | } | 447 | } |
| 448 | 448 | ||
| 449 | void System::PrepareReschedule(const u32 core_index) { | 449 | void 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() { | |||
| 45 | CoreTiming::~CoreTiming() = default; | 45 | CoreTiming::~CoreTiming() = default; |
| 46 | 46 | ||
| 47 | void CoreTiming::ThreadEntry(CoreTiming& instance) { | 47 | void 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 | ||
| 109 | void CoreTiming::ScheduleEvent(s64 ns_into_future, const std::shared_ptr<EventType>& event_type, | 109 | void 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 | ||
| 121 | void CoreTiming::UnscheduleEvent(const std::shared_ptr<EventType>& event_type, u64 userdata) { | 122 | void 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 | ||
| 135 | void CoreTiming::AddTicks(u64 ticks) { | 135 | void CoreTiming::AddTicks(u64 ticks) { |
| @@ -187,8 +187,8 @@ void CoreTiming::RemoveEvent(const std::shared_ptr<EventType>& event_type) { | |||
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | std::optional<s64> CoreTiming::Advance() { | 189 | std::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 | ||
| 474 | void KernelCore::InvalidateAllInstructionCaches() { | 474 | void 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 | ||
| 40 | bool PhysicalCore::IsInterrupted() const { | ||
| 41 | return interrupt_handler.IsInterrupted(); | ||
| 42 | } | ||
| 43 | |||
| 40 | void PhysicalCore::Interrupt() { | 44 | void 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 | |||
| 12 | namespace Common { | 10 | namespace Common { |
| 13 | class SpinLock; | 11 | class SpinLock; |
| 14 | } | 12 | } |
| @@ -19,6 +17,7 @@ class Scheduler; | |||
| 19 | 17 | ||
| 20 | namespace Core { | 18 | namespace Core { |
| 21 | class ARM_Interface; | 19 | class ARM_Interface; |
| 20 | class CPUInterruptHandler; | ||
| 22 | class ExclusiveMonitor; | 21 | class ExclusiveMonitor; |
| 23 | class System; | 22 | class 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 | |||
| 243 | private: | 247 | private: |
| 244 | friend class GlobalScheduler; | 248 | friend class GlobalScheduler; |
| 245 | 249 | ||
diff --git a/src/tests/common/fibers.cpp b/src/tests/common/fibers.cpp index 12536b6d8..4fd92428f 100644 --- a/src/tests/common/fibers.cpp +++ b/src/tests/common/fibers.cpp | |||
| @@ -68,7 +68,7 @@ static void ThreadStart1(u32 id, TestControl1& test_control) { | |||
| 68 | * doing all the work required. | 68 | * doing all the work required. |
| 69 | */ | 69 | */ |
| 70 | TEST_CASE("Fibers::Setup", "[common]") { | 70 | TEST_CASE("Fibers::Setup", "[common]") { |
| 71 | constexpr u32 num_threads = 7; | 71 | constexpr std::size_t num_threads = 7; |
| 72 | TestControl1 test_control{}; | 72 | TestControl1 test_control{}; |
| 73 | test_control.thread_fibers.resize(num_threads); | 73 | test_control.thread_fibers.resize(num_threads); |
| 74 | test_control.work_fibers.resize(num_threads); | 74 | test_control.work_fibers.resize(num_threads); |