aboutsummaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/k_light_session.h
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2023-12-09 19:03:50 -0500
committerGitHub <noreply@github.com>2023-12-09 19:03:50 -0500
commit988e557ec81a9f4b883e9089fedd6079f76e07e9 (patch)
tree2c223ebd34794fc8954d09a7f96fee132d749407 /src/core/hle/kernel/k_light_session.h
parent6d2af32f2930cd3c4a1d1163153b3434ef770379 (diff)
parent9268f265a1207f0cddb97a908a1cc349f9b6410b (diff)
Merge pull request #12299 from liamwhite/light-ipc
kernel: implement light IPC
Diffstat (limited to 'src/core/hle/kernel/k_light_session.h')
-rw-r--r--src/core/hle/kernel/k_light_session.h86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/core/hle/kernel/k_light_session.h b/src/core/hle/kernel/k_light_session.h
new file mode 100644
index 000000000..f78d8e689
--- /dev/null
+++ b/src/core/hle/kernel/k_light_session.h
@@ -0,0 +1,86 @@
+// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "core/hle/kernel/k_light_client_session.h"
+#include "core/hle/kernel/k_light_server_session.h"
+#include "core/hle/kernel/slab_helpers.h"
+#include "core/hle/result.h"
+
+namespace Kernel {
+
+class KClientPort;
+class KProcess;
+
+// TODO: SupportDynamicExpansion for SlabHeap
+class KLightSession final
+ : public KAutoObjectWithSlabHeapAndContainer<KLightSession, KAutoObjectWithList> {
+ KERNEL_AUTOOBJECT_TRAITS(KLightSession, KAutoObject);
+
+private:
+ enum class State : u8 {
+ Invalid = 0,
+ Normal = 1,
+ ClientClosed = 2,
+ ServerClosed = 3,
+ };
+
+public:
+ static constexpr size_t DataSize = sizeof(u32) * 7;
+ static constexpr u32 ReplyFlag = (1U << 31);
+
+private:
+ KLightServerSession m_server;
+ KLightClientSession m_client;
+ State m_state{State::Invalid};
+ KClientPort* m_port{};
+ uintptr_t m_name{};
+ KProcess* m_process{};
+ bool m_initialized{};
+
+public:
+ explicit KLightSession(KernelCore& kernel);
+ ~KLightSession();
+
+ void Initialize(KClientPort* client_port, uintptr_t name);
+ void Finalize() override;
+
+ bool IsInitialized() const override {
+ return m_initialized;
+ }
+ uintptr_t GetPostDestroyArgument() const override {
+ return reinterpret_cast<uintptr_t>(m_process);
+ }
+
+ static void PostDestroy(uintptr_t arg);
+
+ void OnServerClosed();
+ void OnClientClosed();
+
+ bool IsServerClosed() const {
+ return m_state != State::Normal;
+ }
+ bool IsClientClosed() const {
+ return m_state != State::Normal;
+ }
+
+ Result OnRequest(KThread* request_thread) {
+ R_RETURN(m_server.OnRequest(request_thread));
+ }
+
+ KLightClientSession& GetClientSession() {
+ return m_client;
+ }
+ KLightServerSession& GetServerSession() {
+ return m_server;
+ }
+ const KLightClientSession& GetClientSession() const {
+ return m_client;
+ }
+ const KLightServerSession& GetServerSession() const {
+ return m_server;
+ }
+};
+
+} // namespace Kernel