diff options
Diffstat (limited to 'src/core/hle/service')
-rw-r--r-- | src/core/hle/service/service.cpp | 14 | ||||
-rw-r--r-- | src/core/hle/service/service.h | 14 | ||||
-rw-r--r-- | src/core/hle/service/srv.cpp | 14 |
3 files changed, 21 insertions, 21 deletions
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index c90802455..3462af8ce 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -44,8 +44,8 @@ namespace Service { -std::unordered_map<std::string, std::tuple<Kernel::SharedPtr<Kernel::ClientPort>, std::shared_ptr<Interface>>> g_kernel_named_ports; -std::unordered_map<std::string, std::tuple<Kernel::SharedPtr<Kernel::ClientPort>, std::shared_ptr<Interface>>> g_srv_services; +std::unordered_map<std::string, Kernel::SharedPtr<Kernel::ClientPort>> g_kernel_named_ports; +std::unordered_map<std::string, Kernel::SharedPtr<Kernel::ClientPort>> g_srv_services; /** * Creates a function string for logging, complete with the name (or header code, depending @@ -102,15 +102,17 @@ void Interface::Register(const FunctionInfo* functions, size_t n) { // Module interface static void AddNamedPort(Interface* interface_) { - auto ports = Kernel::ServerPort::CreatePortPair(interface_->GetMaxSessions(), interface_->GetPortName()); + auto ports = Kernel::ServerPort::CreatePortPair(interface_->GetMaxSessions(), interface_->GetPortName(), + std::shared_ptr<Interface>(interface_)); auto client_port = std::get<Kernel::SharedPtr<Kernel::ClientPort>>(ports); - g_kernel_named_ports.emplace(interface_->GetPortName(), std::make_tuple(client_port, std::shared_ptr<Interface>(interface_))); + g_kernel_named_ports.emplace(interface_->GetPortName(), client_port); } void AddService(Interface* interface_) { - auto ports = Kernel::ServerPort::CreatePortPair(interface_->GetMaxSessions(), interface_->GetPortName()); + auto ports = Kernel::ServerPort::CreatePortPair(interface_->GetMaxSessions(), interface_->GetPortName(), + std::shared_ptr<Interface>(interface_)); auto client_port = std::get<Kernel::SharedPtr<Kernel::ClientPort>>(ports); - g_srv_services.emplace(interface_->GetPortName(), std::make_tuple(client_port, std::shared_ptr<Interface>(interface_))); + g_srv_services.emplace(interface_->GetPortName(), client_port); } /// Initialize ServiceManager diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 931512339..e85882713 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -176,7 +176,11 @@ namespace Service { static const int kMaxPortSize = 8; ///< Maximum size of a port name (8 characters) static const u32 DefaultMaxSessions = 10; ///< Arbitrary default number of maximum connections to an HLE port -/// TODO(Subv): Write documentation for this class +/** + * Interface implemented by HLE Session handlers. + * This can be provided to a ServerSession in order to hook into several relevant events (such as a new connection or a SyncRequest) + * so they can be implemented in the emulator. + */ class SessionRequestHandler { public: /** @@ -190,7 +194,9 @@ public: virtual ResultCode HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) = 0; }; -/// Interface to a CTROS service +/** + * Framework for implementing HLE service handlers which dispatch incoming SyncRequests based on a table mapping header ids to handler functions. + */ class Interface : public SessionRequestHandler { public: std::string GetName() const { @@ -257,9 +263,9 @@ void Init(); void Shutdown(); /// Map of named ports managed by the kernel, which can be retrieved using the ConnectToPort SVC. -extern std::unordered_map<std::string, std::tuple<Kernel::SharedPtr<Kernel::ClientPort>, std::shared_ptr<Interface>>> g_kernel_named_ports; +extern std::unordered_map<std::string, Kernel::SharedPtr<Kernel::ClientPort>> g_kernel_named_ports; /// Map of services registered with the "srv:" service, retrieved using GetServiceHandle. -extern std::unordered_map<std::string, std::tuple<Kernel::SharedPtr<Kernel::ClientPort>, std::shared_ptr<Interface>>> g_srv_services; +extern std::unordered_map<std::string, Kernel::SharedPtr<Kernel::ClientPort>> g_srv_services; /// Adds a service to the services table void AddService(Interface* interface_); diff --git a/src/core/hle/service/srv.cpp b/src/core/hle/service/srv.cpp index c0abfd711..bb2c8fcc4 100644 --- a/src/core/hle/service/srv.cpp +++ b/src/core/hle/service/srv.cpp @@ -85,21 +85,13 @@ static void GetServiceHandle(Service::Interface* self) { auto it = Service::g_srv_services.find(port_name); if (it != Service::g_srv_services.end()) { - auto client_port = std::get<Kernel::SharedPtr<Kernel::ClientPort>>(it->second); - // The hle_handler will be nullptr if this port was registered by the emulated - // application by means of srv:RegisterService. - auto hle_handler = std::get<std::shared_ptr<Service::Interface>>(it->second); - - // Create a new session pair - auto sessions = Kernel::ServerSession::CreateSessionPair(port_name, hle_handler); - auto client_session = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions); - auto server_session = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions); + auto client_port = it->second; // Note: Threads do not wait for the server endpoint to call // AcceptSession before returning from this call. - // Add the server session to the port's queue - client_port->AddWaitingSession(server_session); + // Connect to the port and retrieve the client endpoint of the connection Session. + auto client_session = client_port->Connect(); // Return the client session cmd_buff[3] = Kernel::g_handle_table.Create(client_session).MoveFrom(); |