2015-05-12 20:25:15 +00:00
|
|
|
// Copyright 2015 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include <cstring>
|
2017-05-29 23:45:42 +00:00
|
|
|
#include "common/assert.h"
|
2015-05-12 20:25:15 +00:00
|
|
|
#include "common/logging/log.h"
|
2016-09-21 06:52:38 +00:00
|
|
|
#include "core/hle/kernel/resource_limit.h"
|
2015-05-12 20:25:15 +00:00
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
2018-08-28 16:30:33 +00:00
|
|
|
ResourceLimit::ResourceLimit(KernelCore& kernel) : Object{kernel} {}
|
|
|
|
ResourceLimit::~ResourceLimit() = default;
|
2015-05-12 20:25:15 +00:00
|
|
|
|
2018-08-28 16:30:33 +00:00
|
|
|
SharedPtr<ResourceLimit> ResourceLimit::Create(KernelCore& kernel, std::string name) {
|
|
|
|
SharedPtr<ResourceLimit> resource_limit(new ResourceLimit(kernel));
|
2015-05-12 20:25:15 +00:00
|
|
|
|
|
|
|
resource_limit->name = std::move(name);
|
|
|
|
return resource_limit;
|
|
|
|
}
|
|
|
|
|
2018-04-20 23:35:02 +00:00
|
|
|
s32 ResourceLimit::GetCurrentResourceValue(ResourceType resource) const {
|
2015-05-12 20:25:15 +00:00
|
|
|
switch (resource) {
|
2018-04-20 23:35:02 +00:00
|
|
|
case ResourceType::Commit:
|
2016-09-18 00:38:01 +00:00
|
|
|
return current_commit;
|
2018-04-20 23:35:02 +00:00
|
|
|
case ResourceType::Thread:
|
2016-09-18 00:38:01 +00:00
|
|
|
return current_threads;
|
2018-04-20 23:35:02 +00:00
|
|
|
case ResourceType::Event:
|
2016-09-18 00:38:01 +00:00
|
|
|
return current_events;
|
2018-04-20 23:35:02 +00:00
|
|
|
case ResourceType::Mutex:
|
2016-09-18 00:38:01 +00:00
|
|
|
return current_mutexes;
|
2018-04-20 23:35:02 +00:00
|
|
|
case ResourceType::Semaphore:
|
2016-09-18 00:38:01 +00:00
|
|
|
return current_semaphores;
|
2018-04-20 23:35:02 +00:00
|
|
|
case ResourceType::Timer:
|
2016-09-18 00:38:01 +00:00
|
|
|
return current_timers;
|
2018-04-20 23:35:02 +00:00
|
|
|
case ResourceType::SharedMemory:
|
2016-09-18 00:38:01 +00:00
|
|
|
return current_shared_mems;
|
2018-04-20 23:35:02 +00:00
|
|
|
case ResourceType::AddressArbiter:
|
2016-09-18 00:38:01 +00:00
|
|
|
return current_address_arbiters;
|
2018-04-20 23:35:02 +00:00
|
|
|
case ResourceType::CPUTime:
|
2016-09-18 00:38:01 +00:00
|
|
|
return current_cpu_time;
|
|
|
|
default:
|
2018-07-02 16:13:26 +00:00
|
|
|
LOG_ERROR(Kernel, "Unknown resource type={:08X}", static_cast<u32>(resource));
|
2016-09-18 00:38:01 +00:00
|
|
|
UNIMPLEMENTED();
|
|
|
|
return 0;
|
2015-05-12 20:25:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-04-20 23:35:02 +00:00
|
|
|
u32 ResourceLimit::GetMaxResourceValue(ResourceType resource) const {
|
2015-05-12 20:25:15 +00:00
|
|
|
switch (resource) {
|
2018-04-20 23:35:02 +00:00
|
|
|
case ResourceType::Priority:
|
2017-01-11 17:08:10 +00:00
|
|
|
return max_priority;
|
2018-04-20 23:35:02 +00:00
|
|
|
case ResourceType::Commit:
|
2016-09-18 00:38:01 +00:00
|
|
|
return max_commit;
|
2018-04-20 23:35:02 +00:00
|
|
|
case ResourceType::Thread:
|
2016-09-18 00:38:01 +00:00
|
|
|
return max_threads;
|
2018-04-20 23:35:02 +00:00
|
|
|
case ResourceType::Event:
|
2016-09-18 00:38:01 +00:00
|
|
|
return max_events;
|
2018-04-20 23:35:02 +00:00
|
|
|
case ResourceType::Mutex:
|
2016-09-18 00:38:01 +00:00
|
|
|
return max_mutexes;
|
2018-04-20 23:35:02 +00:00
|
|
|
case ResourceType::Semaphore:
|
2016-09-18 00:38:01 +00:00
|
|
|
return max_semaphores;
|
2018-04-20 23:35:02 +00:00
|
|
|
case ResourceType::Timer:
|
2016-09-18 00:38:01 +00:00
|
|
|
return max_timers;
|
2018-04-20 23:35:02 +00:00
|
|
|
case ResourceType::SharedMemory:
|
2016-09-18 00:38:01 +00:00
|
|
|
return max_shared_mems;
|
2018-04-20 23:35:02 +00:00
|
|
|
case ResourceType::AddressArbiter:
|
2016-09-18 00:38:01 +00:00
|
|
|
return max_address_arbiters;
|
2018-04-20 23:35:02 +00:00
|
|
|
case ResourceType::CPUTime:
|
2016-09-18 00:38:01 +00:00
|
|
|
return max_cpu_time;
|
|
|
|
default:
|
2018-07-02 16:13:26 +00:00
|
|
|
LOG_ERROR(Kernel, "Unknown resource type={:08X}", static_cast<u32>(resource));
|
2016-09-18 00:38:01 +00:00
|
|
|
UNIMPLEMENTED();
|
|
|
|
return 0;
|
2015-05-12 20:25:15 +00:00
|
|
|
}
|
|
|
|
}
|
2018-01-20 07:48:02 +00:00
|
|
|
} // namespace Kernel
|