From 1242c1ec0aab88d91b0bb4faf6200e4f20e4bdc2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 2 Sep 2018 11:58:58 -0400 Subject: service: Migrate global named port map to the KernelCore class Now that we have a class representing the kernel in some capacity, we now have a place to put the named port map, so we move it over and get rid of another piece of global state within the core. --- src/core/hle/kernel/kernel.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/core/hle/kernel/kernel.cpp') diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 615d7901a..7902c2882 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -13,6 +13,7 @@ #include "core/core.h" #include "core/core_timing.h" +#include "core/hle/kernel/client_port.h" #include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/process.h" @@ -124,6 +125,8 @@ struct KernelCore::Impl { timer_callback_handle_table.Clear(); timer_callback_event_type = nullptr; + + named_ports.clear(); } void InitializeResourceLimits(KernelCore& kernel) { @@ -217,6 +220,10 @@ struct KernelCore::Impl { // TODO(yuriks): This can be removed if Thread objects are explicitly pooled in the future, // allowing us to simply use a pool index or similar. Kernel::HandleTable thread_wakeup_callback_handle_table; + + /// Map of named ports managed by the kernel, which can be retrieved using + /// the ConnectToPort SVC. + NamedPortTable named_ports; }; KernelCore::KernelCore() : impl{std::make_unique()} {} @@ -257,6 +264,23 @@ void KernelCore::AppendNewProcess(SharedPtr process) { impl->process_list.push_back(std::move(process)); } +void KernelCore::AddNamedPort(std::string name, SharedPtr port) { + impl->named_ports.emplace(std::move(name), std::move(port)); +} + +KernelCore::NamedPortTable::iterator KernelCore::FindNamedPort(const std::string& name) { + return impl->named_ports.find(name); +} + +KernelCore::NamedPortTable::const_iterator KernelCore::FindNamedPort( + const std::string& name) const { + return impl->named_ports.find(name); +} + +bool KernelCore::IsValidNamedPort(NamedPortTable::const_iterator port) const { + return port != impl->named_ports.cend(); +} + u32 KernelCore::CreateNewObjectID() { return impl->next_object_id++; } -- cgit v1.2.3