mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
add duart debug support for std environment
This commit is contained in:
parent
e91eb176e7
commit
fc3da61307
2 changed files with 30 additions and 1 deletions
|
|
@ -33,7 +33,28 @@ impl Uart {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "debug-print", target_os = "xous"))]
|
#[cfg(all(feature = "debug-print-duart", target_os = "xous"))]
|
||||||
|
pub fn putc(&self, c: u8) {
|
||||||
|
if unsafe { SWAP_APP_UART_VADDR } == 0 {
|
||||||
|
match xous::syscall::map_memory(
|
||||||
|
xous::MemoryAddress::new(utralib::utra::duart::HW_DUART_BASE),
|
||||||
|
None,
|
||||||
|
4096,
|
||||||
|
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||||
|
) {
|
||||||
|
Ok(uart) => {
|
||||||
|
unsafe { SWAP_APP_UART_VADDR = uart.as_mut_ptr() as usize };
|
||||||
|
}
|
||||||
|
_ => return,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let base = unsafe { SWAP_APP_UART_VADDR as *mut u32 };
|
||||||
|
let mut uart = CSR::new(base);
|
||||||
|
while uart.r(utra::duart::SFR_SR) != 0 {}
|
||||||
|
uart.wo(utra::duart::SFR_TXD, c as u32);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(all(feature = "debug-print-uart", target_os = "xous"))]
|
||||||
pub fn putc(&mut self, c: u8) {
|
pub fn putc(&mut self, c: u8) {
|
||||||
if unsafe { SWAP_APP_UART_VADDR } == 0 {
|
if unsafe { SWAP_APP_UART_VADDR } == 0 {
|
||||||
match xous::syscall::map_memory(
|
match xous::syscall::map_memory(
|
||||||
|
|
|
||||||
|
|
@ -97,3 +97,11 @@ pub unsafe fn read_sp() -> usize {
|
||||||
core::arch::asm!("mv {0}, sp", out(reg) sp);
|
core::arch::asm!("mv {0}, sp", out(reg) sp);
|
||||||
sp
|
sp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// DUART is first-come, first-served in Xous environment. This stub
|
||||||
|
/// can be called early in a server's initialization process so that it can get
|
||||||
|
/// exclusive access to the DUART (assuming the kernel is configured to relinquish it)
|
||||||
|
#[cfg(feature = "std")]
|
||||||
|
pub fn claim_duart() {
|
||||||
|
crate::println!("PID {} got duart", xous::process::id());
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue