summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2020-07-15 13:18:03 -0400
committerGravatar Lioncash2020-07-15 13:40:15 -0400
commit52e83f0d5c5dbef89fa789ef1da1245781ee183d (patch)
treefed5fa3fc37d890a6187ed18fc87dfb4890efb0e /src
parentkernel/thread: Remove global GetCurrentThread() (diff)
downloadyuzu-52e83f0d5c5dbef89fa789ef1da1245781ee183d.tar.gz
yuzu-52e83f0d5c5dbef89fa789ef1da1245781ee183d.tar.xz
yuzu-52e83f0d5c5dbef89fa789ef1da1245781ee183d.zip
kernel/handle_table: Remove usages of the global system instance
Removes even more usages of the global system instance, trimming away more dependencies on global variables and making them explicit in the interface.
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/handle_table.cpp9
-rw-r--r--src/core/hle/kernel/handle_table.h7
-rw-r--r--src/core/hle/kernel/kernel.cpp5
-rw-r--r--src/core/hle/kernel/process.cpp2
4 files changed, 15 insertions, 8 deletions
diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp
index aaf048243..fb30b6f8b 100644
--- a/src/core/hle/kernel/handle_table.cpp
+++ b/src/core/hle/kernel/handle_table.cpp
@@ -8,8 +8,9 @@
8#include "core/core.h" 8#include "core/core.h"
9#include "core/hle/kernel/errors.h" 9#include "core/hle/kernel/errors.h"
10#include "core/hle/kernel/handle_table.h" 10#include "core/hle/kernel/handle_table.h"
11#include "core/hle/kernel/scheduler.h" 11#include "core/hle/kernel/kernel.h"
12#include "core/hle/kernel/process.h" 12#include "core/hle/kernel/process.h"
13#include "core/hle/kernel/scheduler.h"
13#include "core/hle/kernel/thread.h" 14#include "core/hle/kernel/thread.h"
14 15
15namespace Kernel { 16namespace Kernel {
@@ -23,7 +24,7 @@ constexpr u16 GetGeneration(Handle handle) {
23} 24}
24} // Anonymous namespace 25} // Anonymous namespace
25 26
26HandleTable::HandleTable() { 27HandleTable::HandleTable(KernelCore& kernel) : kernel{kernel} {
27 Clear(); 28 Clear();
28} 29}
29 30
@@ -104,9 +105,9 @@ bool HandleTable::IsValid(Handle handle) const {
104 105
105std::shared_ptr<Object> HandleTable::GetGeneric(Handle handle) const { 106std::shared_ptr<Object> HandleTable::GetGeneric(Handle handle) const {
106 if (handle == CurrentThread) { 107 if (handle == CurrentThread) {
107 return SharedFrom(Core::System::GetInstance().CurrentScheduler().GetCurrentThread()); 108 return SharedFrom(kernel.CurrentScheduler().GetCurrentThread());
108 } else if (handle == CurrentProcess) { 109 } else if (handle == CurrentProcess) {
109 return SharedFrom(Core::System::GetInstance().CurrentProcess()); 110 return SharedFrom(kernel.CurrentProcess());
110 } 111 }
111 112
112 if (!IsValid(handle)) { 113 if (!IsValid(handle)) {
diff --git a/src/core/hle/kernel/handle_table.h b/src/core/hle/kernel/handle_table.h
index 8029660ed..c9dab8cdd 100644
--- a/src/core/hle/kernel/handle_table.h
+++ b/src/core/hle/kernel/handle_table.h
@@ -14,6 +14,8 @@
14 14
15namespace Kernel { 15namespace Kernel {
16 16
17class KernelCore;
18
17enum KernelHandle : Handle { 19enum KernelHandle : Handle {
18 InvalidHandle = 0, 20 InvalidHandle = 0,
19 CurrentThread = 0xFFFF8000, 21 CurrentThread = 0xFFFF8000,
@@ -48,7 +50,7 @@ public:
48 /// This is the maximum limit of handles allowed per process in Horizon 50 /// This is the maximum limit of handles allowed per process in Horizon
49 static constexpr std::size_t MAX_COUNT = 1024; 51 static constexpr std::size_t MAX_COUNT = 1024;
50 52
51 HandleTable(); 53 explicit HandleTable(KernelCore& kernel);
52 ~HandleTable(); 54 ~HandleTable();
53 55
54 /** 56 /**
@@ -134,6 +136,9 @@ private:
134 136
135 /// Head of the free slots linked list. 137 /// Head of the free slots linked list.
136 u16 next_free_slot = 0; 138 u16 next_free_slot = 0;
139
140 /// Underlying kernel instance that this handle table operates under.
141 KernelCore& kernel;
137}; 142};
138 143
139} // namespace Kernel 144} // namespace Kernel
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 1f2af7a1b..6e2014e08 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -50,7 +50,8 @@ namespace Kernel {
50 50
51struct KernelCore::Impl { 51struct KernelCore::Impl {
52 explicit Impl(Core::System& system, KernelCore& kernel) 52 explicit Impl(Core::System& system, KernelCore& kernel)
53 : global_scheduler{kernel}, synchronization{system}, time_manager{system}, system{system} {} 53 : global_scheduler{kernel}, synchronization{system}, time_manager{system},
54 global_handle_table{kernel}, system{system} {}
54 55
55 void SetMulticore(bool is_multicore) { 56 void SetMulticore(bool is_multicore) {
56 this->is_multicore = is_multicore; 57 this->is_multicore = is_multicore;
@@ -307,7 +308,7 @@ struct KernelCore::Impl {
307 308
308 // This is the kernel's handle table or supervisor handle table which 309 // This is the kernel's handle table or supervisor handle table which
309 // stores all the objects in place. 310 // stores all the objects in place.
310 Kernel::HandleTable global_handle_table; 311 HandleTable global_handle_table;
311 312
312 /// Map of named ports managed by the kernel, which can be retrieved using 313 /// Map of named ports managed by the kernel, which can be retrieved using
313 /// the ConnectToPort SVC. 314 /// the ConnectToPort SVC.
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp
index c6fcb56ad..ff9d9248b 100644
--- a/src/core/hle/kernel/process.cpp
+++ b/src/core/hle/kernel/process.cpp
@@ -408,7 +408,7 @@ void Process::LoadModule(CodeSet code_set, VAddr base_addr) {
408Process::Process(Core::System& system) 408Process::Process(Core::System& system)
409 : SynchronizationObject{system.Kernel()}, page_table{std::make_unique<Memory::PageTable>( 409 : SynchronizationObject{system.Kernel()}, page_table{std::make_unique<Memory::PageTable>(
410 system)}, 410 system)},
411 address_arbiter{system}, mutex{system}, system{system} {} 411 handle_table{system.Kernel()}, address_arbiter{system}, mutex{system}, system{system} {}
412 412
413Process::~Process() = default; 413Process::~Process() = default;
414 414