Skip to content

Commit

Permalink
feat(kernel): dump commands for GDT and timer (#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Dec 1, 2022
1 parent bd2f195 commit c156e8c
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/arch/x86_64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ mod framebuf;
pub mod interrupt;
mod oops;
pub mod pci;
pub mod shell;
pub use self::{
boot::ArchInfo,
oops::{oops, Oops},
Expand Down
2 changes: 1 addition & 1 deletion src/arch/x86_64/interrupt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static TSS: sync::Lazy<task::StateSegment> = sync::Lazy::new(|| {
tss
});

static GDT: sync::InitOnce<Gdt> = sync::InitOnce::uninitialized();
pub(in crate::arch) static GDT: sync::InitOnce<Gdt> = sync::InitOnce::uninitialized();

const TIMER_INTERVAL: time::Duration = time::Duration::from_millis(10);
pub(super) static TIMER: time::Timer = time::Timer::new(TIMER_INTERVAL);
Expand Down
25 changes: 25 additions & 0 deletions src/arch/x86_64/shell.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use crate::shell::{self, Command};

pub const DUMP_ARCH: Command = Command::new("arch")
.with_help("dump architecture-specific structures")
.with_subcommands(&[
Command::new("gdt")
.with_help("print the global descriptor table (GDT)")
.with_fn(|_| {
let gdt = super::interrupt::GDT.get();
tracing::info!(?gdt);
Ok(())
}),
// Command::new("idt")
// .with_help("print the interrupt descriptor table (IDT)")
// .with_fn(|_| {
// let gdt = super::interrupt::GDT.get();
// tracing::info!(?gdt);
// Ok(())
// }),
]);

pub fn dump_timer(_: &str) -> Result<(), shell::Error> {
tracing::info!(timer = ?super::interrupt::TIMER);
Ok(())
}
7 changes: 7 additions & 0 deletions src/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ pub fn eval(line: &str) {
Command::new("archinfo")
.with_help("print the architecture information structure")
.with_fn(|line| Err(Error::other(line, "not yet implemented"))),
Command::new("timer")
.with_help("print the timer wheel")
.with_fn(crate::arch::shell::dump_timer),
Command::new("timer")
.with_help("print the timer wheel")
.with_fn(crate::arch::shell::dump_timer),
crate::arch::shell::DUMP_ARCH,
Command::new("heap")
.with_help("print kernel heap statistics")
.with_fn(|_| {
Expand Down

0 comments on commit c156e8c

Please sign in to comment.