1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-24 04:42:11 +00:00
Atmosphere/libraries/libmesosphere/include/mesosphere/kern_k_resource_limit.hpp

58 lines
2.5 KiB
C++
Raw Normal View History

2020-02-06 13:34:38 +00:00
/*
* Copyright (c) 2018-2020 Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <mesosphere/kern_common.hpp>
#include <mesosphere/kern_k_auto_object.hpp>
#include <mesosphere/kern_slab_helpers.hpp>
#include <mesosphere/kern_k_light_lock.hpp>
#include <mesosphere/kern_k_light_condition_variable.hpp>
namespace ams::kern {
class KResourceLimit final : public KAutoObjectWithSlabHeapAndContainer<KResourceLimit, KAutoObjectWithList> {
MESOSPHERE_AUTOOBJECT_TRAITS(KResourceLimit, KAutoObject);
private:
s64 limit_values[ams::svc::LimitableResource_Count];
s64 current_values[ams::svc::LimitableResource_Count];
s64 current_hints[ams::svc::LimitableResource_Count];
2020-12-01 14:07:18 +00:00
s64 peak_values[ams::svc::LimitableResource_Count];
2020-02-06 13:34:38 +00:00
mutable KLightLock lock;
s32 waiter_count;
KLightConditionVariable cond_var;
public:
2020-12-01 14:07:18 +00:00
constexpr ALWAYS_INLINE KResourceLimit() : limit_values(), current_values(), current_hints(), peak_values(), lock(), waiter_count(), cond_var() { /* ... */ }
2020-02-06 13:34:38 +00:00
virtual ~KResourceLimit() { /* ... */ }
2020-08-21 01:29:10 +01:00
static void PostDestroy(uintptr_t arg) { MESOSPHERE_UNUSED(arg); /* ... */ }
2020-02-06 13:34:38 +00:00
void Initialize();
virtual void Finalize() override;
s64 GetLimitValue(ams::svc::LimitableResource which) const;
s64 GetCurrentValue(ams::svc::LimitableResource which) const;
2020-12-01 14:07:18 +00:00
s64 GetPeakValue(ams::svc::LimitableResource which) const;
2020-02-06 13:34:38 +00:00
s64 GetFreeValue(ams::svc::LimitableResource which) const;
Result SetLimitValue(ams::svc::LimitableResource which, s64 value);
bool Reserve(ams::svc::LimitableResource which, s64 value);
bool Reserve(ams::svc::LimitableResource which, s64 value, s64 timeout);
void Release(ams::svc::LimitableResource which, s64 value);
void Release(ams::svc::LimitableResource which, s64 value, s64 hint);
};
}