2022-04-23 10:59:50 +02:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2021-04-24 02:00:15 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "common/common_types.h"
|
|
|
|
#include "core/hle/kernel/k_client_port.h"
|
|
|
|
#include "core/hle/kernel/k_server_port.h"
|
|
|
|
#include "core/hle/kernel/slab_helpers.h"
|
|
|
|
#include "core/hle/result.h"
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
class KServerSession;
|
|
|
|
|
|
|
|
class KPort final : public KAutoObjectWithSlabHeapAndContainer<KPort, KAutoObjectWithList> {
|
|
|
|
KERNEL_AUTOOBJECT_TRAITS(KPort, KAutoObject);
|
|
|
|
|
|
|
|
public:
|
2021-05-08 18:11:36 +02:00
|
|
|
explicit KPort(KernelCore& kernel_);
|
2021-05-29 08:49:07 +02:00
|
|
|
~KPort() override;
|
2021-04-24 02:00:15 +02:00
|
|
|
|
|
|
|
static void PostDestroy([[maybe_unused]] uintptr_t arg) {}
|
|
|
|
|
|
|
|
void Initialize(s32 max_sessions_, bool is_light_, const std::string& name_);
|
|
|
|
void OnClientClosed();
|
|
|
|
void OnServerClosed();
|
|
|
|
|
|
|
|
bool IsLight() const {
|
|
|
|
return is_light;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsServerClosed() const;
|
|
|
|
|
|
|
|
ResultCode EnqueueSession(KServerSession* session);
|
|
|
|
|
|
|
|
KClientPort& GetClientPort() {
|
|
|
|
return client;
|
|
|
|
}
|
|
|
|
KServerPort& GetServerPort() {
|
|
|
|
return server;
|
|
|
|
}
|
|
|
|
const KClientPort& GetClientPort() const {
|
|
|
|
return client;
|
|
|
|
}
|
|
|
|
const KServerPort& GetServerPort() const {
|
|
|
|
return server;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
enum class State : u8 {
|
|
|
|
Invalid = 0,
|
|
|
|
Normal = 1,
|
|
|
|
ClientClosed = 2,
|
|
|
|
ServerClosed = 3,
|
|
|
|
};
|
|
|
|
|
|
|
|
KServerPort server;
|
|
|
|
KClientPort client;
|
|
|
|
State state{State::Invalid};
|
|
|
|
bool is_light{};
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Kernel
|