diff options
Diffstat (limited to 'src')
28 files changed, 187 insertions, 118 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index ed1e93cc2..59b999935 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp | |||
| @@ -3,19 +3,20 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <array> | 6 | #include <atomic> |
| 7 | #include <chrono> | 7 | #include <chrono> |
| 8 | #include <climits> | 8 | #include <climits> |
| 9 | #include <condition_variable> | 9 | #include <condition_variable> |
| 10 | #include <memory> | 10 | #include <memory> |
| 11 | #include <mutex> | ||
| 11 | #include <thread> | 12 | #include <thread> |
| 13 | #include <vector> | ||
| 12 | #ifdef _WIN32 | 14 | #ifdef _WIN32 |
| 13 | #include <share.h> // For _SH_DENYWR | 15 | #include <share.h> // For _SH_DENYWR |
| 14 | #else | 16 | #else |
| 15 | #define _SH_DENYWR 0 | 17 | #define _SH_DENYWR 0 |
| 16 | #endif | 18 | #endif |
| 17 | #include "common/assert.h" | 19 | #include "common/assert.h" |
| 18 | #include "common/common_funcs.h" // snprintf compatibility define | ||
| 19 | #include "common/logging/backend.h" | 20 | #include "common/logging/backend.h" |
| 20 | #include "common/logging/log.h" | 21 | #include "common/logging/log.h" |
| 21 | #include "common/logging/text_formatter.h" | 22 | #include "common/logging/text_formatter.h" |
| @@ -48,11 +49,11 @@ public: | |||
| 48 | backends.push_back(std::move(backend)); | 49 | backends.push_back(std::move(backend)); |
| 49 | } | 50 | } |
| 50 | 51 | ||
| 51 | void RemoveBackend(const std::string& backend_name) { | 52 | void RemoveBackend(std::string_view backend_name) { |
| 52 | std::lock_guard<std::mutex> lock(writing_mutex); | 53 | std::lock_guard<std::mutex> lock(writing_mutex); |
| 53 | auto it = std::remove_if(backends.begin(), backends.end(), [&backend_name](const auto& i) { | 54 | const auto it = |
| 54 | return !strcmp(i->GetName(), backend_name.c_str()); | 55 | std::remove_if(backends.begin(), backends.end(), |
| 55 | }); | 56 | [&backend_name](const auto& i) { return backend_name == i->GetName(); }); |
| 56 | backends.erase(it, backends.end()); | 57 | backends.erase(it, backends.end()); |
| 57 | } | 58 | } |
| 58 | 59 | ||
| @@ -64,10 +65,10 @@ public: | |||
| 64 | filter = f; | 65 | filter = f; |
| 65 | } | 66 | } |
| 66 | 67 | ||
| 67 | Backend* GetBackend(const std::string& backend_name) { | 68 | Backend* GetBackend(std::string_view backend_name) { |
| 68 | auto it = std::find_if(backends.begin(), backends.end(), [&backend_name](const auto& i) { | 69 | const auto it = |
| 69 | return !strcmp(i->GetName(), backend_name.c_str()); | 70 | std::find_if(backends.begin(), backends.end(), |
| 70 | }); | 71 | [&backend_name](const auto& i) { return backend_name == i->GetName(); }); |
| 71 | if (it == backends.end()) | 72 | if (it == backends.end()) |
| 72 | return nullptr; | 73 | return nullptr; |
| 73 | return it->get(); | 74 | return it->get(); |
| @@ -265,11 +266,11 @@ void AddBackend(std::unique_ptr<Backend> backend) { | |||
| 265 | Impl::Instance().AddBackend(std::move(backend)); | 266 | Impl::Instance().AddBackend(std::move(backend)); |
| 266 | } | 267 | } |
| 267 | 268 | ||
| 268 | void RemoveBackend(const std::string& backend_name) { | 269 | void RemoveBackend(std::string_view backend_name) { |
| 269 | Impl::Instance().RemoveBackend(backend_name); | 270 | Impl::Instance().RemoveBackend(backend_name); |
| 270 | } | 271 | } |
| 271 | 272 | ||
| 272 | Backend* GetBackend(const std::string& backend_name) { | 273 | Backend* GetBackend(std::string_view backend_name) { |
| 273 | return Impl::Instance().GetBackend(backend_name); | 274 | return Impl::Instance().GetBackend(backend_name); |
| 274 | } | 275 | } |
| 275 | 276 | ||
diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h index 57cdf6b2d..b3f4b9cef 100644 --- a/src/common/logging/backend.h +++ b/src/common/logging/backend.h | |||
| @@ -4,10 +4,9 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <chrono> | 6 | #include <chrono> |
| 7 | #include <cstdarg> | ||
| 8 | #include <memory> | 7 | #include <memory> |
| 9 | #include <string> | 8 | #include <string> |
| 10 | #include <utility> | 9 | #include <string_view> |
| 11 | #include "common/file_util.h" | 10 | #include "common/file_util.h" |
| 12 | #include "common/logging/filter.h" | 11 | #include "common/logging/filter.h" |
| 13 | #include "common/logging/log.h" | 12 | #include "common/logging/log.h" |
| @@ -106,9 +105,9 @@ private: | |||
| 106 | 105 | ||
| 107 | void AddBackend(std::unique_ptr<Backend> backend); | 106 | void AddBackend(std::unique_ptr<Backend> backend); |
| 108 | 107 | ||
| 109 | void RemoveBackend(const std::string& backend_name); | 108 | void RemoveBackend(std::string_view backend_name); |
| 110 | 109 | ||
| 111 | Backend* GetBackend(const std::string& backend_name); | 110 | Backend* GetBackend(std::string_view backend_name); |
| 112 | 111 | ||
| 113 | /** | 112 | /** |
| 114 | * Returns the name of the passed log class as a C-string. Subclasses are separated by periods | 113 | * Returns the name of the passed log class as a C-string. Subclasses are separated by periods |
diff --git a/src/common/logging/filter.cpp b/src/common/logging/filter.cpp index 6ed087beb..2dd331152 100644 --- a/src/common/logging/filter.cpp +++ b/src/common/logging/filter.cpp | |||
| @@ -8,39 +8,9 @@ | |||
| 8 | #include "common/string_util.h" | 8 | #include "common/string_util.h" |
| 9 | 9 | ||
| 10 | namespace Log { | 10 | namespace Log { |
| 11 | 11 | namespace { | |
| 12 | Filter::Filter(Level default_level) { | ||
| 13 | ResetAll(default_level); | ||
| 14 | } | ||
| 15 | |||
| 16 | void Filter::ResetAll(Level level) { | ||
| 17 | class_levels.fill(level); | ||
| 18 | } | ||
| 19 | |||
| 20 | void Filter::SetClassLevel(Class log_class, Level level) { | ||
| 21 | class_levels[static_cast<size_t>(log_class)] = level; | ||
| 22 | } | ||
| 23 | |||
| 24 | void Filter::ParseFilterString(const std::string& filter_str) { | ||
| 25 | auto clause_begin = filter_str.cbegin(); | ||
| 26 | while (clause_begin != filter_str.cend()) { | ||
| 27 | auto clause_end = std::find(clause_begin, filter_str.cend(), ' '); | ||
| 28 | |||
| 29 | // If clause isn't empty | ||
| 30 | if (clause_end != clause_begin) { | ||
| 31 | ParseFilterRule(clause_begin, clause_end); | ||
| 32 | } | ||
| 33 | |||
| 34 | if (clause_end != filter_str.cend()) { | ||
| 35 | // Skip over the whitespace | ||
| 36 | ++clause_end; | ||
| 37 | } | ||
| 38 | clause_begin = clause_end; | ||
| 39 | } | ||
| 40 | } | ||
| 41 | |||
| 42 | template <typename It> | 12 | template <typename It> |
| 43 | static Level GetLevelByName(const It begin, const It end) { | 13 | Level GetLevelByName(const It begin, const It end) { |
| 44 | for (u8 i = 0; i < static_cast<u8>(Level::Count); ++i) { | 14 | for (u8 i = 0; i < static_cast<u8>(Level::Count); ++i) { |
| 45 | const char* level_name = GetLevelName(static_cast<Level>(i)); | 15 | const char* level_name = GetLevelName(static_cast<Level>(i)); |
| 46 | if (Common::ComparePartialString(begin, end, level_name)) { | 16 | if (Common::ComparePartialString(begin, end, level_name)) { |
| @@ -51,7 +21,7 @@ static Level GetLevelByName(const It begin, const It end) { | |||
| 51 | } | 21 | } |
| 52 | 22 | ||
| 53 | template <typename It> | 23 | template <typename It> |
| 54 | static Class GetClassByName(const It begin, const It end) { | 24 | Class GetClassByName(const It begin, const It end) { |
| 55 | for (ClassType i = 0; i < static_cast<ClassType>(Class::Count); ++i) { | 25 | for (ClassType i = 0; i < static_cast<ClassType>(Class::Count); ++i) { |
| 56 | const char* level_name = GetLogClassName(static_cast<Class>(i)); | 26 | const char* level_name = GetLogClassName(static_cast<Class>(i)); |
| 57 | if (Common::ComparePartialString(begin, end, level_name)) { | 27 | if (Common::ComparePartialString(begin, end, level_name)) { |
| @@ -61,8 +31,8 @@ static Class GetClassByName(const It begin, const It end) { | |||
| 61 | return Class::Count; | 31 | return Class::Count; |
| 62 | } | 32 | } |
| 63 | 33 | ||
| 64 | bool Filter::ParseFilterRule(const std::string::const_iterator begin, | 34 | template <typename Iterator> |
| 65 | const std::string::const_iterator end) { | 35 | bool ParseFilterRule(Filter& instance, Iterator begin, Iterator end) { |
| 66 | auto level_separator = std::find(begin, end, ':'); | 36 | auto level_separator = std::find(begin, end, ':'); |
| 67 | if (level_separator == end) { | 37 | if (level_separator == end) { |
| 68 | LOG_ERROR(Log, "Invalid log filter. Must specify a log level after `:`: {}", | 38 | LOG_ERROR(Log, "Invalid log filter. Must specify a log level after `:`: {}", |
| @@ -77,7 +47,7 @@ bool Filter::ParseFilterRule(const std::string::const_iterator begin, | |||
| 77 | } | 47 | } |
| 78 | 48 | ||
| 79 | if (Common::ComparePartialString(begin, level_separator, "*")) { | 49 | if (Common::ComparePartialString(begin, level_separator, "*")) { |
| 80 | ResetAll(level); | 50 | instance.ResetAll(level); |
| 81 | return true; | 51 | return true; |
| 82 | } | 52 | } |
| 83 | 53 | ||
| @@ -87,9 +57,40 @@ bool Filter::ParseFilterRule(const std::string::const_iterator begin, | |||
| 87 | return false; | 57 | return false; |
| 88 | } | 58 | } |
| 89 | 59 | ||
| 90 | SetClassLevel(log_class, level); | 60 | instance.SetClassLevel(log_class, level); |
| 91 | return true; | 61 | return true; |
| 92 | } | 62 | } |
| 63 | } // Anonymous namespace | ||
| 64 | |||
| 65 | Filter::Filter(Level default_level) { | ||
| 66 | ResetAll(default_level); | ||
| 67 | } | ||
| 68 | |||
| 69 | void Filter::ResetAll(Level level) { | ||
| 70 | class_levels.fill(level); | ||
| 71 | } | ||
| 72 | |||
| 73 | void Filter::SetClassLevel(Class log_class, Level level) { | ||
| 74 | class_levels[static_cast<size_t>(log_class)] = level; | ||
| 75 | } | ||
| 76 | |||
| 77 | void Filter::ParseFilterString(std::string_view filter_view) { | ||
| 78 | auto clause_begin = filter_view.cbegin(); | ||
| 79 | while (clause_begin != filter_view.cend()) { | ||
| 80 | auto clause_end = std::find(clause_begin, filter_view.cend(), ' '); | ||
| 81 | |||
| 82 | // If clause isn't empty | ||
| 83 | if (clause_end != clause_begin) { | ||
| 84 | ParseFilterRule(*this, clause_begin, clause_end); | ||
| 85 | } | ||
| 86 | |||
| 87 | if (clause_end != filter_view.cend()) { | ||
| 88 | // Skip over the whitespace | ||
| 89 | ++clause_end; | ||
| 90 | } | ||
| 91 | clause_begin = clause_end; | ||
| 92 | } | ||
| 93 | } | ||
| 93 | 94 | ||
| 94 | bool Filter::CheckMessage(Class log_class, Level level) const { | 95 | bool Filter::CheckMessage(Class log_class, Level level) const { |
| 95 | return static_cast<u8>(level) >= static_cast<u8>(class_levels[static_cast<size_t>(log_class)]); | 96 | return static_cast<u8>(level) >= static_cast<u8>(class_levels[static_cast<size_t>(log_class)]); |
diff --git a/src/common/logging/filter.h b/src/common/logging/filter.h index 2a4f7c845..d5ffc5a58 100644 --- a/src/common/logging/filter.h +++ b/src/common/logging/filter.h | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <cstddef> | 8 | #include <cstddef> |
| 9 | #include <string> | 9 | #include <string_view> |
| 10 | #include "common/logging/log.h" | 10 | #include "common/logging/log.h" |
| 11 | 11 | ||
| 12 | namespace Log { | 12 | namespace Log { |
| @@ -40,9 +40,7 @@ public: | |||
| 40 | * - `Service:Info` -- Sets the level of Service to Info. | 40 | * - `Service:Info` -- Sets the level of Service to Info. |
| 41 | * - `Service.FS:Trace` -- Sets the level of the Service.FS class to Trace. | 41 | * - `Service.FS:Trace` -- Sets the level of the Service.FS class to Trace. |
| 42 | */ | 42 | */ |
| 43 | void ParseFilterString(const std::string& filter_str); | 43 | void ParseFilterString(std::string_view filter_view); |
| 44 | bool ParseFilterRule(const std::string::const_iterator start, | ||
| 45 | const std::string::const_iterator end); | ||
| 46 | 44 | ||
| 47 | /// Matches class/level combination against the filter, returning true if it passed. | 45 | /// Matches class/level combination against the filter, returning true if it passed. |
| 48 | bool CheckMessage(Class log_class, Level level) const; | 46 | bool CheckMessage(Class log_class, Level level) const; |
diff --git a/src/common/param_package.cpp b/src/common/param_package.cpp index e0df430ab..9526ca0c6 100644 --- a/src/common/param_package.cpp +++ b/src/common/param_package.cpp | |||
| @@ -3,7 +3,9 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <array> | 5 | #include <array> |
| 6 | #include <utility> | ||
| 6 | #include <vector> | 7 | #include <vector> |
| 8 | |||
| 7 | #include "common/logging/log.h" | 9 | #include "common/logging/log.h" |
| 8 | #include "common/param_package.h" | 10 | #include "common/param_package.h" |
| 9 | #include "common/string_util.h" | 11 | #include "common/string_util.h" |
| @@ -12,10 +14,11 @@ namespace Common { | |||
| 12 | 14 | ||
| 13 | constexpr char KEY_VALUE_SEPARATOR = ':'; | 15 | constexpr char KEY_VALUE_SEPARATOR = ':'; |
| 14 | constexpr char PARAM_SEPARATOR = ','; | 16 | constexpr char PARAM_SEPARATOR = ','; |
| 17 | |||
| 15 | constexpr char ESCAPE_CHARACTER = '$'; | 18 | constexpr char ESCAPE_CHARACTER = '$'; |
| 16 | const std::string KEY_VALUE_SEPARATOR_ESCAPE{ESCAPE_CHARACTER, '0'}; | 19 | constexpr char KEY_VALUE_SEPARATOR_ESCAPE[] = "$0"; |
| 17 | const std::string PARAM_SEPARATOR_ESCAPE{ESCAPE_CHARACTER, '1'}; | 20 | constexpr char PARAM_SEPARATOR_ESCAPE[] = "$1"; |
| 18 | const std::string ESCAPE_CHARACTER_ESCAPE{ESCAPE_CHARACTER, '2'}; | 21 | constexpr char ESCAPE_CHARACTER_ESCAPE[] = "$2"; |
| 19 | 22 | ||
| 20 | ParamPackage::ParamPackage(const std::string& serialized) { | 23 | ParamPackage::ParamPackage(const std::string& serialized) { |
| 21 | std::vector<std::string> pairs; | 24 | std::vector<std::string> pairs; |
| @@ -35,7 +38,7 @@ ParamPackage::ParamPackage(const std::string& serialized) { | |||
| 35 | part = Common::ReplaceAll(part, ESCAPE_CHARACTER_ESCAPE, {ESCAPE_CHARACTER}); | 38 | part = Common::ReplaceAll(part, ESCAPE_CHARACTER_ESCAPE, {ESCAPE_CHARACTER}); |
| 36 | } | 39 | } |
| 37 | 40 | ||
| 38 | Set(key_value[0], key_value[1]); | 41 | Set(key_value[0], std::move(key_value[1])); |
| 39 | } | 42 | } |
| 40 | } | 43 | } |
| 41 | 44 | ||
| @@ -101,16 +104,16 @@ float ParamPackage::Get(const std::string& key, float default_value) const { | |||
| 101 | } | 104 | } |
| 102 | } | 105 | } |
| 103 | 106 | ||
| 104 | void ParamPackage::Set(const std::string& key, const std::string& value) { | 107 | void ParamPackage::Set(const std::string& key, std::string value) { |
| 105 | data[key] = value; | 108 | data.insert_or_assign(key, std::move(value)); |
| 106 | } | 109 | } |
| 107 | 110 | ||
| 108 | void ParamPackage::Set(const std::string& key, int value) { | 111 | void ParamPackage::Set(const std::string& key, int value) { |
| 109 | data[key] = std::to_string(value); | 112 | data.insert_or_assign(key, std::to_string(value)); |
| 110 | } | 113 | } |
| 111 | 114 | ||
| 112 | void ParamPackage::Set(const std::string& key, float value) { | 115 | void ParamPackage::Set(const std::string& key, float value) { |
| 113 | data[key] = std::to_string(value); | 116 | data.insert_or_assign(key, std::to_string(value)); |
| 114 | } | 117 | } |
| 115 | 118 | ||
| 116 | bool ParamPackage::Has(const std::string& key) const { | 119 | bool ParamPackage::Has(const std::string& key) const { |
diff --git a/src/common/param_package.h b/src/common/param_package.h index c4c11b221..7842cd4ef 100644 --- a/src/common/param_package.h +++ b/src/common/param_package.h | |||
| @@ -28,7 +28,7 @@ public: | |||
| 28 | std::string Get(const std::string& key, const std::string& default_value) const; | 28 | std::string Get(const std::string& key, const std::string& default_value) const; |
| 29 | int Get(const std::string& key, int default_value) const; | 29 | int Get(const std::string& key, int default_value) const; |
| 30 | float Get(const std::string& key, float default_value) const; | 30 | float Get(const std::string& key, float default_value) const; |
| 31 | void Set(const std::string& key, const std::string& value); | 31 | void Set(const std::string& key, std::string value); |
| 32 | void Set(const std::string& key, int value); | 32 | void Set(const std::string& key, int value); |
| 33 | void Set(const std::string& key, float value); | 33 | void Set(const std::string& key, float value); |
| 34 | bool Has(const std::string& key) const; | 34 | bool Has(const std::string& key) const; |
diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h index 8416e73b0..28a99defe 100644 --- a/src/core/arm/arm_interface.h +++ b/src/core/arm/arm_interface.h | |||
| @@ -104,6 +104,10 @@ public: | |||
| 104 | 104 | ||
| 105 | virtual void SetTlsAddress(VAddr address) = 0; | 105 | virtual void SetTlsAddress(VAddr address) = 0; |
| 106 | 106 | ||
| 107 | virtual u64 GetTPIDR_EL0() const = 0; | ||
| 108 | |||
| 109 | virtual void SetTPIDR_EL0(u64 value) = 0; | ||
| 110 | |||
| 107 | /** | 111 | /** |
| 108 | * Saves the current CPU context | 112 | * Saves the current CPU context |
| 109 | * @param ctx Thread context to save | 113 | * @param ctx Thread context to save |
diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp index 3572ee7b9..df47d5ee8 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic.cpp | |||
| @@ -196,6 +196,14 @@ void ARM_Dynarmic::SetTlsAddress(u64 address) { | |||
| 196 | cb->tpidrro_el0 = address; | 196 | cb->tpidrro_el0 = address; |
| 197 | } | 197 | } |
| 198 | 198 | ||
| 199 | u64 ARM_Dynarmic::GetTPIDR_EL0() const { | ||
| 200 | return cb->tpidr_el0; | ||
| 201 | } | ||
| 202 | |||
| 203 | void ARM_Dynarmic::SetTPIDR_EL0(u64 value) { | ||
| 204 | cb->tpidr_el0 = value; | ||
| 205 | } | ||
| 206 | |||
| 199 | void ARM_Dynarmic::SaveContext(ARM_Interface::ThreadContext& ctx) { | 207 | void ARM_Dynarmic::SaveContext(ARM_Interface::ThreadContext& ctx) { |
| 200 | ctx.cpu_registers = jit->GetRegisters(); | 208 | ctx.cpu_registers = jit->GetRegisters(); |
| 201 | ctx.sp = jit->GetSP(); | 209 | ctx.sp = jit->GetSP(); |
diff --git a/src/core/arm/dynarmic/arm_dynarmic.h b/src/core/arm/dynarmic/arm_dynarmic.h index ed724c3f1..a9891ac4f 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.h +++ b/src/core/arm/dynarmic/arm_dynarmic.h | |||
| @@ -34,6 +34,8 @@ public: | |||
| 34 | void SetCPSR(u32 cpsr) override; | 34 | void SetCPSR(u32 cpsr) override; |
| 35 | VAddr GetTlsAddress() const override; | 35 | VAddr GetTlsAddress() const override; |
| 36 | void SetTlsAddress(VAddr address) override; | 36 | void SetTlsAddress(VAddr address) override; |
| 37 | void SetTPIDR_EL0(u64 value) override; | ||
| 38 | u64 GetTPIDR_EL0() const override; | ||
| 37 | 39 | ||
| 38 | void SaveContext(ThreadContext& ctx) override; | 40 | void SaveContext(ThreadContext& ctx) override; |
| 39 | void LoadContext(const ThreadContext& ctx) override; | 41 | void LoadContext(const ThreadContext& ctx) override; |
diff --git a/src/core/arm/unicorn/arm_unicorn.cpp b/src/core/arm/unicorn/arm_unicorn.cpp index d2d699e9b..44a46bf04 100644 --- a/src/core/arm/unicorn/arm_unicorn.cpp +++ b/src/core/arm/unicorn/arm_unicorn.cpp | |||
| @@ -169,6 +169,16 @@ void ARM_Unicorn::SetTlsAddress(VAddr base) { | |||
| 169 | CHECKED(uc_reg_write(uc, UC_ARM64_REG_TPIDRRO_EL0, &base)); | 169 | CHECKED(uc_reg_write(uc, UC_ARM64_REG_TPIDRRO_EL0, &base)); |
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | u64 ARM_Unicorn::GetTPIDR_EL0() const { | ||
| 173 | u64 value{}; | ||
| 174 | CHECKED(uc_reg_read(uc, UC_ARM64_REG_TPIDR_EL0, &value)); | ||
| 175 | return value; | ||
| 176 | } | ||
| 177 | |||
| 178 | void ARM_Unicorn::SetTPIDR_EL0(u64 value) { | ||
| 179 | CHECKED(uc_reg_write(uc, UC_ARM64_REG_TPIDR_EL0, &value)); | ||
| 180 | } | ||
| 181 | |||
| 172 | void ARM_Unicorn::Run() { | 182 | void ARM_Unicorn::Run() { |
| 173 | if (GDBStub::IsServerEnabled()) { | 183 | if (GDBStub::IsServerEnabled()) { |
| 174 | ExecuteInstructions(std::max(4000000, 0)); | 184 | ExecuteInstructions(std::max(4000000, 0)); |
diff --git a/src/core/arm/unicorn/arm_unicorn.h b/src/core/arm/unicorn/arm_unicorn.h index a78a0acf2..af7943352 100644 --- a/src/core/arm/unicorn/arm_unicorn.h +++ b/src/core/arm/unicorn/arm_unicorn.h | |||
| @@ -28,6 +28,8 @@ public: | |||
| 28 | void SetCPSR(u32 cpsr) override; | 28 | void SetCPSR(u32 cpsr) override; |
| 29 | VAddr GetTlsAddress() const override; | 29 | VAddr GetTlsAddress() const override; |
| 30 | void SetTlsAddress(VAddr address) override; | 30 | void SetTlsAddress(VAddr address) override; |
| 31 | void SetTPIDR_EL0(u64 value) override; | ||
| 32 | u64 GetTPIDR_EL0() const override; | ||
| 31 | void SaveContext(ThreadContext& ctx) override; | 33 | void SaveContext(ThreadContext& ctx) override; |
| 32 | void LoadContext(const ThreadContext& ctx) override; | 34 | void LoadContext(const ThreadContext& ctx) override; |
| 33 | void PrepareReschedule() override; | 35 | void PrepareReschedule() override; |
diff --git a/src/core/file_sys/errors.h b/src/core/file_sys/errors.h index a152dbd33..fea0593c7 100644 --- a/src/core/file_sys/errors.h +++ b/src/core/file_sys/errors.h | |||
| @@ -20,13 +20,13 @@ enum { | |||
| 20 | constexpr ResultCode ERROR_PATH_NOT_FOUND(ErrorModule::FS, ErrCodes::NotFound); | 20 | constexpr ResultCode ERROR_PATH_NOT_FOUND(ErrorModule::FS, ErrCodes::NotFound); |
| 21 | 21 | ||
| 22 | // TODO(bunnei): Replace these with correct errors for Switch OS | 22 | // TODO(bunnei): Replace these with correct errors for Switch OS |
| 23 | constexpr ResultCode ERROR_INVALID_PATH(ResultCode(-1)); | 23 | constexpr ResultCode ERROR_INVALID_PATH(-1); |
| 24 | constexpr ResultCode ERROR_UNSUPPORTED_OPEN_FLAGS(ResultCode(-1)); | 24 | constexpr ResultCode ERROR_UNSUPPORTED_OPEN_FLAGS(-1); |
| 25 | constexpr ResultCode ERROR_INVALID_OPEN_FLAGS(ResultCode(-1)); | 25 | constexpr ResultCode ERROR_INVALID_OPEN_FLAGS(-1); |
| 26 | constexpr ResultCode ERROR_FILE_NOT_FOUND(ResultCode(-1)); | 26 | constexpr ResultCode ERROR_FILE_NOT_FOUND(-1); |
| 27 | constexpr ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY(ResultCode(-1)); | 27 | constexpr ResultCode ERROR_UNEXPECTED_FILE_OR_DIRECTORY(-1); |
| 28 | constexpr ResultCode ERROR_DIRECTORY_ALREADY_EXISTS(ResultCode(-1)); | 28 | constexpr ResultCode ERROR_DIRECTORY_ALREADY_EXISTS(-1); |
| 29 | constexpr ResultCode ERROR_FILE_ALREADY_EXISTS(ResultCode(-1)); | 29 | constexpr ResultCode ERROR_FILE_ALREADY_EXISTS(-1); |
| 30 | constexpr ResultCode ERROR_DIRECTORY_NOT_EMPTY(ResultCode(-1)); | 30 | constexpr ResultCode ERROR_DIRECTORY_NOT_EMPTY(-1); |
| 31 | 31 | ||
| 32 | } // namespace FileSys | 32 | } // namespace FileSys |
diff --git a/src/core/file_sys/vfs.cpp b/src/core/file_sys/vfs.cpp index 16c8ad90b..3f690f12a 100644 --- a/src/core/file_sys/vfs.cpp +++ b/src/core/file_sys/vfs.cpp | |||
| @@ -42,7 +42,7 @@ bool VfsFile::WriteByte(u8 data, size_t offset) { | |||
| 42 | return Write(&data, 1, offset) == 1; | 42 | return Write(&data, 1, offset) == 1; |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | size_t VfsFile::WriteBytes(std::vector<u8> data, size_t offset) { | 45 | size_t VfsFile::WriteBytes(const std::vector<u8>& data, size_t offset) { |
| 46 | return Write(data.data(), data.size(), offset); | 46 | return Write(data.data(), data.size(), offset); |
| 47 | } | 47 | } |
| 48 | 48 | ||
diff --git a/src/core/file_sys/vfs.h b/src/core/file_sys/vfs.h index a5213e0cc..db3c77eac 100644 --- a/src/core/file_sys/vfs.h +++ b/src/core/file_sys/vfs.h | |||
| @@ -59,8 +59,7 @@ struct VfsFile : NonCopyable { | |||
| 59 | // Returns the number of bytes (sizeof(T)*number_elements) read successfully. | 59 | // Returns the number of bytes (sizeof(T)*number_elements) read successfully. |
| 60 | template <typename T> | 60 | template <typename T> |
| 61 | size_t ReadArray(T* data, size_t number_elements, size_t offset = 0) const { | 61 | size_t ReadArray(T* data, size_t number_elements, size_t offset = 0) const { |
| 62 | static_assert(std::is_trivially_copyable<T>::value, | 62 | static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable."); |
| 63 | "Data type must be trivially copyable."); | ||
| 64 | 63 | ||
| 65 | return Read(reinterpret_cast<u8*>(data), number_elements * sizeof(T), offset); | 64 | return Read(reinterpret_cast<u8*>(data), number_elements * sizeof(T), offset); |
| 66 | } | 65 | } |
| @@ -69,8 +68,7 @@ struct VfsFile : NonCopyable { | |||
| 69 | // Returns the number of bytes read successfully. | 68 | // Returns the number of bytes read successfully. |
| 70 | template <typename T> | 69 | template <typename T> |
| 71 | size_t ReadBytes(T* data, size_t size, size_t offset = 0) const { | 70 | size_t ReadBytes(T* data, size_t size, size_t offset = 0) const { |
| 72 | static_assert(std::is_trivially_copyable<T>::value, | 71 | static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable."); |
| 73 | "Data type must be trivially copyable."); | ||
| 74 | return Read(reinterpret_cast<u8*>(data), size, offset); | 72 | return Read(reinterpret_cast<u8*>(data), size, offset); |
| 75 | } | 73 | } |
| 76 | 74 | ||
| @@ -78,8 +76,7 @@ struct VfsFile : NonCopyable { | |||
| 78 | // Returns the number of bytes read successfully (sizeof(T)). | 76 | // Returns the number of bytes read successfully (sizeof(T)). |
| 79 | template <typename T> | 77 | template <typename T> |
| 80 | size_t ReadObject(T* data, size_t offset = 0) const { | 78 | size_t ReadObject(T* data, size_t offset = 0) const { |
| 81 | static_assert(std::is_trivially_copyable<T>::value, | 79 | static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable."); |
| 82 | "Data type must be trivially copyable."); | ||
| 83 | return Read(reinterpret_cast<u8*>(data), sizeof(T), offset); | 80 | return Read(reinterpret_cast<u8*>(data), sizeof(T), offset); |
| 84 | } | 81 | } |
| 85 | 82 | ||
| @@ -88,33 +85,29 @@ struct VfsFile : NonCopyable { | |||
| 88 | virtual bool WriteByte(u8 data, size_t offset = 0); | 85 | virtual bool WriteByte(u8 data, size_t offset = 0); |
| 89 | // Writes a vector of bytes to offset in file and returns the number of bytes successfully | 86 | // Writes a vector of bytes to offset in file and returns the number of bytes successfully |
| 90 | // written. | 87 | // written. |
| 91 | virtual size_t WriteBytes(std::vector<u8> data, size_t offset = 0); | 88 | virtual size_t WriteBytes(const std::vector<u8>& data, size_t offset = 0); |
| 92 | 89 | ||
| 93 | // Writes an array of type T, size number_elements to offset in file. | 90 | // Writes an array of type T, size number_elements to offset in file. |
| 94 | // Returns the number of bytes (sizeof(T)*number_elements) written successfully. | 91 | // Returns the number of bytes (sizeof(T)*number_elements) written successfully. |
| 95 | template <typename T> | 92 | template <typename T> |
| 96 | size_t WriteArray(T* data, size_t number_elements, size_t offset = 0) { | 93 | size_t WriteArray(const T* data, size_t number_elements, size_t offset = 0) { |
| 97 | static_assert(std::is_trivially_copyable<T>::value, | 94 | static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable."); |
| 98 | "Data type must be trivially copyable."); | ||
| 99 | |||
| 100 | return Write(data, number_elements * sizeof(T), offset); | 95 | return Write(data, number_elements * sizeof(T), offset); |
| 101 | } | 96 | } |
| 102 | 97 | ||
| 103 | // Writes size bytes starting at memory location data to offset in file. | 98 | // Writes size bytes starting at memory location data to offset in file. |
| 104 | // Returns the number of bytes written successfully. | 99 | // Returns the number of bytes written successfully. |
| 105 | template <typename T> | 100 | template <typename T> |
| 106 | size_t WriteBytes(T* data, size_t size, size_t offset = 0) { | 101 | size_t WriteBytes(const T* data, size_t size, size_t offset = 0) { |
| 107 | static_assert(std::is_trivially_copyable<T>::value, | 102 | static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable."); |
| 108 | "Data type must be trivially copyable."); | 103 | return Write(reinterpret_cast<const u8*>(data), size, offset); |
| 109 | return Write(reinterpret_cast<u8*>(data), size, offset); | ||
| 110 | } | 104 | } |
| 111 | 105 | ||
| 112 | // Writes one object of type T to offset in file. | 106 | // Writes one object of type T to offset in file. |
| 113 | // Returns the number of bytes written successfully (sizeof(T)). | 107 | // Returns the number of bytes written successfully (sizeof(T)). |
| 114 | template <typename T> | 108 | template <typename T> |
| 115 | size_t WriteObject(const T& data, size_t offset = 0) { | 109 | size_t WriteObject(const T& data, size_t offset = 0) { |
| 116 | static_assert(std::is_trivially_copyable<T>::value, | 110 | static_assert(std::is_trivially_copyable_v<T>, "Data type must be trivially copyable."); |
| 117 | "Data type must be trivially copyable."); | ||
| 118 | return Write(&data, sizeof(T), offset); | 111 | return Write(&data, sizeof(T), offset); |
| 119 | } | 112 | } |
| 120 | 113 | ||
diff --git a/src/core/file_sys/vfs_offset.cpp b/src/core/file_sys/vfs_offset.cpp index 31fdd9aa1..217e02235 100644 --- a/src/core/file_sys/vfs_offset.cpp +++ b/src/core/file_sys/vfs_offset.cpp | |||
| @@ -2,6 +2,7 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <algorithm> | ||
| 5 | #include <utility> | 6 | #include <utility> |
| 6 | 7 | ||
| 7 | #include "core/file_sys/vfs_offset.h" | 8 | #include "core/file_sys/vfs_offset.h" |
| @@ -75,7 +76,7 @@ bool OffsetVfsFile::WriteByte(u8 data, size_t r_offset) { | |||
| 75 | return false; | 76 | return false; |
| 76 | } | 77 | } |
| 77 | 78 | ||
| 78 | size_t OffsetVfsFile::WriteBytes(std::vector<u8> data, size_t r_offset) { | 79 | size_t OffsetVfsFile::WriteBytes(const std::vector<u8>& data, size_t r_offset) { |
| 79 | return file->Write(data.data(), TrimToFit(data.size(), r_offset), offset + r_offset); | 80 | return file->Write(data.data(), TrimToFit(data.size(), r_offset), offset + r_offset); |
| 80 | } | 81 | } |
| 81 | 82 | ||
| @@ -88,7 +89,7 @@ size_t OffsetVfsFile::GetOffset() const { | |||
| 88 | } | 89 | } |
| 89 | 90 | ||
| 90 | size_t OffsetVfsFile::TrimToFit(size_t r_size, size_t r_offset) const { | 91 | size_t OffsetVfsFile::TrimToFit(size_t r_size, size_t r_offset) const { |
| 91 | return std::max<size_t>(std::min<size_t>(size - r_offset, r_size), 0); | 92 | return std::clamp(r_size, size_t{0}, size - r_offset); |
| 92 | } | 93 | } |
| 93 | 94 | ||
| 94 | } // namespace FileSys | 95 | } // namespace FileSys |
diff --git a/src/core/file_sys/vfs_offset.h b/src/core/file_sys/vfs_offset.h index 2e16e47eb..ded4827f5 100644 --- a/src/core/file_sys/vfs_offset.h +++ b/src/core/file_sys/vfs_offset.h | |||
| @@ -28,7 +28,7 @@ struct OffsetVfsFile : public VfsFile { | |||
| 28 | std::vector<u8> ReadBytes(size_t size, size_t offset) const override; | 28 | std::vector<u8> ReadBytes(size_t size, size_t offset) const override; |
| 29 | std::vector<u8> ReadAllBytes() const override; | 29 | std::vector<u8> ReadAllBytes() const override; |
| 30 | bool WriteByte(u8 data, size_t offset) override; | 30 | bool WriteByte(u8 data, size_t offset) override; |
| 31 | size_t WriteBytes(std::vector<u8> data, size_t offset) override; | 31 | size_t WriteBytes(const std::vector<u8>& data, size_t offset) override; |
| 32 | 32 | ||
| 33 | bool Rename(const std::string& name) override; | 33 | bool Rename(const std::string& name) override; |
| 34 | 34 | ||
diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index 24605a273..8b5b06f31 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h | |||
| @@ -175,6 +175,25 @@ public: | |||
| 175 | void Push(const First& first_value, const Other&... other_values); | 175 | void Push(const First& first_value, const Other&... other_values); |
| 176 | 176 | ||
| 177 | /** | 177 | /** |
| 178 | * Helper function for pushing strongly-typed enumeration values. | ||
| 179 | * | ||
| 180 | * @tparam Enum The enumeration type to be pushed | ||
| 181 | * | ||
| 182 | * @param value The value to push. | ||
| 183 | * | ||
| 184 | * @note The underlying size of the enumeration type is the size of the | ||
| 185 | * data that gets pushed. e.g. "enum class SomeEnum : u16" will | ||
| 186 | * push a u16-sized amount of data. | ||
| 187 | */ | ||
| 188 | template <typename Enum> | ||
| 189 | void PushEnum(Enum value) { | ||
| 190 | static_assert(std::is_enum_v<Enum>, "T must be an enum type within a PushEnum call."); | ||
| 191 | static_assert(!std::is_convertible_v<Enum, int>, | ||
| 192 | "enum type in PushEnum must be a strongly typed enum."); | ||
| 193 | Push(static_cast<std::underlying_type_t<Enum>>(value)); | ||
| 194 | } | ||
| 195 | |||
| 196 | /** | ||
| 178 | * @brief Copies the content of the given trivially copyable class to the buffer as a normal | 197 | * @brief Copies the content of the given trivially copyable class to the buffer as a normal |
| 179 | * param | 198 | * param |
| 180 | * @note: The input class must be correctly packed/padded to fit hardware layout. | 199 | * @note: The input class must be correctly packed/padded to fit hardware layout. |
diff --git a/src/core/hle/kernel/scheduler.cpp b/src/core/hle/kernel/scheduler.cpp index f7e25cbf5..e307eec98 100644 --- a/src/core/hle/kernel/scheduler.cpp +++ b/src/core/hle/kernel/scheduler.cpp | |||
| @@ -56,6 +56,8 @@ void Scheduler::SwitchContext(Thread* new_thread) { | |||
| 56 | if (previous_thread) { | 56 | if (previous_thread) { |
| 57 | previous_thread->last_running_ticks = CoreTiming::GetTicks(); | 57 | previous_thread->last_running_ticks = CoreTiming::GetTicks(); |
| 58 | cpu_core->SaveContext(previous_thread->context); | 58 | cpu_core->SaveContext(previous_thread->context); |
| 59 | // Save the TPIDR_EL0 system register in case it was modified. | ||
| 60 | previous_thread->tpidr_el0 = cpu_core->GetTPIDR_EL0(); | ||
| 59 | 61 | ||
| 60 | if (previous_thread->status == ThreadStatus::Running) { | 62 | if (previous_thread->status == ThreadStatus::Running) { |
| 61 | // This is only the case when a reschedule is triggered without the current thread | 63 | // This is only the case when a reschedule is triggered without the current thread |
| @@ -87,6 +89,7 @@ void Scheduler::SwitchContext(Thread* new_thread) { | |||
| 87 | 89 | ||
| 88 | cpu_core->LoadContext(new_thread->context); | 90 | cpu_core->LoadContext(new_thread->context); |
| 89 | cpu_core->SetTlsAddress(new_thread->GetTLSAddress()); | 91 | cpu_core->SetTlsAddress(new_thread->GetTLSAddress()); |
| 92 | cpu_core->SetTPIDR_EL0(new_thread->GetTPIDR_EL0()); | ||
| 90 | cpu_core->ClearExclusiveState(); | 93 | cpu_core->ClearExclusiveState(); |
| 91 | } else { | 94 | } else { |
| 92 | current_thread = nullptr; | 95 | current_thread = nullptr; |
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 53f2e861e..cd85c4b7c 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -312,6 +312,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, | |||
| 312 | thread->status = ThreadStatus::Dormant; | 312 | thread->status = ThreadStatus::Dormant; |
| 313 | thread->entry_point = entry_point; | 313 | thread->entry_point = entry_point; |
| 314 | thread->stack_top = stack_top; | 314 | thread->stack_top = stack_top; |
| 315 | thread->tpidr_el0 = 0; | ||
| 315 | thread->nominal_priority = thread->current_priority = priority; | 316 | thread->nominal_priority = thread->current_priority = priority; |
| 316 | thread->last_running_ticks = CoreTiming::GetTicks(); | 317 | thread->last_running_ticks = CoreTiming::GetTicks(); |
| 317 | thread->processor_id = processor_id; | 318 | thread->processor_id = processor_id; |
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 47881ec20..6218960d2 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -183,6 +183,14 @@ public: | |||
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | /* | 185 | /* |
| 186 | * Returns the value of the TPIDR_EL0 Read/Write system register for this thread. | ||
| 187 | * @returns The value of the TPIDR_EL0 register. | ||
| 188 | */ | ||
| 189 | u64 GetTPIDR_EL0() const { | ||
| 190 | return tpidr_el0; | ||
| 191 | } | ||
| 192 | |||
| 193 | /* | ||
| 186 | * Returns the address of the current thread's command buffer, located in the TLS. | 194 | * Returns the address of the current thread's command buffer, located in the TLS. |
| 187 | * @returns VAddr of the thread's command buffer. | 195 | * @returns VAddr of the thread's command buffer. |
| 188 | */ | 196 | */ |
| @@ -213,6 +221,7 @@ public: | |||
| 213 | s32 processor_id; | 221 | s32 processor_id; |
| 214 | 222 | ||
| 215 | VAddr tls_address; ///< Virtual address of the Thread Local Storage of the thread | 223 | VAddr tls_address; ///< Virtual address of the Thread Local Storage of the thread |
| 224 | u64 tpidr_el0; ///< TPIDR_EL0 read/write system register. | ||
| 216 | 225 | ||
| 217 | SharedPtr<Process> owner_process; ///< Process that owns this thread | 226 | SharedPtr<Process> owner_process; ///< Process that owns this thread |
| 218 | 227 | ||
diff --git a/src/core/hle/service/apm/interface.cpp b/src/core/hle/service/apm/interface.cpp index 751d73f8d..ce943d829 100644 --- a/src/core/hle/service/apm/interface.cpp +++ b/src/core/hle/service/apm/interface.cpp | |||
| @@ -20,6 +20,21 @@ public: | |||
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | private: | 22 | private: |
| 23 | enum class PerformanceConfiguration : u32 { | ||
| 24 | Config1 = 0x00010000, | ||
| 25 | Config2 = 0x00010001, | ||
| 26 | Config3 = 0x00010002, | ||
| 27 | Config4 = 0x00020000, | ||
| 28 | Config5 = 0x00020001, | ||
| 29 | Config6 = 0x00020002, | ||
| 30 | Config7 = 0x00020003, | ||
| 31 | Config8 = 0x00020004, | ||
| 32 | Config9 = 0x00020005, | ||
| 33 | Config10 = 0x00020006, | ||
| 34 | Config11 = 0x92220007, | ||
| 35 | Config12 = 0x92220008, | ||
| 36 | }; | ||
| 37 | |||
| 23 | void SetPerformanceConfiguration(Kernel::HLERequestContext& ctx) { | 38 | void SetPerformanceConfiguration(Kernel::HLERequestContext& ctx) { |
| 24 | IPC::RequestParser rp{ctx}; | 39 | IPC::RequestParser rp{ctx}; |
| 25 | 40 | ||
| @@ -40,7 +55,7 @@ private: | |||
| 40 | 55 | ||
| 41 | IPC::ResponseBuilder rb{ctx, 3}; | 56 | IPC::ResponseBuilder rb{ctx, 3}; |
| 42 | rb.Push(RESULT_SUCCESS); | 57 | rb.Push(RESULT_SUCCESS); |
| 43 | rb.Push<u32>(0); // Performance configuration | 58 | rb.Push<u32>(static_cast<u32>(PerformanceConfiguration::Config1)); |
| 44 | 59 | ||
| 45 | LOG_WARNING(Service_APM, "(STUBBED) called mode={}", static_cast<u32>(mode)); | 60 | LOG_WARNING(Service_APM, "(STUBBED) called mode={}", static_cast<u32>(mode)); |
| 46 | } | 61 | } |
diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cpp index 19b8667ba..394963a69 100644 --- a/src/core/loader/deconstructed_rom_directory.cpp +++ b/src/core/loader/deconstructed_rom_directory.cpp | |||
| @@ -83,16 +83,13 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load( | |||
| 83 | VAddr next_load_addr{Memory::PROCESS_IMAGE_VADDR}; | 83 | VAddr next_load_addr{Memory::PROCESS_IMAGE_VADDR}; |
| 84 | for (const auto& module : {"rtld", "main", "subsdk0", "subsdk1", "subsdk2", "subsdk3", | 84 | for (const auto& module : {"rtld", "main", "subsdk0", "subsdk1", "subsdk2", "subsdk3", |
| 85 | "subsdk4", "subsdk5", "subsdk6", "subsdk7", "sdk"}) { | 85 | "subsdk4", "subsdk5", "subsdk6", "subsdk7", "sdk"}) { |
| 86 | const VAddr load_addr = next_load_addr; | ||
| 87 | const FileSys::VirtualFile module_file = dir->GetFile(module); | 86 | const FileSys::VirtualFile module_file = dir->GetFile(module); |
| 88 | if (module_file != nullptr) | 87 | if (module_file != nullptr) { |
| 88 | const VAddr load_addr = next_load_addr; | ||
| 89 | next_load_addr = AppLoader_NSO::LoadModule(module_file, load_addr); | 89 | next_load_addr = AppLoader_NSO::LoadModule(module_file, load_addr); |
| 90 | if (next_load_addr) { | ||
| 91 | LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", module, load_addr); | 90 | LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", module, load_addr); |
| 92 | // Register module with GDBStub | 91 | // Register module with GDBStub |
| 93 | GDBStub::RegisterModule(module, load_addr, next_load_addr - 1, false); | 92 | GDBStub::RegisterModule(module, load_addr, next_load_addr - 1, false); |
| 94 | } else { | ||
| 95 | next_load_addr = load_addr; | ||
| 96 | } | 93 | } |
| 97 | } | 94 | } |
| 98 | 95 | ||
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index e36483145..a003bc9e3 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp | |||
| @@ -20,7 +20,11 @@ GPU::GPU() { | |||
| 20 | 20 | ||
| 21 | GPU::~GPU() = default; | 21 | GPU::~GPU() = default; |
| 22 | 22 | ||
| 23 | const Tegra::Engines::Maxwell3D& GPU::Get3DEngine() const { | 23 | const Engines::Maxwell3D& GPU::Maxwell3D() const { |
| 24 | return *maxwell_3d; | ||
| 25 | } | ||
| 26 | |||
| 27 | Engines::Maxwell3D& GPU::Maxwell3D() { | ||
| 24 | return *maxwell_3d; | 28 | return *maxwell_3d; |
| 25 | } | 29 | } |
| 26 | 30 | ||
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index 60930e997..a32148ecd 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h | |||
| @@ -93,15 +93,14 @@ public: | |||
| 93 | /// Processes a command list stored at the specified address in GPU memory. | 93 | /// Processes a command list stored at the specified address in GPU memory. |
| 94 | void ProcessCommandList(GPUVAddr address, u32 size); | 94 | void ProcessCommandList(GPUVAddr address, u32 size); |
| 95 | 95 | ||
| 96 | /// Returns a const reference to the Maxwell3D GPU engine. | ||
| 97 | const Engines::Maxwell3D& Maxwell3D() const; | ||
| 98 | |||
| 96 | /// Returns a reference to the Maxwell3D GPU engine. | 99 | /// Returns a reference to the Maxwell3D GPU engine. |
| 97 | const Engines::Maxwell3D& Get3DEngine() const; | 100 | Engines::Maxwell3D& Maxwell3D(); |
| 98 | 101 | ||
| 99 | std::unique_ptr<MemoryManager> memory_manager; | 102 | std::unique_ptr<MemoryManager> memory_manager; |
| 100 | 103 | ||
| 101 | Engines::Maxwell3D& Maxwell3D() { | ||
| 102 | return *maxwell_3d; | ||
| 103 | } | ||
| 104 | |||
| 105 | private: | 104 | private: |
| 106 | /// Writes a single register in the engine bound to the specified subchannel | 105 | /// Writes a single register in the engine bound to the specified subchannel |
| 107 | void WriteReg(u32 method, u32 subchannel, u32 value, u32 remaining_params); | 106 | void WriteReg(u32 method, u32 subchannel, u32 value, u32 remaining_params); |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index f75999557..65a2fd5e8 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -634,8 +634,8 @@ void RasterizerOpenGL::SamplerInfo::SyncWithConfig(const Tegra::Texture::TSCEntr | |||
| 634 | u32 RasterizerOpenGL::SetupConstBuffers(Maxwell::ShaderStage stage, GLuint program, | 634 | u32 RasterizerOpenGL::SetupConstBuffers(Maxwell::ShaderStage stage, GLuint program, |
| 635 | u32 current_bindpoint, | 635 | u32 current_bindpoint, |
| 636 | const std::vector<GLShader::ConstBufferEntry>& entries) { | 636 | const std::vector<GLShader::ConstBufferEntry>& entries) { |
| 637 | auto& gpu = Core::System::GetInstance().GPU(); | 637 | const auto& gpu = Core::System::GetInstance().GPU(); |
| 638 | auto& maxwell3d = gpu.Get3DEngine(); | 638 | const auto& maxwell3d = gpu.Maxwell3D(); |
| 639 | 639 | ||
| 640 | // Reset all buffer draw state for this stage. | 640 | // Reset all buffer draw state for this stage. |
| 641 | for (auto& buffer : state.draw.const_buffers[static_cast<size_t>(stage)]) { | 641 | for (auto& buffer : state.draw.const_buffers[static_cast<size_t>(stage)]) { |
| @@ -644,7 +644,7 @@ u32 RasterizerOpenGL::SetupConstBuffers(Maxwell::ShaderStage stage, GLuint progr | |||
| 644 | } | 644 | } |
| 645 | 645 | ||
| 646 | // Upload only the enabled buffers from the 16 constbuffers of each shader stage | 646 | // Upload only the enabled buffers from the 16 constbuffers of each shader stage |
| 647 | auto& shader_stage = maxwell3d.state.shader_stages[static_cast<size_t>(stage)]; | 647 | const auto& shader_stage = maxwell3d.state.shader_stages[static_cast<size_t>(stage)]; |
| 648 | 648 | ||
| 649 | for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) { | 649 | for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) { |
| 650 | const auto& used_buffer = entries[bindpoint]; | 650 | const auto& used_buffer = entries[bindpoint]; |
| @@ -700,8 +700,8 @@ u32 RasterizerOpenGL::SetupConstBuffers(Maxwell::ShaderStage stage, GLuint progr | |||
| 700 | 700 | ||
| 701 | u32 RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, GLuint program, u32 current_unit, | 701 | u32 RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, GLuint program, u32 current_unit, |
| 702 | const std::vector<GLShader::SamplerEntry>& entries) { | 702 | const std::vector<GLShader::SamplerEntry>& entries) { |
| 703 | auto& gpu = Core::System::GetInstance().GPU(); | 703 | const auto& gpu = Core::System::GetInstance().GPU(); |
| 704 | auto& maxwell3d = gpu.Get3DEngine(); | 704 | const auto& maxwell3d = gpu.Maxwell3D(); |
| 705 | 705 | ||
| 706 | ASSERT_MSG(current_unit + entries.size() <= std::size(state.texture_units), | 706 | ASSERT_MSG(current_unit + entries.size() <= std::size(state.texture_units), |
| 707 | "Exceeded the number of active textures."); | 707 | "Exceeded the number of active textures."); |
diff --git a/src/video_core/renderer_opengl/gl_shader_manager.cpp b/src/video_core/renderer_opengl/gl_shader_manager.cpp index 1aa437f76..e81fcbbc4 100644 --- a/src/video_core/renderer_opengl/gl_shader_manager.cpp +++ b/src/video_core/renderer_opengl/gl_shader_manager.cpp | |||
| @@ -10,8 +10,9 @@ | |||
| 10 | namespace GLShader { | 10 | namespace GLShader { |
| 11 | 11 | ||
| 12 | namespace Impl { | 12 | namespace Impl { |
| 13 | void SetShaderUniformBlockBinding(GLuint shader, const char* name, | 13 | static void SetShaderUniformBlockBinding(GLuint shader, const char* name, |
| 14 | Maxwell3D::Regs::ShaderStage binding, size_t expected_size) { | 14 | Maxwell3D::Regs::ShaderStage binding, |
| 15 | size_t expected_size) { | ||
| 15 | GLuint ub_index = glGetUniformBlockIndex(shader, name); | 16 | GLuint ub_index = glGetUniformBlockIndex(shader, name); |
| 16 | if (ub_index != GL_INVALID_INDEX) { | 17 | if (ub_index != GL_INVALID_INDEX) { |
| 17 | GLint ub_size = 0; | 18 | GLint ub_size = 0; |
diff --git a/src/video_core/renderer_opengl/gl_shader_manager.h b/src/video_core/renderer_opengl/gl_shader_manager.h index 4295c20a6..e29d551e1 100644 --- a/src/video_core/renderer_opengl/gl_shader_manager.h +++ b/src/video_core/renderer_opengl/gl_shader_manager.h | |||
| @@ -21,7 +21,6 @@ using Tegra::Engines::Maxwell3D; | |||
| 21 | 21 | ||
| 22 | namespace Impl { | 22 | namespace Impl { |
| 23 | void SetShaderUniformBlockBindings(GLuint shader); | 23 | void SetShaderUniformBlockBindings(GLuint shader); |
| 24 | void SetShaderSamplerBindings(GLuint shader); | ||
| 25 | } // namespace Impl | 24 | } // namespace Impl |
| 26 | 25 | ||
| 27 | /// Uniform structure for the Uniform Buffer Object, all vectors must be 16-byte aligned | 26 | /// Uniform structure for the Uniform Buffer Object, all vectors must be 16-byte aligned |
diff --git a/src/yuzu/debugger/graphics/graphics_surface.cpp b/src/yuzu/debugger/graphics/graphics_surface.cpp index 1fbca8ad0..c41ff693b 100644 --- a/src/yuzu/debugger/graphics/graphics_surface.cpp +++ b/src/yuzu/debugger/graphics/graphics_surface.cpp | |||
| @@ -336,9 +336,9 @@ void GraphicsSurfaceWidget::OnUpdate() { | |||
| 336 | // TODO: Store a reference to the registers in the debug context instead of accessing them | 336 | // TODO: Store a reference to the registers in the debug context instead of accessing them |
| 337 | // directly... | 337 | // directly... |
| 338 | 338 | ||
| 339 | auto& registers = gpu.Get3DEngine().regs; | 339 | const auto& registers = gpu.Maxwell3D().regs; |
| 340 | auto& rt = registers.rt[static_cast<size_t>(surface_source) - | 340 | const auto& rt = registers.rt[static_cast<size_t>(surface_source) - |
| 341 | static_cast<size_t>(Source::RenderTarget0)]; | 341 | static_cast<size_t>(Source::RenderTarget0)]; |
| 342 | 342 | ||
| 343 | surface_address = rt.Address(); | 343 | surface_address = rt.Address(); |
| 344 | surface_width = rt.width; | 344 | surface_width = rt.width; |