1
0
Fork 0
forked from AbleOS/ableos

X86: cpuid changes

This commit is contained in:
able 2023-07-12 09:01:58 -05:00
parent 340d76fd13
commit c264865d49
2 changed files with 26 additions and 2 deletions

View file

@ -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!(

View file

@ -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();