summaryrefslogtreecommitdiff
path: root/src/core/hle/service/service.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2018-08-28 12:30:33 -0400
committerGravatar Lioncash2018-08-28 22:31:51 -0400
commit0cbcd6ec9aeeafc298fe2e6e4ac10d68bb7267c5 (patch)
tree2d7bb143d490c3984bff6deda426b818bf27d552 /src/core/hle/service/service.cpp
parentMerge pull request #1193 from lioncash/priv (diff)
downloadyuzu-0cbcd6ec9aeeafc298fe2e6e4ac10d68bb7267c5.tar.gz
yuzu-0cbcd6ec9aeeafc298fe2e6e4ac10d68bb7267c5.tar.xz
yuzu-0cbcd6ec9aeeafc298fe2e6e4ac10d68bb7267c5.zip
kernel: Eliminate kernel global state
As means to pave the way for getting rid of global state within core, This eliminates kernel global state by removing all globals. Instead this introduces a KernelCore class which acts as a kernel instance. This instance lives in the System class, which keeps its lifetime contained to the lifetime of the System class. This also forces the kernel types to actually interact with the main kernel instance itself instead of having transient kernel state placed all over several translation units, keeping everything together. It also has a nice consequence of making dependencies much more explicit. This also makes our initialization a tad bit more correct. Previously we were creating a kernel process before the actual kernel was initialized, which doesn't really make much sense. The KernelCore class itself follows the PImpl idiom, which allows keeping all the implementation details sealed away from everything else, which forces the use of the exposed API and allows us to avoid any unnecessary inclusions within the main kernel header.
Diffstat (limited to 'src/core/hle/service/service.cpp')
-rw-r--r--src/core/hle/service/service.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 11951adaf..8fb907072 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -107,19 +107,24 @@ void ServiceFrameworkBase::InstallAsService(SM::ServiceManager& service_manager)
107 107
108void ServiceFrameworkBase::InstallAsNamedPort() { 108void ServiceFrameworkBase::InstallAsNamedPort() {
109 ASSERT(port == nullptr); 109 ASSERT(port == nullptr);
110
111 auto& kernel = Core::System::GetInstance().Kernel();
110 SharedPtr<ServerPort> server_port; 112 SharedPtr<ServerPort> server_port;
111 SharedPtr<ClientPort> client_port; 113 SharedPtr<ClientPort> client_port;
112 std::tie(server_port, client_port) = ServerPort::CreatePortPair(max_sessions, service_name); 114 std::tie(server_port, client_port) =
115 ServerPort::CreatePortPair(kernel, max_sessions, service_name);
113 server_port->SetHleHandler(shared_from_this()); 116 server_port->SetHleHandler(shared_from_this());
114 AddNamedPort(service_name, std::move(client_port)); 117 AddNamedPort(service_name, std::move(client_port));
115} 118}
116 119
117Kernel::SharedPtr<Kernel::ClientPort> ServiceFrameworkBase::CreatePort() { 120Kernel::SharedPtr<Kernel::ClientPort> ServiceFrameworkBase::CreatePort() {
118 ASSERT(port == nullptr); 121 ASSERT(port == nullptr);
122
123 auto& kernel = Core::System::GetInstance().Kernel();
119 Kernel::SharedPtr<Kernel::ServerPort> server_port; 124 Kernel::SharedPtr<Kernel::ServerPort> server_port;
120 Kernel::SharedPtr<Kernel::ClientPort> client_port; 125 Kernel::SharedPtr<Kernel::ClientPort> client_port;
121 std::tie(server_port, client_port) = 126 std::tie(server_port, client_port) =
122 Kernel::ServerPort::CreatePortPair(max_sessions, service_name); 127 Kernel::ServerPort::CreatePortPair(kernel, max_sessions, service_name);
123 port = MakeResult<Kernel::SharedPtr<Kernel::ServerPort>>(std::move(server_port)).Unwrap(); 128 port = MakeResult<Kernel::SharedPtr<Kernel::ServerPort>>(std::move(server_port)).Unwrap();
124 port->SetHleHandler(shared_from_this()); 129 port->SetHleHandler(shared_from_this());
125 return client_port; 130 return client_port;