mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-21 09:14:34 +00:00
kernel: silence warnings and remove excess prints
These prints were used to debug errors in the new process switching architecture. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
1730cb377b
commit
85522602ea
6 changed files with 21 additions and 59 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::arch::current_pid;
|
use crate::arch::current_pid;
|
||||||
use crate::arch::mem::MemoryMapping;
|
use crate::arch::mem::MemoryMapping;
|
||||||
use crate::arch::process::ProcessHandle;
|
use crate::arch::process::ProcessHandle;
|
||||||
use crate::mem::{MemoryManagerHandle, PAGE_SIZE};
|
use crate::mem::MemoryManagerHandle;
|
||||||
use crate::services::{ProcessContext, ProcessState, SystemServicesHandle, RETURN_FROM_ISR};
|
use crate::services::{ProcessContext, ProcessState, SystemServicesHandle, RETURN_FROM_ISR};
|
||||||
use riscv::register::{scause, sepc, sie, sstatus, stval, vexriscv::sim, vexriscv::sip};
|
use riscv::register::{scause, sepc, sie, sstatus, stval, vexriscv::sim, vexriscv::sip};
|
||||||
use xous::{SysCall, PID};
|
use xous::{SysCall, PID};
|
||||||
|
|
@ -108,6 +108,7 @@ pub extern "C" fn trap_handler(
|
||||||
|
|
||||||
println!("Result: {:?}", response);
|
println!("Result: {:?}", response);
|
||||||
let mut process = ProcessHandle::get();
|
let mut process = ProcessHandle::get();
|
||||||
|
let ctx = process.current_context();
|
||||||
|
|
||||||
// If we're resuming a process that was previously sleeping, restore the context.
|
// If we're resuming a process that was previously sleeping, restore the context.
|
||||||
// Otherwise, keep the context the same but pass the return values in 8 return
|
// Otherwise, keep the context the same but pass the return values in 8 return
|
||||||
|
|
@ -173,7 +174,6 @@ pub extern "C" fn trap_handler(
|
||||||
|
|
||||||
if let Some(previous_pid) = PREVIOUS_PID.take() {
|
if let Some(previous_pid) = PREVIOUS_PID.take() {
|
||||||
// Switch to the previous process' address space.
|
// Switch to the previous process' address space.
|
||||||
println!("<<< Resuming previous pid {}", previous_pid);
|
|
||||||
SystemServicesHandle::get()
|
SystemServicesHandle::get()
|
||||||
.resume_pid(previous_pid, ProcessState::Ready)
|
.resume_pid(previous_pid, ProcessState::Ready)
|
||||||
.expect("unable to resume previous PID");
|
.expect("unable to resume previous PID");
|
||||||
|
|
@ -200,10 +200,8 @@ pub extern "C" fn trap_handler(
|
||||||
PREVIOUS_PID = Some(pid);
|
PREVIOUS_PID = Some(pid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
println!(">>> HANDLING IRQ {:08x} (current PID: {})", irqs_pending, pid);
|
|
||||||
crate::irq::handle(irqs_pending).expect("Couldn't handle IRQ");
|
crate::irq::handle(irqs_pending).expect("Couldn't handle IRQ");
|
||||||
let mut process = ProcessHandle::get();
|
let mut process = ProcessHandle::get();
|
||||||
println!(">>> returning to pid {}", current_pid());
|
|
||||||
crate::arch::syscall::resume(current_pid() == 1, process.trap_context());
|
crate::arch::syscall::resume(current_pid() == 1, process.trap_context());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,13 +118,6 @@ impl ProcessContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// How many people have checked out the handle object.
|
|
||||||
/// This should be replaced by an AtomicUsize when we get
|
|
||||||
/// multicore support.
|
|
||||||
/// For now, we can get away with this since the memory manager
|
|
||||||
/// should only be accessed in an IRQ context.
|
|
||||||
static mut PROCESS_HANDLE_COUNT: usize = 0;
|
|
||||||
|
|
||||||
pub struct ProcessHandle<'a> {
|
pub struct ProcessHandle<'a> {
|
||||||
process: &'a mut Process,
|
process: &'a mut Process,
|
||||||
}
|
}
|
||||||
|
|
@ -134,25 +127,12 @@ pub struct ProcessHandle<'a> {
|
||||||
impl<'a> ProcessHandle<'a> {
|
impl<'a> ProcessHandle<'a> {
|
||||||
/// Get the singleton Process.
|
/// Get the singleton Process.
|
||||||
pub fn get() -> ProcessHandle<'a> {
|
pub fn get() -> ProcessHandle<'a> {
|
||||||
let count = unsafe {
|
|
||||||
PROCESS_HANDLE_COUNT += 1;
|
|
||||||
PROCESS_HANDLE_COUNT - 1
|
|
||||||
};
|
|
||||||
// if count != 0 {
|
|
||||||
// panic!("Multiple users of ProcessHandle!");
|
|
||||||
// }
|
|
||||||
ProcessHandle {
|
ProcessHandle {
|
||||||
process: unsafe { &mut *PROCESS },
|
process: unsafe { &mut *PROCESS },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for ProcessHandle<'_> {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
unsafe { PROCESS_HANDLE_COUNT -= 1 };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
use core::ops::{Deref, DerefMut};
|
use core::ops::{Deref, DerefMut};
|
||||||
impl Deref for ProcessHandle<'_> {
|
impl Deref for ProcessHandle<'_> {
|
||||||
type Target = Process;
|
type Target = Process;
|
||||||
|
|
|
||||||
|
|
@ -35,11 +35,11 @@ pub fn resume(supervisor: bool, context: &ProcessContext) -> ! {
|
||||||
// Return to the appropriate CPU mode
|
// Return to the appropriate CPU mode
|
||||||
set_supervisor(supervisor);
|
set_supervisor(supervisor);
|
||||||
|
|
||||||
println!(
|
// println!(
|
||||||
"Switching to PID {}, SP: {:08x}, PC: {:08x}",
|
// "Switching to PID {}, SP: {:08x}, PC: {:08x}",
|
||||||
crate::arch::current_pid(),
|
// crate::arch::current_pid(),
|
||||||
context.registers[1],
|
// context.registers[1],
|
||||||
context.sepc,
|
// context.sepc,
|
||||||
);
|
// );
|
||||||
unsafe { _xous_resume_context(context.registers.as_ptr()) };
|
unsafe { _xous_resume_context(context.registers.as_ptr()) };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -160,6 +160,7 @@ impl MemoryManager {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
pub fn print_ownership(&self) {
|
pub fn print_ownership(&self) {
|
||||||
println!("Ownership ({} bytes in all):", self.allocations.len());
|
println!("Ownership ({} bytes in all):", self.allocations.len());
|
||||||
|
|
||||||
|
|
@ -207,19 +208,6 @@ impl MemoryManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn bzero<T>(&self, mut sbss: *mut T, ebss: *mut T)
|
|
||||||
where
|
|
||||||
T: Copy,
|
|
||||||
{
|
|
||||||
use core::ptr;
|
|
||||||
println!("ZERO: {:08x} - {:08x}", sbss as usize, ebss as usize);
|
|
||||||
while sbss < ebss {
|
|
||||||
// NOTE(volatile) to prevent this from being transformed into `memclr`
|
|
||||||
ptr::write_volatile(sbss, mem::zeroed());
|
|
||||||
sbss = sbss.offset(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Allocate a single page to the given process.
|
/// Allocate a single page to the given process.
|
||||||
/// DOES NOT ZERO THE PAGE!!!
|
/// DOES NOT ZERO THE PAGE!!!
|
||||||
/// This function CANNOT zero the page, as it hasn't been mapped yet.
|
/// This function CANNOT zero the page, as it hasn't been mapped yet.
|
||||||
|
|
|
||||||
|
|
@ -304,16 +304,6 @@ impl SystemServices {
|
||||||
pid as PID
|
pid as PID
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn current_process(&self) -> Result<&Process, xous::Error> {
|
|
||||||
let pid = self.current_pid();
|
|
||||||
self.get_process(pid)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn current_process_mut(&mut self) -> Result<&mut Process, xous::Error> {
|
|
||||||
let pid = self.current_pid();
|
|
||||||
self.get_process_mut(pid)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Create a stack frame in the specified process and jump to it.
|
/// Create a stack frame in the specified process and jump to it.
|
||||||
/// 1. Pause the current process and switch to the new one
|
/// 1. Pause the current process and switch to the new one
|
||||||
/// 2. Save the process state, if it hasn't already been saved
|
/// 2. Save the process state, if it hasn't already been saved
|
||||||
|
|
@ -414,10 +404,10 @@ impl SystemServices {
|
||||||
|
|
||||||
// Mark the previous process as ready to run, since we just switched away
|
// Mark the previous process as ready to run, since we just switched away
|
||||||
{
|
{
|
||||||
println!(
|
// println!(
|
||||||
"Marking previous process {} as {:?}",
|
// "Marking previous process {} as {:?}",
|
||||||
previous_pid, previous_state
|
// previous_pid, previous_state
|
||||||
);
|
// );
|
||||||
self.get_process_mut(previous_pid)
|
self.get_process_mut(previous_pid)
|
||||||
.expect("couldn't get previous pid")
|
.expect("couldn't get previous pid")
|
||||||
.state = previous_state;
|
.state = previous_state;
|
||||||
|
|
@ -436,7 +426,7 @@ impl SystemServices {
|
||||||
|
|
||||||
/// Allocate a new server ID for this process and return the address.
|
/// Allocate a new server ID for this process and return the address.
|
||||||
/// If the server table is full, return an error.
|
/// If the server table is full, return an error.
|
||||||
pub fn create_server(&mut self) -> Result<SID, xous::Error> {
|
pub fn create_server(&mut self, name: usize) -> Result<SID, xous::Error> {
|
||||||
for entry in self.servers.iter_mut() {
|
for entry in self.servers.iter_mut() {
|
||||||
if entry.state == ServerState::Free {
|
if entry.state == ServerState::Free {
|
||||||
let pid = self.pid;
|
let pid = self.pid;
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
use crate::arch;
|
use crate::arch;
|
||||||
|
use crate::arch::process::ProcessHandle;
|
||||||
use crate::irq::interrupt_claim;
|
use crate::irq::interrupt_claim;
|
||||||
use crate::mem::{MemoryManagerHandle, PAGE_SIZE};
|
use crate::mem::{MemoryManagerHandle, PAGE_SIZE};
|
||||||
use crate::services::{ProcessState, SystemServicesHandle};
|
use crate::services::{ProcessState, SystemServicesHandle};
|
||||||
use crate::arch::process::ProcessHandle;
|
|
||||||
use xous::*;
|
use xous::*;
|
||||||
|
|
||||||
// extern "Rust" {
|
// extern "Rust" {
|
||||||
|
|
@ -227,6 +227,12 @@ pub fn handle(call: SysCall) -> xous::Result {
|
||||||
.map(|_| xous::Result::ResumeProcess)
|
.map(|_| xous::Result::ResumeProcess)
|
||||||
.unwrap_or(xous::Result::Error(xous::Error::ProcessNotFound))
|
.unwrap_or(xous::Result::Error(xous::Error::ProcessNotFound))
|
||||||
}
|
}
|
||||||
|
SysCall::CreateServer(name) => {
|
||||||
|
let mut ss = SystemServicesHandle::get();
|
||||||
|
ss.create_server(name)
|
||||||
|
.map(|x| xous::Result::ServerID(x))
|
||||||
|
.unwrap_or_else(|e| xous::Result::Error(e))
|
||||||
|
}
|
||||||
_ => xous::Result::Error(xous::Error::UnhandledSyscall),
|
_ => xous::Result::Error(xous::Error::UnhandledSyscall),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue