mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
gdb-stub: disable userspace console
The serial port going to the userspace console is disabled to allow for gdb access to the kernel.
This commit is contained in:
parent
284e639453
commit
533607b9ec
3 changed files with 24 additions and 16 deletions
|
|
@ -45,6 +45,8 @@ board-baosor = ["bao1x-hal/board-baosor"]
|
|||
board-dabao = ["bao1x-hal/board-dabao"]
|
||||
hosted-baosec = []
|
||||
hwsim = []
|
||||
# when activated, disables the console so the kernel GDB stub can claim it.
|
||||
gdb-stub = []
|
||||
|
||||
precursor = ["utralib/precursor"]
|
||||
hosted = ["utralib/hosted"]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use core::fmt::{Error, Write};
|
||||
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim"), not(feature = "gdb-stub")))]
|
||||
use bao1x_hal::udma;
|
||||
|
||||
#[macro_export]
|
||||
|
|
@ -28,9 +28,10 @@ macro_rules! println
|
|||
pub struct Uart {}
|
||||
|
||||
// this is a hack to bypass an explicit initialization/allocation step for the debug structure
|
||||
#[cfg(not(feature = "gdb-stub"))]
|
||||
pub static mut DEFAULT_UART_ADDR: *mut usize = 0x0000_0000 as *mut usize;
|
||||
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim"), not(feature = "gdb-stub")))]
|
||||
impl Uart {
|
||||
pub fn putc(&self, c: u8) {
|
||||
// check that we've been initialized before attempting to send any characters...
|
||||
|
|
@ -70,7 +71,9 @@ impl Uart {
|
|||
}
|
||||
|
||||
impl Write for Uart {
|
||||
#[allow(unused_variables)]
|
||||
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
||||
#[cfg(not(feature = "gdb-stub"))]
|
||||
for c in s.bytes() {
|
||||
self.putc(c);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +1,27 @@
|
|||
use core::fmt::{Error, Write};
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim"), not(feature = "gdb-stub")))]
|
||||
use std::pin::Pin;
|
||||
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim"), not(feature = "gdb-stub")))]
|
||||
use bao1x_hal::board::UART_DMA_TX_BUF_PHYS;
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim"), not(feature = "gdb-stub")))]
|
||||
use bao1x_hal::udma;
|
||||
#[cfg(not(feature = "gdb-stub"))]
|
||||
use utralib::generated::*;
|
||||
|
||||
pub struct Output {}
|
||||
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim"), not(feature = "gdb-stub")))]
|
||||
pub static mut UART_DMA_TX_BUF_VIRT: *mut u8 = 0x0000_0000 as *mut u8;
|
||||
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim"), not(feature = "gdb-stub")))]
|
||||
pub static mut UART_IRQ: Option<Pin<Box<bao1x_hal::udma::UartIrq>>> = None;
|
||||
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim"), not(feature = "gdb-stub")))]
|
||||
pub static mut KBD_CONN: u32 = 0;
|
||||
|
||||
pub fn init() -> Output {
|
||||
// TODO: migrate this to a "proper" UART that is available on SoC hardware, but for now all we have access
|
||||
// to is the DUART.
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim"), not(feature = "gdb-stub")))]
|
||||
let uart = xous::syscall::map_memory(
|
||||
xous::MemoryAddress::new(utra::udma_uart_2::HW_UDMA_UART_2_BASE),
|
||||
None,
|
||||
|
|
@ -30,11 +29,11 @@ pub fn init() -> Output {
|
|||
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||
)
|
||||
.expect("couldn't map serial port");
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim"), not(feature = "gdb-stub")))]
|
||||
unsafe {
|
||||
crate::platform::debug::DEFAULT_UART_ADDR = uart.as_mut_ptr() as _
|
||||
};
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim"), not(feature = "gdb-stub")))]
|
||||
{
|
||||
// Note: for the TX buf, we allocate a pre-reserved portion of IFRAM as our
|
||||
// DMA buffer. We do *not* use the IFRAM allocator in `bao1x-hal-service` because
|
||||
|
|
@ -80,13 +79,14 @@ pub fn init() -> Output {
|
|||
unsafe {
|
||||
crate::platform::debug::DEFAULT_UART_ADDR = uart.as_mut_ptr() as _
|
||||
};
|
||||
#[cfg(not(feature = "gdb-stub"))]
|
||||
println!("Mapped UART @ {:08x}", uart.as_ptr() as usize);
|
||||
println!("Process: map success!");
|
||||
|
||||
Output {}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim"), not(feature = "gdb-stub")))]
|
||||
fn uart_handler(_irq_no: usize, _arg: *mut usize) {
|
||||
let mut uart = unsafe {
|
||||
udma::Uart::get_handle(
|
||||
|
|
@ -131,8 +131,9 @@ pub struct OutputWriter {}
|
|||
|
||||
#[allow(dead_code)]
|
||||
impl OutputWriter {
|
||||
#[allow(unused_variables)]
|
||||
pub fn putc(&self, c: u8) {
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim"), not(feature = "gdb-stub")))]
|
||||
{
|
||||
// safety: safe to call as long as the raw parts are initialized and we exclusively
|
||||
// own it; and the UART has been initialized. For this peripheral, initialization
|
||||
|
|
@ -161,7 +162,7 @@ impl OutputWriter {
|
|||
/// bytes written. This is mostly compatible with `std::io::Write`,
|
||||
/// except it is infallible.
|
||||
pub fn write(&mut self, buf: &[u8]) -> usize {
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim"), not(feature = "gdb-stub")))]
|
||||
{
|
||||
// safety: safe to call as long as the raw parts are initialized and we exclusively
|
||||
// own it; and the UART has been initialized. For this peripheral, initialization
|
||||
|
|
@ -185,6 +186,8 @@ impl OutputWriter {
|
|||
}
|
||||
buf.len()
|
||||
}
|
||||
#[cfg(feature = "gdb-stub")]
|
||||
buf.len() // just fake the write
|
||||
}
|
||||
|
||||
pub fn write_all(&mut self, buf: &[u8]) -> core::result::Result<usize, ()> { Ok(self.write(buf)) }
|
||||
|
|
|
|||
Loading…
Reference in a new issue