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.
This commit is contained in:
parent
322349e8cc
commit
1a954b2a59
222 changed files with 1221 additions and 907 deletions
|
@ -6,7 +6,8 @@
|
|||
|
||||
namespace Service::SPL {
|
||||
|
||||
CSRNG::CSRNG(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "csrng") {
|
||||
CSRNG::CSRNG(Core::System& system_, std::shared_ptr<Module> module_)
|
||||
: Interface(system_, std::move(module_), "csrng") {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, &CSRNG::GetRandomBytes, "GetRandomBytes"},
|
||||
};
|
||||
|
|
|
@ -6,11 +6,15 @@
|
|||
|
||||
#include "core/hle/service/spl/module.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Service::SPL {
|
||||
|
||||
class CSRNG final : public Module::Interface {
|
||||
public:
|
||||
explicit CSRNG(std::shared_ptr<Module> module);
|
||||
explicit CSRNG(Core::System& system_, std::shared_ptr<Module> module_);
|
||||
~CSRNG() override;
|
||||
};
|
||||
|
||||
|
|
|
@ -17,8 +17,9 @@
|
|||
|
||||
namespace Service::SPL {
|
||||
|
||||
Module::Interface::Interface(std::shared_ptr<Module> module, const char* name)
|
||||
: ServiceFramework(name), module(std::move(module)),
|
||||
Module::Interface::Interface(Core::System& system_, std::shared_ptr<Module> module_,
|
||||
const char* name)
|
||||
: ServiceFramework{system_, name}, module{std::move(module_)},
|
||||
rng(Settings::values.rng_seed.GetValue().value_or(std::time(nullptr))) {}
|
||||
|
||||
Module::Interface::~Interface() = default;
|
||||
|
@ -38,10 +39,10 @@ void Module::Interface::GetRandomBytes(Kernel::HLERequestContext& ctx) {
|
|||
rb.Push(RESULT_SUCCESS);
|
||||
}
|
||||
|
||||
void InstallInterfaces(SM::ServiceManager& service_manager) {
|
||||
void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
|
||||
auto module = std::make_shared<Module>();
|
||||
std::make_shared<CSRNG>(module)->InstallAsService(service_manager);
|
||||
std::make_shared<SPL>(module)->InstallAsService(service_manager);
|
||||
std::make_shared<CSRNG>(system, module)->InstallAsService(service_manager);
|
||||
std::make_shared<SPL>(system, module)->InstallAsService(service_manager);
|
||||
}
|
||||
|
||||
} // namespace Service::SPL
|
||||
|
|
|
@ -7,13 +7,18 @@
|
|||
#include <random>
|
||||
#include "core/hle/service/service.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Service::SPL {
|
||||
|
||||
class Module final {
|
||||
public:
|
||||
class Interface : public ServiceFramework<Interface> {
|
||||
public:
|
||||
explicit Interface(std::shared_ptr<Module> module, const char* name);
|
||||
explicit Interface(Core::System& system_, std::shared_ptr<Module> module_,
|
||||
const char* name);
|
||||
~Interface() override;
|
||||
|
||||
void GetRandomBytes(Kernel::HLERequestContext& ctx);
|
||||
|
@ -27,6 +32,6 @@ public:
|
|||
};
|
||||
|
||||
/// Registers all SPL services with the specified service manager.
|
||||
void InstallInterfaces(SM::ServiceManager& service_manager);
|
||||
void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system);
|
||||
|
||||
} // namespace Service::SPL
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
|
||||
namespace Service::SPL {
|
||||
|
||||
SPL::SPL(std::shared_ptr<Module> module) : Module::Interface(std::move(module), "spl:") {
|
||||
SPL::SPL(Core::System& system_, std::shared_ptr<Module> module_)
|
||||
: Interface(system_, std::move(module_), "spl:") {
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, nullptr, "GetConfig"},
|
||||
{1, nullptr, "ModularExponentiate"},
|
||||
|
|
|
@ -6,11 +6,15 @@
|
|||
|
||||
#include "core/hle/service/spl/module.h"
|
||||
|
||||
namespace Core {
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Service::SPL {
|
||||
|
||||
class SPL final : public Module::Interface {
|
||||
public:
|
||||
explicit SPL(std::shared_ptr<Module> module);
|
||||
explicit SPL(Core::System& system_, std::shared_ptr<Module> module_);
|
||||
~SPL() override;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue