mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +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"]
|
board-dabao = ["bao1x-hal/board-dabao"]
|
||||||
hosted-baosec = []
|
hosted-baosec = []
|
||||||
hwsim = []
|
hwsim = []
|
||||||
|
# when activated, disables the console so the kernel GDB stub can claim it.
|
||||||
|
gdb-stub = []
|
||||||
|
|
||||||
precursor = ["utralib/precursor"]
|
precursor = ["utralib/precursor"]
|
||||||
hosted = ["utralib/hosted"]
|
hosted = ["utralib/hosted"]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use core::fmt::{Error, Write};
|
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;
|
use bao1x_hal::udma;
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
|
|
@ -28,9 +28,10 @@ macro_rules! println
|
||||||
pub struct Uart {}
|
pub struct Uart {}
|
||||||
|
|
||||||
// this is a hack to bypass an explicit initialization/allocation step for the debug structure
|
// 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;
|
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 {
|
impl Uart {
|
||||||
pub fn putc(&self, c: u8) {
|
pub fn putc(&self, c: u8) {
|
||||||
// check that we've been initialized before attempting to send any characters...
|
// check that we've been initialized before attempting to send any characters...
|
||||||
|
|
@ -70,7 +71,9 @@ impl Uart {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Write for Uart {
|
impl Write for Uart {
|
||||||
|
#[allow(unused_variables)]
|
||||||
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
fn write_str(&mut self, s: &str) -> Result<(), Error> {
|
||||||
|
#[cfg(not(feature = "gdb-stub"))]
|
||||||
for c in s.bytes() {
|
for c in s.bytes() {
|
||||||
self.putc(c);
|
self.putc(c);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,28 +1,27 @@
|
||||||
use core::fmt::{Error, Write};
|
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;
|
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;
|
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;
|
use bao1x_hal::udma;
|
||||||
|
#[cfg(not(feature = "gdb-stub"))]
|
||||||
use utralib::generated::*;
|
use utralib::generated::*;
|
||||||
|
|
||||||
pub struct Output {}
|
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;
|
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;
|
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 static mut KBD_CONN: u32 = 0;
|
||||||
|
|
||||||
pub fn init() -> Output {
|
pub fn init() -> Output {
|
||||||
// TODO: migrate this to a "proper" UART that is available on SoC hardware, but for now all we have access
|
#[cfg(all(feature = "bao1x", not(feature = "hwsim"), not(feature = "gdb-stub")))]
|
||||||
// to is the DUART.
|
|
||||||
#[cfg(all(feature = "bao1x", not(feature = "hwsim")))]
|
|
||||||
let uart = xous::syscall::map_memory(
|
let uart = xous::syscall::map_memory(
|
||||||
xous::MemoryAddress::new(utra::udma_uart_2::HW_UDMA_UART_2_BASE),
|
xous::MemoryAddress::new(utra::udma_uart_2::HW_UDMA_UART_2_BASE),
|
||||||
None,
|
None,
|
||||||
|
|
@ -30,11 +29,11 @@ pub fn init() -> Output {
|
||||||
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||||
)
|
)
|
||||||
.expect("couldn't map serial port");
|
.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 {
|
unsafe {
|
||||||
crate::platform::debug::DEFAULT_UART_ADDR = uart.as_mut_ptr() as _
|
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
|
// 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
|
// DMA buffer. We do *not* use the IFRAM allocator in `bao1x-hal-service` because
|
||||||
|
|
@ -80,13 +79,14 @@ pub fn init() -> Output {
|
||||||
unsafe {
|
unsafe {
|
||||||
crate::platform::debug::DEFAULT_UART_ADDR = uart.as_mut_ptr() as _
|
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!("Mapped UART @ {:08x}", uart.as_ptr() as usize);
|
||||||
println!("Process: map success!");
|
println!("Process: map success!");
|
||||||
|
|
||||||
Output {}
|
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) {
|
fn uart_handler(_irq_no: usize, _arg: *mut usize) {
|
||||||
let mut uart = unsafe {
|
let mut uart = unsafe {
|
||||||
udma::Uart::get_handle(
|
udma::Uart::get_handle(
|
||||||
|
|
@ -131,8 +131,9 @@ pub struct OutputWriter {}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
impl OutputWriter {
|
impl OutputWriter {
|
||||||
|
#[allow(unused_variables)]
|
||||||
pub fn putc(&self, c: u8) {
|
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
|
// 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
|
// 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`,
|
/// bytes written. This is mostly compatible with `std::io::Write`,
|
||||||
/// except it is infallible.
|
/// except it is infallible.
|
||||||
pub fn write(&mut self, buf: &[u8]) -> usize {
|
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
|
// 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
|
// own it; and the UART has been initialized. For this peripheral, initialization
|
||||||
|
|
@ -185,6 +186,8 @@ impl OutputWriter {
|
||||||
}
|
}
|
||||||
buf.len()
|
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)) }
|
pub fn write_all(&mut self, buf: &[u8]) -> core::result::Result<usize, ()> { Ok(self.write(buf)) }
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue