summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChloe Marcec <dmarcecguzman@gmail.com>2021-02-03 02:55:16 +0100
committerChloe Marcec <dmarcecguzman@gmail.com>2021-02-03 02:55:16 +0100
commit2c6e94049362f592bfb578a2b078f6f3067ed0d8 (patch)
tree513aa888bfe87637e8736165b35b852de079b02f
parentCompile error (diff)
downloadyuzu-2c6e94049362f592bfb578a2b078f6f3067ed0d8.tar
yuzu-2c6e94049362f592bfb578a2b078f6f3067ed0d8.tar.gz
yuzu-2c6e94049362f592bfb578a2b078f6f3067ed0d8.tar.bz2
yuzu-2c6e94049362f592bfb578a2b078f6f3067ed0d8.tar.lz
yuzu-2c6e94049362f592bfb578a2b078f6f3067ed0d8.tar.xz
yuzu-2c6e94049362f592bfb578a2b078f6f3067ed0d8.tar.zst
yuzu-2c6e94049362f592bfb578a2b078f6f3067ed0d8.zip
-rw-r--r--src/core/hle/kernel/k_resource_limit.h10
-rw-r--r--src/core/hle/kernel/k_thread.cpp2
-rw-r--r--src/core/hle/kernel/kernel.cpp16
-rw-r--r--src/core/hle/kernel/memory/page_table.cpp11
-rw-r--r--src/core/hle/kernel/process.cpp18
-rw-r--r--src/core/hle/kernel/svc.cpp8
6 files changed, 29 insertions, 36 deletions
diff --git a/src/core/hle/kernel/k_resource_limit.h b/src/core/hle/kernel/k_resource_limit.h
index 6b3437ea6..58ae456f1 100644
--- a/src/core/hle/kernel/k_resource_limit.h
+++ b/src/core/hle/kernel/k_resource_limit.h
@@ -22,11 +22,11 @@ class System;
namespace Kernel {
class KernelCore;
enum class LimitableResource : u32 {
- PhysicalMemoryMax = 0,
- ThreadCountMax = 1,
- EventCountMax = 2,
- TransferMemoryCountMax = 3,
- SessionCountMax = 4,
+ PhysicalMemory = 0,
+ Threads = 1,
+ Events = 2,
+ TransferMemory = 3,
+ Sessions = 4,
Count,
};
diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp
index 38fd8e500..b59259c4f 100644
--- a/src/core/hle/kernel/k_thread.cpp
+++ b/src/core/hle/kernel/k_thread.cpp
@@ -247,7 +247,7 @@ void KThread::Finalize() {
// Decrement the parent process's thread count.
if (parent != nullptr) {
parent->DecrementThreadCount();
- parent->GetResourceLimit()->Release(LimitableResource::ThreadCountMax, 1);
+ parent->GetResourceLimit()->Release(LimitableResource::Threads, 1);
}
}
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp
index c66a993c2..b20c2d13a 100644
--- a/src/core/hle/kernel/kernel.cpp
+++ b/src/core/hle/kernel/kernel.cpp
@@ -135,19 +135,15 @@ struct KernelCore::Impl {
system_resource_limit = std::make_shared<KResourceLimit>(kernel, system);
// If setting the default system values fails, then something seriously wrong has occurred.
- ASSERT(
- system_resource_limit->SetLimitValue(LimitableResource::PhysicalMemoryMax, 0x100000000)
- .IsSuccess());
- ASSERT(system_resource_limit->SetLimitValue(LimitableResource::ThreadCountMax, 800)
+ ASSERT(system_resource_limit->SetLimitValue(LimitableResource::PhysicalMemory, 0x100000000)
.IsSuccess());
- ASSERT(system_resource_limit->SetLimitValue(LimitableResource::EventCountMax, 700)
- .IsSuccess());
- ASSERT(system_resource_limit->SetLimitValue(LimitableResource::TransferMemoryCountMax, 200)
- .IsSuccess());
- ASSERT(system_resource_limit->SetLimitValue(LimitableResource::SessionCountMax, 900)
+ ASSERT(system_resource_limit->SetLimitValue(LimitableResource::Threads, 800).IsSuccess());
+ ASSERT(system_resource_limit->SetLimitValue(LimitableResource::Events, 700).IsSuccess());
+ ASSERT(system_resource_limit->SetLimitValue(LimitableResource::TransferMemory, 200)
.IsSuccess());
+ ASSERT(system_resource_limit->SetLimitValue(LimitableResource::Sessions, 900).IsSuccess());
- if (!system_resource_limit->Reserve(LimitableResource::PhysicalMemoryMax, 0x60000)) {
+ if (!system_resource_limit->Reserve(LimitableResource::PhysicalMemory, 0x60000)) {
UNREACHABLE();
}
}
diff --git a/src/core/hle/kernel/memory/page_table.cpp b/src/core/hle/kernel/memory/page_table.cpp
index d8c7d980a..7de91c768 100644
--- a/src/core/hle/kernel/memory/page_table.cpp
+++ b/src/core/hle/kernel/memory/page_table.cpp
@@ -413,8 +413,8 @@ ResultCode PageTable::MapPhysicalMemory(VAddr addr, std::size_t size) {
const std::size_t remaining_size{size - mapped_size};
const std::size_t remaining_pages{remaining_size / PageSize};
- if (process->GetResourceLimit() && !process->GetResourceLimit()->Reserve(
- LimitableResource::PhysicalMemoryMax, remaining_size)) {
+ if (process->GetResourceLimit() &&
+ !process->GetResourceLimit()->Reserve(LimitableResource::PhysicalMemory, remaining_size)) {
return ERR_RESOURCE_LIMIT_EXCEEDED;
}
@@ -422,8 +422,7 @@ ResultCode PageTable::MapPhysicalMemory(VAddr addr, std::size_t size) {
{
auto block_guard = detail::ScopeExit([&] {
system.Kernel().MemoryManager().Free(page_linked_list, remaining_pages, memory_pool);
- process->GetResourceLimit()->Release(LimitableResource::PhysicalMemoryMax,
- remaining_size);
+ process->GetResourceLimit()->Release(LimitableResource::PhysicalMemory, remaining_size);
});
CASCADE_CODE(system.Kernel().MemoryManager().Allocate(page_linked_list, remaining_pages,
@@ -475,7 +474,7 @@ ResultCode PageTable::UnmapPhysicalMemory(VAddr addr, std::size_t size) {
CASCADE_CODE(UnmapMemory(addr, size));
auto process{system.Kernel().CurrentProcess()};
- process->GetResourceLimit()->Release(LimitableResource::PhysicalMemoryMax, mapped_size);
+ process->GetResourceLimit()->Release(LimitableResource::PhysicalMemory, mapped_size);
physical_memory_usage -= mapped_size;
return RESULT_SUCCESS;
@@ -784,7 +783,7 @@ ResultVal<VAddr> PageTable::SetHeapSize(std::size_t size) {
auto process{system.Kernel().CurrentProcess()};
if (process->GetResourceLimit() && delta != 0 &&
- !process->GetResourceLimit()->Reserve(LimitableResource::PhysicalMemoryMax, delta)) {
+ !process->GetResourceLimit()->Reserve(LimitableResource::PhysicalMemory, delta)) {
return ERR_RESOURCE_LIMIT_EXCEEDED;
}
diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp
index 9efcb95f3..afdb27c54 100644
--- a/src/core/hle/kernel/process.cpp
+++ b/src/core/hle/kernel/process.cpp
@@ -154,7 +154,7 @@ void Process::DecrementThreadCount() {
}
u64 Process::GetTotalPhysicalMemoryAvailable() const {
- const u64 capacity{resource_limit->GetFreeValue(LimitableResource::PhysicalMemoryMax) +
+ const u64 capacity{resource_limit->GetFreeValue(LimitableResource::PhysicalMemory) +
page_table->GetTotalHeapSize() + GetSystemResourceSize() + image_size +
main_thread_stack_size};
@@ -308,13 +308,13 @@ ResultCode Process::LoadFromMetadata(const FileSys::ProgramMetadata& metadata,
// Set initial resource limits
resource_limit->SetLimitValue(
- LimitableResource::PhysicalMemoryMax,
+ LimitableResource::PhysicalMemory,
kernel.MemoryManager().GetSize(Memory::MemoryManager::Pool::Application));
- resource_limit->SetLimitValue(LimitableResource::ThreadCountMax, 608);
- resource_limit->SetLimitValue(LimitableResource::EventCountMax, 700);
- resource_limit->SetLimitValue(LimitableResource::TransferMemoryCountMax, 128);
- resource_limit->SetLimitValue(LimitableResource::SessionCountMax, 894);
- ASSERT(resource_limit->Reserve(LimitableResource::PhysicalMemoryMax, code_size));
+ resource_limit->SetLimitValue(LimitableResource::Threads, 608);
+ resource_limit->SetLimitValue(LimitableResource::Events, 700);
+ resource_limit->SetLimitValue(LimitableResource::TransferMemory, 128);
+ resource_limit->SetLimitValue(LimitableResource::Sessions, 894);
+ ASSERT(resource_limit->Reserve(LimitableResource::PhysicalMemory, code_size));
// Create TLS region
tls_region_address = CreateTLSRegion();
@@ -331,8 +331,8 @@ void Process::Run(s32 main_thread_priority, u64 stack_size) {
ChangeStatus(ProcessStatus::Running);
SetupMainThread(system, *this, main_thread_priority, main_thread_stack_top);
- resource_limit->Reserve(LimitableResource::ThreadCountMax, 1);
- resource_limit->Reserve(LimitableResource::PhysicalMemoryMax, main_thread_stack_size);
+ resource_limit->Reserve(LimitableResource::Threads, 1);
+ resource_limit->Reserve(LimitableResource::PhysicalMemory, main_thread_stack_size);
}
void Process::PrepareForTermination() {
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index d89873104..74eb90100 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -312,8 +312,7 @@ static ResultCode ConnectToNamedPort(Core::System& system, Handle* out_handle,
return ERR_NOT_FOUND;
}
- ASSERT(kernel.CurrentProcess()->GetResourceLimit()->Reserve(LimitableResource::SessionCountMax,
- 1));
+ ASSERT(kernel.CurrentProcess()->GetResourceLimit()->Reserve(LimitableResource::Sessions, 1));
auto client_port = it->second;
@@ -1451,9 +1450,8 @@ static ResultCode CreateThread(Core::System& system, Handle* out_handle, VAddr e
Svc::ResultInvalidPriority);
R_UNLESS(process.CheckThreadPriority(priority), Svc::ResultInvalidPriority);
- ASSERT(process.GetResourceLimit()->Reserve(LimitableResource::ThreadCountMax, 1,
- system.CoreTiming().GetGlobalTimeNs().count() +
- 100000000));
+ ASSERT(process.GetResourceLimit()->Reserve(
+ LimitableResource::Threads, 1, system.CoreTiming().GetGlobalTimeNs().count() + 100000000));
std::shared_ptr<KThread> thread;
{