diff options
| author | 2021-08-06 22:45:18 -0700 | |
|---|---|---|
| committer | 2021-12-06 16:39:16 -0800 | |
| commit | 669a2d2c67bd9a3267286bc0c2e6e3c1dc98c154 (patch) | |
| tree | c2c3228add0d937de938081d000f62b3d6e4d2d2 /src/core | |
| parent | Merge pull request #7529 from german77/sdl2.0.18 (diff) | |
| download | yuzu-669a2d2c67bd9a3267286bc0c2e6e3c1dc98c154.tar.gz yuzu-669a2d2c67bd9a3267286bc0c2e6e3c1dc98c154.tar.xz yuzu-669a2d2c67bd9a3267286bc0c2e6e3c1dc98c154.zip | |
core: hle: kernel: Reflect non-emulated threads as core 3.
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/core.cpp | 6 | ||||
| -rw-r--r-- | src/core/core.h | 3 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_address_arbiter.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_condition_variable.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 8 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.h | 3 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 5 |
7 files changed, 17 insertions, 14 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 473ab9f81..aa96f709b 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -521,12 +521,6 @@ const ARM_Interface& System::CurrentArmInterface() const { | |||
| 521 | return impl->kernel.CurrentPhysicalCore().ArmInterface(); | 521 | return impl->kernel.CurrentPhysicalCore().ArmInterface(); |
| 522 | } | 522 | } |
| 523 | 523 | ||
| 524 | std::size_t System::CurrentCoreIndex() const { | ||
| 525 | std::size_t core = impl->kernel.GetCurrentHostThreadID(); | ||
| 526 | ASSERT(core < Core::Hardware::NUM_CPU_CORES); | ||
| 527 | return core; | ||
| 528 | } | ||
| 529 | |||
| 530 | Kernel::PhysicalCore& System::CurrentPhysicalCore() { | 524 | Kernel::PhysicalCore& System::CurrentPhysicalCore() { |
| 531 | return impl->kernel.CurrentPhysicalCore(); | 525 | return impl->kernel.CurrentPhysicalCore(); |
| 532 | } | 526 | } |
diff --git a/src/core/core.h b/src/core/core.h index 645e5c241..52ff90359 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -208,9 +208,6 @@ public: | |||
| 208 | /// Gets an ARM interface to the CPU core that is currently running | 208 | /// Gets an ARM interface to the CPU core that is currently running |
| 209 | [[nodiscard]] const ARM_Interface& CurrentArmInterface() const; | 209 | [[nodiscard]] const ARM_Interface& CurrentArmInterface() const; |
| 210 | 210 | ||
| 211 | /// Gets the index of the currently running CPU core | ||
| 212 | [[nodiscard]] std::size_t CurrentCoreIndex() const; | ||
| 213 | |||
| 214 | /// Gets the physical core for the CPU core that is currently running | 211 | /// Gets the physical core for the CPU core that is currently running |
| 215 | [[nodiscard]] Kernel::PhysicalCore& CurrentPhysicalCore(); | 212 | [[nodiscard]] Kernel::PhysicalCore& CurrentPhysicalCore(); |
| 216 | 213 | ||
diff --git a/src/core/hle/kernel/k_address_arbiter.cpp b/src/core/hle/kernel/k_address_arbiter.cpp index 1b429bc1e..6771ef621 100644 --- a/src/core/hle/kernel/k_address_arbiter.cpp +++ b/src/core/hle/kernel/k_address_arbiter.cpp | |||
| @@ -28,7 +28,7 @@ bool ReadFromUser(Core::System& system, s32* out, VAddr address) { | |||
| 28 | 28 | ||
| 29 | bool DecrementIfLessThan(Core::System& system, s32* out, VAddr address, s32 value) { | 29 | bool DecrementIfLessThan(Core::System& system, s32* out, VAddr address, s32 value) { |
| 30 | auto& monitor = system.Monitor(); | 30 | auto& monitor = system.Monitor(); |
| 31 | const auto current_core = system.CurrentCoreIndex(); | 31 | const auto current_core = system.Kernel().CurrentPhysicalCoreIndex(); |
| 32 | 32 | ||
| 33 | // TODO(bunnei): We should disable interrupts here via KScopedInterruptDisable. | 33 | // TODO(bunnei): We should disable interrupts here via KScopedInterruptDisable. |
| 34 | // TODO(bunnei): We should call CanAccessAtomic(..) here. | 34 | // TODO(bunnei): We should call CanAccessAtomic(..) here. |
| @@ -58,7 +58,7 @@ bool DecrementIfLessThan(Core::System& system, s32* out, VAddr address, s32 valu | |||
| 58 | 58 | ||
| 59 | bool UpdateIfEqual(Core::System& system, s32* out, VAddr address, s32 value, s32 new_value) { | 59 | bool UpdateIfEqual(Core::System& system, s32* out, VAddr address, s32 value, s32 new_value) { |
| 60 | auto& monitor = system.Monitor(); | 60 | auto& monitor = system.Monitor(); |
| 61 | const auto current_core = system.CurrentCoreIndex(); | 61 | const auto current_core = system.Kernel().CurrentPhysicalCoreIndex(); |
| 62 | 62 | ||
| 63 | // TODO(bunnei): We should disable interrupts here via KScopedInterruptDisable. | 63 | // TODO(bunnei): We should disable interrupts here via KScopedInterruptDisable. |
| 64 | // TODO(bunnei): We should call CanAccessAtomic(..) here. | 64 | // TODO(bunnei): We should call CanAccessAtomic(..) here. |
diff --git a/src/core/hle/kernel/k_condition_variable.cpp b/src/core/hle/kernel/k_condition_variable.cpp index 7fa9b8cc3..ed6f328fc 100644 --- a/src/core/hle/kernel/k_condition_variable.cpp +++ b/src/core/hle/kernel/k_condition_variable.cpp | |||
| @@ -33,7 +33,7 @@ bool WriteToUser(Core::System& system, VAddr address, const u32* p) { | |||
| 33 | bool UpdateLockAtomic(Core::System& system, u32* out, VAddr address, u32 if_zero, | 33 | bool UpdateLockAtomic(Core::System& system, u32* out, VAddr address, u32 if_zero, |
| 34 | u32 new_orr_mask) { | 34 | u32 new_orr_mask) { |
| 35 | auto& monitor = system.Monitor(); | 35 | auto& monitor = system.Monitor(); |
| 36 | const auto current_core = system.CurrentCoreIndex(); | 36 | const auto current_core = system.Kernel().CurrentPhysicalCoreIndex(); |
| 37 | 37 | ||
| 38 | // Load the value from the address. | 38 | // Load the value from the address. |
| 39 | const auto expected = monitor.ExclusiveRead32(current_core, address); | 39 | const auto expected = monitor.ExclusiveRead32(current_core, address); |
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 45e86a677..04926a291 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -845,6 +845,14 @@ const Kernel::PhysicalCore& KernelCore::PhysicalCore(std::size_t id) const { | |||
| 845 | return impl->cores[id]; | 845 | return impl->cores[id]; |
| 846 | } | 846 | } |
| 847 | 847 | ||
| 848 | size_t KernelCore::CurrentPhysicalCoreIndex() const { | ||
| 849 | const u32 core_id = impl->GetCurrentHostThreadID(); | ||
| 850 | if (core_id >= Core::Hardware::NUM_CPU_CORES) { | ||
| 851 | return Core::Hardware::NUM_CPU_CORES - 1; | ||
| 852 | } | ||
| 853 | return core_id; | ||
| 854 | } | ||
| 855 | |||
| 848 | Kernel::PhysicalCore& KernelCore::CurrentPhysicalCore() { | 856 | Kernel::PhysicalCore& KernelCore::CurrentPhysicalCore() { |
| 849 | u32 core_id = impl->GetCurrentHostThreadID(); | 857 | u32 core_id = impl->GetCurrentHostThreadID(); |
| 850 | ASSERT(core_id < Core::Hardware::NUM_CPU_CORES); | 858 | ASSERT(core_id < Core::Hardware::NUM_CPU_CORES); |
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index d2ceae950..3499f8b90 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h | |||
| @@ -148,6 +148,9 @@ public: | |||
| 148 | /// Gets the an instance of the respective physical CPU core. | 148 | /// Gets the an instance of the respective physical CPU core. |
| 149 | const Kernel::PhysicalCore& PhysicalCore(std::size_t id) const; | 149 | const Kernel::PhysicalCore& PhysicalCore(std::size_t id) const; |
| 150 | 150 | ||
| 151 | /// Gets the current physical core index for the running host thread. | ||
| 152 | std::size_t CurrentPhysicalCoreIndex() const; | ||
| 153 | |||
| 151 | /// Gets the sole instance of the Scheduler at the current running core. | 154 | /// Gets the sole instance of the Scheduler at the current running core. |
| 152 | Kernel::KScheduler* CurrentScheduler(); | 155 | Kernel::KScheduler* CurrentScheduler(); |
| 153 | 156 | ||
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index f0cd8471e..e5e879eb5 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -873,7 +873,7 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle | |||
| 873 | const u64 thread_ticks = current_thread->GetCpuTime(); | 873 | const u64 thread_ticks = current_thread->GetCpuTime(); |
| 874 | 874 | ||
| 875 | out_ticks = thread_ticks + (core_timing.GetCPUTicks() - prev_ctx_ticks); | 875 | out_ticks = thread_ticks + (core_timing.GetCPUTicks() - prev_ctx_ticks); |
| 876 | } else if (same_thread && info_sub_id == system.CurrentCoreIndex()) { | 876 | } else if (same_thread && info_sub_id == system.Kernel().CurrentPhysicalCoreIndex()) { |
| 877 | out_ticks = core_timing.GetCPUTicks() - prev_ctx_ticks; | 877 | out_ticks = core_timing.GetCPUTicks() - prev_ctx_ticks; |
| 878 | } | 878 | } |
| 879 | 879 | ||
| @@ -887,7 +887,8 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle | |||
| 887 | return ResultInvalidHandle; | 887 | return ResultInvalidHandle; |
| 888 | } | 888 | } |
| 889 | 889 | ||
| 890 | if (info_sub_id != 0xFFFFFFFFFFFFFFFF && info_sub_id != system.CurrentCoreIndex()) { | 890 | if (info_sub_id != 0xFFFFFFFFFFFFFFFF && |
| 891 | info_sub_id != system.Kernel().CurrentPhysicalCoreIndex()) { | ||
| 891 | LOG_ERROR(Kernel_SVC, "Core is not the current core, got {}", info_sub_id); | 892 | LOG_ERROR(Kernel_SVC, "Core is not the current core, got {}", info_sub_id); |
| 892 | return ResultInvalidCombination; | 893 | return ResultInvalidCombination; |
| 893 | } | 894 | } |