forked from AbleOS/ableos
Merge pull request 'another shrimple macro!' (#6) from IntoTheNight/ableos:master into master
Reviewed-on: https://git.ablecorp.us/AbleOS/ableos/pulls/6
This commit is contained in:
commit
490f15db48
|
@ -1,3 +1,5 @@
|
|||
use crate::cpu_features;
|
||||
|
||||
use {
|
||||
alloc::vec::Vec,
|
||||
core::{arch::asm, fmt, ops::Deref, slice, str},
|
||||
|
@ -772,23 +774,8 @@ impl Master {
|
|||
// 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
|
||||
cpu_features!(self, fv);
|
||||
return fv;
|
||||
}
|
||||
|
||||
master_attr_reader!(version_information, VersionInformation);
|
||||
|
|
|
@ -26,3 +26,28 @@ macro_rules! device_tree {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
// NOTE: this only reduces the code duplication in source code not in generated code!
|
||||
// Written by Yours Truly: Munir
|
||||
/// A simple macro to reduce code duplication when we insert cpu features into the array/vector
|
||||
#[macro_export]
|
||||
macro_rules! cpu_features {
|
||||
($cpu_master_object:expr, $result_vec:expr) => {
|
||||
// checks for cpu features and returns bool for each feature
|
||||
let apic = $cpu_master_object.apic();
|
||||
let avx = $cpu_master_object.avx();
|
||||
let avx2 = $cpu_master_object.avx2();
|
||||
let x2 = $cpu_master_object.x2apic();
|
||||
let gb_pages = $cpu_master_object.gigabyte_pages();
|
||||
let rdseed = $cpu_master_object.rdseed();
|
||||
let rdrand = $cpu_master_object.rdrand();
|
||||
|
||||
$result_vec.push(("apic", apic));
|
||||
$result_vec.push(("avx", avx));
|
||||
$result_vec.push(("avx2", avx2));
|
||||
$result_vec.push(("gigabyte pages", gb_pages));
|
||||
$result_vec.push(("rdrand", rdrand));
|
||||
$result_vec.push(("rdseed", rdseed));
|
||||
$result_vec.push(("x2apic", x2));
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue