mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
kernel: remove printlns, needless context queries
Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
1a6b1160a3
commit
549866bcd5
3 changed files with 53 additions and 74 deletions
|
|
@ -128,12 +128,12 @@ impl Process {
|
|||
context: TID,
|
||||
_setup: ContextInit,
|
||||
) -> Result<(), xous::Error> {
|
||||
println!(
|
||||
"KERNEL({}): Setting up context {} @ {:?}",
|
||||
self.pid,
|
||||
context,
|
||||
std::thread::current()
|
||||
);
|
||||
// println!(
|
||||
// "KERNEL({}): Setting up context {} @ {:?}",
|
||||
// self.pid,
|
||||
// context,
|
||||
// std::thread::current()
|
||||
// );
|
||||
assert!(context > 0);
|
||||
PROCESS_TABLE.with(|pt| {
|
||||
let mut process_table = pt.borrow_mut();
|
||||
|
|
@ -142,12 +142,12 @@ impl Process {
|
|||
|
||||
assert!(!process.contexts[context - 1].allocated);
|
||||
process.contexts[context - 1].allocated = true;
|
||||
println!(
|
||||
"KERNEL({}): self.contexts[{}].allocated = {}",
|
||||
current_pid_idx,
|
||||
context - 1,
|
||||
process.contexts[context - 1].allocated
|
||||
);
|
||||
// println!(
|
||||
// "KERNEL({}): self.contexts[{}].allocated = {}",
|
||||
// current_pid_idx,
|
||||
// context - 1,
|
||||
// process.contexts[context - 1].allocated
|
||||
// );
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -500,10 +500,10 @@ impl SystemServices {
|
|||
pid, context, other
|
||||
),
|
||||
};
|
||||
println!(
|
||||
"KERNEL({}): Readying context {} -> {:?}",
|
||||
pid, context, process.state
|
||||
);
|
||||
// println!(
|
||||
// "KERNEL({}): Readying context {} -> {:?}",
|
||||
// pid, context, process.state
|
||||
// );
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -513,13 +513,11 @@ impl SystemServices {
|
|||
///
|
||||
/// If the current process is not running, or if it's "Running" but has no free contexts
|
||||
pub fn switch_to(&mut self, pid: PID, context: Option<TID>) -> Result<(), xous::Error> {
|
||||
// println!("KERNEL(?): Getting current process...");
|
||||
let process = self.get_process_mut(pid)?;
|
||||
// println!("KERNEL(?): Current process is {:?}", process);
|
||||
println!(
|
||||
"switch_to({}:{:?}): Old state was {:?}",
|
||||
pid, context, process.state
|
||||
);
|
||||
// println!(
|
||||
// "switch_to({}:{:?}): Old state was {:?}",
|
||||
// pid, context, process.state
|
||||
// );
|
||||
|
||||
// Determine which context number to switch to
|
||||
process.state = match process.state {
|
||||
|
|
@ -620,10 +618,10 @@ impl SystemServices {
|
|||
ProcessState::Running(new_mask)
|
||||
}
|
||||
};
|
||||
println!(
|
||||
"switch_to({}:{:?}): New state is {:?}",
|
||||
pid, context, process.state
|
||||
);
|
||||
// println!(
|
||||
// "switch_to({}:{:?}): New state is {:?}",
|
||||
// pid, context, process.state
|
||||
// );
|
||||
// self.pid = pid;
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -643,10 +641,10 @@ impl SystemServices {
|
|||
can_resume: bool,
|
||||
) -> Result<(), xous::Error> {
|
||||
let process = self.get_process_mut(pid)?;
|
||||
println!(
|
||||
"switch_from({}:{}): Old state was {:?}",
|
||||
pid, context, process.state
|
||||
);
|
||||
// println!(
|
||||
// "switch_from({}:{}): Old state was {:?}",
|
||||
// pid, context, process.state
|
||||
// );
|
||||
process.state = match process.state {
|
||||
ProcessState::Running(x) if x & (1 << context) != 0 => panic!(
|
||||
"PID {} context {} was already queued for running when `switch_from()` was called",
|
||||
|
|
@ -675,10 +673,10 @@ impl SystemServices {
|
|||
pid, other
|
||||
),
|
||||
};
|
||||
println!(
|
||||
"switch_from({}:{}): New state is {:?}",
|
||||
pid, context, process.state
|
||||
);
|
||||
// println!(
|
||||
// "switch_from({}:{}): New state is {:?}",
|
||||
// pid, context, process.state
|
||||
// );
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -1196,7 +1194,7 @@ impl SystemServices {
|
|||
// &[arg.map(|x| x.get()).unwrap_or_default() as usize],
|
||||
// );
|
||||
|
||||
println!("KERNEL({}): Created new context {}", pid, new_context_nr);
|
||||
// println!("KERNEL({}): Created new context {}", pid, new_context_nr);
|
||||
|
||||
// Queue the thread to run
|
||||
process.state = match process.state {
|
||||
|
|
|
|||
|
|
@ -111,13 +111,7 @@ fn send_message(pid: PID, thread: TID, cid: CID, message: Message) -> SysCallRes
|
|||
let sender = match message {
|
||||
Message::Scalar(_) | Message::Move(_) => 0,
|
||||
Message::Borrow(_) | Message::MutableBorrow(_) => ss
|
||||
.remember_server_message(
|
||||
sidx,
|
||||
pid,
|
||||
thread,
|
||||
&message,
|
||||
client_address,
|
||||
)
|
||||
.remember_server_message(sidx, pid, thread, &message, client_address)
|
||||
.or_else(|e| {
|
||||
ss.server_from_sidx(sidx)
|
||||
.expect("server couldn't be located")
|
||||
|
|
@ -144,32 +138,20 @@ fn send_message(pid: PID, thread: TID, cid: CID, message: Message) -> SysCallRes
|
|||
} else if blocking && !cfg!(baremetal) {
|
||||
// println!("Blocking client, since it sent a blocking message");
|
||||
ss.switch_to(server_pid, None)?;
|
||||
ss.set_context_result(
|
||||
server_pid,
|
||||
ctx_number,
|
||||
xous::Result::Message(envelope),
|
||||
)
|
||||
.and_then(|_| ss.switch_from(pid, thread, false))
|
||||
.map(|_| xous::Result::BlockedProcess)
|
||||
ss.set_context_result(server_pid, ctx_number, xous::Result::Message(envelope))
|
||||
.and_then(|_| ss.switch_from(pid, thread, false))
|
||||
.map(|_| xous::Result::BlockedProcess)
|
||||
} else if cfg!(baremetal) {
|
||||
// println!("Setting the return value of the Server and returning to Client");
|
||||
ss.set_context_result(
|
||||
server_pid,
|
||||
ctx_number,
|
||||
xous::Result::Message(envelope),
|
||||
)
|
||||
.map(|_| xous::Result::Ok)
|
||||
ss.set_context_result(server_pid, ctx_number, xous::Result::Message(envelope))
|
||||
.map(|_| xous::Result::Ok)
|
||||
} else {
|
||||
// println!("Setting the return value of the Server and returning to Client");
|
||||
// "Switch to" the server PID when not running on bare metal. This ensures
|
||||
// that it's "Running".
|
||||
ss.switch_to(server_pid, None)?;
|
||||
ss.set_context_result(
|
||||
server_pid,
|
||||
ctx_number,
|
||||
xous::Result::Message(envelope),
|
||||
)
|
||||
.map(|_| xous::Result::Ok)
|
||||
ss.set_context_result(server_pid, ctx_number, xous::Result::Message(envelope))
|
||||
.map(|_| xous::Result::Ok)
|
||||
}
|
||||
} else {
|
||||
// Add this message to the queue. If the queue is full, this
|
||||
|
|
@ -199,10 +181,14 @@ fn send_message(pid: PID, thread: TID, cid: CID, message: Message) -> SysCallRes
|
|||
})
|
||||
}
|
||||
|
||||
pub fn handle(pid: PID, tid: TID, call: SysCall) -> core::result::Result<xous::Result, xous::Error> {
|
||||
pub fn handle(
|
||||
pid: PID,
|
||||
tid: TID,
|
||||
call: SysCall,
|
||||
) -> core::result::Result<xous::Result, xous::Error> {
|
||||
// let pid = arch::current_pid();
|
||||
|
||||
println!("KERNEL({}): Syscall {:?}", pid, call);
|
||||
// println!("KERNEL({}): Syscall {:?}", pid, call);
|
||||
match call {
|
||||
SysCall::MapMemory(phys, virt, size, req_flags) => {
|
||||
let mut mm = MemoryManagerHandle::get();
|
||||
|
|
@ -326,13 +312,12 @@ pub fn handle(pid: PID, tid: TID, call: SysCall) -> core::result::Result<xous::R
|
|||
}
|
||||
SysCall::SwitchTo(new_pid, new_context) => {
|
||||
SystemServices::with_mut(|ss| {
|
||||
let context_nr = ss.current_context_nr(pid);
|
||||
unsafe {
|
||||
assert!(
|
||||
SWITCHTO_CALLER.is_none(),
|
||||
"SWITCHTO_CALLER was not None, indicating SwitchTo was called twice"
|
||||
);
|
||||
SWITCHTO_CALLER = Some((pid, context_nr));
|
||||
SWITCHTO_CALLER = Some((pid, tid));
|
||||
}
|
||||
ss.activate_process_context(new_pid, new_context, true, false)
|
||||
.map(|_ctx| {
|
||||
|
|
@ -376,7 +361,6 @@ pub fn handle(pid: PID, tid: TID, call: SysCall) -> core::result::Result<xous::R
|
|||
SysCall::ReceiveMessage(sid) => {
|
||||
SystemServices::with_mut(|ss| {
|
||||
// See if there is a pending message. If so, return immediately.
|
||||
let context_nr = ss.current_context_nr(pid);
|
||||
let sidx = ss.server_sidx(sid).ok_or(xous::Error::ServerNotFound)?;
|
||||
let server = ss
|
||||
.server_from_sidx(sidx)
|
||||
|
|
@ -400,9 +384,9 @@ pub fn handle(pid: PID, tid: TID, call: SysCall) -> core::result::Result<xous::R
|
|||
// MessageEnvelope of the incoming message.
|
||||
// println!(
|
||||
// "KERNEL({}): did not have any waiting messages -- parking context {}",
|
||||
// pid, context_nr
|
||||
// pid, tid
|
||||
// );
|
||||
server.park_context(context_nr);
|
||||
server.park_context(tid);
|
||||
|
||||
// For baremetal targets, switch away from this process.
|
||||
if cfg!(baremetal) {
|
||||
|
|
@ -415,7 +399,7 @@ pub fn handle(pid: PID, tid: TID, call: SysCall) -> core::result::Result<xous::R
|
|||
// For hosted targets, simply return `BlockedProcess` indicating we'll make
|
||||
// a callback to their socket at a later time.
|
||||
else {
|
||||
ss.switch_from(pid, context_nr, false)
|
||||
ss.switch_from(pid, tid, false)
|
||||
.map(|_| xous::Result::BlockedProcess)
|
||||
}
|
||||
})
|
||||
|
|
@ -513,12 +497,9 @@ pub fn handle(pid: PID, tid: TID, call: SysCall) -> core::result::Result<xous::R
|
|||
Ok(xous::Result::Ok)
|
||||
})
|
||||
}
|
||||
SysCall::SendMessage(cid, message) => {
|
||||
send_message(pid, tid, cid, message)
|
||||
}
|
||||
SysCall::SendMessage(cid, message) => send_message(pid, tid, cid, message),
|
||||
SysCall::TerminateProcess => SystemServices::with_mut(|ss| {
|
||||
let context_nr = ss.current_context_nr(pid);
|
||||
ss.switch_from(pid, context_nr, false)?;
|
||||
ss.switch_from(pid, tid, false)?;
|
||||
let ppid = ss.terminate_process(pid)?;
|
||||
if cfg!(baremetal) {
|
||||
ss.switch_to(ppid, None)
|
||||
|
|
|
|||
Loading…
Reference in a new issue