diff options
| author | 2021-08-06 22:45:18 -0700 | |
|---|---|---|
| committer | 2021-08-07 12:18:47 -0700 | |
| commit | 68eee948758eeddb4f3f091cd89c870e481b278b (patch) | |
| tree | 00d0687f171ad686ceea0283c157332cce406d1f /src | |
| parent | core: cpu_manager: Use jthread. (diff) | |
| download | yuzu-68eee948758eeddb4f3f091cd89c870e481b278b.tar.gz yuzu-68eee948758eeddb4f3f091cd89c870e481b278b.tar.xz yuzu-68eee948758eeddb4f3f091cd89c870e481b278b.zip | |
core: hle: kernel: Reflect non-emulated threads as core 3.
Diffstat (limited to 'src')
| -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 | 2 |
7 files changed, 15 insertions, 13 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index d3e84c4ef..5d8a61b3a 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -494,12 +494,6 @@ const ARM_Interface& System::CurrentArmInterface() const { | |||
| 494 | return impl->kernel.CurrentPhysicalCore().ArmInterface(); | 494 | return impl->kernel.CurrentPhysicalCore().ArmInterface(); |
| 495 | } | 495 | } |
| 496 | 496 | ||
| 497 | std::size_t System::CurrentCoreIndex() const { | ||
| 498 | std::size_t core = impl->kernel.GetCurrentHostThreadID(); | ||
| 499 | ASSERT(core < Core::Hardware::NUM_CPU_CORES); | ||
| 500 | return core; | ||
| 501 | } | ||
| 502 | |||
| 503 | Kernel::PhysicalCore& System::CurrentPhysicalCore() { | 497 | Kernel::PhysicalCore& System::CurrentPhysicalCore() { |
| 504 | return impl->kernel.CurrentPhysicalCore(); | 498 | return impl->kernel.CurrentPhysicalCore(); |
| 505 | } | 499 | } |
diff --git a/src/core/core.h b/src/core/core.h index ea143043c..cd9af0c07 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -205,9 +205,6 @@ public: | |||
| 205 | /// Gets an ARM interface to the CPU core that is currently running | 205 | /// Gets an ARM interface to the CPU core that is currently running |
| 206 | [[nodiscard]] const ARM_Interface& CurrentArmInterface() const; | 206 | [[nodiscard]] const ARM_Interface& CurrentArmInterface() const; |
| 207 | 207 | ||
| 208 | /// Gets the index of the currently running CPU core | ||
| 209 | [[nodiscard]] std::size_t CurrentCoreIndex() const; | ||
| 210 | |||
| 211 | /// Gets the physical core for the CPU core that is currently running | 208 | /// Gets the physical core for the CPU core that is currently running |
| 212 | [[nodiscard]] Kernel::PhysicalCore& CurrentPhysicalCore(); | 209 | [[nodiscard]] Kernel::PhysicalCore& CurrentPhysicalCore(); |
| 213 | 210 | ||
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 ef14ad1d2..4174f35fd 100644 --- a/src/core/hle/kernel/k_condition_variable.cpp +++ b/src/core/hle/kernel/k_condition_variable.cpp | |||
| @@ -35,7 +35,7 @@ bool WriteToUser(Core::System& system, VAddr address, const u32* p) { | |||
| 35 | bool UpdateLockAtomic(Core::System& system, u32* out, VAddr address, u32 if_zero, | 35 | bool UpdateLockAtomic(Core::System& system, u32* out, VAddr address, u32 if_zero, |
| 36 | u32 new_orr_mask) { | 36 | u32 new_orr_mask) { |
| 37 | auto& monitor = system.Monitor(); | 37 | auto& monitor = system.Monitor(); |
| 38 | const auto current_core = system.CurrentCoreIndex(); | 38 | const auto current_core = system.Kernel().CurrentPhysicalCoreIndex(); |
| 39 | 39 | ||
| 40 | // Load the value from the address. | 40 | // Load the value from the address. |
| 41 | const auto expected = monitor.ExclusiveRead32(current_core, address); | 41 | 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 92fbc5532..b0b130719 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -824,6 +824,14 @@ const Kernel::PhysicalCore& KernelCore::PhysicalCore(std::size_t id) const { | |||
| 824 | return impl->cores[id]; | 824 | return impl->cores[id]; |
| 825 | } | 825 | } |
| 826 | 826 | ||
| 827 | size_t KernelCore::CurrentPhysicalCoreIndex() const { | ||
| 828 | const u32 core_id = impl->GetCurrentHostThreadID(); | ||
| 829 | if (core_id >= Core::Hardware::NUM_CPU_CORES) { | ||
| 830 | return Core::Hardware::NUM_CPU_CORES - 1; | ||
| 831 | } | ||
| 832 | return core_id; | ||
| 833 | } | ||
| 834 | |||
| 827 | Kernel::PhysicalCore& KernelCore::CurrentPhysicalCore() { | 835 | Kernel::PhysicalCore& KernelCore::CurrentPhysicalCore() { |
| 828 | u32 core_id = impl->GetCurrentHostThreadID(); | 836 | u32 core_id = impl->GetCurrentHostThreadID(); |
| 829 | ASSERT(core_id < Core::Hardware::NUM_CPU_CORES); | 837 | 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 3a6db0b1c..57535433b 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h | |||
| @@ -146,6 +146,9 @@ public: | |||
| 146 | /// Gets the an instance of the respective physical CPU core. | 146 | /// Gets the an instance of the respective physical CPU core. |
| 147 | const Kernel::PhysicalCore& PhysicalCore(std::size_t id) const; | 147 | const Kernel::PhysicalCore& PhysicalCore(std::size_t id) const; |
| 148 | 148 | ||
| 149 | /// Gets the current physical core index for the running host thread. | ||
| 150 | std::size_t CurrentPhysicalCoreIndex() const; | ||
| 151 | |||
| 149 | /// Gets the sole instance of the Scheduler at the current running core. | 152 | /// Gets the sole instance of the Scheduler at the current running core. |
| 150 | Kernel::KScheduler* CurrentScheduler(); | 153 | Kernel::KScheduler* CurrentScheduler(); |
| 151 | 154 | ||
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 2eb532472..a90b291da 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -877,7 +877,7 @@ static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle | |||
| 877 | const u64 thread_ticks = current_thread->GetCpuTime(); | 877 | const u64 thread_ticks = current_thread->GetCpuTime(); |
| 878 | 878 | ||
| 879 | out_ticks = thread_ticks + (core_timing.GetCPUTicks() - prev_ctx_ticks); | 879 | out_ticks = thread_ticks + (core_timing.GetCPUTicks() - prev_ctx_ticks); |
| 880 | } else if (same_thread && info_sub_id == system.CurrentCoreIndex()) { | 880 | } else if (same_thread && info_sub_id == system.Kernel().CurrentPhysicalCoreIndex()) { |
| 881 | out_ticks = core_timing.GetCPUTicks() - prev_ctx_ticks; | 881 | out_ticks = core_timing.GetCPUTicks() - prev_ctx_ticks; |
| 882 | } | 882 | } |
| 883 | 883 | ||