|
|
|
@ -8,8 +8,7 @@ |
|
|
|
|
|
|
|
#include <cstddef> |
|
|
|
#include <mutex> |
|
|
|
#include <string> |
|
|
|
#include <boost/container/flat_map.hpp> |
|
|
|
#include <ankerl/unordered_dense.h> |
|
|
|
#include "common/common_types.h" |
|
|
|
#include "core/hle/service/hle_ipc.h" |
|
|
|
|
|
|
|
@ -78,13 +77,6 @@ protected: |
|
|
|
[[nodiscard]] virtual std::unique_lock<std::mutex> LockService() noexcept { |
|
|
|
return std::unique_lock{lock_service}; |
|
|
|
} |
|
|
|
|
|
|
|
/// System context that the service operates under. |
|
|
|
Core::System& system; |
|
|
|
|
|
|
|
/// Identifier string used to connect to the service. |
|
|
|
std::string service_name; |
|
|
|
|
|
|
|
private: |
|
|
|
template <typename T> |
|
|
|
friend class ServiceFramework; |
|
|
|
@ -106,16 +98,19 @@ private: |
|
|
|
void RegisterHandlersBaseTipc(const FunctionInfoBase* functions, std::size_t n); |
|
|
|
void ReportUnimplementedFunction(HLERequestContext& ctx, const FunctionInfoBase* info); |
|
|
|
|
|
|
|
boost::container::flat_map<u32, FunctionInfoBase> handlers; |
|
|
|
boost::container::flat_map<u32, FunctionInfoBase> handlers_tipc; |
|
|
|
protected: |
|
|
|
ankerl::unordered_dense::map<u32, FunctionInfoBase> handlers; |
|
|
|
ankerl::unordered_dense::map<u32, FunctionInfoBase> handlers_tipc; |
|
|
|
/// Used to gain exclusive access to the service members, e.g. from CoreTiming thread. |
|
|
|
std::mutex lock_service; |
|
|
|
/// System context that the service operates under. |
|
|
|
Core::System& system; |
|
|
|
/// Identifier string used to connect to the service. |
|
|
|
const char* service_name; |
|
|
|
/// Function used to safely up-cast pointers to the derived class before invoking a handler. |
|
|
|
InvokerFn* handler_invoker; |
|
|
|
|
|
|
|
/// Maximum number of concurrent sessions that this service can handle. |
|
|
|
u32 max_sessions; |
|
|
|
|
|
|
|
/// Flag to store if a port was already create/installed to detect multiple install attempts, |
|
|
|
/// which is not supported. |
|
|
|
bool service_registered = false; |
|
|
|
@ -159,8 +154,7 @@ protected: |
|
|
|
* @param max_sessions_ Maximum number of sessions that can be connected to this service at the |
|
|
|
* same time. |
|
|
|
*/ |
|
|
|
explicit ServiceFramework(Core::System& system_, const char* service_name_, |
|
|
|
u32 max_sessions_ = ServerSessionCountMax) |
|
|
|
explicit ServiceFramework(Core::System& system_, const char* service_name_, u32 max_sessions_ = ServerSessionCountMax) |
|
|
|
: ServiceFrameworkBase(system_, service_name_, max_sessions_, Invoker) {} |
|
|
|
|
|
|
|
/// Registers handlers in the service. |
|
|
|
@ -219,7 +213,7 @@ private: |
|
|
|
static void Invoker(ServiceFrameworkBase* object, HandlerFnP<ServiceFrameworkBase> member, |
|
|
|
HLERequestContext& ctx) { |
|
|
|
// Cast back up to our original types and call the member function |
|
|
|
(static_cast<Self*>(object)->*static_cast<HandlerFnP<Self>>(member))(ctx); |
|
|
|
(static_cast<Self*>(object)->*HandlerFnP<Self>(member))(ctx); |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
|