Get CPU features
This commit is contained in:
parent
6927a4c5cf
commit
7fa413019f
6 changed files with 138 additions and 0 deletions
13
kernel/scheme/sys/cpu.rs
Normal file
13
kernel/scheme/sys/cpu.rs
Normal file
|
@ -0,0 +1,13 @@
|
|||
use collections::Vec;
|
||||
|
||||
use arch::device::cpu::cpu_info;
|
||||
use syscall::error::{Error, EIO, Result};
|
||||
|
||||
pub fn resource() -> Result<Vec<u8>> {
|
||||
let mut string = format!("CPUs: {}\n", ::cpu_count());
|
||||
|
||||
match cpu_info(&mut string) {
|
||||
Ok(()) => Ok(string.into_bytes()),
|
||||
Err(_) => Err(Error::new(EIO))
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ use syscall::flag::{MODE_DIR, MODE_FILE, SEEK_CUR, SEEK_END, SEEK_SET};
|
|||
use syscall::scheme::Scheme;
|
||||
|
||||
mod context;
|
||||
mod cpu;
|
||||
mod memory;
|
||||
mod scheme;
|
||||
//mod interrupt;
|
||||
|
@ -37,6 +38,7 @@ impl SysScheme {
|
|||
let mut files: BTreeMap<&'static [u8], Box<SysFn>> = BTreeMap::new();
|
||||
|
||||
files.insert(b"context", Box::new(move || context::resource()));
|
||||
files.insert(b"cpu", Box::new(move || cpu::resource()));
|
||||
files.insert(b"memory", Box::new(move || memory::resource()));
|
||||
files.insert(b"scheme", Box::new(move || scheme::resource()));
|
||||
//files.insert(b"interrupt", Box::new(move || interrupt::resource()));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue