From 96c5739cdd46f0897b4ab262a7167bfae61b10bd Mon Sep 17 00:00:00 2001 From: Sean Cross Date: Sun, 30 Aug 2020 01:17:35 +0800 Subject: [PATCH] kernel: fix remaining warnings This fixes all remaining warnings in the kernel. For now. Signed-off-by: Sean Cross --- kernel/src/arch/hosted/irq.rs | 4 --- kernel/src/arch/riscv/process.rs | 3 +- kernel/src/args.rs | 3 +- kernel/src/mem.rs | 2 ++ kernel/src/services.rs | 49 +++++++++++++++++--------------- 5 files changed, 31 insertions(+), 30 deletions(-) diff --git a/kernel/src/arch/hosted/irq.rs b/kernel/src/arch/hosted/irq.rs index b02181dc2..f7f89da2d 100644 --- a/kernel/src/arch/hosted/irq.rs +++ b/kernel/src/arch/hosted/irq.rs @@ -12,10 +12,6 @@ pub fn enable_irq(_irq_no: usize) { unimplemented!(); } -pub fn disable_irq(_irq_no: usize) -> Result<(), xous_kernel::Error> { - Err(xous_kernel::Error::UnhandledSyscall) -} - pub unsafe fn take_isr_return_pair() -> Option<(PID, TID)> { unimplemented!() } diff --git a/kernel/src/arch/riscv/process.rs b/kernel/src/arch/riscv/process.rs index dd83926a7..5a5d8e04c 100644 --- a/kernel/src/arch/riscv/process.rs +++ b/kernel/src/arch/riscv/process.rs @@ -237,7 +237,7 @@ impl Process { /// Initialize this process thread with the given entrypoint and stack /// addresses. - pub fn setup_process(pid: PID, thread_init: ThreadInit) { + pub fn setup_process(pid: PID, thread_init: ThreadInit) -> Result<(), xous_kernel::Error> { let mut process = unsafe { &mut *PROCESS }; let tid = INITIAL_TID; @@ -313,6 +313,7 @@ impl Process { .expect("couldn't reserve stack") }); } + Ok(()) } pub fn setup_thread(&mut self, new_tid: TID, setup: ThreadInit) -> Result<(), xous_kernel::Error> { diff --git a/kernel/src/args.rs b/kernel/src/args.rs index dcbc81bbf..cd95bbb82 100644 --- a/kernel/src/args.rs +++ b/kernel/src/args.rs @@ -22,13 +22,12 @@ pub struct KernelArgumentsIterator { offset: usize, } +#[allow(dead_code)] impl KernelArguments { - #[allow(dead_code)] pub fn get() -> Self { KernelArguments { base: unsafe { KERNEL_ARGUMENTS_BASE } } } - #[allow(dead_code)] pub unsafe fn init(base: *const u32) { KERNEL_ARGUMENTS_BASE = base; } diff --git a/kernel/src/mem.rs b/kernel/src/mem.rs index 63e9a0704..0d12d5c7e 100644 --- a/kernel/src/mem.rs +++ b/kernel/src/mem.rs @@ -46,7 +46,9 @@ impl fmt::Display for MemoryRangeExtra { pub struct MemoryManager { ram_start: usize, ram_size: usize, + #[allow(dead_code)] ram_name: u32, + #[allow(dead_code)] last_ram_page: usize, } diff --git a/kernel/src/services.rs b/kernel/src/services.rs index 8360a14c5..ecf3ac0d5 100644 --- a/kernel/src/services.rs +++ b/kernel/src/services.rs @@ -43,6 +43,7 @@ pub enum ProcessState { /// This is a brand-new process that hasn't been run yet, and needs its /// initial context set up. + #[allow(dead_code)] Setup(ThreadInit), /// This process is able to be run. The context bitmask describes contexts @@ -322,7 +323,7 @@ impl SystemServices { // Set up our handle with a bogus sp and pc. These will get updated // once a context switch _away_ from the kernel occurs, however we need // to make sure other fields such as "thread number" are all valid. - ArchProcess::setup_process(PID::new(1).unwrap(), ThreadInit::default()); + ArchProcess::setup_process(PID::new(1).unwrap(), ThreadInit::default()).expect("couldn't setup process"); } /// Add a new entry to the process table. This results in a new address space @@ -446,16 +447,16 @@ impl SystemServices { Ok(()) } - #[cfg(not(baremetal))] - pub fn make_callback_to( - &mut self, - _pid: PID, - _pc: *const usize, - _irq_no: usize, - _arg: *mut usize, - ) -> Result<(), xous_kernel::Error> { - Err(xous_kernel::Error::UnhandledSyscall) - } + // #[cfg(not(baremetal))] + // pub fn make_callback_to( + // &mut self, + // _pid: PID, + // _pc: *const usize, + // _irq_no: usize, + // _arg: *mut usize, + // ) -> Result<(), xous_kernel::Error> { + // Err(xous_kernel::Error::UnhandledSyscall) + // } /// Create a stack frame in the specified process and jump to it. /// 1. Pause the current process and switch to the new one @@ -854,7 +855,8 @@ impl SystemServices { new.state = match new.state { ProcessState::Setup(thread_init) => { println!("Setting up new process..."); - ArchProcess::setup_process(new_pid, thread_init); + ArchProcess::setup_process(new_pid, thread_init) + .expect("couldn't set up new process"); ProcessState::Running(0) } @@ -899,16 +901,16 @@ impl SystemServices { previous_pid, other ), }; - // if advance_thread { - // previous.current_thread += 1; - // if previous.current_thread as TID > arch::process::MAX_CONTEXT { - // previous.current_thread = 0; - // } - // } - // println!( - // "Set previous process PID {} state to {:?} (with can_resume = {})", - // previous_pid, previous.state, can_resume - // ); + // if advance_thread { + // previous.current_thread += 1; + // if previous.current_thread as TID > arch::process::MAX_CONTEXT { + // previous.current_thread = 0; + // } + // } + // println!( + // "Set previous process PID {} state to {:?} (with can_resume = {})", + // previous_pid, previous.state, can_resume + // ); } else { // if self.current_thread(previous_pid) == new_tid { // if !can_resume { @@ -1367,7 +1369,8 @@ impl SystemServices { for (server_idx, server) in self.servers.iter().enumerate() { if let Some(allocated_server) = server { if allocated_server.sid == sid { - process_inner.connection_map[slot_idx] = Some(NonZeroU8::new((server_idx as u8) + 2).unwrap()); + process_inner.connection_map[slot_idx] = + Some(NonZeroU8::new((server_idx as u8) + 2).unwrap()); // println!( // "KERNEL({}): New connection to {:?}. After connection, process connection map is: {:?}", // _pid.get(),