From bb3c1b612022a0c26fa1e1b94d7ed5bd9df4c763 Mon Sep 17 00:00:00 2001 From: able Date: Sun, 28 May 2023 02:00:54 -0500 Subject: [PATCH] CPU: Added more cpu feature detection --- kernel/src/arch/x86_64/mod.rs | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/kernel/src/arch/x86_64/mod.rs b/kernel/src/arch/x86_64/mod.rs index 34712d5..0c81116 100644 --- a/kernel/src/arch/x86_64/mod.rs +++ b/kernel/src/arch/x86_64/mod.rs @@ -78,11 +78,17 @@ unsafe extern "C" fn _kernel_start() -> ! { let mut cpu = XMLElement::new("cpu"); let core_count = smp.cpu_count.to_string(); cpu.set_attribute("core count", core_count); + for x in 0..smp.cpu_count { + let core_name = alloc::format!("core_{}", x); + let core = XMLElement::new(core_name); + cpu.set_child(core); + } + cpu.set_attribute("brand string", brand_string); let _cpu_speed = 0; - cpu.set_attribute("speed", "Unknown"); + cpu.set_attribute("speed", "unknown"); if false { // disable() // disable interrupts (if still not done) @@ -96,14 +102,29 @@ unsafe extern "C" fn _kernel_start() -> ! { let mut cpu_features = xml::XMLElement::new("CPU Features"); { - let x2 = cpuinfo.x2apic(); let apic = cpuinfo.apic(); - let _avx = cpuinfo.avx(); + let avx = cpuinfo.avx(); + let avx2 = cpuinfo.avx2(); + let x2 = cpuinfo.x2apic(); + + let gb_pages = cpuinfo.gigabyte_pages(); + let rdseed = cpuinfo.rdseed(); + let rdrand = cpuinfo.rdrand(); cpu_features.set_attribute("apic", apic.to_string()); - cpu_features.set_attribute("avx", apic.to_string()); + cpu_features.set_attribute("avx", avx.to_string()); + cpu_features.set_attribute("avx2", avx2.to_string()); + cpu_features.set_attribute("gigabyte pages", gb_pages.to_string()); + cpu_features.set_attribute("rdrand", rdrand.to_string()); + cpu_features.set_attribute("rdseed", rdseed.to_string()); cpu_features.set_attribute("x2apic", x2.to_string()); } + if cpuinfo.digital_temperature_sensor() { + let mut temperature_child = XMLElement::new("Temperature"); + + temperature_child.set_attribute("degrees", "Unknown"); + cpu.set_child(temperature_child); + } cpu.set_child(cpu_features); cpus.push(cpu); @@ -156,6 +177,7 @@ unsafe extern "C" fn _kernel_start() -> ! { dis.swap_buffers(); }; + // TODO: Add in rdseed and rdrand as sources for randomness let _rand = xml::XMLElement::new("Random"); crate::kmain::kmain(