diff options
author | bunnei <bunneidev@gmail.com> | 2023-01-31 10:51:10 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-31 10:51:10 -0800 |
commit | de28cd0c2df507ffc84497e6069233d1a7cac208 (patch) | |
tree | 98d32eac04d7e84eda7ef4010e85ac3dd766dd78 /src/core/hardware_properties.h | |
parent | ed4a88bd93c93ac1aaf5b6bae7d8ede10ff0338a (diff) | |
parent | 67a8740af6c13d42f3c361c0f242cfa52f94b754 (diff) |
Merge pull request #9697 from liamwhite/kcap
kernel: add KCapabilities
Diffstat (limited to 'src/core/hardware_properties.h')
-rw-r--r-- | src/core/hardware_properties.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/core/hardware_properties.h b/src/core/hardware_properties.h index 13cbdb734..45567b840 100644 --- a/src/core/hardware_properties.h +++ b/src/core/hardware_properties.h @@ -25,6 +25,26 @@ constexpr std::array<s32, Common::BitSize<u64>()> VirtualToPhysicalCoreMap{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, }; +static constexpr inline size_t NumVirtualCores = Common::BitSize<u64>(); + +static constexpr inline u64 VirtualCoreMask = [] { + u64 mask = 0; + for (size_t i = 0; i < NumVirtualCores; ++i) { + mask |= (UINT64_C(1) << i); + } + return mask; +}(); + +static constexpr inline u64 ConvertVirtualCoreMaskToPhysical(u64 v_core_mask) { + u64 p_core_mask = 0; + while (v_core_mask != 0) { + const u64 next = std::countr_zero(v_core_mask); + v_core_mask &= ~(static_cast<u64>(1) << next); + p_core_mask |= (static_cast<u64>(1) << VirtualToPhysicalCoreMap[next]); + } + return p_core_mask; +} + // Cortex-A57 supports 4 memory watchpoints constexpr u64 NUM_WATCHPOINTS = 4; |