citra-emu
/
citra-canary
Archived
1
0
Fork 0

service/sm: Add service name retrival based on client port ID

This is for displaying the service names. This function is only used in the frontend, because Recorder which is in the Kernel cannot and should not have access to SM in the System.
This commit is contained in:
zhupengfei 2019-07-22 20:27:35 +08:00
parent efd69e1315
commit f40232adc9
No known key found for this signature in database
GPG Key ID: DD129E108BD09378
2 changed files with 15 additions and 0 deletions

View File

@ -42,6 +42,7 @@ ResultVal<std::shared_ptr<Kernel::ServerPort>> ServiceManager::RegisterService(
auto [server_port, client_port] = system.Kernel().CreatePortPair(max_sessions, name); auto [server_port, client_port] = system.Kernel().CreatePortPair(max_sessions, name);
registered_services_inverse.emplace(client_port->GetObjectId(), name);
registered_services.emplace(std::move(name), std::move(client_port)); registered_services.emplace(std::move(name), std::move(client_port));
return MakeResult(std::move(server_port)); return MakeResult(std::move(server_port));
} }
@ -65,4 +66,12 @@ ResultVal<std::shared_ptr<Kernel::ClientSession>> ServiceManager::ConnectToServi
return client_port->Connect(); return client_port->Connect();
} }
std::string ServiceManager::GetServiceNameByPortId(u32 port) const {
if (registered_services_inverse.count(port)) {
return registered_services_inverse.at(port);
}
return "";
}
} // namespace Service::SM } // namespace Service::SM

View File

@ -51,6 +51,8 @@ public:
unsigned int max_sessions); unsigned int max_sessions);
ResultVal<std::shared_ptr<Kernel::ClientPort>> GetServicePort(const std::string& name); ResultVal<std::shared_ptr<Kernel::ClientPort>> GetServicePort(const std::string& name);
ResultVal<std::shared_ptr<Kernel::ClientSession>> ConnectToService(const std::string& name); ResultVal<std::shared_ptr<Kernel::ClientSession>> ConnectToService(const std::string& name);
// For IPC Recorder
std::string GetServiceNameByPortId(u32 port) const;
template <typename T> template <typename T>
std::shared_ptr<T> GetService(const std::string& service_name) const { std::shared_ptr<T> GetService(const std::string& service_name) const {
@ -74,6 +76,10 @@ private:
/// Map of registered services, retrieved using GetServicePort or ConnectToService. /// Map of registered services, retrieved using GetServicePort or ConnectToService.
std::unordered_map<std::string, std::shared_ptr<Kernel::ClientPort>> registered_services; std::unordered_map<std::string, std::shared_ptr<Kernel::ClientPort>> registered_services;
// For IPC Recorder
/// client port Object id -> service name
std::unordered_map<u32, std::string> registered_services_inverse;
}; };
} // namespace Service::SM } // namespace Service::SM