1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-12-04 17:42:15 +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 m_limit_values[ams::svc::LimitableResource_Count];
s64 m_current_values[ams::svc::LimitableResource_Count];
s64 m_current_hints[ams::svc::LimitableResource_Count];
s64 m_peak_values[ams::svc::LimitableResource_Count];
mutable KLightLock m_lock;
s32 m_waiter_count;
KLightConditionVariable m_cond_var;
2020-02-06 13:34:38 +00:00
public:
constexpr ALWAYS_INLINE KResourceLimit() : m_limit_values(), m_current_values(), m_current_hints(), m_peak_values(), m_lock(), m_waiter_count(), m_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);
};
}