From c264865d49c199427a53d76ff3c141b7320dccea Mon Sep 17 00:00:00 2001 From: able Date: Wed, 12 Jul 2023 09:01:58 -0500 Subject: [PATCH] X86: cpuid changes --- kernel/src/arch/x86_64/cpuid.rs | 27 +++++++++++++++++++++++++-- kernel/src/arch/x86_64/mod.rs | 1 + 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/kernel/src/arch/x86_64/cpuid.rs b/kernel/src/arch/x86_64/cpuid.rs index f94d77f..e0ed015 100644 --- a/kernel/src/arch/x86_64/cpuid.rs +++ b/kernel/src/arch/x86_64/cpuid.rs @@ -1,5 +1,7 @@ -use core::{arch::asm, fmt, ops::Deref, slice, str}; - +use { + alloc::vec::Vec, + core::{arch::asm, fmt, ops::Deref, slice, str}, +}; #[repr(u32)] pub enum RequestType { BasicInformation = 0x0000_0000, @@ -767,6 +769,27 @@ impl Master { physical_address_size: pas, } } + // TODO: Macroify this and also include all of the cpu features from self + pub fn features(&self) -> Vec<(&str, bool)> { + let mut fv = Vec::new(); + let apic = self.apic(); + let avx = self.avx(); + let avx2 = self.avx2(); + let x2 = self.x2apic(); + + let gb_pages = self.gigabyte_pages(); + let rdseed = self.rdseed(); + let rdrand = self.rdrand(); + + fv.push(("apic", apic)); + fv.push(("avx", avx)); + fv.push(("avx2", avx2)); + fv.push(("gigabyte pages", gb_pages)); + fv.push(("rdrand", rdrand)); + fv.push(("rdseed", rdseed)); + fv.push(("x2apic", x2)); + fv + } master_attr_reader!(version_information, VersionInformation); master_attr_reader!( diff --git a/kernel/src/arch/x86_64/mod.rs b/kernel/src/arch/x86_64/mod.rs index 0151c7d..a7d141f 100644 --- a/kernel/src/arch/x86_64/mod.rs +++ b/kernel/src/arch/x86_64/mod.rs @@ -102,6 +102,7 @@ unsafe extern "C" fn _kernel_start() -> ! { let mut cpu_features = xml::XMLElement::new("CPU Features"); { + cpuinfo.version_information().unwrap(); let apic = cpuinfo.apic(); let avx = cpuinfo.avx(); let avx2 = cpuinfo.avx2();