summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/kernel.cpp
diff options
context:
space:
mode:
authorGravatar Chloe Marcec2021-01-30 20:40:49 +1100
committerGravatar Chloe Marcec2021-01-30 20:40:49 +1100
commit3be1a565f895d5399a6c1f6d0997dc528537fe86 (patch)
treed5c94d86c78bdcf7a73785b9c28b0c1f5fc0c6af /src/core/hle/kernel/kernel.cpp
parentMerge pull request #5779 from bunnei/kthread-rewrite (diff)
downloadyuzu-3be1a565f895d5399a6c1f6d0997dc528537fe86.tar.gz
yuzu-3be1a565f895d5399a6c1f6d0997dc528537fe86.tar.xz
yuzu-3be1a565f895d5399a6c1f6d0997dc528537fe86.zip
kernel: Rewrite resource limit to be more accurate
Matches closer to hardware
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
-rw-r--r--src/core/hle/kernel/kernel.cpp30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index df309d523..c66a993c2 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -28,6 +28,7 @@
28#include "core/hle/kernel/client_port.h" 28#include "core/hle/kernel/client_port.h"
29#include "core/hle/kernel/errors.h" 29#include "core/hle/kernel/errors.h"
30#include "core/hle/kernel/handle_table.h" 30#include "core/hle/kernel/handle_table.h"
31#include "core/hle/kernel/k_resource_limit.h"
31#include "core/hle/kernel/k_scheduler.h" 32#include "core/hle/kernel/k_scheduler.h"
32#include "core/hle/kernel/k_thread.h" 33#include "core/hle/kernel/k_thread.h"
33#include "core/hle/kernel/kernel.h" 34#include "core/hle/kernel/kernel.h"
@@ -36,7 +37,6 @@
36#include "core/hle/kernel/memory/slab_heap.h" 37#include "core/hle/kernel/memory/slab_heap.h"
37#include "core/hle/kernel/physical_core.h" 38#include "core/hle/kernel/physical_core.h"
38#include "core/hle/kernel/process.h" 39#include "core/hle/kernel/process.h"
39#include "core/hle/kernel/resource_limit.h"
40#include "core/hle/kernel/service_thread.h" 40#include "core/hle/kernel/service_thread.h"
41#include "core/hle/kernel/shared_memory.h" 41#include "core/hle/kernel/shared_memory.h"
42#include "core/hle/kernel/time_manager.h" 42#include "core/hle/kernel/time_manager.h"
@@ -66,7 +66,7 @@ struct KernelCore::Impl {
66 is_phantom_mode_for_singlecore = false; 66 is_phantom_mode_for_singlecore = false;
67 67
68 InitializePhysicalCores(); 68 InitializePhysicalCores();
69 InitializeSystemResourceLimit(kernel); 69 InitializeSystemResourceLimit(kernel, system);
70 InitializeMemoryLayout(); 70 InitializeMemoryLayout();
71 InitializePreemption(kernel); 71 InitializePreemption(kernel);
72 InitializeSchedulers(); 72 InitializeSchedulers();
@@ -131,19 +131,23 @@ struct KernelCore::Impl {
131 } 131 }
132 132
133 // Creates the default system resource limit 133 // Creates the default system resource limit
134 void InitializeSystemResourceLimit(KernelCore& kernel) { 134 void InitializeSystemResourceLimit(KernelCore& kernel, Core::System& system) {
135 system_resource_limit = ResourceLimit::Create(kernel); 135 system_resource_limit = std::make_shared<KResourceLimit>(kernel, system);
136 136
137 // If setting the default system values fails, then something seriously wrong has occurred. 137 // If setting the default system values fails, then something seriously wrong has occurred.
138 ASSERT(system_resource_limit->SetLimitValue(ResourceType::PhysicalMemory, 0x100000000) 138 ASSERT(
139 system_resource_limit->SetLimitValue(LimitableResource::PhysicalMemoryMax, 0x100000000)
140 .IsSuccess());
141 ASSERT(system_resource_limit->SetLimitValue(LimitableResource::ThreadCountMax, 800)
142 .IsSuccess());
143 ASSERT(system_resource_limit->SetLimitValue(LimitableResource::EventCountMax, 700)
144 .IsSuccess());
145 ASSERT(system_resource_limit->SetLimitValue(LimitableResource::TransferMemoryCountMax, 200)
146 .IsSuccess());
147 ASSERT(system_resource_limit->SetLimitValue(LimitableResource::SessionCountMax, 900)
139 .IsSuccess()); 148 .IsSuccess());
140 ASSERT(system_resource_limit->SetLimitValue(ResourceType::Threads, 800).IsSuccess());
141 ASSERT(system_resource_limit->SetLimitValue(ResourceType::Events, 700).IsSuccess());
142 ASSERT(system_resource_limit->SetLimitValue(ResourceType::TransferMemory, 200).IsSuccess());
143 ASSERT(system_resource_limit->SetLimitValue(ResourceType::Sessions, 900).IsSuccess());
144 149
145 if (!system_resource_limit->Reserve(ResourceType::PhysicalMemory, 0) || 150 if (!system_resource_limit->Reserve(LimitableResource::PhysicalMemoryMax, 0x60000)) {
146 !system_resource_limit->Reserve(ResourceType::PhysicalMemory, 0x60000)) {
147 UNREACHABLE(); 151 UNREACHABLE();
148 } 152 }
149 } 153 }
@@ -320,7 +324,7 @@ struct KernelCore::Impl {
320 std::unique_ptr<Kernel::GlobalSchedulerContext> global_scheduler_context; 324 std::unique_ptr<Kernel::GlobalSchedulerContext> global_scheduler_context;
321 Kernel::TimeManager time_manager; 325 Kernel::TimeManager time_manager;
322 326
323 std::shared_ptr<ResourceLimit> system_resource_limit; 327 std::shared_ptr<KResourceLimit> system_resource_limit;
324 328
325 std::shared_ptr<Core::Timing::EventType> preemption_event; 329 std::shared_ptr<Core::Timing::EventType> preemption_event;
326 330
@@ -390,7 +394,7 @@ void KernelCore::Shutdown() {
390 impl->Shutdown(); 394 impl->Shutdown();
391} 395}
392 396
393std::shared_ptr<ResourceLimit> KernelCore::GetSystemResourceLimit() const { 397std::shared_ptr<KResourceLimit> KernelCore::GetSystemResourceLimit() const {
394 return impl->system_resource_limit; 398 return impl->system_resource_limit;
395} 399}
396 400