forked from theseus-os/Theseus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Klimenty Tsoutsman <klim@tsoutsman.com>
- Loading branch information
Showing
7 changed files
with
102 additions
and
70 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,69 @@ | ||
#![no_std] | ||
|
||
// extern crate alloc; | ||
// #[macro_use] extern crate app_io; | ||
extern crate alloc; | ||
|
||
// extern crate apic; | ||
// extern crate getopts; | ||
// extern crate task; | ||
use alloc::{ | ||
fmt::Write, | ||
string::{String, ToString}, | ||
vec::Vec, | ||
}; | ||
|
||
// use getopts::Options; | ||
// use alloc::{ | ||
// fmt::Write, | ||
// string::{ | ||
// String, | ||
// ToString, | ||
// }, | ||
// vec::Vec, | ||
// }; | ||
// use apic::get_lapics; | ||
use app_io::{print, println}; | ||
use getopts::Options; | ||
|
||
// pub fn main(args: Vec<String>) -> isize { | ||
// let mut opts = Options::new(); | ||
// opts.optflag("h", "help", "print this help menu"); | ||
pub fn main(args: Vec<String>) -> isize { | ||
let mut opts = Options::new(); | ||
opts.optflag("h", "help", "print this help menu"); | ||
|
||
// let matches = match opts.parse(args) { | ||
// Ok(m) => { m } | ||
// Err(_f) => { println!("{} \n", _f); | ||
// return -1; } | ||
// }; | ||
let matches = match opts.parse(args) { | ||
Ok(m) => m, | ||
Err(_f) => { | ||
println!("{} \n", _f); | ||
return -1; | ||
} | ||
}; | ||
|
||
// if matches.opt_present("h") { | ||
// return print_usage(opts) | ||
// } | ||
if matches.opt_present("h") { | ||
return print_usage(opts); | ||
} | ||
let bootstrap_cpu = cpu::bootstrap_cpu(); | ||
|
||
// let all_lapics = get_lapics(); | ||
// for lapic in all_lapics.iter() { | ||
// let lapic = lapic.1; | ||
// let apic_id = lapic.read().apic_id(); | ||
// let processor = lapic.read().processor_id(); | ||
// let is_bootstrap_cpu = lapic.read().is_bootstrap_cpu(); | ||
// let core_type = if is_bootstrap_cpu { "Boot CPU" } else { "Secondary CPU" }; | ||
for (cpu, task_list) in task::scheduler::dump() { | ||
let core_type = if Some(cpu) == bootstrap_cpu { | ||
"Boot CPU" | ||
} else { | ||
"Secondary CPU" | ||
}; | ||
|
||
// println!("\n{} (apic: {}, proc: {})", core_type, apic_id, processor); | ||
|
||
// if let Some(runqueue) = runqueue::get_runqueue(apic_id.value() as u8).map(|rq| rq.read().clone()) { | ||
// let mut runqueue_contents = String::new(); | ||
// for task in runqueue.iter() { | ||
// writeln!(runqueue_contents, " {} ({}) {}", | ||
// task.name, | ||
// task.id, | ||
// if task.is_running() { "*" } else { "" } | ||
// ) | ||
// .expect("Failed to write to runqueue_contents"); | ||
// } | ||
// print!("{}", runqueue_contents); | ||
// } | ||
|
||
// else { | ||
// println!("Can't retrieve runqueue for core {}", apic_id); | ||
// return -1; | ||
// } | ||
// } | ||
|
||
// println!(""); | ||
// 0 | ||
// } | ||
println!("\n{} (CPU: {})", core_type, cpu); | ||
|
||
// fn print_usage(opts: Options) -> isize { | ||
// let mut brief = "Usage: rq \n \n".to_string(); | ||
let mut runqueue_contents = String::new(); | ||
for task in task_list.iter() { | ||
writeln!( | ||
runqueue_contents, | ||
" {} ({}) {}", | ||
task.name, | ||
task.id, | ||
if task.is_running() { "*" } else { "" } | ||
) | ||
.expect("Failed to write to runqueue_contents"); | ||
} | ||
print!("{}", runqueue_contents); | ||
} | ||
|
||
// brief.push_str("Prints each CPU's ID, the tasks on its runqueue ('*' identifies the currently running task), and whether it is the boot CPU or not"); | ||
println!(""); | ||
0 | ||
} | ||
|
||
// println!("{} \n", opts.usage(&brief)); | ||
fn print_usage(opts: Options) -> isize { | ||
let mut brief = "Usage: rq \n \n".to_string(); | ||
|
||
// 0 | ||
// } | ||
brief.push_str( | ||
"Prints each CPU's ID, the tasks on its runqueue ('*' identifies the currently running \ | ||
task), and whether it is the boot CPU or not", | ||
); | ||
|
||
println!("{} \n", opts.usage(&brief)); | ||
|
||
0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters