summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-11-26 18:32:13 -0500
committerGravatar Zach Hilman2018-11-29 08:42:26 -0500
commitc61d2a28413bd149d58b1173fa89a250ddce03c4 (patch)
treeb45cef0f468a5cd28c7624a78db036025800525a
parentkernel: Divide Event into ReadableEvent and WritableEvent (diff)
downloadyuzu-c61d2a28413bd149d58b1173fa89a250ddce03c4.tar.gz
yuzu-c61d2a28413bd149d58b1173fa89a250ddce03c4.tar.xz
yuzu-c61d2a28413bd149d58b1173fa89a250ddce03c4.zip
kernel: Add named event table
Used to store ReadableEvents of all events on the system.
-rw-r--r--src/core/hle/kernel/kernel.cpp19
-rw-r--r--src/core/hle/kernel/kernel.h11
2 files changed, 30 insertions, 0 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index e441c5bc6..9cd714586 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -17,9 +17,11 @@
17#include "core/hle/kernel/handle_table.h" 17#include "core/hle/kernel/handle_table.h"
18#include "core/hle/kernel/kernel.h" 18#include "core/hle/kernel/kernel.h"
19#include "core/hle/kernel/process.h" 19#include "core/hle/kernel/process.h"
20#include "core/hle/kernel/readable_event.h"
20#include "core/hle/kernel/resource_limit.h" 21#include "core/hle/kernel/resource_limit.h"
21#include "core/hle/kernel/thread.h" 22#include "core/hle/kernel/thread.h"
22#include "core/hle/kernel/timer.h" 23#include "core/hle/kernel/timer.h"
24#include "core/hle/kernel/writable_event.h"
23#include "core/hle/lock.h" 25#include "core/hle/lock.h"
24#include "core/hle/result.h" 26#include "core/hle/result.h"
25 27
@@ -175,6 +177,10 @@ struct KernelCore::Impl {
175 // allowing us to simply use a pool index or similar. 177 // allowing us to simply use a pool index or similar.
176 Kernel::HandleTable thread_wakeup_callback_handle_table; 178 Kernel::HandleTable thread_wakeup_callback_handle_table;
177 179
180 /// Map of named events managed by the kernel, which are retrieved when HLE services need to
181 /// return an event to the system.
182 NamedEventTable named_events;
183
178 /// Map of named ports managed by the kernel, which can be retrieved using 184 /// Map of named ports managed by the kernel, which can be retrieved using
179 /// the ConnectToPort SVC. 185 /// the ConnectToPort SVC.
180 NamedPortTable named_ports; 186 NamedPortTable named_ports;
@@ -221,6 +227,19 @@ const Process* KernelCore::CurrentProcess() const {
221 return impl->current_process; 227 return impl->current_process;
222} 228}
223 229
230void KernelCore::AddNamedEvent(std::string name, SharedPtr<ReadableEvent> event) {
231 impl->named_events.emplace(std::move(name), std::move(event));
232}
233
234KernelCore::NamedEventTable::iterator KernelCore::FindNamedEvent(const std::string& name) {
235 return impl->named_events.find(name);
236}
237
238KernelCore::NamedEventTable::const_iterator KernelCore::FindNamedEvent(
239 const std::string& name) const {
240 return impl->named_events.find(name);
241}
242
224void KernelCore::AddNamedPort(std::string name, SharedPtr<ClientPort> port) { 243void KernelCore::AddNamedPort(std::string name, SharedPtr<ClientPort> port) {
225 impl->named_ports.emplace(std::move(name), std::move(port)); 244 impl->named_ports.emplace(std::move(name), std::move(port));
226} 245}
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index ea00c89f5..f12d061eb 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -20,6 +20,7 @@ namespace Kernel {
20class ClientPort; 20class ClientPort;
21class HandleTable; 21class HandleTable;
22class Process; 22class Process;
23class ReadableEvent;
23class ResourceLimit; 24class ResourceLimit;
24class Thread; 25class Thread;
25class Timer; 26class Timer;
@@ -27,6 +28,7 @@ class Timer;
27/// Represents a single instance of the kernel. 28/// Represents a single instance of the kernel.
28class KernelCore { 29class KernelCore {
29private: 30private:
31 using NamedEventTable = std::unordered_map<std::string, SharedPtr<ReadableEvent>>;
30 using NamedPortTable = std::unordered_map<std::string, SharedPtr<ClientPort>>; 32 using NamedPortTable = std::unordered_map<std::string, SharedPtr<ClientPort>>;
31 33
32public: 34public:
@@ -66,6 +68,15 @@ public:
66 /// Retrieves a const pointer to the current process. 68 /// Retrieves a const pointer to the current process.
67 const Process* CurrentProcess() const; 69 const Process* CurrentProcess() const;
68 70
71 /// Adds an event to the named event table
72 void AddNamedEvent(std::string name, SharedPtr<ReadableEvent> event);
73
74 /// Finds an event within the named event table wit the given name.
75 NamedEventTable::iterator FindNamedEvent(const std::string& name);
76
77 /// Finds an event within the named event table wit the given name.
78 NamedEventTable::const_iterator FindNamedEvent(const std::string& name) const;
79
69 /// Adds a port to the named port table 80 /// Adds a port to the named port table
70 void AddNamedPort(std::string name, SharedPtr<ClientPort> port); 81 void AddNamedPort(std::string name, SharedPtr<ClientPort> port);
71 82