summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel/resource_limit.h
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2018-11-19 18:54:06 +0100
committerLioncash <mathew1800@gmail.com>2018-11-20 00:16:39 +0100
commit5d46038c5cd91504b00b76660212a3a28b244f38 (patch)
tree01e29da6e94c76109225ae27ed92dbfe7973c22d /src/core/hle/kernel/resource_limit.h
parentMerge pull request #1634 from DarkLordZach/better-hid-2 (diff)
downloadyuzu-5d46038c5cd91504b00b76660212a3a28b244f38.tar
yuzu-5d46038c5cd91504b00b76660212a3a28b244f38.tar.gz
yuzu-5d46038c5cd91504b00b76660212a3a28b244f38.tar.bz2
yuzu-5d46038c5cd91504b00b76660212a3a28b244f38.tar.lz
yuzu-5d46038c5cd91504b00b76660212a3a28b244f38.tar.xz
yuzu-5d46038c5cd91504b00b76660212a3a28b244f38.tar.zst
yuzu-5d46038c5cd91504b00b76660212a3a28b244f38.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/resource_limit.h98
1 files changed, 41 insertions, 57 deletions
diff --git a/src/core/hle/kernel/resource_limit.h b/src/core/hle/kernel/resource_limit.h
index 219e49562..bec065543 100644
--- a/src/core/hle/kernel/resource_limit.h
+++ b/src/core/hle/kernel/resource_limit.h
@@ -4,31 +4,25 @@
#pragma once
+#include <array>
#include "common/common_types.h"
#include "core/hle/kernel/object.h"
+union ResultCode;
+
namespace Kernel {
class KernelCore;
-enum class ResourceLimitCategory : u8 {
- APPLICATION = 0,
- SYS_APPLET = 1,
- LIB_APPLET = 2,
- OTHER = 3
-};
-
enum class ResourceType {
- Priority = 0,
- Commit = 1,
- Thread = 2,
- Event = 3,
- Mutex = 4,
- Semaphore = 5,
- Timer = 6,
- SharedMemory = 7,
- AddressArbiter = 8,
- CPUTime = 9,
+ PhysicalMemory,
+ Threads,
+ Events,
+ TransferMemory,
+ Sessions,
+
+ // Used as a count, not an actual type.
+ ResourceTypeCount
};
class ResourceLimit final : public Object {
@@ -55,61 +49,51 @@ public:
* @param resource Requested resource type
* @returns The current value of the resource type
*/
- s32 GetCurrentResourceValue(ResourceType resource) const;
+ s64 GetCurrentResourceValue(ResourceType resource) const;
/**
* Gets the max value for the specified resource.
* @param resource Requested resource type
* @returns The max value of the resource type
*/
- u32 GetMaxResourceValue(ResourceType resource) const;
-
- /// Name of resource limit object.
- std::string name;
-
- /// Max thread priority that a process in this category can create
- s32 max_priority = 0;
-
- /// Max memory that processes in this category can use
- s32 max_commit = 0;
+ s64 GetMaxResourceValue(ResourceType resource) const;
- ///< Max number of objects that can be collectively created by the processes in this category
- s32 max_threads = 0;
- s32 max_events = 0;
- s32 max_mutexes = 0;
- s32 max_semaphores = 0;
- s32 max_timers = 0;
- s32 max_shared_mems = 0;
- s32 max_address_arbiters = 0;
+ /**
+ * Sets the limit value for a given resource type.
+ *
+ * @param resource The resource type to apply the limit to.
+ * @param value The limit to apply to the given resource type.
+ *
+ * @return A result code indicating if setting the limit value
+ * was successful or not.
+ *
+ * @note The supplied limit value *must* be greater than or equal to
+ * the current resource value for the given resource type,
+ * otherwise ERR_INVALID_STATE will be returned.
+ */
+ ResultCode SetLimitValue(ResourceType resource, s64 value);
- /// Max CPU time that the processes in this category can utilize
- s32 max_cpu_time = 0;
+private:
+ explicit ResourceLimit(KernelCore& kernel);
+ ~ResourceLimit() override;
- // TODO(Subv): Increment these in their respective Kernel::T::Create functions, keeping in mind
- // that APPLICATION resource limits should not be affected by the objects created by service
- // modules.
+ // TODO(Subv): Increment resource limit current values in their respective Kernel::T::Create
+ // functions
+ //
// Currently we have no way of distinguishing if a Create was called by the running application,
// or by a service module. Approach this once we have separated the service modules into their
// own processes
- /// Current memory that the processes in this category are using
- s32 current_commit = 0;
+ using ResourceArray =
+ std::array<s64, static_cast<std::size_t>(ResourceType::ResourceTypeCount)>;
- ///< Current number of objects among all processes in this category
- s32 current_threads = 0;
- s32 current_events = 0;
- s32 current_mutexes = 0;
- s32 current_semaphores = 0;
- s32 current_timers = 0;
- s32 current_shared_mems = 0;
- s32 current_address_arbiters = 0;
+ /// Maximum values a resource type may reach.
+ ResourceArray limits{};
+ /// Current resource limit values.
+ ResourceArray values{};
- /// Current CPU time that the processes in this category are utilizing
- s32 current_cpu_time = 0;
-
-private:
- explicit ResourceLimit(KernelCore& kernel);
- ~ResourceLimit() override;
+ /// Name of resource limit object.
+ std::string name;
};
} // namespace Kernel