diff options
Diffstat (limited to 'src/core/hle/service/service.cpp')
| -rw-r--r-- | src/core/hle/service/service.cpp | 151 |
1 files changed, 61 insertions, 90 deletions
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 1ffc1c694..31021ea03 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp | |||
| @@ -90,44 +90,13 @@ namespace Service { | |||
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | ServiceFrameworkBase::ServiceFrameworkBase(Core::System& system_, const char* service_name_, | 92 | ServiceFrameworkBase::ServiceFrameworkBase(Core::System& system_, const char* service_name_, |
| 93 | ServiceThreadType thread_type, u32 max_sessions_, | 93 | u32 max_sessions_, InvokerFn* handler_invoker_) |
| 94 | InvokerFn* handler_invoker_) | 94 | : SessionRequestHandler(system_.Kernel(), service_name_), system{system_}, |
| 95 | : SessionRequestHandler(system_.Kernel(), service_name_, thread_type), system{system_}, | ||
| 96 | service_name{service_name_}, max_sessions{max_sessions_}, handler_invoker{handler_invoker_} {} | 95 | service_name{service_name_}, max_sessions{max_sessions_}, handler_invoker{handler_invoker_} {} |
| 97 | 96 | ||
| 98 | ServiceFrameworkBase::~ServiceFrameworkBase() { | 97 | ServiceFrameworkBase::~ServiceFrameworkBase() { |
| 99 | // Wait for other threads to release access before destroying | 98 | // Wait for other threads to release access before destroying |
| 100 | const auto guard = LockService(); | 99 | const auto guard = LockService(); |
| 101 | |||
| 102 | if (named_port != nullptr) { | ||
| 103 | named_port->GetClientPort().Close(); | ||
| 104 | named_port->GetServerPort().Close(); | ||
| 105 | named_port = nullptr; | ||
| 106 | } | ||
| 107 | } | ||
| 108 | |||
| 109 | void ServiceFrameworkBase::InstallAsService(SM::ServiceManager& service_manager) { | ||
| 110 | const auto guard = LockService(); | ||
| 111 | |||
| 112 | ASSERT(!service_registered); | ||
| 113 | |||
| 114 | service_manager.RegisterService(service_name, max_sessions, shared_from_this()); | ||
| 115 | service_registered = true; | ||
| 116 | } | ||
| 117 | |||
| 118 | Kernel::KClientPort& ServiceFrameworkBase::CreatePort() { | ||
| 119 | const auto guard = LockService(); | ||
| 120 | |||
| 121 | if (named_port == nullptr) { | ||
| 122 | ASSERT(!service_registered); | ||
| 123 | |||
| 124 | named_port = Kernel::KPort::Create(kernel); | ||
| 125 | named_port->Initialize(max_sessions, false, service_name); | ||
| 126 | |||
| 127 | service_registered = true; | ||
| 128 | } | ||
| 129 | |||
| 130 | return named_port->GetClientPort(); | ||
| 131 | } | 100 | } |
| 132 | 101 | ||
| 133 | void ServiceFrameworkBase::RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n) { | 102 | void ServiceFrameworkBase::RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n) { |
| @@ -244,67 +213,69 @@ Services::Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system | |||
| 244 | : hos_binder_driver_server{std::make_unique<NVFlinger::HosBinderDriverServer>(system)}, | 213 | : hos_binder_driver_server{std::make_unique<NVFlinger::HosBinderDriverServer>(system)}, |
| 245 | nv_flinger{std::make_unique<NVFlinger::NVFlinger>(system, *hos_binder_driver_server)} { | 214 | nv_flinger{std::make_unique<NVFlinger::NVFlinger>(system, *hos_binder_driver_server)} { |
| 246 | 215 | ||
| 216 | auto& kernel = system.Kernel(); | ||
| 217 | |||
| 247 | // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it | 218 | // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it |
| 248 | // here and pass it into the respective InstallInterfaces functions. | 219 | // here and pass it into the respective InstallInterfaces functions. |
| 249 | |||
| 250 | system.GetFileSystemController().CreateFactories(*system.GetFilesystem(), false); | 220 | system.GetFileSystemController().CreateFactories(*system.GetFilesystem(), false); |
| 251 | 221 | ||
| 252 | system.Kernel().RegisterNamedService("sm:", SM::ServiceManager::InterfaceFactory); | 222 | // clang-format off |
| 253 | system.Kernel().RegisterInterfaceForNamedService("sm:", SM::ServiceManager::SessionHandler); | 223 | kernel.RunOnHostCoreProcess("audio", [&] { Audio::LoopProcess(system); }).detach(); |
| 254 | 224 | kernel.RunOnHostCoreProcess("FS", [&] { FileSystem::LoopProcess(system); }).detach(); | |
| 255 | Account::InstallInterfaces(system); | 225 | kernel.RunOnHostCoreProcess("jit", [&] { JIT::LoopProcess(system); }).detach(); |
| 256 | AM::InstallInterfaces(*sm, *nv_flinger, system); | 226 | kernel.RunOnHostCoreProcess("ldn", [&] { LDN::LoopProcess(system); }).detach(); |
| 257 | AOC::InstallInterfaces(*sm, system); | 227 | kernel.RunOnHostCoreProcess("Loader", [&] { LDR::LoopProcess(system); }).detach(); |
| 258 | APM::InstallInterfaces(system); | 228 | kernel.RunOnHostCoreProcess("nvservices", [&] { Nvidia::LoopProcess(*nv_flinger, system); }).detach(); |
| 259 | Audio::InstallInterfaces(*sm, system); | 229 | kernel.RunOnHostCoreProcess("bsdsocket", [&] { Sockets::LoopProcess(system); }).detach(); |
| 260 | BCAT::InstallInterfaces(system); | 230 | kernel.RunOnHostCoreProcess("vi", [&] { VI::LoopProcess(system, *nv_flinger, *hos_binder_driver_server); }).detach(); |
| 261 | BPC::InstallInterfaces(*sm, system); | 231 | |
| 262 | BtDrv::InstallInterfaces(*sm, system); | 232 | kernel.RunOnGuestCoreProcess("sm", [&] { SM::LoopProcess(system); }); |
| 263 | BTM::InstallInterfaces(*sm, system); | 233 | kernel.RunOnGuestCoreProcess("account", [&] { Account::LoopProcess(system); }); |
| 264 | Capture::InstallInterfaces(*sm, system); | 234 | kernel.RunOnGuestCoreProcess("am", [&] { AM::LoopProcess(*nv_flinger, system); }); |
| 265 | ERPT::InstallInterfaces(*sm, system); | 235 | kernel.RunOnGuestCoreProcess("aoc", [&] { AOC::LoopProcess(system); }); |
| 266 | ES::InstallInterfaces(*sm, system); | 236 | kernel.RunOnGuestCoreProcess("apm", [&] { APM::LoopProcess(system); }); |
| 267 | EUPLD::InstallInterfaces(*sm, system); | 237 | kernel.RunOnGuestCoreProcess("bcat", [&] { BCAT::LoopProcess(system); }); |
| 268 | Fatal::InstallInterfaces(*sm, system); | 238 | kernel.RunOnGuestCoreProcess("bpc", [&] { BPC::LoopProcess(system); }); |
| 269 | FGM::InstallInterfaces(*sm, system); | 239 | kernel.RunOnGuestCoreProcess("btdrv", [&] { BtDrv::LoopProcess(system); }); |
| 270 | FileSystem::InstallInterfaces(system); | 240 | kernel.RunOnGuestCoreProcess("btm", [&] { BTM::LoopProcess(system); }); |
| 271 | Friend::InstallInterfaces(*sm, system); | 241 | kernel.RunOnGuestCoreProcess("capsrv", [&] { Capture::LoopProcess(system); }); |
| 272 | Glue::InstallInterfaces(system); | 242 | kernel.RunOnGuestCoreProcess("erpt", [&] { ERPT::LoopProcess(system); }); |
| 273 | GRC::InstallInterfaces(*sm, system); | 243 | kernel.RunOnGuestCoreProcess("es", [&] { ES::LoopProcess(system); }); |
| 274 | HID::InstallInterfaces(*sm, system); | 244 | kernel.RunOnGuestCoreProcess("eupld", [&] { EUPLD::LoopProcess(system); }); |
| 275 | JIT::InstallInterfaces(*sm, system); | 245 | kernel.RunOnGuestCoreProcess("fatal", [&] { Fatal::LoopProcess(system); }); |
| 276 | LBL::InstallInterfaces(*sm, system); | 246 | kernel.RunOnGuestCoreProcess("fgm", [&] { FGM::LoopProcess(system); }); |
| 277 | LDN::InstallInterfaces(*sm, system); | 247 | kernel.RunOnGuestCoreProcess("friends", [&] { Friend::LoopProcess(system); }); |
| 278 | LDR::InstallInterfaces(*sm, system); | 248 | kernel.RunOnGuestCoreProcess("glue", [&] { Glue::LoopProcess(system); }); |
| 279 | LM::InstallInterfaces(system); | 249 | kernel.RunOnGuestCoreProcess("grc", [&] { GRC::LoopProcess(system); }); |
| 280 | Migration::InstallInterfaces(*sm, system); | 250 | kernel.RunOnGuestCoreProcess("hid", [&] { HID::LoopProcess(system); }); |
| 281 | Mii::InstallInterfaces(*sm, system); | 251 | kernel.RunOnGuestCoreProcess("lbl", [&] { LBL::LoopProcess(system); }); |
| 282 | MM::InstallInterfaces(*sm, system); | 252 | kernel.RunOnGuestCoreProcess("LogManager.Prod", [&] { LM::LoopProcess(system); }); |
| 283 | MNPP::InstallInterfaces(*sm, system); | 253 | kernel.RunOnGuestCoreProcess("mig", [&] { Migration::LoopProcess(system); }); |
| 284 | NCM::InstallInterfaces(*sm, system); | 254 | kernel.RunOnGuestCoreProcess("mii", [&] { Mii::LoopProcess(system); }); |
| 285 | NFC::InstallInterfaces(*sm, system); | 255 | kernel.RunOnGuestCoreProcess("mm", [&] { MM::LoopProcess(system); }); |
| 286 | NFP::InstallInterfaces(*sm, system); | 256 | kernel.RunOnGuestCoreProcess("mnpp", [&] { MNPP::LoopProcess(system); }); |
| 287 | NGCT::InstallInterfaces(*sm, system); | 257 | kernel.RunOnGuestCoreProcess("NCM", [&] { NCM::LoopProcess(system); }); |
| 288 | NIFM::InstallInterfaces(*sm, system); | 258 | kernel.RunOnGuestCoreProcess("nfc", [&] { NFC::LoopProcess(system); }); |
| 289 | NIM::InstallInterfaces(*sm, system); | 259 | kernel.RunOnGuestCoreProcess("nfp", [&] { NFP::LoopProcess(system); }); |
| 290 | NPNS::InstallInterfaces(*sm, system); | 260 | kernel.RunOnGuestCoreProcess("ngct", [&] { NGCT::LoopProcess(system); }); |
| 291 | NS::InstallInterfaces(*sm, system); | 261 | kernel.RunOnGuestCoreProcess("nifm", [&] { NIFM::LoopProcess(system); }); |
| 292 | Nvidia::InstallInterfaces(*sm, *nv_flinger, system); | 262 | kernel.RunOnGuestCoreProcess("nim", [&] { NIM::LoopProcess(system); }); |
| 293 | OLSC::InstallInterfaces(*sm, system); | 263 | kernel.RunOnGuestCoreProcess("npns", [&] { NPNS::LoopProcess(system); }); |
| 294 | PCIe::InstallInterfaces(*sm, system); | 264 | kernel.RunOnGuestCoreProcess("ns", [&] { NS::LoopProcess(system); }); |
| 295 | PCTL::InstallInterfaces(*sm, system); | 265 | kernel.RunOnGuestCoreProcess("olsc", [&] { OLSC::LoopProcess(system); }); |
| 296 | PCV::InstallInterfaces(*sm, system); | 266 | kernel.RunOnGuestCoreProcess("pcie", [&] { PCIe::LoopProcess(system); }); |
| 297 | PlayReport::InstallInterfaces(*sm, system); | 267 | kernel.RunOnGuestCoreProcess("pctl", [&] { PCTL::LoopProcess(system); }); |
| 298 | PM::InstallInterfaces(system); | 268 | kernel.RunOnGuestCoreProcess("pcv", [&] { PCV::LoopProcess(system); }); |
| 299 | PSC::InstallInterfaces(*sm, system); | 269 | kernel.RunOnGuestCoreProcess("prepo", [&] { PlayReport::LoopProcess(system); }); |
| 300 | PTM::InstallInterfaces(*sm, system); | 270 | kernel.RunOnGuestCoreProcess("ProcessManager", [&] { PM::LoopProcess(system); }); |
| 301 | Set::InstallInterfaces(*sm, system); | 271 | kernel.RunOnGuestCoreProcess("psc", [&] { PSC::LoopProcess(system); }); |
| 302 | Sockets::InstallInterfaces(*sm, system); | 272 | kernel.RunOnGuestCoreProcess("ptm", [&] { PTM::LoopProcess(system); }); |
| 303 | SPL::InstallInterfaces(*sm, system); | 273 | kernel.RunOnGuestCoreProcess("settings", [&] { Set::LoopProcess(system); }); |
| 304 | SSL::InstallInterfaces(*sm, system); | 274 | kernel.RunOnGuestCoreProcess("spl", [&] { SPL::LoopProcess(system); }); |
| 305 | Time::InstallInterfaces(system); | 275 | kernel.RunOnGuestCoreProcess("ssl", [&] { SSL::LoopProcess(system); }); |
| 306 | USB::InstallInterfaces(*sm, system); | 276 | kernel.RunOnGuestCoreProcess("time", [&] { Time::LoopProcess(system); }); |
| 307 | VI::InstallInterfaces(*sm, system, *nv_flinger, *hos_binder_driver_server); | 277 | kernel.RunOnGuestCoreProcess("usb", [&] { USB::LoopProcess(system); }); |
| 278 | // clang-format on | ||
| 308 | } | 279 | } |
| 309 | 280 | ||
| 310 | Services::~Services() = default; | 281 | Services::~Services() = default; |