diff options
| author | 2020-11-26 15:19:08 -0500 | |
|---|---|---|
| committer | 2020-11-26 20:03:11 -0500 | |
| commit | 1a954b2a596fdfd4fc4b5feb9b43c8147de4cc7f (patch) | |
| tree | 3593cd42e0ba676c3919561983f7e9766fcb641c /src/core/hle/service/spl | |
| parent | Merge pull request #4975 from comex/invalid-syncpoint-id (diff) | |
| download | yuzu-1a954b2a596fdfd4fc4b5feb9b43c8147de4cc7f.tar.gz yuzu-1a954b2a596fdfd4fc4b5feb9b43c8147de4cc7f.tar.xz yuzu-1a954b2a596fdfd4fc4b5feb9b43c8147de4cc7f.zip | |
service: Eliminate usages of the global system instance
Completely removes all usages of the global system instance within the
services code by passing in the using system instance to the services.
Diffstat (limited to 'src/core/hle/service/spl')
| -rw-r--r-- | src/core/hle/service/spl/csrng.cpp | 3 | ||||
| -rw-r--r-- | src/core/hle/service/spl/csrng.h | 6 | ||||
| -rw-r--r-- | src/core/hle/service/spl/module.cpp | 11 | ||||
| -rw-r--r-- | src/core/hle/service/spl/module.h | 9 | ||||
| -rw-r--r-- | src/core/hle/service/spl/spl.cpp | 3 | ||||
| -rw-r--r-- | src/core/hle/service/spl/spl.h | 6 |
6 files changed, 27 insertions, 11 deletions
diff --git a/src/core/hle/service/spl/csrng.cpp b/src/core/hle/service/spl/csrng.cpp index 674928798..1beca417c 100644 --- a/src/core/hle/service/spl/csrng.cpp +++ b/src/core/hle/service/spl/csrng.cpp | |||
| @@ -6,7 +6,8 @@ | |||
| 6 | 6 | ||
| 7 | namespace Service::SPL { | 7 | namespace Service::SPL { |
| 8 | 8 | ||
| 9 | CSRNG::CSRNG(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "csrng") { | 9 | CSRNG::CSRNG(Core::System& system_, std::shared_ptr<Module> module_) |
| 10 | : Interface(system_, std::move(module_), "csrng") { | ||
| 10 | static const FunctionInfo functions[] = { | 11 | static const FunctionInfo functions[] = { |
| 11 | {0, &CSRNG::GetRandomBytes, "GetRandomBytes"}, | 12 | {0, &CSRNG::GetRandomBytes, "GetRandomBytes"}, |
| 12 | }; | 13 | }; |
diff --git a/src/core/hle/service/spl/csrng.h b/src/core/hle/service/spl/csrng.h index 764d5ceb0..5c0bd2199 100644 --- a/src/core/hle/service/spl/csrng.h +++ b/src/core/hle/service/spl/csrng.h | |||
| @@ -6,11 +6,15 @@ | |||
| 6 | 6 | ||
| 7 | #include "core/hle/service/spl/module.h" | 7 | #include "core/hle/service/spl/module.h" |
| 8 | 8 | ||
| 9 | namespace Core { | ||
| 10 | class System; | ||
| 11 | } | ||
| 12 | |||
| 9 | namespace Service::SPL { | 13 | namespace Service::SPL { |
| 10 | 14 | ||
| 11 | class CSRNG final : public Module::Interface { | 15 | class CSRNG final : public Module::Interface { |
| 12 | public: | 16 | public: |
| 13 | explicit CSRNG(std::shared_ptr<Module> module); | 17 | explicit CSRNG(Core::System& system_, std::shared_ptr<Module> module_); |
| 14 | ~CSRNG() override; | 18 | ~CSRNG() override; |
| 15 | }; | 19 | }; |
| 16 | 20 | ||
diff --git a/src/core/hle/service/spl/module.cpp b/src/core/hle/service/spl/module.cpp index 865ed3b91..dea6b0fe0 100644 --- a/src/core/hle/service/spl/module.cpp +++ b/src/core/hle/service/spl/module.cpp | |||
| @@ -17,8 +17,9 @@ | |||
| 17 | 17 | ||
| 18 | namespace Service::SPL { | 18 | namespace Service::SPL { |
| 19 | 19 | ||
| 20 | Module::Interface::Interface(std::shared_ptr<Module> module, const char* name) | 20 | Module::Interface::Interface(Core::System& system_, std::shared_ptr<Module> module_, |
| 21 | : ServiceFramework(name), module(std::move(module)), | 21 | const char* name) |
| 22 | : ServiceFramework{system_, name}, module{std::move(module_)}, | ||
| 22 | rng(Settings::values.rng_seed.GetValue().value_or(std::time(nullptr))) {} | 23 | rng(Settings::values.rng_seed.GetValue().value_or(std::time(nullptr))) {} |
| 23 | 24 | ||
| 24 | Module::Interface::~Interface() = default; | 25 | Module::Interface::~Interface() = default; |
| @@ -38,10 +39,10 @@ void Module::Interface::GetRandomBytes(Kernel::HLERequestContext& ctx) { | |||
| 38 | rb.Push(RESULT_SUCCESS); | 39 | rb.Push(RESULT_SUCCESS); |
| 39 | } | 40 | } |
| 40 | 41 | ||
| 41 | void InstallInterfaces(SM::ServiceManager& service_manager) { | 42 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { |
| 42 | auto module = std::make_shared<Module>(); | 43 | auto module = std::make_shared<Module>(); |
| 43 | std::make_shared<CSRNG>(module)->InstallAsService(service_manager); | 44 | std::make_shared<CSRNG>(system, module)->InstallAsService(service_manager); |
| 44 | std::make_shared<SPL>(module)->InstallAsService(service_manager); | 45 | std::make_shared<SPL>(system, module)->InstallAsService(service_manager); |
| 45 | } | 46 | } |
| 46 | 47 | ||
| 47 | } // namespace Service::SPL | 48 | } // namespace Service::SPL |
diff --git a/src/core/hle/service/spl/module.h b/src/core/hle/service/spl/module.h index afa1f0295..71855c1bf 100644 --- a/src/core/hle/service/spl/module.h +++ b/src/core/hle/service/spl/module.h | |||
| @@ -7,13 +7,18 @@ | |||
| 7 | #include <random> | 7 | #include <random> |
| 8 | #include "core/hle/service/service.h" | 8 | #include "core/hle/service/service.h" |
| 9 | 9 | ||
| 10 | namespace Core { | ||
| 11 | class System; | ||
| 12 | } | ||
| 13 | |||
| 10 | namespace Service::SPL { | 14 | namespace Service::SPL { |
| 11 | 15 | ||
| 12 | class Module final { | 16 | class Module final { |
| 13 | public: | 17 | public: |
| 14 | class Interface : public ServiceFramework<Interface> { | 18 | class Interface : public ServiceFramework<Interface> { |
| 15 | public: | 19 | public: |
| 16 | explicit Interface(std::shared_ptr<Module> module, const char* name); | 20 | explicit Interface(Core::System& system_, std::shared_ptr<Module> module_, |
| 21 | const char* name); | ||
| 17 | ~Interface() override; | 22 | ~Interface() override; |
| 18 | 23 | ||
| 19 | void GetRandomBytes(Kernel::HLERequestContext& ctx); | 24 | void GetRandomBytes(Kernel::HLERequestContext& ctx); |
| @@ -27,6 +32,6 @@ public: | |||
| 27 | }; | 32 | }; |
| 28 | 33 | ||
| 29 | /// Registers all SPL services with the specified service manager. | 34 | /// Registers all SPL services with the specified service manager. |
| 30 | void InstallInterfaces(SM::ServiceManager& service_manager); | 35 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); |
| 31 | 36 | ||
| 32 | } // namespace Service::SPL | 37 | } // namespace Service::SPL |
diff --git a/src/core/hle/service/spl/spl.cpp b/src/core/hle/service/spl/spl.cpp index 773551464..3fabc2c79 100644 --- a/src/core/hle/service/spl/spl.cpp +++ b/src/core/hle/service/spl/spl.cpp | |||
| @@ -6,7 +6,8 @@ | |||
| 6 | 6 | ||
| 7 | namespace Service::SPL { | 7 | namespace Service::SPL { |
| 8 | 8 | ||
| 9 | SPL::SPL(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "spl:") { | 9 | SPL::SPL(Core::System& system_, std::shared_ptr<Module> module_) |
| 10 | : Interface(system_, std::move(module_), "spl:") { | ||
| 10 | static const FunctionInfo functions[] = { | 11 | static const FunctionInfo functions[] = { |
| 11 | {0, nullptr, "GetConfig"}, | 12 | {0, nullptr, "GetConfig"}, |
| 12 | {1, nullptr, "ModularExponentiate"}, | 13 | {1, nullptr, "ModularExponentiate"}, |
diff --git a/src/core/hle/service/spl/spl.h b/src/core/hle/service/spl/spl.h index 3637d1623..d27d16b86 100644 --- a/src/core/hle/service/spl/spl.h +++ b/src/core/hle/service/spl/spl.h | |||
| @@ -6,11 +6,15 @@ | |||
| 6 | 6 | ||
| 7 | #include "core/hle/service/spl/module.h" | 7 | #include "core/hle/service/spl/module.h" |
| 8 | 8 | ||
| 9 | namespace Core { | ||
| 10 | class System; | ||
| 11 | } | ||
| 12 | |||
| 9 | namespace Service::SPL { | 13 | namespace Service::SPL { |
| 10 | 14 | ||
| 11 | class SPL final : public Module::Interface { | 15 | class SPL final : public Module::Interface { |
| 12 | public: | 16 | public: |
| 13 | explicit SPL(std::shared_ptr<Module> module); | 17 | explicit SPL(Core::System& system_, std::shared_ptr<Module> module_); |
| 14 | ~SPL() override; | 18 | ~SPL() override; |
| 15 | }; | 19 | }; |
| 16 | 20 | ||