1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:17:35 +00:00

Kernel: Add Aarch64 CPU feature detection

This commit is contained in:
konrad 2023-01-08 00:01:25 +01:00 committed by Jelle Raaijmakers
parent 9f736d782c
commit 97dce5d001
4 changed files with 53 additions and 16 deletions

View file

@ -8,6 +8,12 @@
namespace Kernel {
CPUFeature::Type detect_cpu_features()
{
auto features = CPUFeature::Type(0u);
return features;
}
// https://developer.arm.com/downloads/-/exploration-tools/feature-names-for-a-profile
StringView cpu_feature_to_name(CPUFeature::Type const& feature)
{
@ -1004,4 +1010,21 @@ StringView cpu_feature_to_description(CPUFeature::Type const& feature)
VERIFY_NOT_REACHED();
}
NonnullOwnPtr<KString> build_cpu_feature_names(CPUFeature::Type const& features)
{
StringBuilder builder;
bool first = true;
for (auto feature = CPUFeature::Type(1u); feature != CPUFeature::__End; feature <<= 1u) {
if (features.has_flag(feature)) {
if (first)
first = false;
else
MUST(builder.try_append(' '));
auto name = cpu_feature_to_name(feature);
MUST(builder.try_append(name));
}
}
return KString::must_create(builder.string_view());
}
}