mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
add API calls for debugging kernel under baochip targets
also updated some really bit-rotted docs we will deprecate the docs/ directory soon, they are wrong and misleading at this point.
This commit is contained in:
parent
4b8a202985
commit
a3a566b240
7 changed files with 134 additions and 8 deletions
|
|
@ -1,4 +1,3 @@
|
|||
# Xous Documentation
|
||||
|
||||
Xous is the operating system powering Betrusted. This repository
|
||||
documents the inner workings of this operating system.
|
||||
This directory is about to be deprecated. Please refer to the [Xous Book](https://betrusted.io/xous-book/) for up to date documentation.
|
||||
|
|
@ -69,12 +69,13 @@ memmap-flash = []
|
|||
debug-swap = []
|
||||
debug-swap-verbose = []
|
||||
raw-trng = ["xous-kernel/raw-trng"]
|
||||
debug-proc = []
|
||||
|
||||
# patches for simulation targets ONLY. Applying these flags will result in totally broken security.
|
||||
hwsim = []
|
||||
|
||||
# default = ["print-panics", "debug-print", "wrap-print"]
|
||||
default = ["print-panics"]
|
||||
default = ["debug-proc", "print-panics"]
|
||||
|
||||
[target.'cfg(any(windows, unix))'.dependencies]
|
||||
crossbeam-channel = "0.5"
|
||||
|
|
|
|||
|
|
@ -43,6 +43,10 @@ pub enum SwapAbi {
|
|||
ReleaseMemory = 6,
|
||||
WritePage = 7,
|
||||
BlockErase = 8,
|
||||
DebugProcesses = 9,
|
||||
DebugServers = 10,
|
||||
DebugFree = 11,
|
||||
DebugInterrupts = 12,
|
||||
}
|
||||
/// SYNC WITH `xous-swapper/src/main.rs`
|
||||
impl SwapAbi {
|
||||
|
|
@ -57,6 +61,10 @@ impl SwapAbi {
|
|||
6 => ReleaseMemory,
|
||||
7 => WritePage,
|
||||
8 => BlockErase,
|
||||
9 => DebugProcesses,
|
||||
10 => DebugServers,
|
||||
11 => DebugFree,
|
||||
12 => DebugInterrupts,
|
||||
_ => Invalid,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1180,6 +1180,94 @@ pub fn handle_inner(pid: PID, tid: TID, in_irq: bool, call: SysCall) -> SysCallR
|
|||
});
|
||||
Ok(xous_kernel::Result::Ok)
|
||||
}
|
||||
SwapAbi::DebugProcesses => {
|
||||
#[cfg(feature = "debug-proc")]
|
||||
crate::services::SystemServices::with(|system_services| {
|
||||
println!("Printing processes");
|
||||
let current_pid = system_services.current_pid();
|
||||
for process in &system_services.processes {
|
||||
if !process.free() {
|
||||
process.activate().unwrap();
|
||||
let mut connection_count = 0;
|
||||
ArchProcess::with_inner(|process_inner| {
|
||||
for conn in &process_inner.connection_map {
|
||||
if conn.is_some() {
|
||||
connection_count += 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
println!(
|
||||
"{:x?} conns:{}/32 {}",
|
||||
process,
|
||||
connection_count,
|
||||
system_services.process_name(process.pid).unwrap_or("")
|
||||
);
|
||||
}
|
||||
}
|
||||
system_services.get_process(current_pid).unwrap().activate().unwrap();
|
||||
});
|
||||
Ok(xous_kernel::Result::Ok)
|
||||
}
|
||||
SwapAbi::DebugServers => {
|
||||
#[cfg(feature = "debug-proc")]
|
||||
crate::services::SystemServices::with(|system_services| {
|
||||
println!("Servers in use:");
|
||||
println!(" idx | pid | process | sid");
|
||||
println!(" --- + --- + -------------------- | ------------------");
|
||||
for (idx, server) in system_services.servers.iter().enumerate() {
|
||||
if let Some(s) = server {
|
||||
println!(
|
||||
" {:3} | {:3} | {:20} | {:x?}",
|
||||
idx,
|
||||
s.pid,
|
||||
system_services.process_name(s.pid).unwrap_or(""),
|
||||
s.sid
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
Ok(xous_kernel::Result::Ok)
|
||||
}
|
||||
SwapAbi::DebugFree => {
|
||||
#[cfg(feature = "debug-proc")]
|
||||
crate::services::SystemServices::with(|system_services| {
|
||||
println!("RAM usage:");
|
||||
let mut total_bytes = 0;
|
||||
crate::mem::MemoryManager::with(|mm| {
|
||||
for process in &system_services.processes {
|
||||
if !process.free() {
|
||||
let bytes_used = mm.ram_used_by(process.pid);
|
||||
total_bytes += bytes_used;
|
||||
println!(
|
||||
" PID {:>3}: {:>4} k {}",
|
||||
process.pid,
|
||||
bytes_used / 1024,
|
||||
system_services.process_name(process.pid).unwrap_or("")
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
println!("{} k total", total_bytes / 1024);
|
||||
});
|
||||
Ok(xous_kernel::Result::Ok)
|
||||
}
|
||||
SwapAbi::DebugInterrupts => {
|
||||
#[cfg(feature = "debug-proc")]
|
||||
crate::services::SystemServices::with(|system_services| {
|
||||
println!("Interrupt handlers:");
|
||||
println!(" IRQ | Process | Handler | Argument");
|
||||
crate::irq::for_each_irq(|irq, pid, address, arg| {
|
||||
println!(
|
||||
" {}: {} @ {:x?} {:x?}",
|
||||
irq,
|
||||
system_services.process_name(*pid).unwrap_or(""),
|
||||
address,
|
||||
arg
|
||||
);
|
||||
});
|
||||
});
|
||||
Ok(xous_kernel::Result::Ok)
|
||||
}
|
||||
SwapAbi::Invalid => {
|
||||
println!(
|
||||
"Invalid SwapOp: {:x} {:x} {:x} {:x} {:x} {:x} {:x}",
|
||||
|
|
|
|||
|
|
@ -22,6 +22,10 @@ pub enum SwapAbi {
|
|||
ReleaseMemory = 6,
|
||||
WritePage = 7,
|
||||
BlockErase = 8,
|
||||
DebugProcesses = 9,
|
||||
DebugServers = 10,
|
||||
DebugFree = 11,
|
||||
DebugInterrupts = 12,
|
||||
}
|
||||
/// SYNC WITH `kernel/src/swap.rs`
|
||||
impl SwapAbi {
|
||||
|
|
@ -36,6 +40,10 @@ impl SwapAbi {
|
|||
6 => ReleaseMemory,
|
||||
7 => WritePage,
|
||||
8 => BlockErase,
|
||||
9 => DebugProcesses,
|
||||
10 => DebugServers,
|
||||
11 => DebugFree,
|
||||
12 => DebugInterrupts,
|
||||
_ => Invalid,
|
||||
}
|
||||
}
|
||||
|
|
@ -46,18 +54,25 @@ impl SwapAbi {
|
|||
#[repr(usize)]
|
||||
pub enum Opcode {
|
||||
/// Userspace request to GC some physical pages
|
||||
GarbageCollect,
|
||||
GarbageCollect = 0,
|
||||
/// This call will only process full-page writes to an offset in SPI FLASH.
|
||||
/// The full-page criteria is acceptable because (a) we need the full page anyways
|
||||
/// due to the sector erase constraint and (b) the caller has to have the full page
|
||||
/// anyways because the page was read in and mapped into the caller's space at some
|
||||
/// point in time.
|
||||
WritePage,
|
||||
BulkErase,
|
||||
WritePage = 1,
|
||||
BulkErase = 2,
|
||||
/// Test messages
|
||||
#[cfg(feature = "swap-userspace-testing")]
|
||||
Test0,
|
||||
None,
|
||||
Test0 = 3,
|
||||
// kernel has to be compiled with "debug-proc" for these to work
|
||||
// the Debug* series of opcodes are hard-coded in other crates, so don't change their discriminant.
|
||||
DebugProcesses = 9,
|
||||
DebugServers = 10,
|
||||
DebugFree = 11,
|
||||
DebugInterrupts = 12,
|
||||
|
||||
None = 255,
|
||||
}
|
||||
|
||||
/// An aligned structure for sending FLASH data between structures. This only works
|
||||
|
|
|
|||
|
|
@ -822,6 +822,21 @@ fn main() {
|
|||
.expect("couldn't Block Erase region");
|
||||
}
|
||||
}
|
||||
Some(Opcode::DebugProcesses) => {
|
||||
xous::rsyscall(xous::SysCall::SwapOp(SwapAbi::DebugProcesses as usize, 0, 0, 0, 0, 0, 0))
|
||||
.unwrap();
|
||||
}
|
||||
Some(Opcode::DebugServers) => {
|
||||
xous::rsyscall(xous::SysCall::SwapOp(SwapAbi::DebugServers as usize, 0, 0, 0, 0, 0, 0))
|
||||
.unwrap();
|
||||
}
|
||||
Some(Opcode::DebugFree) => {
|
||||
xous::rsyscall(xous::SysCall::SwapOp(SwapAbi::DebugFree as usize, 0, 0, 0, 0, 0, 0)).unwrap();
|
||||
}
|
||||
Some(Opcode::DebugInterrupts) => {
|
||||
xous::rsyscall(xous::SysCall::SwapOp(SwapAbi::DebugInterrupts as usize, 0, 0, 0, 0, 0, 0))
|
||||
.unwrap();
|
||||
}
|
||||
#[cfg(feature = "swap-userspace-testing")]
|
||||
Some(Opcode::Test0) => {
|
||||
log::info!("Free mem: {}kiB", get_free_pages() * PAGE_SIZE / 1024);
|
||||
|
|
|
|||
Loading…
Reference in a new issue