diff options
| author | 2018-02-18 14:46:11 -0500 | |
|---|---|---|
| committer | 2018-02-18 14:46:11 -0500 | |
| commit | cec0d4f1918c640524fa0087549da2fab0960e24 (patch) | |
| tree | 3b2c3e28cc798b6cdf081d6ddd6e13554458b72a | |
| parent | Merge pull request #198 from N00byKing/clang (diff) | |
| download | yuzu-cec0d4f1918c640524fa0087549da2fab0960e24.tar.gz yuzu-cec0d4f1918c640524fa0087549da2fab0960e24.tar.xz yuzu-cec0d4f1918c640524fa0087549da2fab0960e24.zip | |
kernel: Remove unused address_arbiter code.
| -rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/address_arbiter.cpp | 91 | ||||
| -rw-r--r-- | src/core/hle/kernel/address_arbiter.h | 60 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 34 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.h | 12 |
5 files changed, 0 insertions, 199 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index ce68194c5..2f1fd7880 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -28,8 +28,6 @@ add_library(core STATIC | |||
| 28 | hle/config_mem.h | 28 | hle/config_mem.h |
| 29 | hle/ipc.h | 29 | hle/ipc.h |
| 30 | hle/ipc_helpers.h | 30 | hle/ipc_helpers.h |
| 31 | hle/kernel/address_arbiter.cpp | ||
| 32 | hle/kernel/address_arbiter.h | ||
| 33 | hle/kernel/client_port.cpp | 31 | hle/kernel/client_port.cpp |
| 34 | hle/kernel/client_port.h | 32 | hle/kernel/client_port.h |
| 35 | hle/kernel/client_session.cpp | 33 | hle/kernel/client_session.cpp |
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp deleted file mode 100644 index 776d342f0..000000000 --- a/src/core/hle/kernel/address_arbiter.cpp +++ /dev/null | |||
| @@ -1,91 +0,0 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/common_types.h" | ||
| 6 | #include "common/logging/log.h" | ||
| 7 | #include "core/hle/kernel/address_arbiter.h" | ||
| 8 | #include "core/hle/kernel/errors.h" | ||
| 9 | #include "core/hle/kernel/thread.h" | ||
| 10 | #include "core/memory.h" | ||
| 11 | |||
| 12 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 13 | // Kernel namespace | ||
| 14 | |||
| 15 | namespace Kernel { | ||
| 16 | |||
| 17 | AddressArbiter::AddressArbiter() {} | ||
| 18 | AddressArbiter::~AddressArbiter() {} | ||
| 19 | |||
| 20 | SharedPtr<AddressArbiter> AddressArbiter::Create(std::string name) { | ||
| 21 | SharedPtr<AddressArbiter> address_arbiter(new AddressArbiter); | ||
| 22 | |||
| 23 | address_arbiter->name = std::move(name); | ||
| 24 | |||
| 25 | return address_arbiter; | ||
| 26 | } | ||
| 27 | |||
| 28 | ResultCode AddressArbiter::ArbitrateAddress(ArbitrationType type, VAddr address, s32 value, | ||
| 29 | u64 nanoseconds) { | ||
| 30 | switch (type) { | ||
| 31 | |||
| 32 | // Signal thread(s) waiting for arbitrate address... | ||
| 33 | case ArbitrationType::Signal: | ||
| 34 | // Negative value means resume all threads | ||
| 35 | if (value < 0) { | ||
| 36 | ArbitrateAllThreads(address); | ||
| 37 | } else { | ||
| 38 | // Resume first N threads | ||
| 39 | for (int i = 0; i < value; i++) | ||
| 40 | ArbitrateHighestPriorityThread(address); | ||
| 41 | } | ||
| 42 | break; | ||
| 43 | |||
| 44 | // Wait current thread (acquire the arbiter)... | ||
| 45 | case ArbitrationType::WaitIfLessThan: | ||
| 46 | if ((s32)Memory::Read32(address) < value) { | ||
| 47 | Kernel::WaitCurrentThread_ArbitrateAddress(address); | ||
| 48 | } | ||
| 49 | break; | ||
| 50 | case ArbitrationType::WaitIfLessThanWithTimeout: | ||
| 51 | if ((s32)Memory::Read32(address) < value) { | ||
| 52 | Kernel::WaitCurrentThread_ArbitrateAddress(address); | ||
| 53 | GetCurrentThread()->WakeAfterDelay(nanoseconds); | ||
| 54 | } | ||
| 55 | break; | ||
| 56 | case ArbitrationType::DecrementAndWaitIfLessThan: { | ||
| 57 | s32 memory_value = Memory::Read32(address); | ||
| 58 | if (memory_value < value) { | ||
| 59 | // Only change the memory value if the thread should wait | ||
| 60 | Memory::Write32(address, (s32)memory_value - 1); | ||
| 61 | Kernel::WaitCurrentThread_ArbitrateAddress(address); | ||
| 62 | } | ||
| 63 | break; | ||
| 64 | } | ||
| 65 | case ArbitrationType::DecrementAndWaitIfLessThanWithTimeout: { | ||
| 66 | s32 memory_value = Memory::Read32(address); | ||
| 67 | if (memory_value < value) { | ||
| 68 | // Only change the memory value if the thread should wait | ||
| 69 | Memory::Write32(address, (s32)memory_value - 1); | ||
| 70 | Kernel::WaitCurrentThread_ArbitrateAddress(address); | ||
| 71 | GetCurrentThread()->WakeAfterDelay(nanoseconds); | ||
| 72 | } | ||
| 73 | break; | ||
| 74 | } | ||
| 75 | |||
| 76 | default: | ||
| 77 | LOG_ERROR(Kernel, "unknown type=%d", type); | ||
| 78 | return ERR_INVALID_ENUM_VALUE_FND; | ||
| 79 | } | ||
| 80 | |||
| 81 | // The calls that use a timeout seem to always return a Timeout error even if they did not put | ||
| 82 | // the thread to sleep | ||
| 83 | if (type == ArbitrationType::WaitIfLessThanWithTimeout || | ||
| 84 | type == ArbitrationType::DecrementAndWaitIfLessThanWithTimeout) { | ||
| 85 | |||
| 86 | return RESULT_TIMEOUT; | ||
| 87 | } | ||
| 88 | return RESULT_SUCCESS; | ||
| 89 | } | ||
| 90 | |||
| 91 | } // namespace Kernel | ||
diff --git a/src/core/hle/kernel/address_arbiter.h b/src/core/hle/kernel/address_arbiter.h deleted file mode 100644 index f902ddf2d..000000000 --- a/src/core/hle/kernel/address_arbiter.h +++ /dev/null | |||
| @@ -1,60 +0,0 @@ | |||
| 1 | // Copyright 2014 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "common/common_types.h" | ||
| 8 | #include "core/hle/kernel/kernel.h" | ||
| 9 | #include "core/hle/result.h" | ||
| 10 | |||
| 11 | // Address arbiters are an underlying kernel synchronization object that can be created/used via | ||
| 12 | // supervisor calls (SVCs). They function as sort of a global lock. Typically, games/other CTR | ||
| 13 | // applications use them as an underlying mechanism to implement thread-safe barriers, events, and | ||
| 14 | // semphores. | ||
| 15 | |||
| 16 | //////////////////////////////////////////////////////////////////////////////////////////////////// | ||
| 17 | // Kernel namespace | ||
| 18 | |||
| 19 | namespace Kernel { | ||
| 20 | |||
| 21 | enum class ArbitrationType : u32 { | ||
| 22 | Signal, | ||
| 23 | WaitIfLessThan, | ||
| 24 | DecrementAndWaitIfLessThan, | ||
| 25 | WaitIfLessThanWithTimeout, | ||
| 26 | DecrementAndWaitIfLessThanWithTimeout, | ||
| 27 | }; | ||
| 28 | |||
| 29 | class AddressArbiter final : public Object { | ||
| 30 | public: | ||
| 31 | /** | ||
| 32 | * Creates an address arbiter. | ||
| 33 | * | ||
| 34 | * @param name Optional name used for debugging. | ||
| 35 | * @returns The created AddressArbiter. | ||
| 36 | */ | ||
| 37 | static SharedPtr<AddressArbiter> Create(std::string name = "Unknown"); | ||
| 38 | |||
| 39 | std::string GetTypeName() const override { | ||
| 40 | return "Arbiter"; | ||
| 41 | } | ||
| 42 | std::string GetName() const override { | ||
| 43 | return name; | ||
| 44 | } | ||
| 45 | |||
| 46 | static const HandleType HANDLE_TYPE = HandleType::AddressArbiter; | ||
| 47 | HandleType GetHandleType() const override { | ||
| 48 | return HANDLE_TYPE; | ||
| 49 | } | ||
| 50 | |||
| 51 | std::string name; ///< Name of address arbiter object (optional) | ||
| 52 | |||
| 53 | ResultCode ArbitrateAddress(ArbitrationType type, VAddr address, s32 value, u64 nanoseconds); | ||
| 54 | |||
| 55 | private: | ||
| 56 | AddressArbiter(); | ||
| 57 | ~AddressArbiter() override; | ||
| 58 | }; | ||
| 59 | |||
| 60 | } // namespace Kernel | ||
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 130b669a0..0fcc65cbf 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -109,40 +109,6 @@ void Thread::Stop() { | |||
| 109 | Kernel::g_current_process->tls_slots[tls_page].reset(tls_slot); | 109 | Kernel::g_current_process->tls_slots[tls_page].reset(tls_slot); |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | Thread* ArbitrateHighestPriorityThread(u32 address) { | ||
| 113 | Thread* highest_priority_thread = nullptr; | ||
| 114 | u32 priority = THREADPRIO_LOWEST; | ||
| 115 | |||
| 116 | // Iterate through threads, find highest priority thread that is waiting to be arbitrated... | ||
| 117 | for (auto& thread : thread_list) { | ||
| 118 | if (!CheckWait_AddressArbiter(thread.get(), address)) | ||
| 119 | continue; | ||
| 120 | |||
| 121 | if (thread == nullptr) | ||
| 122 | continue; | ||
| 123 | |||
| 124 | if (thread->current_priority <= priority) { | ||
| 125 | highest_priority_thread = thread.get(); | ||
| 126 | priority = thread->current_priority; | ||
| 127 | } | ||
| 128 | } | ||
| 129 | |||
| 130 | // If a thread was arbitrated, resume it | ||
| 131 | if (nullptr != highest_priority_thread) { | ||
| 132 | highest_priority_thread->ResumeFromWait(); | ||
| 133 | } | ||
| 134 | |||
| 135 | return highest_priority_thread; | ||
| 136 | } | ||
| 137 | |||
| 138 | void ArbitrateAllThreads(u32 address) { | ||
| 139 | // Resume all threads found to be waiting on the address | ||
| 140 | for (auto& thread : thread_list) { | ||
| 141 | if (CheckWait_AddressArbiter(thread.get(), address)) | ||
| 142 | thread->ResumeFromWait(); | ||
| 143 | } | ||
| 144 | } | ||
| 145 | |||
| 146 | /** | 112 | /** |
| 147 | * Switches the CPU's active thread context to that of the specified thread | 113 | * Switches the CPU's active thread context to that of the specified thread |
| 148 | * @param new_thread The thread to switch to | 114 | * @param new_thread The thread to switch to |
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index bbffaf4cf..aa80a51a9 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -260,18 +260,6 @@ bool HaveReadyThreads(); | |||
| 260 | void Reschedule(); | 260 | void Reschedule(); |
| 261 | 261 | ||
| 262 | /** | 262 | /** |
| 263 | * Arbitrate the highest priority thread that is waiting | ||
| 264 | * @param address The address for which waiting threads should be arbitrated | ||
| 265 | */ | ||
| 266 | Thread* ArbitrateHighestPriorityThread(VAddr address); | ||
| 267 | |||
| 268 | /** | ||
| 269 | * Arbitrate all threads currently waiting. | ||
| 270 | * @param address The address for which waiting threads should be arbitrated | ||
| 271 | */ | ||
| 272 | void ArbitrateAllThreads(VAddr address); | ||
| 273 | |||
| 274 | /** | ||
| 275 | * Gets the current thread | 263 | * Gets the current thread |
| 276 | */ | 264 | */ |
| 277 | Thread* GetCurrentThread(); | 265 | Thread* GetCurrentThread(); |