summaryrefslogtreecommitdiff
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.cpp38
1 files changed, 15 insertions, 23 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index 04926a291..275fee0d8 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -83,8 +83,9 @@ struct KernelCore::Impl {
83 } 83 }
84 84
85 void InitializeCores() { 85 void InitializeCores() {
86 for (auto& core : cores) { 86 for (u32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) {
87 core.Initialize(current_process->Is64BitProcess()); 87 cores[core_id].Initialize(current_process->Is64BitProcess());
88 system.Memory().SetCurrentPageTable(*current_process, core_id);
88 } 89 }
89 } 90 }
90 91
@@ -123,15 +124,6 @@ struct KernelCore::Impl {
123 next_user_process_id = KProcess::ProcessIDMin; 124 next_user_process_id = KProcess::ProcessIDMin;
124 next_thread_id = 1; 125 next_thread_id = 1;
125 126
126 for (u32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) {
127 if (suspend_threads[core_id]) {
128 suspend_threads[core_id]->Close();
129 suspend_threads[core_id] = nullptr;
130 }
131
132 schedulers[core_id].reset();
133 }
134
135 cores.clear(); 127 cores.clear();
136 128
137 global_handle_table->Finalize(); 129 global_handle_table->Finalize();
@@ -159,6 +151,16 @@ struct KernelCore::Impl {
159 CleanupObject(time_shared_mem); 151 CleanupObject(time_shared_mem);
160 CleanupObject(system_resource_limit); 152 CleanupObject(system_resource_limit);
161 153
154 for (u32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) {
155 if (suspend_threads[core_id]) {
156 suspend_threads[core_id]->Close();
157 suspend_threads[core_id] = nullptr;
158 }
159
160 schedulers[core_id]->Finalize();
161 schedulers[core_id].reset();
162 }
163
162 // Next host thead ID to use, 0-3 IDs represent core threads, >3 represent others 164 // Next host thead ID to use, 0-3 IDs represent core threads, >3 represent others
163 next_host_thread_id = Core::Hardware::NUM_CPU_CORES; 165 next_host_thread_id = Core::Hardware::NUM_CPU_CORES;
164 166
@@ -267,14 +269,6 @@ struct KernelCore::Impl {
267 269
268 void MakeCurrentProcess(KProcess* process) { 270 void MakeCurrentProcess(KProcess* process) {
269 current_process = process; 271 current_process = process;
270 if (process == nullptr) {
271 return;
272 }
273
274 const u32 core_id = GetCurrentHostThreadID();
275 if (core_id < Core::Hardware::NUM_CPU_CORES) {
276 system.Memory().SetCurrentPageTable(*process, core_id);
277 }
278 } 272 }
279 273
280 static inline thread_local u32 host_thread_id = UINT32_MAX; 274 static inline thread_local u32 host_thread_id = UINT32_MAX;
@@ -1079,13 +1073,11 @@ void KernelCore::ExceptionalExit() {
1079} 1073}
1080 1074
1081void KernelCore::EnterSVCProfile() { 1075void KernelCore::EnterSVCProfile() {
1082 std::size_t core = impl->GetCurrentHostThreadID(); 1076 impl->svc_ticks[CurrentPhysicalCoreIndex()] = MicroProfileEnter(MICROPROFILE_TOKEN(Kernel_SVC));
1083 impl->svc_ticks[core] = MicroProfileEnter(MICROPROFILE_TOKEN(Kernel_SVC));
1084} 1077}
1085 1078
1086void KernelCore::ExitSVCProfile() { 1079void KernelCore::ExitSVCProfile() {
1087 std::size_t core = impl->GetCurrentHostThreadID(); 1080 MicroProfileLeave(MICROPROFILE_TOKEN(Kernel_SVC), impl->svc_ticks[CurrentPhysicalCoreIndex()]);
1088 MicroProfileLeave(MICROPROFILE_TOKEN(Kernel_SVC), impl->svc_ticks[core]);
1089} 1081}
1090 1082
1091std::weak_ptr<Kernel::ServiceThread> KernelCore::CreateServiceThread(const std::string& name) { 1083std::weak_ptr<Kernel::ServiceThread> KernelCore::CreateServiceThread(const std::string& name) {