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/sm | |
| 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/sm')
| -rw-r--r-- | src/core/hle/service/sm/controller.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/service/sm/controller.h | 6 | ||||
| -rw-r--r-- | src/core/hle/service/sm/sm.cpp | 14 | ||||
| -rw-r--r-- | src/core/hle/service/sm/sm.h | 8 |
4 files changed, 19 insertions, 11 deletions
diff --git a/src/core/hle/service/sm/controller.cpp b/src/core/hle/service/sm/controller.cpp index 972aaa6d9..916177efd 100644 --- a/src/core/hle/service/sm/controller.cpp +++ b/src/core/hle/service/sm/controller.cpp | |||
| @@ -48,7 +48,7 @@ void Controller::QueryPointerBufferSize(Kernel::HLERequestContext& ctx) { | |||
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | // https://switchbrew.org/wiki/IPC_Marshalling | 50 | // https://switchbrew.org/wiki/IPC_Marshalling |
| 51 | Controller::Controller() : ServiceFramework("IpcController") { | 51 | Controller::Controller(Core::System& system_) : ServiceFramework{system_, "IpcController"} { |
| 52 | static const FunctionInfo functions[] = { | 52 | static const FunctionInfo functions[] = { |
| 53 | {0, &Controller::ConvertCurrentObjectToDomain, "ConvertCurrentObjectToDomain"}, | 53 | {0, &Controller::ConvertCurrentObjectToDomain, "ConvertCurrentObjectToDomain"}, |
| 54 | {1, nullptr, "CopyFromCurrentDomain"}, | 54 | {1, nullptr, "CopyFromCurrentDomain"}, |
diff --git a/src/core/hle/service/sm/controller.h b/src/core/hle/service/sm/controller.h index 180c6da50..7494f898d 100644 --- a/src/core/hle/service/sm/controller.h +++ b/src/core/hle/service/sm/controller.h | |||
| @@ -6,11 +6,15 @@ | |||
| 6 | 6 | ||
| 7 | #include "core/hle/service/service.h" | 7 | #include "core/hle/service/service.h" |
| 8 | 8 | ||
| 9 | namespace Core { | ||
| 10 | class System; | ||
| 11 | } | ||
| 12 | |||
| 9 | namespace Service::SM { | 13 | namespace Service::SM { |
| 10 | 14 | ||
| 11 | class Controller final : public ServiceFramework<Controller> { | 15 | class Controller final : public ServiceFramework<Controller> { |
| 12 | public: | 16 | public: |
| 13 | Controller(); | 17 | explicit Controller(Core::System& system_); |
| 14 | ~Controller() override; | 18 | ~Controller() override; |
| 15 | 19 | ||
| 16 | private: | 20 | private: |
diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index 9c1da361b..4da69f503 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp | |||
| @@ -38,14 +38,13 @@ static ResultCode ValidateServiceName(const std::string& name) { | |||
| 38 | return RESULT_SUCCESS; | 38 | return RESULT_SUCCESS; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | void ServiceManager::InstallInterfaces(std::shared_ptr<ServiceManager> self, | 41 | void ServiceManager::InstallInterfaces(std::shared_ptr<ServiceManager> self, Core::System& system) { |
| 42 | Kernel::KernelCore& kernel) { | ||
| 43 | ASSERT(self->sm_interface.expired()); | 42 | ASSERT(self->sm_interface.expired()); |
| 44 | 43 | ||
| 45 | auto sm = std::make_shared<SM>(self, kernel); | 44 | auto sm = std::make_shared<SM>(self, system); |
| 46 | sm->InstallAsNamedPort(kernel); | 45 | sm->InstallAsNamedPort(system.Kernel()); |
| 47 | self->sm_interface = sm; | 46 | self->sm_interface = sm; |
| 48 | self->controller_interface = std::make_unique<Controller>(); | 47 | self->controller_interface = std::make_unique<Controller>(system); |
| 49 | } | 48 | } |
| 50 | 49 | ||
| 51 | ResultVal<std::shared_ptr<Kernel::ServerPort>> ServiceManager::RegisterService(std::string name, | 50 | ResultVal<std::shared_ptr<Kernel::ServerPort>> ServiceManager::RegisterService(std::string name, |
| @@ -190,8 +189,9 @@ void SM::UnregisterService(Kernel::HLERequestContext& ctx) { | |||
| 190 | rb.Push(service_manager->UnregisterService(name)); | 189 | rb.Push(service_manager->UnregisterService(name)); |
| 191 | } | 190 | } |
| 192 | 191 | ||
| 193 | SM::SM(std::shared_ptr<ServiceManager> service_manager, Kernel::KernelCore& kernel) | 192 | SM::SM(std::shared_ptr<ServiceManager> service_manager_, Core::System& system_) |
| 194 | : ServiceFramework{"sm:", 4}, service_manager{std::move(service_manager)}, kernel{kernel} { | 193 | : ServiceFramework{system_, "sm:", 4}, |
| 194 | service_manager{std::move(service_manager_)}, kernel{system_.Kernel()} { | ||
| 195 | static const FunctionInfo functions[] = { | 195 | static const FunctionInfo functions[] = { |
| 196 | {0x00000000, &SM::Initialize, "Initialize"}, | 196 | {0x00000000, &SM::Initialize, "Initialize"}, |
| 197 | {0x00000001, &SM::GetService, "GetService"}, | 197 | {0x00000001, &SM::GetService, "GetService"}, |
diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h index 6790c86f0..3f46ae44f 100644 --- a/src/core/hle/service/sm/sm.h +++ b/src/core/hle/service/sm/sm.h | |||
| @@ -16,6 +16,10 @@ | |||
| 16 | #include "core/hle/result.h" | 16 | #include "core/hle/result.h" |
| 17 | #include "core/hle/service/service.h" | 17 | #include "core/hle/service/service.h" |
| 18 | 18 | ||
| 19 | namespace Core { | ||
| 20 | class System; | ||
| 21 | } | ||
| 22 | |||
| 19 | namespace Kernel { | 23 | namespace Kernel { |
| 20 | class ClientPort; | 24 | class ClientPort; |
| 21 | class ClientSession; | 25 | class ClientSession; |
| @@ -31,7 +35,7 @@ class Controller; | |||
| 31 | /// Interface to "sm:" service | 35 | /// Interface to "sm:" service |
| 32 | class SM final : public ServiceFramework<SM> { | 36 | class SM final : public ServiceFramework<SM> { |
| 33 | public: | 37 | public: |
| 34 | explicit SM(std::shared_ptr<ServiceManager> service_manager, Kernel::KernelCore& kernel); | 38 | explicit SM(std::shared_ptr<ServiceManager> service_manager_, Core::System& system_); |
| 35 | ~SM() override; | 39 | ~SM() override; |
| 36 | 40 | ||
| 37 | private: | 41 | private: |
| @@ -46,7 +50,7 @@ private: | |||
| 46 | 50 | ||
| 47 | class ServiceManager { | 51 | class ServiceManager { |
| 48 | public: | 52 | public: |
| 49 | static void InstallInterfaces(std::shared_ptr<ServiceManager> self, Kernel::KernelCore& kernel); | 53 | static void InstallInterfaces(std::shared_ptr<ServiceManager> self, Core::System& system); |
| 50 | 54 | ||
| 51 | explicit ServiceManager(Kernel::KernelCore& kernel_); | 55 | explicit ServiceManager(Kernel::KernelCore& kernel_); |
| 52 | ~ServiceManager(); | 56 | ~ServiceManager(); |