mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-21 09:14:34 +00:00
kernel: update debug and shell modules
This commit is contained in:
parent
38a02f9dbb
commit
3451d106f9
2 changed files with 31 additions and 25 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
// SPDX-FileCopyrightText: 2020 Sean Cross <sean@xobs.io>
|
// SPDX-FileCopyrightText: 2020 Sean Cross <sean@xobs.io>
|
||||||
// SPDX-FileCopyrightText: 2022 Foundation Devices, Inc. <hello@foundationdevices.com>
|
// SPDX-FileCopyrightText: 2023 Foundation Devices, Inc. <hello@foundationdevices.com>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
/// Prints to the debug output directly.
|
/// Prints to the debug output directly.
|
||||||
|
|
@ -36,13 +36,13 @@ macro_rules! println {
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! klog {
|
macro_rules! klog {
|
||||||
() => ({
|
() => ({
|
||||||
print!(" [{}:{}]", file!(), line!())
|
println!(" [{}:{}]", file!(), line!())
|
||||||
});
|
});
|
||||||
($fmt:expr) => ({
|
($fmt:expr) => ({
|
||||||
print!(concat!(" [{}:{} ", $fmt, "]"), file!(), line!())
|
println!(concat!(" [{}:{} ", $fmt, "]"), file!(), line!())
|
||||||
});
|
});
|
||||||
($fmt:expr, $($args:tt)+) => ({
|
($fmt:expr, $($args:tt)+) => ({
|
||||||
print!(concat!(" [{}:{} ", $fmt, "]"), file!(), line!(), $($args)+)
|
println!(concat!(" [{}:{} ", $fmt, "]"), file!(), line!(), $($args)+)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
// SPDX-FileCopyrightText: 2020 Sean Cross <sean@xobs.io>
|
// SPDX-FileCopyrightText: 2020 Sean Cross <sean@xobs.io>
|
||||||
// SPDX-FileCopyrightText: 2022 Foundation Devices, Inc. <hello@foundationdevices.com>
|
// SPDX-FileCopyrightText: 2023 Foundation Devices, Inc. <hello@foundationdevices.com>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use core::fmt;
|
|
||||||
use crate::{
|
use crate::{
|
||||||
args::KernelArguments,
|
args::KernelArguments,
|
||||||
io::{SerialWrite, SerialRead},
|
io::{SerialRead, SerialWrite},
|
||||||
};
|
};
|
||||||
|
use core::fmt;
|
||||||
|
|
||||||
/// Instance of the shell output.
|
/// Instance of the shell output.
|
||||||
pub static mut OUTPUT: Option<Output> = None;
|
pub static mut OUTPUT: Option<Output> = None;
|
||||||
|
|
@ -56,9 +56,7 @@ impl fmt::Write for Output {
|
||||||
///
|
///
|
||||||
/// This should be called in platform initialization code.
|
/// This should be called in platform initialization code.
|
||||||
pub fn init(serial: &'static mut dyn SerialWrite) {
|
pub fn init(serial: &'static mut dyn SerialWrite) {
|
||||||
unsafe {
|
unsafe { OUTPUT = Some(Output::new(serial)) }
|
||||||
OUTPUT = Some(Output::new(serial))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Print the processed kernel arguments
|
// Print the processed kernel arguments
|
||||||
let args = KernelArguments::get();
|
let args = KernelArguments::get();
|
||||||
|
|
@ -66,6 +64,10 @@ pub fn init(serial: &'static mut dyn SerialWrite) {
|
||||||
for arg in args.iter() {
|
for arg in args.iter() {
|
||||||
println!(" {}", arg);
|
println!(" {}", arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
println!("=== Kernel Debug Shell Available ====");
|
||||||
|
print_help();
|
||||||
|
println!("=====================================");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Process possible characters received through a serial interface.
|
/// Process possible characters received through a serial interface.
|
||||||
|
|
@ -74,6 +76,7 @@ pub fn init(serial: &'static mut dyn SerialWrite) {
|
||||||
/// on an interrupt.
|
/// on an interrupt.
|
||||||
pub fn process_characters<R: SerialRead>(serial: &mut R) {
|
pub fn process_characters<R: SerialRead>(serial: &mut R) {
|
||||||
while let Some(b) = serial.getc() {
|
while let Some(b) = serial.getc() {
|
||||||
|
println!("> {}", b as char);
|
||||||
handle_character(b);
|
handle_character(b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -136,7 +139,7 @@ fn handle_character(b: u8) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
println!(
|
println!(
|
||||||
"{:?} conns:{}/32 {}",
|
"{:x?} conns:{}/32 {}",
|
||||||
process,
|
process,
|
||||||
connection_count,
|
connection_count,
|
||||||
system_services.process_name(process.pid).unwrap_or("")
|
system_services.process_name(process.pid).unwrap_or("")
|
||||||
|
|
@ -157,7 +160,7 @@ fn handle_character(b: u8) {
|
||||||
for process in &system_services.processes {
|
for process in &system_services.processes {
|
||||||
if !process.free() {
|
if !process.free() {
|
||||||
println!(
|
println!(
|
||||||
"{:?} {}:",
|
"{:x?} {}:",
|
||||||
process,
|
process,
|
||||||
system_services.process_name(process.pid).unwrap_or("")
|
system_services.process_name(process.pid).unwrap_or("")
|
||||||
);
|
);
|
||||||
|
|
@ -214,17 +217,20 @@ fn handle_character(b: u8) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
b'h' => {
|
b'h' => print_help(),
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn print_help() {
|
||||||
println!("Xous Kernel Debug");
|
println!("Xous Kernel Debug");
|
||||||
println!("key | command");
|
println!("key | command");
|
||||||
println!("--- + -----------------------");
|
println!("--- + -----------------------");
|
||||||
|
println!(" h | print this message");
|
||||||
println!(" i | print irq handlers");
|
println!(" i | print irq handlers");
|
||||||
println!(" m | print MMU page tables of all processes");
|
println!(" m | print MMU page tables of all processes");
|
||||||
println!(" p | print all processes");
|
println!(" p | print all processes");
|
||||||
println!(" P | print all processes and threads");
|
println!(" P | print all processes and threads");
|
||||||
println!(" r | report RAM usage of all processes");
|
println!(" r | report RAM usage of all processes");
|
||||||
println!(" s | print all allocated servers");
|
println!(" s | print all allocated servers");
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue