diff options
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/service/hle_ipc.h (renamed from src/core/hle/kernel/hle_ipc.h) | 124 |
1 files changed, 58 insertions, 66 deletions
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/service/hle_ipc.h index 5bf4f171b..4bd24c899 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/service/hle_ipc.h @@ -31,31 +31,22 @@ class ResponseBuilder; namespace Service { class ServiceFrameworkBase; -} - -enum class ServiceThreadType { - Default, - CreateNew, -}; +class ServerManager; +} // namespace Service namespace Kernel { - -class Domain; -class HLERequestContext; class KAutoObject; class KernelCore; -class KEvent; class KHandleTable; -class KServerPort; -class KProcess; class KServerSession; class KThread; -class KReadableEvent; -class KSession; -class SessionRequestManager; -class ServiceThread; +} // namespace Kernel -enum class ThreadWakeupReason; +namespace Service { + +using Handle = Kernel::Handle; + +class HLERequestContext; /** * Interface implemented by HLE Session handlers. @@ -64,8 +55,7 @@ enum class ThreadWakeupReason; */ class SessionRequestHandler : public std::enable_shared_from_this<SessionRequestHandler> { public: - SessionRequestHandler(KernelCore& kernel_, const char* service_name_, - ServiceThreadType thread_type); + SessionRequestHandler(Kernel::KernelCore& kernel_, const char* service_name_); virtual ~SessionRequestHandler(); /** @@ -77,19 +67,10 @@ public: * @returns Result the result code of the translate operation. */ virtual Result HandleSyncRequest(Kernel::KServerSession& session, - Kernel::HLERequestContext& context) = 0; - - void AcceptSession(KServerPort* server_port); - void RegisterSession(KServerSession* server_session, - std::shared_ptr<SessionRequestManager> manager); - - ServiceThread& GetServiceThread() const { - return service_thread; - } + HLERequestContext& context) = 0; protected: - KernelCore& kernel; - ServiceThread& service_thread; + Kernel::KernelCore& kernel; }; using SessionRequestHandlerWeakPtr = std::weak_ptr<SessionRequestHandler>; @@ -102,7 +83,8 @@ using SessionRequestHandlerPtr = std::shared_ptr<SessionRequestHandler>; */ class SessionRequestManager final { public: - explicit SessionRequestManager(KernelCore& kernel); + explicit SessionRequestManager(Kernel::KernelCore& kernel, + Service::ServerManager& server_manager); ~SessionRequestManager(); bool IsDomain() const { @@ -155,48 +137,47 @@ public: session_handler = std::move(handler); } - ServiceThread& GetServiceThread() const { - return session_handler->GetServiceThread(); + bool HasSessionRequestHandler(const HLERequestContext& context) const; + + Result HandleDomainSyncRequest(Kernel::KServerSession* server_session, + HLERequestContext& context); + Result CompleteSyncRequest(Kernel::KServerSession* server_session, HLERequestContext& context); + + Service::ServerManager& GetServerManager() { + return server_manager; } - bool HasSessionRequestHandler(const HLERequestContext& context) const; + // TODO: remove this when sm: is implemented with the proper IUserInterface + // abstraction, creating a new C++ handler object for each session: + + bool GetIsInitializedForSm() const { + return is_initialized_for_sm; + } - Result HandleDomainSyncRequest(KServerSession* server_session, HLERequestContext& context); - Result CompleteSyncRequest(KServerSession* server_session, HLERequestContext& context); + void SetIsInitializedForSm() { + is_initialized_for_sm = true; + } private: bool convert_to_domain{}; bool is_domain{}; + bool is_initialized_for_sm{}; SessionRequestHandlerPtr session_handler; std::vector<SessionRequestHandlerPtr> domain_handlers; private: - KernelCore& kernel; + Kernel::KernelCore& kernel; + Service::ServerManager& server_manager; }; /** * Class containing information about an in-flight IPC request being handled by an HLE service - * implementation. Services should avoid using old global APIs (e.g. Kernel::GetCommandBuffer()) and - * when possible use the APIs in this class to service the request. - * - * HLE handle protocol - * =================== - * - * To avoid needing HLE services to keep a separate handle table, or having to directly modify the - * requester's table, a tweaked protocol is used to receive and send handles in requests. The kernel - * will decode the incoming handles into object pointers and insert a id in the buffer where the - * handle would normally be. The service then calls GetIncomingHandle() with that id to get the - * pointer to the object. Similarly, instead of inserting a handle into the command buffer, the - * service calls AddOutgoingHandle() and stores the returned id where the handle would normally go. - * - * The end result is similar to just giving services their own real handle tables, but since these - * ids are local to a specific context, it avoids requiring services to manage handles for objects - * across multiple calls and ensuring that unneeded handles are cleaned up. + * implementation. */ class HLERequestContext { public: - explicit HLERequestContext(KernelCore& kernel, Core::Memory::Memory& memory, - KServerSession* session, KThread* thread); + explicit HLERequestContext(Kernel::KernelCore& kernel, Core::Memory::Memory& memory, + Kernel::KServerSession* session, Kernel::KThread* thread); ~HLERequestContext(); /// Returns a pointer to the IPC command buffer for this request. @@ -213,10 +194,11 @@ public: } /// Populates this context with data from the requesting process/thread. - Result PopulateFromIncomingCommandBuffer(const KHandleTable& handle_table, u32_le* src_cmdbuf); + Result PopulateFromIncomingCommandBuffer(const Kernel::KHandleTable& handle_table, + u32_le* src_cmdbuf); /// Writes data from this context back to the requesting process/thread. - Result WriteToOutgoingCommandBuffer(KThread& requesting_thread); + Result WriteToOutgoingCommandBuffer(Kernel::KThread& requesting_thread); [[nodiscard]] u32_le GetHipcCommand() const { return command; @@ -343,11 +325,11 @@ public: return incoming_move_handles.at(index); } - void AddMoveObject(KAutoObject* object) { + void AddMoveObject(Kernel::KAutoObject* object) { outgoing_move_objects.emplace_back(object); } - void AddCopyObject(KAutoObject* object) { + void AddCopyObject(Kernel::KAutoObject* object) { outgoing_copy_objects.emplace_back(object); } @@ -366,7 +348,7 @@ public: [[nodiscard]] std::string Description() const; - [[nodiscard]] KThread& GetThread() { + [[nodiscard]] Kernel::KThread& GetThread() { return *thread; } @@ -374,20 +356,29 @@ public: return manager.lock(); } + bool GetIsDeferred() const { + return is_deferred; + } + + void SetIsDeferred(bool is_deferred_ = true) { + is_deferred = is_deferred_; + } + private: friend class IPC::ResponseBuilder; - void ParseCommandBuffer(const KHandleTable& handle_table, u32_le* src_cmdbuf, bool incoming); + void ParseCommandBuffer(const Kernel::KHandleTable& handle_table, u32_le* src_cmdbuf, + bool incoming); std::array<u32, IPC::COMMAND_BUFFER_LENGTH> cmd_buf; Kernel::KServerSession* server_session{}; - KThread* thread; + Kernel::KThread* thread; std::vector<Handle> incoming_move_handles; std::vector<Handle> incoming_copy_handles; - std::vector<KAutoObject*> outgoing_move_objects; - std::vector<KAutoObject*> outgoing_copy_objects; + std::vector<Kernel::KAutoObject*> outgoing_move_objects; + std::vector<Kernel::KAutoObject*> outgoing_copy_objects; std::vector<SessionRequestHandlerPtr> outgoing_domain_objects; std::optional<IPC::CommandHeader> command_header; @@ -408,9 +399,10 @@ private: u32 domain_offset{}; std::weak_ptr<SessionRequestManager> manager{}; + bool is_deferred{false}; - KernelCore& kernel; + Kernel::KernelCore& kernel; Core::Memory::Memory& memory; }; -} // namespace Kernel +} // namespace Service |