diff options
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 79 |
1 files changed, 16 insertions, 63 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 1fd4ba5d2..e441c5bc6 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -105,7 +105,7 @@ struct KernelCore::Impl { | |||
| 105 | void Initialize(KernelCore& kernel) { | 105 | void Initialize(KernelCore& kernel) { |
| 106 | Shutdown(); | 106 | Shutdown(); |
| 107 | 107 | ||
| 108 | InitializeResourceLimits(kernel); | 108 | InitializeSystemResourceLimit(kernel); |
| 109 | InitializeThreads(); | 109 | InitializeThreads(); |
| 110 | InitializeTimers(); | 110 | InitializeTimers(); |
| 111 | } | 111 | } |
| @@ -118,7 +118,7 @@ struct KernelCore::Impl { | |||
| 118 | process_list.clear(); | 118 | process_list.clear(); |
| 119 | current_process = nullptr; | 119 | current_process = nullptr; |
| 120 | 120 | ||
| 121 | resource_limits.fill(nullptr); | 121 | system_resource_limit = nullptr; |
| 122 | 122 | ||
| 123 | thread_wakeup_callback_handle_table.Clear(); | 123 | thread_wakeup_callback_handle_table.Clear(); |
| 124 | thread_wakeup_event_type = nullptr; | 124 | thread_wakeup_event_type = nullptr; |
| @@ -129,63 +129,17 @@ struct KernelCore::Impl { | |||
| 129 | named_ports.clear(); | 129 | named_ports.clear(); |
| 130 | } | 130 | } |
| 131 | 131 | ||
| 132 | void InitializeResourceLimits(KernelCore& kernel) { | 132 | // Creates the default system resource limit |
| 133 | // Create the four resource limits that the system uses | 133 | void InitializeSystemResourceLimit(KernelCore& kernel) { |
| 134 | // Create the APPLICATION resource limit | 134 | system_resource_limit = ResourceLimit::Create(kernel, "System"); |
| 135 | SharedPtr<ResourceLimit> resource_limit = ResourceLimit::Create(kernel, "Applications"); | 135 | |
| 136 | resource_limit->max_priority = 0x18; | 136 | // If setting the default system values fails, then something seriously wrong has occurred. |
| 137 | resource_limit->max_commit = 0x4000000; | 137 | ASSERT(system_resource_limit->SetLimitValue(ResourceType::PhysicalMemory, 0x200000000) |
| 138 | resource_limit->max_threads = 0x20; | 138 | .IsSuccess()); |
| 139 | resource_limit->max_events = 0x20; | 139 | ASSERT(system_resource_limit->SetLimitValue(ResourceType::Threads, 800).IsSuccess()); |
| 140 | resource_limit->max_mutexes = 0x20; | 140 | ASSERT(system_resource_limit->SetLimitValue(ResourceType::Events, 700).IsSuccess()); |
| 141 | resource_limit->max_semaphores = 0x8; | 141 | ASSERT(system_resource_limit->SetLimitValue(ResourceType::TransferMemory, 200).IsSuccess()); |
| 142 | resource_limit->max_timers = 0x8; | 142 | ASSERT(system_resource_limit->SetLimitValue(ResourceType::Sessions, 900).IsSuccess()); |
| 143 | resource_limit->max_shared_mems = 0x10; | ||
| 144 | resource_limit->max_address_arbiters = 0x2; | ||
| 145 | resource_limit->max_cpu_time = 0x1E; | ||
| 146 | resource_limits[static_cast<u8>(ResourceLimitCategory::APPLICATION)] = resource_limit; | ||
| 147 | |||
| 148 | // Create the SYS_APPLET resource limit | ||
| 149 | resource_limit = ResourceLimit::Create(kernel, "System Applets"); | ||
| 150 | resource_limit->max_priority = 0x4; | ||
| 151 | resource_limit->max_commit = 0x5E00000; | ||
| 152 | resource_limit->max_threads = 0x1D; | ||
| 153 | resource_limit->max_events = 0xB; | ||
| 154 | resource_limit->max_mutexes = 0x8; | ||
| 155 | resource_limit->max_semaphores = 0x4; | ||
| 156 | resource_limit->max_timers = 0x4; | ||
| 157 | resource_limit->max_shared_mems = 0x8; | ||
| 158 | resource_limit->max_address_arbiters = 0x3; | ||
| 159 | resource_limit->max_cpu_time = 0x2710; | ||
| 160 | resource_limits[static_cast<u8>(ResourceLimitCategory::SYS_APPLET)] = resource_limit; | ||
| 161 | |||
| 162 | // Create the LIB_APPLET resource limit | ||
| 163 | resource_limit = ResourceLimit::Create(kernel, "Library Applets"); | ||
| 164 | resource_limit->max_priority = 0x4; | ||
| 165 | resource_limit->max_commit = 0x600000; | ||
| 166 | resource_limit->max_threads = 0xE; | ||
| 167 | resource_limit->max_events = 0x8; | ||
| 168 | resource_limit->max_mutexes = 0x8; | ||
| 169 | resource_limit->max_semaphores = 0x4; | ||
| 170 | resource_limit->max_timers = 0x4; | ||
| 171 | resource_limit->max_shared_mems = 0x8; | ||
| 172 | resource_limit->max_address_arbiters = 0x1; | ||
| 173 | resource_limit->max_cpu_time = 0x2710; | ||
| 174 | resource_limits[static_cast<u8>(ResourceLimitCategory::LIB_APPLET)] = resource_limit; | ||
| 175 | |||
| 176 | // Create the OTHER resource limit | ||
| 177 | resource_limit = ResourceLimit::Create(kernel, "Others"); | ||
| 178 | resource_limit->max_priority = 0x4; | ||
| 179 | resource_limit->max_commit = 0x2180000; | ||
| 180 | resource_limit->max_threads = 0xE1; | ||
| 181 | resource_limit->max_events = 0x108; | ||
| 182 | resource_limit->max_mutexes = 0x25; | ||
| 183 | resource_limit->max_semaphores = 0x43; | ||
| 184 | resource_limit->max_timers = 0x2C; | ||
| 185 | resource_limit->max_shared_mems = 0x1F; | ||
| 186 | resource_limit->max_address_arbiters = 0x2D; | ||
| 187 | resource_limit->max_cpu_time = 0x3E8; | ||
| 188 | resource_limits[static_cast<u8>(ResourceLimitCategory::OTHER)] = resource_limit; | ||
| 189 | } | 143 | } |
| 190 | 144 | ||
| 191 | void InitializeThreads() { | 145 | void InitializeThreads() { |
| @@ -208,7 +162,7 @@ struct KernelCore::Impl { | |||
| 208 | std::vector<SharedPtr<Process>> process_list; | 162 | std::vector<SharedPtr<Process>> process_list; |
| 209 | Process* current_process = nullptr; | 163 | Process* current_process = nullptr; |
| 210 | 164 | ||
| 211 | std::array<SharedPtr<ResourceLimit>, 4> resource_limits; | 165 | SharedPtr<ResourceLimit> system_resource_limit; |
| 212 | 166 | ||
| 213 | /// The event type of the generic timer callback event | 167 | /// The event type of the generic timer callback event |
| 214 | CoreTiming::EventType* timer_callback_event_type = nullptr; | 168 | CoreTiming::EventType* timer_callback_event_type = nullptr; |
| @@ -239,9 +193,8 @@ void KernelCore::Shutdown() { | |||
| 239 | impl->Shutdown(); | 193 | impl->Shutdown(); |
| 240 | } | 194 | } |
| 241 | 195 | ||
| 242 | SharedPtr<ResourceLimit> KernelCore::ResourceLimitForCategory( | 196 | SharedPtr<ResourceLimit> KernelCore::GetSystemResourceLimit() const { |
| 243 | ResourceLimitCategory category) const { | 197 | return impl->system_resource_limit; |
| 244 | return impl->resource_limits.at(static_cast<std::size_t>(category)); | ||
| 245 | } | 198 | } |
| 246 | 199 | ||
| 247 | SharedPtr<Thread> KernelCore::RetrieveThreadFromWakeupCallbackHandleTable(Handle handle) const { | 200 | SharedPtr<Thread> KernelCore::RetrieveThreadFromWakeupCallbackHandleTable(Handle handle) const { |