diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/CMakeLists.txt | 5 | ||||
| -rw-r--r-- | src/core/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/core/hid/emulated_console.cpp | 3 | ||||
| -rw-r--r-- | src/core/hid/emulated_console.h | 2 | ||||
| -rw-r--r-- | src/core/hid/motion_input.cpp | 12 | ||||
| -rw-r--r-- | src/core/hid/motion_input.h | 5 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_process.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 5 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 9 | ||||
| -rw-r--r-- | src/core/hle/lock.cpp | 9 | ||||
| -rw-r--r-- | src/core/hle/lock.h | 18 | ||||
| -rw-r--r-- | src/core/hle/service/bcat/backend/backend.cpp | 12 | ||||
| -rw-r--r-- | src/core/hle/service/bcat/backend/backend.h | 5 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/console_sixaxis.cpp | 20 | ||||
| -rw-r--r-- | src/core/hle/service/hid/controllers/console_sixaxis.h | 10 | ||||
| -rw-r--r-- | src/core/hle/service/nfp/nfp.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu/applets/qt_controller.cpp | 3 | ||||
| -rw-r--r-- | src/yuzu/applets/qt_error.cpp | 3 | ||||
| -rw-r--r-- | src/yuzu/applets/qt_profile_select.cpp | 3 |
19 files changed, 42 insertions, 88 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 919da4a53..790193b00 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt | |||
| @@ -22,6 +22,11 @@ add_custom_command(OUTPUT scm_rev.cpp | |||
| 22 | -DTITLE_BAR_FORMAT_RUNNING=${TITLE_BAR_FORMAT_RUNNING} | 22 | -DTITLE_BAR_FORMAT_RUNNING=${TITLE_BAR_FORMAT_RUNNING} |
| 23 | -DBUILD_TAG=${BUILD_TAG} | 23 | -DBUILD_TAG=${BUILD_TAG} |
| 24 | -DBUILD_ID=${DISPLAY_VERSION} | 24 | -DBUILD_ID=${DISPLAY_VERSION} |
| 25 | -DGIT_REF_SPEC=${GIT_REF_SPEC} | ||
| 26 | -DGIT_REV=${GIT_REV} | ||
| 27 | -DGIT_DESC=${GIT_DESC} | ||
| 28 | -DGIT_BRANCH=${GIT_BRANCH} | ||
| 29 | -DBUILD_FULLNAME=${BUILD_FULLNAME} | ||
| 25 | -DGIT_EXECUTABLE=${GIT_EXECUTABLE} | 30 | -DGIT_EXECUTABLE=${GIT_EXECUTABLE} |
| 26 | -P ${CMAKE_SOURCE_DIR}/CMakeModules/GenerateSCMRev.cmake | 31 | -P ${CMAKE_SOURCE_DIR}/CMakeModules/GenerateSCMRev.cmake |
| 27 | DEPENDS | 32 | DEPENDS |
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 49bed614a..698c4f912 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt | |||
| @@ -265,8 +265,6 @@ add_library(core STATIC | |||
| 265 | hle/kernel/svc_wrap.h | 265 | hle/kernel/svc_wrap.h |
| 266 | hle/kernel/time_manager.cpp | 266 | hle/kernel/time_manager.cpp |
| 267 | hle/kernel/time_manager.h | 267 | hle/kernel/time_manager.h |
| 268 | hle/lock.cpp | ||
| 269 | hle/lock.h | ||
| 270 | hle/result.h | 268 | hle/result.h |
| 271 | hle/service/acc/acc.cpp | 269 | hle/service/acc/acc.cpp |
| 272 | hle/service/acc/acc.h | 270 | hle/service/acc/acc.h |
diff --git a/src/core/hid/emulated_console.cpp b/src/core/hid/emulated_console.cpp index 685ec080c..08f8af551 100644 --- a/src/core/hid/emulated_console.cpp +++ b/src/core/hid/emulated_console.cpp | |||
| @@ -161,7 +161,10 @@ void EmulatedConsole::SetMotion(const Common::Input::CallbackStatus& callback) { | |||
| 161 | motion.rotation = emulated.GetGyroscope(); | 161 | motion.rotation = emulated.GetGyroscope(); |
| 162 | motion.orientation = emulated.GetOrientation(); | 162 | motion.orientation = emulated.GetOrientation(); |
| 163 | motion.quaternion = emulated.GetQuaternion(); | 163 | motion.quaternion = emulated.GetQuaternion(); |
| 164 | motion.gyro_bias = emulated.GetGyroBias(); | ||
| 164 | motion.is_at_rest = !emulated.IsMoving(motion_sensitivity); | 165 | motion.is_at_rest = !emulated.IsMoving(motion_sensitivity); |
| 166 | // Find what is this value | ||
| 167 | motion.verticalization_error = 0.0f; | ||
| 165 | 168 | ||
| 166 | TriggerOnChange(ConsoleTriggerType::Motion); | 169 | TriggerOnChange(ConsoleTriggerType::Motion); |
| 167 | } | 170 | } |
diff --git a/src/core/hid/emulated_console.h b/src/core/hid/emulated_console.h index 3afd284d5..707419102 100644 --- a/src/core/hid/emulated_console.h +++ b/src/core/hid/emulated_console.h | |||
| @@ -50,6 +50,8 @@ struct ConsoleMotion { | |||
| 50 | Common::Vec3f rotation{}; | 50 | Common::Vec3f rotation{}; |
| 51 | std::array<Common::Vec3f, 3> orientation{}; | 51 | std::array<Common::Vec3f, 3> orientation{}; |
| 52 | Common::Quaternion<f32> quaternion{}; | 52 | Common::Quaternion<f32> quaternion{}; |
| 53 | Common::Vec3f gyro_bias{}; | ||
| 54 | f32 verticalization_error{}; | ||
| 53 | bool is_at_rest{}; | 55 | bool is_at_rest{}; |
| 54 | }; | 56 | }; |
| 55 | 57 | ||
diff --git a/src/core/hid/motion_input.cpp b/src/core/hid/motion_input.cpp index c25fea966..a23f192d7 100644 --- a/src/core/hid/motion_input.cpp +++ b/src/core/hid/motion_input.cpp | |||
| @@ -23,11 +23,11 @@ void MotionInput::SetAcceleration(const Common::Vec3f& acceleration) { | |||
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | void MotionInput::SetGyroscope(const Common::Vec3f& gyroscope) { | 25 | void MotionInput::SetGyroscope(const Common::Vec3f& gyroscope) { |
| 26 | gyro = gyroscope - gyro_drift; | 26 | gyro = gyroscope - gyro_bias; |
| 27 | 27 | ||
| 28 | // Auto adjust drift to minimize drift | 28 | // Auto adjust drift to minimize drift |
| 29 | if (!IsMoving(0.1f)) { | 29 | if (!IsMoving(0.1f)) { |
| 30 | gyro_drift = (gyro_drift * 0.9999f) + (gyroscope * 0.0001f); | 30 | gyro_bias = (gyro_bias * 0.9999f) + (gyroscope * 0.0001f); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | if (gyro.Length2() < gyro_threshold) { | 33 | if (gyro.Length2() < gyro_threshold) { |
| @@ -41,8 +41,8 @@ void MotionInput::SetQuaternion(const Common::Quaternion<f32>& quaternion) { | |||
| 41 | quat = quaternion; | 41 | quat = quaternion; |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | void MotionInput::SetGyroDrift(const Common::Vec3f& drift) { | 44 | void MotionInput::SetGyroBias(const Common::Vec3f& bias) { |
| 45 | gyro_drift = drift; | 45 | gyro_bias = bias; |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | void MotionInput::SetGyroThreshold(f32 threshold) { | 48 | void MotionInput::SetGyroThreshold(f32 threshold) { |
| @@ -192,6 +192,10 @@ Common::Vec3f MotionInput::GetGyroscope() const { | |||
| 192 | return gyro; | 192 | return gyro; |
| 193 | } | 193 | } |
| 194 | 194 | ||
| 195 | Common::Vec3f MotionInput::GetGyroBias() const { | ||
| 196 | return gyro_bias; | ||
| 197 | } | ||
| 198 | |||
| 195 | Common::Quaternion<f32> MotionInput::GetQuaternion() const { | 199 | Common::Quaternion<f32> MotionInput::GetQuaternion() const { |
| 196 | return quat; | 200 | return quat; |
| 197 | } | 201 | } |
diff --git a/src/core/hid/motion_input.h b/src/core/hid/motion_input.h index 5b5b420bb..bca4520fa 100644 --- a/src/core/hid/motion_input.h +++ b/src/core/hid/motion_input.h | |||
| @@ -24,7 +24,7 @@ public: | |||
| 24 | void SetAcceleration(const Common::Vec3f& acceleration); | 24 | void SetAcceleration(const Common::Vec3f& acceleration); |
| 25 | void SetGyroscope(const Common::Vec3f& gyroscope); | 25 | void SetGyroscope(const Common::Vec3f& gyroscope); |
| 26 | void SetQuaternion(const Common::Quaternion<f32>& quaternion); | 26 | void SetQuaternion(const Common::Quaternion<f32>& quaternion); |
| 27 | void SetGyroDrift(const Common::Vec3f& drift); | 27 | void SetGyroBias(const Common::Vec3f& bias); |
| 28 | void SetGyroThreshold(f32 threshold); | 28 | void SetGyroThreshold(f32 threshold); |
| 29 | 29 | ||
| 30 | void EnableReset(bool reset); | 30 | void EnableReset(bool reset); |
| @@ -36,6 +36,7 @@ public: | |||
| 36 | [[nodiscard]] std::array<Common::Vec3f, 3> GetOrientation() const; | 36 | [[nodiscard]] std::array<Common::Vec3f, 3> GetOrientation() const; |
| 37 | [[nodiscard]] Common::Vec3f GetAcceleration() const; | 37 | [[nodiscard]] Common::Vec3f GetAcceleration() const; |
| 38 | [[nodiscard]] Common::Vec3f GetGyroscope() const; | 38 | [[nodiscard]] Common::Vec3f GetGyroscope() const; |
| 39 | [[nodiscard]] Common::Vec3f GetGyroBias() const; | ||
| 39 | [[nodiscard]] Common::Vec3f GetRotations() const; | 40 | [[nodiscard]] Common::Vec3f GetRotations() const; |
| 40 | [[nodiscard]] Common::Quaternion<f32> GetQuaternion() const; | 41 | [[nodiscard]] Common::Quaternion<f32> GetQuaternion() const; |
| 41 | 42 | ||
| @@ -69,7 +70,7 @@ private: | |||
| 69 | Common::Vec3f gyro; | 70 | Common::Vec3f gyro; |
| 70 | 71 | ||
| 71 | // Vector to be substracted from gyro measurements | 72 | // Vector to be substracted from gyro measurements |
| 72 | Common::Vec3f gyro_drift; | 73 | Common::Vec3f gyro_bias; |
| 73 | 74 | ||
| 74 | // Minimum gyro amplitude to detect if the device is moving | 75 | // Minimum gyro amplitude to detect if the device is moving |
| 75 | f32 gyro_threshold = 0.0f; | 76 | f32 gyro_threshold = 0.0f; |
diff --git a/src/core/hle/kernel/k_process.cpp b/src/core/hle/kernel/k_process.cpp index 90dda40dc..aee313995 100644 --- a/src/core/hle/kernel/k_process.cpp +++ b/src/core/hle/kernel/k_process.cpp | |||
| @@ -28,7 +28,6 @@ | |||
| 28 | #include "core/hle/kernel/k_thread.h" | 28 | #include "core/hle/kernel/k_thread.h" |
| 29 | #include "core/hle/kernel/kernel.h" | 29 | #include "core/hle/kernel/kernel.h" |
| 30 | #include "core/hle/kernel/svc_results.h" | 30 | #include "core/hle/kernel/svc_results.h" |
| 31 | #include "core/hle/lock.h" | ||
| 32 | #include "core/memory.h" | 31 | #include "core/memory.h" |
| 33 | 32 | ||
| 34 | namespace Kernel { | 33 | namespace Kernel { |
| @@ -543,7 +542,6 @@ void KProcess::FreeTLSRegion(VAddr tls_address) { | |||
| 543 | } | 542 | } |
| 544 | 543 | ||
| 545 | void KProcess::LoadModule(CodeSet code_set, VAddr base_addr) { | 544 | void KProcess::LoadModule(CodeSet code_set, VAddr base_addr) { |
| 546 | std::lock_guard lock{HLE::g_hle_lock}; | ||
| 547 | const auto ReprotectSegment = [&](const CodeSet::Segment& segment, | 545 | const auto ReprotectSegment = [&](const CodeSet::Segment& segment, |
| 548 | KMemoryPermission permission) { | 546 | KMemoryPermission permission) { |
| 549 | page_table->SetProcessMemoryPermission(segment.addr + base_addr, segment.size, permission); | 547 | page_table->SetProcessMemoryPermission(segment.addr + base_addr, segment.size, permission); |
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 2e4e4cb1c..1225e1fba 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -182,7 +182,10 @@ struct KernelCore::Impl { | |||
| 182 | // Shutdown all processes. | 182 | // Shutdown all processes. |
| 183 | if (current_process) { | 183 | if (current_process) { |
| 184 | current_process->Finalize(); | 184 | current_process->Finalize(); |
| 185 | current_process->Close(); | 185 | // current_process->Close(); |
| 186 | // TODO: The current process should be destroyed based on accurate ref counting after | ||
| 187 | // calling Close(). Adding a manual Destroy() call instead to avoid a memory leak. | ||
| 188 | current_process->Destroy(); | ||
| 186 | current_process = nullptr; | 189 | current_process = nullptr; |
| 187 | } | 190 | } |
| 188 | 191 | ||
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index a9f7438ea..bb9475c56 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -41,7 +41,6 @@ | |||
| 41 | #include "core/hle/kernel/svc_results.h" | 41 | #include "core/hle/kernel/svc_results.h" |
| 42 | #include "core/hle/kernel/svc_types.h" | 42 | #include "core/hle/kernel/svc_types.h" |
| 43 | #include "core/hle/kernel/svc_wrap.h" | 43 | #include "core/hle/kernel/svc_wrap.h" |
| 44 | #include "core/hle/lock.h" | ||
| 45 | #include "core/hle/result.h" | 44 | #include "core/hle/result.h" |
| 46 | #include "core/memory.h" | 45 | #include "core/memory.h" |
| 47 | #include "core/reporter.h" | 46 | #include "core/reporter.h" |
| @@ -137,7 +136,6 @@ enum class ResourceLimitValueType { | |||
| 137 | 136 | ||
| 138 | /// Set the process heap to a given Size. It can both extend and shrink the heap. | 137 | /// Set the process heap to a given Size. It can both extend and shrink the heap. |
| 139 | static ResultCode SetHeapSize(Core::System& system, VAddr* heap_addr, u64 heap_size) { | 138 | static ResultCode SetHeapSize(Core::System& system, VAddr* heap_addr, u64 heap_size) { |
| 140 | std::lock_guard lock{HLE::g_hle_lock}; | ||
| 141 | LOG_TRACE(Kernel_SVC, "called, heap_size=0x{:X}", heap_size); | 139 | LOG_TRACE(Kernel_SVC, "called, heap_size=0x{:X}", heap_size); |
| 142 | 140 | ||
| 143 | // Size must be a multiple of 0x200000 (2MB) and be equal to or less than 8GB. | 141 | // Size must be a multiple of 0x200000 (2MB) and be equal to or less than 8GB. |
| @@ -168,7 +166,6 @@ static ResultCode SetHeapSize32(Core::System& system, u32* heap_addr, u32 heap_s | |||
| 168 | 166 | ||
| 169 | static ResultCode SetMemoryAttribute(Core::System& system, VAddr address, u64 size, u32 mask, | 167 | static ResultCode SetMemoryAttribute(Core::System& system, VAddr address, u64 size, u32 mask, |
| 170 | u32 attribute) { | 168 | u32 attribute) { |
| 171 | std::lock_guard lock{HLE::g_hle_lock}; | ||
| 172 | LOG_DEBUG(Kernel_SVC, | 169 | LOG_DEBUG(Kernel_SVC, |
| 173 | "called, address=0x{:016X}, size=0x{:X}, mask=0x{:08X}, attribute=0x{:08X}", address, | 170 | "called, address=0x{:016X}, size=0x{:X}, mask=0x{:08X}, attribute=0x{:08X}", address, |
| 174 | size, mask, attribute); | 171 | size, mask, attribute); |
| @@ -212,7 +209,6 @@ static ResultCode SetMemoryAttribute32(Core::System& system, u32 address, u32 si | |||
| 212 | 209 | ||
| 213 | /// Maps a memory range into a different range. | 210 | /// Maps a memory range into a different range. |
| 214 | static ResultCode MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) { | 211 | static ResultCode MapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) { |
| 215 | std::lock_guard lock{HLE::g_hle_lock}; | ||
| 216 | LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, | 212 | LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, |
| 217 | src_addr, size); | 213 | src_addr, size); |
| 218 | 214 | ||
| @@ -232,7 +228,6 @@ static ResultCode MapMemory32(Core::System& system, u32 dst_addr, u32 src_addr, | |||
| 232 | 228 | ||
| 233 | /// Unmaps a region that was previously mapped with svcMapMemory | 229 | /// Unmaps a region that was previously mapped with svcMapMemory |
| 234 | static ResultCode UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) { | 230 | static ResultCode UnmapMemory(Core::System& system, VAddr dst_addr, VAddr src_addr, u64 size) { |
| 235 | std::lock_guard lock{HLE::g_hle_lock}; | ||
| 236 | LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, | 231 | LOG_TRACE(Kernel_SVC, "called, dst_addr=0x{:X}, src_addr=0x{:X}, size=0x{:X}", dst_addr, |
| 237 | src_addr, size); | 232 | src_addr, size); |
| 238 | 233 | ||
| @@ -642,7 +637,6 @@ static void OutputDebugString(Core::System& system, VAddr address, u64 len) { | |||
| 642 | /// Gets system/memory information for the current process | 637 | /// Gets system/memory information for the current process |
| 643 | static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle, | 638 | static ResultCode GetInfo(Core::System& system, u64* result, u64 info_id, Handle handle, |
| 644 | u64 info_sub_id) { | 639 | u64 info_sub_id) { |
| 645 | std::lock_guard lock{HLE::g_hle_lock}; | ||
| 646 | LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, | 640 | LOG_TRACE(Kernel_SVC, "called info_id=0x{:X}, info_sub_id=0x{:X}, handle=0x{:08X}", info_id, |
| 647 | info_sub_id, handle); | 641 | info_sub_id, handle); |
| 648 | 642 | ||
| @@ -924,7 +918,6 @@ static ResultCode GetInfo32(Core::System& system, u32* result_low, u32* result_h | |||
| 924 | 918 | ||
| 925 | /// Maps memory at a desired address | 919 | /// Maps memory at a desired address |
| 926 | static ResultCode MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { | 920 | static ResultCode MapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { |
| 927 | std::lock_guard lock{HLE::g_hle_lock}; | ||
| 928 | LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); | 921 | LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); |
| 929 | 922 | ||
| 930 | if (!Common::Is4KBAligned(addr)) { | 923 | if (!Common::Is4KBAligned(addr)) { |
| @@ -978,7 +971,6 @@ static ResultCode MapPhysicalMemory32(Core::System& system, u32 addr, u32 size) | |||
| 978 | 971 | ||
| 979 | /// Unmaps memory previously mapped via MapPhysicalMemory | 972 | /// Unmaps memory previously mapped via MapPhysicalMemory |
| 980 | static ResultCode UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { | 973 | static ResultCode UnmapPhysicalMemory(Core::System& system, VAddr addr, u64 size) { |
| 981 | std::lock_guard lock{HLE::g_hle_lock}; | ||
| 982 | LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); | 974 | LOG_DEBUG(Kernel_SVC, "called, addr=0x{:016X}, size=0x{:X}", addr, size); |
| 983 | 975 | ||
| 984 | if (!Common::Is4KBAligned(addr)) { | 976 | if (!Common::Is4KBAligned(addr)) { |
| @@ -1520,7 +1512,6 @@ static ResultCode ControlCodeMemory(Core::System& system, Handle code_memory_han | |||
| 1520 | static ResultCode QueryProcessMemory(Core::System& system, VAddr memory_info_address, | 1512 | static ResultCode QueryProcessMemory(Core::System& system, VAddr memory_info_address, |
| 1521 | VAddr page_info_address, Handle process_handle, | 1513 | VAddr page_info_address, Handle process_handle, |
| 1522 | VAddr address) { | 1514 | VAddr address) { |
| 1523 | std::lock_guard lock{HLE::g_hle_lock}; | ||
| 1524 | LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address); | 1515 | LOG_TRACE(Kernel_SVC, "called process=0x{:08X} address={:X}", process_handle, address); |
| 1525 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | 1516 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); |
| 1526 | KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); | 1517 | KScopedAutoObject process = handle_table.GetObject<KProcess>(process_handle); |
diff --git a/src/core/hle/lock.cpp b/src/core/hle/lock.cpp deleted file mode 100644 index be4bfce3b..000000000 --- a/src/core/hle/lock.cpp +++ /dev/null | |||
| @@ -1,9 +0,0 @@ | |||
| 1 | // Copyright 2017 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <core/hle/lock.h> | ||
| 6 | |||
| 7 | namespace HLE { | ||
| 8 | std::recursive_mutex g_hle_lock; | ||
| 9 | } | ||
diff --git a/src/core/hle/lock.h b/src/core/hle/lock.h deleted file mode 100644 index 5c99fe996..000000000 --- a/src/core/hle/lock.h +++ /dev/null | |||
| @@ -1,18 +0,0 @@ | |||
| 1 | // Copyright 2017 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 <mutex> | ||
| 8 | |||
| 9 | namespace HLE { | ||
| 10 | /* | ||
| 11 | * Synchronizes access to the internal HLE kernel structures, it is acquired when a guest | ||
| 12 | * application thread performs a syscall. It should be acquired by any host threads that read or | ||
| 13 | * modify the HLE kernel state. Note: Any operation that directly or indirectly reads from or writes | ||
| 14 | * to the emulated memory is not protected by this mutex, and should be avoided in any threads other | ||
| 15 | * than the CPU thread. | ||
| 16 | */ | ||
| 17 | extern std::recursive_mutex g_hle_lock; | ||
| 18 | } // namespace HLE | ||
diff --git a/src/core/hle/service/bcat/backend/backend.cpp b/src/core/hle/service/bcat/backend/backend.cpp index 4c7d3bb6e..ee49edbb9 100644 --- a/src/core/hle/service/bcat/backend/backend.cpp +++ b/src/core/hle/service/bcat/backend/backend.cpp | |||
| @@ -6,7 +6,6 @@ | |||
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | #include "core/core.h" | 7 | #include "core/core.h" |
| 8 | #include "core/hle/kernel/k_event.h" | 8 | #include "core/hle/kernel/k_event.h" |
| 9 | #include "core/hle/lock.h" | ||
| 10 | #include "core/hle/service/bcat/backend/backend.h" | 9 | #include "core/hle/service/bcat/backend/backend.h" |
| 11 | 10 | ||
| 12 | namespace Service::BCAT { | 11 | namespace Service::BCAT { |
| @@ -29,10 +28,6 @@ DeliveryCacheProgressImpl& ProgressServiceBackend::GetImpl() { | |||
| 29 | return impl; | 28 | return impl; |
| 30 | } | 29 | } |
| 31 | 30 | ||
| 32 | void ProgressServiceBackend::SetNeedHLELock(bool need) { | ||
| 33 | need_hle_lock = need; | ||
| 34 | } | ||
| 35 | |||
| 36 | void ProgressServiceBackend::SetTotalSize(u64 size) { | 31 | void ProgressServiceBackend::SetTotalSize(u64 size) { |
| 37 | impl.total_bytes = size; | 32 | impl.total_bytes = size; |
| 38 | SignalUpdate(); | 33 | SignalUpdate(); |
| @@ -88,12 +83,7 @@ void ProgressServiceBackend::FinishDownload(ResultCode result) { | |||
| 88 | } | 83 | } |
| 89 | 84 | ||
| 90 | void ProgressServiceBackend::SignalUpdate() { | 85 | void ProgressServiceBackend::SignalUpdate() { |
| 91 | if (need_hle_lock) { | 86 | update_event->GetWritableEvent().Signal(); |
| 92 | std::lock_guard lock(HLE::g_hle_lock); | ||
| 93 | update_event->GetWritableEvent().Signal(); | ||
| 94 | } else { | ||
| 95 | update_event->GetWritableEvent().Signal(); | ||
| 96 | } | ||
| 97 | } | 87 | } |
| 98 | 88 | ||
| 99 | Backend::Backend(DirectoryGetter getter) : dir_getter(std::move(getter)) {} | 89 | Backend::Backend(DirectoryGetter getter) : dir_getter(std::move(getter)) {} |
diff --git a/src/core/hle/service/bcat/backend/backend.h b/src/core/hle/service/bcat/backend/backend.h index 59c6d4740..63833c927 100644 --- a/src/core/hle/service/bcat/backend/backend.h +++ b/src/core/hle/service/bcat/backend/backend.h | |||
| @@ -71,10 +71,6 @@ class ProgressServiceBackend { | |||
| 71 | public: | 71 | public: |
| 72 | ~ProgressServiceBackend(); | 72 | ~ProgressServiceBackend(); |
| 73 | 73 | ||
| 74 | // Clients should call this with true if any of the functions are going to be called from a | ||
| 75 | // non-HLE thread and this class need to lock the hle mutex. (default is false) | ||
| 76 | void SetNeedHLELock(bool need); | ||
| 77 | |||
| 78 | // Sets the number of bytes total in the entire download. | 74 | // Sets the number of bytes total in the entire download. |
| 79 | void SetTotalSize(u64 size); | 75 | void SetTotalSize(u64 size); |
| 80 | 76 | ||
| @@ -109,7 +105,6 @@ private: | |||
| 109 | 105 | ||
| 110 | DeliveryCacheProgressImpl impl{}; | 106 | DeliveryCacheProgressImpl impl{}; |
| 111 | Kernel::KEvent* update_event; | 107 | Kernel::KEvent* update_event; |
| 112 | bool need_hle_lock = false; | ||
| 113 | }; | 108 | }; |
| 114 | 109 | ||
| 115 | // A class representing an abstract backend for BCAT functionality. | 110 | // A class representing an abstract backend for BCAT functionality. |
diff --git a/src/core/hle/service/hid/controllers/console_sixaxis.cpp b/src/core/hle/service/hid/controllers/console_sixaxis.cpp index f0f3105dc..a727b3582 100644 --- a/src/core/hle/service/hid/controllers/console_sixaxis.cpp +++ b/src/core/hle/service/hid/controllers/console_sixaxis.cpp | |||
| @@ -33,15 +33,14 @@ void Controller_ConsoleSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_ti | |||
| 33 | const auto& last_entry = seven_sixaxis_lifo.ReadCurrentEntry().state; | 33 | const auto& last_entry = seven_sixaxis_lifo.ReadCurrentEntry().state; |
| 34 | next_seven_sixaxis_state.sampling_number = last_entry.sampling_number + 1; | 34 | next_seven_sixaxis_state.sampling_number = last_entry.sampling_number + 1; |
| 35 | 35 | ||
| 36 | // Try to read sixaxis sensor states | ||
| 37 | const auto motion_status = console->GetMotion(); | 36 | const auto motion_status = console->GetMotion(); |
| 37 | last_global_timestamp = core_timing.GetGlobalTimeNs().count(); | ||
| 38 | 38 | ||
| 39 | console_six_axis.is_seven_six_axis_sensor_at_rest = motion_status.is_at_rest; | 39 | // This value increments every time the switch goes to sleep |
| 40 | 40 | next_seven_sixaxis_state.unknown = 1; | |
| 41 | next_seven_sixaxis_state.timestamp = last_global_timestamp - last_saved_timestamp; | ||
| 41 | next_seven_sixaxis_state.accel = motion_status.accel; | 42 | next_seven_sixaxis_state.accel = motion_status.accel; |
| 42 | // Zero gyro values as they just mess up with the camera | 43 | next_seven_sixaxis_state.gyro = motion_status.gyro; |
| 43 | // Note: Probably a correct sensivity setting must be set | ||
| 44 | next_seven_sixaxis_state.gyro = {}; | ||
| 45 | next_seven_sixaxis_state.quaternion = { | 44 | next_seven_sixaxis_state.quaternion = { |
| 46 | { | 45 | { |
| 47 | motion_status.quaternion.xyz.y, | 46 | motion_status.quaternion.xyz.y, |
| @@ -52,9 +51,9 @@ void Controller_ConsoleSixAxis::OnUpdate(const Core::Timing::CoreTiming& core_ti | |||
| 52 | }; | 51 | }; |
| 53 | 52 | ||
| 54 | console_six_axis.sampling_number++; | 53 | console_six_axis.sampling_number++; |
| 55 | // TODO(German77): Find the purpose of those values | 54 | console_six_axis.is_seven_six_axis_sensor_at_rest = motion_status.is_at_rest; |
| 56 | console_six_axis.verticalization_error = 0.0f; | 55 | console_six_axis.verticalization_error = motion_status.verticalization_error; |
| 57 | console_six_axis.gyro_bias = {0.0f, 0.0f, 0.0f}; | 56 | console_six_axis.gyro_bias = motion_status.gyro_bias; |
| 58 | 57 | ||
| 59 | // Update console six axis shared memory | 58 | // Update console six axis shared memory |
| 60 | std::memcpy(data + SHARED_MEMORY_OFFSET, &console_six_axis, sizeof(console_six_axis)); | 59 | std::memcpy(data + SHARED_MEMORY_OFFSET, &console_six_axis, sizeof(console_six_axis)); |
| @@ -69,7 +68,6 @@ void Controller_ConsoleSixAxis::SetTransferMemoryPointer(u8* t_mem) { | |||
| 69 | } | 68 | } |
| 70 | 69 | ||
| 71 | void Controller_ConsoleSixAxis::ResetTimestamp() { | 70 | void Controller_ConsoleSixAxis::ResetTimestamp() { |
| 72 | seven_sixaxis_lifo.buffer_count = 0; | 71 | last_saved_timestamp = last_global_timestamp; |
| 73 | seven_sixaxis_lifo.buffer_tail = 0; | ||
| 74 | } | 72 | } |
| 75 | } // namespace Service::HID | 73 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/controllers/console_sixaxis.h b/src/core/hle/service/hid/controllers/console_sixaxis.h index 279241858..26d153f0c 100644 --- a/src/core/hle/service/hid/controllers/console_sixaxis.h +++ b/src/core/hle/service/hid/controllers/console_sixaxis.h | |||
| @@ -39,8 +39,9 @@ public: | |||
| 39 | 39 | ||
| 40 | private: | 40 | private: |
| 41 | struct SevenSixAxisState { | 41 | struct SevenSixAxisState { |
| 42 | INSERT_PADDING_WORDS(4); // unused | 42 | INSERT_PADDING_WORDS(2); // unused |
| 43 | s64 sampling_number{}; | 43 | u64 timestamp{}; |
| 44 | u64 sampling_number{}; | ||
| 44 | u64 unknown{}; | 45 | u64 unknown{}; |
| 45 | Common::Vec3f accel{}; | 46 | Common::Vec3f accel{}; |
| 46 | Common::Vec3f gyro{}; | 47 | Common::Vec3f gyro{}; |
| @@ -52,9 +53,10 @@ private: | |||
| 52 | struct ConsoleSharedMemory { | 53 | struct ConsoleSharedMemory { |
| 53 | u64 sampling_number{}; | 54 | u64 sampling_number{}; |
| 54 | bool is_seven_six_axis_sensor_at_rest{}; | 55 | bool is_seven_six_axis_sensor_at_rest{}; |
| 55 | INSERT_PADDING_BYTES(4); // padding | 56 | INSERT_PADDING_BYTES(3); // padding |
| 56 | f32 verticalization_error{}; | 57 | f32 verticalization_error{}; |
| 57 | Common::Vec3f gyro_bias{}; | 58 | Common::Vec3f gyro_bias{}; |
| 59 | INSERT_PADDING_BYTES(4); // padding | ||
| 58 | }; | 60 | }; |
| 59 | static_assert(sizeof(ConsoleSharedMemory) == 0x20, "ConsoleSharedMemory is an invalid size"); | 61 | static_assert(sizeof(ConsoleSharedMemory) == 0x20, "ConsoleSharedMemory is an invalid size"); |
| 60 | 62 | ||
| @@ -64,6 +66,8 @@ private: | |||
| 64 | Core::HID::EmulatedConsole* console; | 66 | Core::HID::EmulatedConsole* console; |
| 65 | u8* transfer_memory = nullptr; | 67 | u8* transfer_memory = nullptr; |
| 66 | bool is_transfer_memory_set = false; | 68 | bool is_transfer_memory_set = false; |
| 69 | u64 last_saved_timestamp{}; | ||
| 70 | u64 last_global_timestamp{}; | ||
| 67 | ConsoleSharedMemory console_six_axis{}; | 71 | ConsoleSharedMemory console_six_axis{}; |
| 68 | SevenSixAxisState next_seven_sixaxis_state{}; | 72 | SevenSixAxisState next_seven_sixaxis_state{}; |
| 69 | }; | 73 | }; |
diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cpp index 693ffc71a..761d0d3c6 100644 --- a/src/core/hle/service/nfp/nfp.cpp +++ b/src/core/hle/service/nfp/nfp.cpp | |||
| @@ -9,7 +9,6 @@ | |||
| 9 | #include "core/core.h" | 9 | #include "core/core.h" |
| 10 | #include "core/hle/ipc_helpers.h" | 10 | #include "core/hle/ipc_helpers.h" |
| 11 | #include "core/hle/kernel/k_event.h" | 11 | #include "core/hle/kernel/k_event.h" |
| 12 | #include "core/hle/lock.h" | ||
| 13 | #include "core/hle/service/nfp/nfp.h" | 12 | #include "core/hle/service/nfp/nfp.h" |
| 14 | #include "core/hle/service/nfp/nfp_user.h" | 13 | #include "core/hle/service/nfp/nfp_user.h" |
| 15 | 14 | ||
| @@ -337,7 +336,6 @@ void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) { | |||
| 337 | } | 336 | } |
| 338 | 337 | ||
| 339 | bool Module::Interface::LoadAmiibo(const std::vector<u8>& buffer) { | 338 | bool Module::Interface::LoadAmiibo(const std::vector<u8>& buffer) { |
| 340 | std::lock_guard lock{HLE::g_hle_lock}; | ||
| 341 | if (buffer.size() < sizeof(AmiiboFile)) { | 339 | if (buffer.size() < sizeof(AmiiboFile)) { |
| 342 | return false; | 340 | return false; |
| 343 | } | 341 | } |
diff --git a/src/yuzu/applets/qt_controller.cpp b/src/yuzu/applets/qt_controller.cpp index c5685db2e..c6222b571 100644 --- a/src/yuzu/applets/qt_controller.cpp +++ b/src/yuzu/applets/qt_controller.cpp | |||
| @@ -12,7 +12,6 @@ | |||
| 12 | #include "core/hid/emulated_controller.h" | 12 | #include "core/hid/emulated_controller.h" |
| 13 | #include "core/hid/hid_core.h" | 13 | #include "core/hid/hid_core.h" |
| 14 | #include "core/hid/hid_types.h" | 14 | #include "core/hid/hid_types.h" |
| 15 | #include "core/hle/lock.h" | ||
| 16 | #include "core/hle/service/hid/controllers/npad.h" | 15 | #include "core/hle/service/hid/controllers/npad.h" |
| 17 | #include "core/hle/service/hid/hid.h" | 16 | #include "core/hle/service/hid/hid.h" |
| 18 | #include "core/hle/service/sm/sm.h" | 17 | #include "core/hle/service/sm/sm.h" |
| @@ -664,7 +663,5 @@ void QtControllerSelector::ReconfigureControllers( | |||
| 664 | } | 663 | } |
| 665 | 664 | ||
| 666 | void QtControllerSelector::MainWindowReconfigureFinished() { | 665 | void QtControllerSelector::MainWindowReconfigureFinished() { |
| 667 | // Acquire the HLE mutex | ||
| 668 | std::lock_guard lock(HLE::g_hle_lock); | ||
| 669 | callback(); | 666 | callback(); |
| 670 | } | 667 | } |
diff --git a/src/yuzu/applets/qt_error.cpp b/src/yuzu/applets/qt_error.cpp index 45cf64603..879e73660 100644 --- a/src/yuzu/applets/qt_error.cpp +++ b/src/yuzu/applets/qt_error.cpp | |||
| @@ -3,7 +3,6 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <QDateTime> | 5 | #include <QDateTime> |
| 6 | #include "core/hle/lock.h" | ||
| 7 | #include "yuzu/applets/qt_error.h" | 6 | #include "yuzu/applets/qt_error.h" |
| 8 | #include "yuzu/main.h" | 7 | #include "yuzu/main.h" |
| 9 | 8 | ||
| @@ -57,7 +56,5 @@ void QtErrorDisplay::ShowCustomErrorText(ResultCode error, std::string dialog_te | |||
| 57 | } | 56 | } |
| 58 | 57 | ||
| 59 | void QtErrorDisplay::MainWindowFinishedError() { | 58 | void QtErrorDisplay::MainWindowFinishedError() { |
| 60 | // Acquire the HLE mutex | ||
| 61 | std::lock_guard lock{HLE::g_hle_lock}; | ||
| 62 | callback(); | 59 | callback(); |
| 63 | } | 60 | } |
diff --git a/src/yuzu/applets/qt_profile_select.cpp b/src/yuzu/applets/qt_profile_select.cpp index 7b19f1f8d..5b32da923 100644 --- a/src/yuzu/applets/qt_profile_select.cpp +++ b/src/yuzu/applets/qt_profile_select.cpp | |||
| @@ -14,7 +14,6 @@ | |||
| 14 | #include "common/fs/path_util.h" | 14 | #include "common/fs/path_util.h" |
| 15 | #include "common/string_util.h" | 15 | #include "common/string_util.h" |
| 16 | #include "core/constants.h" | 16 | #include "core/constants.h" |
| 17 | #include "core/hle/lock.h" | ||
| 18 | #include "yuzu/applets/qt_profile_select.h" | 17 | #include "yuzu/applets/qt_profile_select.h" |
| 19 | #include "yuzu/main.h" | 18 | #include "yuzu/main.h" |
| 20 | #include "yuzu/util/controller_navigation.h" | 19 | #include "yuzu/util/controller_navigation.h" |
| @@ -170,7 +169,5 @@ void QtProfileSelector::SelectProfile( | |||
| 170 | } | 169 | } |
| 171 | 170 | ||
| 172 | void QtProfileSelector::MainWindowFinishedSelection(std::optional<Common::UUID> uuid) { | 171 | void QtProfileSelector::MainWindowFinishedSelection(std::optional<Common::UUID> uuid) { |
| 173 | // Acquire the HLE mutex | ||
| 174 | std::lock_guard lock{HLE::g_hle_lock}; | ||
| 175 | callback(uuid); | 172 | callback(uuid); |
| 176 | } | 173 | } |