2021-04-24 02:00:15 +02:00
|
|
|
// Copyright 2021 yuzu emulator team
|
2016-05-22 18:22:49 +02:00
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2016-12-05 18:05:00 +01:00
|
|
|
#include <memory>
|
2016-05-22 18:22:49 +02:00
|
|
|
#include <string>
|
2019-04-06 07:36:50 +02:00
|
|
|
#include <utility>
|
2018-07-31 14:06:09 +02:00
|
|
|
#include <vector>
|
2021-04-24 02:00:15 +02:00
|
|
|
|
|
|
|
#include <boost/intrusive/list.hpp>
|
|
|
|
|
2016-05-22 18:22:49 +02:00
|
|
|
#include "common/common_types.h"
|
2021-04-24 02:00:15 +02:00
|
|
|
#include "core/hle/kernel/k_server_session.h"
|
2020-12-22 07:36:53 +01:00
|
|
|
#include "core/hle/kernel/k_synchronization_object.h"
|
2018-10-06 08:49:01 +02:00
|
|
|
#include "core/hle/result.h"
|
2016-05-22 18:22:49 +02:00
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2018-08-28 18:30:33 +02:00
|
|
|
class KernelCore;
|
2021-04-24 02:00:15 +02:00
|
|
|
class KPort;
|
2017-06-05 06:52:19 +02:00
|
|
|
class SessionRequestHandler;
|
2016-05-22 19:30:13 +02:00
|
|
|
|
2021-04-22 06:53:56 +02:00
|
|
|
class KServerPort final : public KSynchronizationObject {
|
|
|
|
KERNEL_AUTOOBJECT_TRAITS(KServerPort, KSynchronizationObject);
|
|
|
|
|
2021-04-24 02:00:15 +02:00
|
|
|
private:
|
|
|
|
using SessionList = boost::intrusive::list<KServerSession>;
|
|
|
|
|
2016-05-22 18:22:49 +02:00
|
|
|
public:
|
2021-04-22 06:53:56 +02:00
|
|
|
explicit KServerPort(KernelCore& kernel);
|
|
|
|
virtual ~KServerPort() override;
|
2019-11-25 02:15:51 +01:00
|
|
|
|
2019-03-11 15:28:16 +01:00
|
|
|
using HLEHandler = std::shared_ptr<SessionRequestHandler>;
|
2016-05-22 18:22:49 +02:00
|
|
|
|
2021-04-24 02:00:15 +02:00
|
|
|
void Initialize(KPort* parent_, std::string&& name_);
|
2017-06-23 08:57:05 +02:00
|
|
|
|
2019-03-11 15:28:16 +01:00
|
|
|
/// Whether or not this server port has an HLE handler available.
|
|
|
|
bool HasHLEHandler() const {
|
|
|
|
return hle_handler != nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Gets the HLE handler for this port.
|
|
|
|
HLEHandler GetHLEHandler() const {
|
|
|
|
return hle_handler;
|
|
|
|
}
|
|
|
|
|
2017-06-06 07:39:26 +02:00
|
|
|
/**
|
|
|
|
* Sets the HLE handler template for the port. ServerSessions crated by connecting to this port
|
|
|
|
* will inherit a reference to this handler.
|
|
|
|
*/
|
2019-03-11 15:28:16 +01:00
|
|
|
void SetHleHandler(HLEHandler hle_handler_) {
|
2017-06-06 07:39:26 +02:00
|
|
|
hle_handler = std::move(hle_handler_);
|
|
|
|
}
|
|
|
|
|
2021-04-24 02:00:15 +02:00
|
|
|
void EnqueueSession(KServerSession* pending_session);
|
|
|
|
|
|
|
|
KServerSession* AcceptSession();
|
|
|
|
|
2021-05-01 21:48:58 +02:00
|
|
|
const KPort* GetParent() const {
|
2021-04-24 02:00:15 +02:00
|
|
|
return parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsLight() const;
|
2016-12-05 17:02:08 +01:00
|
|
|
|
2021-04-22 06:53:56 +02:00
|
|
|
// Overridden virtual functions.
|
|
|
|
virtual void Destroy() override;
|
|
|
|
virtual bool IsSignaled() const override;
|
|
|
|
|
2016-05-22 18:22:49 +02:00
|
|
|
private:
|
2021-04-24 02:00:15 +02:00
|
|
|
void CleanupSessions();
|
2019-03-11 15:28:16 +01:00
|
|
|
|
2021-04-24 02:00:15 +02:00
|
|
|
private:
|
|
|
|
SessionList session_list;
|
2019-03-11 15:28:16 +01:00
|
|
|
HLEHandler hle_handler;
|
2021-04-24 02:00:15 +02:00
|
|
|
KPort* parent{};
|
2016-05-22 18:22:49 +02:00
|
|
|
};
|
|
|
|
|
2018-01-20 08:48:02 +01:00
|
|
|
} // namespace Kernel
|