strat9_kernel/shell/commands/timer/
mod.rs1use crate::{arch::x86_64::timer::TIMER_HZ, shell::ShellError, shell_println};
6use alloc::string::String;
7
8pub fn cmd_timer(args: &[String]) -> Result<(), ShellError> {
14 if args.is_empty() {
15 print_usage();
16 return Ok(());
17 }
18
19 match args[0].as_str() {
20 "test" => {
21 shell_println!("timer test is disabled (unstable debug path removed).");
22 shell_println!("Use 'timer info' to inspect current timer configuration.");
23 Ok(())
24 }
25 "info" => {
26 shell_println!("=== Timer Information ===");
27 shell_println!("Scheduler ticks: {}", crate::process::scheduler::ticks());
28
29 if crate::arch::x86_64::timer::is_apic_timer_active() {
30 let ticks_per_10ms = crate::arch::x86_64::timer::apic_ticks_per_10ms();
31 shell_println!("Timer mode: APIC");
32 shell_println!("Ticks per 10ms: {}", ticks_per_10ms);
33 shell_println!(
34 "Estimated CPU: {} MHz",
35 (ticks_per_10ms as u64) * 16 * 100 / 1_000_000
36 );
37 } else {
38 shell_println!("Timer mode: PIT (fallback)");
39 shell_println!("Frequency: {} Hz", TIMER_HZ);
40 }
41
42 Ok(())
43 }
44 _ => {
45 print_usage();
46 Ok(())
47 }
48 }
49}
50
51fn print_usage() {
53 shell_println!("Timer debug commands:");
54 shell_println!(" timer test - Disabled (unstable debug path removed)");
55 shell_println!(" timer info - Show timer configuration");
56 shell_println!("");
57 shell_println!("Examples:");
58 shell_println!(" timer test - Shows disabled message");
59 shell_println!(" timer info - Show current timer info");
60}