|
|
|
@ -5,18 +5,23 @@
|
|
|
|
|
#include <tuple>
|
|
|
|
|
#include "common/assert.h"
|
|
|
|
|
#include "core/hle/kernel/k_client_port.h"
|
|
|
|
|
#include "core/hle/kernel/k_server_port.h"
|
|
|
|
|
#include "core/hle/kernel/k_server_session.h"
|
|
|
|
|
#include "core/hle/kernel/k_thread.h"
|
|
|
|
|
#include "core/hle/kernel/object.h"
|
|
|
|
|
#include "core/hle/kernel/server_port.h"
|
|
|
|
|
#include "core/hle/kernel/svc_results.h"
|
|
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
|
|
ServerPort::ServerPort(KernelCore& kernel) : KSynchronizationObject{kernel} {}
|
|
|
|
|
ServerPort::~ServerPort() = default;
|
|
|
|
|
KServerPort::KServerPort(KernelCore& kernel) : KSynchronizationObject{kernel} {}
|
|
|
|
|
KServerPort::~KServerPort() = default;
|
|
|
|
|
|
|
|
|
|
ResultVal<KServerSession*> ServerPort::Accept() {
|
|
|
|
|
void KServerPort::Initialize(std::string&& name_) {
|
|
|
|
|
// Set member variables.
|
|
|
|
|
name = std::move(name_);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ResultVal<KServerSession*> KServerPort::Accept() {
|
|
|
|
|
if (pending_sessions.empty()) {
|
|
|
|
|
return ResultNotFound;
|
|
|
|
|
}
|
|
|
|
@ -26,30 +31,35 @@ ResultVal<KServerSession*> ServerPort::Accept() {
|
|
|
|
|
return MakeResult(session);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ServerPort::AppendPendingSession(KServerSession* pending_session) {
|
|
|
|
|
void KServerPort::AppendPendingSession(KServerSession* pending_session) {
|
|
|
|
|
pending_sessions.push_back(std::move(pending_session));
|
|
|
|
|
if (pending_sessions.size() == 1) {
|
|
|
|
|
NotifyAvailable();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ServerPort::IsSignaled() const {
|
|
|
|
|
void KServerPort::Destroy() {}
|
|
|
|
|
|
|
|
|
|
bool KServerPort::IsSignaled() const {
|
|
|
|
|
return !pending_sessions.empty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ServerPort::PortPair ServerPort::CreatePortPair(KernelCore& kernel, u32 max_sessions,
|
|
|
|
|
std::string name) {
|
|
|
|
|
std::shared_ptr<ServerPort> server_port = std::make_shared<ServerPort>(kernel);
|
|
|
|
|
KServerPort::PortPair KServerPort::CreatePortPair(KernelCore& kernel, u32 max_sessions,
|
|
|
|
|
std::string name) {
|
|
|
|
|
KServerPort* server_port = new KServerPort(kernel);
|
|
|
|
|
KClientPort* client_port = new KClientPort(kernel);
|
|
|
|
|
|
|
|
|
|
KAutoObject::Create(server_port);
|
|
|
|
|
KAutoObject::Create(client_port);
|
|
|
|
|
|
|
|
|
|
server_port->Initialize(name + "_Server");
|
|
|
|
|
client_port->Initialize(max_sessions, name + "_Client");
|
|
|
|
|
|
|
|
|
|
client_port->server_port = server_port;
|
|
|
|
|
|
|
|
|
|
server_port->name = name + "_Server";
|
|
|
|
|
|
|
|
|
|
return std::make_pair(std::move(server_port), client_port);
|
|
|
|
|
return std::make_pair(server_port, client_port);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Kernel
|