mirror of
https://git.h3cjp.net/H3cJP/yuzu.git
synced 2024-11-15 21:42:58 +00:00
core: hle: kernel: KResourceLimit: Add a helper function for creating a KResourceLimit for a process.
This commit is contained in:
parent
21f5912ec9
commit
c7019db6f4
|
@ -3,6 +3,7 @@
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "common/assert.h"
|
#include "common/assert.h"
|
||||||
|
#include "core/core.h"
|
||||||
#include "core/core_timing.h"
|
#include "core/core_timing.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"
|
||||||
|
@ -151,4 +152,22 @@ void KResourceLimit::Release(LimitableResource which, s64 value, s64 hint) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
KResourceLimit* CreateResourceLimitForProcess(Core::System& system, s64 physical_memory_size) {
|
||||||
|
auto* resource_limit = KResourceLimit::Create(system.Kernel());
|
||||||
|
resource_limit->Initialize(&system.CoreTiming());
|
||||||
|
|
||||||
|
// Initialize default resource limit values.
|
||||||
|
// TODO(bunnei): These values are the system defaults, the limits for service processes are
|
||||||
|
// lower. These should use the correct limit values.
|
||||||
|
|
||||||
|
ASSERT(resource_limit->SetLimitValue(LimitableResource::PhysicalMemory, physical_memory_size)
|
||||||
|
.IsSuccess());
|
||||||
|
ASSERT(resource_limit->SetLimitValue(LimitableResource::Threads, 800).IsSuccess());
|
||||||
|
ASSERT(resource_limit->SetLimitValue(LimitableResource::Events, 900).IsSuccess());
|
||||||
|
ASSERT(resource_limit->SetLimitValue(LimitableResource::TransferMemory, 200).IsSuccess());
|
||||||
|
ASSERT(resource_limit->SetLimitValue(LimitableResource::Sessions, 1133).IsSuccess());
|
||||||
|
|
||||||
|
return resource_limit;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Kernel
|
} // namespace Kernel
|
||||||
|
|
|
@ -67,4 +67,7 @@ private:
|
||||||
KLightConditionVariable cond_var;
|
KLightConditionVariable cond_var;
|
||||||
const Core::Timing::CoreTiming* core_timing{};
|
const Core::Timing::CoreTiming* core_timing{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
KResourceLimit* CreateResourceLimitForProcess(Core::System& system, s64 physical_memory_size);
|
||||||
|
|
||||||
} // namespace Kernel
|
} // namespace Kernel
|
||||||
|
|
Loading…
Reference in a new issue