diff options
| author | 2021-01-10 22:09:56 -0700 | |
|---|---|---|
| committer | 2021-01-10 22:09:56 -0700 | |
| commit | 7a3c884e39fccfbb498b855080bffabc9ce2e7f1 (patch) | |
| tree | 5056f9406dec188439cb0deb87603498243a9412 /src/core/hle/service/service.cpp | |
| parent | More forgetting... duh (diff) | |
| parent | Merge pull request #5229 from Morph1984/fullscreen-opt (diff) | |
| download | yuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.tar.gz yuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.tar.xz yuzu-7a3c884e39fccfbb498b855080bffabc9ce2e7f1.zip | |
Merge remote-tracking branch 'upstream/master' into int-flags
Diffstat (limited to 'src/core/hle/service/service.cpp')
| -rw-r--r-- | src/core/hle/service/service.cpp | 134 |
1 files changed, 77 insertions, 57 deletions
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 76b3533ec..ff2a5b1db 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp | |||
| @@ -51,6 +51,7 @@ | |||
| 51 | #include "core/hle/service/ns/ns.h" | 51 | #include "core/hle/service/ns/ns.h" |
| 52 | #include "core/hle/service/nvdrv/nvdrv.h" | 52 | #include "core/hle/service/nvdrv/nvdrv.h" |
| 53 | #include "core/hle/service/nvflinger/nvflinger.h" | 53 | #include "core/hle/service/nvflinger/nvflinger.h" |
| 54 | #include "core/hle/service/olsc/olsc.h" | ||
| 54 | #include "core/hle/service/pcie/pcie.h" | 55 | #include "core/hle/service/pcie/pcie.h" |
| 55 | #include "core/hle/service/pctl/module.h" | 56 | #include "core/hle/service/pctl/module.h" |
| 56 | #include "core/hle/service/pcv/pcv.h" | 57 | #include "core/hle/service/pcv/pcv.h" |
| @@ -72,13 +73,36 @@ | |||
| 72 | 73 | ||
| 73 | namespace Service { | 74 | namespace Service { |
| 74 | 75 | ||
| 75 | ServiceFrameworkBase::ServiceFrameworkBase(const char* service_name, u32 max_sessions, | 76 | /** |
| 76 | InvokerFn* handler_invoker) | 77 | * Creates a function string for logging, complete with the name (or header code, depending |
| 77 | : service_name(service_name), max_sessions(max_sessions), handler_invoker(handler_invoker) {} | 78 | * on what's passed in) the port name, and all the cmd_buff arguments. |
| 79 | */ | ||
| 80 | [[maybe_unused]] static std::string MakeFunctionString(std::string_view name, | ||
| 81 | std::string_view port_name, | ||
| 82 | const u32* cmd_buff) { | ||
| 83 | // Number of params == bits 0-5 + bits 6-11 | ||
| 84 | int num_params = (cmd_buff[0] & 0x3F) + ((cmd_buff[0] >> 6) & 0x3F); | ||
| 78 | 85 | ||
| 79 | ServiceFrameworkBase::~ServiceFrameworkBase() = default; | 86 | std::string function_string = fmt::format("function '{}': port={}", name, port_name); |
| 87 | for (int i = 1; i <= num_params; ++i) { | ||
| 88 | function_string += fmt::format(", cmd_buff[{}]=0x{:X}", i, cmd_buff[i]); | ||
| 89 | } | ||
| 90 | return function_string; | ||
| 91 | } | ||
| 92 | |||
| 93 | ServiceFrameworkBase::ServiceFrameworkBase(Core::System& system_, const char* service_name_, | ||
| 94 | u32 max_sessions_, InvokerFn* handler_invoker_) | ||
| 95 | : system{system_}, service_name{service_name_}, max_sessions{max_sessions_}, | ||
| 96 | handler_invoker{handler_invoker_} {} | ||
| 97 | |||
| 98 | ServiceFrameworkBase::~ServiceFrameworkBase() { | ||
| 99 | // Wait for other threads to release access before destroying | ||
| 100 | const auto guard = LockService(); | ||
| 101 | } | ||
| 80 | 102 | ||
| 81 | void ServiceFrameworkBase::InstallAsService(SM::ServiceManager& service_manager) { | 103 | void ServiceFrameworkBase::InstallAsService(SM::ServiceManager& service_manager) { |
| 104 | const auto guard = LockService(); | ||
| 105 | |||
| 82 | ASSERT(!port_installed); | 106 | ASSERT(!port_installed); |
| 83 | 107 | ||
| 84 | auto port = service_manager.RegisterService(service_name, max_sessions).Unwrap(); | 108 | auto port = service_manager.RegisterService(service_name, max_sessions).Unwrap(); |
| @@ -87,6 +111,8 @@ void ServiceFrameworkBase::InstallAsService(SM::ServiceManager& service_manager) | |||
| 87 | } | 111 | } |
| 88 | 112 | ||
| 89 | void ServiceFrameworkBase::InstallAsNamedPort(Kernel::KernelCore& kernel) { | 113 | void ServiceFrameworkBase::InstallAsNamedPort(Kernel::KernelCore& kernel) { |
| 114 | const auto guard = LockService(); | ||
| 115 | |||
| 90 | ASSERT(!port_installed); | 116 | ASSERT(!port_installed); |
| 91 | 117 | ||
| 92 | auto [server_port, client_port] = | 118 | auto [server_port, client_port] = |
| @@ -96,17 +122,6 @@ void ServiceFrameworkBase::InstallAsNamedPort(Kernel::KernelCore& kernel) { | |||
| 96 | port_installed = true; | 122 | port_installed = true; |
| 97 | } | 123 | } |
| 98 | 124 | ||
| 99 | std::shared_ptr<Kernel::ClientPort> ServiceFrameworkBase::CreatePort(Kernel::KernelCore& kernel) { | ||
| 100 | ASSERT(!port_installed); | ||
| 101 | |||
| 102 | auto [server_port, client_port] = | ||
| 103 | Kernel::ServerPort::CreatePortPair(kernel, max_sessions, service_name); | ||
| 104 | auto port = MakeResult(std::move(server_port)).Unwrap(); | ||
| 105 | port->SetHleHandler(shared_from_this()); | ||
| 106 | port_installed = true; | ||
| 107 | return client_port; | ||
| 108 | } | ||
| 109 | |||
| 110 | void ServiceFrameworkBase::RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n) { | 125 | void ServiceFrameworkBase::RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n) { |
| 111 | handlers.reserve(handlers.size() + n); | 126 | handlers.reserve(handlers.size() + n); |
| 112 | for (std::size_t i = 0; i < n; ++i) { | 127 | for (std::size_t i = 0; i < n; ++i) { |
| @@ -128,8 +143,8 @@ void ServiceFrameworkBase::ReportUnimplementedFunction(Kernel::HLERequestContext | |||
| 128 | } | 143 | } |
| 129 | buf.push_back('}'); | 144 | buf.push_back('}'); |
| 130 | 145 | ||
| 131 | Core::System::GetInstance().GetReporter().SaveUnimplementedFunctionReport( | 146 | system.GetReporter().SaveUnimplementedFunctionReport(ctx, ctx.GetCommand(), function_name, |
| 132 | ctx, ctx.GetCommand(), function_name, service_name); | 147 | service_name); |
| 133 | UNIMPLEMENTED_MSG("Unknown / unimplemented {}", fmt::to_string(buf)); | 148 | UNIMPLEMENTED_MSG("Unknown / unimplemented {}", fmt::to_string(buf)); |
| 134 | } | 149 | } |
| 135 | 150 | ||
| @@ -145,6 +160,8 @@ void ServiceFrameworkBase::InvokeRequest(Kernel::HLERequestContext& ctx) { | |||
| 145 | } | 160 | } |
| 146 | 161 | ||
| 147 | ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext& context) { | 162 | ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext& context) { |
| 163 | const auto guard = LockService(); | ||
| 164 | |||
| 148 | switch (context.GetCommandType()) { | 165 | switch (context.GetCommandType()) { |
| 149 | case IPC::CommandType::Close: { | 166 | case IPC::CommandType::Close: { |
| 150 | IPC::ResponseBuilder rb{context, 2}; | 167 | IPC::ResponseBuilder rb{context, 2}; |
| @@ -153,7 +170,7 @@ ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext& co | |||
| 153 | } | 170 | } |
| 154 | case IPC::CommandType::ControlWithContext: | 171 | case IPC::CommandType::ControlWithContext: |
| 155 | case IPC::CommandType::Control: { | 172 | case IPC::CommandType::Control: { |
| 156 | Core::System::GetInstance().ServiceManager().InvokeControlRequest(context); | 173 | system.ServiceManager().InvokeControlRequest(context); |
| 157 | break; | 174 | break; |
| 158 | } | 175 | } |
| 159 | case IPC::CommandType::RequestWithContext: | 176 | case IPC::CommandType::RequestWithContext: |
| @@ -162,79 +179,82 @@ ResultCode ServiceFrameworkBase::HandleSyncRequest(Kernel::HLERequestContext& co | |||
| 162 | break; | 179 | break; |
| 163 | } | 180 | } |
| 164 | default: | 181 | default: |
| 165 | UNIMPLEMENTED_MSG("command_type={}", static_cast<int>(context.GetCommandType())); | 182 | UNIMPLEMENTED_MSG("command_type={}", context.GetCommandType()); |
| 166 | } | 183 | } |
| 167 | 184 | ||
| 168 | context.WriteToOutgoingCommandBuffer(context.GetThread()); | 185 | // If emulation was shutdown, we are closing service threads, do not write the response back to |
| 186 | // memory that may be shutting down as well. | ||
| 187 | if (system.IsPoweredOn()) { | ||
| 188 | context.WriteToOutgoingCommandBuffer(context.GetThread()); | ||
| 189 | } | ||
| 169 | 190 | ||
| 170 | return RESULT_SUCCESS; | 191 | return RESULT_SUCCESS; |
| 171 | } | 192 | } |
| 172 | 193 | ||
| 173 | /// Initialize ServiceManager | 194 | /// Initialize Services |
| 174 | void Init(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system) { | 195 | Services::Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system) |
| 196 | : nv_flinger{std::make_unique<NVFlinger::NVFlinger>(system)} { | ||
| 197 | |||
| 175 | // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it | 198 | // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it |
| 176 | // here and pass it into the respective InstallInterfaces functions. | 199 | // here and pass it into the respective InstallInterfaces functions. |
| 177 | auto nv_flinger = std::make_shared<NVFlinger::NVFlinger>(system); | 200 | |
| 178 | system.GetFileSystemController().CreateFactories(*system.GetFilesystem(), false); | 201 | system.GetFileSystemController().CreateFactories(*system.GetFilesystem(), false); |
| 179 | 202 | ||
| 180 | SM::ServiceManager::InstallInterfaces(sm, system.Kernel()); | 203 | SM::ServiceManager::InstallInterfaces(sm, system); |
| 181 | 204 | ||
| 182 | Account::InstallInterfaces(system); | 205 | Account::InstallInterfaces(system); |
| 183 | AM::InstallInterfaces(*sm, nv_flinger, system); | 206 | AM::InstallInterfaces(*sm, *nv_flinger, system); |
| 184 | AOC::InstallInterfaces(*sm, system); | 207 | AOC::InstallInterfaces(*sm, system); |
| 185 | APM::InstallInterfaces(system); | 208 | APM::InstallInterfaces(system); |
| 186 | Audio::InstallInterfaces(*sm, system); | 209 | Audio::InstallInterfaces(*sm, system); |
| 187 | BCAT::InstallInterfaces(system); | 210 | BCAT::InstallInterfaces(system); |
| 188 | BPC::InstallInterfaces(*sm); | 211 | BPC::InstallInterfaces(*sm, system); |
| 189 | BtDrv::InstallInterfaces(*sm, system); | 212 | BtDrv::InstallInterfaces(*sm, system); |
| 190 | BTM::InstallInterfaces(*sm, system); | 213 | BTM::InstallInterfaces(*sm, system); |
| 191 | Capture::InstallInterfaces(*sm); | 214 | Capture::InstallInterfaces(*sm, system); |
| 192 | ERPT::InstallInterfaces(*sm); | 215 | ERPT::InstallInterfaces(*sm, system); |
| 193 | ES::InstallInterfaces(*sm); | 216 | ES::InstallInterfaces(*sm, system); |
| 194 | EUPLD::InstallInterfaces(*sm); | 217 | EUPLD::InstallInterfaces(*sm, system); |
| 195 | Fatal::InstallInterfaces(*sm, system); | 218 | Fatal::InstallInterfaces(*sm, system); |
| 196 | FGM::InstallInterfaces(*sm); | 219 | FGM::InstallInterfaces(*sm, system); |
| 197 | FileSystem::InstallInterfaces(system); | 220 | FileSystem::InstallInterfaces(system); |
| 198 | Friend::InstallInterfaces(*sm, system); | 221 | Friend::InstallInterfaces(*sm, system); |
| 199 | Glue::InstallInterfaces(system); | 222 | Glue::InstallInterfaces(system); |
| 200 | GRC::InstallInterfaces(*sm); | 223 | GRC::InstallInterfaces(*sm, system); |
| 201 | HID::InstallInterfaces(*sm, system); | 224 | HID::InstallInterfaces(*sm, system); |
| 202 | LBL::InstallInterfaces(*sm); | 225 | LBL::InstallInterfaces(*sm, system); |
| 203 | LDN::InstallInterfaces(*sm); | 226 | LDN::InstallInterfaces(*sm, system); |
| 204 | LDR::InstallInterfaces(*sm, system); | 227 | LDR::InstallInterfaces(*sm, system); |
| 205 | LM::InstallInterfaces(system); | 228 | LM::InstallInterfaces(system); |
| 206 | Migration::InstallInterfaces(*sm); | 229 | Migration::InstallInterfaces(*sm, system); |
| 207 | Mii::InstallInterfaces(*sm); | 230 | Mii::InstallInterfaces(*sm, system); |
| 208 | MM::InstallInterfaces(*sm); | 231 | MM::InstallInterfaces(*sm, system); |
| 209 | NCM::InstallInterfaces(*sm); | 232 | NCM::InstallInterfaces(*sm, system); |
| 210 | NFC::InstallInterfaces(*sm); | 233 | NFC::InstallInterfaces(*sm, system); |
| 211 | NFP::InstallInterfaces(*sm, system); | 234 | NFP::InstallInterfaces(*sm, system); |
| 212 | NIFM::InstallInterfaces(*sm, system); | 235 | NIFM::InstallInterfaces(*sm, system); |
| 213 | NIM::InstallInterfaces(*sm, system); | 236 | NIM::InstallInterfaces(*sm, system); |
| 214 | NPNS::InstallInterfaces(*sm); | 237 | NPNS::InstallInterfaces(*sm, system); |
| 215 | NS::InstallInterfaces(*sm, system); | 238 | NS::InstallInterfaces(*sm, system); |
| 216 | Nvidia::InstallInterfaces(*sm, *nv_flinger, system); | 239 | Nvidia::InstallInterfaces(*sm, *nv_flinger, system); |
| 217 | PCIe::InstallInterfaces(*sm); | 240 | OLSC::InstallInterfaces(*sm, system); |
| 218 | PCTL::InstallInterfaces(*sm); | 241 | PCIe::InstallInterfaces(*sm, system); |
| 219 | PCV::InstallInterfaces(*sm); | 242 | PCTL::InstallInterfaces(*sm, system); |
| 243 | PCV::InstallInterfaces(*sm, system); | ||
| 220 | PlayReport::InstallInterfaces(*sm, system); | 244 | PlayReport::InstallInterfaces(*sm, system); |
| 221 | PM::InstallInterfaces(system); | 245 | PM::InstallInterfaces(system); |
| 222 | PSC::InstallInterfaces(*sm); | 246 | PSC::InstallInterfaces(*sm, system); |
| 223 | PSM::InstallInterfaces(*sm); | 247 | PSM::InstallInterfaces(*sm, system); |
| 224 | Set::InstallInterfaces(*sm); | 248 | Set::InstallInterfaces(*sm, system); |
| 225 | Sockets::InstallInterfaces(*sm, system); | 249 | Sockets::InstallInterfaces(*sm, system); |
| 226 | SPL::InstallInterfaces(*sm); | 250 | SPL::InstallInterfaces(*sm, system); |
| 227 | SSL::InstallInterfaces(*sm); | 251 | SSL::InstallInterfaces(*sm, system); |
| 228 | Time::InstallInterfaces(system); | 252 | Time::InstallInterfaces(system); |
| 229 | USB::InstallInterfaces(*sm); | 253 | USB::InstallInterfaces(*sm, system); |
| 230 | VI::InstallInterfaces(*sm, nv_flinger); | 254 | VI::InstallInterfaces(*sm, system, *nv_flinger); |
| 231 | WLAN::InstallInterfaces(*sm); | 255 | WLAN::InstallInterfaces(*sm, system); |
| 232 | |||
| 233 | LOG_DEBUG(Service, "initialized OK"); | ||
| 234 | } | 256 | } |
| 235 | 257 | ||
| 236 | /// Shutdown ServiceManager | 258 | Services::~Services() = default; |
| 237 | void Shutdown() { | 259 | |
| 238 | LOG_DEBUG(Service, "shutdown OK"); | ||
| 239 | } | ||
| 240 | } // namespace Service | 260 | } // namespace Service |