summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/domain.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2017-12-29 05:30:21 +0100
committerbunnei <bunneidev@gmail.com>2017-12-29 05:30:21 +0100
commite17c0019c5cf9faaa8f23e3904342c8c4faf0980 (patch)
tree66c9735e44cf91fadca66cfe5c7a651bdc20cf89 /src/core/hle/kernel/domain.cpp
parentkernel: Add SyncObject primitive, use it for ClientSession. (diff)
downloadyuzu-e17c0019c5cf9faaa8f23e3904342c8c4faf0980.tar
yuzu-e17c0019c5cf9faaa8f23e3904342c8c4faf0980.tar.gz
yuzu-e17c0019c5cf9faaa8f23e3904342c8c4faf0980.tar.bz2
yuzu-e17c0019c5cf9faaa8f23e3904342c8c4faf0980.tar.lz
yuzu-e17c0019c5cf9faaa8f23e3904342c8c4faf0980.tar.xz
yuzu-e17c0019c5cf9faaa8f23e3904342c8c4faf0980.tar.zst
yuzu-e17c0019c5cf9faaa8f23e3904342c8c4faf0980.zip
Diffstat (limited to 'src/core/hle/kernel/domain.cpp')
-rw-r--r--src/core/hle/kernel/domain.cpp44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/core/hle/kernel/domain.cpp b/src/core/hle/kernel/domain.cpp
new file mode 100644
index 000000000..19ba861f5
--- /dev/null
+++ b/src/core/hle/kernel/domain.cpp
@@ -0,0 +1,44 @@
+// Copyright 2017 Citra Emulator Project
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#include "core/hle/kernel/client_port.h"
+#include "core/hle/kernel/domain.h"
+#include "core/hle/kernel/handle_table.h"
+#include "core/hle/kernel/hle_ipc.h"
+#include "core/hle/kernel/process.h"
+#include "core/hle/kernel/session.h"
+#include "core/hle/kernel/thread.h"
+
+namespace Kernel {
+
+ResultVal<SharedPtr<Domain>> Domain::Create(std::string name) {
+ SharedPtr<Domain> domain(new Domain);
+ domain->name = std::move(name);
+ return MakeResult(std::move(domain));
+}
+
+ResultVal<SharedPtr<Domain>> Domain::CreateFromSession(const Session& session) {
+ auto res = Create(session.port->GetName() + "_Domain");
+ auto& domain = res.Unwrap();
+ domain->request_handlers.push_back(std::move(session.server->hle_handler));
+ Kernel::g_handle_table.ConvertSessionToDomain(session, domain);
+ return res;
+}
+
+ResultCode Domain::SendSyncRequest(SharedPtr<Thread> thread) {
+ Kernel::HLERequestContext context(this);
+ u32* cmd_buf = (u32*)Memory::GetPointer(Kernel::GetCurrentThread()->GetTLSAddress());
+ context.PopulateFromIncomingCommandBuffer(cmd_buf, *Kernel::g_current_process,
+ Kernel::g_handle_table);
+
+ auto& domain_message_header = context.GetDomainMessageHeader();
+ if (domain_message_header) {
+ // If there is a DomainMessageHeader, then this is CommandType "Request"
+ const u32 object_id{context.GetDomainMessageHeader()->object_id};
+ return request_handlers[object_id - 1]->HandleSyncRequest(context);
+ }
+ return request_handlers.front()->HandleSyncRequest(context);
+}
+
+} // namespace Kernel