mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
Kernel: Rename some ProcessorInfo members to match Intel manual
Let's use terminology from the the Intel manual to avoid confusion. Also add `_string` suffixes to better distinguish the numeric values from the string values.
This commit is contained in:
parent
ebe2cf8995
commit
53a95a5347
Notes:
sideshowbarker
2024-07-17 20:58:35 +09:00
Author: https://github.com/linusg Commit: https://github.com/SerenityOS/serenity/commit/53a95a5347 Pull-request: https://github.com/SerenityOS/serenity/pull/13482 Reviewed-by: https://github.com/bgianfo ✅
|
@ -20,12 +20,12 @@ class ProcessorInfo {
|
||||||
public:
|
public:
|
||||||
ProcessorInfo(Processor const& processor);
|
ProcessorInfo(Processor const& processor);
|
||||||
|
|
||||||
static NonnullOwnPtr<KString> query_processor_cpuid();
|
static NonnullOwnPtr<KString> build_vendor_id_string();
|
||||||
static NonnullOwnPtr<KString> query_processor_brand();
|
static NonnullOwnPtr<KString> build_brand_string();
|
||||||
|
|
||||||
StringView cpuid() const { return m_cpuid->view(); }
|
StringView vendor_id_string() const { return m_vendor_id_string->view(); }
|
||||||
StringView brand() const { return m_brand->view(); }
|
StringView brand_string() const { return m_brand_string->view(); }
|
||||||
StringView features() const { return m_features->view(); }
|
StringView features_string() const { return m_features_string->view(); }
|
||||||
u32 display_model() const { return m_display_model; }
|
u32 display_model() const { return m_display_model; }
|
||||||
u32 display_family() const { return m_display_family; }
|
u32 display_family() const { return m_display_family; }
|
||||||
u32 stepping() const { return m_stepping; }
|
u32 stepping() const { return m_stepping; }
|
||||||
|
@ -35,9 +35,9 @@ public:
|
||||||
void set_apic_id(u32 apic_id) { m_apic_id = apic_id; }
|
void set_apic_id(u32 apic_id) { m_apic_id = apic_id; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
NonnullOwnPtr<KString> m_cpuid;
|
NonnullOwnPtr<KString> m_vendor_id_string;
|
||||||
NonnullOwnPtr<KString> m_brand;
|
NonnullOwnPtr<KString> m_brand_string;
|
||||||
NonnullOwnPtr<KString> m_features;
|
NonnullOwnPtr<KString> m_features_string;
|
||||||
u32 m_display_model { 0 };
|
u32 m_display_model { 0 };
|
||||||
u32 m_display_family { 0 };
|
u32 m_display_family { 0 };
|
||||||
u32 m_stepping { 0 };
|
u32 m_stepping { 0 };
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
ProcessorInfo::ProcessorInfo(Processor const& processor)
|
ProcessorInfo::ProcessorInfo(Processor const& processor)
|
||||||
: m_cpuid(query_processor_cpuid())
|
: m_vendor_id_string(build_vendor_id_string())
|
||||||
, m_brand(query_processor_brand())
|
, m_brand_string(build_brand_string())
|
||||||
, m_features(processor.features_string())
|
, m_features_string(processor.features_string())
|
||||||
{
|
{
|
||||||
CPUID cpuid(1);
|
CPUID cpuid(1);
|
||||||
m_stepping = cpuid.eax() & 0xf;
|
m_stepping = cpuid.eax() & 0xf;
|
||||||
|
@ -36,7 +36,7 @@ ProcessorInfo::ProcessorInfo(Processor const& processor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullOwnPtr<KString> ProcessorInfo::query_processor_cpuid()
|
NonnullOwnPtr<KString> ProcessorInfo::build_vendor_id_string()
|
||||||
{
|
{
|
||||||
CPUID cpuid(0);
|
CPUID cpuid(0);
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
|
@ -53,7 +53,7 @@ NonnullOwnPtr<KString> ProcessorInfo::query_processor_cpuid()
|
||||||
return KString::must_create(builder.string_view());
|
return KString::must_create(builder.string_view());
|
||||||
}
|
}
|
||||||
|
|
||||||
NonnullOwnPtr<KString> ProcessorInfo::query_processor_brand()
|
NonnullOwnPtr<KString> ProcessorInfo::build_brand_string()
|
||||||
{
|
{
|
||||||
u32 max_extended_leaf = CPUID(0x80000000).eax();
|
u32 max_extended_leaf = CPUID(0x80000000).eax();
|
||||||
|
|
||||||
|
|
|
@ -582,14 +582,15 @@ private:
|
||||||
auto& info = proc.info();
|
auto& info = proc.info();
|
||||||
auto obj = TRY(array.add_object());
|
auto obj = TRY(array.add_object());
|
||||||
TRY(obj.add("processor", proc.id()));
|
TRY(obj.add("processor", proc.id()));
|
||||||
TRY(obj.add("cpuid", info.cpuid()));
|
// FIXME: Rename this to use the same name everywhere.
|
||||||
|
TRY(obj.add("cpuid", info.vendor_id_string()));
|
||||||
TRY(obj.add("family", info.display_family()));
|
TRY(obj.add("family", info.display_family()));
|
||||||
|
|
||||||
auto features_array = TRY(obj.add_array("features"));
|
auto features_array = TRY(obj.add_array("features"));
|
||||||
auto keep_empty = false;
|
auto keep_empty = false;
|
||||||
|
|
||||||
ErrorOr<void> result; // FIXME: Make this nicer
|
ErrorOr<void> result; // FIXME: Make this nicer
|
||||||
info.features().for_each_split_view(' ', keep_empty, [&](StringView feature) {
|
info.features_string().for_each_split_view(' ', keep_empty, [&](StringView feature) {
|
||||||
if (result.is_error())
|
if (result.is_error())
|
||||||
return;
|
return;
|
||||||
result = features_array.add(feature);
|
result = features_array.add(feature);
|
||||||
|
@ -601,7 +602,7 @@ private:
|
||||||
TRY(obj.add("model", info.display_model()));
|
TRY(obj.add("model", info.display_model()));
|
||||||
TRY(obj.add("stepping", info.stepping()));
|
TRY(obj.add("stepping", info.stepping()));
|
||||||
TRY(obj.add("type", info.type()));
|
TRY(obj.add("type", info.type()));
|
||||||
TRY(obj.add("brand", info.brand()));
|
TRY(obj.add("brand", info.brand_string()));
|
||||||
|
|
||||||
TRY(obj.finish());
|
TRY(obj.finish());
|
||||||
return {};
|
return {};
|
||||||
|
|
Loading…
Reference in a new issue