diff options
author | Lioncash <mathew1800@gmail.com> | 2018-12-20 01:09:18 +0100 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2018-12-21 13:05:34 +0100 |
commit | 27caf7120444d1c34e1c2e322ab97ba9f5275b28 (patch) | |
tree | f84ed4a9178786c27ceddf9940e7be6e26f94d51 /src/core/hle/kernel/process_capability.cpp | |
parent | kernel/process: Introduce process capability parsing skeleton (diff) | |
download | yuzu-27caf7120444d1c34e1c2e322ab97ba9f5275b28.tar yuzu-27caf7120444d1c34e1c2e322ab97ba9f5275b28.tar.gz yuzu-27caf7120444d1c34e1c2e322ab97ba9f5275b28.tar.bz2 yuzu-27caf7120444d1c34e1c2e322ab97ba9f5275b28.tar.lz yuzu-27caf7120444d1c34e1c2e322ab97ba9f5275b28.tar.xz yuzu-27caf7120444d1c34e1c2e322ab97ba9f5275b28.tar.zst yuzu-27caf7120444d1c34e1c2e322ab97ba9f5275b28.zip |
Diffstat (limited to 'src/core/hle/kernel/process_capability.cpp')
-rw-r--r-- | src/core/hle/kernel/process_capability.cpp | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/core/hle/kernel/process_capability.cpp b/src/core/hle/kernel/process_capability.cpp index 8d787547b..9f513b25b 100644 --- a/src/core/hle/kernel/process_capability.cpp +++ b/src/core/hle/kernel/process_capability.cpp @@ -205,7 +205,36 @@ void ProcessCapabilities::Clear() { } ResultCode ProcessCapabilities::HandlePriorityCoreNumFlags(u32 flags) { - // TODO: Implement + if (priority_mask != 0 || core_mask != 0) { + return ERR_INVALID_CAPABILITY_DESCRIPTOR; + } + + const u32 core_num_min = (flags >> 16) & 0xFF; + const u32 core_num_max = (flags >> 24) & 0xFF; + if (core_num_min > core_num_max) { + return ERR_INVALID_COMBINATION; + } + + const u32 priority_min = (flags >> 10) & 0x3F; + const u32 priority_max = (flags >> 4) & 0x3F; + if (priority_min > priority_max) { + return ERR_INVALID_COMBINATION; + } + + // The switch only has 4 usable cores. + if (core_num_max >= 4) { + return ERR_INVALID_PROCESSOR_ID; + } + + const auto make_mask = [](u64 min, u64 max) { + const u64 range = max - min + 1; + const u64 mask = (1ULL << range) - 1; + + return mask << min; + }; + + core_mask = make_mask(core_num_min, core_num_max); + priority_mask = make_mask(priority_min, priority_max); return RESULT_SUCCESS; } |