mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
kernel: debug: add wrap-print feature
This feature works around a bug in Renode where unwrapped lines cause it to crash. This forces columns to be wrapped at 80 characters. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
f3ed417c7a
commit
06a5997a45
1 changed files with 22 additions and 3 deletions
|
|
@ -6,9 +6,6 @@ use core::fmt::{Error, Write};
|
|||
#[cfg(baremetal)]
|
||||
use utralib::generated::*;
|
||||
|
||||
#[allow(dead_code)] // this is unused in hosted mode, kill the warning
|
||||
static mut INITIALIZED: bool = false;
|
||||
|
||||
#[macro_use]
|
||||
#[cfg(all(
|
||||
not(test),
|
||||
|
|
@ -66,6 +63,11 @@ macro_rules! println
|
|||
pub struct Uart {
|
||||
// pub base: *mut usize,
|
||||
}
|
||||
#[cfg(baremetal)]
|
||||
static mut INITIALIZED: bool = false;
|
||||
|
||||
#[cfg(all(baremetal, feature = "wrap-print"))]
|
||||
static mut CHAR_COUNT: usize = 0;
|
||||
|
||||
#[cfg(baremetal)]
|
||||
impl Uart {
|
||||
|
|
@ -86,6 +88,23 @@ impl Uart {
|
|||
while uart_csr.r(utra::uart::TXFULL) != 0 {
|
||||
()
|
||||
}
|
||||
#[cfg(feature = "wrap-print")]
|
||||
unsafe {
|
||||
if c == b'\n' {
|
||||
CHAR_COUNT = 0;
|
||||
} else if CHAR_COUNT > 80 {
|
||||
CHAR_COUNT = 0;
|
||||
self.putc(b'\n');
|
||||
self.putc(b'\r');
|
||||
self.putc(b' ');
|
||||
self.putc(b' ');
|
||||
self.putc(b' ');
|
||||
self.putc(b' ');
|
||||
}
|
||||
else {
|
||||
CHAR_COUNT += 1;
|
||||
}
|
||||
}
|
||||
uart_csr.wfo(utra::uart::RXTX_RXTX, c as u32);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue