summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/resource_limit.cpp
diff options
context:
space:
mode:
authorChloe Marcec <dmarcecguzman@gmail.com>2021-01-30 10:40:49 +0100
committerChloe Marcec <dmarcecguzman@gmail.com>2021-01-30 10:40:49 +0100
commit3be1a565f895d5399a6c1f6d0997dc528537fe86 (patch)
treed5c94d86c78bdcf7a73785b9c28b0c1f5fc0c6af /src/core/hle/kernel/resource_limit.cpp
parentMerge pull request #5779 from bunnei/kthread-rewrite (diff)
downloadyuzu-3be1a565f895d5399a6c1f6d0997dc528537fe86.tar
yuzu-3be1a565f895d5399a6c1f6d0997dc528537fe86.tar.gz
yuzu-3be1a565f895d5399a6c1f6d0997dc528537fe86.tar.bz2
yuzu-3be1a565f895d5399a6c1f6d0997dc528537fe86.tar.lz
yuzu-3be1a565f895d5399a6c1f6d0997dc528537fe86.tar.xz
yuzu-3be1a565f895d5399a6c1f6d0997dc528537fe86.tar.zst
yuzu-3be1a565f895d5399a6c1f6d0997dc528537fe86.zip
Diffstat (limited to 'src/core/hle/kernel/resource_limit.cpp')
-rw-r--r--src/core/hle/kernel/resource_limit.cpp73
1 files changed, 0 insertions, 73 deletions
diff --git a/src/core/hle/kernel/resource_limit.cpp b/src/core/hle/kernel/resource_limit.cpp
deleted file mode 100644
index 7bf50339d..000000000
--- a/src/core/hle/kernel/resource_limit.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2015 Citra Emulator Project
-// Licensed under GPLv2 or any later version
-// Refer to the license.txt file included.
-
-#include "core/hle/kernel/errors.h"
-#include "core/hle/kernel/resource_limit.h"
-#include "core/hle/result.h"
-
-namespace Kernel {
-namespace {
-constexpr std::size_t ResourceTypeToIndex(ResourceType type) {
- return static_cast<std::size_t>(type);
-}
-} // Anonymous namespace
-
-ResourceLimit::ResourceLimit(KernelCore& kernel) : Object{kernel} {}
-ResourceLimit::~ResourceLimit() = default;
-
-bool ResourceLimit::Reserve(ResourceType resource, s64 amount) {
- return Reserve(resource, amount, 10000000000);
-}
-
-bool ResourceLimit::Reserve(ResourceType resource, s64 amount, u64 timeout) {
- const std::size_t index{ResourceTypeToIndex(resource)};
-
- s64 new_value = current[index] + amount;
- if (new_value > limit[index] && available[index] + amount <= limit[index]) {
- // TODO(bunnei): This is wrong for multicore, we should wait the calling thread for timeout
- new_value = current[index] + amount;
- }
-
- if (new_value <= limit[index]) {
- current[index] = new_value;
- return true;
- }
- return false;
-}
-
-void ResourceLimit::Release(ResourceType resource, u64 amount) {
- Release(resource, amount, amount);
-}
-
-void ResourceLimit::Release(ResourceType resource, u64 used_amount, u64 available_amount) {
- const std::size_t index{ResourceTypeToIndex(resource)};
-
- current[index] -= used_amount;
- available[index] -= available_amount;
-}
-
-std::shared_ptr<ResourceLimit> ResourceLimit::Create(KernelCore& kernel) {
- return std::make_shared<ResourceLimit>(kernel);
-}
-
-s64 ResourceLimit::GetCurrentResourceValue(ResourceType resource) const {
- return limit.at(ResourceTypeToIndex(resource)) - current.at(ResourceTypeToIndex(resource));
-}
-
-s64 ResourceLimit::GetMaxResourceValue(ResourceType resource) const {
- return limit.at(ResourceTypeToIndex(resource));
-}
-
-ResultCode ResourceLimit::SetLimitValue(ResourceType resource, s64 value) {
- const std::size_t index{ResourceTypeToIndex(resource)};
- if (current[index] <= value) {
- limit[index] = value;
- return RESULT_SUCCESS;
- } else {
- LOG_ERROR(Kernel, "Limit value is too large! resource={}, value={}, index={}", resource,
- value, index);
- return ERR_INVALID_STATE;
- }
-}
-} // namespace Kernel