yuzu-emu
/
yuzu
Archived
1
0
Fork 0

HLE: Use a member variable instead of a virtual function to retrieve the max number of sessions that can be connected to an HLE service at the same time.

This commit is contained in:
Subv 2016-12-05 13:44:41 -05:00
parent 00f0c77570
commit 61a2fe8c3b
5 changed files with 18 additions and 8 deletions

View File

@ -14,6 +14,8 @@ class Interface;
namespace APT { namespace APT {
static const u32 MaxAPTSessions = 2; ///< Each APT service can only have up to 2 sessions connected at the same time.
/// Holds information about the parameters used in Send/Glance/ReceiveParameter /// Holds information about the parameters used in Send/Glance/ReceiveParameter
struct MessageParameter { struct MessageParameter {
u32 sender_id = 0; u32 sender_id = 0;

View File

@ -39,7 +39,7 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x01020000, CheckNew3DS, "CheckNew3DS"}, {0x01020000, CheckNew3DS, "CheckNew3DS"},
}; };
APT_A_Interface::APT_A_Interface() { APT_A_Interface::APT_A_Interface() : Interface(MaxAPTSessions) {
Register(FunctionTable); Register(FunctionTable);
} }

View File

@ -99,7 +99,7 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x01020000, CheckNew3DS, "CheckNew3DS"}, {0x01020000, CheckNew3DS, "CheckNew3DS"},
}; };
APT_S_Interface::APT_S_Interface() { APT_S_Interface::APT_S_Interface() : Interface(MaxAPTSessions) {
Register(FunctionTable); Register(FunctionTable);
} }

View File

@ -99,7 +99,7 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x01020000, CheckNew3DS, "CheckNew3DS"}, {0x01020000, CheckNew3DS, "CheckNew3DS"},
}; };
APT_U_Interface::APT_U_Interface() { APT_U_Interface::APT_U_Interface() : Interface(MaxAPTSessions) {
Register(FunctionTable); Register(FunctionTable);
} }

View File

@ -174,7 +174,7 @@ inline DescriptorType GetDescriptorType(u32 descriptor) {
namespace Service { namespace Service {
static const int kMaxPortSize = 8; ///< Maximum size of a port name (8 characters) 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 static const u32 DefaultMaxSessions = 10; ///< Arbitrary default number of maximum connections to an HLE service
/** /**
* Interface implemented by HLE Session handlers. * Interface implemented by HLE Session handlers.
@ -215,6 +215,15 @@ private:
*/ */
class Interface : public SessionRequestHandler { class Interface : public SessionRequestHandler {
public: public:
/**
* Creates an HLE interface with the specified max sessions.
* @param max_sessions Maximum number of sessions that can be
* connected to this service at the same time.
*/
Interface(u32 max_sessions = DefaultMaxSessions) : max_sessions(max_sessions) { }
virtual ~Interface() = default;
std::string GetName() const { std::string GetName() const {
return GetPortName(); return GetPortName();
} }
@ -222,14 +231,12 @@ public:
virtual void SetVersion(u32 raw_version) { virtual void SetVersion(u32 raw_version) {
version.raw = raw_version; version.raw = raw_version;
} }
virtual ~Interface() {}
/** /**
* Gets the maximum allowed number of sessions that can be connected to this port at the same time. * Gets the maximum allowed number of sessions that can be connected to this service at the same time.
* It should be overwritten by each service implementation for more fine-grained control.
* @returns The maximum number of connections allowed. * @returns The maximum number of connections allowed.
*/ */
virtual u32 GetMaxSessions() const { return DefaultMaxSessions; } u32 GetMaxSessions() const { return max_sessions; }
typedef void (*Function)(Interface*); typedef void (*Function)(Interface*);
@ -269,6 +276,7 @@ protected:
} version = {}; } version = {};
private: private:
u32 max_sessions; ///< Maximum number of concurrent sessions that this service can handle.
boost::container::flat_map<u32, FunctionInfo> m_functions; boost::container::flat_map<u32, FunctionInfo> m_functions;
}; };