meso: Implement ConnectLight

This commit is contained in:
TuxSH
2018-11-13 01:14:55 +01:00
committed by Michael Scire
parent efe7325af3
commit ad879ca327
12 changed files with 73 additions and 18 deletions

View File

@@ -35,6 +35,9 @@ MESOSPHERE_AUTO_OBJECT_FW_DECL(InterruptEvent);
MESOSPHERE_AUTO_OBJECT_FW_DECL(LightSession);
MESOSPHERE_AUTO_OBJECT_FW_DECL(LightClientSession);
MESOSPHERE_AUTO_OBJECT_FW_DECL(LightServerSession);
MESOSPHERE_AUTO_OBJECT_FW_DECL(Port);
MESOSPHERE_AUTO_OBJECT_FW_DECL(ClientPort);
MESOSPHERE_AUTO_OBJECT_FW_DECL(ServerPort);
class KAutoObject {
public:

View File

@@ -97,6 +97,8 @@ class ResultError : public ResultBase<ResultError<module, description>> {
#define DEFINE_RESULT(module, name, description) class Result##module##name final : public ResultError<ResultModule::module, description> {}
DEFINE_RESULT(Kernel, OutOfSessions, 7);
DEFINE_RESULT(Kernel, InvalidCapabilityDescriptor, 14);
DEFINE_RESULT(Kernel, NotImplemented, 33);

View File

@@ -40,6 +40,15 @@ auto MakeObjectRaw(Args&& ...args)
if constexpr (std::is_base_of_v<ISetAllocated<T>, T>) {
obj->AddToAllocatedSet();
}
} else {
if constexpr (std::is_base_of_v<IClientServerParentTag, T>) {
delete &obj->GetClient();
delete &obj->GetServer();
} else {
delete obj;
}
obj = nullptr;
}
cleanup:
if (doReslimitCleanup) {

View File

@@ -1,10 +1,9 @@
#pragma once
#include <mesosphere/core/KSynchronizationObject.hpp>
#include <mesosphere/core/util.hpp>
#include <mesosphere/core/Result.hpp>
#include <mesosphere/interfaces/IClient.hpp>
#include <mesosphere/threading/KThread.hpp>
#include <tuple>
namespace mesosphere
{
@@ -24,12 +23,16 @@ class KClientPort final :
virtual bool IsSignaled() const override;
std::tuple<Result, SharedPtr<KLightClientSession>> ConnectLight();
private:
friend class KPort;
std::atomic<int> numSessions{0}, currentCapacity{0}, maxSessions{0};
std::atomic<int> numSessions{0};
std::atomic<int> peakNumNormalSessions{0};
int maxSessions = 0;
};
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(ClientPort);
}
}

View File

@@ -24,7 +24,7 @@ class KLightClientSession final : public KAutoObject, public IClient<KLightSessi
private:
friend class KLightSession;
KClientPort *parentPort = nullptr;
SharedPtr<KClientPort> parentClientPort = nullptr;
};
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(LightClientSession);

View File

@@ -11,6 +11,8 @@
namespace mesosphere
{
class KPort;
struct LightSessionRequest {
s32 cmdId;
u32 data[6];
@@ -28,7 +30,7 @@ class KLightSession final :
virtual ~KLightSession();
Result Initialize();
Result Initialize(KPort *parentPort = nullptr);
private:
friend class KLightClientSession;

View File

@@ -6,7 +6,7 @@
#include <mesosphere/interfaces/ISetAllocated.hpp>
#include <mesosphere/processes/KClientPort.hpp>
#include <mesosphere/processes/KServerPort.hpp>
#include <mesosphere/processes/KLightServerSession.hpp>
#include <mesosphere/processes/KLightSession.hpp>
namespace mesosphere
{
@@ -23,12 +23,12 @@ class KPort final :
Result Initialize(int maxSessions, bool isLight);
Result AddLightServerSession(KLightServerSession &lightServerSession);
private:
friend class KClientPort;
friend class KServerPort;
Result AddServerSession(KLightServerSession &lightServerSession);
bool isClientAlive = false;
bool isServerAlive = false;
bool isLight = false;
@@ -36,4 +36,4 @@ class KPort final :
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(Port);
}
}

View File

@@ -23,11 +23,11 @@ class KServerPort final :
private:
friend class KPort;
Result AddServerSession(KLightServerSession &lightServerSession);
Result AddLightServerSession(KLightServerSession &lightServerSession);
KLightServerSession::List lightServerSessions{};
};
MESOSPHERE_AUTO_OBJECT_DEFINE_INCREF(ServerPort);
}
}