summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/kernel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
-rw-r--r--src/core/hle/kernel/kernel.cpp52
1 files changed, 20 insertions, 32 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index fdc774e30..09c36ee09 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -60,7 +60,6 @@ struct KernelCore::Impl {
global_scheduler_context = std::make_unique<Kernel::GlobalSchedulerContext>(kernel);
global_handle_table = std::make_unique<Kernel::KHandleTable>(kernel);
global_handle_table->Initialize(KHandleTable::MaxTableSize);
- default_service_thread = CreateServiceThread(kernel, "DefaultServiceThread");
is_phantom_mode_for_singlecore = false;
@@ -86,6 +85,8 @@ struct KernelCore::Impl {
}
RegisterHostThread();
+
+ default_service_thread = CreateServiceThread(kernel, "DefaultServiceThread");
}
void InitializeCores() {
@@ -184,17 +185,6 @@ struct KernelCore::Impl {
}
void CloseServices() {
- // Close all open server sessions and ports.
- std::unordered_set<KAutoObject*> server_objects_;
- {
- std::scoped_lock lk(server_objects_lock);
- server_objects_ = server_objects;
- server_objects.clear();
- }
- for (auto* server_object : server_objects_) {
- server_object->Close();
- }
-
// Ensures all service threads gracefully shutdown.
ClearServiceThreads();
}
@@ -346,6 +336,8 @@ struct KernelCore::Impl {
return this_id;
}
+ static inline thread_local bool is_phantom_mode_for_singlecore{false};
+
bool IsPhantomModeForSingleCore() const {
return is_phantom_mode_for_singlecore;
}
@@ -698,24 +690,21 @@ struct KernelCore::Impl {
return {};
}
- KClientPort* port = &search->second(system.ServiceManager(), system);
- RegisterServerObject(&port->GetParent()->GetServerPort());
- return port;
+ return &search->second(system.ServiceManager(), system);
}
- void RegisterServerObject(KAutoObject* server_object) {
- std::scoped_lock lk(server_objects_lock);
- server_objects.insert(server_object);
- }
+ void RegisterNamedServiceHandler(std::string name, KServerPort* server_port) {
+ auto search = service_interface_handlers.find(name);
+ if (search == service_interface_handlers.end()) {
+ return;
+ }
- void UnregisterServerObject(KAutoObject* server_object) {
- std::scoped_lock lk(server_objects_lock);
- server_objects.erase(server_object);
+ search->second(system.ServiceManager(), server_port);
}
std::weak_ptr<Kernel::ServiceThread> CreateServiceThread(KernelCore& kernel,
const std::string& name) {
- auto service_thread = std::make_shared<Kernel::ServiceThread>(kernel, 1, name);
+ auto service_thread = std::make_shared<Kernel::ServiceThread>(kernel, name);
service_threads_manager.QueueWork(
[this, service_thread]() { service_threads.emplace(service_thread); });
@@ -745,7 +734,6 @@ struct KernelCore::Impl {
service_thread_barrier.Sync();
}
- std::mutex server_objects_lock;
std::mutex registered_objects_lock;
std::mutex registered_in_use_objects_lock;
@@ -774,8 +762,8 @@ struct KernelCore::Impl {
/// Map of named ports managed by the kernel, which can be retrieved using
/// the ConnectToPort SVC.
std::unordered_map<std::string, ServiceInterfaceFactory> service_interface_factory;
+ std::unordered_map<std::string, ServiceInterfaceHandlerFn> service_interface_handlers;
NamedPortTable named_ports;
- std::unordered_set<KAutoObject*> server_objects;
std::unordered_set<KAutoObject*> registered_objects;
std::unordered_set<KAutoObject*> registered_in_use_objects;
@@ -814,7 +802,6 @@ struct KernelCore::Impl {
bool is_multicore{};
std::atomic_bool is_shutting_down{};
- bool is_phantom_mode_for_singlecore{};
u32 single_core_thread_id{};
std::array<u64, Core::Hardware::NUM_CPU_CORES> svc_ticks{};
@@ -981,16 +968,17 @@ void KernelCore::RegisterNamedService(std::string name, ServiceInterfaceFactory&
impl->service_interface_factory.emplace(std::move(name), factory);
}
-KClientPort* KernelCore::CreateNamedServicePort(std::string name) {
- return impl->CreateNamedServicePort(std::move(name));
+void KernelCore::RegisterInterfaceForNamedService(std::string name,
+ ServiceInterfaceHandlerFn&& handler) {
+ impl->service_interface_handlers.emplace(std::move(name), handler);
}
-void KernelCore::RegisterServerObject(KAutoObject* server_object) {
- impl->RegisterServerObject(server_object);
+KClientPort* KernelCore::CreateNamedServicePort(std::string name) {
+ return impl->CreateNamedServicePort(std::move(name));
}
-void KernelCore::UnregisterServerObject(KAutoObject* server_object) {
- impl->UnregisterServerObject(server_object);
+void KernelCore::RegisterNamedServiceHandler(std::string name, KServerPort* server_port) {
+ impl->RegisterNamedServiceHandler(std::move(name), server_port);
}
void KernelCore::RegisterKernelObject(KAutoObject* object) {