strip out debug shell commands from the kernel in bao1x targets

debug shell is actually not reachable in bao1x targets because
the DUART is Tx-only. thus this code is just dead weight in the
kernel for bao1x platforms.
This commit is contained in:
bunnie 2026-01-08 02:24:03 +08:00
parent d623dc723e
commit c7d8b88456
2 changed files with 12 additions and 20 deletions

View file

@ -7,10 +7,9 @@
use core::fmt;
use crate::{
args::KernelArguments,
io::{SerialRead, SerialWrite},
};
use crate::io::SerialWrite;
#[cfg(not(feature = "bao1x"))]
use crate::{args::KernelArguments, io::SerialRead};
/// Instance of the shell output.
pub static mut OUTPUT: Option<Output> = None;
@ -59,6 +58,7 @@ impl fmt::Write for Output {
/// Initialize the kernel shell.
///
/// This should be called in platform initialization code.
#[cfg(not(feature = "bao1x"))]
pub fn init(serial: &'static mut dyn SerialWrite) {
unsafe { OUTPUT = Some(Output::new(serial)) }
@ -78,6 +78,7 @@ pub fn init(serial: &'static mut dyn SerialWrite) {
///
/// This should be called when a serial interface has new data, for example,
/// on an interrupt.
#[cfg(not(feature = "bao1x"))]
pub fn process_characters<R: SerialRead>(serial: &mut R) {
while let Some(b) = serial.getc() {
println!("> {}", b as char);
@ -85,6 +86,7 @@ pub fn process_characters<R: SerialRead>(serial: &mut R) {
}
}
#[cfg(not(feature = "bao1x"))]
fn handle_character(b: u8) {
use crate::services::ArchProcess;
@ -222,6 +224,7 @@ fn handle_character(b: u8) {
}
}
#[cfg(not(feature = "bao1x"))]
fn print_help() {
println!("Xous Kernel Debug");
println!("key | command");

View file

@ -12,12 +12,7 @@ use utralib::generated::*;
use xous_kernel::{MemoryFlags, MemoryType};
#[cfg(feature = "bao1x")]
use crate::{
PID,
debug::shell::process_characters,
io::{SerialRead, SerialWrite},
mem::MemoryManager,
};
use crate::{PID, io::SerialWrite, mem::MemoryManager};
/// UART virtual address.
///
@ -48,11 +43,12 @@ pub fn init() {
)
.expect("unable to map serial port")
});
let mut uart = Uart::new(UART_ADDR, IRQ0_ADDR, process_characters);
let mut uart = Uart::new(UART_ADDR, IRQ0_ADDR);
uart.init();
unsafe {
UART = Some(uart);
crate::debug::shell::init((&mut *(&raw mut UART)).as_mut().unwrap());
// inaccessible because DUART is tx-only
// crate::debug::shell::init((&mut *(&raw mut UART)).as_mut().unwrap());
}
}
@ -63,9 +59,7 @@ pub struct Uart {
#[cfg(feature = "bao1x")]
impl Uart {
pub fn new(addr: usize, _irq_addr: usize, _callback: fn(&mut Self)) -> Uart {
Uart { uart_csr: CSR::new(addr as *mut u32) }
}
pub fn new(addr: usize, _irq_addr: usize) -> Uart { Uart { uart_csr: CSR::new(addr as *mut u32) } }
pub fn init(&mut self) {
// duart requires no special initializations
@ -79,8 +73,3 @@ impl SerialWrite for Uart {
self.uart_csr.wo(utra::duart::SFR_TXD, c as u32);
}
}
#[cfg(feature = "bao1x")]
impl SerialRead for Uart {
fn getc(&mut self) -> Option<u8> { None }
}