diff --git a/kernel/src/arch/x86_64/cpuid.rs b/kernel/src/arch/x86_64/cpuid.rs index f94d77f2..e0ed015f 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 0151c7d9..a7d141f2 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();