mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-22 10:51:50 -05:00
Merge pull request #6197 from ameerj/kreslimit-cleanup
k_resource_limit: Cleanup of member variables/headers
This commit is contained in:
commit
eedbe8351c
4 changed files with 13 additions and 21 deletions
|
@ -2,21 +2,16 @@
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
// This file references various implementation details from Atmosphere, an open-source firmware for
|
|
||||||
// the Nintendo Switch. Copyright 2018-2020 Atmosphere-NX.
|
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
#include "core/core.h"
|
|
||||||
#include "core/core_timing.h"
|
#include "core/core_timing.h"
|
||||||
#include "core/core_timing_util.h"
|
|
||||||
#include "core/hle/kernel/k_resource_limit.h"
|
#include "core/hle/kernel/k_resource_limit.h"
|
||||||
#include "core/hle/kernel/svc_results.h"
|
#include "core/hle/kernel/svc_results.h"
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
constexpr s64 DefaultTimeout = 10000000000; // 10 seconds
|
constexpr s64 DefaultTimeout = 10000000000; // 10 seconds
|
||||||
|
|
||||||
KResourceLimit::KResourceLimit(KernelCore& kernel, Core::System& system)
|
KResourceLimit::KResourceLimit(KernelCore& kernel, const Core::Timing::CoreTiming& core_timing_)
|
||||||
: Object{kernel}, lock{kernel}, cond_var{kernel}, kernel{kernel}, system(system) {}
|
: Object{kernel}, lock{kernel}, cond_var{kernel}, core_timing(core_timing_) {}
|
||||||
KResourceLimit::~KResourceLimit() = default;
|
KResourceLimit::~KResourceLimit() = default;
|
||||||
|
|
||||||
s64 KResourceLimit::GetLimitValue(LimitableResource which) const {
|
s64 KResourceLimit::GetLimitValue(LimitableResource which) const {
|
||||||
|
@ -83,7 +78,7 @@ ResultCode KResourceLimit::SetLimitValue(LimitableResource which, s64 value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KResourceLimit::Reserve(LimitableResource which, s64 value) {
|
bool KResourceLimit::Reserve(LimitableResource which, s64 value) {
|
||||||
return Reserve(which, value, system.CoreTiming().GetGlobalTimeNs().count() + DefaultTimeout);
|
return Reserve(which, value, core_timing.GetGlobalTimeNs().count() + DefaultTimeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KResourceLimit::Reserve(LimitableResource which, s64 value, s64 timeout) {
|
bool KResourceLimit::Reserve(LimitableResource which, s64 value, s64 timeout) {
|
||||||
|
@ -114,7 +109,7 @@ bool KResourceLimit::Reserve(LimitableResource which, s64 value, s64 timeout) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_hints[index] + value <= limit_values[index] &&
|
if (current_hints[index] + value <= limit_values[index] &&
|
||||||
(timeout < 0 || system.CoreTiming().GetGlobalTimeNs().count() < timeout)) {
|
(timeout < 0 || core_timing.GetGlobalTimeNs().count() < timeout)) {
|
||||||
waiter_count++;
|
waiter_count++;
|
||||||
cond_var.Wait(&lock, timeout);
|
cond_var.Wait(&lock, timeout);
|
||||||
waiter_count--;
|
waiter_count--;
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
// This file references various implementation details from Atmosphere, an open-source firmware for
|
|
||||||
// the Nintendo Switch. Copyright 2018-2020 Atmosphere-NX.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
@ -15,8 +12,8 @@
|
||||||
|
|
||||||
union ResultCode;
|
union ResultCode;
|
||||||
|
|
||||||
namespace Core {
|
namespace Core::Timing {
|
||||||
class System;
|
class CoreTiming;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
@ -37,7 +34,7 @@ constexpr bool IsValidResourceType(LimitableResource type) {
|
||||||
|
|
||||||
class KResourceLimit final : public Object {
|
class KResourceLimit final : public Object {
|
||||||
public:
|
public:
|
||||||
explicit KResourceLimit(KernelCore& kernel, Core::System& system);
|
explicit KResourceLimit(KernelCore& kernel, const Core::Timing::CoreTiming& core_timing_);
|
||||||
~KResourceLimit();
|
~KResourceLimit();
|
||||||
|
|
||||||
s64 GetLimitValue(LimitableResource which) const;
|
s64 GetLimitValue(LimitableResource which) const;
|
||||||
|
@ -75,7 +72,6 @@ private:
|
||||||
mutable KLightLock lock;
|
mutable KLightLock lock;
|
||||||
s32 waiter_count{};
|
s32 waiter_count{};
|
||||||
KLightConditionVariable cond_var;
|
KLightConditionVariable cond_var;
|
||||||
KernelCore& kernel;
|
const Core::Timing::CoreTiming& core_timing;
|
||||||
Core::System& system;
|
|
||||||
};
|
};
|
||||||
} // namespace Kernel
|
} // namespace Kernel
|
||||||
|
|
|
@ -72,7 +72,7 @@ struct KernelCore::Impl {
|
||||||
KMemoryLayout memory_layout;
|
KMemoryLayout memory_layout;
|
||||||
DeriveInitialMemoryLayout(memory_layout);
|
DeriveInitialMemoryLayout(memory_layout);
|
||||||
InitializeMemoryLayout(memory_layout);
|
InitializeMemoryLayout(memory_layout);
|
||||||
InitializeSystemResourceLimit(kernel, system, memory_layout);
|
InitializeSystemResourceLimit(kernel, system.CoreTiming(), memory_layout);
|
||||||
InitializeSlabHeaps();
|
InitializeSlabHeaps();
|
||||||
InitializeSchedulers();
|
InitializeSchedulers();
|
||||||
InitializeSuspendThreads();
|
InitializeSuspendThreads();
|
||||||
|
@ -142,9 +142,10 @@ struct KernelCore::Impl {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates the default system resource limit
|
// Creates the default system resource limit
|
||||||
void InitializeSystemResourceLimit(KernelCore& kernel, Core::System& system,
|
void InitializeSystemResourceLimit(KernelCore& kernel,
|
||||||
|
const Core::Timing::CoreTiming& core_timing,
|
||||||
const KMemoryLayout& memory_layout) {
|
const KMemoryLayout& memory_layout) {
|
||||||
system_resource_limit = std::make_shared<KResourceLimit>(kernel, system);
|
system_resource_limit = std::make_shared<KResourceLimit>(kernel, core_timing);
|
||||||
const auto [total_size, kernel_size] = memory_layout.GetTotalAndKernelMemorySizes();
|
const auto [total_size, kernel_size] = memory_layout.GetTotalAndKernelMemorySizes();
|
||||||
|
|
||||||
// If setting the default system values fails, then something seriously wrong has occurred.
|
// If setting the default system values fails, then something seriously wrong has occurred.
|
||||||
|
|
|
@ -2156,7 +2156,7 @@ static ResultCode CreateResourceLimit(Core::System& system, Handle* out_handle)
|
||||||
LOG_DEBUG(Kernel_SVC, "called");
|
LOG_DEBUG(Kernel_SVC, "called");
|
||||||
|
|
||||||
auto& kernel = system.Kernel();
|
auto& kernel = system.Kernel();
|
||||||
auto resource_limit = std::make_shared<KResourceLimit>(kernel, system);
|
auto resource_limit = std::make_shared<KResourceLimit>(kernel, system.CoreTiming());
|
||||||
|
|
||||||
auto* const current_process = kernel.CurrentProcess();
|
auto* const current_process = kernel.CurrentProcess();
|
||||||
ASSERT(current_process != nullptr);
|
ASSERT(current_process != nullptr);
|
||||||
|
|
Loading…
Reference in a new issue