summaryrefslogtreecommitdiff
path: root/src/core/hle/service/spl
diff options
context:
space:
mode:
authorGravatar Lioncash2020-11-26 15:19:08 -0500
committerGravatar Lioncash2020-11-26 20:03:11 -0500
commit1a954b2a596fdfd4fc4b5feb9b43c8147de4cc7f (patch)
tree3593cd42e0ba676c3919561983f7e9766fcb641c /src/core/hle/service/spl
parentMerge pull request #4975 from comex/invalid-syncpoint-id (diff)
downloadyuzu-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.cpp3
-rw-r--r--src/core/hle/service/spl/csrng.h6
-rw-r--r--src/core/hle/service/spl/module.cpp11
-rw-r--r--src/core/hle/service/spl/module.h9
-rw-r--r--src/core/hle/service/spl/spl.cpp3
-rw-r--r--src/core/hle/service/spl/spl.h6
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
7namespace Service::SPL { 7namespace Service::SPL {
8 8
9CSRNG::CSRNG(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "csrng") { 9CSRNG::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
9namespace Core {
10class System;
11}
12
9namespace Service::SPL { 13namespace Service::SPL {
10 14
11class CSRNG final : public Module::Interface { 15class CSRNG final : public Module::Interface {
12public: 16public:
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
18namespace Service::SPL { 18namespace Service::SPL {
19 19
20Module::Interface::Interface(std::shared_ptr<Module> module, const char* name) 20Module::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
24Module::Interface::~Interface() = default; 25Module::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
41void InstallInterfaces(SM::ServiceManager& service_manager) { 42void 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
10namespace Core {
11class System;
12}
13
10namespace Service::SPL { 14namespace Service::SPL {
11 15
12class Module final { 16class Module final {
13public: 17public:
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.
30void InstallInterfaces(SM::ServiceManager& service_manager); 35void 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
7namespace Service::SPL { 7namespace Service::SPL {
8 8
9SPL::SPL(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "spl:") { 9SPL::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
9namespace Core {
10class System;
11}
12
9namespace Service::SPL { 13namespace Service::SPL {
10 14
11class SPL final : public Module::Interface { 15class SPL final : public Module::Interface {
12public: 16public:
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