mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-13 07:48:30 +00:00
retrofit swapper so that its print function can be selected out
so that we can share app uart with other processes that need it for debug
This commit is contained in:
parent
6dcb23a53b
commit
fa067f1137
3 changed files with 10 additions and 8 deletions
|
|
@ -40,7 +40,9 @@ renode = ["utralib/renode"]
|
|||
swap-userspace-testing = []
|
||||
oom-doom = []
|
||||
|
||||
debug-print = [
|
||||
] # mutually exclusive feature with other crates that use the app UART
|
||||
# mutually exclusive feature with other crates that use the app UART
|
||||
# requires "userspace-debug" to be passed to the loader for this to work.
|
||||
debug-print-swapper = []
|
||||
|
||||
debug-verbose = []
|
||||
default = []
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use core::fmt::{Error, Write};
|
|||
|
||||
pub struct DebugUart {}
|
||||
impl DebugUart {
|
||||
#[cfg(all(feature = "debug-print", any(feature = "precursor", feature = "renode")))]
|
||||
#[cfg(all(feature = "debug-print-swapper", any(feature = "precursor", feature = "renode")))]
|
||||
pub fn putc(&mut self, c: u8) {
|
||||
use utralib::generated::*;
|
||||
let mut csr = CSR::new(loader::swap::SWAP_APP_UART_VADDR as *mut u32);
|
||||
|
|
@ -12,7 +12,7 @@ impl DebugUart {
|
|||
csr.wfo(utra::app_uart::RXTX_RXTX, c as u32);
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "debug-print", any(feature = "cramium-soc")))]
|
||||
#[cfg(all(feature = "debug-print-swapper", any(feature = "cramium-soc")))]
|
||||
pub fn putc(&mut self, c: u8) {
|
||||
use cramium_hal::udma;
|
||||
// safety: safe to call as long as the raw parts are initialized and we exclusively
|
||||
|
|
@ -30,7 +30,7 @@ impl DebugUart {
|
|||
uart.write(&[c]);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "debug-print"))]
|
||||
#[cfg(not(feature = "debug-print-swapper"))]
|
||||
pub fn putc(&self, _c: u8) {}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -330,7 +330,7 @@ fn write_to_swap_inner(
|
|||
};
|
||||
|
||||
// step 2: write the page to swap
|
||||
#[cfg(feature = "debug-print")]
|
||||
#[cfg(feature = "debug-print-swapper")]
|
||||
writeln!(DebugUart {}, "WTS PID{} VA {:x}", candidate.raw_pid(), candidate.vaddr()).ok();
|
||||
// this is safe because the page is aligned and initialized as it comes from the kernel
|
||||
// remember that this page is overwritten with encrypted data
|
||||
|
|
@ -448,7 +448,7 @@ fn swap_handler(
|
|||
|
||||
// swapper is not allowed to use `log` for debugging under most circumstances, because
|
||||
// the swapper can't send messages when handling a swap call. Instead, we use a local
|
||||
// debug UART to handle this. This needs to be enabled with the "debug-print" feature
|
||||
// debug UART to handle this. This needs to be enabled with the "debug-print-swapper" feature
|
||||
// and is mutually exclusive with the "gdb-stub" feature in the kernel since it uses
|
||||
// the same physical hardware.
|
||||
sss.inner = Some(SwapperSharedState {
|
||||
|
|
@ -507,7 +507,7 @@ fn swap_handler(
|
|||
};
|
||||
// clear the used bit in swap
|
||||
ss.sct.counts[paddr_in_swap / PAGE_SIZE] &= !loader::FLG_SWAP_USED;
|
||||
#[cfg(feature = "debug-print")]
|
||||
#[cfg(feature = "debug-print-swapper")]
|
||||
writeln!(
|
||||
DebugUart {},
|
||||
"RFS PID{} VA {:x} PA {:x} counts {:x}",
|
||||
|
|
|
|||
Loading…
Reference in a new issue