diff options
| author | 2018-04-20 21:26:27 -0400 | |
|---|---|---|
| committer | 2018-04-20 21:26:27 -0400 | |
| commit | 2e7ce96b1d55df535ab7e16efb711d9bdf82cfd1 (patch) | |
| tree | eb3a8d9007462f1864174ea4ffe9e5a80d56c9d5 /src | |
| parent | Merge pull request #340 from mailwl/vi-update (diff) | |
| parent | core: Relocate g_service_manager to the System class (diff) | |
| download | yuzu-2e7ce96b1d55df535ab7e16efb711d9bdf82cfd1.tar.gz yuzu-2e7ce96b1d55df535ab7e16efb711d9bdf82cfd1.tar.xz yuzu-2e7ce96b1d55df535ab7e16efb711d9bdf82cfd1.zip | |
Merge pull request #371 from lioncash/global
core: Relocate g_service_manager to the System class
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/core.cpp | 28 | ||||
| -rw-r--r-- | src/core/core.h | 12 | ||||
| -rw-r--r-- | src/core/hle/service/service.cpp | 52 | ||||
| -rw-r--r-- | src/core/hle/service/service.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/sm/sm.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/sm/sm.h | 6 |
6 files changed, 66 insertions, 38 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 9f5507a65..ee4af4dcc 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -12,10 +12,13 @@ | |||
| 12 | #include "core/core.h" | 12 | #include "core/core.h" |
| 13 | #include "core/core_timing.h" | 13 | #include "core/core_timing.h" |
| 14 | #include "core/gdbstub/gdbstub.h" | 14 | #include "core/gdbstub/gdbstub.h" |
| 15 | #include "core/hle/kernel/client_port.h" | ||
| 15 | #include "core/hle/kernel/kernel.h" | 16 | #include "core/hle/kernel/kernel.h" |
| 16 | #include "core/hle/kernel/process.h" | 17 | #include "core/hle/kernel/process.h" |
| 17 | #include "core/hle/kernel/thread.h" | 18 | #include "core/hle/kernel/thread.h" |
| 18 | #include "core/hle/service/service.h" | 19 | #include "core/hle/service/service.h" |
| 20 | #include "core/hle/service/sm/controller.h" | ||
| 21 | #include "core/hle/service/sm/sm.h" | ||
| 19 | #include "core/hw/hw.h" | 22 | #include "core/hw/hw.h" |
| 20 | #include "core/loader/loader.h" | 23 | #include "core/loader/loader.h" |
| 21 | #include "core/memory_setup.h" | 24 | #include "core/memory_setup.h" |
| @@ -26,6 +29,8 @@ namespace Core { | |||
| 26 | 29 | ||
| 27 | /*static*/ System System::s_instance; | 30 | /*static*/ System System::s_instance; |
| 28 | 31 | ||
| 32 | System::~System() = default; | ||
| 33 | |||
| 29 | System::ResultStatus System::RunLoop(bool tight_loop) { | 34 | System::ResultStatus System::RunLoop(bool tight_loop) { |
| 30 | status = ResultStatus::Success; | 35 | status = ResultStatus::Success; |
| 31 | if (!cpu_core) { | 36 | if (!cpu_core) { |
| @@ -167,10 +172,12 @@ System::ResultStatus System::Init(EmuWindow* emu_window, u32 system_mode) { | |||
| 167 | 172 | ||
| 168 | telemetry_session = std::make_unique<Core::TelemetrySession>(); | 173 | telemetry_session = std::make_unique<Core::TelemetrySession>(); |
| 169 | 174 | ||
| 175 | service_manager = std::make_shared<Service::SM::ServiceManager>(); | ||
| 176 | |||
| 170 | HW::Init(); | 177 | HW::Init(); |
| 171 | Kernel::Init(system_mode); | 178 | Kernel::Init(system_mode); |
| 172 | scheduler = std::make_unique<Kernel::Scheduler>(cpu_core.get()); | 179 | scheduler = std::make_unique<Kernel::Scheduler>(cpu_core.get()); |
| 173 | Service::Init(); | 180 | Service::Init(service_manager); |
| 174 | GDBStub::Init(); | 181 | GDBStub::Init(); |
| 175 | 182 | ||
| 176 | if (!VideoCore::Init(emu_window)) { | 183 | if (!VideoCore::Init(emu_window)) { |
| @@ -200,17 +207,26 @@ void System::Shutdown() { | |||
| 200 | VideoCore::Shutdown(); | 207 | VideoCore::Shutdown(); |
| 201 | GDBStub::Shutdown(); | 208 | GDBStub::Shutdown(); |
| 202 | Service::Shutdown(); | 209 | Service::Shutdown(); |
| 203 | scheduler = nullptr; | 210 | scheduler.reset(); |
| 204 | Kernel::Shutdown(); | 211 | Kernel::Shutdown(); |
| 205 | HW::Shutdown(); | 212 | HW::Shutdown(); |
| 206 | telemetry_session = nullptr; | 213 | service_manager.reset(); |
| 207 | gpu_core = nullptr; | 214 | telemetry_session.reset(); |
| 208 | cpu_core = nullptr; | 215 | gpu_core.reset(); |
| 216 | cpu_core.reset(); | ||
| 209 | CoreTiming::Shutdown(); | 217 | CoreTiming::Shutdown(); |
| 210 | 218 | ||
| 211 | app_loader = nullptr; | 219 | app_loader.reset(); |
| 212 | 220 | ||
| 213 | LOG_DEBUG(Core, "Shutdown OK"); | 221 | LOG_DEBUG(Core, "Shutdown OK"); |
| 214 | } | 222 | } |
| 215 | 223 | ||
| 224 | Service::SM::ServiceManager& System::ServiceManager() { | ||
| 225 | return *service_manager; | ||
| 226 | } | ||
| 227 | |||
| 228 | const Service::SM::ServiceManager& System::ServiceManager() const { | ||
| 229 | return *service_manager; | ||
| 230 | } | ||
| 231 | |||
| 216 | } // namespace Core | 232 | } // namespace Core |
diff --git a/src/core/core.h b/src/core/core.h index f497dc022..f81cbfb3c 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -19,10 +19,16 @@ | |||
| 19 | class EmuWindow; | 19 | class EmuWindow; |
| 20 | class ARM_Interface; | 20 | class ARM_Interface; |
| 21 | 21 | ||
| 22 | namespace Service::SM { | ||
| 23 | class ServiceManager; | ||
| 24 | } | ||
| 25 | |||
| 22 | namespace Core { | 26 | namespace Core { |
| 23 | 27 | ||
| 24 | class System { | 28 | class System { |
| 25 | public: | 29 | public: |
| 30 | ~System(); | ||
| 31 | |||
| 26 | /** | 32 | /** |
| 27 | * Gets the instance of the System singleton class. | 33 | * Gets the instance of the System singleton class. |
| 28 | * @returns Reference to the instance of the System singleton class. | 34 | * @returns Reference to the instance of the System singleton class. |
| @@ -137,6 +143,9 @@ public: | |||
| 137 | return *app_loader; | 143 | return *app_loader; |
| 138 | } | 144 | } |
| 139 | 145 | ||
| 146 | Service::SM::ServiceManager& ServiceManager(); | ||
| 147 | const Service::SM::ServiceManager& ServiceManager() const; | ||
| 148 | |||
| 140 | void SetGPUDebugContext(std::shared_ptr<Tegra::DebugContext> context) { | 149 | void SetGPUDebugContext(std::shared_ptr<Tegra::DebugContext> context) { |
| 141 | debug_context = std::move(context); | 150 | debug_context = std::move(context); |
| 142 | } | 151 | } |
| @@ -171,6 +180,9 @@ private: | |||
| 171 | /// When true, signals that a reschedule should happen | 180 | /// When true, signals that a reschedule should happen |
| 172 | bool reschedule_pending{}; | 181 | bool reschedule_pending{}; |
| 173 | 182 | ||
| 183 | /// Service manager | ||
| 184 | std::shared_ptr<Service::SM::ServiceManager> service_manager; | ||
| 185 | |||
| 174 | /// Telemetry session for this emulation session | 186 | /// Telemetry session for this emulation session |
| 175 | std::unique_ptr<Core::TelemetrySession> telemetry_session; | 187 | std::unique_ptr<Core::TelemetrySession> telemetry_session; |
| 176 | 188 | ||
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index c5490c1ae..08ce29677 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp | |||
| @@ -145,7 +145,7 @@ ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext& co | |||
| 145 | return ResultCode(ErrorModule::HIPC, ErrorDescription::RemoteProcessDead); | 145 | return ResultCode(ErrorModule::HIPC, ErrorDescription::RemoteProcessDead); |
| 146 | } | 146 | } |
| 147 | case IPC::CommandType::Control: { | 147 | case IPC::CommandType::Control: { |
| 148 | SM::g_service_manager->InvokeControlRequest(context); | 148 | Core::System::GetInstance().ServiceManager().InvokeControlRequest(context); |
| 149 | break; | 149 | break; |
| 150 | } | 150 | } |
| 151 | case IPC::CommandType::Request: { | 151 | case IPC::CommandType::Request: { |
| @@ -170,42 +170,40 @@ void AddNamedPort(std::string name, SharedPtr<ClientPort> port) { | |||
| 170 | } | 170 | } |
| 171 | 171 | ||
| 172 | /// Initialize ServiceManager | 172 | /// Initialize ServiceManager |
| 173 | void Init() { | 173 | void Init(std::shared_ptr<SM::ServiceManager>& sm) { |
| 174 | // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it | 174 | // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it |
| 175 | // here and pass it into the respective InstallInterfaces functions. | 175 | // here and pass it into the respective InstallInterfaces functions. |
| 176 | auto nv_flinger = std::make_shared<NVFlinger::NVFlinger>(); | 176 | auto nv_flinger = std::make_shared<NVFlinger::NVFlinger>(); |
| 177 | 177 | ||
| 178 | SM::g_service_manager = std::make_shared<SM::ServiceManager>(); | 178 | SM::ServiceManager::InstallInterfaces(sm); |
| 179 | SM::ServiceManager::InstallInterfaces(SM::g_service_manager); | 179 | |
| 180 | 180 | Account::InstallInterfaces(*sm); | |
| 181 | Account::InstallInterfaces(*SM::g_service_manager); | 181 | AM::InstallInterfaces(*sm, nv_flinger); |
| 182 | AM::InstallInterfaces(*SM::g_service_manager, nv_flinger); | 182 | AOC::InstallInterfaces(*sm); |
| 183 | AOC::InstallInterfaces(*SM::g_service_manager); | 183 | APM::InstallInterfaces(*sm); |
| 184 | APM::InstallInterfaces(*SM::g_service_manager); | 184 | Audio::InstallInterfaces(*sm); |
| 185 | Audio::InstallInterfaces(*SM::g_service_manager); | 185 | Fatal::InstallInterfaces(*sm); |
| 186 | Fatal::InstallInterfaces(*SM::g_service_manager); | 186 | FileSystem::InstallInterfaces(*sm); |
| 187 | FileSystem::InstallInterfaces(*SM::g_service_manager); | 187 | Friend::InstallInterfaces(*sm); |
| 188 | Friend::InstallInterfaces(*SM::g_service_manager); | 188 | HID::InstallInterfaces(*sm); |
| 189 | HID::InstallInterfaces(*SM::g_service_manager); | 189 | LM::InstallInterfaces(*sm); |
| 190 | LM::InstallInterfaces(*SM::g_service_manager); | 190 | NFP::InstallInterfaces(*sm); |
| 191 | NFP::InstallInterfaces(*SM::g_service_manager); | 191 | NIFM::InstallInterfaces(*sm); |
| 192 | NIFM::InstallInterfaces(*SM::g_service_manager); | 192 | NS::InstallInterfaces(*sm); |
| 193 | NS::InstallInterfaces(*SM::g_service_manager); | 193 | Nvidia::InstallInterfaces(*sm); |
| 194 | Nvidia::InstallInterfaces(*SM::g_service_manager); | 194 | PCTL::InstallInterfaces(*sm); |
| 195 | PCTL::InstallInterfaces(*SM::g_service_manager); | 195 | Sockets::InstallInterfaces(*sm); |
| 196 | Sockets::InstallInterfaces(*SM::g_service_manager); | 196 | SPL::InstallInterfaces(*sm); |
| 197 | SPL::InstallInterfaces(*SM::g_service_manager); | 197 | SSL::InstallInterfaces(*sm); |
| 198 | SSL::InstallInterfaces(*SM::g_service_manager); | 198 | Time::InstallInterfaces(*sm); |
| 199 | Time::InstallInterfaces(*SM::g_service_manager); | 199 | VI::InstallInterfaces(*sm, nv_flinger); |
| 200 | VI::InstallInterfaces(*SM::g_service_manager, nv_flinger); | 200 | Set::InstallInterfaces(*sm); |
| 201 | Set::InstallInterfaces(*SM::g_service_manager); | ||
| 202 | 201 | ||
| 203 | LOG_DEBUG(Service, "initialized OK"); | 202 | LOG_DEBUG(Service, "initialized OK"); |
| 204 | } | 203 | } |
| 205 | 204 | ||
| 206 | /// Shutdown ServiceManager | 205 | /// Shutdown ServiceManager |
| 207 | void Shutdown() { | 206 | void Shutdown() { |
| 208 | SM::g_service_manager = nullptr; | ||
| 209 | g_kernel_named_ports.clear(); | 207 | g_kernel_named_ports.clear(); |
| 210 | LOG_DEBUG(Service, "shutdown OK"); | 208 | LOG_DEBUG(Service, "shutdown OK"); |
| 211 | } | 209 | } |
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 9c2e826da..fee841d46 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h | |||
| @@ -178,7 +178,7 @@ private: | |||
| 178 | }; | 178 | }; |
| 179 | 179 | ||
| 180 | /// Initialize ServiceManager | 180 | /// Initialize ServiceManager |
| 181 | void Init(); | 181 | void Init(std::shared_ptr<SM::ServiceManager>& sm); |
| 182 | 182 | ||
| 183 | /// Shutdown ServiceManager | 183 | /// Shutdown ServiceManager |
| 184 | void Shutdown(); | 184 | void Shutdown(); |
diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index 297a4f2c6..4578fc05f 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp | |||
| @@ -14,6 +14,8 @@ | |||
| 14 | 14 | ||
| 15 | namespace Service::SM { | 15 | namespace Service::SM { |
| 16 | 16 | ||
| 17 | ServiceManager::~ServiceManager() = default; | ||
| 18 | |||
| 17 | void ServiceManager::InvokeControlRequest(Kernel::HLERequestContext& context) { | 19 | void ServiceManager::InvokeControlRequest(Kernel::HLERequestContext& context) { |
| 18 | controller_interface->InvokeRequest(context); | 20 | controller_interface->InvokeRequest(context); |
| 19 | } | 21 | } |
| @@ -72,7 +74,7 @@ ResultVal<Kernel::SharedPtr<Kernel::ClientSession>> ServiceManager::ConnectToSer | |||
| 72 | return client_port->Connect(); | 74 | return client_port->Connect(); |
| 73 | } | 75 | } |
| 74 | 76 | ||
| 75 | std::shared_ptr<ServiceManager> g_service_manager; | 77 | SM::~SM() = default; |
| 76 | 78 | ||
| 77 | /** | 79 | /** |
| 78 | * SM::Initialize service function | 80 | * SM::Initialize service function |
diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h index 40421cfd5..13f5c4c28 100644 --- a/src/core/hle/service/sm/sm.h +++ b/src/core/hle/service/sm/sm.h | |||
| @@ -23,7 +23,7 @@ namespace Service::SM { | |||
| 23 | class SM final : public ServiceFramework<SM> { | 23 | class SM final : public ServiceFramework<SM> { |
| 24 | public: | 24 | public: |
| 25 | SM(std::shared_ptr<ServiceManager> service_manager); | 25 | SM(std::shared_ptr<ServiceManager> service_manager); |
| 26 | ~SM() = default; | 26 | ~SM() override; |
| 27 | 27 | ||
| 28 | private: | 28 | private: |
| 29 | void Initialize(Kernel::HLERequestContext& ctx); | 29 | void Initialize(Kernel::HLERequestContext& ctx); |
| @@ -44,6 +44,8 @@ class ServiceManager { | |||
| 44 | public: | 44 | public: |
| 45 | static void InstallInterfaces(std::shared_ptr<ServiceManager> self); | 45 | static void InstallInterfaces(std::shared_ptr<ServiceManager> self); |
| 46 | 46 | ||
| 47 | ~ServiceManager(); | ||
| 48 | |||
| 47 | ResultVal<Kernel::SharedPtr<Kernel::ServerPort>> RegisterService(std::string name, | 49 | ResultVal<Kernel::SharedPtr<Kernel::ServerPort>> RegisterService(std::string name, |
| 48 | unsigned int max_sessions); | 50 | unsigned int max_sessions); |
| 49 | ResultVal<Kernel::SharedPtr<Kernel::ClientPort>> GetServicePort(const std::string& name); | 51 | ResultVal<Kernel::SharedPtr<Kernel::ClientPort>> GetServicePort(const std::string& name); |
| @@ -59,6 +61,4 @@ private: | |||
| 59 | std::unordered_map<std::string, Kernel::SharedPtr<Kernel::ClientPort>> registered_services; | 61 | std::unordered_map<std::string, Kernel::SharedPtr<Kernel::ClientPort>> registered_services; |
| 60 | }; | 62 | }; |
| 61 | 63 | ||
| 62 | extern std::shared_ptr<ServiceManager> g_service_manager; | ||
| 63 | |||
| 64 | } // namespace Service::SM | 64 | } // namespace Service::SM |